moth/res/puzzle.html

66 lines
1.9 KiB
HTML
Raw Normal View History

2018-09-19 17:56:47 -06:00
<!DOCTYPE html>
<html>
<head>
<title>Puzzle</title>
<link rel="stylesheet" href="basic.css">
<meta name="viewport" content="width=device-width">
<link rel="icon" href="res/icon.svg" type="image/svg+xml">
<link rel="icon" href="res/icon.png" type="image/png">
<script>
2018-09-21 14:42:38 -06:00
function resize() {
let frame = document.getElementById("body");
frame.height = frame.contentDocument.documentElement.scrollHeight;
}
function render(obj, base) {
let frame = document.getElementById("body");
let html = "<base href='" + base + "'><link rel='stylesheet' href='../../../basic.css'>" + obj.body;
frame.addEventListener("load", resize);
frame.srcdoc = html;
2018-09-19 17:56:47 -06:00
}
function init() {
let params = new URLSearchParams(window.location.search);
let categoryName = params.get("cat");
let points = params.get("points");
let puzzleId = params.get("pid");
2018-09-21 14:42:38 -06:00
let base = "content/" + categoryName + "/" + puzzleId + "/";
let fn = base + "puzzle.json";
2018-09-19 17:56:47 -06:00
fetch(fn)
.then(function(resp) {
return resp.json();
}).then(function(obj) {
2018-09-21 14:42:38 -06:00
render(obj, base);
2018-09-19 17:56:47 -06:00
}).catch(function(err) {
console.log("Error", err);
});
document.querySelector("body > h1").innerText = categoryName + " " + points
document.querySelector("input[name=cat]").value = categoryName;
document.querySelector("input[name=points]").value = points;
}
document.addEventListener("DOMContentLoaded", init);
</script>
</head>
<body>
<h1>Puzzle</h1>
<section>
2018-09-21 14:42:38 -06:00
<iframe seamless id="body">Loading...</iframe>
2018-09-19 17:56:47 -06:00
</section>
<form action="answer" method="post">
<input type="hidden" name="cat">
<input type="hidden" name="points">
Team ID: <input type="text" name="id"> <br>
Answer: <input type="text" name="answer"> <br>
<input type="submit" value="Submit">
</form>
<nav>
<ul>
<li><a href="puzzle-list.html">Puzzles</a></li>
<li><a href="scoreboard.html">Scoreboard</a></li>
</ul>
</nav>
</body>
</html>