2018-09-18 18:22:03 -06:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Open Puzzles</title>
|
|
|
|
<link rel="stylesheet" href="basic.css">
|
|
|
|
<meta name="viewport" content="width=device-width">
|
2018-10-02 08:07:58 -06:00
|
|
|
<link rel="icon" href="images/luna-moth.svg" type="image/svg+xml">
|
|
|
|
<link rel="icon" href="images/luna-moth.png" type="image/png">
|
2018-09-18 18:22:03 -06:00
|
|
|
<script>
|
|
|
|
|
|
|
|
function render(obj) {
|
|
|
|
puzzlesElement = document.createElement('div');
|
|
|
|
let cats = [];
|
|
|
|
for (let cat in obj) {
|
|
|
|
cats.push(cat);
|
|
|
|
console.log(cat);
|
|
|
|
}
|
|
|
|
cats.sort();
|
|
|
|
|
|
|
|
for (let cat of cats) {
|
|
|
|
let puzzles = obj[cat];
|
|
|
|
|
|
|
|
let pdiv = document.createElement('div');
|
|
|
|
pdiv.className = 'category';
|
|
|
|
|
|
|
|
let h = document.createElement('h2');
|
|
|
|
pdiv.appendChild(h);
|
|
|
|
h.textContent = cat;
|
|
|
|
|
|
|
|
let l = document.createElement('ul');
|
|
|
|
pdiv.appendChild(l);
|
|
|
|
|
|
|
|
for (var puzzle of puzzles) {
|
|
|
|
var points = puzzle[0];
|
|
|
|
var id = puzzle[1];
|
|
|
|
|
|
|
|
var i = document.createElement('li');
|
2018-10-02 08:42:55 -06:00
|
|
|
i.textContent = " ";
|
2018-09-18 18:22:03 -06:00
|
|
|
l.appendChild(i);
|
|
|
|
|
|
|
|
if (points === 0) {
|
2018-09-19 17:56:26 -06:00
|
|
|
i.textContent = "✿";
|
2018-09-18 18:22:03 -06:00
|
|
|
} else {
|
|
|
|
var a = document.createElement('a');
|
|
|
|
i.appendChild(a);
|
|
|
|
a.textContent = points;
|
2018-09-19 17:56:26 -06:00
|
|
|
a.href = "puzzle.html?cat=" + cat + "&points=" + points + "&pid=" + id;
|
2018-09-18 18:22:03 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
puzzlesElement.appendChild(pdiv);
|
|
|
|
document.getElementById("puzzles").appendChild(puzzlesElement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function init() {
|
|
|
|
fetch("puzzles.json")
|
|
|
|
.then(function(resp) {
|
|
|
|
return resp.json();
|
|
|
|
}).then(function(obj) {
|
|
|
|
render(obj);
|
|
|
|
}).catch(function(err) {
|
|
|
|
console.log("Error", err);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
document.addEventListener("DOMContentLoaded", init);
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h1 class="Success">Open Puzzles</h1>
|
|
|
|
<section>
|
|
|
|
<div id="puzzles"></div>
|
|
|
|
</section>
|
|
|
|
<nav>
|
|
|
|
<ul>
|
2018-09-19 17:56:26 -06:00
|
|
|
<li><a href="puzzle-list.html">Puzzles</a></li>
|
2018-09-18 18:22:03 -06:00
|
|
|
<li><a href="scoreboard.html">Scoreboard</a></li>
|
2018-10-02 07:44:31 -06:00
|
|
|
<li><a href="scoring.html">Scoring</a></li>
|
2018-10-02 08:23:35 -06:00
|
|
|
<li><a href="credits.html">Credits</a></li>
|
2018-09-18 18:22:03 -06:00
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
</body>
|
|
|
|
</html>
|