46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
|
(function() {
|
||
|
"use strict";
|
||
|
|
||
|
var show_all = function() {
|
||
|
var tr = document.querySelectorAll(".projtable tr");
|
||
|
for (var i = 0, e = tr.length; i !== e; ++i) {
|
||
|
tr[i].style.display = "table-row";
|
||
|
}
|
||
|
|
||
|
var warn = document.querySelector(".tag-filter-warn");
|
||
|
warn.parentNode.removeChild(warn);
|
||
|
};
|
||
|
|
||
|
var show_tag = function(tag) {
|
||
|
if (document.querySelector(".tag-filter-warn") !== null) {
|
||
|
show_all();
|
||
|
}
|
||
|
|
||
|
var tr = document.querySelectorAll(".projtable tr");
|
||
|
for (var i = 0, e = tr.length; i !== e; ++i) {
|
||
|
tr[i].style.display = (tr[i].className.split(" ").indexOf("taggedWith-"+tag) === -1) ? "none" : "table-row";
|
||
|
}
|
||
|
|
||
|
var div = document.createElement("div");
|
||
|
div.className = "tag-filter-warn";
|
||
|
div.innerHTML = "Filtering by tag. <a>reset</a>";
|
||
|
document.body.appendChild(div);
|
||
|
|
||
|
document.querySelector(".tag-filter-warn a").addEventListener('click', function() {
|
||
|
show_all();
|
||
|
return false;
|
||
|
});
|
||
|
};
|
||
|
|
||
|
var get_show_tag = function(tag) {
|
||
|
return function() { show_tag(tag); return false; };
|
||
|
};
|
||
|
|
||
|
window.addEventListener('load', function() {
|
||
|
var taglinks = document.querySelectorAll(".tag-link");
|
||
|
for (var i = 0, e = taglinks.length; i !== e; ++i) {
|
||
|
var tag = taglinks[i].getAttribute("data-tag");
|
||
|
taglinks[i].addEventListener('click', get_show_tag(tag));
|
||
|
}
|
||
|
});
|
||
|
})();
|