moth/www/res/puzzles.js

46 lines
926 B
JavaScript
Raw Normal View History

2016-04-04 21:45:00 -06:00
var puzzles_terminal;
var puzzles_url = "hack/puzzles.html";
2016-04-03 21:12:48 -06:00
function Puzzles(element) {
var term = new Terminal(element);
2016-04-04 21:45:00 -06:00
var refreshInterval;
function loaded() {
var doc = this.response;
var puzzles = doc.getElementById("puzzles");
var h1 = document.createElement("h1");
h1.textContent = "Puzzles";
2016-04-03 21:12:48 -06:00
term.clear();
2016-04-04 21:45:00 -06:00
term.append(h1);
2016-04-04 22:07:28 -06:00
term.appendShallow(puzzles);
2016-04-04 21:45:00 -06:00
}
function refresh() {
var myRequest = new XMLHttpRequest();
myRequest.responseType = "document";
myRequest.addEventListener("load", loaded);
myRequest.open("GET", puzzles_url);
myRequest.send();
}
function start() {
refreshInterval = setInterval(refresh, 20 * 1000);
refresh();
2016-04-03 21:12:48 -06:00
}
2016-04-04 21:45:00 -06:00
2016-04-04 22:16:22 -06:00
term.clear();
term.par("Loading…");
2016-04-04 21:45:00 -06:00
setTimeout(start, 3000);
2016-04-03 21:12:48 -06:00
}
function puzzles_start() {
2016-04-04 21:45:00 -06:00
puzzles_terminal = new Puzzles(document.getElementById("puzzles"));
2016-04-03 21:12:48 -06:00
}
window.addEventListener("load", puzzles_start);