This repository has been archived by the owner on Nov 29, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f97e64d
commit e84610e
Showing
5 changed files
with
5,319 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +0,0 @@ | ||
# salam/salam-wa.js | ||
# salam/salam-wa.wasm | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<!DOCTYPE html> | ||
<html dir="rtl" lang="fa-IR"> | ||
|
||
<head> | ||
<title>Salam Programming Language</title> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="style/style.css"> | ||
</head> | ||
|
||
<body> | ||
<header> | ||
<button id="execute" disabled="true">اجرا</button> | ||
</header> | ||
<textarea id="code"></textarea> | ||
<iframe></iframe> | ||
<pre></pre> | ||
|
||
<script> | ||
const codeTextArea = document.querySelector('#code'); | ||
const executeButton = document.querySelector('#execute'); | ||
const outputPre = document.querySelector('pre'); | ||
const iframe = document.querySelector('iframe'); | ||
|
||
const args = ['code', '']; | ||
let isReady = false; | ||
|
||
var Module = { | ||
noInitialRun: true, | ||
onRuntimeInitialized: () => { | ||
console.log('Salam loaded successfully'); | ||
isReady = true; | ||
executeButton.disabled = false; | ||
|
||
if (codeTextArea.value.toString().trim() !== '') { | ||
runSalam(); | ||
} | ||
}, | ||
print: (text) => { | ||
console.log(text); | ||
} | ||
}; | ||
|
||
function captureOutput(arguments) { | ||
if(iframe.style.right === "50%"){ | ||
iframe.style.right = "150%" | ||
}else if(iframe.style.right === "150%"){ | ||
iframe.style.right = "50%" | ||
}else { | ||
iframe.style.right = "50%" | ||
} | ||
if (outputPre) { | ||
outputPre.textContent = ''; | ||
} | ||
|
||
let output = ''; | ||
|
||
const originalConsoleLog = console.log; | ||
console.log = function (text) { | ||
output += text + '\n'; | ||
}; | ||
|
||
callMain(arguments); | ||
|
||
console.log = originalConsoleLog; | ||
|
||
if (outputPre) { | ||
outputPre.textContent = output; | ||
|
||
const iframeDocument = iframe.contentDocument || iframe.contentWindow.document; | ||
if (iframeDocument) { | ||
iframeDocument.open(); | ||
iframeDocument.write(output); | ||
iframeDocument.close(); | ||
} | ||
} | ||
|
||
return output; | ||
} | ||
|
||
function runSalam() { | ||
console.log('Running Salam code...'); | ||
const code = codeTextArea.value.toString().trim(); | ||
|
||
if (!code) { | ||
alert('Code is empty! Please enter Salam code.'); | ||
return; | ||
} | ||
|
||
args[1] = code; | ||
console.log('Calling Salam with arguments:', args); | ||
|
||
if (isReady) { | ||
captureOutput(args); | ||
} else { | ||
console.log('Salam runtime not ready. Please wait...'); | ||
} | ||
} | ||
|
||
executeButton.addEventListener('click', () => { | ||
console.log('Button clicked!'); | ||
runSalam(); | ||
}); | ||
|
||
codeTextArea.addEventListener('keydown', (e) => { | ||
if (e.key === 'Tab') { | ||
e.preventDefault(); | ||
const start = codeTextArea.selectionStart; | ||
const end = codeTextArea.selectionEnd; | ||
|
||
codeTextArea.value = codeTextArea.value.substring(0, start) + ' ' + codeTextArea.value.substring(end); | ||
|
||
codeTextArea.selectionStart = codeTextArea.selectionEnd = start + 4; | ||
} | ||
}); | ||
|
||
const script = document.createElement('script'); | ||
script.type = 'text/javascript'; | ||
script.src = 'salam-wa.js'; | ||
document.body.appendChild(script); | ||
</script> | ||
</body> | ||
|
||
</html> |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.