MediaWiki:Common.js: Difference between revisions

From Ekatra Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 21: Line 21:


mw.loader.using( [ 'mediawiki.api' ], function(){
mw.loader.using( [ 'mediawiki.api' ], function(){
var sel = $('<select>').appendTo( sidebarCategory );
var sel = $('<select>').css( 'width', '100%').appendTo( sidebarCategory );
sel.append( $("<option>").attr('disabled', true).attr('selected', true).text( "-- Select an option --" ) );


catMemberParam = {
catMemberParam = {

Revision as of 10:34, 7 June 2021

$( 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>').css( 'width', '100%').appendTo( sidebarCategory );
		sel.append( $("<option>").attr('disabled', true).attr('selected', true).text( "-- Select an option --" ) );

		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>' );
		});		
	}
});