Jump to content

User:Jon (WMF)/minerva.js

From Wikipedia, the free encyclopedia
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.
var M = mw.mobileFrontend;
/*jshint unused:vars */
( function ( M, $ ) {

	function init() {
		var collection = mw.config.get( 'wgGatherCollections' );
		if ( !collection ) { return; }
		if ( collection[0] ) {
			collection = collection[0];
		}
		mw.loader.using( 'ext.gather.watchstar' ).done( function() {
			$( '<button class="mw-ui-button mw-ui-destructive">OH NOOOO! Hide it!</button>' )
				.on( 'click', function () {
					var api,
						Api = M.require( 'ext.gather.watchstar/CollectionsApi' ),
						promptRes = window.confirm( 'Are you sure this collection warrants hiding?' );
					if ( promptRes ) {
						Api = 
						api = new Api();
						api.hideCollection( collection.id ).done( function () {
							$( '#content_wrapper' ).empty().append(
								$( '<img>' ).attr( 'src', 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/70/Censored_rubber_stamp.svg/550px-Censored_rubber_stamp.svg.png' )
							)
						} );
					}
				} )
				.css( { display: 'block', margin: 'auto' } )
				.prependTo( '#content_wrapper' );
		} );
	}

	if ( mw.config.get( 'wgTitle' ).indexOf( 'Gather' ) === 0 &
		mw.config.get( 'wgNamespaceNumber' ) === -1  ) {
		init();
	}
}( mw.mobileFrontend, jQuery ) );