MediaWiki:Common.js

From Official Temtem Wiki
Jump to navigation Jump to search

In other languages: EspañolFrançais


CSS and Javascript changes must comply with the wiki design rules.


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: 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 () {
	
	/* umbra skin */
	/* 1 in 75000 chance of triggering */
	if ( Math.random() <= 1/75000 ) {
	    localStorage.setItem( 'umbra-available', true );
	    mw.loader.using( 'ext.themes.jsapi', function () {
	        mw.loader.require( 'ext.themes.jsapi' ).whenCoreLoaded( function () {
	            MwSkinTheme.set( 'umbra' );
	        } );
	    } );
	}

	/* once umbra has been triggered, it's available normally */
	if ( localStorage.getItem( 'umbra-available' ) ) {
	    mw.hook( 'ext.themes.dropdownSwitcherReady' ).add( function ( switcherElement ) {
	        var themeElement = switcherElement.querySelector( '#pt-themes-item-umbra' );
	        themeElement.style.display = 'block';
	  } );
	}
	/**/
	
	
	/* [[Template:Hover gif]] */
	$(".hover-gif img").each(function(i, obj) {
	  obj.onload = function() {
	    var $canvas = $("<canvas width='" + $(obj).attr("width") + "' height='" + $(obj).attr("height") + "'></canvas>");
	    $(obj).parent().append($canvas);
	    var ctx = $canvas[0].getContext("2d");
	    var img = new Image();
	    img.onload = function() {
	      ctx.drawImage(img, 0, 0);
	    }
	    img.src = obj.src;
	  };
	});
})