User:Fngplg/common.js

(function {   var scriptRan = false;    function run {        if(scriptRan) {            return;        }        var buttons = [];        for(var i = 1; i < 12; ++i) {            var button = $('#checkButton' + i);            if(button.exists) {                buttons.push($('#checkButton' + i).click(buttonClick));            }        }        if(buttons.length < 2) {            return;        }        scriptRan = true;        $('#verifyButton1').click(buttonVerify);        function buttonClick {            var $this = $(this);            if($this.hasClass('checkTag')) {                $this.attr('class', 'checkTagActive');            } else if($this.hasClass('checkTagActive')) {                $this.attr('class', 'checkTag');            }        }        function buttonVerify {            var correct1 = true, correct2 = true, $this = $(this);            buttons.forEach(function(b) { if(!b.hasClass('checkTag')) { correct1 = false; }               if(!b.hasClass('checkTagActive')) { correct2 = false; }           });            if(correct1) {                $this.attr('class', 'checkTag visible');            } else if(correct2) {                $this.attr('class', 'checkTag invisible');            }        }    }    mw.hook('wikipage.content').add(run);    $(run); }); /*   Replaces  with the name of the user browsing the page. Requires copying Template:USERNAME. $(function {   if (window.disableUsernameReplace || mw.config.get('wgUserName') === null) { return; }    $('span.insertusername').text(mw.config.get('wgUserName')); }); if (mwCustomEditButtons.length) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "//images.wikia.com/central/images/c/c8/Button_redirect.png", "speedTip": "Redirect", "tagOpen": "#REDIRECT [" + "[", "tagClose": "]]", "sampleText": "Insert text" };	mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "//images.wikia.com/central/images/c/c9/Button_strike.png", "speedTip": "Strike", "tagOpen": " ", "tagClose": " ", "sampleText": "Strike-through text" };	mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "//images.wikia.com/central/images/1/13/Button_enter.png", "speedTip": "Line break", "tagOpen": " ", "tagClose": "", "sampleText": "" };	mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "//images.wikia.com/central/images/7/74/Button_comment.png", "speedTip": "Comment visible only for editors", "tagOpen": "", "sampleText": "Insert comment here" };	mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "https://cdn.pixabay.com/photo/2012/04/11/12/26/alignment-27939_960_720.png", "speedTip": "Center align selected text", "tagOpen": " ", "tagClose": " ", "sampleText": "Centered Text" };	mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "https://upload.wikimedia.org/wikipedia/en/3/39/Pokeball.PNG", "speedTip": "Sprite and Link", "tagOpen": " ",		"tagClose": "", "sampleText": "Pokemon" };	mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://www.babybedding.com/images/fabric/solid-silver-gray-fabric_medium.jpg", "speedTip": "Common", "tagOpen": "", "tagClose": "", "sampleText": "" };	mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://www.rtings.com/images/test-materials/2015/204_Gray_Uniformity.png", "speedTip": "Uncommon", "tagOpen": "", "tagClose": "", "sampleText": "" };	mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://cdn.wallpapersafari.com/43/27/BfyFnY.jpg", "speedTip": "Rare", "tagOpen": "", "tagClose": "", "sampleText": "" };	mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://cdn.wallpapersafari.com/35/18/sGjl2t.jpg", "speedTip": "Rare", "tagOpen": "", "tagClose": "", "sampleText": "" };	mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://pngimg.com/uploads/rainbow/rainbow_PNG5570.png", "speedTip": "Rare", "tagOpen": "", "tagClose": "", "sampleText": "" };	mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "https://upload.wikimedia.org/wikipedia/commons/thumb/2/25/Red.svg/2000px-Red.svg.png", "speedTip": "Red", "tagOpen": " '''", "tagClose": "''' ", "sampleText": "Text" };	mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "https://images.bzflag.org/bnoran/Dark%20Red%20Suede.png", "speedTip": "Dark Red", "tagOpen": " '''", "tagClose": "''' ", "sampleText": "Text" };	mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "https://upload.wikimedia.org/wikipedia/commons/5/5f/Sky_Blue.png", "speedTip": "Blue", "tagOpen": " '''", "tagClose": "''' ", "sampleText": "Text" };	mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "https://upload.wikimedia.org/wikipedia/commons/e/e5/Solid_blue.png", "speedTip": "Dark Blue", "tagOpen": " '''", "tagClose": "''' ", "sampleText": "Text" };	mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "https://vignette4.wikia.nocookie.net/uncyclopedia/images/7/72/Green.png/revision/latest?cb=20060327020342", "speedTip": "Green", "tagOpen": " '''", "tagClose": "''' ", "sampleText": "Text" }; } importArticles({   type: "script",    articles: [        "u:dev:MediaWiki:ArchiveBoards/code.js"    ] }); importArticles({   type: 'script',    articles: [        'u:dev:MessageBlock/code.js'    ] }); importArticles({   type: "script",    articles: [        "u:dev:LockForums/code.js"    ] }); (function {   if(mw.config.get('wgPageName') !== 'Mystery Gift Codes') {        return;    }    var loaded;    mw.hook('wikipage.content').add(function { if($('#WikiaArticleComments') && !loaded) { loaded = true; $('#article-comments').prepend(               $(' ', { id: 'article-comments-warning' }).html('Before you comment: We do NOT make the codes. ')           );        }    }); }); $(function {    $('#mw-content-text .auraCalculatorByHero')    .html(' ' + ' Pokémon Aura value Calculator ' + '' + ' Tints ' + '' + 'None ' + ' 1 ' +           ' 2 ' +            ' 3 ' +            ' 4 ' +            '5 ' + '6 ' + '7 ' + '8 ' + '9 ' + '10 ' + '11 ' + ' ' +       ' Has an animated Aura? ' +       '' + ' No ' + ' Yes ' + ' ' +       ' Has a Recolor? ' +       '' + ' No ' + ' Yes ' + ' ' +       ' Is it a Legendary? ' +       '' + ' No ' + ' Yes ' + ' ' +       '' + ' ' +       ' ' +            ' ' +            ' ' +                ' ' +                    ' Pokémon Aura value Calculator Result ' + ' ' +                   '' + ' Close ' + ' ' +           ' ' +        ' ' +    ' '); }); document.getElementById("submit").addEventListener("click", function {  var tintsElement = document.getElementById("tints");  var tints = tintsElement.value;  var aauraElement = document.getElementById("aaura");  var aura = aauraElement.value;  var recolorElement = document.getElementById("recolor");  var recolor = recolorElement.value;  var legendaryElement = document.getElementById("legendary");  var legend = legendaryElement.value;  var sum = tints * aura * recolor * legend;    // Below this  var tintNum = tintsElement.options[tintsElement.selectedIndex].innerHTML;  var tintTxt;  var tintTxt2;  var auraNum = aauraElement.options[aauraElement.selectedIndex].innerHTML;  var auraTxt;  var recolorNum = recolorElement.options[recolorElement.selectedIndex].innerHTML;  var recolorTxt;  var legendNum = legendaryElement.options[legendaryElement.selectedIndex].innerHTML; var legendTxt; var selected = 0; var comma;

console.log(tints, aura, recolor, legend); document.getElementById("backpane").className = "backpane"; document.getElementById("popup").className = "popup"; if (sum == 1) { document.getElementById("result").innerHTML  =  "Your Pokémon is an ordinary Pokémon with no Auras on it."; } else if (sum == 1000) { document.getElementById("result").innerHTML  =  "Your Pokémon is a Legendary Pokémon with no Auras on it."; } else { if (tints == 1) { tintTxt = ""; selected -= 1; } else { if (tintNum == 1) { tintTxt2 = " tint"; } else { tintTxt2 = " tints"; }     selected += 1; tintTxt = tintNum + tintTxt2; }   if (aura == 1) { auraTxt = ""; selected -= 1; } else { if (selected == 2) { comma = ","; } else if (selected == 1) { comma = " and"; } else if (selected <= 0) { comma = ""; }     auraTxt = comma + " an animated aura"; selected += 1; }   if (recolor == 1) { recolorTxt = ""; } else { recolorTxt = " recolored"; }   if (legend == 1) { legendTxt = "an Ordinary "; } else { legendTxt = "a Legendary "; }   document.getElementById("result").innerHTML  =  "Your Pokémon is " + legendTxt + recolorTxt + " Pokémon with " + tintTxt + auraTxt + " on it, and with the rarity of " + "1/" + sum + selected + "."; // Final Result } }); document.getElementById("calcClose").addEventListener("click", function { document.getElementById("backpane").className = "backpane hide"; document.getElementById("popup").className = "popup hide"; });