crunk
4 years ago
7 changed files with 75 additions and 57 deletions
Can't render this file because it contains an unexpected character in line 11 and column 0.
|
@ -0,0 +1,56 @@ |
|||||
|
// Filter section ===================== old school code divider ================
|
||||
|
|
||||
|
filterSelection("all", "None"); |
||||
|
function filterSelection(c, id) { |
||||
|
resetDropDownButtons(); |
||||
|
var i; |
||||
|
var button = document.getElementById(id); |
||||
|
if(button){ |
||||
|
button.innerText = c; |
||||
|
addClass(button, "activebtn"); |
||||
|
} |
||||
|
var allpublications = document.getElementsByClassName("filter"); |
||||
|
if (c == "all") { |
||||
|
for (i = 0; i < allpublications.length; i++) { |
||||
|
addClass(allpublications[i], "show"); |
||||
|
} |
||||
|
} |
||||
|
else { |
||||
|
for (i = 0; i < allpublications.length; i++) { |
||||
|
removeClass(allpublications[i], "show"); |
||||
|
if (allpublications[i].className.indexOf(c) > -1) { |
||||
|
addClass(allpublications[i], "show"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
function resetDropDownButtons(){ |
||||
|
document.getElementById("License").innerText = "License"; |
||||
|
document.getElementById("PubType").innerText = "Type"; |
||||
|
document.getElementById("Year").innerText = "Year"; |
||||
|
allactivebuttons = document.getElementsByClassName("activebtn"); |
||||
|
for(var i = 0;allactivebuttons.length; i++) { |
||||
|
removeClass(allactivebuttons[i], "activebtn"); |
||||
|
} |
||||
|
} |
||||
|
function addClass(element, name) { |
||||
|
var i, arr1, arr2; |
||||
|
arr1 = element.className.split(" "); |
||||
|
arr2 = name.split(" "); |
||||
|
for (i = 0; i < arr2.length; i++) { |
||||
|
if (arr1.indexOf(arr2[i]) == -1) {element.className += " " + arr2[i];} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
function removeClass(element, name) { |
||||
|
var i, arr1, arr2; |
||||
|
arr1 = element.className.split(" "); |
||||
|
arr2 = name.split(" "); |
||||
|
for (i = 0; i < arr2.length; i++) { |
||||
|
while (arr1.indexOf(arr2[i]) > -1) { |
||||
|
arr1.splice(arr1.indexOf(arr2[i]), 1); |
||||
|
} |
||||
|
} |
||||
|
element.className = arr1.join(" "); |
||||
|
} |
Loading…
Reference in new issue