MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
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 filterImages () { | function filterImages () { | ||
var x = document.getElementsByClassName("tooltip"); | var x = document.getElementsByClassName("tooltip"); | ||
| Line 74: | Line 73: | ||
$('#articlebox').html('<input type="text" id="articleinput" onkeyup="filterArticles()" 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">'); | ||
Revision as of 07:39, 28 February 2021
/* 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">');