mock_filter.html: Enable full filter hiding [#21]

This doesn't auto-skip
It may also do a superfluous loop. Trying to compress now
This commit is contained in:
Matt Mascarenhas 2017-05-17 21:13:18 +01:00
parent 73d7e996e5
commit bd7baf9e5d
1 changed files with 44 additions and 35 deletions

View File

@ -276,39 +276,42 @@ filterModeElement.addEventListener("click", function(ev) {
} }
}); });
for (var i = 0; i < filterTopics.length; ++i) for(var i = 0; i < filterTopics.length; ++i)
{ {
filterTopics[i].addEventListener("click", function(ev) { filterTopics[i].addEventListener("click", function(ev) {
// NOTE(matt): Useful test
// if(this.parentNode.className == "filter_topics")
var selectedCategory = this.childNodes[1].classList[2]; var selectedCategory = this.childNodes[1].classList[2];
var testMarkers = document.querySelectorAll(".cat_" + selectedCategory);
// TODO(matt): Fix this routine! off seems to work, but not skip
var categorisedMarkers = document.querySelectorAll("." + selectedCategory);
if(!(this.classList.contains("off"))) if(!(this.classList.contains("off")))
{ {
this.classList.add("off"); this.classList.add("off");
var Skipping = 1; for(var j = 0; j < testMarkers.length; ++j)
for (var j = 0; j < categorisedMarkers.length; ++j)
{ {
categorisedMarkers[j].classList.add("off"); var categorisedMarkers = testMarkers[j].querySelectorAll("." + selectedCategory);
if(filterMode == "exclusive") for(var k = 0; k < categorisedMarkers.length; ++k)
{ {
categorisedMarkers[j].parentNode.classList.add("skip"); var Skipping = 1;
} categorisedMarkers[k].classList.add("off");
else if(filterMode == "exclusive")
{
for(var k = 0; k < categorisedMarkers[j].parentNode.childNodes.length; ++k)
{ {
if(!categorisedMarkers[j].parentNode.childNodes[k].contains == "off") testMarkers[j].classList.add("skip");
{
Skipping = 0;
}
} }
if(Skipping) else
{ {
categorisedMarkers[j].parentNode.classList.add("skip"); var markerCategories = testMarkers[j].querySelectorAll(".category");
for(var l = 0; l < markerCategories.length; ++l)
{
if(!markerCategories[l].classList.contains("off"))
{
Skipping = 0;
}
}
if(Skipping)
{
testMarkers[j].classList.add("skip");
}
} }
} }
} }
@ -316,26 +319,32 @@ for (var i = 0; i < filterTopics.length; ++i)
else else
{ {
this.classList.remove("off"); this.classList.remove("off");
var Skipping = 0; for(var j = 0; j < testMarkers.length; ++j)
for (var j = 0; j < categorisedMarkers.length; ++j)
{ {
categorisedMarkers[j].classList.remove("off"); var categorisedMarkers = testMarkers[j].querySelectorAll("." + selectedCategory);
if(filterMode == "inclusive") for(var k = 0; k < categorisedMarkers.length; ++k)
{ {
categorisedMarkers[j].parentNode.classList.remove("skip"); var Skipping = 0;
} categorisedMarkers[k].classList.remove("off");
else if(filterMode == "inclusive")
{
for(var k = 0; k < categorisedMarkers[j].parentNode.childNodes.length; ++k)
{ {
if(categorisedMarkers[j].parentNode.childNodes[k].contains == "off") testMarkers[j].classList.remove("skip");
{
Skipping = 1;
}
} }
if(Skipping) else
{ {
categorisedMarkers[j].parentNode.classList.add("skip"); var markerCategories = testMarkers[j].querySelectorAll(".category");
for(var l = 0; l < markerCategories.length; ++l)
{
if(markerCategories[l].classList.contains("off"))
{
Skipping = 1;
}
}
if(!Skipping)
{
testMarkers[j].classList.remove("skip");
}
} }
} }
} }