PageSourceSearch

https://www.aponzonepatrika.com/banglakeyboard/unijoy00.js

js aponzonepatrika.com collected 2026-10-02 21:56:25 UTC 10,285 bytes, 380 lines download raw bytes

1/**
2 * Unicode unijoy Parser for writing in webpages
3 * This script helps to write unicode bangla using unijoy keyboard mapping
4 * 
5 * @name Unijoy Unicode Parser
6 * @version 1.0 [Date 26th August, 2006]
7 * @author Hasin Hayder. Visit My Homepage at http://www.hasinhyder.net
8 * @license LGPL
9 */
10 
11/**
12 * This script is released under Lesser GNU Public License [LGPL] 
13 * which implies that you are free to use this script in your 
14 * web applications without any problem. No warranty ensured. If you like 
15 * this script, Please acknowledge by keeping a link to my website 
16 * http://hasin.wordpress.com in the page where you use this script. 
17 */ 
18/*
19Last Modification:01/11/2008 by Sabuj Kundu(http://manchu.wordpress.com)
20Last Modification: 26 Jan 2008 by Omi Azad (http://omi.net.bd)
21*/
22// Set of Characters
23var activeta; //active text area
24var unijoy=new Array();
25
26unijoy['0']='\u09e6';//'০'; 
27unijoy['1']='\u09e7';//'à§§';
28unijoy['2']='\u09e8';//'২';
29unijoy['3']='\u09e9';//'à§©';
30unijoy['4']='\u09ea';//'৪';
31unijoy['5']='\u09eb';//'à§«';
32unijoy['6']='\u09ec';//'৬';
33unijoy['7']='\u09ed';//'à§­';
34unijoy['8']='\u09ee';//'à§®';
35unijoy['9']='\u09ef';//'৯';
36
37// unijoy bangla equivalents
38unijoy['j'] = '\u0995'; // ko
39
40unijoy['d']='\u09BF'; // hrossho i kar
41unijoy['gd']='\u0987'; // hrossho i
42unijoy['D']='\u09C0'; // dirgho i kar
43unijoy['gD']='\u0988'; // dirgho i
44unijoy['c']='\u09C7'; // e kar
45unijoy['gc'] = '\u098F'; // E
46unijoy['gs'] = '\u0989'; // hrossho u
47unijoy['s'] = '\u09C1'; // hrossho u kar
48unijoy['S'] = '\u09C2'; // dirgho u kar
49unijoy['gS'] = '\u098A'; // dirgho u
50unijoy['v']='\u09B0'; // ro
51unijoy['a']='\u098B'; // wri
52unijoy['f']='\u09BE'; // a kar
53unijoy['gf'] = '\u0986'; //shore a
54unijoy['F']='\u0985'; // shore ao
55//unijoy['ao']='\u0985'; // shore o
56unijoy['n']='\u09B8'; // dontyo so
57unijoy['t']='\u099f'; // to
58unijoy['J'] = '\u0996'; // Kho
59
60//unijoy['kh'] = '\u0996'; // kho
61
62unijoy['b']='\u09A8'; // dontyo no
63unijoy['B']='\u09A3'; // murdhonyo no
64unijoy['k']='\u09A4'; // tto
65unijoy['K']='\u09A5'; // ttho
66
67unijoy['e']='\u09A1'; // ddo
68unijoy['E']='\u09A2'; // ddho
69
70unijoy['h']='\u09AC'; // bo
71unijoy['H']='\u09AD'; // bho
72//unijoy['v']='\u09AD'; // bho
73//unijoy['rh']='o';	 // doye bindu ro
74unijoy['p']='\u09DC';	 // doye bindu ro
75unijoy['P']='\u09DD';	 // dhoye bindu ro
76unijoy['o']='\u0997';	// go
77unijoy['O']='\u0998';	// gho
78
79//unijoy['gh']='\u0998'; // gho
80
81unijoy['i']='\u09B9';	// ho
82unijoy['I']='\u099E';	// yo
83unijoy['u']='\u099C';	// borgio jo
84unijoy['U']='\u099D'; // jho
85//unijoy['jh']='\u099D'; // jho
86unijoy['y']='\u099A'; //  cho
87unijoy['Y']='\u099B'; // cho
88//unijoy['C']='\u099B'; // ccho
89unijoy['T']='\u09A0'; // tho
90unijoy['r']='\u09AA'; // po
91unijoy['R']='\u09AB'; // fo
92//unijoy['ph']='\u09AB'; // fo
93unijoy['l']='\u09A6'; // do
94unijoy['L']='\u09A7'; // dho
95
96unijoy['w']='\u09AF';// ontoshyo zo
97unijoy['W']='\u09DF';	// ontostho yo
98unijoy['q']='\u0999';	// Uma
99unijoy['Q']='\u0982';	// uniswor
100unijoy['V']='\u09B2';	// lo
101unijoy['m']='\u09AE';	// mo
102unijoy['M']='\u09B6';	// talobyo sho
103unijoy['N']='\u09B7'; // mordhonyo sho
104unijoy['gx']= '\u0993';//'\u09CB'; // o
105unijoy['X']='\u09CC'; // ou kar
106unijoy['gX']='\u0994'; // OU
107//unijoy['Ou']='\u0994'; // OU
108unijoy['gC']='\u0990'; // Oi
109unijoy['\\']='\u0983'; // khandaTa
110unijoy['|']='\u09CE'; // bisworgo
111unijoy["G"] ="\u0964"; // dari
112//unijoy[".."] = "."; // fullstop
113unijoy['g'] = ' ';//'\u09CD' + '\u200c'; // hosonto
114unijoy['&'] = '\u0981'; // chondrobindu
115unijoy['Z'] ='\u09CD'+'\u09AF'; // jo fola
116unijoy['gh'] ='\u09CD'+ '\u09AC'; // bo fola
117unijoy['ga'] ='\u098B';// wri kar
118unijoy['a'] ='\u09C3'; // wri 
119//unijoy['k'] ="\u0995"  + '\u09CD'+ '\u09B8';
120unijoy['vZ'] = unijoy['v']+ '\u200d'+ '\u09CD'+'\u09AF';
121unijoy['z'] =  '\u09CD'+ unijoy['v'];
122unijoy['x'] = '\u09CB';
123unijoy['C'] = '\u09C8'; //Oi Kar
124
125
126
127var carry = '';  //This variable stores each keystrokes
128var old_len =0; //This stores length parsed bangla charcter
129var ctrlPressed=false;
130var first_letter = false;
131var lastInserted;
132
133isIE=document.all? 1:0;
134//Commented out by Sarwar Erfan
135//var switched=false;
136
137function checkKeyDown(ev)
138{
139	//just track the control key
140	var e = (window.event) ? event.keyCode : ev.which;
141	if (e=='17')
142	{
143		ctrlPressed = true;
144	}
145}
146
147function checkKeyUp(ev)
148{
149	//just track the control key
150	var e = (window.event) ? event.keyCode : ev.which;
151	if (e=='17')
152	{
153		ctrlPressed = false;
154		//alert(ctrlPressed);
155	}
156
157}
158
159
160function parseunijoy(evnt)
161{
162	// main unijoy parser
163	var t = document.getElementById(activeta); // the active text area
164	var e = (window.event) ? event.keyCode : evnt.which; // get the keycode
165
166	//commented out by Sarwar Erfan
167	/*
168	if (e=='113')
169	{
170		//switch the keyboard mode
171		if(ctrlPressed){
172			switched = !switched;
173			//alert("H"+switched);
174			return true;
175		}
176	}
177	*/
178	
179	if (!isUniJoy) return true;
180	
181	if(ctrlPressed)
182	{
183		// user is pressing control, so leave the parsing
184		e=0; 
185	}
186
187	var char_e = String.fromCharCode(e); // get the character equivalent to this keycode
188	
189	if(e==8 || e==32)
190	{
191		// if space is pressed we have to clear the carry. otherwise there will be some malformed conjunctions
192		carry = " ";	
193		old_len = 1;
194		return;
195	}
196
197	lastcarry = carry;
198	carry += "" + char_e;	 //append the current character pressed to the carry
199	
200	bangla = parseunijoyCarry(carry); // get the combined equivalent
201	tempBangla = parseunijoyCarry(char_e); // get the single equivalent
202
203	if (tempBangla == ".." || bangla == "..") //that means it has sibling
204	{
205		return false;
206	}
207	if (char_e=="g")
208	{
209		if(carry=="gg")
210		{
211			// check if it is a plus sign
212			insertConjunction('\u09CD' + '\u200c',old_len);
213			old_len=1;
214			return false;
215		}	
216		//otherwise this is a simple joiner
217		insertAtCursor("\u09CD");old_len = 1;
218		carry="g";
219		return false;
220	}
221
222	else if(old_len==0) //first character
223	{
224		// this is first time someone press a character
225		insertConjunction(bangla,1);
226		old_len=1;
227		return false;
228		
229	}
230
231	else if(char_e=="A")
232	{
233		//process old style ref
234		newChar = unijoy['v']+ '\u09CD';
235		insertAtCursor(newChar);
236		old_len = 1;
237		return false;
238	}
239
240	
241	else if((bangla == "" && tempBangla !="")) //that means it has no joint equivalent
242	{
243		
244		// there is no joint equivalent - so show the single equivalent. 
245		bangla = tempBangla;
246		if (bangla=="")
247		{
248			// there is no available equivalent - leave as is
249			carry ="";
250			return;
251		}
252		
253		else
254		{
255			// found one equivalent
256			carry = char_e;
257			insertAtCursor(bangla);
258			old_len = bangla.length;
259			return false;
260		}
261	}
262	else if(bangla!="")//joint equivalent found 
263	{
264		// we have found some joint equivalent process it
265		
266		insertConjunction(bangla, old_len);
267		old_len = bangla.length;
268		return false;
269	}
270}
271
272    function parseunijoyCarry(code)
273    {
274	//this function just returns a bangla equivalent for a given keystroke
275	//or a conjunction
276	//just read the array - if found then return the bangla eq.
277	//otherwise return a null value
278        if (!unijoy[code])  //Oh my god :-( no bangla equivalent for this keystroke
279
280        {
281			return ''; //return a null value
282        }
283        else
284        {
285            return ( unijoy[code]);  //voila - we've found bangla equivalent
286        }
287
288    }
289
290
291function insertAtCursor(myValue) {
292	/**
293	 * this function inserts a character at the current cursor position in a text area
294	 * many thanks to alex king and phpMyAdmin for this cool function
295	 * 
296	 * This function is originally found in phpMyAdmin package and modified by Hasin Hayder to meet the requirement
297	 */
298	lastInserted = myValue;
299	var myField = document.getElementById(activeta);
300	if (document.selection) {
301		//alert("hello2");
302		myField.focus();
303		sel = document.selection.createRange();
304		sel.text = myValue;
305		sel.collapse(true);
306		sel.select();
307	}
308	//MOZILLA/NETSCAPE support
309	else if (myField.selectionStart || myField.selectionStart == 0) {
310		
311		var startPos = myField.selectionStart;
312		var endPos = myField.selectionEnd;
313		var scrollTop = myField.scrollTop;
314		startPos = (startPos == -1 ? myField.value.length : startPos );
315		myField.value = myField.value.substring(0, startPos)
316		+ myValue
317		+ myField.value.substring(endPos, myField.value.length);
318		myField.focus();
319		myField.selectionStart = startPos + myValue.length;
320		myField.selectionEnd = startPos + myValue.length;
321		myField.scrollTop = scrollTop;
322	} else {
323		var scrollTop = myField.scrollTop;
324		myField.value += myValue;
325		myField.focus();
326		myField.scrollTop = scrollTop;
327	}
328}
329
330function insertConjunction(myValue, len) {
331	/**
332	 * this function inserts a conjunction and removes previous single character at the current cursor position in a text area
333	 * 
334	 * This function is derived from the original one found in phpMyAdmin package and modified by Hasin to meet our need
335	 */
336	//alert(len);
337	lastInserted = myValue;
338	var myField = document.getElementById(activeta);
339	if (document.selection) {
340		myField.focus();
341		sel = document.selection.createRange();
342		if (myField.value.length >= len){  // here is that first conjunction bug in IE, if you use the > operator
343			sel.moveStart('character', -1*(len));   
344			//sel.moveEnd('character',-1*(len-1));
345		}
346		sel.text = myValue;
347		sel.collapse(true);
348		sel.select();
349	}
350	//MOZILLA/NETSCAPE support
351	else if (myField.selectionStart || myField.selectionStart == 0) {
352		myField.focus();
353		var startPos = myField.selectionStart-len;
354		var endPos = myField.selectionEnd;
355		var scrollTop = myField.scrollTop;
356		startPos = (startPos == -1 ? myField.value.length : startPos );
357		myField.value = myField.value.substring(0, startPos)
358		+ myValue
359		+ myField.value.substring(endPos, myField.value.length);
360		myField.focus();
361		myField.selectionStart = startPos + myValue.length;
362		myField.selectionEnd = startPos + myValue.length;
363		myField.scrollTop = scrollTop;
364	} else {
365		var scrollTop = myField.scrollTop;
366		myField.value += myValue;
367		myField.focus();
368		myField.scrollTop = scrollTop;
369	}
370	//document.getElementById("len").innerHTML = len;
371}
372
373function makeUnijoyEditor(textAreaId)
374{
375	activeTextAreaInstance = document.getElementById(textAreaId);
376	activeTextAreaInstance.onkeypress = parseunijoy; 
377	activeTextAreaInstance.onkeydown = checkKeyDown; 
378	activeTextAreaInstance.onkeyup = checkKeyUp;
379	activeTextAreaInstance.onfocus = function(){activeta=textAreaId;};
380}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.