racket-pkg-website/static/todos.js
2017-07-12 00:14:55 -04:00

49 lines
1.2 KiB
JavaScript

$(function() {
"use strict";
function applyFilter() {
$("table.packages > tbody > tr").each(function() {
var row = this;
if (Number.parseInt($(row).data("todokey"), 10) === 0) {
row.style.display = "none";
}
});
$("table.packages").trigger("sorton", [[[4, 1]]]);
}
function removeFilter() {
$("table.packages > tbody > tr").each(function() {
var row = this;
if (Number.parseInt($(row).data("todokey"), 10) === 0) {
row.style.display = "";
}
});
$("table.packages").trigger("sorton", [[[1, 0]]]);
}
var todoTotal = $("table.packages").data("todokey");
if (todoTotal > 0) {
$("#todo-msg").html(
todoTotal + " todos. " +
"<a style='cursor:pointer' id='filter-pkgs'> Click here to see them.</a>"
);
var filterIsApplied = false;
$("#filter-pkgs").click(function() {
var filterLink = $(this);
if (!filterIsApplied) {
applyFilter();
filterLink.text("Click to see all packages.");
filterIsApplied = true;
} else {
removeFilter();
filterLink.text("Click here to see them.");
filterIsApplied = false;
}
});
}
}); /* document.ready */