Created
November 22, 2016 14:58
-
-
Save Darker/4202e9c45d4386370f9b7adaed8b479d to your computer and use it in GitHub Desktop.
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8"> | |
<meta name="generator" content="PSPad editor, www.pspad.com"> | |
<title>PyPy</title> | |
</head> | |
<body> | |
<h2>Select python file</h2> | |
<input type="file" id="files" name="file" multiple /> | |
<!-- Script to handle file selection --> | |
<script type="text/javascript"> | |
function handleFileSelect(evt) { | |
// clear current list of files | |
FILES = {} | |
// get uploaded file list | |
var files = evt.target.files; // FileList object | |
// Loop through the FileList and render image files as thumbnails. | |
for (var i = 0, f; f = files[i]; i++) { | |
var reader = new FileReader(); | |
// Closure to capture the file information. | |
reader.onload = (function(theFile) { | |
return function(e) { | |
FILES[theFile.name] = e.target.result;//Sk.importMainWithBody("<stdin>", false, e.target.result); | |
}; | |
})(f); | |
// Read in the image file as a data URL. | |
reader.readAsText(f); | |
} | |
} | |
document.getElementById('files').addEventListener('change', handleFileSelect, false); | |
</script> | |
<script src="http://pypyjs.org/pypyjs-release/lib/Promise.min.js" type="text/javascript" charset="utf-8"></script> | |
<script src="http://pypyjs.org/pypyjs-release/lib/FunctionPromise.js" type="text/javascript" charset="utf-8"></script> | |
<script src="http://pypyjs.org/pypyjs-release/lib/pypyjs.js" type="text/javascript" charset="utf-8"></script> | |
<script> | |
// Send all VM output to the console. | |
pypyjs.stdout = pypyjs.stderr = function(data) { | |
console.log("[PYTHON] ", data); | |
} | |
// Display a helpful message and twiddle thumbs as it loads. | |
pypyjs.stdout("Loading PyPy.js.\n\n"); | |
pypyjs.stdout("It's big, so this might take a while..."); | |
pypyjs.ready().then(function() { | |
pypyjs.stdout('Welcome to PyPy.js!\n') ; | |
return pypyjs.repl(function (ps1) { | |
// wtf is this? | |
console.log(ps1); | |
return new Promise(function (resolve, reject) { | |
// if DOM event is raised, the text will go to stdin | |
// provided this is stdin, I mean, the hell I know? | |
function pypy_text(e) { | |
resolve(e.text); | |
window.removeEventListener("pypy_stdin", pypy_text); | |
} | |
window.addEventListener("pypy_stdin", pypy_text); | |
}); | |
}); | |
}).then(null, function(err) { | |
//jqconsole.Reset(); | |
console.error("PyPy failed: ", err); | |
}); | |
// function pypy_stdin(text) { | |
// return pypyjs.ready().then(function() { | |
// var ev = new Event("pypy_stdin", {"bubbles":true, "cancelable":false}); | |
// ev.text = text; | |
// window.dispatchEvent(ev); | |
// }); | |
// } | |
// function addFileToPyPy(name, contents) { | |
// | |
// | |
// } | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment