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     getUserDataFile: function()
 76     {
 77        return "/userwordtable.fireinput";
 78     }, 
 79  
 80     getUserHistoryFile: function()
 81     {
 82        return "/userhistory.fireinput.rdf"; 
 83     }, 
 84   
 85     getPinyinTransformFile: function()
 86     {
 87        return "/chrome/data/pinyin_transform";
 88     }, 
 89 
 90     sortCodeArray: function (a, b)
 91     {
 92        if(!a || !b)
 93           return 0;
 94 
 95        //a = converter.convertStringToUTF8(a, "ASCII", false);
 96        //b = converter.convertStringToUTF8(b, "ASCII", false);
 97        var num1 = a.word.match(/[\d\.]+/g)[0];
 98        var num2 = b.word.match(/[\d\.]+/g)[0];
 99        var str1 = a.word.match(/[\D\.]+/g)[0];
100        var str2 = b.word.match(/[\D\.]+/g)[0];
101 
102        if(num2 != num1)
103           return num2 - num1; 
104 
105        if(str2.length != str1.length)
106           return str2.length - str1.length;
107 
108        return 0; 
109     },
110 
111     getKeyWord: function(wordArray)
112     {
113        if(!wordArray) return null; 
114        var str = "";
115        for(var i=0; i<wordArray.length; i++)
116        {
117           str += wordArray[i].key + "=" + wordArray[i].word; 
118           str += ",";
119        }
120        str = FireinputUnicode.getUnicodeString(str);
121        var strArray = str.split(",");
122        return (strArray.slice(0, strArray.length-1));
123     },
124 
125     isHalfLetterMode: function()
126     {
127        return this.letterMode == HALF_LETTER_MODE; 
128     }, 
129 
130     setHalfLetterMode: function()
131     {
132        this.letterMode = HALF_LETTER_MODE; 
133     },
134 
135     setFullLetterMode: function()
136     {
137        this.letterMode = FULL_LETTER_MODE; 
138     },
139 
140     isHalfPunctMode: function()
141     {
142        return this.punctMode == HALF_PUNCT_MODE;
143     },
144   
145     setHalfPunctMode: function()
146     {
147        this.punctMode = HALF_PUNCT_MODE;
148     },
149 
150     setFullPunctMode: function()
151     {
152        this.punctMode = FULL_PUNCT_MODE;    
153     }
154 };


syntax highlighted by Code2HTML, v. 0.9.1