properly store current primary and secondary nodes

This commit is contained in:
MrOtherGuy 2020-07-18 11:39:59 +03:00
parent 0b56963e78
commit f9b151ccfd

View file

@ -46,23 +46,23 @@ function fetchWithType(url){
} }
let currentCategory = new (function(){ let currentCategory = new (function(){
const currentPrimaryNode = null; let currentPrimaryNode = null;
const currentSecondaryNode = null; let currentSecondaryNode = null;
// TODO make filenames store ONLY the top level fileNames // TODO make filenames store ONLY the top level fileNames
// //
let currentTopLevelFileNames = null; let currentTopLevelFileNames = null;
this.set = function(t,secondary){ this.set = function(t,secondary){
let targetNode;
if(secondary){ if(secondary){
targetNode = currentSecondaryNode; currentSecondaryNode && currentSecondaryNode.classList.remove("currentCategory");
currentSecondaryNode = t;
currentSecondaryNode.classList.add("currentCategory");
}else{ }else{
targetNode = currentPrimaryNode; currentPrimaryNode && currentPrimaryNode.classList.remove("currentCategory");
currentPrimaryNode = t;
currentPrimaryNode.classList.add("currentCategory");
} }
targetNode && targetNode.classList.remove("currentCategory");
targetNode = t;
targetNode.classList.add("currentCategory");
if(!secondary){ if(!secondary){
currentTopLevelFileNames = DB.query(t.textContent); currentTopLevelFileNames = DB.query(t.textContent);
} }