Jump to content

User:Ladsgroup/election.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/** voting tools ************************************************
 *
 *  by [[w:fa:user:ebraminio]] and copied from [[w:fa:مدیاویکی:Gadget-election.js]] */
/*<pre>*/
 
function extpar(par) {
    return location.href.replace(RegExp(".*?[&?]" + par + "=([^&]*).*"), "$1");
}
$(function () {
    vote = extpar("vote");
    if (/(support|oppose|neutral)/.test(vote)) {
        subcontent = $('#wpTextbox1').val();
        var bodycontent = $('#bodyContent') || $('#mw_contentholder');
        bodycontent.css("display", "none");
        subcontent.replace(/\n$/, "");
        if (subcontent.search(RegExp(wgUserName, "i")) != -1) {
            alert("Submitted already");
        } else {
            var why = 0;
            if (extpar("comment") == "yes") why = prompt("reason");
            why = why ? why + " " : "";
            if (vote == "oppose") {
                vote = "Oppose";
            } else if (vote == "support") {
                vote = "Support";
            } else if (vote == "neutral") {
                vote = "Neutral";
            }
            $('#wpTextbox1').val(subcontent + "#{{" + vote + "}} ~~" + "~~");
            $('#wpSummary').val("An" + vote + "by the election tool. [[User:Ladsgroup/election.js|See more]]");
        }
        document.editform.submit();
    }
});
/*</pre>*/