MediaWiki:Common.js: Difference between revisions
Content added Content deleted
Piranhaplant (talk | contribs) No edit summary |
Piranhaplant (talk | contribs) No edit summary |
||
Line 4: | Line 4: | ||
$(function() { |
$(function() { |
||
const tables = document.getElementsByClassName("ram_rom_map"); |
const tables = document.getElementsByClassName("ram_rom_map"); |
||
for ( |
for (var i = 0; i < tables.length; i++) { |
||
const table = tables[i]; |
const table = tables[i]; |
||
// Sort table by the first column |
// Sort table by the first column |
||
Line 11: | Line 11: | ||
// Add the ending address to the length column |
// Add the ending address to the length column |
||
const rows = table.getElementsByTagName("tbody")[0].children; |
const rows = table.getElementsByTagName("tbody")[0].children; |
||
for ( |
for (var j = 0; j < rows.length; j++) { |
||
const row = rows[j]; |
const row = rows[j]; |
||
const address = row.children[0].innerText; |
const address = row.children[0].innerText; |
Revision as of 00:50, 8 April 2024
/* Any JavaScript here will be loaded for all users on every page load. */
// Extra functionality for RAM/ROM maps
$(function() {
const tables = document.getElementsByClassName("ram_rom_map");
for (var i = 0; i < tables.length; i++) {
const table = tables[i];
// Sort table by the first column
table.getElementsByTagName("th")[0].click();
// Add the ending address to the length column
const rows = table.getElementsByTagName("tbody")[0].children;
for (var j = 0; j < rows.length; j++) {
const row = rows[j];
const address = row.children[0].innerText;
const length = parseInt(row.children[1].innerText);
const endAddress = address.substr(0, 4) + (parseInt(address.substr(4, 4), 16) + length).toString(16).padStart(4, "0");
row.children[1].title = "[" + address + ", " + endAddress + ")";
}
}
});