No edit summary Tag: Reverted |
Tag: Rollback |
||
| Line 1: | Line 1: | ||
/* == | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
$(document).ready(function () { | |||
console.log("loaded") | |||
$.getScript(mw.util.getUrl("MediaWiki:ProfileTags.js") + "?action=raw&ctype=text/javascript"); | |||
if (document.getElementById("interactiveMap")) { | |||
console.log("map loaded") | |||
$.getScript(mw.util.getUrl("MediaWiki:InteractiveMap/Objects.js") + "?action=raw&ctype=text/javascript", function() { | |||
$.getScript(mw.util.getUrl("MediaWiki:InteractiveMap/NPCs.js") + "?action=raw&ctype=text/javascript", function() { | |||
$.getScript(mw.util.getUrl("MediaWiki:InteractiveMap/Maps.js") + "?action=raw&ctype=text/javascript", function() { | |||
$.getScript(mw.util.getUrl("MediaWiki:InteractiveMap.js") + "?action=raw&ctype=text/javascript", function() { | |||
}); | |||
}); | |||
}); | |||
}); | |||
} | |||
if (document.getElementById("wardrobe")) { | |||
$.getScript(mw.util.getUrl("MediaWiki:Wardrobe.js") + "?action=raw&ctype=text/javascript"); | |||
console.log("wardrobe loaded") | |||
} | |||
// | if (document.getElementById("mapEditor")) { | ||
if ( | $.getScript("https://cdn.jsdelivr.net/npm/interactjs/dist/interact.min.js", function() { | ||
$.getScript(mw.util.getUrl("MediaWiki:InteractiveMap/Objects.js") + "?action=raw&ctype=text/javascript", function() { | |||
$.getScript(mw.util.getUrl("MediaWiki:InteractiveMap/NPCs.js") + "?action=raw&ctype=text/javascript", function() { | |||
$.getScript(mw.util.getUrl("MediaWiki:InteractiveMap/Maps.js") + "?action=raw&ctype=text/javascript", function() { | |||
$.getScript(mw.util.getUrl("MediaWiki:MapEditor.js") + "?action=raw&ctype=text/javascript", function() { | |||
}); | |||
}); | |||
}); | |||
}); | |||
}); | |||
} | |||
if (document.querySelector(".code")) { | |||
$.getScript("../custom/highlight.min.js", ()=>{ | |||
document.querySelectorAll(".code").forEach(el=>hljs.highlightElement(el)) | |||
console.log('Code highlighted'); | |||
}); | |||
} | |||
if (document.querySelector('[class*="Tracker"]')) { | |||
$.getScript(mw.util.getUrl("MediaWiki:Trackers.js") + "?action=raw&ctype=text/javascript"); | |||
console.log("Tracker loaded"); | |||
} | |||
if (document.getElementById("enemiesDB")) { | |||
$.getScript(mw.util.getUrl("MediaWiki:Update_DB.js") + "?action=raw&ctype=text/javascript"); | |||
console.log("DB Updater Loaded") | |||
} | |||
function hitChance(accuracy, defence) { | |||
} | accuracy = parseInt(accuracy); | ||
defence = parseInt(defence); | |||
let hitChance = 0; | |||
if(accuracy >= defence) { | |||
hitChance = 1; | |||
} else { | |||
hitChance = 1 / (1 + defence - accuracy) | |||
} | } | ||
return (hitChance * 100).toFixed(2); | |||
} | |||
if (document.querySelector('.hitChance')) { | |||
document.querySelectorAll(".hitChance").forEach(el => { | |||
let [acc, def] = el.innerText.split(",") | |||
el.innerText = ""; | |||
const accSpan = document.createElement("span"); | |||
const defSpan = document.createElement("span"); | |||
const hitSpan = document.createElement("span"); | |||
const accInput = document.createElement("input"); | |||
const defInput = document.createElement("input"); | |||
const hitValueSpan = document.createElement("span"); | |||
accSpan.innerText = "Accuracy:"; | |||
defSpan.innerText = "Defence:"; | |||
hitSpan.innerText = "Hit Chance:"; | |||
accInput.type = "number"; | |||
defInput.type = "number"; | |||
accInput.min = 0; | |||
defInput.min = 0; | |||
if ( | if(acc !== "0") { | ||
accInput.disabled = true; | |||
} | |||
if(def !== "0") { | |||
defInput.disabled = true | |||
} | |||
def = def < 0 ? 0 : def; | |||
acc = acc < 0 ? 0 : acc; | |||
accInput.defaultValue = acc; | |||
defInput.defaultValue = def; | |||
accInput.onchange = function(){ | |||
hitValueSpan.innerText = hitChance(accInput.value, defInput.value) + "%"; | |||
} | |||
defInput.onchange = function(){ | |||
hitValueSpan.innerText = hitChance(accInput.value, defInput.value) + "%"; | |||
} | } | ||
}) | el.append(accSpan, accInput, defSpan, defInput, hitSpan, hitValueSpan); | ||
hitValueSpan.innerText = hitChance(accInput.value, defInput.value) + "%"; | |||
}) | |||
} | |||
}); | |||
Revision as of 01:42, 10 February 2026
1 /* Any JavaScript here will be loaded for all users on every page load. */
2 $(document).ready(function () {
3 console.log("loaded")
4 $.getScript(mw.util.getUrl("MediaWiki:ProfileTags.js") + "?action=raw&ctype=text/javascript");
5 if (document.getElementById("interactiveMap")) {
6 console.log("map loaded")
7 $.getScript(mw.util.getUrl("MediaWiki:InteractiveMap/Objects.js") + "?action=raw&ctype=text/javascript", function() {
8 $.getScript(mw.util.getUrl("MediaWiki:InteractiveMap/NPCs.js") + "?action=raw&ctype=text/javascript", function() {
9 $.getScript(mw.util.getUrl("MediaWiki:InteractiveMap/Maps.js") + "?action=raw&ctype=text/javascript", function() {
10 $.getScript(mw.util.getUrl("MediaWiki:InteractiveMap.js") + "?action=raw&ctype=text/javascript", function() {
11 });
12 });
13 });
14 });
15 }
16
17 if (document.getElementById("wardrobe")) {
18 $.getScript(mw.util.getUrl("MediaWiki:Wardrobe.js") + "?action=raw&ctype=text/javascript");
19 console.log("wardrobe loaded")
20 }
21
22 if (document.getElementById("mapEditor")) {
23 $.getScript("https://cdn.jsdelivr.net/npm/interactjs/dist/interact.min.js", function() {
24 $.getScript(mw.util.getUrl("MediaWiki:InteractiveMap/Objects.js") + "?action=raw&ctype=text/javascript", function() {
25 $.getScript(mw.util.getUrl("MediaWiki:InteractiveMap/NPCs.js") + "?action=raw&ctype=text/javascript", function() {
26 $.getScript(mw.util.getUrl("MediaWiki:InteractiveMap/Maps.js") + "?action=raw&ctype=text/javascript", function() {
27 $.getScript(mw.util.getUrl("MediaWiki:MapEditor.js") + "?action=raw&ctype=text/javascript", function() {
28 });
29 });
30 });
31 });
32 });
33 }
34 if (document.querySelector(".code")) {
35 $.getScript("../custom/highlight.min.js", ()=>{
36 document.querySelectorAll(".code").forEach(el=>hljs.highlightElement(el))
37 console.log('Code highlighted');
38 });
39 }
40
41 if (document.querySelector('[class*="Tracker"]')) {
42 $.getScript(mw.util.getUrl("MediaWiki:Trackers.js") + "?action=raw&ctype=text/javascript");
43 console.log("Tracker loaded");
44 }
45
46 if (document.getElementById("enemiesDB")) {
47 $.getScript(mw.util.getUrl("MediaWiki:Update_DB.js") + "?action=raw&ctype=text/javascript");
48 console.log("DB Updater Loaded")
49 }
50 function hitChance(accuracy, defence) {
51 accuracy = parseInt(accuracy);
52 defence = parseInt(defence);
53 let hitChance = 0;
54 if(accuracy >= defence) {
55 hitChance = 1;
56 } else {
57 hitChance = 1 / (1 + defence - accuracy)
58 }
59 return (hitChance * 100).toFixed(2);
60 }
61 if (document.querySelector('.hitChance')) {
62 document.querySelectorAll(".hitChance").forEach(el => {
63 let [acc, def] = el.innerText.split(",")
64 el.innerText = "";
65 const accSpan = document.createElement("span");
66 const defSpan = document.createElement("span");
67 const hitSpan = document.createElement("span");
68 const accInput = document.createElement("input");
69 const defInput = document.createElement("input");
70 const hitValueSpan = document.createElement("span");
71
72 accSpan.innerText = "Accuracy:";
73 defSpan.innerText = "Defence:";
74 hitSpan.innerText = "Hit Chance:";
75
76 accInput.type = "number";
77 defInput.type = "number";
78 accInput.min = 0;
79 defInput.min = 0;
80 if(acc !== "0") {
81 accInput.disabled = true;
82 }
83 if(def !== "0") {
84 defInput.disabled = true
85 }
86 def = def < 0 ? 0 : def;
87 acc = acc < 0 ? 0 : acc;
88 accInput.defaultValue = acc;
89 defInput.defaultValue = def;
90 accInput.onchange = function(){
91 hitValueSpan.innerText = hitChance(accInput.value, defInput.value) + "%";
92 }
93 defInput.onchange = function(){
94 hitValueSpan.innerText = hitChance(accInput.value, defInput.value) + "%";
95 }
96 el.append(accSpan, accInput, defSpan, defInput, hitSpan, hitValueSpan);
97 hitValueSpan.innerText = hitChance(accInput.value, defInput.value) + "%";
98 })
99 }
100
101 });
