MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 2: | Line 2: | ||
function filterImages () { | function filterImages () { | ||
var x = document.getElementsByClassName(" | var x = document.getElementsByClassName("image"); | ||
var search = ""; | var search = ""; | ||
| Line 8: | Line 8: | ||
{ | { | ||
search = document.getElementById("imageinput").value; | 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 filterImages1 () { | |||
var x = document.getElementsByClassName("image1"); | |||
var search = ""; | |||
if(document.getElementById("image1input") !== null && document.getElementById("image1input").value !== null) | |||
{ | |||
search = document.getElementById("image1input").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 filterDocuments () { | |||
var x = document.getElementsByClassName("document"); | |||
var search = ""; | |||
if(document.getElementById("documentinput") !== null && document.getElementById("documentinput").value !== null) | |||
{ | |||
search = document.getElementById("documentinput").value; | |||
} | } | ||
| Line 20: | Line 57: | ||
function filterTable() { | function filterTable() { | ||
var input, filter, table, tr, td, i, txtValue; | var input, filter, table, tr, td, i, title, creator, year, notes, txtValue; | ||
input = document.getElementById("tableinput"); | input = document.getElementById("tableinput"); | ||
filter = input.value.toUpperCase(); | filter = input.value.toUpperCase(); | ||
| Line 26: | Line 63: | ||
tr = table.getElementsByTagName("tr"); | tr = table.getElementsByTagName("tr"); | ||
for (i = 0; i < tr.length; i++) { | for (i = 0; i < tr.length; i++) { | ||
// match text in columns Title, Creator, Year, Notes | |||
// | title= tr[i].getElementsByTagName("td")[0]; | ||
if (title) { | |||
if ( | creator= tr[i].getElementsByTagName("td")[1]; | ||
year= tr[i].getElementsByTagName("td")[2]; | |||
notes= tr[i].getElementsByTagName("td")[5]; | |||
txtValue = title.textContent + creator.textContent + year.textContent + notes.textContent; | |||
txtValue = | |||
if (txtValue.toUpperCase().indexOf(filter) > -1) { | if (txtValue.toUpperCase().indexOf(filter) > -1) { | ||
tr[i].style.display = ""; | tr[i].style.display = ""; | ||
} else { | |||
tr[i].style.display = "none"; | |||
} | } | ||
} | } | ||
| Line 46: | Line 79: | ||
} | } | ||
function | function filterReferences() { | ||
var input, filter, table, tr, td, i, txtValue, | var input, filter, table, tr, td, i, txtValue, reference, description, creator, date, notes; | ||
input = document.getElementById(" | input = document.getElementById("referenceinput"); | ||
filter = input.value.toUpperCase(); | filter = input.value.toUpperCase(); | ||
table = document.getElementById(" | table = document.getElementById("filterreferences"); | ||
tr = table.getElementsByTagName("tr"); | tr = table.getElementsByTagName("tr"); | ||
for (i = 0; i < tr.length; i++) { | for (i = 0; i < tr.length; i++) { | ||
// match text in columns | // match text in columns Reference, Description, Creator, Date, Notes | ||
reference = tr[i].getElementsByTagName("td")[0]; | |||
description = tr[i].getElementsByTagName("td")[1]; | |||
creator = tr[i].getElementsByTagName("td")[2]; | |||
if ( | date = tr[i].getElementsByTagName("td")[3]; | ||
txtValue = | notes = tr[i].getElementsByTagName("td")[4]; | ||
if (description) { | |||
txtValue = reference.textContent + description.textContent + creator.textContent + date.textContent + notes.textContent; | |||
if (txtValue.toUpperCase().indexOf(filter) > -1) { | if (txtValue.toUpperCase().indexOf(filter) > -1) { | ||
tr[i].style.display = ""; | tr[i].style.display = ""; | ||
| Line 72: | Line 107: | ||
$('#imagebox').html('<input type="text" id="imageinput" onkeyup="filterImages()" 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">'); | ||
$('# | $('#image1box').html('<input type="text" id="image1input" onkeyup="filterImages1()" value="" placeholder="Filter..." title="Type in a name1">'); | ||
$('#documentbox').html('<input type="text" id="documentinput" onkeyup="filterDocuments()" value="" placeholder="Filter..." title="Type in a name">'); | |||
$('#referencebox').html('<input type="text" id="referenceinput" onkeyup="filterReferences()" value="" placeholder="Filter..." title="Type in a name">'); | |||
Revision as of 10:18, 7 March 2021
/* Any JavaScript here will be loaded for all users on every page load. */
function filterImages () {
var x = document.getElementsByClassName("image");
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 filterImages1 () {
var x = document.getElementsByClassName("image1");
var search = "";
if(document.getElementById("image1input") !== null && document.getElementById("image1input").value !== null)
{
search = document.getElementById("image1input").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 filterDocuments () {
var x = document.getElementsByClassName("document");
var search = "";
if(document.getElementById("documentinput") !== null && document.getElementById("documentinput").value !== null)
{
search = document.getElementById("documentinput").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, title, creator, year, notes, txtValue;
input = document.getElementById("tableinput");
filter = input.value.toUpperCase();
table = document.getElementById("filtertable");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
// match text in columns Title, Creator, Year, Notes
title= tr[i].getElementsByTagName("td")[0];
if (title) {
creator= tr[i].getElementsByTagName("td")[1];
year= tr[i].getElementsByTagName("td")[2];
notes= tr[i].getElementsByTagName("td")[5];
txtValue = title.textContent + creator.textContent + year.textContent + notes.textContent;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
function filterReferences() {
var input, filter, table, tr, td, i, txtValue, reference, description, creator, date, notes;
input = document.getElementById("referenceinput");
filter = input.value.toUpperCase();
table = document.getElementById("filterreferences");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
// match text in columns Reference, Description, Creator, Date, Notes
reference = tr[i].getElementsByTagName("td")[0];
description = tr[i].getElementsByTagName("td")[1];
creator = tr[i].getElementsByTagName("td")[2];
date = tr[i].getElementsByTagName("td")[3];
notes = tr[i].getElementsByTagName("td")[4];
if (description) {
txtValue = reference.textContent + description.textContent + creator.textContent + date.textContent + notes.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">');
$('#image1box').html('<input type="text" id="image1input" onkeyup="filterImages1()" value="" placeholder="Filter..." title="Type in a name1">');
$('#documentbox').html('<input type="text" id="documentinput" onkeyup="filterDocuments()" value="" placeholder="Filter..." title="Type in a name">');
$('#referencebox').html('<input type="text" id="referenceinput" onkeyup="filterReferences()" value="" placeholder="Filter..." title="Type in a name">');