User:Syrénix Sérénité/global.js

massCategorizationDelay = 1000; importArticles({   type: 'script',    articles: [        'u:dev:ListFiles/code.js',        'u:dev:DupImageList/code.js',        'u:dev:MassCategorization/code.js',        'u:dev:PurgeButton/code.js'    ] }); /* OverPowered MultiUpload script */ (function ($) {   var i18n = {        en: {            logout: "You have to be log in and autoconfirmed to upload files",            update: "Update the form",            nofile: "You have to choose a file to upload it",            imagename: 'Image n°',            filename: 'File name : ',            licensetext: 'File license : ',            uploadfiles: 'Upload all images',            browsersupport: 'This browser doesn\'t seem to support the `files` property of file inputs.',            nolicence: 'None selected',            problem: 'A problem occured, upload cancelled',            success: 'Image uploaded successfully.',            duplicate: 'This image is a doublon of : ',            alreadyname: 'A image has already this name, please choose an other one below :',            reset: 'Reset the form',            description: 'Summary :',            filedescription: 'File description' },       fr: { logout: "Vous devez être connecté et autoconfirmed pour importer des fichiers", update: "Mettre à jour le formulaire", nofile: "Vous devez choisir un fichier pour l'importer !", imagename: 'Image n°', filename: 'Nom du fichier : ', licensetext: 'Licence du fichier : ', uploadfiles: 'Importer les images', browsersupport: 'Ce navigateur n\'a pas l\'air de reconnaître l\'attribut file des file inputs', nolicence: 'Aucune licence sélectionné', problem: 'Un problème est survenu, l\'opération a été annulé', success: 'Les images ont été importés avec succès.', duplicate: 'Cette image est un doublon de l\'image : ', alreadyname: 'Une image porte déjà ce nom sur ce wikia, merci donc de choisir un autre nom', reset: 'Remettre à zéro le formulaire', description: 'Description :', filedescription: 'Description du fichier' },	es: { logout: "Debes haber iniciado sesión y estar autoconfirmado para subir archivos", update: "Actualizar el formulario", nofile: "Tienes que elegir un archivo para subirlo", imagename: 'Imagen n°', filename: 'Nombre del archivo : ', licensetext: 'Licencia del archivo : ', uploadfiles: 'Subir todas las imágenes', browsersupport: 'Este navegador no parece soportar la propiedad `files` de las entradas de archivo.', nolicence: 'Ninguna seleccionada', problem: 'Ha ocurrido un problema, subida cancelada', success: 'Imagen subida satisfactoriamente.', duplicate: 'Esta imagen es un duplicado de : ', alreadyname: 'Una imagen ya tiene este nombre, por favor escoge otro nombre debajo:', reset: 'Reiniciar el formulario', description: 'Sumario:', filedescription: 'Descripción del archivo' },       pl: { logout: "Musisz być zalogowany i mieć potwierdzone konto, aby móc przesyłać pliki", update: "Zaktualizuj formularz", nofile: "Musisz wybrać plik, aby go przesłać", imagename: 'Obraz n°', filename: 'Nazwa pliku : ', licensetext: 'Licencja pliku : ', uploadfiles: 'Prześlij wszystkie pliki', browsersupport: 'Ta przeglądarka nie wspiera właściwości `files` na wejściu.', nolicence: 'Nic nie wybrano', problem: 'Wystąpił problem, przesyłanie anulowane', success: 'Obrazy zostały przesłane.', duplicate: 'Ten obraz jest duplikatem : ', alreadyname: 'Inny obraz już posiada tą nazwę, proszę wybierz poniżej inną :', reset: 'Wyczyść formularz', description: 'Opis :', filedescription: 'Opis pliku' }   };    // UserLanguage > ContentLanguage > ENGLISH i18n = $.extend(i18n.en, i18n[mw.config.get('wgContentLanguage')], i18n[mw.config.get('wgUserLanguage')]); var MultiUpload = { init: function { $('#my-tools-menu').prepend(' Multi Upload'); if (mw.config.get('wgCanonicalSpecialPageName') === 'Blankpage' && $.getUrlVar('blankspecial') === 'MultiUpload') { if (wgUserName === null || !$.inArray('autoconfirmed', wgUserGroups)) { /* If the user don't have multiple upload rights (if it's not autoconfirmed) */ $('#mw-content-text').html(i18n.logout); return false; }               var MultiUploadoption = MultiUploadoption || {}; $.extend(MultiUpload, MultiUploadoption); $('#mw-content-text').remove; $('#WikiaArticle').append('\n Ici \n ' + i18n.update + ' '); $('#editor').css('display', 'none'); var token = mw.user.tokens.get('editToken'); $('.AdminDashboardArticleHeader > h1').html('Multi Upload'); var filename; }       },        updatelicensebutton: function (licencestext) { if (licencestext !== null) { var licences = licencestext.split('\n'); if (licences[licences.length - 1] === ) { licences.splice(-1, 1); //Remove last line as it is empty }               $('.licence').replaceWith('  '); $('.licence').prepend(' ' + i18n.nolicence + ' '); for (i = 0; i < licences.length; i++) { if (licences[i].indexOf('** ') === 0) { licences[i] = licences[i].replace("** ", ""); if (licences[i].split('|')[0] == MultiUpload.defaultlicence) { $('.licence').find('optgroup:last-child').append('' + licences[i].split('|')[1] + ' '); } else { $('.licence').find('optgroup:last-child').append('' + licences[i].split('|')[1] + ' '); }                   } else { licences[i] = licences[i].replace('* ', ); $('.licence').append('</optgroup'); }               }            }        },        getlicence: function  { $.ajax({               type: "GET",                url: wgServer + '/api.php?action=query&meta=allmessages&ammessages=Licenses&format=json',                success: function (data) {                    var content = data.query.allmessages[0]['*'];                    MultiUpload.updatelicensebutton(content);                },                error: function (data) {                    alert(i18n.errorapi + ' : ' + data.error.info);                }            }); },       update: function  { if ($('fieldset').length > 0) { MultiUpload.handleFileSelect; return false; }           $('#editor').css('display', 'block'); $('#fileinput').attr("disabled", true); input = document.getElementById('fileinput'); $('#editor').html(); if (input.files.length === 0) { alert(i18n.nofile); return false; }           if (!MultiUpload.max || typeof MultiUpload.max != "number" || MultiUpload.max < 0 || MultiUpload.max > 101) { if ($.inArray('staff', wgUserGroups) + $.inArray('helper', wgUserGroups) + $.inArray('util', wgUserGroups) + $.inArray('bot-global', wgUserGroups) > -4) { MultiUpload.max = 200; } else if ($.inArray('bureaucrat', wgUserGroups) + $.inArray('bot', wgUserGroups) > -2) { MultiUpload.max = 70; } else if ($.inArray('sysop', wgUserGroups) > -1) { MultiUpload.max = 50; } else if ($.inArray('rollback', wgUserGroups) > -1) { MultiUpload.max = 1200; } else { MultiUpload.max = 1000; }           }            if (!MultiUpload.max) { alert(lng.problem); return false; }           var limit; if (MultiUpload.max < input.files.length) { limit = MultiUpload.max; } else { limit = input.files.length; }           for (i = 0; i < limit; i++) { $('#editor').append(' ' + i18n.imagename + (i + 1) + ' ' + i18n.filename + '  ' + i18n.licensetext + ' '); }           MultiUpload.getlicence; $('#editor').append(' ' + i18n.filedescription + '  '); $('#go').html(i18n.uploadfiles); },       handleFileSelect: function  { input = document.getElementById('fileinput'); if (!input.files) { alert(i18n.browsersupport); $('#fileinput').attr("disabled", false); } else if (!input.files[0]) { alert(i18n.problem); $('#fileinput').attr("disabled", false); } else { $('fieldset').attr('disabled', 'disabled'); $('#go').attr('disabled', 'disabled'); var numberfiles = $('fieldset').length - 1; if (numberfiles > 0) { for (i = 0; i < numberfiles; i++) { file = input.files[i]; filename = $('.imagename').eq(i).val || input.files[i].name; console.log(filename); if ($('#WikiaArticle').find('select:eq(' + i + ')').find('option:selected').val !== "none") { licence = '{' + '{' + $('#WikiaArticle').find('select:eq(' + i + ')').find('option:selected').val + '}}' + '\n' + $('#UploadDescription').val; } else { licence = $('#UploadDescription').val; }                       console.log(licence); $('#loading' + (i + 1)).css('display', 'initial'); MultiUpload.uploadfiles(file, filename, licence); }                   alert(i18n.success); $('#go').html(i18n.reset); $('#go').removeAttr('disabled'); $('#go').click(function (event) {                       if ($('#go').html == i18n.reset) {                        event.stopPropagation;                        $('#WikiaArticle').find('*').attr("disabled", false);                        $('#editor').html();                        $('#editor').css('display', 'none');                        $('#go').html(i18n.update);                        $('#fileinput').val();                        }                    }); }           }        },        uploadfiles: function (fileToUpload, fileName, licence) { var lFileName = fileName; formdata = new FormData; //see https://developer.mozilla.org/en-US/docs/Web/Guide/Using_FormData_Objects?redirectlocale=en-US&redirectslug=Web%2FAPI%2FFormData%2FUsing_FormData_Objects formdata.append('action', 'upload'); formdata.append('filename', lFileName); formdata.append('token', mw.user.tokens.get('editToken')); formdata.append('file', fileToUpload); formdata.append('text', licence); formdata.append('format', 'json'); //as we now have created the data to send, we send it... $.ajax({ //http://stackoverflow.com/questions/6974684/how-to-send-formdata-objects-with-ajax-requests-in-jquery               url: mw.util.wikiScript('api'), //url to api.php                 contentType: false,                processData: false,                type: 'POST',                data: formdata, //the formdata object we created above                dataType: 'json',                async: false,                success: function (data) {                    //        console.log(data);                    if (data.upload.result == 'Warning') {                        if (data.upload.warnings.hasOwnProperty('duplicate')) {                            //if file is a duplicate, we use the name of the first existing file                            lFileName = data.upload.warnings.duplicate[0];                            alert(i18n.duplicate + lFileName);                            MultiUpload.uploadfinished(false); } else if (data.upload.warnings.hasOwnProperty('exists')) { lFileName = prompt(i18n.alreadyname, lFileName); if (lFileName !== null) { lFileName = MultiUpload.uploadfiles(fileToUpload, lFileName, licence); } else { MultiUpload.uploadfinished(false); }                       }                    } else { MultiUpload.uploadfinished(true); }               },                error: function (xhr, status, error) { alert(error); MultiUpload.uploadfinished(false); }           });        },        uploadfinished: function (result) {            if (result) {                $('#loading' + (i + 1) + ' > img').attr('src', 'http://vignette4.wikia.nocookie.net/guigui/images/e/ef/Success.png/revision/latest?cb=20141230103851&path-prefix=fr ');            } else {                $('#loading' + (i + 1) + ' > img').attr('src', 'http://vignette1.wikia.nocookie.net/guigui/images/8/8a/Problem.png/revision/latest?cb=20141230110222&path-prefix=fr ');            }        }    };    $('#WikiaArticle').on("click", "#go", function  { MultiUpload.update; });   MultiUpload.init; // Start script })(jQuery);

/* Toolbar */ importStylesheetURI('https://rawgit.com/LunarTwilight/cb84225e1edad24b81d7d460e7771d34/raw/26c226a8feed3993de133b0584b4cdc0ad9a1c9d/toolbar.css '); $('.WikiaBarWrapper .toolbar .tools > li:has(a[class="sprite gear"])').remove; $('.WikiaBarWrapper .toolbar .tools > li:has(a[class="tools-customize"])').remove; $('.WikiaBarWrapper .toolbar .tools > li:has(a[class="global-shortcuts-help-entry-point"])').remove; /* Link to report thread on suwiki */ $('', {id: 'report'}) .html('Report Thread') .prependTo('.toolbar .tools'); /* Remove the part of the url that opens the editor on redlinks */ var head = $('a[href$="?action=edit&redlink=1"]'); if ($('a[href$="?action=edit&redlink=1"]').attr("href")) { //if ?action=edit&redlink=1 is in the url head.attr("href", head.attr("href").replace("?action=edit&redlink=1", "")); //remove it

} /* Link to subpages in my tools menu */

$(' ', {id: 'subpages'}) .html('Subpages</a>') .prependTo('.toolbar .tools'); /* Disable user js */

$(' ', {id: 'nouserjs'}) .html('<a href="?useuserjs=0">No User JS</a>') .prependTo('#my-tools-menu'); /* Disable site js */

$(' ', {id: 'nositejs'}) .html('<a href="?usesitejs=0">No Site JS</a>') .prependTo('#my-tools-menu'); /* Add option to make code pages use different font */ if ($("#theme-solarized-light").length || $("#theme-solarized-dark").length) {

$(' ', {id: 'codefont',}) .html('<a href="#">Code Font</a>') //create the link .prependTo('.toolbar .tools') //attach the link .click(function {       mw.util.addCSS('#theme-solarized-light, #theme-solarized-dark { font-family: Fira !important; }');    }); } /* ColoredColors */ (function {	var isHexCode = function(h) {		var a = parseInt(h, 16);		return (a.toString(16) === h);	};	var tags = document.getElementsByClassName('re0');	if (wgAction == 'view' && wgPageName.split('.')[wgPageName.split('.').length - 1] == 'css') {		for (i = 0; i < tags.length; i++) {			var html = tags[i].innerHTML;			if (html.charAt(0) == '#' && html.length == 7 && isHexCode(html.slice(1).toLowerCase)) {				var brokened = html.split(';');				for (j = 0; j < html.split('#').length - 1; j++) {					if (brokened[j][0] == '#') {						brokened[j] = '<span style="color:' + brokened[j].substring(0, 7) + '">' + brokened[j].substring(0, 7) + ' ';					}				}				tags[i].innerHTML = brokened.join(';');			}		}	} }); /* Make page take the full width of the screen */

$(' ', {id: 'screenwidth',}) .html('<a href="#">Full Screen</a>') //create the link .prependTo('.toolbar .tools') //attach the link .click(function {   mw.util.addCSS('.WikiaPage {\ border: none !important;\ padding: 0 8px;\ width: calc(100% - 16px);\ }\   #WikiaRail {\ display: none;\ }\   #WikiaMainContent {\ width: 100%;\ }');

}); /* Disable 5 sec edit save delay */ GlobalTriggers.bind("WikiaEditorReady", function(point) { if (point.controls) { point.controls.editform.off("submit").on("submit", function {     point.setState(3);    }); }

}); /** * Name:       UnhideUserWikis * Description: Unhides hidden user wikis in masthead and appends the edit count * Author:      KockaAdmiralac <1405223@gmail.com> */

$(function {   if($('#UserProfileMasthead').length === 0) {        return;    }    $.getJSON(mw.util.wikiScript('api'), { action: 'query', list: 'users', ususers: $('.masthead-info hgroup h1').text, format: 'json' }, function(d) { var u = d.query.users; if(u && u[0] && u[0].userid) { $.getJSON(mw.util.wikiScript('wikia'), {               controller: 'UserProfilePageController',                method: 'renderLightbox',                userId: u[0].userid,                format: 'json'            }, function(da) {                if(da && da.user && da.user.topWikis && da.user.topWikis.length > 0) {                    $('.masthead-info-lower .wikis').remove;                    var el = $('<ul>'),                        tw = da.user.topWikis;                    for(var i in tw) {                        if(tw.hasOwnProperty(i)) {                            var w = tw[i];                            el.append( $('') .append(                                       $('')                                            .attr('href', w.wikiUrl)                                            .text(w.wikiName + ' (' + w.edits + ')')                                    ) );                       }                    }                    $('.masthead-info-lower').append( $('<ul>') .attr('class', 'wikis') .append(                               $(' ')                                    .text('My favorite wikis')                            ) .append(el) );               }            });        }    }); }); /* Add gender tag to global masterhead */ $(function {   if($("#UserProfileMasthead").length === 0) {        return;    }    mw.loader.using('mediawiki.api').then(function { new mw.Api.get({           action: 'parse',            text: ''        }).done(function(d) {            if(d.parse.text['*'].indexOf('thisisjustsomethingstupid') === -1) {                $('.masthead-info hgroup').append(' ' + d.parse.text['*'] + ' ');            }        }); });

}); /* Staff/VSTF/Bot/Helper highlights */ importStylesheetPage('Highlight/code.css', 'dev'); /* WLB highlights */ importStylesheetPage('MediaWiki:WLBhighlight.css', 'wlb'); /* BotoneraPopups */ importArticles({ type: "script", articles: [ "u:dev:MediaWiki:BotoneraPopups/BotoneraPopups.js", "u:dev:MediaWiki:BotoneraPopups/WikiArticle.js", "u:dev:MediaWiki:BotoneraPopups/UILang/en.js", "u:dev:MediaWiki:BotoneraPopups/code.js" ]

}); importStylesheetPage('BotoneraPopups/code.css', 'dev'); /* Imports */ importArticles({ type: "script", articles: [ 'u:dev:MediaWiki:CacheCheck/code.js', 'u:dev:MediaWiki:MarkBlocked.js', 'u:dev:MediaWiki:AjaxRC/code.js', 'u:dev:MediaWiki:LastEdited/code.js', 'u:dev:MediaWiki:AjaxUndo/code.js', 'u:dev:MediaWiki:ToggleSideBar/code.js', 'u:dev:MediaWiki:PageCreator/code2.js', 'u:dev:MediaWiki:HoverEditCount/code.js', 'u:dev:MediaWiki:QuickDiff/code.js', 'u:dev:MediaWiki:GlobalEditcount/code.js', 'u:dev:MediaWiki:UserAccountAge/code.js', 'u:dev:MediaWiki:ContribsLink/code.js', 'u:dev:MediaWiki:DupImageList/code.js', 'u:dev:MediaWiki:DisplayTimer/code.js', 'u:dev:MediaWiki:Linksweeper/code.js', 'u:dev:MediaWiki:RecentChangesMultiple/code.2.js' ]

});