User:MarkS/XEB/dev.js

This is an old revision of this page, as edited by MarkS (talk | contribs) at 19:30, 7 April 2007 (blank parts for sortable testing). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//============================================================
// Table generator 
//============================================================
/** en: Generate an array using Mediawiki syntax
* @author: originally from fr:user:dake
* @version: 0.2 */
function generateTable(caption, exhead, nbCol, nbRow, exfield, align){
	
};


function XEBPopupRef(e){

	m=new GetPos(e||event);

	curPopup=new XEBPopup("ref",m.x,m.y);
	curPopup.width=500;
	mt='<p>Enter the reference parameters below: <\/p>'
		+'<form name="XEBPopupRefForm">'
		+'Name:<input type="text" name="refName" value="" size="10"><p\/>'
		+'Material:<input type="text" name="refMaterial" value="' + XEBGetSelectedText() + '" size="20">'
		+'<\/form>'
		+'<p><button onClick="javascript:insertRef()">Insert</button>'
		+'<button onClick="hideXEBPopup()">Cancel</button>';

	curPopup.setInnerHTML(mt);
//	document.XEBPopupRefForm.refName.focus();
	return true;
}

function insertRef(){
	f=document.XEBPopupRefForm;
	var refName = f.refName.value;
	var refMaterial=f.refMaterial.value;
	
	hideXEBPopup();
	var code1='<ref';
	code1+=(refName)?' name="'+refName+'">':'>'; 
	code2=refMaterial;
	code3='<\/ref>'
	XEBinsertText(code1,code2,code3,curPopup.IESelectedRange);

	extendSummary('ref');
	return false;
} 

//===GEO LINK Function==================================================

function XEBPopupGeoLink(e)
{
	m=new GetPos(e||event);

	curPopup=new XEBPopup("geo",m.x,m.y);
	curPopup.width=300;
	mt='<p>Enter the ___location parameters below: <\/p>'
		+'<form name="XEBPopupGeoLinkForm">'
		+'Loction:<p\/>'
		+'<table style="background: transparent;">'
		+'<tr><td>Latitude:<\/td><td><input type="text" autocomplete="off" name="geoLatDeg" value="" size="4"><\/td>'
		+'<td><input type="text" name="geoLatMin" value="" size="4"><\/td>'
		+'<td><input type="text" name="geoLatSec" value="" size="4"><\/td>'
		+'<td><select name="geoLatNS"><option value="N">N<option value="S">S</select><\/td><\/tr>'
		+'<tr><td>Longitude:<\/td><td><input type="text" name="geoLonDeg" value="" size="4"><\/td>'
		+'<td><input type="text" name="geoLonMin" value="" size="4"><\/td>'
		+'<td><input type="text" name="geoLonSec" value="" size="4"><\/td>'
		+'<td><select name="geoLonEW"><option value="E">E<option value="W">W</select><\/td><\/tr>'
		+'<\/table>'
		+'Region:<input type="text" name="geoRegion" value="" size="4"><p\/>'
		+'Type:'
		+'<SELECT NAME="geoType" size="5">'
		+'<OPTION VALUE="country">Country<OPTION VALUE="state">State'
		+'<OPTION VALUE="adm1st">Admin unit, 1st level<OPTION VALUE="adm2st">Admin unit, 2nd level'
		+'<OPTION VALUE="city">City<OPTION VALUE="airport">Airport'
		+'<OPTION VALUE="mountain">Mountain<OPTION VALUE="isle">Isle'
		+'<OPTION VALUE="waterbody">Waterbody<OPTION VALUE="landmark" SELECTED>Landmark'
		+'<OPTION VALUE="forest">forest</SELECT><br>'
		+'Title: <input type="checkbox" name="geoTitle" ><p\/>'
		+'<\/form>'
		+'<p><button onClick="javascript:insertGeoLink()">Insert</button>'
		+'<button onClick="hideXEBPopup()">Cancel</button>';

	curPopup.setInnerHTML(mt);
	document.paramForm.refName.focus();
	return true;

}
function insertGeoLink()
{
	f=document.XEBPopupGeoLinkForm;

	var code='{{Coor ';
	if(f.geoTitle.checked)code+='title ';
	ft='dms';
	if(f.geoLatSec.value==''&&f.geoLonSec.value=='')ft='dm';
	if(ft=='dm'&&f.geoLatMin.value==''&&f.geoLonMin.value=='')ft='d';
	code+=ft;
	code+='|'+f.geoLatDeg.value;
	code+=(ft=='dm'||ft=='dms')?'|'+f.geoLatMin.value:'';
	code+=(ft=='dms')?'|'+f.geoLatSec.value:'';
	code+='|'+f.geoLatNS.value;
	code+='|'+f.geoLonDeg.value;
	code+=(ft=='dm'||ft=='dms')?'|'+f.geoLonMin.value:'';
	code+=(ft=='dms')?'|'+f.geoLonSec.value:'';
	code+='|'+f.geoLonEW.value;
	code+='|type:'+f.geoType.value+'_region:'+f.geoRegion.value
	code+='}}';
	insertTags('','', code);
	extendSummary('geo-___location');
	hideXEBPopup();
	return false;
}

//===Talk Page entry Function===========================================

function XEBPopupTalk(e)
{
	m=new GetPos(e||event);

	curPopup=new XEBPopup("talk",m.x,m.y);
	curPopup.width=200;
	mt='<div style="font-size:medium"><p>Please choose:<\/p>'
	mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(1)">Test1<\/span><br>'
	mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(2)">Self Test<\/span><br>'
	mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(3)">Nonsense<\/span><br>'
	mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(4)">Please stop<\/span><br>'
	mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(5)">Last chance<\/span><br>'
	mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(6)">Blanking<\/span><br>'
	mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(7)">Blatant<\/span><br>'
	mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(8)">*BLOCKED*<\/span><br>'
	mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(9)">Spam<\/span><br>'
	mt+='<span class="XEBMnuItm" onclick="XEBInsertTalk(10)">Npov<\/span></div>'

	curPopup.setInnerHTML(mt);

	return true;

}
function XEBInsertTalk(itm)
{
	hideXEBPopup();
	insertTags('','', code);
	return false;
}
function XEBPopupImage(e)
{
	m=new GetPos(e||event);

	curPopup=new XEBPopup("image",m.x,m.y);
	curPopup.width=300;

	mt='<p>Enter the image parameters below: <\/p>'
		+'<form name="XEBPopupImageForm">'
		+'File:<input type="text" name="imgFile" value="' + XEBGetSelectedText() + '" size="30"><br>'
		+'Type:<SELECT NAME="imgType">'
		+'<OPTION VALUE="thumb">Thumbnail'
		+'<OPTION VALUE="frame">Frame'
		+'<OPTION VALUE="none">[not specified]'
		+'</SELECT><br>'
		+'Location:<SELECT NAME="imgLocation">'
		+'<OPTION VALUE="left">Left'
		+'<OPTION VALUE="center">Centre'
		+'<OPTION VALUE="right">Right'
		+'<OPTION VALUE="none">None'
		+'</SELECT><br>'
		+'Size:<input type="text" name="imgSize" value="100" size="3">px<br>'
		+'Caption:<input type="text" name="imgCaption" value="" size="30"><\/p>'
		+'<\/form>'
		+'<p><button onClick="javascript:XEBInsertImage()">Insert</button>'
		+'<button onClick="hideXEBPopup()">Cancel</button>';

	curPopup.setInnerHTML(mt);

	return true;
}
function XEBInsertImage()
{
	f=document.XEBPopupImageForm;
	hideXEBPopup();
	var code='[[Image:';
	code+=f.imgFile.value;
	code+='|'+f.imgType.value;
	code+='|'+f.imgLocation.value;
	code+='|'+f.imgSize.value;
	code+='|'+f.imgCaption.value;
	code+=']]';
	insertTags('','', code);
	extendSummary('image');

	return false;
}

function XEBPopupFormattedText(e)
{
	m=new GetPos(e||event);

	curPopup=new XEBPopup("image",m.x,m.y);
	curPopup.width=300;
	
	mt='<form name="XEBPopupImageForm">'
		+'<table  style="background: transparent;">'
		+'<tr><td>Bold:<\/td><td><input type="checkbox" name="textBold"><\/td>'
		+'<td>Superscript:<\/td><td><input type="checkbox" name="textSuperscript"><\/td><\/tr>'
		+'<tr><td>Italic:<\/td><td><input type="checkbox" name="textItalic"><\/td>'
		+'<td>Subscript:<\/td><td><input type="checkbox" name="textSubscript"><\/td><\/tr>'
		+'<tr><td>Strike:<\/td><td><input type="checkbox" name="textStrike"><\/td>'
		+'<td>&nbsp;<\/td><\/tr>'
		+'</table>'
		+'Size:<SELECT NAME="textSize">'
		+'<OPTION VALUE="small">small'
		+'<OPTION VALUE="normal">[Normal]'
		+'<OPTION VALUE="big">big'
		+'</SELECT><br><table style="background:transparent;"><tr><td>Colour:<\/td><td>'
		+'<table width="100px">'
		+'<tr><td colspan="4">None<\/td></tr>'
		+'<tr><td bgcolor="aqua">&nbsp;<\/td><td bgcolor="gray"> &nbsp;<\/td>'
		+'<td bgcolor="olive">&nbsp;<\/td><td bgcolor="navy">&nbsp;<\/td><\/tr>'
		+'<tr><td bgcolor="black">&nbsp;<\/td><td bgcolor="green"> &nbsp;<\/td>'
		+'<td bgcolor="purple">&nbsp;<\/td><td bgcolor="teal">&nbsp;<\/td><\/tr>'
		+'<tr><td bgcolor="blue">&nbsp;<\/td><td bgcolor="lime">&nbsp;<\/td>'
		+'<td bgcolor="red">&nbsp;<\/td><td bgcolor="white">&nbsp;<\/td><\/tr>'
		+'<tr><td bgcolor="fuchsia">&nbsp;<\/td><td bgcolor="maroon">&nbsp;<\/td>'
		+'<td bgcolor="silver">&nbsp;<\/td><td bgcolor="yellow">&nbsp;<\/td><\/tr>'
		+'</table><\/td><\/tr>'
		+'<\/form>'
		+'Sample:'
		+'<span id="sampleText">Text</span>"'
		+'<p><button onClick="javascript:XEBInsertFormattedText()">Insert</button>'
		+'<button onClick="hideXEBPopup()">Cancel</button>';

	curPopup.setInnerHTML(mt);

	return true;
}

function XEBUpdateSampleText()
{
	f=document.XEBPopupImageForm;
}

//====================

function XEBMenuMouseOut(e)
{
	var targ;
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;

	targ.style.color='black';
}

function XEBMenuMouseOver(e)
{	var targ;
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;

	targ.style.color='red';
}

//=======================================================================
// Other functions
//=======================================================================

function getElementsByClassName(parent,clsName,htmltag){ 
	var arr = new Array(); 
	var elems = parent.getElementsByTagName(htmltag);
	for ( var cls, i = 0; ( elem = elems[i] ); i++ ){
		if ( elem.className == clsName ){
			arr[arr.length] = elem;
		}
	}
	return arr;
}

function extendSummary(newText)
{
	if(!XEBExtendEditSummary)return;
	s=document.editform.elements['wpSummary'].value;
	s+=(s=='')?newText:' +'+newText;
	document.editform.elements['wpSummary'].value=s;
}

function bug(msg)
{
	if(wgUserName=='MarkS')alert(msg);
}


//</pre>