1 const HALF_LETTER_MODE = 1;
2 const FULL_LETTER_MODE = 2;
3 const HALF_PUNCT_MODE = 3;
4 const FULL_PUNCT_MODE = 4;
5
6 var FireinputIME = function() {};
7
8 FireinputIME.prototype =
9 {
10 codeHash: null,
11 phraseCodeHash: null,
12 name: null,
13 letterMode: HALF_LETTER_MODE,
14 punctMode: HALF_PUNCT_MODE,
15
16 getName: function ()
17 {
18 return this.name;
19 },
20
21 loadTable: function()
22 {
23
24 },
25
26 find: function(inputChar)
27 {
28
29 },
30
31 next: function (index)
32 {
33
34 },
35
36 prev: function (index)
37 {
38
39 },
40
41 getDataPath: function()
42 {
43 var path = FireinputUtils.getExtensionPath();
44 path = path.substring(0, path.length - 19);
45
46 if(/chrome/.test(path))
47 {
48 return path.substring(0, path.lastIndexOf("/chrome"));
49 }
50
51 return path;
52 },
53
54 getPinyinDataFile: function()
55 {
56
57 return "/chrome/data/smart_pinyin_table";
58 },
59
60 getPinyinPhraseFile: function()
61 {
62 return "/chrome/data/smart_pinyin_phrase";
63 },
64
65 getWubi86File: function()
66 {
67 return "/chrome/data/wubi86_table";
68 },
69
70 getWubi98File: function()
71 {
72 return "/chrome/data/wubi98_table";
73 },
74
75 getCangjie5File: function()
76 {
77 return "/chrome/data/cangjie5_table";
78 },
79
80 getUserDataFile: function()
81 {
82 return "/userwordtable.fireinput";
83 },
84
85 getUserHistoryFile: function()
86 {
87 return "/userhistory.fireinput.rdf";
88 },
89
90 getPinyinTransformFile: function()
91 {
92 return "/chrome/data/pinyin_transform";
93 },
94
95 sortCodeArray: function (a, b)
96 {
97 if(!a || !b)
98 return 0;
99
100 //a = converter.convertStringToUTF8(a, "ASCII", false);
101 //b = converter.convertStringToUTF8(b, "ASCII", false);
102 var num1 = a.word.match(/[\d\.]+/g)[0];
103 var num2 = b.word.match(/[\d\.]+/g)[0];
104 var str1 = a.word.match(/[\D\.]+/g)[0];
105 var str2 = b.word.match(/[\D\.]+/g)[0];
106
107 if(num2 != num1)
108 return num2 - num1;
109
110 if(str2.length != str1.length)
111 return str2.length - str1.length;
112
113 return 0;
114 },
115
116 getKeyWord: function(wordArray)
117 {
118 if(!wordArray) return null;
119 var str = "";
120 for(var i=0; i<wordArray.length; i++)
121 {
122 str += wordArray[i].key + "=" + wordArray[i].word + "=" + ((typeof(wordArray[i].ufreq) == 'undefined') ? 'true' : wordArray[i].ufreq);
123 str += ",";
124 }
125 str = FireinputUnicode.getUnicodeString(str);
126 var strArray = str.split(",");
127 return (strArray.slice(0, strArray.length-1));
128 },
129
130 isHalfLetterMode: function()
131 {
132 return this.letterMode == HALF_LETTER_MODE;
133 },
134
135 setHalfLetterMode: function()
136 {
137 this.letterMode = HALF_LETTER_MODE;
138 },
139
140 setFullLetterMode: function()
141 {
142 this.letterMode = FULL_LETTER_MODE;
143 },
144
145 isHalfPunctMode: function()
146 {
147 return this.punctMode == HALF_PUNCT_MODE;
148 },
149
150 setHalfPunctMode: function()
151 {
152 this.punctMode = HALF_PUNCT_MODE;
153 },
154
155 setFullPunctMode: function()
156 {
157 this.punctMode = FULL_PUNCT_MODE;
158 },
159
160 storeOneUpdatePhrase: function(string)
161 {
162
163 },
164
165 storeUpdatePhrases: function(array)
166 {
167
168 }
169
170 };
syntax highlighted by Code2HTML, v. 0.9.1