User:KurwaAntics/global.js

// AjaxRC settings // window.ajaxPages = ["Special:RecentChanges","Special:Log","Special:WikiActivity"];

// Load scripts // importArticles({   type: "script",    articles: [        "w:c:dev:RelocateEditDiscussionButtons/code.js",        "w:c:dev:DisplayClock/code.js",        "w:c:dev:ReferencePopups/code.js",        "w:c:dev:FindAndReplace/code.js",        "w:c:dev:RevealAnonIP/usercode.js",        "w:c:dev:View_Source/code.js",        "w:c:dev:SearchSuggest/code.js",        "w:c:dev:AjaxDiff/code.js",        "w:c:dev:ScriptAssist/code.js"    ] });

// Full resolution images // function clearimage{ $("img").each(function {       var src = $(this).attr("src").split("/scale-to-width-down", 1);        $(this).attr("src", src).css({"max-width": "100%"});    }); $("a.image-thumbnail").each(function {       var href = $(this).attr("href").split("/revision", 1);        $(this).attr("href", href);    }); }

$("img").click(function(e) {   if ( e.shiftKey ) {        var src = $(this).attr("src").split("/scale-to-width-down", 1);        $(this).attr("src", src).css({"max-width": "100%"});        event.preventDefault;        return false;    } });

// Custom toolbar menus // $('.toolbar .tools').append(' '+ //'  '+ ' User'+ ''+ 'My user page'+ '' + $('a[data-id="mytalk"]').text + ''+ 'My preferences'+ '<a href="/wiki/Special:Contact/general">Contact Wikia</a></li>'+ '</ul></li>'+ ' '+ //'   '+ '<a style="cursor:pointer"> Edit JS</a>'+ '<ul id="my-user-menu" class="tools-menu" style="right: auto; display: none;">'+ '<a href="/wiki/MediaWiki:Common.js?action=edit" target="_blank">This Wiki</a></li>'+    '<a href="/wiki/User:Yhynerson1/common.js?action=edit" target="_blank">Personal</a></li>'+    '<a href="http://community.wikia.com/wiki/User:Yhynerson1/global.js?action=edit" target="_blank">Global</a></li>'+ '<a href="/wiki/MediaWiki:ImportJS?action=edit" target="_blank">List of imports</a></li>'+ '<a href="/wiki/Special:JSPages" target="_blank">Review status</a></li>'+ '</ul></li>'+ ' '+ //'  '+ '<a style="cursor:pointer"> Edit CSS</a>'+ '<ul id="my-user-menu" class="tools-menu" style="right: auto; display: none;">'+ '<a href="/wiki/MediaWiki:Wikia.css?action=edit" target="_blank">This Wiki</a></li>'+ '<a href="/wiki/User:Yhynerson1/wikia.css?action=edit" target="_blank">Personal</a></li>'+ '<a href="http://community.wikia.com/wiki/User:Yhynerson1/global.css?action=edit" target="_blank">Global</a></li>'+ '</ul></li>'+ //'<a onclick="clearimage" style="cursor:pointer">Clear images</a></li>'+ '<a href="/wiki/Special:Search"> Search</a></li>'+ '<a onclick="importscriptmodal" style="cursor:pointer"> Import script</a></li>');

//+'<a onclick="scriptassistmodal" style="cursor:pointer"> Script assist</a></li>'

if ( wgUserGroups.indexOf("sysop") < 0 ) { $(".admin-only").remove; }

// Import script modal // var importscriptHTML = '<input type="text" style="width: 100%; box-sizing: border-box; font-size: 12px;" id="ImportScript">';

function importscriptmodal { $.showCustomModal('Import script', importscriptHTML, { width: 400, id: 'ImportScriptModal',       buttons: [{            message: 'Developers Wiki',            defaultButton: true,            handler: function   {                importScriptPage($('#ImportScript').val,'dev');            }        }, {            message: 'External',            handler: function   {                $.getScript($('#ImportScript').val);            }        }, {            message: 'Cancel',            handler: function  {                 $('#ImportScriptModal').closeModal;            }	        }]}); }

// Ctrl+S to save page // $(document).keydown(function(event) {       if((event.ctrlKey || event.metaKey) && event.which == 83) {            $('#wpSave').click;            event.preventDefault;            return false;        }    } );

// Case redirect // if ( $('.noarticletext .mw-headline a').length > 0 ) { window.location = $('.noarticletext .mw-headline a').attr('href'); }

// Page load completion indicator // $(window).bind("load", function {  console.log('Everything is ready');   $('#WikiaBar .toolbar').append('  Ready '); });

// Script assist // /* var scriptassistHTML = 'Enter the URL of the script:<input type="text" id="ScriptURL">Use it for <select id="UseScript"> everyone in this Wiki myself in this Wiki  myself in all Wikis  ';

mw.util.addCSS('#ScriptURL { width: 100%; box-sizing: border-box; font-size: 12px; display: block; margin-bottom: 0.5em; } .view-code { border: 1px solid #ddd; background: #eee; padding: 0.25em 0.5em; } #ViewCode { width: 100%; box-sizing: border-box; font-size: 12px; display: block; font-family: monospace; margin-bottom: 0.5em; }');

function scriptassistmodal { $.showCustomModal('Script assist', scriptassistHTML, { width: 500, id: 'ScriptAssistModal',       buttons: [{            message: 'Import',            defaultButton: true,            id:'initiate-assist',            handler: function  {                 var InstallCode;            var InstallLocation;            if ($("#UseScript").val === "thiswiki") {                InstallCode = $('#ScriptURL').val.split('http://')[1].replace(/.wikia.com\/wiki\//g,':').replace(/MediaWiki:/g,);                InstallLocation = 'User:' + wgUserName + '/sandbox';            } else if ( $("#UseScript").val === "personal" ) {                InstallCode = "importScriptPage('"+$('#ScriptURL').val.split('.wikia.com/wiki/')[1].replace(/MediaWiki:/g,)+"','"+$('#ScriptURL').val.split('http://')[1].split('.wikia.com/wiki/')[0]+"');";                InstallLocation = 'User:' + wgUserName + '/sandbox'; } else if ( $("#UseScript").val === "global" ) { InstallCode = "importScriptPage('"+$('#ScriptURL').val.split('.wikia.com/wiki/')[1].replace(/MediaWiki:/g,'')+"','"+$('#ScriptURL').val.split('http://')[1].split('.wikia.com/wiki/')[0]+"');"; InstallLocation = 'w:c:community:User:' + wgUserName + '/sandbox'; }           $.post(mw.util.wikiScript( 'api' ), {                    format: 'json',                    action: 'edit',                    title: InstallLocation,                    prependtext: InstallCode + "\n",                    minor: true,                    bot: true,                    token: mw.user.tokens.get("editToken")            }, function( data ) {                    if (!data.error) {             console.log('Edit of '+pages+ ' has been made successfully !');                    } else {             console.log('Failed.');                    $('#text-error-output').html('Failed to edit page '+pages+': '+data.error.info );                    }            }); }	       }, {            message: 'Close', handler: function { $('#ScriptAssistModal').closeModal; }	       }]});        $("#ScriptURL").keyup(function(event){ if(event.keyCode == 13){ $('#initiate-assist').click; } });

$('#initiate-assist').click(function {        }); if ( wgUserGroups.indexOf("sysop") < 0 ) { $('option[value="thiswiki"]').remove; }       if ( window.location.hostname == "community.wikia.com" ) { $('option[value="personal"]').remove; }       if ( window.location.hostname != "community.wikia.com" ) { $('option[value="global"]').remove; } }*/