MediaWiki:Common.js: Difference between revisions

From Emmy The Robot Fandom Wiki
no edit summary
No edit summary
No edit summary
Line 13:
searchInput.setAttribute('type', 'text');
searchInput.setAttribute('id', 'mediawiki-text-parser-input');
searchInput.setAttribute('placeholder', 'Type to search1search');
document.getElementById('mw-content-text').insertBefore(searchInput, document.getElementById('mw-content-text').firstChild);
 
Line 21:
 
// Get all paragraphs in the content area
var paragraphsrows = document.querySelectorAll ('table.wikitable.sortable.mw-datatable.jquery-tablesorter tr:not(:first-child)');
 
// Loop through each paragraphrow
rows.forEach(function(row) {
for (var i = 0; i < paragraphs.length; i++) {
var paragraphrowCells = paragraphs[i]row.cells;
var paragraphTextrowShouldBeVisible = paragraph.textContent.toLowerCase()false;
 
// CheckLoop ifthrough theeach paragraphcell containsin the search textrow
if (paragraphTextArray.includesfrom(searchTextrowCells).forEach(function(cell) {
paragraph.style.displayvar cellText = 'block'cell.textContent.toLowerCase(); // Show the paragraph
// 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';
Array.from(rowCells).forEach(function(cell) {
cell.style.display = 'table-cell';
});
} else {
paragraphrow.style.display = 'none'; // Hide the paragraph
}
});
});
}
Cookies help us deliver our services. By using our services, you agree to our use of cookies.