User:Saftzie/common.js

ShoutWiki — express yourself and be heard!
Jump to navigation Jump to search

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
(function (mw, $) {
	'use strict';

	var
		global, common;

	// short-circuit running this file, Wikia-style, usually for debugging
	if (/(?:\?|&)useuserjs=0(?:&|$)/.test(location.search)) {
		return;
	}

	// define load states for global/common/skin js
	(window.user = window.user || {}).state = user.state || {};
	// common.js
	common = user.state.common = user.state.common || {
		last: null,
		defer: $.Deferred()
	};
	if (common.last === 'common') {
		return; // prevent repeat loading
	}
	common.last = 'common';
	// global.js
	global = user.state.global = user.state.global || {
		last: 'common',
		defer: $.Deferred()
	};

	// enforce global -> common -> skin js serialization
	global.defer.done(function () {
		// local wikimarks config
		if (user.loader) {
			user.loader.using(
				['u:www:User:Saftzie/ui.wikimarks.js'], // [[User:Saftzie/ui.wikimarks.js]]
				['User:Saftzie/ui.wikimarks.config.js'] // [[User:Saftzie/ui.wikimarks.config.js]]
			);
		}

		// Extension:DismissableSiteNotice defines the global pollutant "cookieName"
		//   and sets the associated cookie for 30 days
		// expire the cookie immediately
		if (typeof cookieName === 'string') {
			document.cookie = cookieName + '; expires=' + new Date().toUTCString() + '; path=/';
		}

		common.defer.resolve(); // skin.js next
	});

	// make block list sortable
	if (mw.config.get('wgCanonicalSpecialPageName') === 'BlockList') {
		$('.mw-blocklist').addClass('sortable');
		mw.loader.using('jquery.tablesorter', function () {
			$('.mw-blocklist').tablesorter();
		});
	}
}(mediaWiki, jQuery));