MediaWiki discusión:Common.js

De Guild Wars 2 Wiki
Ir a la navegaciónIr a la búsqueda

July 2017 Suggestion Updates[editar]

Hey Sayeth, User:Chieftain Alex from en:gw2w here, here are my suggestions for your Common.js

// Scripts to use when viewing articles
if (mw.config.get('wgIsArticle') || window.location.href.indexOf('action=submit') > -1 || mw.config.get('wgNamespaceNumber') == -1) {
    mw.loader.load( '/index.php?title=MediaWiki:CollapsibleTables.js&action=raw&ctype=text/javascript' );
}

// Scripts to use when searching
if (mw.config.get('wgPageName') == 'Especial:Buscar') {
    mw.loader.load( '/index.php?title=MediaWiki:ChatLinkSearch.js&action=raw&ctype=text/javascript' );
}

// Add a clock to the top of the window
(function displayTimer (window, document) {
  if ( typeof( timerDisplay ) !== 'undefined' && timerDisplay === false )
    return;
  
  var timerParent = document.getElementById( 'p-personal' ).getElementsByTagName( 'ul' )[0];
  var timerLink   = document.createElement( 'a' );
  var timerObj    = document.createElement( 'li' );
  timerLink.href               = '/index.php?title=' + mw.config.get('wgPageName') + '&action=purge';
  timerLink.title              = 'Borra la caché del servidor y actualiza los contenidos del articulo.'
  timerObj.id                  = 'pt-timer';
  timerObj.style.textTransform = 'none';
  timerObj.style.fontWeight    = 'bold';
  timerObj.appendChild( timerLink );
  timerParent.insertBefore( timerObj, timerParent.firstChild );
  
  var localTimezoneOffset = 0;
  var test = new Date()
  if (test.getTimezoneOffset() != 0)
  {
    localTimezoneOffset = (test.getTimezoneOffset()/-60);
    localTimezoneOffset = ( localTimezoneOffset < 0 ? '' : '+' ) + localTimezoneOffset;
  }
  
  function updateTime (localTimezoneOffset)
  {
    var now = new Date();
    var nowUTC = new Date();

    var hhUTC = nowUTC.getUTCHours();
    var mmUTC = nowUTC.getUTCMinutes();
    var ssUTC = nowUTC.getUTCSeconds();
    var timeUTC = ( hhUTC < 10 ? '0' + hhUTC : hhUTC ) + ':' + ( mmUTC < 10 ? '0' + mmUTC : mmUTC ) + ':' + ( ssUTC < 10 ? '0' + ssUTC : ssUTC );
    var timeText = timeUTC + ' (UTC)';
    
    if (localTimezoneOffset != 0)
    {
      var hh = now.getHours();
      var mm = now.getMinutes();
      var ss = now.getSeconds();
      var time = ( hh < 10 ? '0' + hh : hh ) + ':' + ( mm < 10 ? '0' + mm : mm ) + ':' + ( ss < 10 ? '0' + ss : ss );
      timeText = timeUTC + ' UTC (' + time + ' UTC' + localTimezoneOffset + ')';
    }
    timerLink.innerHTML = timeText;
  }
  
  // Display
  updateTime(localTimezoneOffset);
  setInterval( updateTime.bind(null, localTimezoneOffset), 1000 );
})(window, document);

// Force users to select a license option when uploading files, also allows manual entry in Summary for 'ArenaNet imagen' and 'Imagen de usuario' licenses
$('#mw-upload-form').submit(function(event) {
    var licenseValue = $('#wpLicense').val();
    var uploadDescription = $('#wpUploadDescription').val();
    if (licenseValue == '' && !uploadDescription.match(/(Licencia|ArenaNet imagen|Imagen de usuario)/i)) {
        alert('Please select a Licensing option.');
        event.preventDefault();
    }
});
Changes summary
  • Removed: nowiki tags - these are not required anymore
  • Removed: extension to the deletion list - it isn't really needed.
  • Removed: addScript - outdated, use "mw.loader.load" instead. However bear in mind if you have user scripts they might reference it.
  • Removed: diffwithFix - patched an ancient mediawiki bug that no longer exists
  • Removed: displayPlaceholder - used to insert a line of text into the search box, no longer required
  • Updated: Displaytimer - fixed some bugs, added slightly older internet explorer (IE8) support.
  • Removed: Demarcate dialogue - basically this could be left, but as far as I can see you have so few NPCs documented its not worth loading on every page.

--217.42.244.137 12:13 15 jul 2017 (CEST)

Next topic[editar]

here