diff --git a/src/app/glp/page.tsx b/src/app/glp/page.tsx index ff0e903..5275721 100644 --- a/src/app/glp/page.tsx +++ b/src/app/glp/page.tsx @@ -16,16 +16,6 @@ const GlpPage = () => { const tr_hTitle = text(language, 'header_title'); const tr_hSubtitle = text(language, 'header_subtitle'); - // const tr_boxObjTitle = text(language, 'boxObjTitle'); - // const tr_boxObjDesc = text(language, "boxObjDesc"); - // const tr_boxSubjTitle = text(language, 'boxSubjTitle'); - // const tr_boxSubjDesc = text(language, "boxSubjDesc"); - // const tr_boxBoundsTitle = text(language, 'boxBoundsTitle'); - // const tr_boxBoundsDesc = text(language, "boxBoundsDesc"); - // const tr_boxVarsTitle = text(language, 'boxVarsTitle'); - // const tr_boxVarsDesc = text(language, "boxVarsDesc"); - // const tr_boxOut = text(language, "boxOut"); - const tr_boxExportLP = text(language, "boxExportLP"); const tr_calcButton = text(language, "buttonCalc"); const tr_GmplTitle = text(language, 'GmplHeader'); const tr_GenProblems = text(language, 'GenProblem'); @@ -43,11 +33,11 @@ const GlpPage = () => { const [solverTime, setSolverTime] = useState(''); const [showPopup, setShowPopup] = useState(false); const [resultContent, setResultContent] = useState(''); - const [syntaxErrors, setSyntaxErrors] = useState([]); + //const [syntaxErrors, setSyntaxErrors] = useState([]); const [showErrorPopup, setShowErrorPopup] = useState(false); const solverTimeoutRef = useRef(null); const solverAbortController = useRef(null); - const [highlightedContent, setHighlightedContent] = useState(''); + //const [highlightedContent, setHighlightedContent] = useState(''); const [fileName, setFileName] = useState(""); @@ -64,11 +54,11 @@ const GlpPage = () => { } }; - useEffect(() => { - if (syntaxErrors.length > 0) { - setShowErrorPopup(true); - } - }, [syntaxErrors]); + //useEffect(() => { + // if (syntaxErrors.length > 0) { + // setShowErrorPopup(true); + // } + //}, [syntaxErrors]); const addMessage = (message: string) => { const msgZone = document.getElementById("msgZone"); @@ -77,10 +67,10 @@ const GlpPage = () => { } }; - const updateHighlightedContent = (content: string) => { - const highlighted = highlightErrors(content); - setHighlightedContent(highlighted); - }; + // const updateHighlightedContent = (content: string) => { + // const highlighted = highlightErrors(content); + // setHighlightedContent(highlighted); + // }; const handleFileUpload = (event: React.ChangeEvent) => { @@ -94,50 +84,50 @@ const GlpPage = () => { reader.onload = (e) => { const content = e.target?.result as string; setFileContent(content); - updateHighlightedContent(content); + // updateHighlightedContent(content); addMessage("File successfully uploaded and read."); setIsFileUploaded(true); // Perform syntax check - const errors = checkSyntax(content); - setSyntaxErrors(errors); - updateHighlightedContent(content); + //const errors = checkSyntax(content); + //setSyntaxErrors(errors); + // updateHighlightedContent(content); }; reader.readAsText(file); }; - const checkSyntax = (content: string): string[] => { - const errors: string[] = []; - const lines = content.split("\n"); - - const ignorePattern = /^(#|\/\/|printf|\/\*|\*).*$/; - - lines.forEach((line, index) => { - if (ignorePattern.test(line) || line.trim() === "") { - return; // Ignore this line - } - - const validGmplLinePattern = /^(var|param|set|maximize|minimize|s\.t\.|subject to|for|in|if|then|else|end|:=|<=|>=|=|\+|\-|\*|\/|[a-zA-Z_][a-zA-Z0-9_]*\s*[=<>+\-*/]*\s*[0-9a-zA-Z_]+.*;)/; - - if (!validGmplLinePattern.test(line)) { - errors.push(`Syntax error on line ${index + 1}: ${line}`); - } - }); - - return errors; - }; + //const checkSyntax = (content: string): string[] => { + // const errors: string[] = []; + // const lines = content.split("\n"); + // + // const ignorePattern = /^(#|\/\/|printf|\/\*|\*).*$/; + // + // lines.forEach((line, index) => { + // if (ignorePattern.test(line) || line.trim() === "") { + // return; // Ignore this line + // } + // + // const validGmplLinePattern = /^(var|param|set|maximize|minimize|s\.t\.|subject to|for|in|if|then|else|end|:=|<=|>=|=|\+|\-|\*|\/|[a-zA-Z_][a-zA-Z0-9_]*\s*[=<>+\-*/]*\s*[0-9a-zA-Z_]+.*;)/; + // + // if (!validGmplLinePattern.test(line)) { + // errors.push(`Syntax error on line ${index + 1}: ${line}`); + // } + // }); + // + // return errors; + //}; // Highlight syntax errors in the file content - const highlightErrors = (content: string) => { - const lines = content.split("\n"); - return lines.map((line, index) => { - const error = syntaxErrors.find((error) => error.includes(`line ${index + 1}`)); - if (error) { - return `${line}`; - } - return line; - }).join("\n"); - }; + //const highlightErrors = (content: string) => { + // const lines = content.split("\n"); + // return lines.map((line, index) => { + // const error = syntaxErrors.find((error) => error.includes(`line ${index + 1}`)); + // if (error) { + // return `${line}`; + // } + // return line; + // }).join("\n"); + //}; // Function to dynamically set the height of the textarea const getTextAreaHeight = (value: any) => { @@ -231,7 +221,6 @@ const GlpPage = () => { } }; - // Function to download the modified file const downloadFile = () => { const element = document.createElement("a"); const file = new Blob([fileContent], { type: 'text/plain' }); @@ -306,7 +295,7 @@ const GlpPage = () => { value={fileContent} onChange={(e) => { setFileContent(e.target.value); - updateHighlightedContent(e.target.value); + //updateHighlightedContent(e.target.value); }} rows={getTextAreaHeight(fileContent)} /> @@ -326,7 +315,7 @@ const GlpPage = () => {
{solverTime}
{/* Display Solver Time */} - {/* Syntax Errors */} + {/* Syntax Errors {syntaxErrors.length > 0 && (

Syntax Errors

@@ -337,13 +326,15 @@ const GlpPage = () => {
)} + */} - {/* Syntax Error Popup */} + {/* Syntax Error Popup {showErrorPopup && (

There are syntax errors in the file.

)} + */} {/* Result Popup */} {showPopup && ( diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 0542883..a2d1618 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,7 +1,7 @@ import type { Metadata } from "next"; import Image from "next/image"; import localFont from "next/font/local"; -import { LanguageProvider } from './context/LanguageContext'; // Importiere den Provider +import { LanguageProvider } from './context/LanguageContext'; import "./globals.css"; const geistSans = localFont({ @@ -33,8 +33,6 @@ export default function RootLayout({ className={`${geistSans.variable} ${geistMono.variable} antialiased`} > - {children} {} - {children}
+ + );