User:Func/wpfunc/addipaextensions.js

From Wikipedia, the free encyclopedia

Note: After saving, you have to bypass your browser's cache to see the changes. Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.

	//	Add the Unicode IPA extensions to the
	//	character-div on monobook edit pages.
	//
function AddIpaExtensions()
{
	var div = document.getElementById( 'editpage-specialchars' );

	if ( ! div ) return;

	div = div.getElementsByTagName( 'a' )[ 0 ].parentNode;

		//	From http://www.alanwood.net/unicode/ipa_extensions.html
		//
	var ipa = [
		'\u002E', // period FULL STOP
		'\u002F', // slash SOLIDUS
		'\u005B', // bracketleft LEFT SQUARE BRACKET
		'\u005D', // bracketright RIGHT SQUARE BRACKET
		'\u007C', // bar VERTICAL LINE
		'\u02C8', // linevert MODIFIER LETTER VERTICAL LINE
		'\u02CC', // linevertsub MODIFIER LETTER LOW VERTICAL LINE
		'\u02D0', // length MODIFIER LETTER TRIANGULAR COLON
		'\u2016', // verticalbardbl DOUBLE VERTICAL LINE
		'\u2192', // arrowright RIGHTWARDS ARROW
		'\u0250', // LATIN SMALL LETTER TURNED A
		'\u0251', // LATIN SMALL LETTER ALPHA
		'\u0252', // LATIN SMALL LETTER TURNED ALPHA
		'\u0253', // LATIN SMALL LETTER B WITH HOOK
		'\u0254', // LATIN SMALL LETTER OPEN O
		'\u0255', // LATIN SMALL LETTER C WITH CURL
		'\u0256', // LATIN SMALL LETTER D WITH TAIL
		'\u0257', // LATIN SMALL LETTER D WITH HOOK
		'\u0258', // LATIN SMALL LETTER REVERSED E
		'\u0259', // LATIN SMALL LETTER SCHWA
		'\u025A', // LATIN SMALL LETTER SCHWA WITH HOOK
		'\u025B', // LATIN SMALL LETTER OPEN E
		'\u025C', // LATIN SMALL LETTER REVERSED OPEN E
		'\u025D', // LATIN SMALL LETTER REVERSED OPEN E WITH HOOK
		'\u025E', // LATIN SMALL LETTER CLOSED REVERSED OPEN E
		'\u025F', // LATIN SMALL LETTER DOTLESS J WITH STROKE
		'\u0260', // LATIN SMALL LETTER G WITH HOOK
		'\u0261', // LATIN SMALL LETTER SCRIPT G
		'\u0262', // LATIN LETTER SMALL CAPITAL G
		'\u0263', // LATIN SMALL LETTER GAMMA
		'\u0264', // LATIN SMALL LETTER RAMS HORN
		'\u0265', // LATIN SMALL LETTER TURNED H
		'\u0266', // LATIN SMALL LETTER H WITH HOOK
		'\u0267', // LATIN SMALL LETTER HENG WITH HOOK
		'\u0268', // LATIN SMALL LETTER I WITH STROKE
		'\u0269', // LATIN SMALL LETTER IOTA
		'\u026A', // LATIN LETTER SMALL CAPITAL I
		'\u026B', // LATIN SMALL LETTER L WITH MIDDLE TILDE
		'\u026C', // LATIN SMALL LETTER L WITH BELT
		'\u026D', // LATIN SMALL LETTER L WITH RETROFLEX HOOK
		'\u026E', // LATIN SMALL LETTER LEZH
		'\u026F', // LATIN SMALL LETTER TURNED M
		'\u0270', // LATIN SMALL LETTER TURNED M WITH LONG LEG
		'\u0271', // LATIN SMALL LETTER M WITH HOOK
		'\u0272', // LATIN SMALL LETTER N WITH LEFT HOOK
		'\u0273', // LATIN SMALL LETTER N WITH RETROFLEX HOOK
		'\u0274', // LATIN LETTER SMALL CAPITAL N
		'\u0275', // LATIN SMALL LETTER BARRED O
		'\u0276', // LATIN LETTER SMALL CAPITAL OE
		'\u0277', // LATIN SMALL LETTER CLOSED OMEGA
		'\u0278', // LATIN SMALL LETTER PHI
		'\u0279', // LATIN SMALL LETTER TURNED R
		'\u027A', // LATIN SMALL LETTER TURNED R WITH LONG LEG
		'\u027B', // LATIN SMALL LETTER TURNED R WITH HOOK
		'\u027C', // LATIN SMALL LETTER R WITH LONG LEG
		'\u027D', // LATIN SMALL LETTER R WITH TAIL
		'\u027E', // LATIN SMALL LETTER R WITH FISHHOOK
		'\u027F', // LATIN SMALL LETTER REVERSED R WITH FISHHOOK
		'\u0280', // LATIN LETTER SMALL CAPITAL R
		'\u0281', // LATIN LETTER SMALL CAPITAL INVERTED R
		'\u0282', // LATIN SMALL LETTER S WITH HOOK
		'\u0283', // LATIN SMALL LETTER ESH
		'\u0284', // LATIN SMALL LETTER DOTLESS J WITH STROKE AND HOOK
		'\u0285', // LATIN SMALL LETTER SQUAT REVERSED ESH
		'\u0286', // LATIN SMALL LETTER ESH WITH CURL
		'\u0287', // LATIN SMALL LETTER TURNED T
		'\u0288', // LATIN SMALL LETTER T WITH RETROFLEX HOOK
		'\u0289', // LATIN SMALL LETTER U BAR
		'\u028A', // LATIN SMALL LETTER UPSILON
		'\u028B', // LATIN SMALL LETTER V WITH HOOK
		'\u028C', // LATIN SMALL LETTER TURNED V
		'\u028D', // LATIN SMALL LETTER TURNED W
		'\u028E', // LATIN SMALL LETTER TURNED Y
		'\u028F', // LATIN LETTER SMALL CAPITAL Y
		'\u0290', // LATIN SMALL LETTER Z WITH RETROFLEX HOOK
		'\u0291', // LATIN SMALL LETTER Z WITH CURL
		'\u0292', // LATIN SMALL LETTER EZH
		'\u0293', // LATIN SMALL LETTER EZH WITH CURL
		'\u0294', // LATIN LETTER GLOTTAL STOP
		'\u0295', // LATIN LETTER PHARYNGEAL VOICED FRICATIVE
		'\u0296', // LATIN LETTER INVERTED GLOTTAL STOP
		'\u0297', // LATIN LETTER STRETCHED C
		'\u0298', // LATIN LETTER BILABIAL CLICK
		'\u0299', // LATIN LETTER SMALL CAPITAL B
		'\u029A', // LATIN SMALL LETTER CLOSED OPEN E
		'\u029B', // LATIN LETTER SMALL CAPITAL G WITH HOOK
		'\u029C', // LATIN LETTER SMALL CAPITAL H
		'\u029D', // LATIN SMALL LETTER J WITH CROSSED-TAIL
		'\u029E', // LATIN SMALL LETTER TURNED K
		'\u029F', // LATIN LETTER SMALL CAPITAL L
		'\u02A0', // LATIN SMALL LETTER Q WITH HOOK
		'\u02A1', // LATIN LETTER GLOTTAL STOP WITH STROKE
		'\u02A2', // LATIN LETTER REVERSED GLOTTAL STOP WITH STROKE
		'\u02A3', // LATIN SMALL LETTER DZ DIGRAPH
		'\u02A4', // LATIN SMALL LETTER DEZH DIGRAPH
		'\u02A5', // LATIN SMALL LETTER DZ DIGRAPH WITH CURL
		'\u02A6', // LATIN SMALL LETTER TS DIGRAPH
		'\u02A7', // LATIN SMALL LETTER TESH DIGRAPH
		'\u02A8', // LATIN SMALL LETTER TC DIGRAPH WITH CURL
		'\u02A9', // LATIN SMALL LETTER FENG DIGRAPH
		'\u02AA', // LATIN SMALL LETTER LS DIGRAPH
		'\u02AB', // LATIN SMALL LETTER LZ DIGRAPH
		'\u02AC', // LATIN SMALL LETTER BILABIAL PERCUSSIVE
		'\u02AD', // LATIN SMALL LETTER BIDENTAL PERCUSSIVE
		'\u02AE', // LATIN SMALL LETTER TURNED H WITH FISHHOOK
		'\u02AF'  // LATIN SMALL LETTER TURNED H WITH FISHHOOK AND TAIL
	];

	div.appendChild( document.createElement( 'br' ) );
	div.appendChild( document.createTextNode( 'Insert IPA: ' ) );

		//	Windows IE display fix?
		//
		//	Why am I fixing something related to MS with no one paying me a dime??? ;-)
		//
	var A = document.createElement( 'a' );
		A.className = 'IPA';
		A.style.fontFamily = "'Code2000', 'Chrysanthi Unicode', 'Doulos SIL', 'Gentium', 'GentiumAlt', 'TITUS Cyberbit Basic', 'Bitstream Vera', 'Bitstream Cyberbit', 'Arial Unicode MS', 'Lucida Sans Unicode', 'Hiragino Kaku Gothic Pro'";

	for ( var a, i = 0; i < ipa.length; i++ )
	{
		div.appendChild( document.createTextNode( ' ' ) );
		a = A.cloneNode( false );
		a.href = "javascript:insertTags('" + ipa[ i ] + "','','')";
		a.appendChild( document.createTextNode( ipa[ i ] ) );
		div.appendChild( a );
	}
}
if ( window.addEventListener ) window.addEventListener( 'load', AddIpaExtensions, false );
else if ( window.attachEvent ) window.attachEvent( 'onload', AddIpaExtensions );