MediaWiki:Common.js: Difference between revisions

From Wikizilla, the kaiju encyclopedia
Jump to navigationJump to search
(fixing wiki editor icons)
mNo edit summary
Line 219: Line 219:
icon: "/w/images/6/68/Editor_Button_-_Infobox_Film.png",
icon: "/w/images/6/68/Editor_Button_-_Infobox_Film.png",
label: 'Film infobox',
label: 'Film infobox',
insertBefore: '{{Infopelicula\r|type1      =\r|type2      =\r|image      =\r|caption    =The Japanese poster for \r|name        =\r|us-title    =\r|jp-title    =\r|director    =[[\r|producer    =[[\r|writer      =[[\r|composer    =[[\r|distributor =[[Toho]]{{sup|[[Japan|JP]]}}<br>[[]]{{sup|[[United States|US]]}}\r|rating      =\r|budget      =¥\r|gross      =¥\r|runtime    =?? minutes{{sup|[[Japan|JP]]}}<br>{{Small|(? hour, ?? minutes)}}<br />?? minutes{{sup|[[United States|US]]}}<br>{{Small|(? hour, ?? minutes)}}\r|designs    =[[\r}}',
insertBefore: '{{Infobox Film\r|type1      =\r|type2      =\r|image      =\r|caption    =The Japanese poster for \r|name        =\r|us-title    =\r|jp-title    =\r|director    =[[\r|producer    =[[\r|writer      =[[\r|composer    =[[\r|distributor =[[Toho]]{{sup|[[Japan|JP]]}}<br>[[]]{{sup|[[United States|US]]}}\r|rating      =\r|budget      =¥\r|gross      =¥\r|runtime    =?? minutes{{sup|[[Japan|JP]]}}<br>{{Small|(? hour, ?? minutes)}}<br />?? minutes{{sup|[[United States|US]]}}<br>{{Small|(? hour, ?? minutes)}}\r|designs    =[[\r}}',
insertAfter: '',
insertAfter: '',
sampleText: ''
sampleText: ''

Revision as of 19:14, 18 May 2019

/**
 * Collapsible tables
 *
 * @version 2.0.2 (2014-03-14)
 * @source https://www.mediawiki.org/wiki/MediaWiki:Gadget-collapsibleTables.js
 * @author [[User:R. Koot]]
 * @author [[User:Krinkle]]
 * @deprecated Since MediaWiki 1.20: Use class="mw-collapsible" instead which
 * is supported in MediaWiki core.
 */
/*global $, mw */
var autoCollapse = 2;
var collapseCaption = 'hide';
var expandCaption = 'show';

function collapseTable( tableIndex ) {
	var Button = document.getElementById( 'collapseButton' + tableIndex );
	var Table = document.getElementById( 'collapsibleTable' + tableIndex );

	if ( !Table || !Button ) {
		return false;
	}

	var Rows = Table.rows;
	var i;

	if ( Button.firstChild.data === collapseCaption ) {
		for ( i = 1; i < Rows.length; i++ ) {
			Rows[i].style.display = 'none';
		}
		Button.firstChild.data = expandCaption;
	} else {
		for ( i = 1; i < Rows.length; i++ ) {
			Rows[i].style.display = Rows[0].style.display;
		}
		Button.firstChild.data = collapseCaption;
	}
}

function createClickHandler( tableIndex ) {
	return function ( e ) {
		e.preventDefault();
		collapseTable( tableIndex );
	};
}

function createCollapseButtons() {
	var tableIndex = 0;
	var NavigationBoxes = {};
	var Tables = document.getElementsByTagName( 'table' );
	var i;

	for ( i = 0; i < Tables.length; i++ ) {
		if ( $( Tables[i] ).hasClass( 'collapsible' ) ) {
			/* only add button and increment count if there is a header row to work with */
			var HeaderRow = Tables[i].getElementsByTagName( 'tr' )[0];
			if ( !HeaderRow ) {
				continue;
			}
			var Header = HeaderRow.getElementsByTagName( 'th' )[0];
			if ( !Header ) {
				continue;
			}

			NavigationBoxes[tableIndex] = Tables[i];
			Tables[i].setAttribute( 'id', 'collapsibleTable' + tableIndex );

			var Button = document.createElement( 'span' );
			var ButtonLink = document.createElement( 'a' );
			var ButtonText = document.createTextNode( collapseCaption );
 			// TODO: Declare styles in [[MediaWiki:Gadget-collapsibleTables.css]]
			// Button.className = 'collapseButton';
			Button.style.styleFloat = 'right';
			Button.style.cssFloat = 'right';
			Button.style.fontWeight = 'normal';
			Button.style.textAlign = 'right';
			Button.style.width = '6em';

			ButtonLink.style.color = Header.style.color;
			ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex );
			ButtonLink.setAttribute( 'href', '#' );
			$( ButtonLink ).on( 'click', createClickHandler( tableIndex ) );
			ButtonLink.appendChild( ButtonText );

			Button.appendChild( document.createTextNode( '[' ) );
			Button.appendChild( ButtonLink );
			Button.appendChild( document.createTextNode( ']' ) );

			Header.insertBefore( Button, Header.firstChild );
			tableIndex++;
		}
	}

	for ( i = 0; i < tableIndex; i++ ) {
		if ( $( NavigationBoxes[i] ).hasClass( 'collapsed' ) ||
			( tableIndex >= autoCollapse && $( NavigationBoxes[i] ).hasClass( 'autocollapse' ) )
		) {
			collapseTable( i );
		}
	}
}

mw.hook( 'wikipage.content' ).add( createCollapseButtons );
/******************************************************************************************************************************/

/******************************************************************************************************************************/

/******************************************************************************************************************************/

/*********************************************************************** W I K I  E D I T O R B U T T O N S *******************/

/************************************************ WikiEditor Buttons/Customization ********************************************/

/******************************************************************************************************************************/

/******************************************************************************************************************************
 * Extra buttons in toolbar
 * @stats [[File:Krinkle_InsertWikiEditorButton.js]]
 ******************************************************************************************************************************/
$.ajax({
	url: 'https://meta.wikimedia.org/w/index.php?title=User:Krinkle/Scripts/InsertWikiEditorButton.js&action=raw&ctype=text/javascript',
	dataType: 'script',
	cache: true
}).done(function () {

	// REFERENCE with ID
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-refidbutton",
		icon: "/w/images/9/97/Editor_Button_-_Reference.png",
		label: 'Reference with ID',
		insertBefore: '<ref name="">[http://',
		insertAfter: ']</ref>',
		sampleText: ''
	});
	// BOOK CITATION       ----------------- website citation for when it's added: /w/images/3/38/Editor_Button_-_Reference_Website.png
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-citebookbutton",
		icon: "/w/images/7/73/Editor_Button_-_Reference_Book.png",
		label: 'Cite book',
		insertBefore: '<ref name="">{{cite book|title= |author= |date= |publisher= |page=!!OR!!|pages= ',
		insertAfter: '|isbn=}}</ref>',
		sampleText: '...not all parameters required.--see Template:Cite_book for documentation...'
	});

	// CORRECT FORMAT GALLERY
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-gallerybutton",
		icon: "/w/images/f/f6/Editor_Button_-_Correct_Gallery.png",
		label: 'Gallery',
		insertBefore: '<gallery widths="120" position="center" captionalign="center" spacing="small">\r',
		insertAfter: '\r</gallery>',
		sampleText: 'Test Image.png'
	});

	// YOUTUBE EMBED
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-youtubebutton",
		icon: "/w/images/d/de/Editor_Button_-_YouTube.png",
		label: 'YouTube embed',
		insertBefore: '<youtube width="300" height="169">',
		insertAfter: '</youtube>',
		sampleText: '...Put YT video ID here; remove _width="300" height="169"_ to make default size ~ 300x169 is specifically for infoboxes...'
	});

	// TABBER
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-infoboxtabberbutton",
		icon: "/w/images/0/08/Editor_Button_-_Tabber.png",
		label: 'Tabber',
		insertBefore: '<tabs style="color:black; padding: 0px; margin: 0px;">\r<tab name="NAMEHERE">[[File:|330px| in ]]</tab>\r',
		insertAfter: '\r<tab name="NAMEHERE2">[[File:|330px| in ]]</tab>\r</tabs>',
		sampleText: '<!---- add multiple tabs by copy pasting and changing the values ---- to replace the infobox image with a tabber, change |image = with |altimage = ---->'
	});

	// DVD INFO
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-dvdbutton",
		icon: "/w/images/4/4f/Editor_Button_-_DVD_Info.png",
		label: 'Insert DVD information',
		insertBefore: '<b>COMPANY</b> (YEAR)<ref name="">[http:// Amazon.com: ]</ref>\\r*Region: \r*Audio: \r*Special Features: \r*Notes:  ',
		insertAfter: '',
		sampleText: ''
	});

	// STAFF and CAST Information
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-staffcastbutton",
		icon: "/w/images/e/eb/Editor_Button_-_Staff_and_Cast.png",
		label: 'Insert Staff and Cast information',
		insertBefore: '==Staff==\r{{Staffs\r|Directed by=[[\r|Written by=\r|Produced by=\r|Executive Producing by=\r|Music by=\r|Cinematography by=\r|Edited by=\r|Production Design by=\r|Assistant Directing by=\r|Special Effects by=\r}}\r==Cast==\r{{Cast\r||\r||\r||\r||\r||\r||\r||\r||\r||\r||\r||\r}}',
		insertAfter: '',
		sampleText: ''
	});

	// FILM Tab and Nav
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-filmtabnavbutton",
		icon: "/w/images/9/95/Editor_Button_-_Nav.png",
		label: 'Tab and navigation (film)',
		insertBefore: '{{Tab}}\r{{Nav Design\r|type1       =\r|type2       =\r|type        =[[:Category:|Category:]]\r|name        =\r|prev        =\r|prevname    =\r|next        =\r|nextname    =\r}}',
		insertAfter: '',
		sampleText: ''
	});


	// INFOBOX KAIJU
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-infoboxkaijubutton",
		icon: "/w/images/b/b8/Editor_Button_-_Infobox_Kaiju.png",
		label: 'Kaiju infobox',
		insertBefore: '{{Kaiju Infobox\r|type1            =???\r|type2            =???\r|header           ={{Toho Kaiju}} \r|copyrighticon    =\r|image            =\r|caption          =\r|name             =\r|nicknames        =\r|subtitle         =\r|species          =\r|height           =?? meters\r|length           =?? meters\r|weight           =?? tons\r|forms            =\r|allies           =\r|enemies          =\r|relationships    =\r|controlled       =\r|created          =\r|portrayed        =\r|debut            =\r|last             =\r|suits            =\r|roar             =[[File:.ogg|180px|center|noicon]]{{More Roars}}\r}}',
		insertAfter: '',
		sampleText: ''
	});

	// INFOBOX FILM
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-infoboxfilmbutton",
		icon: "/w/images/6/68/Editor_Button_-_Infobox_Film.png",
		label: 'Film infobox',
		insertBefore: '{{Infobox Film\r|type1       =\r|type2       =\r|image       =\r|caption     =The Japanese poster for \r|name        =\r|us-title    =\r|jp-title    =\r|director    =[[\r|producer    =[[\r|writer      =[[\r|composer    =[[\r|distributor =[[Toho]]{{sup|[[Japan|JP]]}}<br>[[]]{{sup|[[United States|US]]}}\r|rating      =\r|budget      =¥\r|gross       =¥\r|runtime     =?? minutes{{sup|[[Japan|JP]]}}<br>{{Small|(? hour, ?? minutes)}}<br />?? minutes{{sup|[[United States|US]]}}<br>{{Small|(? hour, ?? minutes)}}\r|designs     =[[\r}}',
		insertAfter: '',
		sampleText: ''
	});

	// INFOBOX CHARACTER
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-infoboxcharacterbutton",
		icon: "/w/images/f/f6/Editor_Button_-_Infobox_Character.png",
		label: 'Character infobox',
		insertBefore: '{{Infobox Character\r|type1           =\r|type2           =\r|header          ={{Character}}\r|image           =\r|caption         =\r|species         =\r|nationality     =\r|relationships   =\r|occupation      =\r|affiliation      =\r|firstappearance =\r',
		insertAfter: '\r|played          =\r}}',
		sampleText: '<!--- use |debut = and |last = if the character has more than 1 appearance --->'
	});

	// INFOBOX TV SHOW
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-infoboxtvshowbutton",
		icon: "/w/images/2/22/Editor_Button_-_Infobox_TV.png",
		label: 'TV show infobox',
		insertBefore: '{{Infobox Series\r|header        ={{Series}}\r|type1         =\r|type2         =\r|name          =\r|image         =\r|creator       =\r|producer      =\r|distributor   =\r|genre         =\r|aired         =\r|channel       =\r|episodes      =\r}}',
		insertAfter: '',
		sampleText: ''
	});

	// INFOBOX BOOK
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-infoboxbookbutton",
		icon: "/w/images/7/70/Editor_Button_-_Infobox_Book.png",
		label: 'Book infobox',
		insertBefore: '{{Infobox Book\r|type1        =\r|type2        =\r|image        =\r|name         =\r|author       =\r|publisher    =\r|publishdate  =\r|genre        =\r|isbn         =[[Special:BookSources/|ISBN-10: ]]<br>[[Special:BookSources/|ISBN-13: ]]\r}}',
		insertAfter: '',
		sampleText: ''
	});

	// INFOBOX PERSON
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-infoboxpersonbutton",
		icon: "/w/images/9/93/Editor_Button_-_Infobox_Real_Person.png",
		label: 'Real person infobox',
		insertBefore: '{{Infobox Person\r|type1            =\r|type2            =\r|name             =\r|image            =\r|caption          =\r|occupation       =\r|birthday         =\r|birthplace       =\r|first            =\r|notable          =\r|imdb             =\r|wikipedia        =\r}}',
		insertAfter: '',
		sampleText: ''
	});

	// INFOBOX VIDEO GAME
	krInsertWikiEditorButton({
		id: "mw-customeditbutton-infoboxvideogamebutton",
		icon: "/w/images/f/fb/Editor_Button_-_Infobox_Game.png",
		label: 'Video game infobox',
		insertBefore: '{{Infobox Game\r|type1       =\r|type2       =\r|header      =\r|image       =\r|caption     =\r|name        =\r|us-title    =\r|jp-title    =\r|publisher   =\r|developer   =\r|platforms   =\r|languages   =\r|genre       =\r}}',
		insertAfter: '',
		sampleText: ''
	});

});

/**************************************************/

/*************** END WikiEditor ******************/

/************************************************/