MediaWiki:Common.js: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
Line 13: | Line 13: | ||
} | } | ||
} | } | ||
$(document).ready(function() { | |||
// Create a new OOUI button widget | |||
var button = new OO.ui.ButtonWidget({ | |||
label: 'Click Me', // The text displayed on the button | |||
classes: ['oo-ui-primaryButton'] // Optional: you can apply different styles like primary, secondary, etc. | |||
}); | |||
// Add a click event to the button | |||
button.on('click', function() { | |||
alert('You clicked the button!'); | |||
}); | |||
// Append the button to a container (in this case, the content area) | |||
$('#content').append(button.$element); | |||
}); |
Revision as of 00:14, 31 January 2025
/* Any JavaScript here will be loaded for all users on every page load. */ MMtoHuman(document.getElementsByClassName("micromorts")); function MMtoHuman ( elementArray ){ for (let span of elementArray){ if (span !== null){ let chance = 1000000 / parseInt(span.textContent); let digits = Math.round(chance).toString().length; let rounded = Math.round(chance / Math.pow(10, digits - 2)) * Math.pow(10, digits - 2); span.textContent = "1 in " + rounded.toLocaleString(); } } } $(document).ready(function() { // Create a new OOUI button widget var button = new OO.ui.ButtonWidget({ label: 'Click Me', // The text displayed on the button classes: ['oo-ui-primaryButton'] // Optional: you can apply different styles like primary, secondary, etc. }); // Add a click event to the button button.on('click', function() { alert('You clicked the button!'); }); // Append the button to a container (in this case, the content area) $('#content').append(button.$element); });