Add index page and slice project into files

This commit is contained in:
Romain de Laage 2021-04-02 20:52:23 +02:00
parent 271a04fcd7
commit 59cd431132
Signed by: rdelaage
GPG Key ID: 534845FADDF0C329
6 changed files with 120 additions and 99 deletions

47
assets/css/main.css Normal file
View File

@ -0,0 +1,47 @@
html, body {
height: 100%;
}
body {
background: #0A3D62;
font-family: sans-serif;
font-size: 21px;
}
h1 {
color: white;
text-align: center;
}
#codeContainer {
display: block;
width: 80%;
margin: auto;
height: 500px;
}
#code {
position: relative;
height: 100%;
}
#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;
}

8
assets/js/editor.js Normal file
View File

@ -0,0 +1,8 @@
const flask = new CodeFlask('#code', {
language: 'js',
lineNumbers: true,
areaId: 'thing1',
ariaLabelledby: 'header1',
handleTabs: true/*,
defaultTheme: false*/
});

34
assets/js/jspg.js Normal file
View File

@ -0,0 +1,34 @@
let codeElmt = document.getElementById("code")
let consoleElmt = document.getElementById("console")
function run(elmtID) {
console = newConsole
console.clear()
try {
eval(flask.getCode())
}
catch (e) {
console.error(e)
}
console = oldConsole
}
/* Penser à réimplémenter toute la console : https://developer.mozilla.org/fr/docs/Web/API/Console */
const oldConsole = console
const newConsole = {
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>"
},
clear: function () {
consoleElmt.innerHTML = ""
},
error: function (...msg) {
var outMsg = ""
outMsg = msg[0]
for (var i = 1; i < msg.length; i++) outMsg += " " + msg[i]
consoleElmt.innerHTML += "<div class=\"error\">" + outMsg + "</div>"
}
}

View File

@ -1,110 +1,19 @@
<!DOCTYPE html>
<!--
Javascript Playground -
-->
<html lang="fr">
<head>
<title>Javascript Playground</title>
<title>Code Playground</title>
<meta charset="utf-8" />
<script src="codeflask.min.js"></script>
<style>
html, body {
height: 100%;
}
body {
background: #0A3D62;
font-family: sans-serif;
font-size: 21px;
}
#codeContainer {
display: block;
width: 80%;
margin: auto;
height: 500px;
}
#code {
position: relative;
height: 100%;
}
#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>
<link rel="stylesheet" href="assets/css/main.css" type="text/css" />
</head>
<body>
<div id="codeContainer"><div id="code"></div></div>
<input type="button" onclick="run('code')" value="Exécuter !" id="runBtn" />
<div id="console">
</div>
<header>
<h1>Code Playground</h1>
</header>
<ul>
<li><a href="js.html">Javascript</a></li>
</ul>
<footer>
Romain de Laage - CC0
</footer>
<script>
const flask = new CodeFlask('#code', {
language: 'js',
lineNumbers: true,
areaId: 'thing1',
ariaLabelledby: 'header1',
handleTabs: true/*,
defaultTheme: false*/
});
let codeElmt = document.getElementById("code")
let consoleElmt = document.getElementById("console")
function run(elmtID) {
console = newConsole
console.clear()
try {
eval(flask.getCode())
}
catch (e) {
console.error(e)
}
console = oldConsole
}
/* Penser à réimplémenter toute la console : https://developer.mozilla.org/fr/docs/Web/API/Console */
const oldConsole = console
const newConsole = {
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>"
},
clear: function () {
consoleElmt.innerHTML = ""
},
error: function (...msg) {
var outMsg = ""
outMsg = msg[0]
for (var i = 1; i < msg.length; i++) outMsg += " " + msg[i]
consoleElmt.innerHTML += "<div class=\"error\">" + outMsg + "</div>"
}
}
</script>
</body>
</html>

23
js.html Normal file
View File

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<title>Javascript Playground</title>
<meta charset="utf-8" />
<script src="lib/codeflask.min.js"></script>
<link rel="stylesheet" href="assets/css/main.css" type="text/css" />
</head>
<body>
<header>
<h1>Javascript Playground</h1>
</header>
<div id="codeContainer"><div id="code"></div></div>
<input type="button" onclick="run('code')" value="Exécuter !" id="runBtn" />
<div id="console">
</div>
<footer>
Romain de Laage - CC0
</footer>
<script src="assets/js/editor.js"></script>
<script src="assets/js/jspg.js"></script>
</body>
</html>