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

@ -279,36 +279,39 @@ 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);
for(var k = 0; k < categorisedMarkers.length; ++k)
{
var Skipping = 1;
categorisedMarkers[k].classList.add("off");
if(filterMode == "exclusive") if(filterMode == "exclusive")
{ {
categorisedMarkers[j].parentNode.classList.add("skip"); testMarkers[j].classList.add("skip");
} }
else else
{ {
for(var k = 0; k < categorisedMarkers[j].parentNode.childNodes.length; ++k) var markerCategories = testMarkers[j].querySelectorAll(".category");
for(var l = 0; l < markerCategories.length; ++l)
{ {
if(!categorisedMarkers[j].parentNode.childNodes[k].contains == "off") if(!markerCategories[l].classList.contains("off"))
{ {
Skipping = 0; Skipping = 0;
} }
} }
if(Skipping) if(Skipping)
{ {
categorisedMarkers[j].parentNode.classList.add("skip"); 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);
for(var k = 0; k < categorisedMarkers.length; ++k)
{
var Skipping = 0;
categorisedMarkers[k].classList.remove("off");
if(filterMode == "inclusive") if(filterMode == "inclusive")
{ {
categorisedMarkers[j].parentNode.classList.remove("skip"); testMarkers[j].classList.remove("skip");
} }
else else
{ {
for(var k = 0; k < categorisedMarkers[j].parentNode.childNodes.length; ++k) var markerCategories = testMarkers[j].querySelectorAll(".category");
for(var l = 0; l < markerCategories.length; ++l)
{ {
if(categorisedMarkers[j].parentNode.childNodes[k].contains == "off") if(markerCategories[l].classList.contains("off"))
{ {
Skipping = 1; Skipping = 1;
} }
} }
if(Skipping) if(!Skipping)
{ {
categorisedMarkers[j].parentNode.classList.add("skip"); testMarkers[j].classList.remove("skip");
}
} }
} }
} }