MediaWiki:Common.js: Difference between revisions

From Emmy The Robot Fandom Wiki
Content added Content deleted
No edit summary
No edit summary
Line 13:
searchInput.setAttribute('type', 'text');
searchInput.setAttribute('id', 'mediawiki-text-parser-input');
searchInput.setAttribute('placeholder', 'Type to searchsearch1');
document.getElementById('mw-content-text').insertBefore(searchInput, document.getElementById('mw-content-text').firstChild);
 
// Get the table
var table = document.querySelector('table.wikitable.sortable.mw-datatable.jquery-tablesorter');
 
// Attach an event listener to the search input field
Line 20 ⟶ 23:
var searchText = this.value.toLowerCase();
 
// Get all paragraphsrows in the content areatable
var rows = documenttable.querySelectorAll('table.wikitable.sortable.mw-datatable.jquery-tablesorter tr:not(:first-child)');
 
// Loop through each row
rows.forEach(function(row, index) {
varif rowCells(index === 0) row.cells;{
// Show the first row (headers) always
var rowShouldBeVisible = false;
 
// Loop through each cell in the row
Array.from(rowCells).forEach(function(cell) {
var cellText = cell.textContent.toLowerCase();
// Check if any cell contains the search text
if (cellText.includes(searchText)) {
rowShouldBeVisible = true;
}
});
 
// Set the display property of the row and its cells
if (rowShouldBeVisible) {
row.style.display = 'table-row';
} else {
var cellTextrowCells = cellrow.textContent.toLowerCase()cells;
var rowShouldBeVisible = false;
 
// Loop through each cell in the row
Array.from(rowCells).forEach(function(cell) {
cell.style.displayvar cellText = 'table-cell'.textContent.toLowerCase();
// Check if any cell contains the search text
if (cellText.includes(searchText)) {
rowShouldBeVisible = true;
}
});
 
} else {
row.style.// Set the display =property of the row and its 'none';cells
if (rowShouldBeVisible) {
row.style.display = 'table-row';
Array.from(rowCells).forEach(function(cell) {
cell.style.display = 'table-cell';
});
} else {
row.style.display = 'none';
}
}
});