User:Jayprakash12345/common.js

/** * tabbedwindow.js * * Displays a sample code in the tabbed window */

$( document ).ready( function {

function init { // Loop over all div with tabwindow class $('.tabwindow').each( function{			// Remove [edit] link to get clean text			$(this).find( 'h3 > .mw-editsection').remove;			// Create array to store tabs			var Tabs = [];			// Create Index Layout			var IndexLayout = new OO.ui.IndexLayout( { expanded: false } );			// Loop all === === section			$( this ).find('h3').each( function { // Push the TabPanelLayout in Tabs array Tabs.push( new OO.ui.TabPanelLayout( $( this ).text, { expanded: false, label: $( this ).text, content: [ $(' ').addClass('mw-highlight mw-content-ltr').append( $( this ).next.html ) ]                   } )                );            });			// Add Panal to IndexLayout			IndexLayout.addTabPanels( Tabs );			// Create Panal Layout			var PanelLayout = new OO.ui.PanelLayout( { expanded: false, framed: true, content: [ IndexLayout ] } );			// Create the Widget			var Widget = new OO.ui.Widget( { content: [ PanelLayout ] } );			// Append the Widget to			$( this ).empty.append( Widget.$element );		}); }

$.when( mw.loader.using( 'oojs-ui', 'oojs-ui-core', 'mediawiki.Title' ), $.ready).then( function {		var supportedNamespaces = ['API'],		action = mw.config.get( 'wgAction' ),		namespace = mw.config.get( 'wgCanonicalNamespace' ),		mwTitle = mw.Title.newFromText( mw.config.get( 'wgPageName') ),		isTalkPage = mwTitle.isTalkPage;		if ( action !== 'view' || namespace.indexOf( supportedNamespaces ) === -1 || isTalkPage ) {			return;		}		else {			if ( $('.tabwindow').length === 0 ) { return }			init;		}	});

});