MediaWiki:NumerAlpha.js: mudanças entre as edições

sem sumário de edição
(Criou página com '// from: https://stackoverflow.com/questions/9083037/convert-a-number-into-a-roman-numeral-in-javascript // To be used in Template:CardCatalog and other places as well functi...')
 
Sem resumo de edição
// To be used in Template:CardCatalog and other places as well
 
function romanizemainFunc(num) {
iffunction (isNaNromanize(num)) return NaN;{
if (isNaN(num)) return NaN;
const digits = String(+num).split(""),
key = [
"",key = [
"C",
"CCC",
"CCCCC",
"CDCCC",
"DCD",
"DCD",
"DCCDC",
"DCCCDCC",
"CMDCCC",
"CM",
"X",
"XXX",
"XXXXX",
"XLXXX",
"LXL",
"LXL",
"LXXLX",
"LXXXLXX",
"XCLXXX",
"XC",
"I",
"III",
"IIIII",
"IVIII",
"VIV",
"VIV",
"VIIVI",
"VIIIVII",
"IXVIII",
]; "IX",
let roman = "" ];
let iroman = 3"";
keylet i = [3;
while (i--) roman = (key[+digits.pop() + i * 10] || "") + roman;
return Array while (i--) roman = (key[+digits.joinpop("") + 1).join(i * 10] || "M") + roman;
while (i--) roman =return Array(key[+digits.popjoin("") + i * 10] || 1).join("M") + roman;
}
 
const incrementElemsNumeral = document.querySelectorAll(
".increment-numeralpha-numeral"
);
 
for (let [i, element] of incrementElemsNumeral.entries()) {
element.innerHTML = `${++i}. ${element.innerHTML}`;
}
 
const incrementElemsRoman = document.querySelectorAll(
".increment-numeralpha-roman"
);
 
for (let [i, element] of incrementElemsRoman.entries()) {
element.innerHTML = `${romanize(++i)}. ${element.innerHTML}`;
}
 
if (document.readyState === "complete" || document.readyState !== "loading") {
for (let [i, element] of incrementElemsRoman.entries()) {
mainFunc();
element.innerHTML = `${romanize(++i)}. ${element.innerHTML}`;
} else {
document.addEventListener("DOMContentLoaded", mainFunc);
}