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

No edit summary
No edit summary
Line 36: Line 36:
console.log('Code highlighted');
console.log('Code highlighted');
});
});
}
if (document.querySelector(".mapChestTracker")) {
$.getScript(mw.util.getUrl("MediaWiki:Chest_Tracker.js") + "?action=raw&ctype=text/javascript");
    console.log("Chest Tracker loaded");
}
}



Revision as of 21:32, 4 December 2025

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