Common.js: Difference between revisions
From WhereToday
(Created page with "→Any JavaScript here will be loaded for all users on every page load.: function filterImages1 () { var x = document.getElementsByClassName("image1"); var input, filter; var text= ""; if (document.getElementById("image1input") !== null && document.getElementById("image1input").value !== null) { input = document.getElementById("image1input"); filter = input.value.toUpperCase(); if (filter.search("!") == 0) { filter="^((?!"+filter.sub...") |
No edit summary |
||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
function filterAll () { | |||
var input, filter, td, i, description, keywords, txtValue; | |||
var map = document.getElementsByClassName("leaflet-marker-icon"); | |||
var objects = document.getElementsByClassName("ObjectLine"); | |||
var timeline = document.getElementsByClassName("TimelineLine"); | |||
var gallery = document.getElementsByClassName("galleryline"); | |||
var documents = document.getElementsByClassName("documentline"); | |||
var table = document.getElementById("Table"); | |||
if (table) {var tabletr = table.getElementsByTagName("tr")} | |||
if (document.getElementById("filterinput") !== null && document.getElementById("filterinput").value !== null) | |||
if (document.getElementById(" | |||
{ | { | ||
input = document.getElementById(" | input = document.getElementById("filterinput"); | ||
filter = input.value.toUpperCase(); | filter = input.value.toUpperCase().replace("_"," "); | ||
filter1 = input.value.toUpperCase().replace(" ","_"); | |||
if (filter.search("!") == 0) { | if (filter.search("!") == 0) { | ||
filter=" | if (filter.length > 1) { | ||
for (i = 0; i < map.length; i++) { | |||
if (map[i].id !== "" && map[i].id.toUpperCase().search(filter.substr(1)) == -1) { | |||
map[i].style.opacity="1.0"; | |||
} else { | |||
map[i].style.opacity="0.05"; | |||
} | |||
} | |||
for (i = 0; i < objects.length; i++) { | |||
if (objects[i].id.toUpperCase().search(filter1.substr(1)) == -1) { | |||
objects[i].style.display = 'inline-block'; | |||
} else { | |||
objects[i].style.display = 'none'; | |||
} | |||
} | |||
for (i = 0; i < timeline.length; i++) { | |||
if (timeline[i].id !== "" && timeline[i].id.toUpperCase().search(filter1.substr(1)) == -1) { | |||
timeline[i].style.opacity="1.0"; | |||
} else { | |||
timeline[i].style.opacity="0.1"; | |||
} | |||
} | |||
} | |||
for (i = 0; i < gallery.length; i++) { | |||
if (gallery[i].id.toUpperCase().search(filter.substr(1)) == -1) { | |||
gallery[i].style.display = ''; | |||
text=gallery[i].innerHTML; | |||
gallery[i].innerHTML = text.replace(/slideshowGroup:'exclude/,"slideshowGroup:'gallery"); | |||
} else { | |||
gallery[i].style.display = 'none'; | |||
text=gallery[i].innerHTML; | |||
gallery[i].innerHTML = text.replace(/slideshowGroup:'gallery/,"slideshowGroup:'exclude"); | |||
} | |||
} | |||
for (i = 0; i < documents.length; i++) { | |||
if (documents[i].id.toUpperCase().search(filter.substr(1)) == -1) { | |||
documents[i].style.display = ''; | |||
text=documents[i].innerHTML; | |||
documents[i].innerHTML = text.replace(/slideshowGroup:'exclude/,"slideshowGroup:'documents"); | |||
} else { | |||
documents[i].style.display = 'none'; | |||
text=documents[i].innerHTML; | |||
documents[i].innerHTML = text.replace(/slideshowGroup:'documents/,"slideshowGroup:'exclude"); | |||
} | |||
} | |||
if (table) { | |||
for (i = 0; i < tabletr.length; i++) { | |||
// match text in four columns | |||
if (tabletr[i].getElementsByTagName("td")[0]) { | |||
txtValue = tabletr[i].getElementsByTagName("td")[0].textContent | |||
+ tabletr[i].getElementsByTagName("td")[1].textContent | |||
+ tabletr[i].getElementsByTagName("td")[2].textContent | |||
+ tabletr[i].getElementsByTagName("td")[3].textContent; | |||
if (txtValue.toUpperCase().search(filter.substr(1)) == -1) { | |||
tabletr[i].style.display = ""; | |||
} else { | |||
tabletr[i].style.display = "none"; | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} else { | } else { | ||
for (i = 0; i < map.length; i++) { | |||
if (map[i].id !== "" && map[i].id.toUpperCase().search(filter) > -1) { | |||
map[i].style.opacity="1.0"; | |||
} | } else { | ||
map[i].style.opacity="0.05"; | |||
} | |||
} | |||
for (i = 0; i < objects.length; i++) { | |||
if (objects[i].id.toUpperCase().search(filter1) > -1) { | |||
objects[i].style.display = 'inline-block'; | |||
} else { | |||
objects[i].style.display = 'none'; | |||
} | |||
} | |||
for (i = 0; i < timeline.length; i++) { | |||
if (timeline[i].id !== "" && timeline[i].id.toUpperCase().search(filter1) > -1) { | |||
timeline[i].style.opacity="1.0"; | |||
} else { | |||
timeline[i].style.opacity="0.1"; | |||
} | |||
} | |||
for (i = 0; i < gallery.length; i++) { | |||
if (gallery[i].id.toUpperCase().search(filter) > -1) { | |||
gallery[i].style.display = ''; | |||
text=gallery[i].innerHTML; | |||
gallery[i].innerHTML = text.replace(/slideshowGroup:'exclude/,"slideshowGroup:'gallery"); | |||
} else { | |||
gallery[i].style.display = 'none'; | |||
text=gallery[i].innerHTML; | |||
gallery[i].innerHTML = text.replace(/slideshowGroup:'gallery/,"slideshowGroup:'exclude"); | |||
} | |||
} | |||
} | |||
for (i = 0; i < documents.length; i++) { | |||
if (documents[i].id.toUpperCase().search(filter) > -1) { | |||
documents[i].style.display = ''; | |||
text=documents[i].innerHTML; | |||
documents[i].innerHTML = text.replace(/slideshowGroup:'exclude/,"slideshowGroup:'documents"); | |||
} else { | |||
documents[i].style.display = 'none'; | |||
text=documents[i].innerHTML; | |||
documents[i].innerHTML = text.replace(/slideshowGroup:'documents/,"slideshowGroup:'exclude"); | |||
} | |||
} | } | ||
if (table) { | |||
for (i = 0; i < tabletr.length; i++) { | |||
// match text in four columns | |||
if (tabletr[i].getElementsByTagName("td")[0]) { | |||
txtValue = tabletr[i].getElementsByTagName("td")[0].textContent | |||
+ tabletr[i].getElementsByTagName("td")[1].textContent | |||
+ tabletr[i].getElementsByTagName("td")[2].textContent | |||
+ tabletr[i].getElementsByTagName("td")[3].textContent; | |||
if (txtValue !== "" && txtValue.toUpperCase().search(filter) > -1) { | |||
tabletr[i].style.display = ""; | |||
} else { | |||
tabletr[i].style.display = "none"; | |||
} | |||
} | |||
} | |||
} | } | ||
} | } | ||
} | } | ||
} | } | ||
$('# | $('#filterbox').html('<input type="text" id="filterinput" onkeyup="filterAll()" value="" placeholder="Filter" title="Filter">'); | ||
Revision as of 22:47, 4 February 2024
/* Any JavaScript here will be loaded for all users on every page load. */ function filterAll () { var input, filter, td, i, description, keywords, txtValue; var map = document.getElementsByClassName("leaflet-marker-icon"); var objects = document.getElementsByClassName("ObjectLine"); var timeline = document.getElementsByClassName("TimelineLine"); var gallery = document.getElementsByClassName("galleryline"); var documents = document.getElementsByClassName("documentline"); var table = document.getElementById("Table"); if (table) {var tabletr = table.getElementsByTagName("tr")} if (document.getElementById("filterinput") !== null && document.getElementById("filterinput").value !== null) { input = document.getElementById("filterinput"); filter = input.value.toUpperCase().replace("_"," "); filter1 = input.value.toUpperCase().replace(" ","_"); if (filter.search("!") == 0) { if (filter.length > 1) { for (i = 0; i < map.length; i++) { if (map[i].id !== "" && map[i].id.toUpperCase().search(filter.substr(1)) == -1) { map[i].style.opacity="1.0"; } else { map[i].style.opacity="0.05"; } } for (i = 0; i < objects.length; i++) { if (objects[i].id.toUpperCase().search(filter1.substr(1)) == -1) { objects[i].style.display = 'inline-block'; } else { objects[i].style.display = 'none'; } } for (i = 0; i < timeline.length; i++) { if (timeline[i].id !== "" && timeline[i].id.toUpperCase().search(filter1.substr(1)) == -1) { timeline[i].style.opacity="1.0"; } else { timeline[i].style.opacity="0.1"; } } for (i = 0; i < gallery.length; i++) { if (gallery[i].id.toUpperCase().search(filter.substr(1)) == -1) { gallery[i].style.display = ''; text=gallery[i].innerHTML; gallery[i].innerHTML = text.replace(/slideshowGroup:'exclude/,"slideshowGroup:'gallery"); } else { gallery[i].style.display = 'none'; text=gallery[i].innerHTML; gallery[i].innerHTML = text.replace(/slideshowGroup:'gallery/,"slideshowGroup:'exclude"); } } for (i = 0; i < documents.length; i++) { if (documents[i].id.toUpperCase().search(filter.substr(1)) == -1) { documents[i].style.display = ''; text=documents[i].innerHTML; documents[i].innerHTML = text.replace(/slideshowGroup:'exclude/,"slideshowGroup:'documents"); } else { documents[i].style.display = 'none'; text=documents[i].innerHTML; documents[i].innerHTML = text.replace(/slideshowGroup:'documents/,"slideshowGroup:'exclude"); } } if (table) { for (i = 0; i < tabletr.length; i++) { // match text in four columns if (tabletr[i].getElementsByTagName("td")[0]) { txtValue = tabletr[i].getElementsByTagName("td")[0].textContent + tabletr[i].getElementsByTagName("td")[1].textContent + tabletr[i].getElementsByTagName("td")[2].textContent + tabletr[i].getElementsByTagName("td")[3].textContent; if (txtValue.toUpperCase().search(filter.substr(1)) == -1) { tabletr[i].style.display = ""; } else { tabletr[i].style.display = "none"; } } } } } } else { for (i = 0; i < map.length; i++) { if (map[i].id !== "" && map[i].id.toUpperCase().search(filter) > -1) { map[i].style.opacity="1.0"; } else { map[i].style.opacity="0.05"; } } for (i = 0; i < objects.length; i++) { if (objects[i].id.toUpperCase().search(filter1) > -1) { objects[i].style.display = 'inline-block'; } else { objects[i].style.display = 'none'; } } for (i = 0; i < timeline.length; i++) { if (timeline[i].id !== "" && timeline[i].id.toUpperCase().search(filter1) > -1) { timeline[i].style.opacity="1.0"; } else { timeline[i].style.opacity="0.1"; } } for (i = 0; i < gallery.length; i++) { if (gallery[i].id.toUpperCase().search(filter) > -1) { gallery[i].style.display = ''; text=gallery[i].innerHTML; gallery[i].innerHTML = text.replace(/slideshowGroup:'exclude/,"slideshowGroup:'gallery"); } else { gallery[i].style.display = 'none'; text=gallery[i].innerHTML; gallery[i].innerHTML = text.replace(/slideshowGroup:'gallery/,"slideshowGroup:'exclude"); } } for (i = 0; i < documents.length; i++) { if (documents[i].id.toUpperCase().search(filter) > -1) { documents[i].style.display = ''; text=documents[i].innerHTML; documents[i].innerHTML = text.replace(/slideshowGroup:'exclude/,"slideshowGroup:'documents"); } else { documents[i].style.display = 'none'; text=documents[i].innerHTML; documents[i].innerHTML = text.replace(/slideshowGroup:'documents/,"slideshowGroup:'exclude"); } } if (table) { for (i = 0; i < tabletr.length; i++) { // match text in four columns if (tabletr[i].getElementsByTagName("td")[0]) { txtValue = tabletr[i].getElementsByTagName("td")[0].textContent + tabletr[i].getElementsByTagName("td")[1].textContent + tabletr[i].getElementsByTagName("td")[2].textContent + tabletr[i].getElementsByTagName("td")[3].textContent; if (txtValue !== "" && txtValue.toUpperCase().search(filter) > -1) { tabletr[i].style.display = ""; } else { tabletr[i].style.display = "none"; } } } } } } } $('#filterbox').html('<input type="text" id="filterinput" onkeyup="filterAll()" value="" placeholder="Filter" title="Filter">');