Code: Select all
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>newLISP 10.5.7 compiled to JavaScript</title>
<style type="text/css" media="screen">
.emscripten {
padding-right: 0; margin-left: auto; margin-right: auto; display: block;
}
.button {
color: #AA0000;
font-size: 110%;
}
textarea {
font-family: Andale Mono, "Bitstream Vera Sans Mono", Monaco, Courier;
font-size: 15px;
width: 100%;
}
body, p {
font-family: Lucida Sans, Helvetica, sans-serif;
}
</style>
</head>
<body>
<div class="emscripten" id="status">Downloading...</div>
<div class="emscripten">
<progress value="0" max="100" id="progress" hidden=1></progress>
</div>
<p>Input <input type="button" value="eval" class="button" id="evalinput"
onclick="newlispEvalStr(document.getElementById('input').value.trim())" disabled>
<input type="button" value="clear" id="clearinput" class="button"
onclick="document.getElementById('input').value = '';" disabled><br><br>
<textarea class="emscripten" id="input" rows="14" disabled>;
; wait for "Downloading ..." to finish, then click eval
;
(println "Hello World")
;; up to 1023 characters can be passed to string in eval-string-js
;; no limit on size of returned string
(eval-string-js "window.prompt('Enter some text:','')")
</textarea></p>
<p>Output <input type="button" value="clear" class="button" id="clearoutput"
onclick="document.getElementById('output').value = '';" disabled><br><br>
<textarea class="emscripten" id="output" rows="12" disabled></textarea></p>
<script type='text/javascript'>
// download newlisp-js-lib.js and show progress of downloading
var Module = {
preRun: [],
postRun: [(function() {
newlispEvalStr = Module.cwrap('newlispEvalStr', 'number', ['string']); })],
print: (function() {
var element = document.getElementById('output');
element.value = ''; // clear browser cache
return function(text) {
text = Array.prototype.slice.call(arguments).join(' ');
element.value += text + "\n";
element.scrollTop = 99999; // focus on bottom
};
})(),
printErr: function(text) {
text = Array.prototype.slice.call(arguments).join(' ');
if (0) { // XXX disabled for safety typeof dump == 'function') {
dump(text + '\n'); // fast, straight to the real console
} else {
console.log(text);
}
},
setStatus: function(text) {
if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
if (text === Module.setStatus.text) return;
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
var now = Date.now();
if (m && now - Date.now() < 30) return; // if progress update, skip it if too soon
var statusElement = document.getElementById('status');
var progressElement = document.getElementById('progress');
if (m) {
text = m[1];
progressElement.value = parseInt(m[2])*100;
progressElement.max = parseInt(m[4])*100;
progressElement.hidden = false;
} else {
progressElement.value = null;
progressElement.max = null;
progressElement.hidden = true;
document.getElementById('evalinput').disabled = false;
document.getElementById('clearinput').disabled = false;
document.getElementById('clearoutput').disabled = false;
document.getElementById('input').disabled = false;
document.getElementById('output').disabled = false;
}
statusElement.innerHTML = text;
},
totalDependencies: 0,
monitorRunDependencies: function(left) {
this.totalDependencies = Math.max(this.totalDependencies, left);
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) +
'/' + this.totalDependencies + ')' : 'All downloads complete.');
}
};
Module.setStatus('Downloading...');
</script>
<script async type="text/javascript" src="newlisp-js-lib.js"></script>
<center>
<font size="-1">Copyright © 2014, <a href="http://newlisp.org">newlisp.org</a></font>
</center>
</body>
</html>
<!-- eof -->