MediaWiki:Common.js: Difference between revisions
From Realera Wiki
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
var NanValue = function (entry) { | |||
if(entry=="NaN") { | |||
return 0; | |||
} | |||
return entry; | |||
} | |||
function submit_form() { | function submit_form() { | ||
Line 11: | Line 17: | ||
function submit_pr_form() { | function submit_pr_form() { | ||
victim_level = document.getElementById("victim_level").value | victim_level = NanValue(document.getElementById("victim_level").value) | ||
killer_level = document.getElementById("killer_level").value | killer_level = NanValue(document.getElementById("killer_level").value) | ||
percentage_diff = Math.round(((killer_level - victim_level) / killer_level) * 100) | percentage_diff = Math.round(((killer_level - victim_level) / killer_level) * 100) |
Revision as of 13:49, 16 December 2023
/* Any JavaScript here will be loaded for all users on every page load. */ var NanValue = function (entry) { if(entry=="NaN") { return 0; } return entry; } function submit_form() { level = document.getElementById("level").value content = document.getElementById("expresults") content.innerHTML = ""; lower_range = Math.round(level/1.5) upper_range = Math.round(level*1.5) content.innerHTML = content.innerHTML + "A character with level <b>" + level +"</b> can share experience with levels <b>" + lower_range + "</b> to <b>" + upper_range +"</b><br>" } function submit_pr_form() { victim_level = NanValue(document.getElementById("victim_level").value) killer_level = NanValue(document.getElementById("killer_level").value) percentage_diff = Math.round(((killer_level - victim_level) / killer_level) * 100) console.log("victim", victim_level) console.log("killer", killer_level) console.log("percentage diff", percentage_diff) content = document.getElementById("lowlvlprotection") content.innerHTML = "Percentage diff: " + percentage_diff }