MediaWiki:Cycle11.js: Difference between revisions
miraheze>CodeTriangle it shouldn't try to go farther than it can now |
miraheze>CodeTriangle this code should give players the percentage of total shares owned using a tooltip. |
||
| Line 5: | Line 5: | ||
if (st) { | if (st) { | ||
// This block gets the total amount of shares for each rule | // This block gets the total amount of shares for each rule | ||
var totals = []; | |||
// Loop over the number of columns in the first row (should never be greater | // Loop over the number of columns in the first row (should never be greater | ||
// than number of rows in table) | // than number of rows in table) | ||
| Line 17: | Line 17: | ||
} | } | ||
totals.push(total); | totals.push(total); | ||
// Code to generate a hover-over indication of percentages. | |||
for (let row of st.children) { | |||
if (!isNaN(row.children[i].innerText)) { | |||
row.children[i].setAttribute( | |||
"title", | |||
// hacky way to round to two decimal points | |||
// because the right way is worse | |||
((parseInt(row.children[i].innerText) / total * 10000) | 0) / 100 + "%" | |||
); | |||
} | |||
} | |||
} | } | ||