Anonymous
×
Create a new article
Write your page title here:
We currently have 922 articles on WIKI - Flat MMO. Type your article name above or click on one of the titles below and start writing!



WIKI - Flat MMO
922Articles

MediaWiki:Common.js: Difference between revisions

m Reverted edit by Coolrock (talk) to last revision by Liam
Tag: Rollback
No edit summary
Line 39: Line 39:
}
}


if (document.querySelector('[class*="Tracker"]')) {
if (document.querySelector('[class*="Tracker"]') && !document.querySelector('[class*="page-MediaWiki"]')) {
$.getScript(mw.util.getUrl("MediaWiki:Trackers.js") + "?action=raw&ctype=text/javascript");
$.getScript(mw.util.getUrl("MediaWiki:Trackers.js") + "?action=raw&ctype=text/javascript");
     console.log("Tracker loaded");
     console.log("Tracker loaded");

Revision as of 02:41, 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"]') && !document.querySelector('[class*="page-MediaWiki"]')) {
 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 });