MediaWiki:Common.js

$wgDefaultSkin = 'standard'; /* Any JavaScript here will be loaded for all users on every page load. */ /** additional scripts **/ if (wgIsArticle || window.location.href.indexOf('action=submit') > -1 || wgNamespaceNumber == -1) { importScript('MediaWiki:CollapsibleTables.js'); $(function {   autoConvertUTC;  }); }

// Extension for the deletion drop down list if (wgAction == 'delete') { $(function {   if ((delReasonBtn = document.getElementById('wpConfirmB'))) {      var delReasonList        = document.getElementById('wpDeleteReasonList');      var delLink              = document.createElement('a');      delLink.href             = 'javascript:void(0);'      delLink.title            = document.getElementById('wpReason').value;      delLink.style.fontSize   = '0.9em';      delLink.style.marginLeft = '1em';      $(delLink).click(function { document.getElementById('wpReason').value = this.title; });     $(delReasonList).change(function  { document.getElementById('wpReason').value = ''; this.onchange = null; });     delLink.appendChild(document.createTextNode('restore default reason'));      delReasonBtn.parentNode.appendChild(delLink);      delete delLink, delReasonList, delReasonBtn;    }  }); }

// Chat link search if (wgPageName == 'Special:Search') { importScript('MediaWiki:InterwikiSearchRedirect.js'); importScript('MediaWiki:ChatLinkSearch.js‎'); }

/* * Article Feedback (see Guild Wars 2 Wiki:Feedback initiative) *  add a button to leave feedback about a mainspace article on the talk page */ (function addArticleFeedback (window, document) {  if (wgNamespaceNumber == 0 ) // namespace: main   {      // Construct pretty date format with padded zeros YYYY-MM-DD      var currentDate = new Date;      var day = ("0" + currentDate.getDate.toString).slice(-2);      var month = ("0" + (currentDate.getMonth + 1 ).toString).slice(-2);      var year = currentDate.getFullYear;      var currentDate = year + "%2F" + month + "%2F" + day;

// Construct new tab feedbacktab = document.createElement('li'); feedbacktab.id = 'special-articlefeedback'; feedbacklink = '/w/index.php?title=Talk:' + encodeURIComponent(wgPageName) + '&action=edit&section=new&editintro=Template:Feedback_notice&preload=Template:Feedback_preload&preview=yes&preloadtitle=Feedback+' + currentDate; feedbackhover = 'Leave us feedback on the content of the article so that we can improve it'; feedbacktabtext = 'Leave article feedback';

// Change format depending on whether user is using vector or monobook if (skin == 'vector') {        feedbacktab.innerHTML = ' ' + feedbacktabtext + ' ' }     else if (skin == 'monobook') {        feedbacktab.innerHTML = '' + feedbacktabtext + '' var nexttab = document.getElementById('ca-edit') || document.getElementById('ca-viewsource'); nexttab.style.borderTopLeftRadius = '0px'; }

// Finally add the feedback button somewhere after the discussion tab document.getElementById('ca-talk').parentNode.insertBefore(feedbacktab, document.getElementById('ca-talk').nextSibling); }

// Pre-select the text if they're leaving feedback so they know what to edit if (window.location.href.indexOf('section=new&editintro=Template:Feedback_notice&preload=Template:Feedback_preload') != -1) {

var editingtoolbar = document.getElementById('toolbar'); if (editingtoolbar != undefined) {        document.getElementById('wpTextbox1').focus; mw.toolbar.addButton("", "", "", " ", "Insert feedback text here", "mw-editbutton-feedback"); var feedbackbutton = document.getElementById('mw-editbutton-feedback'); feedbackbutton.click; feedbackbutton.remove; }  } })(window, document);

/* * autoConvertUTC (see Template:UTC time) *  by Patrick Westerhoff [poke] */ function autoConvertUTC { function pad (s) { return (s < 10 ? '0' : '') + s; } [].forEach.call(document.querySelectorAll('.utc-auto-convert'), function(v, i) {   var time = v.innerHTML.match(/(\d?\d):(\d\d) UTC/);    if (!time) {      return;    }

var date = new Date; date.setUTCHours(time[1], time[2], 0, 0);

if (date.getTimezoneOffset == 0) { v.title = 'This is your timezone'; }   else { var offset = (-1 * date.getTimezoneOffset / 60); var local = pad(date.getHours) + ':' + pad(date.getMinutes) + ' UTC' + (offset < 0 ? offset : '+' + offset);

var utcHours = parseInt(time[1], 10); if (offset > 0 && date.getHours < utcHours) { local += ' the next day'; }     else if (offset < 0 && date.getHours > utcHours) { local += ' the day before'; }

v.innerHTML += ' ( ' + local + ' )'; } }); }

/* * Formatting for dialogue sections on mainspace articles */ (function demarcateDialogue(window, document) {   if (wgNamespaceNumber == 0) {        $('h2').each(function (i, e) { var h2Content = this.innerHTML.match(/(dialogue)/i); if (h2Content) { $(this).nextUntil(this.tagName).wrapAll(' '); }       });    } }) (window, document);

/** * Helper script for .hlist class in Common.css * Add pseudo-selector class to last-child list items in IE8 * @source mediawiki.org/wiki/Snippets/Horizontal_lists * @revision 6 (2014-08-23) * @author mediawiki.org/wiki/User:Edokter */ ( function ( mw, $ ) {   var profile = $.client.profile;    if ( profile.name === 'msie' && profile.versionNumber === 8 ) {        mw.hook( 'wikipage.content' ).add( function ( $content ) { $content.find( '.hlist' ).find( 'dd:last-child, dt:last-child, li:last-child' ) .addClass( 'hlist-last-child' ); } );   } } ( mediaWiki, jQuery ) );