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
diff --git a/project/static/js/plugins/charmap/jscripts/map.js b/project/static/js/plugins/charmap/jscripts/map.js
new file mode 100755 (executable)
index 0000000..6c194a4
--- /dev/null
@@ -0,0 +1,373 @@
+var editArea;\r
+\r
+\r
+/**\r
+ *  UTF-8 list taken from http://www.utf8-chartable.de/unicode-utf8-table.pl?utf8=dec \r
+ */  \r
\r
+\r
+/*\r
+var char_range_list={\r
+"Basic Latin":"0021,007F",\r
+"Latin-1 Supplement":"0080,00FF",\r
+"Latin Extended-A":"0100,017F",\r
+"Latin Extended-B":"0180,024F",\r
+"IPA Extensions":"0250,02AF",\r
+"Spacing Modifier Letters":"02B0,02FF",\r
+\r
+"Combining Diacritical Marks":"0300,036F",\r
+"Greek and Coptic":"0370,03FF",\r
+"Cyrillic":"0400,04FF",\r
+"Cyrillic Supplement":"0500,052F",\r
+"Armenian":"0530,058F",\r
+"Hebrew":"0590,05FF",\r
+"Arabic":"0600,06FF",\r
+"Syriac":"0700,074F",\r
+"Arabic Supplement":"0750,077F",\r
+\r
+"Thaana":"0780,07BF",\r
+"Devanagari":"0900,097F",\r
+"Bengali":"0980,09FF",\r
+"Gurmukhi":"0A00,0A7F",\r
+"Gujarati":"0A80,0AFF",\r
+"Oriya":"0B00,0B7F",\r
+"Tamil":"0B80,0BFF",\r
+"Telugu":"0C00,0C7F",\r
+"Kannada":"0C80,0CFF",\r
+\r
+"Malayalam":"0D00,0D7F",\r
+"Sinhala":"0D80,0DFF",\r
+"Thai":"0E00,0E7F",\r
+"Lao":"0E80,0EFF",\r
+"Tibetan":"0F00,0FFF",\r
+"Myanmar":"1000,109F",\r
+"Georgian":"10A0,10FF",\r
+"Hangul Jamo":"1100,11FF",\r
+"Ethiopic":"1200,137F",\r
+\r
+"Ethiopic Supplement":"1380,139F",\r
+"Cherokee":"13A0,13FF",\r
+"Unified Canadian Aboriginal Syllabics":"1400,167F",\r
+"Ogham":"1680,169F",\r
+"Runic":"16A0,16FF",\r
+"Tagalog":"1700,171F",\r
+"Hanunoo":"1720,173F",\r
+"Buhid":"1740,175F",\r
+"Tagbanwa":"1760,177F",\r
+\r
+"Khmer":"1780,17FF",\r
+"Mongolian":"1800,18AF",\r
+"Limbu":"1900,194F",\r
+"Tai Le":"1950,197F",\r
+"New Tai Lue":"1980,19DF",\r
+"Khmer Symbols":"19E0,19FF",\r
+"Buginese":"1A00,1A1F",\r
+"Phonetic Extensions":"1D00,1D7F",\r
+"Phonetic Extensions Supplement":"1D80,1DBF",\r
+\r
+"Combining Diacritical Marks Supplement":"1DC0,1DFF",\r
+"Latin Extended Additional":"1E00,1EFF",\r
+"Greek Extended":"1F00,1FFF",\r
+"General Punctuation":"2000,206F",\r
+"Superscripts and Subscripts":"2070,209F",\r
+"Currency Symbols":"20A0,20CF",\r
+"Combining Diacritical Marks for Symbols":"20D0,20FF",\r
+"Letterlike Symbols":"2100,214F",\r
+"Number Forms":"2150,218F",\r
+\r
+"Arrows":"2190,21FF",\r
+"Mathematical Operators":"2200,22FF",\r
+"Miscellaneous Technical":"2300,23FF",\r
+"Control Pictures":"2400,243F",\r
+"Optical Character Recognition":"2440,245F",\r
+"Enclosed Alphanumerics":"2460,24FF",\r
+"Box Drawing":"2500,257F",\r
+"Block Elements":"2580,259F",\r
+"Geometric Shapes":"25A0,25FF",\r
+\r
+"Miscellaneous Symbols":"2600,26FF",\r
+"Dingbats":"2700,27BF",\r
+"Miscellaneous Mathematical Symbols-A":"27C0,27EF",\r
+"Supplemental Arrows-A":"27F0,27FF",\r
+"Braille Patterns":"2800,28FF",\r
+"Supplemental Arrows-B":"2900,297F",\r
+"Miscellaneous Mathematical Symbols-B":"2980,29FF",\r
+"Supplemental Mathematical Operators":"2A00,2AFF",\r
+"Miscellaneous Symbols and Arrows":"2B00,2BFF",\r
+\r
+"Glagolitic":"2C00,2C5F",\r
+"Coptic":"2C80,2CFF",\r
+"Georgian Supplement":"2D00,2D2F",\r
+"Tifinagh":"2D30,2D7F",\r
+"Ethiopic Extended":"2D80,2DDF",\r
+"Supplemental Punctuation":"2E00,2E7F",\r
+"CJK Radicals Supplement":"2E80,2EFF",\r
+"Kangxi Radicals":"2F00,2FDF",\r
+"Ideographic Description Characters":"2FF0,2FFF",\r
+\r
+"CJK Symbols and Punctuation":"3000,303F",\r
+"Hiragana":"3040,309F",\r
+"Katakana":"30A0,30FF",\r
+"Bopomofo":"3100,312F",\r
+"Hangul Compatibility Jamo":"3130,318F",\r
+"Kanbun":"3190,319F",\r
+"Bopomofo Extended":"31A0,31BF",\r
+"CJK Strokes":"31C0,31EF",\r
+"Katakana Phonetic Extensions":"31F0,31FF",\r
+\r
+"Enclosed CJK Letters and Months":"3200,32FF",\r
+"CJK Compatibility":"3300,33FF",\r
+"CJK Unified Ideographs Extension A":"3400,4DBF",\r
+"Yijing Hexagram Symbols":"4DC0,4DFF",\r
+"CJK Unified Ideographs":"4E00,9FFF",\r
+"Yi Syllables":"A000,A48F",\r
+"Yi Radicals":"A490,A4CF",\r
+"Modifier Tone Letters":"A700,A71F",\r
+"Syloti Nagri":"A800,A82F",\r
+\r
+"Hangul Syllables":"AC00,D7AF",\r
+"High Surrogates":"D800,DB7F",\r
+"High Private Use Surrogates":"DB80,DBFF",\r
+"Low Surrogates":"DC00,DFFF",\r
+"Private Use Area":"E000,F8FF",\r
+"CJK Compatibility Ideographs":"F900,FAFF",\r
+"Alphabetic Presentation Forms":"FB00,FB4F",\r
+"Arabic Presentation Forms-A":"FB50,FDFF",\r
+"Variation Selectors":"FE00,FE0F",\r
+\r
+"Vertical Forms":"FE10,FE1F",\r
+"Combining Half Marks":"FE20,FE2F",\r
+"CJK Compatibility Forms":"FE30,FE4F",\r
+"Small Form Variants":"FE50,FE6F",\r
+"Arabic Presentation Forms-B":"FE70,FEFF",\r
+"Halfwidth and Fullwidth Forms":"FF00,FFEF",\r
+"Specials":"FFF0,FFFF",\r
+"Linear B Syllabary":"10000,1007F",\r
+"Linear B Ideograms":"10080,100FF",\r
+\r
+"Aegean Numbers":"10100,1013F",\r
+"Ancient Greek Numbers":"10140,1018F",\r
+"Old Italic":"10300,1032F",\r
+"Gothic":"10330,1034F",\r
+"Ugaritic":"10380,1039F",\r
+"Old Persian":"103A0,103DF",\r
+"Deseret":"10400,1044F",\r
+"Shavian":"10450,1047F",\r
+"Osmanya":"10480,104AF",\r
+\r
+"Cypriot Syllabary":"10800,1083F",\r
+"Kharoshthi":"10A00,10A5F",\r
+"Byzantine Musical Symbols":"1D000,1D0FF",\r
+"Musical Symbols":"1D100,1D1FF",\r
+"Ancient Greek Musical Notation":"1D200,1D24F",\r
+"Tai Xuan Jing Symbols":"1D300,1D35F",\r
+"Mathematical Alphanumeric Symbols":"1D400,1D7FF",\r
+"CJK Unified Ideographs Extension B":"20000,2A6DF",\r
+"CJK Compatibility Ideographs Supplement":"2F800,2FA1F",\r
+"Tags":"E0000,E007F",\r
+"Variation Selectors Supplement":"E0100,E01EF"\r
+};\r
+*/\r
+var char_range_list={\r
+"Aegean Numbers":"10100,1013F",\r
+"Alphabetic Presentation Forms":"FB00,FB4F",\r
+"Ancient Greek Musical Notation":"1D200,1D24F",\r
+"Ancient Greek Numbers":"10140,1018F",\r
+"Arabic":"0600,06FF",\r
+"Arabic Presentation Forms-A":"FB50,FDFF",\r
+"Arabic Presentation Forms-B":"FE70,FEFF",\r
+"Arabic Supplement":"0750,077F",\r
+"Armenian":"0530,058F",\r
+"Arrows":"2190,21FF",\r
+"Basic Latin":"0020,007F",\r
+"Bengali":"0980,09FF",\r
+"Block Elements":"2580,259F",\r
+"Bopomofo Extended":"31A0,31BF",\r
+"Bopomofo":"3100,312F",\r
+"Box Drawing":"2500,257F",\r
+"Braille Patterns":"2800,28FF",\r
+"Buginese":"1A00,1A1F",\r
+"Buhid":"1740,175F",\r
+"Byzantine Musical Symbols":"1D000,1D0FF",\r
+"CJK Compatibility Forms":"FE30,FE4F",\r
+"CJK Compatibility Ideographs Supplement":"2F800,2FA1F",\r
+"CJK Compatibility Ideographs":"F900,FAFF",\r
+"CJK Compatibility":"3300,33FF",\r
+"CJK Radicals Supplement":"2E80,2EFF",\r
+"CJK Strokes":"31C0,31EF",\r
+"CJK Symbols and Punctuation":"3000,303F",\r
+"CJK Unified Ideographs Extension A":"3400,4DBF",\r
+"CJK Unified Ideographs Extension B":"20000,2A6DF",\r
+"CJK Unified Ideographs":"4E00,9FFF",\r
+"Cherokee":"13A0,13FF",\r
+"Combining Diacritical Marks Supplement":"1DC0,1DFF",\r
+"Combining Diacritical Marks for Symbols":"20D0,20FF",\r
+"Combining Diacritical Marks":"0300,036F",\r
+"Combining Half Marks":"FE20,FE2F",\r
+"Control Pictures":"2400,243F",\r
+"Coptic":"2C80,2CFF",\r
+"Currency Symbols":"20A0,20CF",\r
+"Cypriot Syllabary":"10800,1083F",\r
+"Cyrillic Supplement":"0500,052F",\r
+"Cyrillic":"0400,04FF",\r
+"Deseret":"10400,1044F",\r
+"Devanagari":"0900,097F",\r
+"Dingbats":"2700,27BF",\r
+"Enclosed Alphanumerics":"2460,24FF",\r
+"Enclosed CJK Letters and Months":"3200,32FF",\r
+"Ethiopic Extended":"2D80,2DDF",\r
+"Ethiopic Supplement":"1380,139F",\r
+"Ethiopic":"1200,137F",\r
+"General Punctuation":"2000,206F",\r
+"Geometric Shapes":"25A0,25FF",\r
+"Georgian Supplement":"2D00,2D2F",\r
+"Georgian":"10A0,10FF",\r
+"Glagolitic":"2C00,2C5F",\r
+"Gothic":"10330,1034F",\r
+"Greek Extended":"1F00,1FFF",\r
+"Greek and Coptic":"0370,03FF",\r
+"Gujarati":"0A80,0AFF",\r
+"Gurmukhi":"0A00,0A7F",\r
+"Halfwidth and Fullwidth Forms":"FF00,FFEF",\r
+"Hangul Compatibility Jamo":"3130,318F",\r
+"Hangul Jamo":"1100,11FF",\r
+"Hangul Syllables":"AC00,D7AF",\r
+"Hanunoo":"1720,173F",\r
+"Hebrew":"0590,05FF",\r
+"High Private Use Surrogates":"DB80,DBFF",\r
+"High Surrogates":"D800,DB7F",\r
+"Hiragana":"3040,309F",\r
+"IPA Extensions":"0250,02AF",\r
+"Ideographic Description Characters":"2FF0,2FFF",\r
+"Kanbun":"3190,319F",\r
+"Kangxi Radicals":"2F00,2FDF",\r
+"Kannada":"0C80,0CFF",\r
+"Katakana Phonetic Extensions":"31F0,31FF",\r
+"Katakana":"30A0,30FF",\r
+"Kharoshthi":"10A00,10A5F",\r
+"Khmer Symbols":"19E0,19FF",\r
+"Khmer":"1780,17FF",\r
+"Lao":"0E80,0EFF",\r
+"Latin Extended Additional":"1E00,1EFF",\r
+"Latin Extended-A":"0100,017F",\r
+"Latin Extended-B":"0180,024F",\r
+"Latin-1 Supplement":"0080,00FF",\r
+"Letterlike Symbols":"2100,214F",\r
+"Limbu":"1900,194F",\r
+"Linear B Ideograms":"10080,100FF",\r
+"Linear B Syllabary":"10000,1007F",\r
+"Low Surrogates":"DC00,DFFF",\r
+"Malayalam":"0D00,0D7F",\r
+"Mathematical Alphanumeric Symbols":"1D400,1D7FF",\r
+"Mathematical Operators":"2200,22FF",\r
+"Miscellaneous Mathematical Symbols-A":"27C0,27EF",\r
+"Miscellaneous Mathematical Symbols-B":"2980,29FF",\r
+"Miscellaneous Symbols and Arrows":"2B00,2BFF",\r
+"Miscellaneous Symbols":"2600,26FF",\r
+"Miscellaneous Technical":"2300,23FF",\r
+"Modifier Tone Letters":"A700,A71F",\r
+"Mongolian":"1800,18AF",\r
+"Musical Symbols":"1D100,1D1FF",\r
+"Myanmar":"1000,109F",\r
+"New Tai Lue":"1980,19DF",\r
+"Number Forms":"2150,218F",\r
+"Ogham":"1680,169F",\r
+"Old Italic":"10300,1032F",\r
+"Old Persian":"103A0,103DF",\r
+"Optical Character Recognition":"2440,245F",\r
+"Oriya":"0B00,0B7F",\r
+"Osmanya":"10480,104AF",\r
+"Phonetic Extensions Supplement":"1D80,1DBF",\r
+"Phonetic Extensions":"1D00,1D7F",\r
+"Private Use Area":"E000,F8FF",\r
+"Runic":"16A0,16FF",\r
+"Shavian":"10450,1047F",\r
+"Sinhala":"0D80,0DFF",\r
+"Small Form Variants":"FE50,FE6F",\r
+"Spacing Modifier Letters":"02B0,02FF",\r
+"Specials":"FFF0,FFFF",\r
+"Superscripts and Subscripts":"2070,209F",\r
+"Supplemental Arrows-A":"27F0,27FF",\r
+"Supplemental Arrows-B":"2900,297F",\r
+"Supplemental Mathematical Operators":"2A00,2AFF",\r
+"Supplemental Punctuation":"2E00,2E7F",\r
+"Syloti Nagri":"A800,A82F",\r
+"Syriac":"0700,074F",\r
+"Tagalog":"1700,171F",\r
+"Tagbanwa":"1760,177F",\r
+"Tags":"E0000,E007F",\r
+"Tai Le":"1950,197F",\r
+"Tai Xuan Jing Symbols":"1D300,1D35F",\r
+"Tamil":"0B80,0BFF",\r
+"Telugu":"0C00,0C7F",\r
+"Thaana":"0780,07BF",\r
+"Thai":"0E00,0E7F",\r
+"Tibetan":"0F00,0FFF",\r
+"Tifinagh":"2D30,2D7F",\r
+"Ugaritic":"10380,1039F",\r
+"Unified Canadian Aboriginal Syllabics":"1400,167F",\r
+"Variation Selectors Supplement":"E0100,E01EF",\r
+"Variation Selectors":"FE00,FE0F",\r
+"Vertical Forms":"FE10,FE1F",\r
+"Yi Radicals":"A490,A4CF",\r
+"Yi Syllables":"A000,A48F",\r
+"Yijing Hexagram Symbols":"4DC0,4DFF"\r
+};\r
+\r
+var insert="charmap_insert";\r
+\r
+function map_load(){\r
+       editArea=opener.editArea;\r
+       // translate the document\r
+       insert= editArea.get_translation(insert, "word");\r
+       //alert(document.title);\r
+       document.title= editArea.get_translation(document.title, "template");\r
+       document.body.innerHTML= editArea.get_translation(document.body.innerHTML, "template");\r
+       //document.title= editArea.get_translation(document.getElementBytitle, "template");\r
+       \r
+       var selected_lang=opener.EditArea_charmap.default_language.toLowerCase();\r
+       var selected=0;\r
+       \r
+       var select= document.getElementById("select_range")\r
+       for(var i in char_range_list){\r
+               if(i.toLowerCase()==selected_lang)\r
+                       selected=select.options.length;\r
+               select.options[select.options.length]=new Option(i, char_range_list[i]);\r
+       }\r
+       select.options[selected].selected=true;\r
+/*     start=0;\r
+       end=127;\r
+       content="";\r
+       for(var i=start; i<end; i++){\r
+               content+="&#"+i+"; ";\r
+       }\r
+       document.getElementById("char_list").innerHTML=content;*/\r
+       renderCharMapHTML();\r
+}\r
+\r
+\r
+function renderCharMapHTML() {\r
+       range= document.getElementById("select_range").value.split(",");\r
+\r
+       start= parseInt(range[0],16);\r
+       end= parseInt(range[1],16);\r
+       var charsPerRow = 20, tdWidth=20, tdHeight=20;\r
+       html="";\r
+       for (var i=start; i<end; i++) {\r
+               html+="<a class='char' onmouseover='previewChar(\""+ i + "\");' onclick='insertChar(\""+ i + "\");' title='"+ insert +"'>"+ String.fromCharCode(i) +"</a>";\r
+       }\r
+       document.getElementById("char_list").innerHTML= html;\r
+       document.getElementById("preview_char").innerHTML="";\r
+}\r
+\r
+function previewChar(i){\r
+       document.getElementById("preview_char").innerHTML= String.fromCharCode(i);\r
+       document.getElementById("preview_code").innerHTML= "&amp;#"+ i +";";\r
+}\r
+\r
+function insertChar(i){\r
+       opener.parent.editAreaLoader.setSelectedText(editArea.id, String.fromCharCode( i));\r
+       range= opener.parent.editAreaLoader.getSelectionRange(editArea.id);\r
+       opener.parent.editAreaLoader.setSelectionRange(editArea.id, range["end"], range["end"]);\r
+       window.focus();\r
+}\r