MediaWiki:Common.js

From Ekatra Wiki
Jump to navigation Jump to search

Note: After publishing, 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: Press Ctrl-F5.
$( function(){
	
	if( mw.config.get('wgIsMainPage') ){
		$('#firstHeading').remove();
	}
	if( mw.config.get('wgUserName') === null  ){
		$('body').bind('cut copy', function(e) {
			e.preventDefault();
		});
	} else {
		$("#content").removeAttr("onmousedown");
		$("#content").removeAttr("onselectstart");
	}

	mw.loader.load( '/index.php?title=MediaWiki:Numerakri.js&action=raw&ctype=text/javascript' );
});

$( function(){
	var sidebarCategory = $("#p-Categories > .vector-menu-content");
	sidebarCategory.empty();

	mw.loader.using( [ 'mediawiki.api' ], function(){
		var sel = $('<select>').appendTo( sidebarCategory );

		catMemberParam = {
			"action": "query",
			"format": "json",
			"list": "categorymembers",
			"cmtitle": "Category:Categories on EkatraWiki",
			"cmprop": "title",
			"cmtype": "subcat",
			"cmlimit": "500"
		};
		(new mw.Api()).get( catMemberParam, { async: false }  ).done(function ( resData ){
			var catOptions = [];
			var members = resData.query.categorymembers;
	
			// Creating MenuItems array from Category Members
			members.forEach( function(it){
				var ct = it.title.replace("Category:", "");
				sel.append( $("<option>").attr('value', ct).text(ct) );
			});
		});
	} );
	
	
});

$( function(){
	var poemElement = $(".Poem2-Ekatra");
	
	if( poemElement.length ){
		var poemText = poemElement.html();
		var poemArray = poemText.split("\n");
		
		poemElement.text("");
	
		poemArray.forEach( function(i) {
			poemElement.append( '<p style="text-indent: 3em;">' + i + '</p>' );
		});		
	}
});