Welcome to IOPWiki, Commander.
With the release of the new game, we encourage contributions to topics related to Girls' Frontline 2. Learn how to contribute, read the maintenance guide, and join our Discord server to discuss major changes.
If you or someone you know can help deciphering the game files, contact our administrator.

MediaWiki:Common.js

Welcome to IOP Wiki. This website is maintained by the Girls' Frontline community and is free to edit by anyone.
Revision as of 03:21, 31 August 2016 by Pianoforte (talk | contribs) (Created page with "→‎Any JavaScript here will be loaded for all users on every page load.: $(document).ready(function() { build_skill_form(); }); function build_skill_form() {...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */

$(document).ready(function() {         
	build_skill_form();
});
 
function build_skill_form() {
    if (skill_data[mw.config.get("wgPageName")]) {
        calculator_element = document.getElementById("skill_calculator");
        calculator_element.outerHTML =
            '<div id="skill_calculator"><table style="width:100%"><tr>' +
                '<th>Skill Level</th>' +
                '<th>Activation Chance</th>' +
                '<th colspan="4">Description</th>' +
            '</tr><tr>' +
                '<th><select id="skill_level" onchange="display_data()">' +
                    '<option value="0">Level 1</option>' +
                    '<option value="1">Level 2</option>' +
                    '<option value="2">Level 3</option>' +
                    '<option value="3">Level 4</option>' +
                    '<option value="4">Level 5</option>' +
                    '<option value="5">Level 6</option>' +
                    '<option value="6">Level 7</option>' +
                    '<option value="7">Level 8</option>' +
                    '<option value="8">Level 9</option>' +
                    '<option value="9">Level 10</option>' +
                '</select></th><th id="activation"></th><th id="description"></th>' +
            '</tr></table></div>';
        display_data();
    }
}
 
function display_data() {
    data = skill_data[mw.config.get("wgPageName")];
    if (data !== null) {
        index = document.getElementById("skill_level").value;
        regex = /\(\$\w+\)/g;
        formatted_text = data.text;
        vars = data.text.match(regex);
        for (i = 0; i < vars.length; i++) {
            var_name = vars[i].substring(2, vars[i].length - 1);
            formatted_text = formatted_text.replace(
                vars[i],
                data[var_name][index]);
        }
        document.getElementById("activation").outerHTML =
            '<th id="activation">' + data.activation[index] + '</th>';
        document.getElementById("description").outerHTML =
            '<th id="description">' + formatted_text + '</th>';
    }
}
 
skill_data = {
    'Kar98k': {
        text: "After taking aim for 2 seconds, shoot the nearest target for ($damage_value) the damage.",
        activation: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
        damage_value: [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],
        time: [2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9],
    },
};