const flask = getEditor("#code", "js")
let consoleElmt = document.getElementById("console")

function run() {
	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>"
	}
}
