mirror of https://github.com/dirtbags/moth.git
sort category listing
This commit is contained in:
parent
7662a67ca4
commit
6902af3db0
|
@ -8,17 +8,23 @@ function loadPuzzle(cat, id, points) {
|
||||||
function puzzlesRefresh(term, obj) {
|
function puzzlesRefresh(term, obj) {
|
||||||
term.clear();
|
term.clear();
|
||||||
|
|
||||||
for (var cat in obj) {
|
let cats = [];
|
||||||
var puzzles = obj[cat];
|
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';
|
pdiv.className = 'category';
|
||||||
|
|
||||||
var h = createElement('h2');
|
let h = createElement('h2');
|
||||||
pdiv.appendChild(h);
|
pdiv.appendChild(h);
|
||||||
h.textContent = cat;
|
h.textContent = cat;
|
||||||
|
|
||||||
var l = createElement('ul');
|
let l = createElement('ul');
|
||||||
pdiv.appendChild(l);
|
pdiv.appendChild(l);
|
||||||
|
|
||||||
for (var puzzle of puzzles) {
|
for (var puzzle of puzzles) {
|
||||||
|
@ -28,7 +34,7 @@ function puzzlesRefresh(term, obj) {
|
||||||
var i = createElement('li');
|
var i = createElement('li');
|
||||||
l.appendChild(i);
|
l.appendChild(i);
|
||||||
|
|
||||||
if (points == 0) {
|
if (points === 0) {
|
||||||
i.textContent = "‡";
|
i.textContent = "‡";
|
||||||
} else {
|
} else {
|
||||||
var a = createElement('a');
|
var a = createElement('a');
|
||||||
|
|
Loading…
Reference in New Issue