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: Difference between revisions

Welcome to IOP Wiki. This website is maintained by the Girls' Frontline community and is free to edit by anyone.
Jump to navigation Jump to search
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. */
$(document).ready(function() {        
$(document).ready(function() {
$.getScript( "index.php?title=MediaWiki:SkillData.js&action=raw&ctype=text/javascript");
     build_skill_form();
     build_skill_form();
});
});
Line 48: Line 49:
             '<p id="description">' + formatted_text + '</p>';
             '<p id="description">' + formatted_text + '</p>';
     }
     }
}
function get_skill_data() {
    skill_data = {
        'Kar98k': {
            text: "After taking aim for 2 seconds, shoot the nearest target for ($damage_value)x Kar98k's base damage.",
            activation: ['16.0', 18.1, 20.3, 22.4, 24.5, 26.7, 28.8, 30.9, 33.1, 35.2],
            damage_value: ['4.0', 4.5, 5.1, 5.6, 6.1, 6.7, 7.2, 7.7, 8.3, 8.8],
        },
        'FAL': {
            text: "Launch a grenade that deals ($damage_value) times FAL's base damage to enemies within a radius of 4 units.",
            activation: ['18.0', '21.0', '24.0', '27.0', '30.0', '33.0', '36.0', '39.0', '42.0', '45.0'],
            damage_value: ['1.0', 1.2, 1.3, 1.5, 1.7, 1.8, '2.0', 2.2, 2.3, 2.5],
        },
    };
    return skill_data;
}
}

Revision as of 00:31, 6 September 2016

/* Any JavaScript here will be loaded for all users on every page load. */
$(document).ready(function() {
	$.getScript( "index.php?title=MediaWiki:SkillData.js&action=raw&ctype=text/javascript");
    build_skill_form();
});
 
function build_skill_form() {
    skill_data = get_skill_data();
    if (skill_data[mw.config.get("wgPageName")]) {
        calculator_element = document.getElementById("skill_calculator");
        calculator_element.outerHTML =
            '<div id="skill_calculator" style="position:absolute"><table cellspacing="5"><tr>' +
                '<td rowspan="2" style="background:rgba(128, 128, 128, 0);width:52px;height:52px"></td>' +
                '<td colspan="2" style="background:rgba(255, 255, 255, 0.25)">&#8199;</td>' +
            '</tr><tr>' +
                '<td ><select style="color:rgba(128, 128, 128, 1);width:60px;text-align:center" id="skill_level" onchange="display_data()">' +
                    '<option value="0">Lv. 1</option>' +
                    '<option value="1">Lv. 2</option>' +
                    '<option value="2">Lv. 3</option>' +
                    '<option value="3">Lv. 4</option>' +
                    '<option value="4">Lv. 5</option>' +
                    '<option value="5">Lv. 6</option>' +
                    '<option value="6">Lv. 7</option>' +
                    '<option value="7">Lv. 8</option>' +
                    '<option value="8">Lv. 9</option>' +
                    '<option value="9">Lv. 10</option>' +
                '</select></td><td id="activation"></td></tr><tr></tr></table><p id="description"></p></div>';
        display_data();
    }
}
 
function display_data() {
    skill_data = get_skill_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 =
            '<td id="activation" style="color:rgba(255, 182, 0, 1)">' + data.activation[index] + '% chance to activate</td>';
        document.getElementById("description").outerHTML =
            '<p id="description">' + formatted_text + '</p>';
    }
}