diff --git a/salam-online.html b/salam-online.html index 8457950..7a4bdaf 100644 --- a/salam-online.html +++ b/salam-online.html @@ -86,4 +86,4 @@

تنظیمات

- \ No newline at end of file + diff --git a/salam-wa.wasm b/salam-wa.wasm index 08a3489..ce1ded5 100644 Binary files a/salam-wa.wasm and b/salam-wa.wasm differ diff --git a/script/script.js b/script/script.js index 5006ef5..d9bab6b 100644 --- a/script/script.js +++ b/script/script.js @@ -131,6 +131,25 @@ const showErrorInIframe = () => { } }; +const captureLint = (arguments) => { + console.log("Capture Lint: ", arguments); + + elm_output.textContent = ''; + elm_error.textContent = ''; + + try { + const exitCode = callMain(arguments); + + if (exitCode !== 0) { + return null; + } else { + return elm_output.textContent; + } + } catch (err) { + return null; + } +}; + const captureOutput = (showOutput, arguments) => { console.log("Capture Output: ", arguments); @@ -163,22 +182,43 @@ const captureOutput = (showOutput, arguments) => { } }; -const runSalam = (showOutput) => { - console.log('Running Salam code...'); +const runLint = () => { + console.log('Running Salam lint...'); + + if (!isReady) { + console.log('Salam runtime not ready. Please wait...'); + return; + } const code = elm_code.value.toString().trim(); if (!code) { - alert('Code is empty! Please enter Salam code.'); return; } - const arguments = ['code', code]; + const arguments = ['lint', 'code', code]; + + const res = captureLint(arguments); + if (res !== null) { + elm_code.value = res; + } +}; + +const runSalam = (showOutput) => { + console.log('Running Salam code...'); if (!isReady) { console.log('Salam runtime not ready. Please wait...'); return; } + const code = elm_code.value.toString().trim(); + if (!code) { + alert('Code is empty! Please enter Salam code.'); + return; + } + + const arguments = ['code', code]; + captureOutput(showOutput, arguments); };