From fbcfc847ae6e673baae4d12c2a1be3e1f541746f Mon Sep 17 00:00:00 2001 From: Jeffreyx Date: Wed, 2 Jun 2021 07:06:13 +1000 Subject: [PATCH] =?UTF-8?q?ToneOZ=20=E6=BE=B3=E8=81=B2=E9=80=9A=E5=AD=97?= =?UTF-8?q?=E5=85=B8=E5=B7=A5=E5=85=B7=E6=95=B4=E5=90=88:=E6=94=B9?= =?UTF-8?q?=E9=80=B2IVS=E8=A9=9E=E5=BD=99=E6=9F=A5=E8=A9=A2=E9=82=8F?= =?UTF-8?q?=E8=BC=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ime/ime.js | 40 +++++++---- ime/tzdic/tzdic.html | 6 +- ime/tzdic/tzdicui.js | 124 +++++++++++++++++----------------- ime/tzdic/tzlib/tzdicentry.js | 24 ++++++- ime/zhdicui.js | 73 +++++++++++++++----- 5 files changed, 167 insertions(+), 100 deletions(-) diff --git a/ime/ime.js b/ime/ime.js index a649cb3..e340ef4 100644 --- a/ime/ime.js +++ b/ime/ime.js @@ -1,6 +1,7 @@ var text = []; var curr = -1; var vsbase = 0xe01e0; +window.textinfo = {}; function chr(uni) { if (String.fromCodePoint) return String.fromCodePoint(uni); // ES6 @@ -21,25 +22,33 @@ function match(c, i, p, j, onlydic) { var phrase = p.replace("*",c); for (var x=0; x 0 ? chr(vsbase + j*1) : ''); spDom.text(text[a]).addClass('auto'); } + + // update phrase for dic + if(!textinfo[a]){ + textinfo[a] = {}; + } + var ivsinfo = textinfo[a]; + var phrasearr = ivsinfo.phrasearr; + var phraseidx = ivsinfo.phraseidx; + var phrasedata = {phrase:phrase,x:x,a:a,ivs:text[a]};; + if(phraseidx === undefined){ + phraseidx = {}; + } + if(phrasearr === undefined){ + phrasearr = [phrasedata]; + } else { + phrasearr.push(phrasedata); + } + phraseidx[""+x+phrase] = phrasearr.length-1; + ivsinfo.phrasearr = phrasearr; + ivsinfo.phraseidx = phraseidx; } } @@ -109,6 +118,7 @@ function setEditorText(t) { // [\ud800-\udfff] means surrogate pairs of UTF-16 // Here I wrote /(.|\n)/g because MS Edge doesn't support /(.)/s. text = t.replace(/(.|\n)/g, "\x01$1").replace(/\x01([\ud800-\udfff])/g, "$1").split(/\x01/); + textinfo = {}; var editor = $('#editor'); $('#editor').empty(); diff --git a/ime/tzdic/tzdic.html b/ime/tzdic/tzdic.html index 6898b35..2ec8085 100644 --- a/ime/tzdic/tzdic.html +++ b/ime/tzdic/tzdic.html @@ -5,16 +5,17 @@ Website : https://toneoz.com (Pinyin Zhuyin Graphical Editor) Github : https://github.com/jeffreyxuan/ToneOZDic License : MIT License. Free for both commercial and personal uses -Usage example (with demo tzdic folder): +Usage example : tzdic.html?q=[{"id":1,"q":"和"},{"id":1,"q":"樂"}] --> - + ToneOZ 澳聲通字典