games / htmlrunner.html
Cyranicus's picture
Update htmlrunner.html
d7b5124
raw
history blame
2.19 kB
<!DOCTYPE html>
<html>
<head>
<title>Just A Test</title>
<style>
body: {
background-color: white;
}
</style>
<script>
function handleFileSelect(event) {
const file = event.target.files[0];
const reader = new FileReader();
reader.onload = function(e) {
const htmlContent = e.target.result;
const iframe = document.getElementById('output');
iframe.srcdoc = htmlContent;
};
reader.readAsText(file);
}
function toggleFullscreen() {
var iframe = document.getElementById('output');
if (iframe.requestFullscreen) {
if (document.fullscreenElement) {
document.exitFullscreen();
} else {
iframe.requestFullscreen();
}
} else if (iframe.mozRequestFullScreen) { // Firefox
if (document.mozFullScreenElement) {
document.mozCancelFullScreen();
} else {
iframe.mozRequestFullScreen();
}
} else if (iframe.webkitRequestFullscreen) { // Chrome, Safari, and Opera
if (document.webkitFullscreenElement) {
document.webkitExitFullscreen();
} else {
iframe.webkitRequestFullscreen();
}
} else if (iframe.msRequestFullscreen) { // IE/Edge
if (document.msFullscreenElement) {
document.msExitFullscreen();
} else {
iframe.msRequestFullscreen();
}
}
}
</script>
</head>
<body>
<h1>Upload and Run HTML File</h1>
<p>
(If it isn't working press TAB)
</p>
<input type="file" accept=".html" onchange="handleFileSelect(event)"><br><button onclick="toggleFullscreen()">Toggle Fullscreen</button>
<br>
<iframe id="output" width="100%" height="1000px"></iframe>
</body>
<script>
document.querySelector('#fileInput').addEventListener('change', handleFile,false)
function handleFile(e){
var reader = new FileReader;
var file = e.target.files[0]
reader.onload = function(e){
var csv = e.target.result
// execute chart code in here with
// "csv":{
// "data-string": csv,
// ...
// }
}
reader.readAsText(file);
}
</script>
</html>