MediaWiki:Common.js: Difference between revisions
no edit summary
Piranhaplant (talk | contribs) (Created page with "→Any JavaScript here will be loaded for all users on every page load.: // Extra functionality for RAM/ROM maps $(function() { for (const table of document.getElementsByClassName("ram_rom_map")) { // Sort table by the first column table.getElementsByTagName("th")[0].click(); // Add the ending address to the length column for (const row of table.getElementsByTagName("tbody")[0].children) { const address = row.children[0].innerText; const length = par...") |
Piranhaplant (talk | contribs) No edit summary |
||
(16 intermediate revisions by the same user not shown) | |||
Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
function runUntilSuccess(f) {
(function run() {
if (!f()) {
setTimeout(run, 10);
}
})();
}
// Extra functionality for RAM/ROM maps
/*runUntilSuccess(function() {
var tables = document.getElementsByClassName("ram_rom_map");
for (var i = 0; i < tables.length; i++) {
var table = tables[i];
if (header.classList.contains("headerSort")) {
if (!header.classList.contains("headerSortUp")) {
header.click();
}
} else {
return false;
}
}
return true;
});*/
$(function() {
for (var i = 0; i < tables.length; i++) {
▲ // Sort table by the first column
var table = tables[i];
▲ table.getElementsByTagName("th")[0].click();
▲ // Add the ending address to the length column
for (var j = 0; j < rows.length; j++) {
▲ for (const row of table.getElementsByTagName("tbody")[0].children) {
var length = parseInt(row.children[1].innerText);
row.children[1].title = "[" + address + ", " + endAddress + ")";
}
}
});
// Modify BPMN chart embeds to be just the SVG
runUntilSuccess(function() {
if (document.getElementsByClassName("bpmn_embed").length > 0) {
var canvas = document.getElementById("canvas");
var parent = canvas.parentElement;
var svgs = canvas.getElementsByTagName("svg");
if (svgs.length == 0 || svgs[0].getAttribute("data-element-id") == null) {
return false;
}
var clone = svgs[0].cloneNode(true);
canvas.remove();
parent.appendChild(clone);
var bbox = clone.getBBox();
clone.setAttribute("width", bbox.width + "px");
clone.setAttribute("height", bbox.height + "px");
clone.setAttribute("viewBox", bbox.x + " " + bbox.y + " " + bbox.width + " " + bbox.height);
}
return true;
});
|