User:Func/wpfunc/curps.js

//	User:Func/wpfunc/curps.js	// function Curps {	var charDiv = document.getElementById( 'editpage-specialchars' ); if ( ! charDiv ) return;

//	Items are: //		- 1-item lists: containing literal HTML //		- strings of characters: //			* whitespace is ignored, each char-link is output followed by 1 space //			* each character can be		//				- the character itself, "Ĳ" //				- an html numeric entity, "&#306;" //				- a JavaScript Unicode literal, "\u0132" //			* shorthand: [nb] and [br] will insert  and for formatting //			* a sequence like 'A+Z' will link as javascript:insertTags('A','Z',''), //				- as in '«+»' //		//	All character information below is based on the charts at User:Curps/Sandbox2 //	var charData = [ [ 'es: ' ], 'Á á É é Í í Ó ó Ú ú [nb] Ü ü [nb] Ñ ñ [nb] ¡ ¿ [nb] ª º [br]', [ 'pt: ' ], 'Á á É é Í í Ó ó Ú ú [nb] Â â Ê ê Ô ô [nb] Ü ü [nb] Ç ç [nb] Ã ã Õ õ [br]', [ 'fr: ' ], 'É é [nb] À à È è Ù ù [nb] Â â Ê ê Î î Ô ô Û û [nb]', 'Ä ä Ë ë Ï ï Ö ö Ü ü [nb] Ç ç [nb] Œ œ [nb] «+» [br]', [ 'nl: ' ], '&#306; &#307; [br]', [ '<tt><a href="/wiki/German language" target="somewindow">de</a>:</tt> ' ], 'Ä ä Ö ö Ü ü [nb] ß [br]', [ '<tt><a href="/wiki/Italian language" target="somewindow">it</a>:</tt> ' ], 'É é [nb] À à È è Ò ò Ù ù [br]', [ '<tt><a href="/wiki/Danish language" target="somewindow">da</a>:</tt> ' ], 'Æ æ Ø ø Å å [br]', [ '<tt><a href="/wiki/Norwegian language" target="somewindow">no</a>:</tt> ' ], 'Æ æ Ø ø Å å [br]', [ '<tt><a href="/wiki/Swedish language" target="somewindow">sv</a>:</tt> ' ], 'Å å Ä ä Ö ö Ü ü [br]', [ '<tt><a href="/wiki/Finnish language" target="somewindow">fi</a>:</tt> ' ], 'Å å Ä ä Ö ö Ü ü &#352; &#353; &#381; &#382; [br]', [ '<tt><a href="/wiki/Icelandic language" target="somewindow">is</a>:</tt> ' ], '\u00d0 \u00f0 \u00de \u00fe [br]', // Unicode literals: Ð ð Þ þ [ '<tt><a href="/wiki/Polish language" target="somewindow">pl</a>:</tt> ' ], '&#260; &#261; &#262; &#263; &#280; &#281; &#321; &#322; &#323; &#324;',			'Ó ó &#346; &#347; &#377; &#378; &#379; &#380; [br]', [ '<tt><a href="/wiki/Czech language" target="somewindow">cs</a>:</tt> ' ], 'Á á &#268; &#269; &#270; &#271; É é &#282; &#283; Í í &#327; &#328;', 'Ó ó &#344; &#345; &#352; &#353; &#356; &#357; Ú ú &#366; &#367;', '\u00dd \u00fd &#381; &#382; [br]', // Unicode literals: Ý ý [ '<tt><a href="/wiki/Slovak language" target="somewindow">sk</a>:</tt> ' ], 'Á á Ä ä &#268; &#269; &#270; &#271; É é Í í &#313; &#314; &#317;', '&#318; &#327; &#328; Ó ó Ô ô &#340; &#341; &#352; &#353; &#356; &#357;', 'Ú ú \u00dd \u00fd &#381; &#382; [br]', // Unicode literals: Ý ý [ '<tt><a href="/wiki/Hungarian language" target="somewindow">hu</a>:</tt> ' ], 'Á á É é Í í Ó ó Ú ú [nb] Ö ö Ü ü [nb] &#336; &#337; &#368; &#369; [br]', [ '<tt><a href="/wiki/Slovenian language" target="somewindow">sl</a>:</tt> ' ], '&#268; &#269; &#352; &#353; &#381; &#382; [br]', [ '<tt><a href="/wiki/Croatian language" target="somewindow">hr</a>:</tt> ' ], '&#268; &#269; &#262; &#263; &#272; &#273; &#352; &#353; &#381; &#382; [nb]', '&#452; &#453; &#454; &#455; &#456; &#457; &#458; &#459; &#460; [br]', [ '<tt><a href="/wiki/Albanian language" target="somewindow">sq</a>:</tt> ' ], 'Ç ç Ë ë [br]', [ '<tt><a href="/wiki/Turkish language" target="somewindow">tr</a>:</tt> ' ], 'Ç ç &#286; &#287; &#304; &#305; Ö ö &#350; &#351; Ü ü [br]', [ '<tt><a href="/wiki/Romanian language" target="somewindow">ro</a>:</tt> ' ], '&#258; &#259; Â â Î î &#350; &#351; &#354; &#355; [br]', [ '<tt><a href="/wiki/Lithuanian language" target="somewindow">lt</a>:</tt> ' ], '&#260; &#261; &#268; &#269; &#280; &#281; &#278; &#279; &#302; &#303;',			'\u0160 \u0161 &#370; &#371; &#362; &#363; \u017d \u017e [br]', // Unicode literals: Š š Ž ž [ '<tt><a href="/wiki/Latvian language" target="somewindow">lv</a>:</tt> ' ], '&#256; &#257; &#268; &#269; &#274; &#275; &#290; &#291; &#298;',			'&#299; &#310; &#311; &#315; &#316; &#325; &#326; &#342; &#343;',			'\u0160 \u0161 &#362; &#363; \u017d \u017e [br]', // Unicode literals: Š š Ž ž [ '<tt><a href="/wiki/Estonian language" target="somewindow">et</a>:</tt> ' ], '\u0160 \u0161 \u017d \u017e Õ õ Ä ä Ö ö Ü ü [br]', // Unicode literals: Š š Ž ž [ '<tt><a href="/wiki/Maltese language" target="somewindow">ml</a>:</tt> ' ], '&#266; &#267; &#288; &#289; &#294; &#295; &#379; &#380; [br]', [ '<tt><a href="/wiki/Hanyu pinyin" target="somewindow">zh</a>:</tt> ' ], '&#256; &#257; &#274; &#275; &#298; &#299; &#332; &#333; &#362; &#363; [nb]', 'Á á É é Í í Ó ó Ú ú [nb]', '&#461; &#462; &#282; &#283; &#463; &#464; &#465; &#466; &#467; &#468; [nb]', 'À à È è Ì ì Ò ò Ù ù [nb]', '&#470; &#472; &#474; &#476; [br]', [ '<tt><a href="/wiki/Catalan language" target="somewindow">ca</a>:</tt> ' ], 'À à Ç ç È è É é Í í Ï ï &#319; &#320; Ò ò Ó ó Ú ú Ü ü [br]', [ '<tt><a href="/wiki/Esperanto language" target="somewindow">eo</a>:</tt> ' ], '&#264; &#265; &#284; &#285; &#292; &#293; &#308; &#309; &#348; &#349; &#364; &#365; [br]', [ '<tt><a href="/wiki/Welsh language" target="somewindow">cy</a>:</tt> ' ], '&#372; &#373; &#374; &#375;',	];

var newDiv = document.createElement( 'div' ); newDiv.className = 'plainlinks'; newDiv.style.marginTop = '15px'; newDiv.style.borderWidth = '1px'; newDiv.style.borderStyle = 'solid'; newDiv.style.borderColor = '#aaaaaa'; newDiv.style.padding = '2px'; newDiv.style.fontSize = 'x-small';

newDiv.innerHTML = ''; // it's undefined otherwise, causes problems later

charDiv.parentNode.insertBefore( newDiv, charDiv ); // before the existing insertion-links //	charDiv.parentNode.insertBefore( newDiv, charDiv.nextSibling ); // after the existing insertion-links //	charDiv.parentNode.replaceChild( newDiv, charDiv ); // replace the existing insertion-links

var i, j, v, a, c, c2, link;

for ( i = 0; i < charData.length; i++ ) {		v = charData[ i ]; // array or string

if ( v.constructor == Array ) newDiv.innerHTML += v[ 0 ]; // Is this going to work ??? !!!		else if ( v.constructor == String ) // sanity check {			a = v.split( / +/ ); // break at spaces

for ( j = 0; j < a.length; j++ ) {				if ( ! ( c = a[ j ] ) ) continue; // sanity check

c2 = c.split( /\+/ ); // as in "«+»" for javascript:insertTags('«','»','') if ( c2.length > 1 ) {					c = c2[ 0 ]; c2 = c2[ 1 ]; }				else c2 = '';

if ( c == '[nb]' ) { newDiv.innerHTML += ' '; continue } else if ( c == '[br]' ) { newDiv.innerHTML += ' ';  continue }

if ( c .indexOf( '&#' ) == 0 ) c = String.fromCharCode( Number( c .substring( 2, c .length - 1 ) ) ); if ( c2.indexOf( '&#' ) == 0 ) c2 = String.fromCharCode( Number( c2.substring( 2, c2.length - 1 ) ) );

link = document.createElement( 'a' ); link.appendChild( document.createTextNode( c + c2 ) ); link.href = "javascript:insertTags('" + c + "','" + c2 + "','')";

newDiv.appendChild( link ); newDiv.appendChild( document.createTextNode( ' ' ) ); }		}	} } if ( window.addEventListener ) window.addEventListener( 'load', Curps, false ); else if ( window.attachEvent ) window.attachEvent( 'onload', Curps );