MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */

// Disable creation of non-talk pages by anonymous IP editors and link to registration (also disabled by abuse filter but this provides warning before attempting edit) var wgPageName = mw.config.get( 'wgPageName' ); var wgUserName = mw.config.get( 'wgUserName' );

var isTalk = false, isAnon = false; if (wgPageName.indexOf('talk:') > -1 || wgPageName.indexOf('Talk:') > -1) isTalk = true; if (wgUserName === null) isAnon = true;

if (isAnon == true){ $('a.new').each(function{       var href = $(this).attr('href');        $(this).attr('href', href.replace(/&action=edit/g, '') );    }); }

if (isAnon == true && isTalk == false) { var anonWarnText = 'Page creation by anonymous editors is currently disabled. To create this page, please register an account first.'; $('body').append(' '); $('body').prepend('' + anonWarnText + ' ');

$('#ca-edit a:contains(Create), #ca-ve-edit a:contains(Create), a.external.text:contains(edit this page)').attr('href', '#').click(function{       $('.anonWarnBox').show;        $('.anonWarnOverlay').show;    }); $('.anonWarnOverlay').click(function{       $('.anonWarnBox').hide;        $(this).hide;    }); }