Skip to content

Commit b82cb66

Browse files
authoredJun 1, 2021
Merge pull request #8 from jeffreyxuan/master
ToneOZ 澳聲通字典工具整合
2 parents 322da91 + cd51429 commit b82cb66

File tree

278 files changed

+2340
-10
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

278 files changed

+2340
-10
lines changed
 

‎ime/README.md

+11

‎ime/ime.js

+28-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function chr(uni) {
99
0xdc00 | ((uni-0x10000) & 0x03ff));
1010
}
1111

12-
function match(c, i, p, j) {
12+
function match(c, i, p, j, onlydic) {
1313
var pos = p.indexOf('*');
1414
if (i-pos<0) return false;
1515
if (i-pos+p.length>text.length) return false;
@@ -18,11 +18,27 @@ function match(c, i, p, j) {
1818
for (var z=i-pos; z<i-pos+p.length; z++) tmp += text[z].charAt(0);
1919
if (tmp != p.replace(/\*/g, c)) return false;
2020

21+
var phrase = p.replace("*",c);
2122
for (var x=0; x<p.length; x++) {
22-
if (p.charAt(x) == '*') {
23-
var a = i-pos+x;
23+
var a = i-pos+x;
24+
var spobj = $('#sp' + a);
25+
var phraseattr = spobj.attr("phrase");
26+
if(phraseattr === undefined){
27+
phraseattr = phrase;
28+
} else {
29+
var phrasearr = phraseattr.split(",");
30+
if(phrasearr.indexOf(phrase)<0){
31+
phrasearr.push(phrase);
32+
}
33+
phraseattr = phrasearr.join(",");
34+
}
35+
36+
var spDom = spobj.attr({
37+
"phrase":phraseattr
38+
});
39+
if (p.charAt(x) == '*' && !onlydic) {
2440
text[a] = c + (j > 0 ? chr(vsbase + j*1) : '');
25-
$('#sp' + a).text(text[a]).addClass('auto');
41+
spDom.text(text[a]).addClass('auto');
2642
}
2743
}
2844
}
@@ -32,14 +48,19 @@ function autoSelect() {
3248
var t = text[i];
3349
var c = t.charAt(0);
3450
if (!data[c]) continue;
35-
if (t.length > 1) continue;
51+
var onlydic = false;
52+
if (t.length > 1) {
53+
// For IVS char, do not overwrite the inserted text
54+
onlydic = true;
55+
};
56+
//if (t.length > 1) continue;
3657
if (!data[c].v) continue;
3758

3859
here: for (var j in data[c].v) {
3960
if (!data[c].v[j]) continue;
4061
var list = data[c].v[j].split('/');
4162
for (var n=0; n<list.length; n++) {
42-
if (match(c, i, list[n], j)) break here;
63+
if (match(c, i, list[n], j, onlydic)) break here;
4364
}
4465
//console.log(list);
4566
}
@@ -135,7 +156,7 @@ $('#start').click(function() {
135156
$('#start').hide();
136157
$('#info2').show();
137158
$('#info1').hide();
138-
159+
139160
setEditorText(t);
140161
});
141162

0 commit comments

Comments
 (0)
Please sign in to comment.