MediaWiki:Common.js: Difference between revisions
Content deleted Content added
No edit summary |
No edit summary Tag: Manual revert |
||
(28 intermediate revisions by the same user not shown) | |||
Line 14:
searchInput.setAttribute('id', 'mediawiki-text-parser-input');
searchInput.setAttribute('placeholder', 'Type to search');
// Set the width of the search input field as a percentage
searchInput.style.width = '100%'; // You can adjust the percentage here
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 ⟶ 27:
var searchText = this.value.toLowerCase();
// Get all
var
// Loop through each
// Check if the paragraph contains the search text▼
if (paragraphText.includes(searchText)) {▼
▲ paragraph.style.display = 'block'; // Show the paragraph
} else {
var rowShouldBeVisible = false;
// Loop through each cell in the row
Array.from(rowCells).forEach(function(cell) {
var cellText = cell.textContent.toLowerCase();
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 {▼
row.style.display = 'none';
}
}
});
});
}
Line 40 ⟶ 64:
// Call the initializeTextParser function when the DOM is ready
function initializeTextParserOnLoad() {
var pathname = window.location.pathname;
var pageNames = ['List_of_fan_Nandroids', 'List_of_fan_stories'];
if (pageNames.includes(pathname.substring(pathname.lastIndexOf('/') + 1))) {
initializeTextParser();
▲ } else {
}
}
|