sort category listing

This commit is contained in:
Neale Pickett 2017-11-10 00:50:30 +00:00
parent ae028eb4ec
commit b0a79c9406
1 changed files with 47 additions and 41 deletions

View File

@ -8,17 +8,23 @@ function loadPuzzle(cat, id, points) {
function puzzlesRefresh(term, obj) {
term.clear();
for (var cat in obj) {
var puzzles = obj[cat];
let cats = [];
for (let cat in obj) {
cats.push(cat);
}
cats.sort();
var pdiv = createElement('div');
for (let cat of cats) {
let puzzles = obj[cat];
let pdiv = createElement('div');
pdiv.className = 'category';
var h = createElement('h2');
let h = createElement('h2');
pdiv.appendChild(h);
h.textContent = cat;
var l = createElement('ul');
let l = createElement('ul');
pdiv.appendChild(l);
for (var puzzle of puzzles) {
@ -28,7 +34,7 @@ function puzzlesRefresh(term, obj) {
var i = createElement('li');
l.appendChild(i);
if (points == 0) {
if (points === 0) {
i.textContent = "‡";
} else {
var a = createElement('a');