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 );