!import
1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Original Code is Mozilla Communicator client code, released
15 * March 31, 1998.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998-1999
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 * Baki Bon <bakibon@yahoo.com> (original author)
24 * Charles Manske (cmanske@netscape.com)
25 * Neil Rashbrook (neil@parkwaycc.co.uk)
26 *
27 * Alternatively, the contents of this file may be used under the terms of
28 * either of the GNU General Public License Version 2 or later (the "GPL"),
29 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 * in which case the provisions of the GPL or the LGPL are applicable instead
31 * of those above. If you wish to allow use of your version of this file only
32 * under the terms of either the GPL or the LGPL, and not to allow others to
33 * use your version of this file under the terms of the MPL, indicate your
34 * decision by deleting the provisions above and replace them with the notice
35 * and other provisions required by the GPL or the LGPL. If you do not delete
36 * the provisions above, a recipient may use your version of this file under
37 * the terms of any one of the MPL, the GPL or the LGPL.
38 *
39 * ***** END LICENSE BLOCK ***** */
40
41 //------------------------------------------------------------------
42 // From Unicode 3.0 Page 54. 3.11 Conjoining Jamo Behavior
43 var SBase = 0xac00;
44 var LBase = 0x1100;
45 var VBase = 0x1161;
46 var TBase = 0x11A7;
47 var LCount = 19;
48 var VCount = 21;
49 var TCount = 28;
50 var NCount = VCount * TCount;
51 // End of Unicode 3.0
52
53 // dialog initialization code
Startup
54 function Startup()
55 {
56 if (!GetCurrentEditor())
57 {
58 window.close();
59 return;
60 }
61
62 StartupLatin();
63
64 // Set a variable on the opener window so we
65 // can track ownership of close this window with it
66 window.opener.InsertCharWindow = window;
67 window.sizeToContent();
68
69 SetWindowLocation();
70 }
71
onAccept
72 function onAccept()
73 {
74 // Insert the character
75 try {
76 GetCurrentEditor().insertText(LatinM.label);
77 } catch(e) {}
78
79 // Set persistent attributes to save
80 // which category, letter, and character modifier was used
81 CategoryGroup.setAttribute("category", category);
82 CategoryGroup.setAttribute("letter_index", indexL);
83 CategoryGroup.setAttribute("char_index", indexM);
84
85 // Don't close the dialog
86 return false;
87 }
88
89 // Don't allow inserting in HTML Source Mode
onFocus
90 function onFocus()
91 {
92 var enable = true;
93 if ("gEditorDisplayMode" in window.opener)
94 enable = !window.opener.IsInHTMLSourceMode();
95
96 SetElementEnabled(document.documentElement.getButton("accept"), enable);
97 }
98
onClose
99 function onClose()
100 {
101 window.opener.InsertCharWindow = null;
102 SaveWindowLocation();
103 return true;
104 }
105
106 //------------------------------------------------------------------
107 var LatinL;
108 var LatinM;
109 var LatinL_Label;
110 var LatinM_Label;
111 var indexL=0;
112 var indexM=0;
113 var indexM_AU=0;
114 var indexM_AL=0;
115 var indexM_U=0;
116 var indexM_L=0;
117 var indexM_S=0;
118 var LItems=0;
119 var category;
120 var CategoryGroup;
121 var initialize = true;
122
StartupLatin
123 function StartupLatin()
124 {
125
126 LatinL = document.getElementById("LatinL");
127 LatinM = document.getElementById("LatinM");
128 LatinL_Label = document.getElementById("LatinL_Label");
129 LatinM_Label = document.getElementById("LatinM_Label");
130
131 var Symbol = document.getElementById("Symbol");
132 var AccentUpper = document.getElementById("AccentUpper");
133 var AccentLower = document.getElementById("AccentLower");
134 var Upper = document.getElementById("Upper");
135 var Lower = document.getElementById("Lower");
136 CategoryGroup = document.getElementById("CatGrp");
137
138 // Initialize which radio button is set from persistent attribute...
139 var category = CategoryGroup.getAttribute("category");
140
141 // ...as well as indexes into the letter and character lists
142 var index = Number(CategoryGroup.getAttribute("letter_index"));
143 if (index && index >= 0)
144 indexL = index;
145 index = Number(CategoryGroup.getAttribute("char_index"));
146 if (index && index >= 0)
147 indexM = index;
148
149
150 switch (category)
151 {
152 case "AccentUpper": // Uppercase Diacritical
153 CategoryGroup.selectedItem = AccentUpper;
154 indexM_AU = indexM;
155 break;
156 case "AccentLower": // Lowercase Diacritical
157 CategoryGroup.selectedItem = AccentLower;
158 indexM_AL = indexM;
159 break;
160 case "Upper": // Uppercase w/o Diacritical
161 CategoryGroup.selectedItem = Upper;
162 indexM_U = indexM;
163 break;
164 case "Lower": // Lowercase w/o Diacritical
165 CategoryGroup.selectedItem = Lower;
166 indexM_L = indexM;
167 break;
168 default:
169 category = "Symbol";
170 CategoryGroup.selectedItem = Symbol;
171 indexM_S = indexM;
172 break;
173 }
174
175 ChangeCategory(category);
176 initialize = false;
177 }
178
ChangeCategory
179 function ChangeCategory(newCategory)
180 {
181 if (category != newCategory || initialize)
182 {
183 category = newCategory;
184 // Note: Must do L before M to set LatinL.selectedIndex
185 UpdateLatinL();
186 UpdateLatinM();
187 UpdateCharacter();
188 }
189 }
190
SelectLatinLetter
191 function SelectLatinLetter()
192 {
193 if(LatinL.selectedIndex != indexL )
194 {
195 indexL = LatinL.selectedIndex;
196 UpdateLatinM();
197 UpdateCharacter();
198 }
199 }
200
SelectLatinModifier
201 function SelectLatinModifier()
202 {
203 if(LatinM.selectedIndex != indexM )
204 {
205 indexM = LatinM.selectedIndex;
206 UpdateCharacter();
207 }
208 }
DisableLatinL
209 function DisableLatinL(disable)
210 {
211 if (disable) {
212 LatinL_Label.setAttribute("disabled", "true");
213 LatinL.setAttribute("disabled", "true");
214 } else {
215 LatinL_Label.removeAttribute("disabled");
216 LatinL.removeAttribute("disabled");
217 }
218 }
219
UpdateLatinL
220 function UpdateLatinL()
221 {
222 LatinL.removeAllItems();
223 if (category == "AccentUpper" || category == "AccentLower")
224 {
225 DisableLatinL(false);
226 // No Q or q
227 var alphabet = category == "AccentUpper" ? "ABCDEFGHIJKLMNOPRSTUVWXYZ" : "abcdefghijklmnoprstuvwxyz";
228 for (var letter = 0; letter < alphabet.length; letter++)
229 LatinL.appendItem(alphabet.charAt(letter));
230
231 LatinL.selectedIndex = indexL;
232 }
233 else
234 {
235 // Other categories don't hinge on a "letter"
236 DisableLatinL(true);
237 // Note: don't change the indexL so it can be used next time
238 }
239 }
240
UpdateLatinM
241 function UpdateLatinM()
242 {
243 LatinM.removeAllItems();
244 var i, accent;
245 switch(category)
246 {
247 case "AccentUpper": // Uppercase Diacritical
248 accent = upper[indexL];
249 for(i=0; i < accent.length; i++)
250 LatinM.appendItem(accent.charAt(i));
251
252 if(indexM_AU < accent.length)
253 indexM = indexM_AU;
254 else
255 indexM = accent.length - 1;
256 indexM_AU = indexM;
257 break;
258
259 case "AccentLower": // Lowercase Diacritical
260 accent = lower[indexL];
261 for(i=0; i < accent.length; i++)
262 LatinM.appendItem(accent.charAt(i));
263
264 if(indexM_AL < accent.length)
265 indexM = indexM_AL;
266 else
267 indexM = lower[indexL].length - 1;
268 indexM_AL = indexM;
269 break;
270
271 case "Upper": // Uppercase w/o Diacritical
272 for(i=0; i < otherupper.length; i++)
273 LatinM.appendItem(otherupper.charAt(i));
274
275 if(indexM_U < otherupper.length)
276 indexM = indexM_U;
277 else
278 indexM = otherupper.length - 1;
279 indexM_U = indexM;
280 break;
281
282 case "Lower": // Lowercase w/o Diacritical
283 for(i=0; i < otherlower.length; i++)
284 LatinM.appendItem(otherlower.charAt(i));
285
286 if(indexM_L < otherlower.length)
287 indexM = indexM_L;
288 else
289 indexM = otherlower.length - 1;
290 indexM_L = indexM;
291 break;
292
293 case "Symbol": // Symbol
294 for(i=0; i < symbol.length; i++)
295 LatinM.appendItem(symbol.charAt(i));
296
297 if(indexM_S < symbol.length)
298 indexM = indexM_S;
299 else
300 indexM = symbol.length - 1;
301 indexM_S = indexM;
302 break;
303 }
304 LatinM.selectedIndex = indexM;
305 }
306
UpdateCharacter
307 function UpdateCharacter()
308 {
309 indexM = LatinM.selectedIndex;
310
311 switch(category)
312 {
313 case "AccentUpper": // Uppercase Diacritical
314 indexM_AU = indexM;
315 break;
316 case "AccentLower": // Lowercase Diacritical
317 indexM_AL = indexM;
318 break;
319 case "Upper": // Uppercase w/o Diacritical
320 indexM_U = indexM;
321 break;
322 case "Lower": // Lowercase w/o Diacritical
323 indexM_L = indexM;
324 break;
325 case "Symbol":
326 indexM_S = indexM;
327 break;
328 }
329 //dump("Letter Index="+indexL+", Character Index="+indexM+", Character = "+LatinM.label+"\n");
330 }
331
332 const upper=[
333 // A
334 "\u00c0\u00c1\u00c2\u00c3\u00c4\u00c5\u0100\u0102\u0104\u01cd\u01de\u01de\u01e0\u01fa\u0200\u0202\u0226\u1e00\u1ea0\u1ea2\u1ea4\u1ea6\u1ea8\u1eaa\u1eac\u1eae\u1eb0\u1eb2\u1eb4\u1eb6",
335 // B
336 "\u0181\u0182\u0184\u1e02\u1e04\u1e06",
337 // C
338 "\u00c7\u0106\u0108\u010a\u010c\u0187\u1e08",
339 // D
340 "\u010e\u0110\u0189\u018a\u1e0a\u1e0c\u1e0e\u1e10\u1e12",
341 // E
342 "\u00C8\u00C9\u00CA\u00CB\u0112\u0114\u0116\u0118\u011A\u0204\u0206\u0228\u1e14\u1e16\u1e18\u1e1a\u1e1c\u1eb8\u1eba\u1ebc\u1ebe\u1ec0\u1ec2\u1ec4\u1ec6",
343 // F
344 "\u1e1e",
345 // G
346 "\u011c\u011E\u0120\u0122\u01e4\u01e6\u01f4\u1e20",
347 // H
348 "\u0124\u0126\u021e\u1e22\u1e24\u1e26\u1e28\u1e2a",
349 // I
350 "\u00CC\u00CD\u00CE\u00CF\u0128\u012a\u012C\u012e\u0130\u0208\u020a\u1e2c\u1e2e\u1ec8\u1eca",
351 // J
352 "\u0134\u01f0",
353 // K
354 "\u0136\u0198\u01e8\u1e30\u1e32\u1e34",
355 // L
356 "\u0139\u013B\u013D\u013F\u0141\u1e36\u1e38\u1e3a\u1e3c",
357 // M
358 "\u1e3e\u1e40\u1e42",
359 // N
360 "\u00D1\u0143\u0145\u0147\u014A\u01F8\u1e44\u1e46\u1e48\u1e4a",
361 // O
362 "\u00D2\u00D3\u00D4\u00D5\u00D6\u014C\u014E\u0150\u01ea\u01ec\u020c\u020e\u022A\u022C\u022E\u0230\u1e4c\u1e4e\u1e50\u1e52\u1ecc\u1ece\u1ed0\u1ed2\u1ed4\u1ed6\u1ed8\u1eda\u1edc\u1ede\u1ee0\u1ee2",
363 // P
364 "\u1e54\u1e56",
365 // No Q
366 // R
367 "\u0154\u0156\u0158\u0210\u0212\u1e58\u1e5a\u1e5c\u1e5e",
368 // S
369 "\u015A\u015C\u015E\u0160\u0218\u1e60\u1e62\u1e64\u1e66\u1e68",
370 // T
371 "\u0162\u0164\u0166\u021A\u1e6a\u1e6c\u1e6e\u1e70",
372 // U
373 "\u00D9\u00DA\u00DB\u00DC\u0168\u016A\u016C\u016E\u0170\u0172\u0214\u0216\u1e72\u1e74\u1e76\u1e78\u1e7a\u1ee4\u1ee6\u1ee8\u1eea\u1eec\u1eee\u1ef0",
374 // V
375 "\u1e7c\u1e7e",
376 // W
377 "\u0174\u1e80\u1e82\u1e84\u1e86\u1e88",
378 // X
379 "\u1e8a\u1e8c",
380 // Y
381 "\u00DD\u0176\u0178\u0232\u1e8e\u1ef2\u1ef4\u1ef6\u1ef8",
382 // Z
383 "\u0179\u017B\u017D\u0224\u1e90\u1e92\u1e94"
384 ];
385
386 const lower=[
387 // a
388 "\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5\u0101\u0103\u0105\u01ce\u01df\u01e1\u01fb\u0201\u0203\u0227\u1e01\u1e9a\u1ea1\u1ea3\u1ea5\u1ea7\u1ea9\u1eab\u1ead\u1eaf\u1eb1\u1eb3\u1eb5\u1eb7",
389 // b
390 "\u0180\u0183\u0185\u1e03\u1e05\u1e07",
391 // c
392 "\u00e7\u0107\u0109\u010b\u010d\u0188\u1e09",
393 // d
394 "\u010f\u0111\u1e0b\u1e0d\u1e0f\u1e11\u1e13",
395 // e
396 "\u00e8\u00e9\u00ea\u00eb\u0113\u0115\u0117\u0119\u011b\u0205\u0207\u0229\u1e15\u1e17\u1e19\u1e1b\u1e1d\u1eb9\u1ebb\u1ebd\u1ebf\u1ec1\u1ec3\u1ec5\u1ec7",
397 // f
398 "\u1e1f",
399 // g
400 "\u011d\u011f\u0121\u0123\u01e5\u01e7\u01f5\u1e21",
401 // h
402 "\u0125\u0127\u021f\u1e23\u1e25\u1e27\u1e29\u1e2b\u1e96",
403 // i
404 "\u00ec\u00ed\u00ee\u00ef\u0129\u012b\u012d\u012f\u0131\u01d0\u0209\u020b\u1e2d\u1e2f\u1ec9\u1ecb",
405 // j
406 "\u0135",
407 // k
408 "\u0137\u0138\u01e9\u1e31\u1e33\u1e35",
409 // l
410 "\u013a\u013c\u013e\u0140\u0142\u1e37\u1e39\u1e3b\u1e3d",
411 // m
412 "\u1e3f\u1e41\u1e43",
413 // n
414 "\u00f1\u0144\u0146\u0148\u0149\u014b\u01f9\u1e45\u1e47\u1e49\u1e4b",
415 // o
416 "\u00f2\u00f3\u00f4\u00f5\u00f6\u014d\u014f\u0151\u01d2\u01eb\u01ed\u020d\u020e\u022b\u022d\u022f\u0231\u1e4d\u1e4f\u1e51\u1e53\u1ecd\u1ecf\u1ed1\u1ed3\u1ed5\u1ed7\u1ed9\u1edb\u1edd\u1edf\u1ee1\u1ee3",
417 // p
418 "\u1e55\u1e57",
419 // No q
420 // r
421 "\u0155\u0157\u0159\u0211\u0213\u1e59\u1e5b\u1e5d\u1e5f",
422 // s
423 "\u015b\u015d\u015f\u0161\u0219\u1e61\u1e63\u1e65\u1e67\u1e69",
424 // t
425 "\u0162\u0163\u0165\u0167\u021b\u1e6b\u1e6d\u1e6f\u1e71\u1e97",
426 // u
427 "\u00f9\u00fa\u00fb\u00fc\u0169\u016b\u016d\u016f\u0171\u0173\u01d4\u01d6\u01d8\u01da\u01dc\u0215\u0217\u1e73\u1e75\u1e77\u1e79\u1e7b\u1ee5\u1ee7\u1ee9\u1eeb\u1eed\u1eef\u1ef1",
428 // v
429 "\u1e7d\u1e7f",
430 // w
431 "\u0175\u1e81\u1e83\u1e85\u1e87\u1e89\u1e98",
432 // x
433 "\u1e8b\u1e8d",
434 // y
435 "\u00fd\u00ff\u0177\u0233\u1e8f\u1e99\u1ef3\u1ef5\u1ef7\u1ef9",
436 // z
437 "\u017a\u017c\u017e\u0225\u1e91\u1e93\u1e95"
438 ];
439
440
441 const symbol = "\u00a1\u00a2\u00a3\u00a4\u00a5\u20ac\u00a6\u00a7\u00a8\u00a9\u00aa\u00ab\u00ac\u00ae\u00af\u00b0\u00b1\u00b2\u00b3\u00b4\u00b5\u00b6\u00b7\u00b8\u00b9\u00ba\u00bb\u00bc\u00bd\u00be\u00bf\u00d7\u00f7";
442
443 const otherupper = "\u00c6\u00d0\u00d8\u00de\u0132\u0152\u0186\u01c4\u01c5\u01c7\u01c8\u01ca\u01cb\u01F1\u01f2";
444
445 const otherlower = "\u00e6\u00f0\u00f8\u00fe\u00df\u0133\u0153\u01c6\u01c9\u01cc\u01f3";