User:Mayur/vector.js

From translatewiki.net
Jump to: navigation, search
/**
 * Beginning of Transliteration Tool
 * Author: Junaid P V [[user:Junaidpv]]
 * added date: 2010-09-28
 */
function addOptionsToSimpleSearch() {
	// To add checkbox for simple search box
	//added by : [[User:Sadik Khalid]] (sadik.khalid@gmail.com)
	//********************* Starts here **********************************
	var firstone =document.getElementById('p-search');
	if(firstone!= null) {
		try
		{
		var nextone=document.getElementById('h5');
		
		var transListBox = document.createElement("select");
		transListBox.style.position ="relative";
		transListBox.style.fontSize="0.7em";
		transListBox.style.top="-4.5em";
		if (transListBox.addEventListener)
			transListBox.addEventListener("change", writingStyleLBChanged, false);
		else if (transListBox.attachEvent) 
			transListBox.attachEvent("onchange", writingStyleLBChanged);
		var numOfSchemes = transettings.schemes.length;
		for(var i=0; i < numOfSchemes; i++) {
			var schemeOption = document.createElement("option");
			schemeOption.appendChild( document.createTextNode(transettings.schemes[i].text) );
			schemeOption.value = transettings.schemes[i].text;
			if(transettings.default_scheme_index==i) schemeOption.selected=true;
			transListBox.appendChild( schemeOption );
		}
		 
		var chkboxelement = document.createElement("input");
		chkboxelement.setAttribute("type","checkbox");
		chkboxelement.setAttribute("id","searchInputcb");
		chkboxelement.style.position ="relative";
		chkboxelement.style.left=".2em";
		chkboxelement.style.top="-3.8em";
		chkboxelement.value = 'searchInput'; // specifying curresponding input filed.
		chkboxelement.checked = transettings.default_state;			
		 
		if (chkboxelement.addEventListener) 
		chkboxelement.addEventListener("click", transOptionOnClick, false);
		else if (chkboxelement.attachEvent) 
		chkboxelement.attachEvent("onclick", transOptionOnClick);
		 
		var chkboxlabel = document.createElement('chkboxlabel');
		chkboxlabel.style.fontSize = '.7em';
		//chkboxlabel.style.fontWeight = 'bold';
		chkboxlabel.style.position ="relative";
		chkboxlabel.style.left="0.5em";
		chkboxlabel.style.top="-4.8em"
		 
		var linktohelp = document.createElement ('a')
		linktohelp.href= transettings.checkbox.link.href;
		linktohelp.title= transettings.checkbox.link.tooltip;
		linktohelp.appendChild( document.createTextNode(transettings.checkbox.simple_text) );
		chkboxlabel.appendChild(linktohelp);
		chkboxlabel.appendChild(document.createElement('br'));
		firstone.insertBefore(transListBox,nextone);
		firstone.insertBefore(chkboxelement,nextone);		
		firstone.insertBefore(chkboxlabel,nextone);
		firstone.style.position ="relative";
		//firstone.style.top="-1.6em";
		}
		catch(ex)
		{
		//Error
		}
	}
	//************************* Ends here ****************************
}
importScriptURI('http://hi.wiktionary.org/w/index.php?title=MediaWiki:Sa_rules.js&action=raw&ctype=text/javascript');
importScriptURI('http://sa.wikipedia.org/w/index.php?title=MediaWiki:sa_inscript_rules.js&action=raw&ctype=text/javascript');
importScriptURI('http://ml.wikipedia.org/w/index.php?title=Mediawiki:transli.js&action=raw&ctype=text/javascript');

function transetup(event) {
	transettings.schemes[0] = tr_sa;
	transettings.schemes[1] = tr_sa_inscript;
	transettings.shortcut.controlkey =true;
	transettings.shortcut.key = 'M';
	transettings.checkbox.text =  "देवनागरी ("+transettings.shortcut.toString()+")";
	transettings.checkbox.link.href = "http://sa.wikipedia.org/wiki/Help:Typing";
	transettings.checkbox.simple_text = 'देवनागरी';
	transettings.checkbox.link.tooltip = "Use this tool to write Sanskrit, Shortcut: "+transettings.shortcut.toString();
	setDefaultSchmeIndex(readCookie("transToolIndex"));

	transliterate('searchInput', 'wpTextbox1', 'wpSummary', 'searchText', 'powerSearchText', 'wpNewTitle', 'wpReason', 'nsfrom', 'username', 'mwProtect-reason', 'nsto','wpText',  'wpUploadDescription', 'wpDestFile');
	addTransliterationOption( 'searchText', 'powerSearchText', 'wpNewTitle', 'wpReason', 'nsfrom', 'username', 'mwProtect-reason', 'nsto','wpText', 'wpUploadDescription', 'wpDestFile');
	transettings.checkbox.position = "before";
	addTransliterationOption( 'wpTextbox1', 'wpSummary' );
	addOptionsToSimpleSearch();
	initMultiScheme();
	translitStateSynWithCookie('searchInput', 'wpTextbox1', 'wpSummary', 'searchText', 'powerSearchText', 'wpNewTitle', 'wpReason', 'nsfrom', 'username', 'mwProtect-reason', 'nsto','wpText');
}


if (window.addEventListener){
	window.addEventListener('load', transetup, false);
} else if (window.attachEvent){
	window.attachEvent('onload', transetup);
}
/* End of Transliteration Tool */