2020-05-02 02:16:49 +00:00
|
|
|
(function() {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
//
|
|
|
|
// Tag support
|
|
|
|
//
|
|
|
|
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
//
|
2020-05-02 03:19:58 +00:00
|
|
|
// Sort support
|
2020-05-02 02:16:49 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
var sort_rows = function(cb) {
|
|
|
|
var tr = document.querySelectorAll(".projtable tr");
|
|
|
|
var items = [];
|
|
|
|
for (var i = 0, e = tr.length; i !== e; ++i) {
|
|
|
|
items.push([i, cb(tr[i])]);
|
|
|
|
}
|
|
|
|
items.sort(function(a, b) {
|
2020-05-02 03:19:58 +00:00
|
|
|
return (b[1] - a[1]);
|
2020-05-02 02:16:49 +00:00
|
|
|
});
|
|
|
|
for (var i = 0, e = items.length; i !== e; ++i) {
|
|
|
|
var el = tr[items[i][0]];
|
|
|
|
var parent = el.parentElement;
|
|
|
|
parent.removeChild(el);
|
|
|
|
parent.appendChild(el);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-05-02 03:19:58 +00:00
|
|
|
var sortUpdate = function(sort_by) {
|
2020-05-02 02:16:49 +00:00
|
|
|
sort_rows(function(el) {
|
|
|
|
return el.getAttribute(sort_by);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-05-02 03:19:58 +00:00
|
|
|
var so = document.getElementById('sortorder');
|
|
|
|
if (so) {
|
|
|
|
so.addEventListener('change', function() { sortUpdate(so.value); });
|
|
|
|
sortUpdate(so.value);
|
|
|
|
}
|
|
|
|
window.addEventListener("load", function() {
|
|
|
|
// back button support in webkit
|
|
|
|
sortUpdate(so.value);
|
|
|
|
});
|
2020-05-02 02:16:49 +00:00
|
|
|
|
|
|
|
})();
|