Common.js: Difference between revisions
From Underfoot
No edit summary |
No edit summary |
||
| Line 35: | Line 35: | ||
function filterAll () { | function filterAll () { | ||
alert("filter all"); | alert("filter all"); | ||
var input, filter, td, i, description, keywords, txtValue; | var input, filter, td, i, description, keywords, txtValue; | ||
var map = document.getElementsByClassName("leaflet-marker-icon"); | var map = document.getElementsByClassName("leaflet-marker-icon"); | ||
| Line 43: | Line 44: | ||
var dplline = document.getElementsByClassName("DPLLine"); | var dplline = document.getElementsByClassName("DPLLine"); | ||
var table = document.getElementById("Table"); | var table = document.getElementById("Table"); | ||
var list, i, switching, b, shouldSwitch; | |||
list = document.getElementById("id01"); | |||
switching = true; | |||
/* Make a loop that will continue until | |||
no switching has been done: */ | |||
while (switching) { | |||
// Start by saying: no switching is done: | |||
switching = false; | |||
b = list.getElementsByTagName("LI"); | |||
// Loop through all list items: | |||
for (i = 0; i < (b.length - 1); i++) { | |||
// Start by saying there should be no switching: | |||
shouldSwitch = false; | |||
/* Check if the next item should | |||
switch place with the current item: */ | |||
if (b[i].innerHTML.toLowerCase() > b[i + 1].innerHTML.toLowerCase()) { | |||
/* If next item is alphabetically lower than current item, | |||
mark as a switch and break the loop: */ | |||
shouldSwitch = true; | |||
break; | |||
} | |||
} | |||
if (shouldSwitch) { | |||
/* If a switch has been marked, make the switch | |||
and mark the switch as done: */ | |||
b[i].parentNode.insertBefore(b[i + 1], b[i]); | |||
switching = true; | |||
} | |||
} | |||
if (table) {var tabletr = table.getElementsByTagName("tr")} | if (table) {var tabletr = table.getElementsByTagName("tr")} | ||
Revision as of 20:01, 1 August 2024
/* Any JavaScript here will be loaded for all users on every page load. */
function myFunction() {
alert("Page is loaded and sorted");
var list, i, switching, b, shouldSwitch;
list = document.getElementById("id01");
switching = true;
/* Make a loop that will continue until
no switching has been done: */
while (switching) {
// Start by saying: no switching is done:
switching = false;
b = list.getElementsByTagName("LI");
// Loop through all list items:
for (i = 0; i < (b.length - 1); i++) {
// Start by saying there should be no switching:
shouldSwitch = false;
/* Check if the next item should
switch place with the current item: */
if (b[i].innerHTML.toLowerCase() > b[i + 1].innerHTML.toLowerCase()) {
/* If next item is alphabetically lower than current item,
mark as a switch and break the loop: */
shouldSwitch = true;
break;
}
}
if (shouldSwitch) {
/* If a switch has been marked, make the switch
and mark the switch as done: */
b[i].parentNode.insertBefore(b[i + 1], b[i]);
switching = true;
}
}
}
function filterAll () {
alert("filter all");
var input, filter, td, i, description, keywords, txtValue;
var map = document.getElementsByClassName("leaflet-marker-icon");
var items = document.getElementsByClassName("ItemLine");
var timeline = document.getElementsByClassName("TimelineLine");
var gallery = document.getElementsByClassName("galleryline");
var documents = document.getElementsByClassName("DocumentLine");
var dplline = document.getElementsByClassName("DPLLine");
var table = document.getElementById("Table");
var list, i, switching, b, shouldSwitch;
list = document.getElementById("id01");
switching = true;
/* Make a loop that will continue until
no switching has been done: */
while (switching) {
// Start by saying: no switching is done:
switching = false;
b = list.getElementsByTagName("LI");
// Loop through all list items:
for (i = 0; i < (b.length - 1); i++) {
// Start by saying there should be no switching:
shouldSwitch = false;
/* Check if the next item should
switch place with the current item: */
if (b[i].innerHTML.toLowerCase() > b[i + 1].innerHTML.toLowerCase()) {
/* If next item is alphabetically lower than current item,
mark as a switch and break the loop: */
shouldSwitch = true;
break;
}
}
if (shouldSwitch) {
/* If a switch has been marked, make the switch
and mark the switch as done: */
b[i].parentNode.insertBefore(b[i + 1], b[i]);
switching = true;
}
}
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(/_/g," ");
filter1 = input.value.toUpperCase().replace(/ /g,"_");
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 < items.length; i++) {
if (items[i].id.toUpperCase().search(filter1.substr(1)) == -1) {
items[i].style.display = 'inline-block';
} else {
items[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(filter1.substr(1)) == -1) {
documents[i].style.display = '';
} else {
documents[i].style.display = 'none';
}
}
for (i = 0; i < dplline.length; i++) {
if (dplline[i].id.toUpperCase().search(filter.substr(1)) == -1) {
dplline[i].style.display = '';
} else {
dplline[i].style.display = 'none';
}
}
if (table) {
for (i = 0; i < tabletr.length; i++) {
// match text in all 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
+ tabletr[i].getElementsByTagName("td")[4].textContent
+ tabletr[i].getElementsByTagName("td")[5].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 < items.length; i++) {
if (items[i].id.toUpperCase().search(filter1) > -1) {
items[i].style.display = 'inline-block';
} else {
items[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(filter1) > -1) {
documents[i].style.display = '';
} else {
documents[i].style.display = 'none';
}
}
for (i = 0; i < dplline.length; i++) {
if (dplline[i].id.toUpperCase().search(filter) > -1) {
dplline[i].style.display = '';
} else {
dplline[i].style.display = 'none';
}
}
if (table) {
for (i = 0; i < tabletr.length; i++) {
// match text in all 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
+ tabletr[i].getElementsByTagName("td")[4].textContent
+ tabletr[i].getElementsByTagName("td")[5].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">');
/*$('#filterbox').html('<input type="text" id="filterinput" onkeyup="myFunction()" value="" placeholder="Filter" title="Filter">'); */