Initial commit
This commit is contained in:
commit
d753ba20c9
|
@ -0,0 +1,86 @@
|
|||
<!DOCTYPE html>
|
||||
<!--
|
||||
Javascript Playground -
|
||||
-->
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<title>Javascript Playground</title>
|
||||
<meta charset="utf-8" />
|
||||
<style>
|
||||
body {
|
||||
background: #0A3D62;
|
||||
font-family: sans-serif;
|
||||
font-size: 21px;
|
||||
}
|
||||
#code {
|
||||
background-color: #3C6382;
|
||||
font-size: 15px;
|
||||
display: block;
|
||||
color: white;
|
||||
border: none;
|
||||
resize: none;
|
||||
width: 80%;
|
||||
margin: auto;
|
||||
height: 500px;
|
||||
}
|
||||
#runBtn {
|
||||
background-color: #079992;
|
||||
color: white;
|
||||
display: block;
|
||||
width: 80%;
|
||||
margin: auto;
|
||||
border: none;
|
||||
margin-top: 10px;
|
||||
line-height: 3rem;
|
||||
}
|
||||
#console {
|
||||
color: white;
|
||||
width: 80%;
|
||||
margin: auto;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.error {
|
||||
background-color: #FF0000;
|
||||
color: white;
|
||||
}
|
||||
footer {
|
||||
font-size: 10px;
|
||||
color: white;
|
||||
margin-top: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<textarea spellcheck="false" id="code"></textarea>
|
||||
<input type="button" onclick="run('code')" value="Exécuter !" id="runBtn" />
|
||||
<div id="console">
|
||||
</div>
|
||||
<footer>
|
||||
Romain de Laage - CC0
|
||||
</footer>
|
||||
<script>
|
||||
let codeElmt = document.getElementById("code")
|
||||
let consoleElmt = document.getElementById("console")
|
||||
|
||||
function run(elmtID) {
|
||||
console.clear()
|
||||
eval(codeElmt.value)
|
||||
}
|
||||
|
||||
window.onerror = function(msg, src, lino, colno, error) {
|
||||
errorElmt.innerHTML += "<div class=\"error\">" + msg + "</div>"
|
||||
}
|
||||
|
||||
/* Penser à réimplémenter toute la console : https://developer.mozilla.org/fr/docs/Web/API/Console */
|
||||
console.log = function (...msg) {
|
||||
var outMsg = ""
|
||||
outMsg += msg[0]
|
||||
for (var i = 1; i < msg.length; i++) outMsg += " " + msg[i]
|
||||
consoleElmt.innerHTML += "\<div class=\"message\">" + outMsg + "</div>"
|
||||
}
|
||||
console.clear = function () {
|
||||
consoleElmt.innerHTML = ""
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue