User:Ozuzanna/common.js

var page = mw.config.get('wgPageName'), specialpage = mw.config.get('wgCanonicalSpecialPageName'), title = mw.config.get('wgTitle'), namespace = mw.config.get('wgCanonicalNamespace'), action = mw.config.get('wgAction');
 * (function($, mw) {

/* Code to run while editing */ if (action === "edit" || action === "submit") { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images.wikia.com/ozank/images/1/18/Sig.png", "speedTip": "Signature", "tagOpen": "", "tagClose": "", "sampleText": "" }; if ($.getUrlVar('redlink') == 1) { if (namespace === "User_talk") { if (title.split('.').length != 4) { $('#wpTextbox1').val('{'+'{subst:User:Ozuzanna/w|}}'); $('#wpSummary,#wpSummaryEnhanced').val('Welcome!'); } else { $('#wpTextbox1').val('{'+'{subst:V}} '); $('#wpSummary,#wpSummaryEnhanced').val('Adding warning template'); }   }    if (!namespace)  { $('#wpTextbox1').val('#REDIRECT '); $('#wpSummary,#wpSummaryEnhanced').val('Creating redirect as per Special:SearchDigest'); } }              }

/* Special:SearchDigest */ if (specialpage == "SearchDigest") { $('#mw-content-text ul li').each(function {   var link = $(this).children('a'),    title = link.attr('title'),    href = link.attr('href');    if (title.split('(page does not exist)').length == 1)      $(this).remove;    link.click(function { $('#CreatePageModalDialog,#blackout_CreatePageModalDialog').remove; setTimeout(function {        window.open(href,'_blank');      }, 1000); }); }); }

/* Easy licensing/categories on upload */ if (specialpage == "Upload" || specialpage == "MultipleUpload") { $('#mw-upload-permitted').html('Licenses: Detailed item | Inventory | Scenary Categories: Scan | Compass');

function addLicense(type) { if (type == "DII") { $('#wpUploadDescription').val('{'+'{trans}}{'+'{'+type+' license|{'+'{su'+'bst:#sub:{'+'{su'+'bst:PAGENAME}}|0|-11}}'); }   else if (type == "Scenary") { $('#wpUploadDescription').val('{'+'{trans}}{'+'{'+type+' license|.png|}}'); }   else { $('#wpUploadDescription').val('{'+'{trans}}{'+'{'+type+' license|{'+'{su'+'bst:#replace:{'+'{su'+'bst:PAGENAME}}|.png|}}'); } }

function addCategory(type) { $('#wpUploadDescription').val('['+'[Category:Treasure trail '+type+' images]]'); }

$('#DII-license').click(function {   addLicense('DII');  });

$('#Inv-license').click(function {   addLicense('Inventory');  });

$('#Scen-license').click(function {   addLicense('Scenary');  });

$('#Scan-cat').click(function {   addCategory('scan');  });

$('#Compass-cat').click(function {   addCategory('compass');  });

}

}) (this.jQuery, this.mediaWiki);