Podświetlanie składni w edytorze XML dzięki editArea. Closes #17. Niestety dla tekstó...
[redakcja.git] / project / static / js / plugins / charmap / jscripts / map.js
1 var editArea;\r
2 \r
3 \r
4 /**\r
5  *  UTF-8 list taken from http://www.utf8-chartable.de/unicode-utf8-table.pl?utf8=dec \r
6  */  \r
7  \r
8 \r
9 /*\r
10 var char_range_list={\r
11 "Basic Latin":"0021,007F",\r
12 "Latin-1 Supplement":"0080,00FF",\r
13 "Latin Extended-A":"0100,017F",\r
14 "Latin Extended-B":"0180,024F",\r
15 "IPA Extensions":"0250,02AF",\r
16 "Spacing Modifier Letters":"02B0,02FF",\r
17 \r
18 "Combining Diacritical Marks":"0300,036F",\r
19 "Greek and Coptic":"0370,03FF",\r
20 "Cyrillic":"0400,04FF",\r
21 "Cyrillic Supplement":"0500,052F",\r
22 "Armenian":"0530,058F",\r
23 "Hebrew":"0590,05FF",\r
24 "Arabic":"0600,06FF",\r
25 "Syriac":"0700,074F",\r
26 "Arabic Supplement":"0750,077F",\r
27 \r
28 "Thaana":"0780,07BF",\r
29 "Devanagari":"0900,097F",\r
30 "Bengali":"0980,09FF",\r
31 "Gurmukhi":"0A00,0A7F",\r
32 "Gujarati":"0A80,0AFF",\r
33 "Oriya":"0B00,0B7F",\r
34 "Tamil":"0B80,0BFF",\r
35 "Telugu":"0C00,0C7F",\r
36 "Kannada":"0C80,0CFF",\r
37 \r
38 "Malayalam":"0D00,0D7F",\r
39 "Sinhala":"0D80,0DFF",\r
40 "Thai":"0E00,0E7F",\r
41 "Lao":"0E80,0EFF",\r
42 "Tibetan":"0F00,0FFF",\r
43 "Myanmar":"1000,109F",\r
44 "Georgian":"10A0,10FF",\r
45 "Hangul Jamo":"1100,11FF",\r
46 "Ethiopic":"1200,137F",\r
47 \r
48 "Ethiopic Supplement":"1380,139F",\r
49 "Cherokee":"13A0,13FF",\r
50 "Unified Canadian Aboriginal Syllabics":"1400,167F",\r
51 "Ogham":"1680,169F",\r
52 "Runic":"16A0,16FF",\r
53 "Tagalog":"1700,171F",\r
54 "Hanunoo":"1720,173F",\r
55 "Buhid":"1740,175F",\r
56 "Tagbanwa":"1760,177F",\r
57 \r
58 "Khmer":"1780,17FF",\r
59 "Mongolian":"1800,18AF",\r
60 "Limbu":"1900,194F",\r
61 "Tai Le":"1950,197F",\r
62 "New Tai Lue":"1980,19DF",\r
63 "Khmer Symbols":"19E0,19FF",\r
64 "Buginese":"1A00,1A1F",\r
65 "Phonetic Extensions":"1D00,1D7F",\r
66 "Phonetic Extensions Supplement":"1D80,1DBF",\r
67 \r
68 "Combining Diacritical Marks Supplement":"1DC0,1DFF",\r
69 "Latin Extended Additional":"1E00,1EFF",\r
70 "Greek Extended":"1F00,1FFF",\r
71 "General Punctuation":"2000,206F",\r
72 "Superscripts and Subscripts":"2070,209F",\r
73 "Currency Symbols":"20A0,20CF",\r
74 "Combining Diacritical Marks for Symbols":"20D0,20FF",\r
75 "Letterlike Symbols":"2100,214F",\r
76 "Number Forms":"2150,218F",\r
77 \r
78 "Arrows":"2190,21FF",\r
79 "Mathematical Operators":"2200,22FF",\r
80 "Miscellaneous Technical":"2300,23FF",\r
81 "Control Pictures":"2400,243F",\r
82 "Optical Character Recognition":"2440,245F",\r
83 "Enclosed Alphanumerics":"2460,24FF",\r
84 "Box Drawing":"2500,257F",\r
85 "Block Elements":"2580,259F",\r
86 "Geometric Shapes":"25A0,25FF",\r
87 \r
88 "Miscellaneous Symbols":"2600,26FF",\r
89 "Dingbats":"2700,27BF",\r
90 "Miscellaneous Mathematical Symbols-A":"27C0,27EF",\r
91 "Supplemental Arrows-A":"27F0,27FF",\r
92 "Braille Patterns":"2800,28FF",\r
93 "Supplemental Arrows-B":"2900,297F",\r
94 "Miscellaneous Mathematical Symbols-B":"2980,29FF",\r
95 "Supplemental Mathematical Operators":"2A00,2AFF",\r
96 "Miscellaneous Symbols and Arrows":"2B00,2BFF",\r
97 \r
98 "Glagolitic":"2C00,2C5F",\r
99 "Coptic":"2C80,2CFF",\r
100 "Georgian Supplement":"2D00,2D2F",\r
101 "Tifinagh":"2D30,2D7F",\r
102 "Ethiopic Extended":"2D80,2DDF",\r
103 "Supplemental Punctuation":"2E00,2E7F",\r
104 "CJK Radicals Supplement":"2E80,2EFF",\r
105 "Kangxi Radicals":"2F00,2FDF",\r
106 "Ideographic Description Characters":"2FF0,2FFF",\r
107 \r
108 "CJK Symbols and Punctuation":"3000,303F",\r
109 "Hiragana":"3040,309F",\r
110 "Katakana":"30A0,30FF",\r
111 "Bopomofo":"3100,312F",\r
112 "Hangul Compatibility Jamo":"3130,318F",\r
113 "Kanbun":"3190,319F",\r
114 "Bopomofo Extended":"31A0,31BF",\r
115 "CJK Strokes":"31C0,31EF",\r
116 "Katakana Phonetic Extensions":"31F0,31FF",\r
117 \r
118 "Enclosed CJK Letters and Months":"3200,32FF",\r
119 "CJK Compatibility":"3300,33FF",\r
120 "CJK Unified Ideographs Extension A":"3400,4DBF",\r
121 "Yijing Hexagram Symbols":"4DC0,4DFF",\r
122 "CJK Unified Ideographs":"4E00,9FFF",\r
123 "Yi Syllables":"A000,A48F",\r
124 "Yi Radicals":"A490,A4CF",\r
125 "Modifier Tone Letters":"A700,A71F",\r
126 "Syloti Nagri":"A800,A82F",\r
127 \r
128 "Hangul Syllables":"AC00,D7AF",\r
129 "High Surrogates":"D800,DB7F",\r
130 "High Private Use Surrogates":"DB80,DBFF",\r
131 "Low Surrogates":"DC00,DFFF",\r
132 "Private Use Area":"E000,F8FF",\r
133 "CJK Compatibility Ideographs":"F900,FAFF",\r
134 "Alphabetic Presentation Forms":"FB00,FB4F",\r
135 "Arabic Presentation Forms-A":"FB50,FDFF",\r
136 "Variation Selectors":"FE00,FE0F",\r
137 \r
138 "Vertical Forms":"FE10,FE1F",\r
139 "Combining Half Marks":"FE20,FE2F",\r
140 "CJK Compatibility Forms":"FE30,FE4F",\r
141 "Small Form Variants":"FE50,FE6F",\r
142 "Arabic Presentation Forms-B":"FE70,FEFF",\r
143 "Halfwidth and Fullwidth Forms":"FF00,FFEF",\r
144 "Specials":"FFF0,FFFF",\r
145 "Linear B Syllabary":"10000,1007F",\r
146 "Linear B Ideograms":"10080,100FF",\r
147 \r
148 "Aegean Numbers":"10100,1013F",\r
149 "Ancient Greek Numbers":"10140,1018F",\r
150 "Old Italic":"10300,1032F",\r
151 "Gothic":"10330,1034F",\r
152 "Ugaritic":"10380,1039F",\r
153 "Old Persian":"103A0,103DF",\r
154 "Deseret":"10400,1044F",\r
155 "Shavian":"10450,1047F",\r
156 "Osmanya":"10480,104AF",\r
157 \r
158 "Cypriot Syllabary":"10800,1083F",\r
159 "Kharoshthi":"10A00,10A5F",\r
160 "Byzantine Musical Symbols":"1D000,1D0FF",\r
161 "Musical Symbols":"1D100,1D1FF",\r
162 "Ancient Greek Musical Notation":"1D200,1D24F",\r
163 "Tai Xuan Jing Symbols":"1D300,1D35F",\r
164 "Mathematical Alphanumeric Symbols":"1D400,1D7FF",\r
165 "CJK Unified Ideographs Extension B":"20000,2A6DF",\r
166 "CJK Compatibility Ideographs Supplement":"2F800,2FA1F",\r
167 "Tags":"E0000,E007F",\r
168 "Variation Selectors Supplement":"E0100,E01EF"\r
169 };\r
170 */\r
171 var char_range_list={\r
172 "Aegean Numbers":"10100,1013F",\r
173 "Alphabetic Presentation Forms":"FB00,FB4F",\r
174 "Ancient Greek Musical Notation":"1D200,1D24F",\r
175 "Ancient Greek Numbers":"10140,1018F",\r
176 "Arabic":"0600,06FF",\r
177 "Arabic Presentation Forms-A":"FB50,FDFF",\r
178 "Arabic Presentation Forms-B":"FE70,FEFF",\r
179 "Arabic Supplement":"0750,077F",\r
180 "Armenian":"0530,058F",\r
181 "Arrows":"2190,21FF",\r
182 "Basic Latin":"0020,007F",\r
183 "Bengali":"0980,09FF",\r
184 "Block Elements":"2580,259F",\r
185 "Bopomofo Extended":"31A0,31BF",\r
186 "Bopomofo":"3100,312F",\r
187 "Box Drawing":"2500,257F",\r
188 "Braille Patterns":"2800,28FF",\r
189 "Buginese":"1A00,1A1F",\r
190 "Buhid":"1740,175F",\r
191 "Byzantine Musical Symbols":"1D000,1D0FF",\r
192 "CJK Compatibility Forms":"FE30,FE4F",\r
193 "CJK Compatibility Ideographs Supplement":"2F800,2FA1F",\r
194 "CJK Compatibility Ideographs":"F900,FAFF",\r
195 "CJK Compatibility":"3300,33FF",\r
196 "CJK Radicals Supplement":"2E80,2EFF",\r
197 "CJK Strokes":"31C0,31EF",\r
198 "CJK Symbols and Punctuation":"3000,303F",\r
199 "CJK Unified Ideographs Extension A":"3400,4DBF",\r
200 "CJK Unified Ideographs Extension B":"20000,2A6DF",\r
201 "CJK Unified Ideographs":"4E00,9FFF",\r
202 "Cherokee":"13A0,13FF",\r
203 "Combining Diacritical Marks Supplement":"1DC0,1DFF",\r
204 "Combining Diacritical Marks for Symbols":"20D0,20FF",\r
205 "Combining Diacritical Marks":"0300,036F",\r
206 "Combining Half Marks":"FE20,FE2F",\r
207 "Control Pictures":"2400,243F",\r
208 "Coptic":"2C80,2CFF",\r
209 "Currency Symbols":"20A0,20CF",\r
210 "Cypriot Syllabary":"10800,1083F",\r
211 "Cyrillic Supplement":"0500,052F",\r
212 "Cyrillic":"0400,04FF",\r
213 "Deseret":"10400,1044F",\r
214 "Devanagari":"0900,097F",\r
215 "Dingbats":"2700,27BF",\r
216 "Enclosed Alphanumerics":"2460,24FF",\r
217 "Enclosed CJK Letters and Months":"3200,32FF",\r
218 "Ethiopic Extended":"2D80,2DDF",\r
219 "Ethiopic Supplement":"1380,139F",\r
220 "Ethiopic":"1200,137F",\r
221 "General Punctuation":"2000,206F",\r
222 "Geometric Shapes":"25A0,25FF",\r
223 "Georgian Supplement":"2D00,2D2F",\r
224 "Georgian":"10A0,10FF",\r
225 "Glagolitic":"2C00,2C5F",\r
226 "Gothic":"10330,1034F",\r
227 "Greek Extended":"1F00,1FFF",\r
228 "Greek and Coptic":"0370,03FF",\r
229 "Gujarati":"0A80,0AFF",\r
230 "Gurmukhi":"0A00,0A7F",\r
231 "Halfwidth and Fullwidth Forms":"FF00,FFEF",\r
232 "Hangul Compatibility Jamo":"3130,318F",\r
233 "Hangul Jamo":"1100,11FF",\r
234 "Hangul Syllables":"AC00,D7AF",\r
235 "Hanunoo":"1720,173F",\r
236 "Hebrew":"0590,05FF",\r
237 "High Private Use Surrogates":"DB80,DBFF",\r
238 "High Surrogates":"D800,DB7F",\r
239 "Hiragana":"3040,309F",\r
240 "IPA Extensions":"0250,02AF",\r
241 "Ideographic Description Characters":"2FF0,2FFF",\r
242 "Kanbun":"3190,319F",\r
243 "Kangxi Radicals":"2F00,2FDF",\r
244 "Kannada":"0C80,0CFF",\r
245 "Katakana Phonetic Extensions":"31F0,31FF",\r
246 "Katakana":"30A0,30FF",\r
247 "Kharoshthi":"10A00,10A5F",\r
248 "Khmer Symbols":"19E0,19FF",\r
249 "Khmer":"1780,17FF",\r
250 "Lao":"0E80,0EFF",\r
251 "Latin Extended Additional":"1E00,1EFF",\r
252 "Latin Extended-A":"0100,017F",\r
253 "Latin Extended-B":"0180,024F",\r
254 "Latin-1 Supplement":"0080,00FF",\r
255 "Letterlike Symbols":"2100,214F",\r
256 "Limbu":"1900,194F",\r
257 "Linear B Ideograms":"10080,100FF",\r
258 "Linear B Syllabary":"10000,1007F",\r
259 "Low Surrogates":"DC00,DFFF",\r
260 "Malayalam":"0D00,0D7F",\r
261 "Mathematical Alphanumeric Symbols":"1D400,1D7FF",\r
262 "Mathematical Operators":"2200,22FF",\r
263 "Miscellaneous Mathematical Symbols-A":"27C0,27EF",\r
264 "Miscellaneous Mathematical Symbols-B":"2980,29FF",\r
265 "Miscellaneous Symbols and Arrows":"2B00,2BFF",\r
266 "Miscellaneous Symbols":"2600,26FF",\r
267 "Miscellaneous Technical":"2300,23FF",\r
268 "Modifier Tone Letters":"A700,A71F",\r
269 "Mongolian":"1800,18AF",\r
270 "Musical Symbols":"1D100,1D1FF",\r
271 "Myanmar":"1000,109F",\r
272 "New Tai Lue":"1980,19DF",\r
273 "Number Forms":"2150,218F",\r
274 "Ogham":"1680,169F",\r
275 "Old Italic":"10300,1032F",\r
276 "Old Persian":"103A0,103DF",\r
277 "Optical Character Recognition":"2440,245F",\r
278 "Oriya":"0B00,0B7F",\r
279 "Osmanya":"10480,104AF",\r
280 "Phonetic Extensions Supplement":"1D80,1DBF",\r
281 "Phonetic Extensions":"1D00,1D7F",\r
282 "Private Use Area":"E000,F8FF",\r
283 "Runic":"16A0,16FF",\r
284 "Shavian":"10450,1047F",\r
285 "Sinhala":"0D80,0DFF",\r
286 "Small Form Variants":"FE50,FE6F",\r
287 "Spacing Modifier Letters":"02B0,02FF",\r
288 "Specials":"FFF0,FFFF",\r
289 "Superscripts and Subscripts":"2070,209F",\r
290 "Supplemental Arrows-A":"27F0,27FF",\r
291 "Supplemental Arrows-B":"2900,297F",\r
292 "Supplemental Mathematical Operators":"2A00,2AFF",\r
293 "Supplemental Punctuation":"2E00,2E7F",\r
294 "Syloti Nagri":"A800,A82F",\r
295 "Syriac":"0700,074F",\r
296 "Tagalog":"1700,171F",\r
297 "Tagbanwa":"1760,177F",\r
298 "Tags":"E0000,E007F",\r
299 "Tai Le":"1950,197F",\r
300 "Tai Xuan Jing Symbols":"1D300,1D35F",\r
301 "Tamil":"0B80,0BFF",\r
302 "Telugu":"0C00,0C7F",\r
303 "Thaana":"0780,07BF",\r
304 "Thai":"0E00,0E7F",\r
305 "Tibetan":"0F00,0FFF",\r
306 "Tifinagh":"2D30,2D7F",\r
307 "Ugaritic":"10380,1039F",\r
308 "Unified Canadian Aboriginal Syllabics":"1400,167F",\r
309 "Variation Selectors Supplement":"E0100,E01EF",\r
310 "Variation Selectors":"FE00,FE0F",\r
311 "Vertical Forms":"FE10,FE1F",\r
312 "Yi Radicals":"A490,A4CF",\r
313 "Yi Syllables":"A000,A48F",\r
314 "Yijing Hexagram Symbols":"4DC0,4DFF"\r
315 };\r
316 \r
317 var insert="charmap_insert";\r
318 \r
319 function map_load(){\r
320         editArea=opener.editArea;\r
321         // translate the document\r
322         insert= editArea.get_translation(insert, "word");\r
323         //alert(document.title);\r
324         document.title= editArea.get_translation(document.title, "template");\r
325         document.body.innerHTML= editArea.get_translation(document.body.innerHTML, "template");\r
326         //document.title= editArea.get_translation(document.getElementBytitle, "template");\r
327         \r
328         var selected_lang=opener.EditArea_charmap.default_language.toLowerCase();\r
329         var selected=0;\r
330         \r
331         var select= document.getElementById("select_range")\r
332         for(var i in char_range_list){\r
333                 if(i.toLowerCase()==selected_lang)\r
334                         selected=select.options.length;\r
335                 select.options[select.options.length]=new Option(i, char_range_list[i]);\r
336         }\r
337         select.options[selected].selected=true;\r
338 /*      start=0;\r
339         end=127;\r
340         content="";\r
341         for(var i=start; i<end; i++){\r
342                 content+="&#"+i+"; ";\r
343         }\r
344         document.getElementById("char_list").innerHTML=content;*/\r
345         renderCharMapHTML();\r
346 }\r
347 \r
348 \r
349 function renderCharMapHTML() {\r
350         range= document.getElementById("select_range").value.split(",");\r
351 \r
352         start= parseInt(range[0],16);\r
353         end= parseInt(range[1],16);\r
354         var charsPerRow = 20, tdWidth=20, tdHeight=20;\r
355         html="";\r
356         for (var i=start; i<end; i++) {\r
357                 html+="<a class='char' onmouseover='previewChar(\""+ i + "\");' onclick='insertChar(\""+ i + "\");' title='"+ insert +"'>"+ String.fromCharCode(i) +"</a>";\r
358         }\r
359         document.getElementById("char_list").innerHTML= html;\r
360         document.getElementById("preview_char").innerHTML="";\r
361 }\r
362 \r
363 function previewChar(i){\r
364         document.getElementById("preview_char").innerHTML= String.fromCharCode(i);\r
365         document.getElementById("preview_code").innerHTML= "&amp;#"+ i +";";\r
366 }\r
367 \r
368 function insertChar(i){\r
369         opener.parent.editAreaLoader.setSelectedText(editArea.id, String.fromCharCode( i));\r
370         range= opener.parent.editAreaLoader.getSelectionRange(editArea.id);\r
371         opener.parent.editAreaLoader.setSelectionRange(editArea.id, range["end"], range["end"]);\r
372         window.focus();\r
373 }\r