widget.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. (function( $ ){
  2. var la2li = {
  3. "1":{"~":"𐄇","0":{"~":"𐄐","0":{"~":"𐄙","0":{"~":"𐄢","0":"𐄫"}}}},
  4. "2":{"~":"𐄈","0":{"~":"𐄑","0":{"~":"𐄚","0":{"~":"𐄣","0":"𐄬"}}}},
  5. "3":{"~":"𐄉","0":{"~":"𐄒","0":{"~":"𐄛","0":{"~":"𐄤","0":"𐄭"}}}},
  6. "4":{"~":"𐄊","0":{"~":"𐄓","0":{"~":"𐄜","0":{"~":"𐄥","0":"𐄮"}}}},
  7. "5":{"~":"𐄋","0":{"~":"𐄔","0":{"~":"𐄝","0":{"~":"𐄦","0":"𐄯"}}}},
  8. "6":{"~":"𐄌","0":{"~":"𐄕","0":{"~":"𐄞","0":{"~":"𐄧","0":"𐄰"}}}},
  9. "7":{"~":"𐄍","0":{"~":"𐄖","0":{"~":"𐄟","0":{"~":"𐄨","0":"𐄱"}}}},
  10. "8":{"~":"𐄎","0":{"~":"𐄗","0":{"~":"𐄠","0":{"~":"𐄩","0":"𐄲"}}}},
  11. "9":{"~":"𐄏","0":{"~":"𐄘","0":{"~":"𐄡","0":{"~":"𐄪","0":"𐄳"}}}},
  12. "a": { "~": "𐀀", "i": "𐁁", "lv": "𐃅","mph": "𐃨","rom": "𐂑","u": "𐁂" },
  13. "b": { "i": {"g": "𐃌",},"o": {"s": {"~": "𐀘","f": "𐂌","m": "𐂍"}}},
  14. "c": {"a": {"p": {"~": "𐁒","f": "𐂈","m": "𐂉","s": "𐃎"}},"e": {"l": "𐀯","n": { "t": "𐄙"} ,"r": {"v": "𐂂" }},"u": {"m": {"i": {"n": "𐀓"}},"r": "𐃍"},"y": {"p": "𐂒"}},
  15. "d": {"a": {"~": "𐀅","g": "𐃉",},"e": {"~": "𐀆","c": "𐄐","m": {"i": {"l": "𐄫",}}},"i": "𐀇","m": {"i": {"l": "𐄣",}},"o": "𐀈","u": {"~": "𐀉","c": "𐄚","m": {"i": {"l": "𐄬"}},"o": "𐄈"},"w": {"e": "𐁃","o": "𐁄" }},
  16. "e": "𐀁",
  17. "h": {"a":"𐁀"},
  18. "i": "𐀂",
  19. "j": {"a": "𐀊","e": "𐀋","o": "𐀍"},
  20. "k": {"a": "𐀏","e": "𐀐","i": "𐀑","o": "𐀒","u": "𐀓"},
  21. "m": {"a": "𐀔","e": "𐀕","i": "𐀖","o": "𐀗","u": "𐀘"},
  22. "n": {"a": "𐀙","e": "𐀚","i": "𐀛","o": "𐀜","u": "𐀝","w": {"a":"𐁅"}},
  23. "o": "𐀃",
  24. "p": {"a": "𐀞","e": "𐀟","h": {"u":"𐁆"},"i": "𐀠","o": "𐀡","t": {"e":"𐁇"},"u": "𐀢"},
  25. "q": {"a": "𐀣","e": "𐀤","i": "𐀥","o": "𐀦"},
  26. "r": {"a": {"~" : "𐀨","i" : "𐁉"},"e": "𐀩","i": "𐀪","o": "𐀫","u": "𐀬","y": {"a" : "𐁈","o": "𐁊"}},
  27. "s": {"a": "𐀭","e": "𐀮","i": "𐀯","o": "𐀰","u": "𐀱"},
  28. "t": {"a": "𐀲","e": "𐀳","i": "𐀴","o": "𐀵","u": "𐀶","w": {"e" : "𐁌", "o" : "𐁍"},"y": {"a": "𐁋"}},
  29. "u": "𐀄",
  30. "w": {"a": "𐀷","e": "𐀸","i": "𐀹","o": "𐀺"},
  31. "z": {"a": "𐀼","e": "𐀽","o": "𐀿"}
  32. };
  33. var li2la = {
  34. "\ud800" :
  35. {"\udc00": "a",
  36. "\udc01": "e",
  37. "\udc02": "i",
  38. "\udc03": "o",
  39. "\udc04": "u",
  40. "\udc05": "da",
  41. "\udc06": "de",
  42. "\udc07": "di",
  43. "\udc08": "do",
  44. "\udc09": "du",
  45. "\udc0a": "ja",
  46. "\udc0b": "je",
  47. "\udc0d": "jo",
  48. "\udc0f": "ka",
  49. "\udc10": "ke",
  50. "\udc11": "ki",
  51. "\udc12": "ko",
  52. "\udc13": "ku",
  53. "\udc14": "ma",
  54. "\udc15": "me",
  55. "\udc16": "mi",
  56. "\udc17": "mo",
  57. "\udc18": "mu",
  58. "\udc19": "na",
  59. "\udc1a": "ne",
  60. "\udc1b": "ni",
  61. "\udc1c": "no",
  62. "\udc1d": "nu",
  63. "\udc1e": "pa",
  64. "\udc1f": "pe",
  65. "\udc20": "pi",
  66. "\udc21": "po",
  67. "\udc22": "pu",
  68. "\udc23": "qa",
  69. "\udc24": "qe",
  70. "\udc25": "qi",
  71. "\udc26": "qo",
  72. "\udc28": "ra",
  73. "\udc29": "re",
  74. "\udc2a": "ri",
  75. "\udc2b": "ro",
  76. "\udc2c": "ru",
  77. "\udc2d": "sa",
  78. "\udc2e": "se",
  79. "\udc2f": "si",
  80. "\udc30": "so",
  81. "\udc31": "su",
  82. "\udc32": "ta",
  83. "\udc33": "te",
  84. "\udc34": "ti",
  85. "\udc35": "to",
  86. "\udc36": "tu",
  87. "\udc37": "wa",
  88. "\udc38": "we",
  89. "\udc39": "wi",
  90. "\udc3a": "wo",
  91. "\udc3c": "za",
  92. "\udc3d": "ze",
  93. "\udc3f": "zo",
  94. "\udc40": "ha",
  95. "\udc41": "ai",
  96. "\udc42": "au",
  97. "\udc43": "dwe",
  98. "\udc44": "dwo",
  99. "\udc45": "nwa",
  100. "\udc46": "phu",
  101. "\udc47": "pte",
  102. "\udc48": "rya",
  103. "\udc49": "rai",
  104. "\udc4a": "ryo",
  105. "\udc4b": "tya",
  106. "\udc4c": "twe",
  107. "\udc4d": "two",
  108. "\udc52": "cap",
  109. "\udc80": "vir",
  110. "\udc81": "mul",
  111. "\udc82": "cerv",
  112. "\udc83": "equ",
  113. }
  114. };
  115. var la2cy = {
  116. "a": "𐠀",
  117. "b": {"a": "𐠞","e": "𐠟","i": "𐠠","o": "𐠡","u": "𐠢"},
  118. "d": {"a": "𐠭","e": "𐠮","i": "𐠯","o": "𐠰","u": "𐠱"},
  119. "e": "𐠁",
  120. "g": {"a": "𐠊","e": "𐠋","i": "𐠌","o": "𐠍","u": "𐠎"},
  121. "i": "𐠂",
  122. "j": {"a": "𐠅","o": "𐠈"},
  123. "k": {"a": "𐠊","e": "𐠋","i": "𐠌","o": "𐠍","u": "𐠎"},
  124. "kh": {"a": "𐠊","e": "𐠐","i": "𐠌","o": "𐠍","u": "𐠎"},
  125. "l": {"a": "𐠏","e": "𐀐","i": "𐠑","o": "𐠒","u": "𐠓"},
  126. "m": {"a": "𐠔","e": "𐠕","i": "𐠖","o": "𐠗","u": "𐠘"},
  127. "n": {"a": "𐠙","e": "𐠚","i": "𐠛","o": "𐠜","u": "𐠝"},
  128. "ks": {"a": "𐠷","e": "𐠸"},
  129. "o": "𐠃",
  130. "p": {"a": "𐠞","e": "𐠟","i": "𐠠","o": "𐠡","u": "𐠢"},
  131. "ph": {"a": "𐠞","e": "𐠟","i": "𐠠","o": "𐠡","u": "𐠢"},
  132. "r": {"a": "𐠣","e": "𐠤","i": "𐠥","o": "𐠦","u": "𐠧"},
  133. "s": {"a": "𐠨","e": "𐠩","i": "𐠪","o": "𐠫","u": "𐠬"},
  134. "t": {"a": "𐠭","e": "𐠮","i": "𐠯","o": "𐠰","u": "𐠱"},
  135. "th": {"a": "𐠭","e": "𐠮","i": "𐠯","o": "𐠰","u": "𐠱"},
  136. "u": "𐠄",
  137. "w": {"a": "𐠲","e": "𐠳","i": "𐠴","o": "𐠵"},
  138. "z": {"a": "𐠼","o": "𐠿"}
  139. };
  140. var cy2la = {
  141. "\ud802":
  142. {
  143. "\udc00": "a",
  144. "\udc01": "e",
  145. "\udc02": "i",
  146. "\udc03": "o",
  147. "\udc04": "u",
  148. "\udc32": "wa",
  149. "\udc33": "we",
  150. "\udc34": "wi",
  151. "\udc35": "wo",
  152. "\udc3C": "za",
  153. "\udc3F": "zo",
  154. "\udc05": "ja",
  155. "\udc08": "jo",
  156. "\udc0A": "ka",
  157. "\udc0B": "ke",
  158. "\udc0C": "ki",
  159. "\udc0D": "ko",
  160. "\udc0E": "ku",
  161. "\udc0F": "la",
  162. "\udc10": "le",
  163. "\udc11": "li",
  164. "\udc12": "lo",
  165. "\udc13": "lu",
  166. "\udc14": "ma",
  167. "\udc15": "me",
  168. "\udc16": "mi",
  169. "\udc17": "mo",
  170. "\udc18": "mu",
  171. "\udc19": "na",
  172. "\udc1A": "ne",
  173. "\udc1B": "ni",
  174. "\udc1C": "no",
  175. "\udc1D": "nu",
  176. "\udc37": "kse",
  177. "\udc38": "ksi",
  178. "\udc1E": "pa",
  179. "\udc1F": "pe",
  180. "\udc20": "pi",
  181. "\udc21": "po",
  182. "\udc22": "pu",
  183. "\udc23": "ra",
  184. "\udc24": "re",
  185. "\udc25": "ri",
  186. "\udc26": "ro",
  187. "\udc27": "ru",
  188. "\udc28": "sa",
  189. "\udc29": "se",
  190. "\udc2A": "si",
  191. "\udc2B": "so",
  192. "\udc2C": "su",
  193. "\udc2D": "ta",
  194. "\udc2E": "te",
  195. "\udc2F": "ti",
  196. "\udc30": "to",
  197. "\udc31": "tu",
  198. }
  199. };
  200. var converterMap = la2li;
  201. function doconvert(src) {
  202. function traverse(i, chars, ws) {
  203. var c = src[i];
  204. if (c in chars) {
  205. if (chars[c] instanceof Array)
  206. return (ws ? chars[c][1] : chars[c][0]) + traverse(i + 1, converterMap);
  207. else if (chars[c] instanceof Object)
  208. return traverse(i + 1, chars[c], ws);
  209. else
  210. return chars[c] + traverse(i + 1, converterMap);
  211. }
  212. else if ('~' in chars) {
  213. if (chars['~'] instanceof Array)
  214. return (ws ? chars['~'][1] : chars['~'][0]) + traverse(i, converterMap);
  215. else
  216. return chars['~'] + traverse(i, converterMap);
  217. }
  218. else if (c) {
  219. return c + traverse(i + 1, converterMap, c == ' ');
  220. }
  221. return "";
  222. }
  223. return traverse(0, converterMap, true);
  224. }
  225. function translate() {
  226. var src = $("#source").val();
  227. $("#destination").val(doconvert(src));
  228. }
  229. function changeDictionary() {
  230. converterMap = eval($('#source-map').val());
  231. translate();
  232. }
  233. var htmlForm = ' \
  234. <div class="lbt overlay"></div> \
  235. <div class="lbt window"> \
  236. <h4>Μεταγραφέας της Γραμμικής Β</h4> \
  237. <hr /> \
  238. <table style="width: 100%;"> \
  239. <tr> \
  240. <td> \
  241. Μετάγραψε:<select style="width: 100%;" id="source-map"> \
  242. <option value="la2li">Λατινική Γραφή σε Γραμμική Β</options> \
  243. <option value="li2la">Γραμμική Β σε Λατινική Γραφή</options> \
  244. <option value="la2cy">Λατινική Γραφή σε Κυπριακό συλλαβάριο</options> \
  245. <option value="cy2la">Κυπριακό συλλαβάριο σε Λατινική Γραφή</options> \
  246. </select> \
  247. </tr> \
  248. <tr> \
  249. <td><textarea id="source" style="width: 100%;"></textarea></td> \
  250. <td><textarea id="destination" style="width: 100%;"></textarea></td> \
  251. </tr> \
  252. </table> \
  253. <br>a \
  254. <input type="button" value="𐀀" class="key" /> \
  255. <input type="button" value="𐀅" class="key" /> \
  256. <input type="button" value="𐀊" class="key" /> \
  257. <input type="button" value="𐀏" class="key" /> \
  258. <input type="button" value="𐀔" class="key" /> \
  259. <input type="button" value="𐀙" class="key" /> \
  260. <input type="button" value="𐀞" class="key" /> \
  261. <input type="button" value="𐀣" class="key" /> \
  262. <input type="button" value="𐀨" class="key" /> \
  263. <input type="button" value="𐀭" class="key" /> \
  264. <input type="button" value="𐀲" class="key" /> \
  265. <input type="button" value="𐀷" class="key" /> \
  266. <input type="button" value="𐀼" class="key" /> \
  267. <br>e \
  268. <input type="button" value="𐀁" class="key" /> \
  269. <input type="button" value="𐀆" class="key" /> \
  270. <input type="button" value="𐀋" class="key" /> \
  271. <input type="button" value="𐀐" class="key" /> \
  272. <input type="button" value="𐀕" class="key" /> \
  273. <input type="button" value="𐀚" class="key" /> \
  274. <input type="button" value="𐀟" class="key" /> \
  275. <input type="button" value="𐀤" class="key" /> \
  276. <input type="button" value="𐀩" class="key" /> \
  277. <input type="button" value="𐀮" class="key" /> \
  278. <input type="button" value="𐀳" class="key" /> \
  279. <input type="button" value="𐀸" class="key" /> \
  280. <input type="button" value="𐀽" class="key" /> \
  281. <br>i \
  282. <input type="button" value="𐀂" class="key" /> \
  283. <input type="button" value="𐀇" class="key" /> \
  284. <input type="button" value="𐀑" class="key" /> \
  285. <input type="button" value="𐀖" class="key" /> \
  286. <input type="button" value="𐀛" class="key" /> \
  287. <input type="button" value="𐀠" class="key" /> \
  288. <input type="button" value="𐀥" class="key" /> \
  289. <input type="button" value="𐀪" class="key" /> \
  290. <input type="button" value="𐀯" class="key" /> \
  291. <input type="button" value="𐀴" class="key" /> \
  292. <input type="button" value="𐀹" class="key" /> \
  293. <br>o \
  294. <input type="button" value="𐀃" class="key" /> \
  295. <input type="button" value="𐀈" class="key" /> \
  296. <input type="button" value="𐀍" class="key" /> \
  297. <input type="button" value="𐀒" class="key" /> \
  298. <input type="button" value="𐀗" class="key" /> \
  299. <input type="button" value="𐀜" class="key" /> \
  300. <input type="button" value="𐀡" class="key" /> \
  301. <input type="button" value="𐀦" class="key" /> \
  302. <input type="button" value="𐀫" class="key" /> \
  303. <input type="button" value="𐀰" class="key" /> \
  304. <input type="button" value="𐀵" class="key" /> \
  305. <input type="button" value="𐀺" class="key" /> \
  306. <input type="button" value="𐀿" class="key" /> \
  307. <br>u \
  308. <input type="button" value="𐀄" class="key" /> \
  309. <input type="button" value="𐀉" class="key" /> \
  310. <input type="button" value="𐀓" class="key" /> \
  311. <input type="button" value="𐀘" class="key" /> \
  312. <input type="button" value="𐀝" class="key" /> \
  313. <input type="button" value="𐀢" class="key" /> \
  314. <input type="button" value="𐀬" class="key" /> \
  315. <input type="button" value="𐀱" class="key" /> \
  316. <input type="button" value="𐀶" class="key" /> \
  317. </div> \
  318. ';
  319. $.fn.lbt = function(options) {
  320. var settings = $.extend({}, options);
  321. if (settings['window-holder']) {
  322. $(document).ready(onResize);
  323. $(window).resize(onResize);
  324. $(settings['window-holder']).html(htmlForm);
  325. $('.lbt.overlay').click(hidePopup);
  326. this.click(showPopup);
  327. }
  328. else {
  329. this.html(htmlForm);
  330. $('.lbt.window').show();
  331. $('.lbt.window').css("position", "relative");
  332. }
  333. $('#source').change(translate);
  334. $('#source').keyup(translate);
  335. $('#source-map').change(changeDictionary);
  336. $('.key').click(function(e) {
  337. if (converterMap = la2li )
  338. { $('#source-map').val('li2la');
  339. converterMap = li2la;
  340. }
  341. var phoneme = $(this).attr('value');
  342. $('#source').val($('#source').val()+ phoneme);
  343. translate();
  344. });
  345. };
  346. })( jQuery );