MediaWiki:Cycle11.js: Difference between revisions
miraheze>CodeTriangle this code should give players the percentage of total shares owned using a tooltip. |
miraheze>CodeTriangle make maj/min distinct |
||
| Line 20: | Line 20: | ||
// Code to generate a hover-over indication of percentages. | // Code to generate a hover-over indication of percentages. | ||
for (let row of st.children) { | for (let row of st.children) { | ||
if (!isNaN( | let ch = row.children[i]; | ||
if (!isNaN(ch.innerText)) { | |||
let percent = parseInt(ch.innerText) / total; | |||
let majority = percent > 0.5; | |||
let minority = majority ? false : percent >= 0.1; | |||
ch.setAttribute( | |||
"title", | "title", | ||
// hacky way to round to two decimal points | // hacky way to round to two decimal points | ||
// because the right way is worse | // because the right way is worse | ||
(( | ((percent * 10000) | 0) / 100 + "%" + (majority ? " (majority)" : minority ? " (minority)" : "") | ||
); | ); | ||
if (majority) { | |||
ch.innerHTML = `<b><u>${ch.innerText}</u></b>`; | |||
} | |||
if (minority) { | |||
ch.innerHTML = `<u>${ch.innerText}</u>`; | |||
} | |||
} | } | ||
} | } | ||