FANDOM


//
(function (window, $, mw) {
    "use strict";
    //Global Variables
    var page_name = mw.config.get("wgPageName"),
        server = mw.config.get("wgServer"),
        skin = mw.config.get("skin"),
        token = mw.user.tokens.values.editToken,
        page_id = mw.config.get("wgArticleId"),
        namespace = mw.config.get("wgNamespaceNumber"),
        signature = "~~" + "~~",
        modal_title,
        modal_html,
        modal_id,
        modal_button_name,
        modal_function_to_call;
 
    //Adds buttons
    if ( skin === 'oasis' || skin === 'wikia' ) {
        var node = document.createElement('a');
            node.textContent = "Zaawansowane narzędzia";
            node.className = "wikia-button";
            node.id = "advanced_tools";
            node.addEventListener('click', function () {
                mainMenu();
            });
        $('li.start-a-wiki').html($(node));
    } else {
        $('<li id="ca-at"><a id="at-open">Zaawansowane narzędzia</a></li>').appendTo( '#p-cactions > .pBody > ul' );
        $('#at-open').click(function () { mainMenu(); });
        mw.loader.load( $.getSassCommonURL( 'skins/oasis/css/core/modal.scss' ), 'text/css' );
        mw.loader.load( $.getSassCommonURL( 'skins/oasis/css/core/buttons.scss' ), 'text/css' ); 
    }
    $('#advanced_tools').prepend('<img src="http://images4.wikia.nocookie.net/__cb20120305173219/dev/images/5/50/Bookmark16.png" />&nbsp;');
    mw.util.addCSS('#advanced_tools{-webkit-border-radius:20px!important;-moz-border-radius:20px!important;border-radius:20px!important;border: 2px solid white !important;}');
 
    //Un-urlencoding pagename
    page_name = page_name.replace(/_/g, ' ');
 
    //Main menu modal
    function mainMenu() {
        $.showCustomModal("Zaawansowane narzędzia", '<form class="WikiaForm" method="" name=""><fieldset><div style="text-align: center;"><a class="wikia-button" id="at-block">Zablokuj</a>&nbsp;<a class="wikia-button" id="at-delete">Usuń stronę</a>&nbsp;<a class="wikia-button" id="at-move">Przenieś stronę</a>&nbsp;<a class="wikia-button" id="at-protect">Zabezpiecz/Odbezpiecz stronę</a>&nbsp;<a class="wikia-button" id="at-purge">Odśwież stronę</a><br><br><a class="wikia-button" id="at-redirect">Przenieś stronę</a>&nbsp;<a class="wikia-button" id="at-redlinks">Usuń redlinki</a>&nbsp;<a class="wikia-button" id="at-switch">Zmień skórkę</a>&nbsp;<a class="wikia-button" id="at-template">Dodaj szablon</a>&nbsp;<a class="wikia-button" id="at-unsigned">Dodaj niepodpisane</a>&nbsp;<a class="wikia-button" id="at-batch">Usuń więcej stron</a></div></fieldset><br /><h6 style="float:left">©<a href="http://c.wikia.com/wiki/User:Princess_Platinum">Princess Platinum</a> 2013 | Tłumaczenie <a href="http://c.wikia.com/wiki/User:NCRGresiu">NCRGresiu</a>| Skrypt na redlinki <a href="http://c.wikia.com/wiki/User:Madnessfan34537">Madnessfan34537</a> | Dodatkowa pomoc: <a href="http://c.wikia.com/wiki/User:Callofduty4">Callofduty4</a> i <a href="http://c.wikia.com/wiki/User:TK-999">TK-999</a>&nbsp;|&nbsp;<a href="http://www.dev.wikia.com/wiki/ListFiles">ListFiles</a> wczytano automatycznie</h6></form>', {
            id: "advancedtools",
            width: 650,
            buttons: [{
                id: "close-menu",
                defaultButton: true,
                message: "Close form",
                handler: function() { $("#advancedtools").closeModal(); }
            }]
        });
 
        //Stupid Hack
        $("#at-block").click(function () {
            modal("block");
        });
        $("#at-delete").click(function () {
            modal("delete");
        });
        $("#at-move").click(function () {
            modal("move");
        });
        $("#at-protect").click(function () {
            modal("protect");
        });
        $("#at-purge").click(function () {
            $.get('/index.php?title='+encodeURIComponent(page_name)+'&action=purge',function(){location.reload(true);});
        });
        $("#at-redirect").click(function () {
            modal("redirect");
        });
        $("#at-redlinks").click(function () {
            $.getJSON('/api.php?action=query&prop=revisions&titles='+encodeURIComponent(page_name)+'&rvprop=content&indexpageids=1&format=json',function(result){var text=result.query.pages[result.query.pageids[0]].revisions[0]['*'];var redlinks=$('a.new');var ref=0;while(text.indexOf('[[',ref)!=-1){if(text.indexOf(']]',text.indexOf('[[',ref))!=-1){var open=text.indexOf('[[',ref);var pipe=text.indexOf('|',open);var close=text.indexOf(']]',open);if(text.indexOf('<br/>',open)!=-1&&text.indexOf('<br/>',open)<close){ref=open+1;continue;}if(pipe!=-1&&pipe<close){if(pipe==close-1){var title=text.substring(open+2,pipe);var display=title.substring(title.indexOf(':')+1);}else{var title=text.substring(open+2,pipe);var display=text.substring(pipe+1,close);}}else{var title=text.substring(open+2,close);var display=title;}if(!title){ref=open+1;continue;}for(var i=0;i<redlinks.length;i++){var utitle=title[0].toUpperCase()+title.substring(1);if(redlinks[i].title.indexOf(' (page does not exist)')){var redlink=redlinks[i].title.substring(0,redlinks[i].title.length-22);}else{var redlink=redlinks[i];}if(utitle==redlink||utitle==':'+redlink){if(pipe==close-1){var show=title;}else{var show=display;}text=text.substring(0,open)+show+text.substring(close+2);break;}}ref=open+2;}else{break;}}$.getJSON('/api.php?action=query&prop=info&titles='+encodeURIComponent(page_name)+'&intoken=edit&indexpageids=1&format=json',function(result){$.post('/api.php',{action:'edit',title:page_name,text:text,summary:'Fixing redlinks',token:token},function(){window.location.reload();});});});
        });
        $("#at-switch").click(function() {
            if(!document.getElementById("ca-skins")){if(skin==="oasis"||skin==="wikia"){window.location=server+"/wiki/"+encodeURIComponent(page_name)+"?useskin=monobook";}else{window.location=server+"/wiki/"+encodeURIComponent(page_name)+"?useskin=wikia";}}
        });
        $("#at-template").click(function () {
            modal("template");
        });
        $("#at-unsigned").click(function () {
            if(-1<[1,3,4,5,7,9,11,13,15,110].indexOf(namespace)){$.getJSON("/api.php",{action:"query",prop:"revisions",titles:page_name,rvprop:"user",format:"json",indexpageids:1},function(json){var user=json.query.pages[page_id].revisions[0].user,addText='{{Unsigned|'+user+'}}';var summary="Dodawanie niepodpisanego szablonu do ";url=server+'/api.php?action=edit&title='+encodeURIComponent(page_name)+'&appendtext='+encodeURIComponent(addText)+'&summary='+encodeURIComponent(summary)+''+encodeURIComponent(user)+'&token='+encodeURIComponent(token);$.post(url,function(){alert('Niepodpisany szablon dodany!');});});}
        });
        $("#at-batch").click(function () {
            modal("batch");
        });
    }
 
    function modal(mode) {
        //Close main modal
        $("#advancedtools").closeModal();
        //Switch function (more compact?)
        switch (mode) {
        case "block":
            modal_title = "Zablokuj użytkownika";
            modal_html = '<strong>Nazwa użytkownika/IP do zablokowania:</strong><br /><input type="text" id="block-username" placeholder="Nazwa użytkownika/IP" style="width: 500px"></input><br /><strong>Długość blokady:</strong><br /><input type="text" id="block-duration" placeholder="2 tygodnie" style="width: 500px"></input><br /><strong>Powód blokady:</strong><br /><input type="text" id="block-reason" placeholder="Spamowanie" style="width: 500px"></input>';
            modal_id = "block";
            modal_button_name = "Zablokuj";
            modal_function_to_call = function () { var user = document.getElementById('block-username').value, expiry = document.getElementById('block-duration').value, reason = document.getElementById('block-reason').value; ajaxBlock(user, expiry, reason); };
            break;
        case "delete":
            modal_title = "Usuń stronę";
            modal_html = '<strong>Nazwa strony do usunięcia:</strong><br/><input type="text" id="delete-page" style="width: 500px;"></input><br /><strong>Powód usunięcia: </strong><br /><input type="text" id="delete-reason" placeholder="Spam" style="width: 500px;"></input>';
            modal_id = "delete";
            modal_button_name = "Usuń";
            modal_function_to_call = function () { var page = document.getElementById('delete-page').value, reason = document.getElementById('delete-reason').value; ajaxDelete(page, reason); };
            break;
        case "move":
            modal_title = "Przenieś stronę";
            modal_html = '<strong>Nowa nazwa:</strong><br /><input type="text" id="move-destination" placeholder="Nowa nazwa" style="width: 500px"></input><br /><strong>Reason for moving: </strong><br /><input type="text" id="move-reason" placeholder="Ta bardziej mi się podoba" style="width: 500px;"></input><br /><strong>Zostaw przeniesienie </strong><input type="checkbox" id="redirect-check" />';
            modal_id = "move";
            modal_button_name = "Przenieś";
            modal_function_to_call = function () { var destination = document.getElementById('move-destination').value, reason = document.getElementById('move-reason').value; ajaxMove(destination, reason); };
            break;
        case "protect":
            modal_title = "Zabezpiecz/Odbezpiecz stronę";
            modal_html = '<strong>Strona: </strong><input type="checkbox" id="protect-toggle"></input><br /><strong>Długość zabezpieczenia:</strong><br /><input type="text" id="protect-duration" style="width: 500px;" placeholder="3 days"></input><br /><strong>Powód zabezpiecznia/odbezpieczenia: </strong><br /><input type="text" id="protect-reason" placeholder="Wandalizmy" style="width: 500px;"></input>';
            modal_id = "protect";
            modal_button_name = "Zabezpiecz/Odbezpiecz";
            modal_function_to_call = function () { var duration = document.getElementById('protect-duration').value, reason = document.getElementById('protect-reason').value; ajaxProtect(duration, reason); };
            break;
        case "redirect":
            modal_title = "Stwórz przeniesienie";
            modal_html = '<strong>Przeniesienie:</strong><br /><input type="text" id="redirect-from" style="width: 500px;"></input><br /><strong>Do:</strong><br /><input type="text" id="redirect-location" placeholder="Ameryka" style="width: 500px"></input>';
            modal_id = "redirect";
            modal_button_name = "Stwórz";
            modal_function_to_call = function () { var from= document.getElementById('redirect-from').value, to = document.getElementById('redirect-location').value; ajaxRedirect(from, to); };
            break;
        case "template":
            modal_title = "Dodaj szablon";
            modal_html = '<strong>Nazwa szablonu:</strong><br /><input type="text" id="template-name" style="width: 500px;" placeholder="Nazwa"/><br /><strong>Parametry szablonu:</strong><br /><input type="text" id="template-parameters" style="width: 500px" placeholder="Spam|~~~~" />';
            modal_id = "template";
            modal_button_name = "Dodaj";
            modal_function_to_call = function () { var name = document.getElementById('template-name').value, param = document.getElementById('template-parameters').value; ajaxTemplate(name, param); };
            break;
        case "batch":
            modal_title = "Usuń więcej stron";
            modal_html = '<textarea id="abd-textarea" style="height: 20em;width: 500px;"></textarea><p><label for="abd-reason">Powód usunięcia:</label><input id="abd-reason"style="width: 20em;" type="text"></p><br /><pre style="border: solid 1px grey; width: 500px; height: 60px; overflow: scroll;" id="abd-output"></pre>';
            modal_id = "batch-delete";
            modal_button_name = "Start!";
            modal_function_to_call = function () { ajaxDeleteStart2(); };
            break;
        default:
            alert("Wykryto błąd!");
            break;
        }
 
        //Modal thing
        $.showCustomModal(modal_title, '<form class="WikiaForm" method="" name=""><fieldset>' + modal_html + '</feildset></form>', {
            id: modal_id,
            width: 650,
            buttons: [{
                id: "cancel",
                message: "Anuluj",
                handler: function () {
                    $('#' + modal_id + '').closeModal();
                    mainMenu();
                }
            }, {
                id: "submit",
                defaultButton: true,
                message: modal_button_name,
                handler: modal_function_to_call
            }]
        });
        //Small helper thangs
        document.getElementById('delete-page').value = page_name;
        document.getElementById('move-destination').value = page_name;
    }
 
    //List of functions
    /* Block user */
 
    function ajaxBlock(user, expiry, reason) {
        var url = wgServer + '/api.php?action=block&user=' + encodeURIComponent(user) + '&expiry=' + encodeURIComponent(expiry) + '&reason=' + encodeURIComponent(reason) + '&nocreate&autoblock&noemail&format=json&token=' + encodeURIComponent(token);
        $.post(url, function () {
            $('#block').closeModal();
        });
    }
 
    /* Delete page */
 
    function ajaxDelete(page, reason) {
        var url = wgServer + '/api.php?action=delete&title=' + encodeURIComponent(page) + '&reason=' + encodeURIComponent(reason) + '&format=json&token=' + encodeURIComponent(token);
        $.post(url, function () {
            $('#delete').closeModal();
            document.location.reload(false);
        });
    }
 
    /* Move page */
 
    function ajaxMove(destination, reason) {
        var url;
        if ($('#redirect-check').prop('checked')) {
            url = wgServer + wgScriptPath + '/api.php?action=move&from=' + encodeURIComponent(page_name) + '&to=' + encodeURIComponent(destination) + '&reason=' + encodeURIComponent(reason) + '&format=json&token=' + encodeURIComponent(token);
            $.post(url, function () {
                $('#move').closeModal();
                document.location.reload(false);
            });
        } else {
            url = wgServer + wgScriptPath + '/api.php?action=move&from=' + encodeURIComponent(page_name) + '&to=' + encodeURIComponent(destination) + '&reason=' + encodeURIComponent(reason) + '&format=json&noredirect&token=' + encodeURIComponent(token);
            $.post(url, function () {
               $('#move').closeModal();
               document.location.reload(false);
            });
        }
    }
 
    /* (Un)Protect page */
 
    function ajaxProtect(duration, reason) {
        var url;
        if ($('#protect-toggle').prop('checked') === false) {
            url = wgServer + '/api.php?action=protect&title=' + encodeURIComponent(page_name) + '&protections=edit=sysop%7Cmove=sysop&expiry=' + encodeURIComponent(duration) + '&reason=' + encodeURIComponent(reason) + '&token=' + encodeURIComponent(token);
            $.post(url, function () {
                $('#protect').closeModal();
            });
        } else {
            url = wgServer + '/api.php?action=protect&title=' + encodeURIComponent(page_name) + '&protections=edit=all%7Cmove=all&token=' + encodeURIComponent(token);
            $.post(url, function () {
                $('#protect').closeModal();
            });
        }
    }
 
    /* Redirect page */
 
    function ajaxRedirect(from, to) {
        var Text = '#REDIRECT [[' + to + ']]';
        var url = wgServer + '/api.php?action=edit&title=' + encodeURIComponent(from) + '&text=' + encodeURIComponent(Text) + '&summary=Redirecting&format=json&token=' + encodeURIComponent(token);
        $.post(url, function () {
            $('#redirect').closeModal();
            document.location.reload(false);
        });
    }
 
    /* Template */
 
    function ajaxTemplate(name, param) {
        var sig = '~~' + '~~',
            addtexttalk = '<br /><br /> {{subst:' + name + '|' + param + '}} ' + sig,
            addtextother = '{{' + name + '|' + param + '}} <br />',
            reason = "Korzystasz z zaawansowanej wersji [[w:c:dev:QuickTools|QuickTools]] przetłumacznej przez [[w:User:NCRGresiu|Gresia]]",
            url;
        if (-1 < [1, 3, 5, 7, 9, 11, 13, 15].indexOf(namespace)) {
            url = server + '/api.php?action=edit&title=' + encodeURIComponent(page_name) + '&appendtext=' + encodeURIComponent(addtexttalk) + '&summary=' + encodeURIComponent(reason) + '&token=' + encodeURIComponent(token);
            $.post(url, function () {
                alert('Template appended!');
            });
        }
        if (-1 < [0, 2, 4, 6, 8, 10, 12, 14].indexOf(namespace)) {
            url = server + '/api.php?action=edit&title=' + encodeURIComponent(page_name) + '&prependtext=' + encodeURIComponent(addtextother) + '&summary=' + encodeURIComponent(reason) + '&token=' + encodeURIComponent(token);
            $.post(url, function () {
                alert('Template prepended!');
            });
        }
    }
 
    /* Batch Delete */
 
    function ajaxDeleteStart2() {
        var txt = document.getElementById('abd-textarea'),
            deletes = txt.value.split('\n'),
            page = deletes[0],
            reason = document.getElementById('abd-reason').value,
            badchars = /(\#|<|>|\[|\]|\{|\}|\|)/;
        setInterval(function() {
            var div = $('#abd-output');
                 div.scrollTop( div.get(0).scrollHeight );
        }, 500);
        if (page === '') {
            $('#abd-output').append('* Gotowe!\n');
        } else {
            if (badchars.test(page)) {
                $('#abd-output').append('! Wykryto niedozwolone znaki, omijając' + page + '\n');
                setTimeout(ajaxDeleteStart2, 1000);
            } else {
                $('#abd-output').append('> Próba usunięcia [[' + page + ']]\n');
                ajaxBatchDeleteAPage(page, reason);
            }
        }
        deletes = deletes.slice(1, deletes.length);
        txt.value = deletes.join('\n');
    }
 
    function ajaxBatchDeleteAPage(title, deleteReason) {
        var token = mw.user.tokens.get('editToken'),
            url = wgServer + wgScriptPath + '/api.php?action=delete&title=' + window.encodeURIComponent(title) + '&reason=' + window.encodeURIComponent(deleteReason) + '&format=json&token=' + window.encodeURIComponent(token);
 
        $.post(url, function (data) {
            if (data.error) {
                $('#abd-output').append('  > Błąd: ' + data.error.info + '\n');
            } else {
                $('#abd-output').append('  > Usunięto\n');
            }
            setTimeout(ajaxDeleteStart2, 1000);
        });
    }
 
    /* Creates small text lists */
 
    var specialpages = ["Special:BrokenRedirects", "Special:DoubleRedirects", "Special:DeadendPages", "Special:BrokenRedirects", "Special:LonelyPages", "Special:UnusedTemplates"];
 
    if (specialpages.indexOf(wgPageName) !== -1) {
        $('#WikiaArticle').prepend('<textarea id="output-box" rows="10" cols="100"></textarea>');
 
        $('ol.special').find('li').each(function() {
            var text = $(this).find('a').first().text();
            document.getElementById('output-box').value += text + '\n';
        });
    }
    mw.loader.load('http://dev.wikia.com/wiki/ListFiles/code.js?action=raw');
}(this, this.jQuery, this.mediaWiki));
//

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Więcej z Fandomu

Losowa wiki