MediaWiki:Common.js
Jump to navigation
Jump to search
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 filterImages () { var x = document.getElementsByClassName("tooltip"); var search = ""; if(document.getElementById("imageinput") !== null && document.getElementById("imageinput").value !== null) { search = document.getElementById("imageinput").value; } for (i = 0; i < x.length; i++) { if (x[i].id.indexOf(search) == -1) { x[i].style.display = 'none'; } else { x[i].style.display = ''; } } } function filterTable() { var input, filter, table, tr, td, i, txtValue; input = document.getElementById("tableinput"); filter = input.value.toUpperCase(); table = document.getElementById("filtertable"); tr = table.getElementsByTagName("tr"); for (i = 0; i < tr.length; i++) { tr[i].style.display = "none"; // Name column td = tr[i].getElementsByTagName("td")[0]; if (td) { txtValue = td.textContent || td.innerText; if (txtValue.toUpperCase().indexOf(filter) > -1) { tr[i].style.display = ""; } } // Notes column td = tr[i].getElementsByTagName("td")[5]; if (td) { txtValue = td.textContent || td.innerText; if (txtValue.toUpperCase().indexOf(filter) > -1) { tr[i].style.display = ""; } } } } function filterArticles() { var input, filter, table, tr, td, i, txtValue, article, creator, keywords; input = document.getElementById("articleinput"); filter = input.value.toUpperCase(); table = document.getElementById("filterarticles"); tr = table.getElementsByTagName("tr"); for (i = 0; i < tr.length; i++) { // match text in columns Article, Creator, Keywords) and 2 (creator) article= tr[i].getElementsByTagName("td")[0]; creator= tr[i].getElementsByTagName("td")[1]; keywords= tr[i].getElementsByTagName("td")[5]; if (article) { txtValue = article.textContent + creator.textContent + keywords.textContent; if (txtValue.toUpperCase().indexOf(filter) > -1) { tr[i].style.display = ""; } else { tr[i].style.display = "none"; } } } } $('#tablebox').html('<input type="text" id="tableinput" onkeyup="filterTable()" value="" placeholder="Filter..." title="Type in a name">'); $('#imagebox').html('<input type="text" id="imageinput" onkeyup="filterImages()" value="" placeholder="Filter..." title="Type in a name">'); $('#articlebox').html('<input type="text" id="articleinput" onkeyup="filterArticles()" value="" placeholder="Filter..." title="Type in a name">'); */