Skip to content
This repository has been archived by the owner on Nov 29, 2024. It is now read-only.

Commit

Permalink
refactor(clean): clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
tikrack committed Sep 11, 2024
2 parents 664a6eb + 7464d4a commit 6774067
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
2 changes: 1 addition & 1 deletion salam-online.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ <h1>تنظیمات</h1>
<script src="script/script.js"></script>
</body>

</html>
</html>
Binary file modified salam-wa.wasm
Binary file not shown.
48 changes: 44 additions & 4 deletions script/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
};

Expand Down

0 comments on commit 6774067

Please sign in to comment.