IMQuery.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. .pragma library
  2. function convertToStrokes(fullString) {
  3. // Convert numbers to strokes presentations for the query results of Stroke Order and Stroke 5 input methods.
  4. var r = fullString
  5. r = replaceAll(r, "1","一")
  6. r = replaceAll(r, "2","丨")
  7. r = replaceAll(r, "3","丿")
  8. r = replaceAll(r, "4","丶")
  9. r = replaceAll(r, "5","乛")
  10. return r
  11. }
  12. function convertToCangJie(fullString) {
  13. // Convert alphabet inputs to CangJii radicals for the query results of CangJie and Simplified CangJie input methods.
  14. var r = fullString.toUpperCase()
  15. r = replaceAll(r, "A","日")
  16. r = replaceAll(r, "B","月")
  17. r = replaceAll(r, "C","金")
  18. r = replaceAll(r, "D","木")
  19. r = replaceAll(r, "E","水")
  20. r = replaceAll(r, "F","火")
  21. r = replaceAll(r, "G","土")
  22. r = replaceAll(r, "H","竹")
  23. r = replaceAll(r, "I","戈")
  24. r = replaceAll(r, "J","十")
  25. r = replaceAll(r, "K","大")
  26. r = replaceAll(r, "L","中")
  27. r = replaceAll(r, "M","一")
  28. r = replaceAll(r, "N","弓")
  29. r = replaceAll(r, "O","人")
  30. r = replaceAll(r, "P","心")
  31. r = replaceAll(r, "Q","手")
  32. r = replaceAll(r, "R","口")
  33. r = replaceAll(r, "S","尸")
  34. r = replaceAll(r, "T","廿")
  35. r = replaceAll(r, "U","山")
  36. r = replaceAll(r, "V","女")
  37. r = replaceAll(r, "W","田")
  38. r = replaceAll(r, "X","難")
  39. r = replaceAll(r, "Y","卜")
  40. r = replaceAll(r, "Z","重")
  41. return r
  42. }
  43. function convertToZhuYin(fullString) {
  44. // Convert alphabet inputs to ZhuYin symbols for the query results of the ZhuYin input method.
  45. var r = fullString.toUpperCase()
  46. r = replaceAll(r, "A","ㄇ")
  47. r = replaceAll(r, "B","ㄖ")
  48. r = replaceAll(r, "C","ㄏ")
  49. r = replaceAll(r, "D","ㄎ")
  50. r = replaceAll(r, "E","ㄍ")
  51. r = replaceAll(r, "F","ㄑ")
  52. r = replaceAll(r, "G","ㄕ")
  53. r = replaceAll(r, "H","ㄘ")
  54. r = replaceAll(r, "I","ㄛ")
  55. r = replaceAll(r, "J","ㄨ")
  56. r = replaceAll(r, "K","ㄜ")
  57. r = replaceAll(r, "L","ㄠ")
  58. r = replaceAll(r, "M","ㄩ")
  59. r = replaceAll(r, "N","ㄙ")
  60. r = replaceAll(r, "O","ㄟ")
  61. r = replaceAll(r, "P","ㄣ")
  62. r = replaceAll(r, "Q","ㄆ")
  63. r = replaceAll(r, "R","ㄐ")
  64. r = replaceAll(r, "S","ㄋ")
  65. r = replaceAll(r, "T","ㄔ")
  66. r = replaceAll(r, "U","ㄧ")
  67. r = replaceAll(r, "V","ㄒ")
  68. r = replaceAll(r, "W","ㄊ")
  69. r = replaceAll(r, "X","ㄌ")
  70. r = replaceAll(r, "Y","ㄗ")
  71. r = replaceAll(r, "Z","ㄈ")
  72. r = replaceAll(r, "1","ㄅ")
  73. r = replaceAll(r, "2","ㄉ")
  74. r = replaceAll(r, "3","ˇ")
  75. r = replaceAll(r, "4","ˋ")
  76. r = replaceAll(r, "5","ㄓ")
  77. r = replaceAll(r, "6","ˊ")
  78. r = replaceAll(r, "7","˙")
  79. r = replaceAll(r, "8","ㄚ")
  80. r = replaceAll(r, "9","ㄞ")
  81. r = replaceAll(r, "0","ㄢ")
  82. r = replaceAll(r, "-","ㄦ")
  83. r = replaceAll(r, ";","ㄤ")
  84. r = replaceAll(r, ",","ㄝ")
  85. r = replaceAll(r, ".","ㄡ")
  86. r = replaceAll(r, "/","ㄥ")
  87. return r
  88. }
  89. function convertToDaiYi3(fullString) {
  90. // Convert alphabet inputs to DaYi 3rd Edition radicals for the query results of the DaYi 3rd Edition input method.
  91. var r = fullString.toUpperCase()
  92. r = replaceAll(r, "A","人")
  93. r = replaceAll(r, "B","馬")
  94. r = replaceAll(r, "C","七")
  95. r = replaceAll(r, "D","日")
  96. r = replaceAll(r, "E","一")
  97. r = replaceAll(r, "F","土")
  98. r = replaceAll(r, "G","手")
  99. r = replaceAll(r, "H","鳥")
  100. r = replaceAll(r, "I","木")
  101. r = replaceAll(r, "J","月")
  102. r = replaceAll(r, "K","立")
  103. r = replaceAll(r, "L","女")
  104. r = replaceAll(r, "M","雨")
  105. r = replaceAll(r, "N","魚")
  106. r = replaceAll(r, "O","口")
  107. r = replaceAll(r, "P","耳")
  108. r = replaceAll(r, "Q","石")
  109. r = replaceAll(r, "R","工")
  110. r = replaceAll(r, "S","革")
  111. r = replaceAll(r, "T","糸")
  112. r = replaceAll(r, "U","艸")
  113. r = replaceAll(r, "V","禾")
  114. r = replaceAll(r, "W","山")
  115. r = replaceAll(r, "X","水")
  116. r = replaceAll(r, "Y","火")
  117. r = replaceAll(r, "Z","心")
  118. r = replaceAll(r, ",","力")
  119. r = replaceAll(r, ".","點")
  120. r = replaceAll(r, "/","竹")
  121. r = replaceAll(r, "0","金")
  122. r = replaceAll(r, "1","言")
  123. r = replaceAll(r, "2","牛")
  124. r = replaceAll(r, "3","目")
  125. r = replaceAll(r, "4","四")
  126. r = replaceAll(r, "5","王")
  127. r = replaceAll(r, "6","門")
  128. r = replaceAll(r, "7","田")
  129. r = replaceAll(r, "8","米")
  130. r = replaceAll(r, "9","足")
  131. r = replaceAll(r, ";","虫")
  132. return r
  133. }
  134. function convertToWuBi(fullString) {
  135. // Convert alphabet inputs to WuBi symbols for the query results of the WuBi input method.
  136. var r = fullString.toUpperCase()
  137. r = replaceAll(r, "A","工");
  138. r = replaceAll(r, "B","子");
  139. r = replaceAll(r, "C","又");
  140. r = replaceAll(r, "D","大");
  141. r = replaceAll(r, "E","月");
  142. r = replaceAll(r, "F","土");
  143. r = replaceAll(r, "G","王");
  144. r = replaceAll(r, "H","目");
  145. r = replaceAll(r, "I","水");
  146. r = replaceAll(r, "J","日");
  147. r = replaceAll(r, "K","口");
  148. r = replaceAll(r, "L","田");
  149. r = replaceAll(r, "M","山");
  150. r = replaceAll(r, "N","已");
  151. r = replaceAll(r, "O","火");
  152. r = replaceAll(r, "P","之");
  153. r = replaceAll(r, "Q","金");
  154. r = replaceAll(r, "R","白");
  155. r = replaceAll(r, "S","木");
  156. r = replaceAll(r, "T","禾");
  157. r = replaceAll(r, "U","立");
  158. r = replaceAll(r, "V","女");
  159. r = replaceAll(r, "W","人");
  160. r = replaceAll(r, "X","纟");
  161. r = replaceAll(r, "Y","言");
  162. return r
  163. }
  164. function convertToArray30(fullString) {
  165. // Convert alphabet inputs to Array 30 keys edition symbols for the query results of the Array 30 keys edition input method.
  166. var r = fullString.toUpperCase()
  167. r = replaceAll(r, ",","8v");
  168. r = replaceAll(r, ".","9v");
  169. r = replaceAll(r, "/","0v");
  170. r = replaceAll(r, ";","0-");
  171. r = replaceAll(r, ";","0-");
  172. r = replaceAll(r, "A","1-");
  173. r = replaceAll(r, "B","5v");
  174. r = replaceAll(r, "C","3v");
  175. r = replaceAll(r, "D","3-");
  176. r = replaceAll(r, "E","3^");
  177. r = replaceAll(r, "F","4-");
  178. r = replaceAll(r, "G","5-");
  179. r = replaceAll(r, "H","6-");
  180. r = replaceAll(r, "I","8^");
  181. r = replaceAll(r, "J","7-");
  182. r = replaceAll(r, "K","8-");
  183. r = replaceAll(r, "L","9-");
  184. r = replaceAll(r, "M","7v");
  185. r = replaceAll(r, "N","6v");
  186. r = replaceAll(r, "O","9^");
  187. r = replaceAll(r, "P","0^");
  188. r = replaceAll(r, "Q","1^");
  189. r = replaceAll(r, "R","4^");
  190. r = replaceAll(r, "S","2-");
  191. r = replaceAll(r, "T","5^");
  192. r = replaceAll(r, "U","7^");
  193. r = replaceAll(r, "V","4v");
  194. r = replaceAll(r, "W","2^");
  195. r = replaceAll(r, "X","2v");
  196. r = replaceAll(r, "Y","6^");
  197. r = replaceAll(r, "Z","1v");
  198. return r
  199. }
  200. function replaceAll(fullString, stringToFind,stringToReplace){
  201. // Replace all instances of a substring with another substring within a string.
  202. var temp = fullString
  203. var index = fullString.indexOf(stringToFind);
  204. while(index != -1){
  205. temp = temp.replace(stringToFind,stringToReplace);
  206. index = temp.indexOf(stringToFind);
  207. }
  208. return temp;
  209. }