Added python stuff
This commit is contained in:
52
skulpt.html
Normal file
52
skulpt.html
Normal file
@@ -0,0 +1,52 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="http://skulpt.org/js/skulpt.min.js"></script>
|
||||
<script src="http://skulpt.org/js/skulpt-stdlib.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
let cb;
|
||||
|
||||
function outf(t) {
|
||||
document.getElementById("output").innerHTML += t;
|
||||
}
|
||||
|
||||
function inputf(prompt) {
|
||||
document.getElementById("promptLbl").textContent = prompt;
|
||||
const box = document.getElementById("inpBox");
|
||||
document.getElementById("inpC").style.display = "block";
|
||||
box.value = "";
|
||||
box.focus();
|
||||
return new Promise(r => cb = r);
|
||||
}
|
||||
|
||||
function submitInput() {
|
||||
const box = document.getElementById("inpBox");
|
||||
document.getElementById("inpC").style.display = "none";
|
||||
cb(box.value);
|
||||
}
|
||||
|
||||
function runit() {
|
||||
document.getElementById("output").innerHTML = "";
|
||||
document.getElementById("inpC").style.display = "none";
|
||||
Sk.configure({
|
||||
output: outf,
|
||||
read: x => Sk.builtinFiles.files[x],
|
||||
inputfun: inputf,
|
||||
inputfunTakesPrompt: true
|
||||
});
|
||||
Sk.misceval.asyncToPromise(() => Sk.importMainWithBody(" < stdin > ", false, document.getElementById("yourcode").value, true));
|
||||
}
|
||||
</script>
|
||||
<textarea id="yourcode" cols="40" rows="6">name = raw_input("Name: ")
|
||||
print "Hello, " + name
|
||||
</textarea>
|
||||
<button onclick="runit()">Run</button>
|
||||
<pre id="output"></pre>
|
||||
<div id="inpC" style="display:none;">
|
||||
<label id="promptLbl"></label>
|
||||
<input id="inpBox" onkeypress="event.key==='Enter' && submitInput()">
|
||||
<button onclick="submitInput()">OK</button>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user