From b7583ce9a1f86db9e767d5d7eb1a91a6a62d41cf Mon Sep 17 00:00:00 2001 From: Jeffrey Xuan Date: Wed, 2 Jun 2021 11:10:22 +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:=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E6=BB=91=E9=BC=A0=E5=9C=88=E9=81=B8=E6=9F=A5=E8=A9=A2?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ime/README.md | 5 ++- ime/ime.js | 10 +---- ime/tzdic/tzdicui.js | 17 ++++++-- ime/tzdic/tzlib/tzdicentry.js | 22 ++++++++--- ime/zhdicui.js | 73 +++++++++++++++-------------------- 5 files changed, 65 insertions(+), 62 deletions(-) diff --git a/ime/README.md b/ime/README.md index 7beb6e4..ef4fae1 100644 --- a/ime/README.md +++ b/ime/README.md @@ -26,6 +26,7 @@ ## 字典 在按下 「開始」 後的編輯模式中,點選右下角 「字典」 可開啟 《國語字典簡編本》 輔助查詢字義及標準讀音。 +請用滑鼠點擊或圈選任意字詞,字典工具會即時顯示查詢結果。 ## 協作邀請 (詞庫) @@ -66,9 +67,9 @@ poyin_db.txt 收錄了所有 phonetic/phonic_table_Z.txt 裡所有多音字的 ## 協作邀請 (字典) -本工具字典檔資料來自於教育部國語辭典公眾授權網 《國語辭典簡編本》,採用「CC BY-ND 3.0」授權。 +本工具字典檔資料來自於教育部國語辭典公眾授權網 《國語辭典簡編本》,採用 CC BY-ND 3.0 授權。 -字典工具來自於開源字典架構 「ToneOZDic澳聲通字典」 ,採用 MIT 授權。 此字典工具支援使用者自行製作字典檔,請參考 字典檔生成器使用說明。 +字典工具來自開源的字典架構 ToneOZ 澳聲通字典 ,採用 MIT 授權。 此字典工具支援使用者自行製作字典檔,請參考 ToneOZ Dictionary 字典檔生成器使用說明。 diff --git a/ime/ime.js b/ime/ime.js index e340ef4..1b351b7 100644 --- a/ime/ime.js +++ b/ime/ime.js @@ -35,20 +35,14 @@ function match(c, i, p, j, onlydic) { 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 = {}; - } + var phrasearr = ivsinfo.phrasearr; + var phrasedata = {phrase:phrase,x:x,a:a}; if(phrasearr === undefined){ phrasearr = [phrasedata]; } else { phrasearr.push(phrasedata); } - phraseidx[""+x+phrase] = phrasearr.length-1; ivsinfo.phrasearr = phrasearr; - ivsinfo.phraseidx = phraseidx; } } diff --git a/ime/tzdic/tzdicui.js b/ime/tzdic/tzdicui.js index abb0db8..dbccdb0 100644 --- a/ime/tzdic/tzdicui.js +++ b/ime/tzdic/tzdicui.js @@ -16,6 +16,7 @@ if(!window.tzdicidx){ } function TZDicUI(){ + let thisObj = this; // ToneOZDic Parameters let tzparam = { objInput : null @@ -34,6 +35,8 @@ function TZDicUI(){ // Custeom lookup table to specify the IVS fonts (Ideographic Variation Sequences) displayed in the dictionary entry iframe , strCssIframe : tzstrCssIframe // Custom css object to decorate the objIframe outter position + , intMaxPhrase : 16 + // Max phrases per query , strVer : "" // Version control string }; @@ -73,10 +76,13 @@ function TZDicUI(){ // events init tzparam.objInput.on('input selectionchange propertychange keydown click focus', function(event) { - tzUpdateEvent({event:event}); + thisObj.tzUpdateEvent({event:event}); + }); + tzparam.objInput.on('DOMSubtreeModified', function(event) { + thisObj.tzUpdateEvent({event:event}); }); $(document).on('mouseup', function(event) { - tzUpdateEvent({event:event}); + thisObj.tzUpdateEvent({event:event}); }); return tzparam; @@ -99,7 +105,7 @@ function TZDicUI(){ } let tmrUpdateEvent = null; - window.tzUpdateEvent = function(dicParam){ + this.tzUpdateEvent = function(dicParam){ if(tmrUpdateEvent){ clearTimeout(tmrUpdateEvent); tmrUpdateEvent = null; @@ -154,9 +160,12 @@ function TZDicUI(){ // get query parameters for ToneOZDic for(let idxPhrase in phrases){ let phrase = phrases[idxPhrase]; + if(qArray.length >= tzparam.intMaxPhrase){ + break; + } qArray.push(GetQuery({ phrase : phrase - })); + })); } let dicURLParam = JSON.stringify(qArray); diff --git a/ime/tzdic/tzlib/tzdicentry.js b/ime/tzdic/tzlib/tzdicentry.js index a048e79..c902ecc 100644 --- a/ime/tzdic/tzlib/tzdicentry.js +++ b/ime/tzdic/tzlib/tzdicentry.js @@ -1,8 +1,11 @@ // BEGIN CONFIG ///////// +// Folder path of the dictionary files const defaultDataFolder = "./tzdata/"; +// Max phrases per query +const intMaxPhrase = 16; // END CONFIG ///////// const vsbase = 0xe01e0; -let tzQuery, tzQueryArray, tzCss, tzIvsPosDic; +let tzQuery, tzQueryArray, tzCss, tzIvsPosDic, tzVer; let winSearch = window.location.search; if(!window.tzdic){ window.tzdic = {}; @@ -12,19 +15,23 @@ if(winSearch){ tzQuery = urlParams.get("q"); tzCss = urlParams.get("css"); tzIvsPosDic = urlParams.get("ivs"); + tzVer = urlParams.get("v"); + tzVer = (tzVer?"?v="+tzVer:""); tzQueryArray = JSON.parse(tzQuery); if(tzCss){ - document.write(''); + document.write(''); } if(tzIvsPosDic){ - document.write('