Jump to content

User:SoledadKabocha/common-rewrite.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by SoledadKabocha (talk | contribs) at 06:14, 19 December 2018 (rest of the skeleton (will flag the rest of this work as minor to avoid cluttering RC, for what it's worth...)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// WIP for personal use - See talk

//
// Initialize constants that do not depend on properties of mw
//
var dt   = new Date( );
var dtH  = dt.getHours( );
var dtM  = dt.getMinutes( );
var dtUDm = dt.getUTCDate( );
var dtUDw = dt.getUTCDay( );

// toggle uncat display (potentially) every 20 minutes,
// with the boundary of the 20-min intervals shifted by +/- 1 min
// based on something slowly varying (i.e. my edit count)
var dtUnitMapping = [
  Math.min( dtH + dtUDw, dtUDm ),
  dtH,
  Math.max( dtH + dtUDw, dtUDm )
];
// rest of this logic needs mw.config.get; see below

//using gadget
LocalComments = {
	dateDifference: true,
	dateFormat: 'dmy',
	timeFirst: true,
	twentyFourHours: true,
	dayOfWeek: true,
	dropDays: 121,
	dropMonths: 30
};

function realCommonStuff( dblag ) {
  // Import and configure all sub-scripts
  // (For simplicity, importing should be unconditional.
  // Avoid dependence on whether or not we are editing,
  // like I did in my original common.js.)
}

mw.loader.using( [ 'mediawiki.util', 'mediawiki.user', 'mediawiki.notify' ], function ( ) {
  // Initialize constants that do depend on properties of mw
  // (by "constants" I also mean functions not loaded from external scripts)

  // XXX: not actually useful...
  window.safelyGetMwConfig = function ( confName ) {
    var result = null, maxAttempts = 5;
    for ( var i = 0; i < maxAttempts; i++ ) {
      try {
        result = mw.config.get( confName );
      } catch ( ex ) {
        /* XXX TODO */
      }
      if ( result !== null ) { return result; }
    }
    return result;
  }

  // Make AJAX request to obtain database lag
  // Callbacks should point to realCommonStuff
  const FALLBACK_LAG = 999999;
} )