MediaWiki:Common.js
From Underfoot
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/* 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.substr(1)+").)*$"; } } for (i = 0; i < x.length; i++) { if (x[i].id.toUpperCase().search(filter) > -1) { x[i].style.display = ''; text=x[i].innerHTML; x[i].innerHTML = text.replace(/slideshowGroup:'exclude/,"slideshowGroup:'include"); } else { x[i].style.display = 'none'; text=x[i].innerHTML; x[i].innerHTML = text.replace(/slideshowGroup:'include/,"slideshowGroup:'exclude"); } } } function filterMap () { var input, filter, table, tr, td, i, description, keywords, txtValue; var x = document.getElementsByClassName("leaflet-marker-icon"); table = document.getElementById("maptable"); tr = table.getElementsByTagName("tr"); if (document.getElementById("mapinput") !== null && document.getElementById("mapinput").value !== null) { input = document.getElementById("mapinput"); filter = input.value.toUpperCase(); if (filter.search("!") == 0) { for (i = 0; i < x.length; i++) { if (x[i].id !== "" && x[i].id.toUpperCase().search(filter.substr(1)) > -1) { x[i].style.opacity="0.1"; } else { x[i].style.opacity="1.0"; } } for (i = 0; i < tr.length; i++) { // match text in two columns description = tr[i].getElementsByTagName("td")[0]; if (description) { keywords = tr[i].getElementsByTagName("td")[1]; txtValue = description.textContent + keywords.textContent; if (txtValue.toUpperCase().search(filter.substr(1)) > -1) { tr[i].style.display = ""; } else { tr[i].style.display = "none"; } } } } else { for (i = 0; i < x.length; i++) { if (x[i].id !== "" && x[i].id.toUpperCase().search(filter) > -1) { x[i].style.opacity="1.0"; } else { x[i].style.opacity="0.1"; } } for (i = 0; i < tr.length; i++) { // match text in two columns description = tr[i].getElementsByTagName("td")[0]; if (description) { keywords = tr[i].getElementsByTagName("td")[1]; txtValue = description.textContent + keywords.textContent; if (txtValue.toUpperCase().search(filter) > -1) { tr[i].style.display = ""; } else { tr[i].style.display = "none"; } } } } } } function filterTimeline () { var input, filter, i, description, keywords, txtValue, table, tr; var x = document.getElementsByClassName("TimelineLine"); table = document.getElementById("timelinetable"); tr = table.getElementsByTagName("tr"); if (document.getElementById("timelineinput") !== null && document.getElementById("timelineinput").value !== null) { input = document.getElementById("timelineinput"); filter = input.value.toUpperCase(); if (filter.search("!") == 0) { for (i = 0; i < x.length; i++) { if (x[i].id !== "" && x[i].id.toUpperCase().search(filter.substr(1)) > -1) { x[i].style.opacity="0.1"; } else { x[i].style.opacity="1.0"; } } for (i = 0; i < tr.length; i++) { // match text in two columns description = tr[i].getElementsByTagName("td")[0]; if (description) { keywords = tr[i].getElementsByTagName("td")[1]; txtValue = description.textContent + keywords.textContent; if (txtValue.toUpperCase().search(filter.substr(1)) > -1) { tr[i].style.display = ""; } else { tr[i].style.display = "none"; } } } } else { for (i = 0; i < x.length; i++) { if (x[i].id !== "" && x[i].id.toUpperCase().search(filter) > -1) { x[i].style.opacity="1.0"; } else { x[i].style.opacity="0.1"; } } for (i = 0; i < tr.length; i++) { // match text in two columns description = tr[i].getElementsByTagName("td")[0]; if (description) { keywords = tr[i].getElementsByTagName("td")[1]; txtValue = description.textContent + keywords.textContent; if (txtValue.toUpperCase().search(filter) > -1) { tr[i].style.display = ""; } else { tr[i].style.display = "none"; } } } } } } function filterDocuments () { var x = document.getElementsByClassName("document"); var input, filter; if (document.getElementById("documentinput") !== null && document.getElementById("documentinput").value !== null) { input = document.getElementById("documentinput"); filter = input.value.toUpperCase(); if (filter.search("!") == 0) { filter="^((?!"+filter.substr(1)+").)*$"; } } for (i = 0; i < x.length; i++) { if (txtValue.toUpperCase().search(filter) > -1) { x[i].style.display = ''; } else { x[i].style.display = 'none'; } } } function filterShortTable() { var input, filter, table, tr, td, i, start, description, keywords, notes, txtValue; input = document.getElementById("shorttableinput"); filter = input.value.toUpperCase(); if (filter.search("!") == 0) { filter="^((?!"+filter.substr(1)+").)*$"; } table = document.getElementById("shorttable"); tr = table.getElementsByTagName("tr"); for (i = 0; i < tr.length; i++) { // match text in four columns title= tr[i].getElementsByTagName("td")[0]; if (title) { start = tr[i].getElementsByTagName("td")[0]; description = tr[i].getElementsByTagName("td")[1]; keywords = tr[i].getElementsByTagName("td")[2]; notes = tr[i].getElementsByTagName("td")[3]; txtValue = start.textContent + description.textContent + keywords.textContent + notes.textContent; if (txtValue.toUpperCase().search(filter) > -1) { tr[i].style.display = ""; } else { tr[i].style.display = "none"; } } } } function filterLongTable() { var input, filter, table, tr, td, i, start, description, keywords, notes, txtValue; input = document.getElementById("longtableinput"); filter = input.value.toUpperCase(); if (filter.search("!") == 0) { filter="^((?!"+filter.substr(1)+").)*$"; } table = document.getElementById("longtable"); tr = table.getElementsByTagName("tr"); for (i = 0; i < tr.length; i++) { // match text in four columns title= tr[i].getElementsByTagName("td")[0]; if (title) { start = tr[i].getElementsByTagName("td")[0]; description = tr[i].getElementsByTagName("td")[1]; keywords = tr[i].getElementsByTagName("td")[2]; notes = tr[i].getElementsByTagName("td")[3]; txtValue = start.textContent + description.textContent + keywords.textContent + notes.textContent; if (txtValue.toUpperCase().search(filter) > -1) { tr[i].style.display = ""; } else { tr[i].style.display = "none"; } } } } $('#shorttablebox').html('<input type="text" id="shorttableinput" onkeyup="filterShortTable()" value="" placeholder="Filter table" title="Type in a name">'); $('#longtablebox').html('<input type="text" id="longtableinput" onkeyup="filterLongTable()" value="" placeholder="Filter table" title="Type in a name">'); $('#image1box').html('<input type="text" id="image1input" onkeyup="filterImages1()" value="" placeholder="Filter images" title="Type in a name1">'); $('#documentbox').html('<input type="text" id="documentinput" onkeyup="filterDocuments()" value="" placeholder="Filter documents" title="Type in a name">'); $('#mapbox').html('<input type="text" id="mapinput" onkeyup="filterMap()" value="" placeholder="Filter map and table" title="Type in a name">'); $('#timelinebox').html('<input type="text" id="timelineinput" onkeyup="filterTimeline()" value="" placeholder="Filter timeline" title="Type in a name">');