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