Index: trunk/extensions/Narayam/ext.narayam.core-monobook.css |
— | — | @@ -0,0 +1,3 @@ |
| 2 | +.narayam-wrapper select { |
| 3 | + width: 9em; |
| 4 | +} |
Property changes on: trunk/extensions/Narayam/ext.narayam.core-monobook.css |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 5 | + native |
Index: trunk/extensions/Narayam/sa_rules.js |
— | — | @@ -5,47 +5,44 @@ |
6 | 6 | * @credits With help from Naveen Shankar |
7 | 7 | * License: GPLv3, CC-BY-SA 3.0 |
8 | 8 | */ |
9 | | -if(tr_sa== undefined) var tr_sa = {}; |
10 | | -else tr_sa = {}; |
11 | | -tr_sa.text = "Transliteration"; |
12 | | -tr_sa.description = "Sanskrit transliteration"; |
| 9 | + |
13 | 10 | // Normal rules |
14 | | -tr_sa.rules = [ |
| 11 | +var rules = [ |
15 | 12 | ['क्h','c','च्'], |
16 | | -['\\\\([A-Za-z\\>_~\\.0-9])','\\\\','$2'], |
| 13 | +['\\\\([A-Za-z\\>_~\\.0-9])','\\\\','$1'], |
17 | 14 | |
18 | | -['([क-ह]़?)्a', '','$2'], |
19 | | -['([क-ह]़?)्A', '','$2ा'], |
20 | | -['([क-ह]़?)a', '','$2ा'], |
21 | | -['([क-ह]़?)्i', '','$2ि'], |
22 | | -['([क-ह]़?)(्I|िi|ॆe)', '','$2ी'], |
23 | | -['([क-ह]़?)्u', '','$2ु'], |
24 | | -['([क-ह]़?)(ुu|्U|ॊo)', '','$2ू'], |
25 | | -['([क-ह]़?)्R', '','$2ृ'], |
26 | | -['([क-ह]़?)ृR', '','$2ॄ'], |
27 | | -['([क-ह]़?)्ळ्l', '','$2ॢ'], |
28 | | -['([क-ह]़?)ॢl', '','$2ॣ'], |
29 | | -['([क-ह]़?)ॆ\\^', '','$2ॅ'], |
30 | | -['([क-ह]़?)्e', '','$2ॆ'], |
31 | | -['([क-ह]़?)्E', '','$2े'], |
32 | | -['([क-ह]़?)ॊ\\^', '','$2ॉ'], |
33 | | -['([क-ह]़?)i', '','$2ै'], |
34 | | -['([क-ह]़?)्o', '','$2ॊ'], |
35 | | -['([क-ह]़?)्O', '','$2ो'], |
36 | | -['([क-ह]़?)u', '','$2ौ'], |
37 | | -['([क-ह]़?)ृa', '','$2्ऱ'], |
38 | | -['([क-ह]़?)ृA', '','$2्ऱा'], |
39 | | -['([क-ह]़?)ृi', '','$2्ऱि'], |
40 | | -['([क-ह]़?)ृI', '','$2्ऱी'], |
41 | | -['([क-ह]़?)ृu', '','$2्ऱु'], |
42 | | -['([क-ह]़?)ृU', '','$2्ऱू'], |
43 | | -['([क-ह]़?)ृ\\^', '','$2्ऱॅ'], |
44 | | -['([क-ह]़?)ृe', '','$2्ऱॆ'], |
45 | | -['([क-ह]़?)ृE', '','$2्ऱे'], |
46 | | -['([क-ह]़?)ृo', '','$2्ऱॊ'], |
47 | | -['([क-ह]़?)ृO', '','$2्ऱो'], |
48 | | -['([क-ह]़?)ृ\\~', '','$2्ऱ्'], |
49 | | -['([क-ह])्\\`', '','$2़्'], |
| 15 | +['([क-ह]़?)्a', '','$1'], |
| 16 | +['([क-ह]़?)्A', '','$1ा'], |
| 17 | +['([क-ह]़?)a', '','$1ा'], |
| 18 | +['([क-ह]़?)्i', '','$1ि'], |
| 19 | +['([क-ह]़?)(्I|िi|ॆe)', '','$1ी'], |
| 20 | +['([क-ह]़?)्u', '','$1ु'], |
| 21 | +['([क-ह]़?)(ुu|्U|ॊo)', '','$1ू'], |
| 22 | +['([क-ह]़?)्R', '','$1ृ'], |
| 23 | +['([क-ह]़?)ृR', '','$1ॄ'], |
| 24 | +['([क-ह]़?)्ळ्l', '','$1ॢ'], |
| 25 | +['([क-ह]़?)ॢl', '','$1ॣ'], |
| 26 | +['([क-ह]़?)ॆ\\^', '','$1ॅ'], |
| 27 | +['([क-ह]़?)्e', '','$1ॆ'], |
| 28 | +['([क-ह]़?)्E', '','$1े'], |
| 29 | +['([क-ह]़?)ॊ\\^', '','$1ॉ'], |
| 30 | +['([क-ह]़?)i', '','$1ै'], |
| 31 | +['([क-ह]़?)्o', '','$1ॊ'], |
| 32 | +['([क-ह]़?)्O', '','$1ो'], |
| 33 | +['([क-ह]़?)u', '','$1ौ'], |
| 34 | +['([क-ह]़?)ृa', '','$1्ऱ'], |
| 35 | +['([क-ह]़?)ृA', '','$1्ऱा'], |
| 36 | +['([क-ह]़?)ृi', '','$1्ऱि'], |
| 37 | +['([क-ह]़?)ृI', '','$1्ऱी'], |
| 38 | +['([क-ह]़?)ृu', '','$1्ऱु'], |
| 39 | +['([क-ह]़?)ृU', '','$1्ऱू'], |
| 40 | +['([क-ह]़?)ृ\\^', '','$1्ऱॅ'], |
| 41 | +['([क-ह]़?)ृe', '','$1्ऱॆ'], |
| 42 | +['([क-ह]़?)ृE', '','$1्ऱे'], |
| 43 | +['([क-ह]़?)ृo', '','$1्ऱॊ'], |
| 44 | +['([क-ह]़?)ृO', '','$1्ऱो'], |
| 45 | +['([क-ह]़?)ृ\\~', '','$1्ऱ्'], |
| 46 | +['([क-ह])्\\`', '','$1़्'], |
50 | 47 | |
51 | 48 | ['अa', '','आ'], |
52 | 49 | ['(ऒo|उu)', '','ऊ'], |
— | — | @@ -156,4 +153,11 @@ |
157 | 154 | ['\\.', '','।'], |
158 | 155 | ['//', '','ऽ'], |
159 | 156 | ['\\`', '','़'] |
160 | | -]; |
\ No newline at end of file |
| 157 | +]; |
| 158 | + |
| 159 | +jQuery.narayam.addScheme( 'sa', { |
| 160 | + 'namemsg': 'narayam-sa', |
| 161 | + 'extended_keyboard': false, |
| 162 | + 'lookbackLength': 2, |
| 163 | + 'rules': rules |
| 164 | +} ); |
Index: trunk/extensions/Narayam/ta_rules.js |
— | — | @@ -4,31 +4,28 @@ |
5 | 5 | * @date 2010-11-21 |
6 | 6 | * License: GPLv3, CC-BY-SA 3.0 |
7 | 7 | */ |
8 | | -if(tr_ta== undefined) var tr_ta = {}; |
9 | | -else tr_ta = {}; |
10 | | -tr_ta.text = "எழுத்துபெயர்ப்பு"; |
11 | | -tr_ta.description = "Tamil transliteration"; |
12 | | - // Normal rules |
13 | | -tr_ta.rules = [ |
| 8 | + |
| 9 | +// Normal rules |
| 10 | +var rules = [ |
14 | 11 | ['ச்h','h','ச்ஹ்',], |
15 | 12 | ['ழ்h','h','ழ்ஹ்',], |
16 | 13 | |
17 | 14 | //'(ஸ்ரிi|ஸ்ர்I)', '','', |
18 | 15 | |
19 | | -['([க-ஹ])்a', '','$2'], |
20 | | -['([க-ஹ])(்A|a)', '','$2ா'], |
21 | | -['([க-ஹ])்i', '','$2ி'], |
22 | | -['([க-ஹ])(்I|ிi)', '','$2ீ'], |
23 | | -['([க-ஹ])்u', '','$2ு'], |
24 | | -['([க-ஹ])(்U|ுu)', '','$2ூ'], |
25 | | -['([க-ஹ])்e', '','$2ெ'], |
26 | | -['([க-ஹ])(்E|ெe)', '','$2ே'], |
27 | | -['([க-ஹ])i', '','$2ை'], |
28 | | -['([க-ஹ])்o', '','$2ொ'], |
29 | | -['([க-ஹ])(்O|ொo)', '','$2ோ'], |
30 | | -['([க-ஹ])u', '','$2ௌ'], |
| 16 | +['([க-ஹ])்a', '','$1'], |
| 17 | +['([க-ஹ])(்A|a)', '','$1ா'], |
| 18 | +['([க-ஹ])்i', '','$1ி'], |
| 19 | +['([க-ஹ])(்I|ிi)', '','$1ீ'], |
| 20 | +['([க-ஹ])்u', '','$1ு'], |
| 21 | +['([க-ஹ])(்U|ுu)', '','$1ூ'], |
| 22 | +['([க-ஹ])்e', '','$1ெ'], |
| 23 | +['([க-ஹ])(்E|ெe)', '','$1ே'], |
| 24 | +['([க-ஹ])i', '','$1ை'], |
| 25 | +['([க-ஹ])்o', '','$1ொ'], |
| 26 | +['([க-ஹ])(்O|ொo)', '','$1ோ'], |
| 27 | +['([க-ஹ])u', '','$1ௌ'], |
31 | 28 | |
32 | | -['([அ-ஹ][ெ-்]?)n', '','$2ன்'], |
| 29 | +['([அ-ஹ][ெ-்]?)n', '','$1ன்'], |
33 | 30 | |
34 | 31 | ['அa', '','ஆ'], |
35 | 32 | ['இi', '','ஈ'], |
— | — | @@ -103,4 +100,11 @@ |
104 | 101 | ['10\\\\', '','\u0BF0'], |
105 | 102 | ['100\\\\', '','\u0BF1'], |
106 | 103 | ['1000\\\\', '','\u0BF2'] |
107 | | -]; |
\ No newline at end of file |
| 104 | +]; |
| 105 | + |
| 106 | +jQuery.narayam.addScheme( 'ta', { |
| 107 | + 'namemsg': 'narayam-ta', |
| 108 | + 'extended_keyboard': false, |
| 109 | + 'lookbackLength': 1, |
| 110 | + 'rules': rules |
| 111 | +} ); |
Index: trunk/extensions/Narayam/Narayam.i18n.php |
— | — | @@ -15,9 +15,9 @@ |
16 | 16 | */ |
17 | 17 | $messages['en'] = array( |
18 | 18 | 'narayam-desc' => 'Allows to add custom input methods for input fields', |
19 | | - 'narayam-toggle-ime' => 'To toggle IM', |
| 19 | + 'narayam-toggle-ime' => 'To toggle IM ($1)', // FIXME: better message |
20 | 20 | 'narayam-help-page' => 'Help:Typing', |
21 | | - 'narayam-checkbox-tooltip' => 'To toggle input method On and Off', |
| 21 | + 'narayam-checkbox-tooltip' => 'To toggle input method on and off', // FIXME: better message |
22 | 22 | 'narayam-ml' => 'Malayalam Transliteration', |
23 | 23 | 'narayam-ml-inscript' => 'Malayalam InScript', |
24 | 24 | 'narayam-sa' => 'Sanskrit Transliteration', |
Index: trunk/extensions/Narayam/ml_rules.js |
— | — | @@ -5,12 +5,9 @@ |
6 | 6 | * @credits Malayalam Wikimedia Community, especialy Thachan Makan ([[user:Thachan.makan]]) |
7 | 7 | * License: GPLv3, CC-BY-SA 3.0 |
8 | 8 | */ |
9 | | -if(tr_ml== undefined) var tr_ml = {}; |
10 | | -else tr_ml = {}; |
11 | | -tr_ml.text = "Transliteration"; |
12 | | -tr_ml.description = "Malayalam transliteration"; |
| 9 | + |
13 | 10 | // Normal rules |
14 | | -tr_ml.rules = [ |
| 11 | +var rules = [ |
15 | 12 | ['(\u200c)+a', '', 'അ'], |
16 | 13 | ['(\u200c)+A', '', 'ആ'], |
17 | 14 | ['(\u200c)+i', '', 'ഇ'], |
— | — | @@ -28,28 +25,28 @@ |
29 | 26 | ['ക്ക്h','cc', 'ച്ച്'], |
30 | 27 | ['ല്പ്p','lp','ൽപ്പ്'], |
31 | 28 | |
32 | | -['\\\\([A-Za-z\\>_~])','\\\\','$2'], |
| 29 | +['\\\\([A-Za-z\\>_~])','\\\\','$1'], |
33 | 30 | |
34 | | -['([ക-ഹ])്R', '', '$2ൃ'], |
| 31 | +['([ക-ഹ])്R', '', '$1ൃ'], |
35 | 32 | ['ന്ന്j', '', 'ഞ്ഞ്'], |
36 | 33 | ['ന്ന്g', '', 'ങ്ങ്'], |
37 | 34 | ['റ്റ്h', '', 'ത്'], |
38 | 35 | ['റ്റ്t', '', 'ട്ട്'], |
39 | 36 | ['ന്റ്h', '', 'ന്ത്'], |
40 | | -['([ക-ഹ])്ല്l', 'L', '$2\u0d62'], |
41 | | -['([ക-ഹ])\u0d62l', '', '$2\u0d63'], |
42 | | -['([അ-ഊഌഎ-ഐഒ-ഹ])([ഽ-ൂെ-ൌൗ])+R', '', '$2$3റ്'], |
43 | | -['([ക-ഹ])ൃa', '', '$2്ര'], |
44 | | -['([ക-ഹ])ൃA', '', '$2്രാ'], |
45 | | -['([ക-ഹ])ൃi', '', '$2്രി'], |
46 | | -['([ക-ഹ])ൃI', '', '$2്രീ'], |
47 | | -['([ക-ഹ])ൃu', '', '$2്രു'], |
48 | | -['([ക-ഹ])ൃU', '', '$2്രൂ'], |
49 | | -['([ക-ഹ])ൃe', '', '$2്രെ'], |
50 | | -['([ക-ഹ])ൃE', '', '$2്രേ'], |
51 | | -['([ക-ഹ])ൃo', '', '$2്രൊ'], |
52 | | -['([ക-ഹ])ൃO', '', '$2്രോ'], |
53 | | -['([ക-ഹ])്(l|L)', '', '$2്ല്'], |
| 37 | +['([ക-ഹ])്ല്l', 'L', '$1\u0d62'], |
| 38 | +['([ക-ഹ])\u0d62l', '', '$1\u0d63'], |
| 39 | +['([അ-ഊഌഎ-ഐഒ-ഹ])([ഽ-ൂെ-ൌൗ])+R', '', '$1$2റ്'], |
| 40 | +['([ക-ഹ])ൃa', '', '$1്ര'], |
| 41 | +['([ക-ഹ])ൃA', '', '$1്രാ'], |
| 42 | +['([ക-ഹ])ൃi', '', '$1്രി'], |
| 43 | +['([ക-ഹ])ൃI', '', '$1്രീ'], |
| 44 | +['([ക-ഹ])ൃu', '', '$1്രു'], |
| 45 | +['([ക-ഹ])ൃU', '', '$1്രൂ'], |
| 46 | +['([ക-ഹ])ൃe', '', '$1്രെ'], |
| 47 | +['([ക-ഹ])ൃE', '', '$1്രേ'], |
| 48 | +['([ക-ഹ])ൃo', '', '$1്രൊ'], |
| 49 | +['([ക-ഹ])ൃO', '', '$1്രോ'], |
| 50 | +['([ക-ഹ])്(l|L)', '', '$1്ല്'], |
54 | 51 | ['അa', '', 'ആ'], |
55 | 52 | ['അi', '', 'ഐ'], |
56 | 53 | ['അu', '', 'ഔ'], |
— | — | @@ -104,12 +101,12 @@ |
105 | 102 | ['ംo', '', 'മൊ'], |
106 | 103 | ['ംO', '', 'മോ'], |
107 | 104 | ['ംm', '', 'മ്മ്'], |
108 | | -['([^സ])ംr', '', '$2മ്ര്'], |
| 105 | +['([^സ])ംr', '', '$1മ്ര്'], |
109 | 106 | ['ംp', '', 'മ്പ്'], |
110 | | -['([^സ])ം(l|L)', '', '$2മ്ല്'], |
| 107 | +['([^സ])ം(l|L)', '', '$1മ്ല്'], |
111 | 108 | ['ം~', '', 'മ്'], |
112 | | -['([^സ])ംn', '', '$2മ്ന്'], |
113 | | -['([^സ])ംy', '', '$2മ്യ്'], |
| 109 | +['([^സ])ംn', '', '$1മ്ന്'], |
| 110 | +['([^സ])ംy', '', '$1മ്യ്'], |
114 | 111 | ['സ്h', '', 'ഷ്'], |
115 | 112 | ['ശ്h', '', 'ഴ്'], |
116 | 113 | ['ൺ\\\\\\\\', '', 'ണ്\u200d'], // old style chillu N |
— | — | @@ -158,86 +155,86 @@ |
159 | 156 | ['ൿ(l|L)', '', 'ക്ല്'], |
160 | 157 | ['ൿv', '', 'ക്വ്'], |
161 | 158 | ['ൿ(k|c)', '', 'ക്ക്'], |
162 | | -['([ക-ഹ])a', '', '$2ാ'], |
163 | | -['([ക-ഹ])്a', '', '$2'], |
| 159 | +['([ക-ഹ])a', '', '$1ാ'], |
| 160 | +['([ക-ഹ])്a', '', '$1'], |
164 | 161 | ['ൺa', '', 'ണ'], |
165 | 162 | ['ൻa', '', 'ന'], |
166 | 163 | ['ർa', '', 'ര'], |
167 | 164 | ['ൽa', '', 'ല'], |
168 | 165 | ['ൾa', '', 'ള'], |
169 | 166 | ['ൿa', '', 'ക'], |
170 | | -['([ക-ഹ])്A', '', '$2ാ'], |
| 167 | +['([ക-ഹ])്A', '', '$1ാ'], |
171 | 168 | ['ൺA', '', 'ണാ'], |
172 | 169 | ['ൻA', '', 'നാ'], |
173 | 170 | ['ർA', '', 'രാ'], |
174 | 171 | ['ൽA', '', 'ലാ'], |
175 | 172 | ['ൾA', '', 'ളാ'], |
176 | 173 | ['ൿA', '', 'കാ'], |
177 | | -['([ക-ഹ])്i', '', '$2ി'], |
| 174 | +['([ക-ഹ])്i', '', '$1ി'], |
178 | 175 | ['ൺi', '', 'ണി'], |
179 | 176 | ['ൻi', '', 'നി'], |
180 | 177 | ['ർi', '', 'രി'], |
181 | 178 | ['ൽi', '', 'ലി'], |
182 | 179 | ['ൾi', '', 'ളി'], |
183 | 180 | ['ൿi', '', 'കി'], |
184 | | -['([ക-ഹ])്I', '', '$2ീ'], |
| 181 | +['([ക-ഹ])്I', '', '$1ീ'], |
185 | 182 | ['ൺI', '', 'ണീ'], |
186 | 183 | ['ൻI', '', 'നീ'], |
187 | 184 | ['ർI', '', 'രീ'], |
188 | 185 | ['ൽI', '', 'ലീ'], |
189 | 186 | ['ൾI', '', 'ളീ'], |
190 | 187 | ['ൿI', '', 'കീ'], |
191 | | -['([ക-ഹ])ിi', '', '$2ീ'], |
192 | | -['([ക-ഹ])െe', '', '$2ീ'], |
193 | | -['([ക-ഹ])്u', '', '$2ു'], |
| 188 | +['([ക-ഹ])ിi', '', '$1ീ'], |
| 189 | +['([ക-ഹ])െe', '', '$1ീ'], |
| 190 | +['([ക-ഹ])്u', '', '$1ു'], |
194 | 191 | ['ൺu', '', 'ണു'], |
195 | 192 | ['ൻu', '', 'നു'], |
196 | 193 | ['ർu', '', 'രു'], |
197 | 194 | ['ൽu', '', 'ലു'], |
198 | 195 | ['ൾu', '', 'ളു'], |
199 | 196 | ['ൿu', '', 'കു'], |
200 | | -['([ക-ഹ])്U', '', '$2ൂ'], |
201 | | -['([ക-ഹ])ുu', '', '$2ൂ'], |
| 197 | +['([ക-ഹ])്U', '', '$1ൂ'], |
| 198 | +['([ക-ഹ])ുu', '', '$1ൂ'], |
202 | 199 | ['ൺU', '', 'ണൂ'], |
203 | 200 | ['ൻU', '', 'നൂ'], |
204 | 201 | ['ർU', '', 'രൂ'], |
205 | 202 | ['ൽU', '', 'ലൂ'], |
206 | 203 | ['ൾU', '', 'ളൂ'], |
207 | 204 | ['ൿU', '', 'കൂ'], |
208 | | -['([ക-ഹ])ൊo', '', '$2ൂ'], |
209 | | -['([ക-ഹ])ൃR', '', '$2ൄ'], |
210 | | -['([ക-ഹ])്e', '', '$2െ'], |
| 205 | +['([ക-ഹ])ൊo', '', '$1ൂ'], |
| 206 | +['([ക-ഹ])ൃR', '', '$1ൄ'], |
| 207 | +['([ക-ഹ])്e', '', '$1െ'], |
211 | 208 | ['ൺe', '', 'ണെ'], |
212 | 209 | ['ൻe', '', 'നെ'], |
213 | 210 | ['ർe', '', 'രെ'], |
214 | 211 | ['ൽe', '', 'ലെ'], |
215 | 212 | ['ൾe', '', 'ളെ'], |
216 | 213 | ['ൿe', '', 'കെ'], |
217 | | -['([ക-ഹ])്E', '', '$2േ'], |
| 214 | +['([ക-ഹ])്E', '', '$1േ'], |
218 | 215 | ['ൺE', '', 'ണേ'], |
219 | 216 | ['ൻE', '', 'നേ'], |
220 | 217 | ['ർE', '', 'രേ'], |
221 | 218 | ['ൽE', '', 'ലേ'], |
222 | 219 | ['ൾE', '', 'ളേ'], |
223 | 220 | ['ൿE', '', 'കേ'], |
224 | | -['([ക-ഹ])i', '', '$2ൈ'], |
225 | | -['([ക-ഹ])്o', '', '$2ൊ'], |
| 221 | +['([ക-ഹ])i', '', '$1ൈ'], |
| 222 | +['([ക-ഹ])്o', '', '$1ൊ'], |
226 | 223 | ['ൺo', '', 'ണൊ'], |
227 | 224 | ['ൻo', '', 'നൊ'], |
228 | 225 | ['ർo', '', 'രൊ'], |
229 | 226 | ['ൽo', '', 'ലൊ'], |
230 | 227 | ['ൾo', '', 'ളൊ'], |
231 | 228 | ['ൿo', '', 'കൊ'], |
232 | | -['([ക-ഹ])്O', '', '$2ോ'], |
| 229 | +['([ക-ഹ])്O', '', '$1ോ'], |
233 | 230 | ['ൺO', '', 'ണോ'], |
234 | 231 | ['ൻO', '', 'നോ'], |
235 | 232 | ['ർO', '', 'രോ'], |
236 | 233 | ['ൽO', '', 'ലോ'], |
237 | 234 | ['ൾO', '', 'ളോ'], |
238 | 235 | ['ൿO', '', 'കോ'], |
239 | | -['([ക-ഹ])u', '', '$2ൗ'], |
240 | | -['([ക-ഹ])U', '', '$2ൌ'], |
241 | | -['([അ-്])m', '', '$2ം'], |
| 236 | +['([ക-ഹ])u', '', '$1ൗ'], |
| 237 | +['([ക-ഹ])U', '', '$1ൌ'], |
| 238 | +['([അ-്])m', '', '$1ം'], |
242 | 239 | ['\\\\0', '', '൦'], // escape to ml digit 0 by \0 |
243 | 240 | ['\\\\1', '', '൧'], // escape to ml digit 1 by \1 |
244 | 241 | ['\\\\2', '', '൨'], // escape to ml digit 2 by \2 |
— | — | @@ -265,56 +262,56 @@ |
266 | 263 | ['ൗ\\\\', '', 'ൌ'], |
267 | 264 | ['ഌ\\\\', '', 'ൢ'], |
268 | 265 | ['ൡ\\\\', '', 'ൣ'], |
269 | | -['(([ൺ-ൿം])\u200c+)?A', '', '$3ആ'], |
270 | | -['(([ൺ-ൿം])\u200c+)?B', '', '$3ബ്ബ്'], |
271 | | -['(([ൺ-ൿം])\u200c+)?C', '', '$3ച്ച്'], |
272 | | -['(([ൺ-ൿം])\u200c+)?D', '', '$3ഡ്'], |
273 | | -['(([ൺ-ൿം])\u200c+)?E', '', '$3ഏ'], |
274 | | -['(([ൺ-ൿം])\u200c+)?F', '', '$3ഫ്'], |
275 | | -['(([ൺ-ൿം])\u200c+)?G', '', '$3ഗ്ഗ്'], |
276 | | -['(([ൺ-ൿം])\u200c+)?H', '', '$3ഃ'], |
277 | | -['(([ൺ-ൿം])\u200c+)?I', '', '$3ഐ'], |
278 | | -['(([ൺ-ൿം])\u200c+)?J', '', '$3ജ്ജ്'], |
279 | | -['(([ൺ-ൿം])\u200c+)?K', '', '$3ക്ക്'], |
280 | | -['(([ൺ-ൿം])\u200c+)?L', '', '$3ൾ'], |
281 | | -['(([ൺ-ൿം])\u200c+)?M', '', '$3മ്മ്'], |
282 | | -['(([ൺ-ൿം])\u200c+)?N', '', '$3ൺ'], |
283 | | -['(([ൺ-ൿം])\u200c+)?O', '', '$3ഓ'], |
284 | | -['(([ൺ-ൿം])\u200c+)?P', '', '$3പ്പ്'], |
285 | | -['(([ൺ-ൿം])\u200c+)?Q', '', '$3ക്യ്'], |
286 | | -['(([ൺ-ൿം])\u200c+)?R', '', '$3ഋ'], |
287 | | -['(([ൺ-ൿം])\u200c+)?(S|z)', '', '$3ശ്'], |
288 | | -['(([ൺ-ൿം])\u200c+)?T', '', '$3ട്'], |
289 | | -['(([ൺ-ൿം])\u200c+)?U', '', '$3ഊ'], |
290 | | -['(([ൺ-ൿം])\u200c+)?(V|W)', '', '$3വ്വ്'], |
291 | | -['(([ൺ-ൿം])\u200c+)?X', '', '$3ക്ഷ്'], |
292 | | -['(([ൺ-ൿം])\u200c+)?Y', '', '$3യ്യ്'], |
293 | | -['(([ൺ-ൿം])\u200c+)?Z', '', '$3ശ്ശ്'], |
294 | | -['(([ൺ-ൿം])\u200c+)?a', '', '$3അ'], |
295 | | -['(([ൺ-ൿം])\u200c+)?b', '', '$3ബ്'], |
296 | | -['(([ൺ-ൿം])\u200c+)?c', '', '$3ൿ'], |
297 | | -['(([ൺ-ൿം])\u200c+)?d', '', '$3ദ്'], |
298 | | -['(([ൺ-ൿം])\u200c+)?e', '', '$3എ'], |
299 | | -['(([ൺ-ൿം])\u200c+)?f', '', '$3ഫ്'], |
300 | | -['(([ൺ-ൿം])\u200c+)?g', '', '$3ഗ്'], |
301 | | -['(([ൺ-ൿം])\u200c+)?h', '', '$3ഹ്'], |
302 | | -['(([ൺ-ൿം])\u200c+)?i', '', '$3ഇ'], |
303 | | -['(([ൺ-ൿം])\u200c+)?j', '', '$3ജ്'], |
304 | | -['(([ൺ-ൿം])\u200c+)?k', '', '$3ക്'], |
305 | | -['(([ൺ-ൿം])\u200c+)?l', '', '$3ൽ'], |
306 | | -['(([ൺ-ൿം])\u200c+)?m', '', '$3മ്'], |
307 | | -['(([ൺ-ൿം])\u200c+)?n', '', '$3ൻ'], |
308 | | -['(([ൺ-ൿം])\u200c+)?o', '', '$3ഒ'], |
309 | | -['(([ൺ-ൿം])\u200c+)?p', '', '$3പ്'], |
310 | | -['(([ൺ-ൿം])\u200c+)?q', '', '$3ക്ക്'], |
311 | | -['(([ൺ-ൿം])\u200c+)?r', '', '$3ർ'], |
312 | | -['(([ൺ-ൿം])\u200c+)?s', '', '$3സ്'], |
313 | | -['(([ൺ-ൿം])\u200c+)?t', '', '$3റ്റ്'], // tta according to 5.1 |
314 | | -['(([ൺ-ൿം])\u200c+)?u', '', '$3ഉ'], |
315 | | -['(([ൺ-ൿം])\u200c+)?(v|w)', '', '$3വ്'], |
316 | | -['(([ൺ-ൿം])\u200c+)?x', '', '$3ക്ഷ്'], |
317 | | -['(([ൺ-ൿം])\u200c+)?y', '', '$3യ്'], |
318 | | -['(([ൺ-ൿം])\u200c+)?~', '', '$3്'], |
| 266 | +['(([ൺ-ൿം])\u200c+)?A', '', '$2ആ'], |
| 267 | +['(([ൺ-ൿം])\u200c+)?B', '', '$2ബ്ബ്'], |
| 268 | +['(([ൺ-ൿം])\u200c+)?C', '', '$2ച്ച്'], |
| 269 | +['(([ൺ-ൿം])\u200c+)?D', '', '$2ഡ്'], |
| 270 | +['(([ൺ-ൿം])\u200c+)?E', '', '$2ഏ'], |
| 271 | +['(([ൺ-ൿം])\u200c+)?F', '', '$2ഫ്'], |
| 272 | +['(([ൺ-ൿം])\u200c+)?G', '', '$2ഗ്ഗ്'], |
| 273 | +['(([ൺ-ൿം])\u200c+)?H', '', '$2ഃ'], |
| 274 | +['(([ൺ-ൿം])\u200c+)?I', '', '$2ഐ'], |
| 275 | +['(([ൺ-ൿം])\u200c+)?J', '', '$2ജ്ജ്'], |
| 276 | +['(([ൺ-ൿം])\u200c+)?K', '', '$2ക്ക്'], |
| 277 | +['(([ൺ-ൿം])\u200c+)?L', '', '$2ൾ'], |
| 278 | +['(([ൺ-ൿം])\u200c+)?M', '', '$2മ്മ്'], |
| 279 | +['(([ൺ-ൿം])\u200c+)?N', '', '$2ൺ'], |
| 280 | +['(([ൺ-ൿം])\u200c+)?O', '', '$2ഓ'], |
| 281 | +['(([ൺ-ൿം])\u200c+)?P', '', '$2പ്പ്'], |
| 282 | +['(([ൺ-ൿം])\u200c+)?Q', '', '$2ക്യ്'], |
| 283 | +['(([ൺ-ൿം])\u200c+)?R', '', '$2ഋ'], |
| 284 | +['(([ൺ-ൿം])\u200c+)?(S|z)', '', '$2ശ്'], |
| 285 | +['(([ൺ-ൿം])\u200c+)?T', '', '$2ട്'], |
| 286 | +['(([ൺ-ൿം])\u200c+)?U', '', '$2ഊ'], |
| 287 | +['(([ൺ-ൿം])\u200c+)?(V|W)', '', '$2വ്വ്'], |
| 288 | +['(([ൺ-ൿം])\u200c+)?X', '', '$2ക്ഷ്'], |
| 289 | +['(([ൺ-ൿം])\u200c+)?Y', '', '$2യ്യ്'], |
| 290 | +['(([ൺ-ൿം])\u200c+)?Z', '', '$2ശ്ശ്'], |
| 291 | +['(([ൺ-ൿം])\u200c+)?a', '', '$2അ'], |
| 292 | +['(([ൺ-ൿം])\u200c+)?b', '', '$2ബ്'], |
| 293 | +['(([ൺ-ൿം])\u200c+)?c', '', '$2ൿ'], |
| 294 | +['(([ൺ-ൿം])\u200c+)?d', '', '$2ദ്'], |
| 295 | +['(([ൺ-ൿം])\u200c+)?e', '', '$2എ'], |
| 296 | +['(([ൺ-ൿം])\u200c+)?f', '', '$2ഫ്'], |
| 297 | +['(([ൺ-ൿം])\u200c+)?g', '', '$2ഗ്'], |
| 298 | +['(([ൺ-ൿം])\u200c+)?h', '', '$2ഹ്'], |
| 299 | +['(([ൺ-ൿം])\u200c+)?i', '', '$2ഇ'], |
| 300 | +['(([ൺ-ൿം])\u200c+)?j', '', '$2ജ്'], |
| 301 | +['(([ൺ-ൿം])\u200c+)?k', '', '$2ക്'], |
| 302 | +['(([ൺ-ൿം])\u200c+)?l', '', '$2ൽ'], |
| 303 | +['(([ൺ-ൿം])\u200c+)?m', '', '$2മ്'], |
| 304 | +['(([ൺ-ൿം])\u200c+)?n', '', '$2ൻ'], |
| 305 | +['(([ൺ-ൿം])\u200c+)?o', '', '$2ഒ'], |
| 306 | +['(([ൺ-ൿം])\u200c+)?p', '', '$2പ്'], |
| 307 | +['(([ൺ-ൿം])\u200c+)?q', '', '$2ക്ക്'], |
| 308 | +['(([ൺ-ൿം])\u200c+)?r', '', '$2ർ'], |
| 309 | +['(([ൺ-ൿം])\u200c+)?s', '', '$2സ്'], |
| 310 | +['(([ൺ-ൿം])\u200c+)?t', '', '$2റ്റ്'], // tta according to 5.1 |
| 311 | +['(([ൺ-ൿം])\u200c+)?u', '', '$2ഉ'], |
| 312 | +['(([ൺ-ൿം])\u200c+)?(v|w)', '', '$2വ്'], |
| 313 | +['(([ൺ-ൿം])\u200c+)?x', '', '$2ക്ഷ്'], |
| 314 | +['(([ൺ-ൿം])\u200c+)?y', '', '$2യ്'], |
| 315 | +['(([ൺ-ൿം])\u200c+)?~', '', '$2്'], |
319 | 316 | ['(\u200C)*_', '', '\u200c'], |
320 | 317 | ['//', '', 'ऽ'], |
321 | 318 | ['1/4\\\\', '', '൳'], |
— | — | @@ -329,3 +326,10 @@ |
330 | 327 | ['\\\\\\*', '', '×'], |
331 | 328 | ['\\\\/', '', '÷'] |
332 | 329 | ]; |
| 330 | + |
| 331 | +jQuery.narayam.addScheme( 'ml', { |
| 332 | + 'namemsg': 'narayam-ml', |
| 333 | + 'extended_keyboard': false, |
| 334 | + 'lookbackLength': 2, |
| 335 | + 'rules': rules |
| 336 | +} ); |
Index: trunk/extensions/Narayam/bn_inscript_rules.js |
— | — | @@ -5,12 +5,9 @@ |
6 | 6 | * @date 2010-12-12 |
7 | 7 | * License: GPLv3, CC-BY-SA 3.0 |
8 | 8 | */ |
9 | | -if(tr_bn_inscript== undefined) var tr_bn_inscript = {}; |
10 | | -else tr_bn_inscript = {}; |
11 | | -tr_bn_inscript.text = "InScript"; |
12 | | -tr_bn_inscript.description = "InScript layout for Bengali"; |
| 9 | + |
13 | 10 | // Normal rules |
14 | | -tr_bn_inscript.rules = [ |
| 11 | +var rules = [ |
15 | 12 | ['X', '', 'ঁ'], |
16 | 13 | ['x', '', 'ং'], |
17 | 14 | ['_', '', 'ঃ'], |
— | — | @@ -95,8 +92,7 @@ |
96 | 93 | ]; |
97 | 94 | |
98 | 95 | // Extended layout for InScript. Works in Firefox only |
99 | | -tr_bn_inscript.extended_keyboard = true; |
100 | | -tr_bn_inscript.rules_x = [ |
| 96 | +var rules_x = [ |
101 | 97 | ['F', '', 'ঌ'], |
102 | 98 | ['\\>', '', 'ঽ'], |
103 | 99 | ['\\=', '', 'ৠ'], |
— | — | @@ -120,3 +116,11 @@ |
121 | 117 | ['\\?', '', '৻'], |
122 | 118 | ['4', '', '₹'] |
123 | 119 | ]; |
| 120 | + |
| 121 | +jQuery.narayam.addScheme( 'bn-inscript', { |
| 122 | + 'namemsg': 'narayam-bn-inscript', |
| 123 | + 'extended_keyboard': true, |
| 124 | + 'lookbackLength': 0, |
| 125 | + 'rules': rules, |
| 126 | + 'rules_x': rules_x |
| 127 | +} ); |
Index: trunk/extensions/Narayam/Narayam.hooks.php |
— | — | @@ -0,0 +1,43 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Hooks for Narayam extension |
| 5 | + * @file |
| 6 | + * @ingroup Extensions |
| 7 | + */ |
| 8 | +class NarayamHooks { |
| 9 | + public static function addModules( $out, $skin ) { |
| 10 | + $schemes = array_values( self::getSchemes () ); |
| 11 | + if ( count( $schemes ) ) { |
| 12 | + $out->addModules( $schemes ); |
| 13 | + $out->addModules( 'ext.narayam' ); |
| 14 | + } |
| 15 | + return true; |
| 16 | + } |
| 17 | + |
| 18 | + public static function addConfig( &$vars ) { |
| 19 | + global $wgNarayamEnabledByDefault, $wgNarayamShortcutKey; |
| 20 | + $vars['wgNarayamEnabledByDefault'] = $wgNarayamEnabledByDefault; |
| 21 | + $vars['wgNarayamShortcutKey'] = $wgNarayamShortcutKey; |
| 22 | + |
| 23 | + return true; |
| 24 | + } |
| 25 | + |
| 26 | + public static function addVariables( &$vars ) { |
| 27 | + $vars['wgNarayamAvailableSchemes'] = self::getSchemes(); // Note: scheme names must be keys, not values |
| 28 | + return true; |
| 29 | + } |
| 30 | + |
| 31 | + /** |
| 32 | + * Get the available schemes for the user and content language |
| 33 | + * @return array( scheme name => module name ) |
| 34 | + */ |
| 35 | + protected static function getSchemes() { |
| 36 | + global $wgLanguageCode, $wgLang, $wgNarayamSchemes; |
| 37 | + $userlangCode = $wgLang->getCode(); |
| 38 | + $contlangSchemes = isset( $wgNarayamSchemes[$wgLanguageCode] ) ? |
| 39 | + $wgNarayamSchemes[$wgLanguageCode] : array(); |
| 40 | + $userlangSchemes = isset( $wgNarayamSchemes[$userlangCode] ) ? |
| 41 | + $wgNarayamSchemes[$userlangCode] : array(); |
| 42 | + return $userlangSchemes + $contlangSchemes; |
| 43 | + } |
| 44 | +} |
Property changes on: trunk/extensions/Narayam/Narayam.hooks.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 45 | + native |
Index: trunk/extensions/Narayam/ext.narayam.js |
— | — | @@ -0,0 +1,9 @@ |
| 2 | +/** |
| 3 | + * Narayam startup script |
| 4 | + */ |
| 5 | +( function( $ ) { |
| 6 | + $( document ).ready( function() { |
| 7 | + $.narayam.addInputs( 'input[type=text], input[type=search], input[type=], textarea' ); |
| 8 | + $.narayam.setup(); |
| 9 | + } ); |
| 10 | +} )( jQuery ); |
Property changes on: trunk/extensions/Narayam/ext.narayam.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 11 | + native |
Index: trunk/extensions/Narayam/Narayam.js |
— | — | @@ -8,579 +8,328 @@ |
9 | 9 | * License: GPLv3, CC-BY-SA 3.0 |
10 | 10 | */ |
11 | 11 | |
12 | | -var Narayam = {}; |
| 12 | +( function( $ ) { |
| 13 | +$.narayam = new ( function() { |
| 14 | + /* Private members */ |
| 15 | + |
| 16 | + // Reference to this object |
| 17 | + var that = this; |
| 18 | + // jQuery array holding all text inputs Narayam applies to |
| 19 | + var $inputs = $( [] ); |
| 20 | + // Input method dropdown |
| 21 | + var $select = $( [] ); |
| 22 | + // Whether Narayam is enabled |
| 23 | + var enabled = false; |
| 24 | + // Registered schemes |
| 25 | + var schemes = {}; |
| 26 | + // List of scheme names, ordered for presentation purposes |
| 27 | + // Schemes not in this list won't be allowed to register |
| 28 | + // This object is formatted as { 'schemename': '', 'schemename2': '', ... } |
| 29 | + // for easy searching |
| 30 | + var availableSchemes = mw.config.get( 'wgNarayamAvailableSchemes' ) || {}; |
| 31 | + // Currently selected scheme |
| 32 | + var currentScheme = null; |
| 33 | + // Shortcut key |
| 34 | + var shortcutKey = mw.config.get( 'wgNarayamShortcutKey' ) || { |
| 35 | + altKey: false, |
| 36 | + ctrlKey: false, |
| 37 | + shiftKey: false, |
| 38 | + key: null |
| 39 | + }; |
| 40 | + |
| 41 | + /* Private functions */ |
| 42 | + |
| 43 | + /** |
| 44 | + * Transliterate a string using the current scheme |
| 45 | + * @param str String to transliterate |
| 46 | + * @param lookback The lookback buffer |
| 47 | + * @param useExtended Whether to use the extended part of the scheme |
| 48 | + * @return Transliterated string, or str if no applicable transliteration found. |
| 49 | + */ |
| 50 | + function transliterate( str, lookback, useExtended ) { |
| 51 | + var rules = currentScheme.extended_keyboard && useExtended ? |
| 52 | + currentScheme.rules_x : currentScheme.rules; |
| 53 | + for ( var i = 0; i < rules.length; i++ ) { |
| 54 | + var lookbackMatch = true; |
| 55 | + if ( rules[i][1].length > 0 && rules[i][1].length <= lookback.length ) { |
| 56 | + // Try to match rules[i][1] at the end of the lookback buffer |
| 57 | + lookbackMatch = new RegExp( rules[i][1] + '$' ).test( lookback ); |
| 58 | + } |
| 59 | + var regex = new RegExp( rules[i][0] + '$' ); |
| 60 | + if ( lookbackMatch && regex.test( str ) ) { |
| 61 | + return str.replace( regex, rules[i][2] ); |
| 62 | + } |
| 63 | + } |
| 64 | + // No matches, return the input |
| 65 | + return str; |
| 66 | + } |
| 67 | + |
| 68 | + /** |
| 69 | + * Get the n characters in str that immediately precede pos |
| 70 | + * Example: lastNChars( "foobarbaz", 5, 2 ) == "ba" |
| 71 | + * @param str String to search in |
| 72 | + * @param pos Position in str |
| 73 | + * @param n Number of characters to go back from pos |
| 74 | + * @return Substring of str, at most n characters long, immediately preceding pos |
| 75 | + */ |
| 76 | + function lastNChars( str, pos, n ) { |
| 77 | + if ( n == 0 ) { |
| 78 | + return ''; |
| 79 | + } |
| 80 | + if ( pos <= n ) { |
| 81 | + return str.substr( 0, pos ); |
| 82 | + } else { |
| 83 | + return str.substr( pos - n, n); |
| 84 | + } |
| 85 | + } |
| 86 | + |
| 87 | + /** |
| 88 | + * Find the point at which a and b diverge, i.e. the first position |
| 89 | + * at which they don't have matching characters. |
| 90 | + * @param a String |
| 91 | + * @param b String |
| 92 | + * @return Position at which a and b diverge, or -1 if a == b |
| 93 | + */ |
| 94 | + function firstDivergence( a, b ) { |
| 95 | + var minLength = a.length < b.length ? a.length : b.length; |
| 96 | + for ( var i = 0; i < minLength; i++ ) { |
| 97 | + if ( a.charCodeAt( i ) !== b.charCodeAt( i ) ) { |
| 98 | + return i; |
| 99 | + } |
| 100 | + } |
| 101 | + return -1; |
| 102 | + } |
| 103 | + |
| 104 | + function isShortcutKey( e ) { |
| 105 | + return e.altKey == shortcutKey.altKey && |
| 106 | + e.ctrlKey == shortcutKey.ctrlKey && |
| 107 | + e.shiftKey == shortcutKey.shiftKey && |
| 108 | + String.fromCharCode( e.which ).toLowerCase() == shortcutKey.key.toLowerCase() |
| 109 | + } |
| 110 | + |
| 111 | + function shortcutText() { |
| 112 | + var text = ''; |
| 113 | + // TODO: Localize these things (in core, too) |
| 114 | + if ( shortcutKey.ctrlKey ) { |
| 115 | + text += 'Ctrl-'; |
| 116 | + } |
| 117 | + if ( shortcutKey.shiftKey ) { |
| 118 | + text += 'Shift-'; |
| 119 | + } |
| 120 | + if ( shortcutKey.altKey ) { |
| 121 | + text += 'Alt-'; |
| 122 | + } |
| 123 | + text += shortcutKey.key.toUpperCase(); |
| 124 | + return text; |
| 125 | + } |
| 126 | + |
| 127 | + function onkeydown( e ) { |
| 128 | + // If the current scheme uses the alt key, ignore keydown for Alt+? combinations |
| 129 | + if ( enabled && currentScheme.extended_keyboard && e.altKey && !e.ctrlKey ) { |
| 130 | + e.stopPropagation(); |
| 131 | + return false; // Not in original code -- does this belong here? |
| 132 | + } else if ( isShortcutKey( e ) ) { |
| 133 | + that.toggle(); |
| 134 | + e.stopPropagation(); |
| 135 | + return false; |
| 136 | + } |
| 137 | + return true; |
| 138 | + } |
| 139 | + |
| 140 | + function onkeypress( e ) { |
| 141 | + if ( !enabled ) { |
| 142 | + return true; |
| 143 | + } |
| 144 | + |
| 145 | + if ( e.which == 8 ) { // Backspace |
| 146 | + // Blank the lookback buffer |
| 147 | + $( this ).data( 'narayam-lookback', '' ); |
| 148 | + return true; |
| 149 | + } |
| 150 | + |
| 151 | + // Leave non-ASCII stuff alone, as well as anything involving |
| 152 | + // Alt (except for extended keymaps), Ctrl and Meta |
| 153 | + if ( e.which < 32 || ( e.altKey && !currentScheme.extended_keyboard ) || e.ctrlKey ) { |
| 154 | + return true; |
| 155 | + } |
| 156 | + |
| 157 | + var $this = $( this ); |
| 158 | + var c = String.fromCharCode( e.which ); |
| 159 | + var pos = $this.textSelection( 'getCaretPosition' ); |
| 160 | + // Get the last few characters before the one the user just typed, |
| 161 | + // to provide context for the transliteration regexes. |
| 162 | + // We need to append c because it hasn't been added to $this.val() yet |
| 163 | + var input = lastNChars( $this.val(), pos, currentScheme.lookbackLength ) + c; |
| 164 | + var lookback = $this.data( 'narayam-lookback' ); |
| 165 | + var replacement = transliterate( input, lookback, e.altKey ); |
| 166 | + |
| 167 | + // Update the lookback buffer |
| 168 | + lookback += c; |
| 169 | + if ( lookback.length > currentScheme.lookbackLength ) { |
| 170 | + // The buffer is longer than needed, truncate it at the front |
| 171 | + lookback = lookback.substring( lookback.length - currentScheme.lookbackLength ); |
| 172 | + } |
| 173 | + $this.data( 'narayam-lookback', lookback ); |
| 174 | + |
| 175 | + // textSelection() magic is expensive, so we avoid it as much as we can |
| 176 | + if ( replacement == input ) { |
| 177 | + return true; |
| 178 | + } |
| 179 | + // Drop a common prefix, if any |
| 180 | + // TODO: Profile this, see if it's any faster |
| 181 | + var divergingPos = firstDivergence( input, replacement ); |
| 182 | + input = input.substring( divergingPos ); |
| 183 | + replacement = replacement.substring( divergingPos ); |
| 184 | + |
| 185 | + // Select and replace the text |
| 186 | + $this.textSelection( 'setSelection', { |
| 187 | + 'start': pos - input.length + 1, |
| 188 | + 'end': pos |
| 189 | + } ); |
| 190 | + $this.textSelection( 'encapsulateSelection', { |
| 191 | + 'peri': replacement, |
| 192 | + 'replace': true, |
| 193 | + 'selectPeri': false |
| 194 | + } ); |
| 195 | + |
| 196 | + e.stopPropagation(); |
| 197 | + return false; |
| 198 | + } |
| 199 | + |
| 200 | + function updateSchemeFromSelect() { |
| 201 | + var scheme = $( this ).val(); |
| 202 | + that.setScheme( scheme ); |
| 203 | + $.cookie( 'narayam-scheme', scheme, { 'path': '/', 'expires': 30 } ); |
| 204 | + } |
| 205 | + |
| 206 | + /* Public functions */ |
13 | 207 | |
14 | | -/** |
15 | | - * from: http://stackoverflow.com/questions/3053542/how-to-get-the-start-and-end-points-of-selection-in-text-area/3053640#3053640 |
16 | | - */ |
17 | | -function GetCaretPosition(el) { |
18 | | - var start = 0, end = 0, normalizedValue, range, |
19 | | - textInputRange, len, endRange; |
20 | | - |
21 | | - if (typeof el.selectionStart == "number" && typeof el.selectionEnd == "number") { |
22 | | - start = el.selectionStart; |
23 | | - end = el.selectionEnd; |
24 | | - } else { |
25 | | - range = document.selection.createRange(); |
26 | | - if (range && range.parentElement() == el) { |
27 | | - len = el.value.length; |
28 | | - normalizedValue = el.value.replace(/\r\n/g, "\n"); |
29 | | - |
30 | | - // Create a working TextRange that lives only in the input |
31 | | - textInputRange = el.createTextRange(); |
32 | | - textInputRange.moveToBookmark(range.getBookmark()); |
33 | | - |
34 | | - // Check if the start and end of the selection are at the very end |
35 | | - // of the input, since moveStart/moveEnd doesn't return what we want |
36 | | - // in those cases |
37 | | - endRange = el.createTextRange(); |
38 | | - endRange.collapse(false); |
39 | | - |
40 | | - if (textInputRange.compareEndPoints("StartToEnd", endRange) > -1) { |
41 | | - start = end = len; |
42 | | - } else { |
43 | | - start = -textInputRange.moveStart("character", -len); |
44 | | - start += normalizedValue.slice(0, start).split("\n").length - 1; |
45 | | - |
46 | | - if (textInputRange.compareEndPoints("EndToEnd", endRange) > -1) { |
47 | | - end = len; |
48 | | - } else { |
49 | | - end = -textInputRange.moveEnd("character", -len); |
50 | | - end += normalizedValue.slice(0, end).split("\n").length - 1; |
51 | | - } |
52 | | - } |
53 | | - } |
54 | | - } |
55 | | - return { |
56 | | - start: start, |
57 | | - end: end |
58 | | - }; |
59 | | -} |
60 | | - |
61 | | -/** |
62 | | - * from: http://stackoverflow.com/questions/3274843/get-caret-position-in-textarea-ie |
63 | | - */ |
64 | | -function offsetToRangeCharacterMove(el, offset) { |
65 | | - return offset - (el.value.slice(0, offset).split("\r\n").length - 1); |
66 | | -} |
67 | | -/** |
68 | | - * IE part from: http://stackoverflow.com/questions/3274843/get-caret-position-in-textarea-ie |
69 | | - */ |
70 | | -function setCaretPosition (el, iCaretPos) |
71 | | -{ |
72 | | - if (document.selection) // IE |
73 | | - { |
74 | | - endOffset = startOffset=iCaretPos; |
75 | | - var range = el.createTextRange(); |
76 | | - var startCharMove = offsetToRangeCharacterMove(el, startOffset); |
77 | | - range.collapse(true); |
78 | | - if (startOffset == endOffset) { |
79 | | - range.move("character", startCharMove); |
80 | | - } else { |
81 | | - range.moveEnd("character", offsetToRangeCharacterMove(el, endOffset)); |
82 | | - range.moveStart("character", startCharMove); |
83 | | - } |
84 | | - range.select(); |
85 | | - } |
86 | | - else if (el.selectionStart || el.selectionStart == '0') // Firefox |
87 | | - { |
88 | | - el.setSelectionRange(iCaretPos, iCaretPos) |
89 | | - } |
90 | | -} |
91 | | - |
92 | | -function getAllTextInputs() { |
93 | | - var inputs = document.getElementsByTagName('input'); |
94 | | - var textInputs = []; |
95 | | - var count = inputs.length; |
96 | | - for(var i=0; i < count; i++) { |
97 | | - element = inputs[i]; |
98 | | - if(element.getAttribute('type')==='text' || element.getAttribute('type')==='search' || element.getAttribute('type')==='' || element.getAttribute('type')== undefined) { |
99 | | - textInputs.push(element); |
100 | | - } |
101 | | - } |
102 | | - return textInputs; |
103 | | -} |
104 | | - |
105 | | -function getLastNChars(str, caretPosition, numberOfChars) |
106 | | -{ |
107 | | - if(caretPosition <= numberOfChars ) return str.substring(0,caretPosition); |
108 | | - else return str.substring(caretPosition-numberOfChars,caretPosition); |
109 | | -} |
110 | | - |
111 | | -function replaceTransStringAtCaret(control, oldStringLength, newString, selectionRange) |
112 | | -{ |
113 | | - var text = control.value; |
114 | | - var newCaretPosition; |
115 | | - // firefox always scrolls to topmost position, |
116 | | - // to scroll manually we keep original scroll postion. |
117 | | - if(control.scrollTop || control.scrollTop=='0') { |
118 | | - var scrollTop = control.scrollTop; |
119 | | - } |
120 | | - if(text.length >= 1) { |
121 | | - var firstStr = text.substring(0, selectionRange['start'] - oldStringLength + 1); |
122 | | - var lastStr = text.substring(selectionRange['end'], text.length); |
123 | | - control.value = firstStr+newString+ lastStr; |
124 | | - newCaretPosition = firstStr.length+newString.length; |
125 | | - setCaretPosition(control,newCaretPosition); |
126 | | - } |
127 | | - else { |
128 | | - control.value = newString; |
129 | | - newCaretPosition = newString.length; |
130 | | - setCaretPosition(control,newCaretPosition); |
131 | | - } |
132 | | - // Manually scrolling in firefox, few tweeks or re-writing may require |
133 | | - if (navigator.userAgent.indexOf("Firefox")!=-1) { |
134 | | - var textLength = control.value.length; |
135 | | - var cols = control.cols; |
136 | | - if(newCaretPosition > (textLength-cols)) { |
137 | | - //var height = parseInt(window.getComputedStyle(control,null).getPropertyValue('height')); |
138 | | - var fontsize = parseInt(window.getComputedStyle(control,null).getPropertyValue('font-size')); |
139 | | - //var lineheight = height/fontsize; |
140 | | - control.scrollTop = scrollTop+fontsize; |
141 | | - } else control.scrollTop = scrollTop; |
142 | | - } |
143 | | -} |
144 | | - |
145 | | -/** |
146 | | - * This function will take a string to check against regular expression rules in the rules array. |
147 | | - * It will return a two memeber array, having given string as first member and replacement string as |
148 | | - * second memeber. If corresponding replacement could not be found then second string will be too given string |
149 | | -*/ |
150 | | -function transli(lastpart,e, tr_rules) |
151 | | -{ |
152 | | - var rulesCount = tr_rules.length; |
153 | | - var part1 = lastpart; |
154 | | - var part2 = lastpart; |
155 | | - var triple; |
156 | | - for(var i=0 ; i < rulesCount; i++) |
157 | | - { |
158 | | - triple = tr_rules[i]; |
159 | | - var previousKeysMatch = true; |
160 | | - var presentSeq = '(.*)'+triple[0]+'$'; |
161 | | - var replaceSeq = '$1'+triple[2]; |
162 | | - if(triple[1].length > 0) { |
163 | | - previousKeysMatch = (new RegExp('.*'+triple[1]+'$')).test(Narayam.previous_sequence[(e.currentTarget || e.srcElement).id ]); |
164 | | - } |
165 | | - if((new RegExp(presentSeq)).test(lastpart) && previousKeysMatch) |
166 | | - { |
167 | | - part1 = lastpart; |
168 | | - part2 = lastpart.replace(RegExp(presentSeq), replaceSeq); |
169 | | - break; |
170 | | - } |
171 | | - } |
172 | | - var pair = new Array(part1, part2); |
173 | | - return pair; |
174 | | -} |
175 | | -/** |
176 | | - * from: http://www.javascripter.net/faq/settinga.htm |
177 | | - */ |
178 | | -function setCookie(cookieName,cookieValue,nDays) { |
179 | | - var today = new Date(); |
180 | | - var expire = new Date(); |
181 | | - if (nDays==null || nDays==0) nDays=1; |
182 | | - expire.setTime(today.getTime() + 3600000*24*nDays); |
183 | | - document.cookie = cookieName+"="+escape(cookieValue)+ ";expires="+expire.toGMTString()+";path=/"; |
184 | | -} |
185 | | -/** |
186 | | - * from: http://www.javascripter.net/faq/readinga.htm |
187 | | - */ |
188 | | -function readCookie(cookieName) { |
189 | | - var theCookie=""+document.cookie; |
190 | | - var ind=theCookie.indexOf(cookieName); |
191 | | - if (ind==-1 || cookieName=="") return ""; |
192 | | - var ind1=theCookie.indexOf(';',ind); |
193 | | - if (ind1==-1) ind1=theCookie.length; |
194 | | - return unescape(theCookie.substring(ind+cookieName.length+1,ind1)); |
195 | | -} |
196 | | - |
197 | | -Narayam.enableTrasliteration = function(enable) { |
198 | | - if(enable==undefined) { |
199 | | - enable = true; |
200 | | - } |
201 | | - var cookieValue; |
202 | | - Narayam.enabled = enable; |
203 | | - var count= Narayam.elements.length; |
204 | | - for(var i=0; i < count; i++) { |
205 | | - var element = Narayam.elements[i]; |
206 | | - if(!element.style) { |
207 | | - element.style = new CSS2Properties(); |
208 | | - } |
209 | | - if(Narayam.enabled) { |
210 | | - //Narayam.elementBorders[element.id] = element.style.border; |
211 | | - element.style.border = Narayam.border; |
212 | | - //Narayam.elementBackColors[element.id] = element.style.backgroundColor; |
213 | | - element.style.backgroundColor = Narayam.back_color; |
214 | | - } |
215 | | - if(element.style && !Narayam.enabled) { |
216 | | - //Narayam.elementBorders[element.id] = element.style.border; |
217 | | - element.style.border = Narayam.elementBorders[element.id]; |
218 | | - //Narayam.elementBackColors[element.id] = element.style.backgroundColor; |
219 | | - element.style.backgroundColor = Narayam.elementBackColors[element.id]; |
220 | | - } |
221 | | - } |
222 | | - if(enable) { |
| 208 | + /** |
| 209 | + * Add more inputs to apply Narayam to |
| 210 | + * @param inputs A jQuery object holding one or more input or textarea elements, |
| 211 | + * or an array of DOM elements, or a single DOM element, or a selector |
| 212 | + */ |
| 213 | + this.addInputs = function( inputs ) { |
| 214 | + var $newInputs = $( inputs ); |
| 215 | + $inputs = $inputs.add( $newInputs ); |
| 216 | + $newInputs |
| 217 | + .bind( 'keydown.narayam', onkeydown ) |
| 218 | + .bind( 'keypress.narayam', onkeypress ) |
| 219 | + .data( 'narayam-lookback', '' ); |
| 220 | + if ( enabled ) { |
| 221 | + $newInputs.addClass( 'narayam-input' ); |
| 222 | + } |
| 223 | + }; |
| 224 | + |
| 225 | + this.enable = function() { |
| 226 | + if ( !enabled && currentScheme !== null ) { |
| 227 | + $inputs.addClass( 'narayam-input' ); |
| 228 | + $.cookie( 'narayam-enabled', '1', { 'path': '/', 'expires': 30 } ); |
| 229 | + $( '#narayam-toggle' ).attr( 'checked', true ); |
| 230 | + enabled = true; |
| 231 | + } |
| 232 | + }; |
| 233 | + |
| 234 | + this.disable = function() { |
| 235 | + if ( enabled ) { |
| 236 | + $inputs.removeClass( 'narayam-input' ); |
| 237 | + $.cookie( 'narayam-enabled', '0', { 'path': '/', 'expires': 30 } ); |
| 238 | + $( '#narayam-toggle' ).attr( 'checked', false ); |
| 239 | + enabled = false; |
| 240 | + } |
| 241 | + }; |
| 242 | + |
| 243 | + this.toggle = function() { |
| 244 | + if ( enabled ) { |
| 245 | + that.disable(); |
| 246 | + } else { |
| 247 | + that.enable(); |
| 248 | + } |
| 249 | + }; |
| 250 | + |
| 251 | + /** |
| 252 | + * Add a transliteration scheme. Schemes whose name is not in |
| 253 | + * wgNarayamAvailableSchemes will be ignored. |
| 254 | + * @param name Name of the scheme, must be unique |
| 255 | + * @param data Object with scheme data |
| 256 | + * @return True if added, false if not |
| 257 | + */ |
| 258 | + this.addScheme = function( name, data ) { |
| 259 | + if ( name in availableSchemes ) { |
| 260 | + schemes[name] = data; |
| 261 | + return true; |
| 262 | + } else { |
| 263 | + return false; |
| 264 | + } |
| 265 | + }; |
| 266 | + |
| 267 | + this.setScheme = function( name ) { |
| 268 | + if ( name in schemes ) { |
| 269 | + currentScheme = schemes[name]; |
| 270 | + $select.val( name ); |
| 271 | + } |
| 272 | + }; |
| 273 | + |
| 274 | + this.setup = function() { |
| 275 | + // Build scheme dropdown |
| 276 | + $select = $( '<select />' ); |
| 277 | + var haveSchemes = false; |
| 278 | + for ( var scheme in schemes ) { |
| 279 | + $( '<option />' ) |
| 280 | + .val( scheme ) |
| 281 | + .text( mw.msg( schemes[scheme].namemsg ) ) |
| 282 | + .appendTo( $select ); |
| 283 | + haveSchemes = true; |
| 284 | + } |
| 285 | + $select.change( updateSchemeFromSelect ); |
223 | 286 | |
224 | | - //Narayam.temp_disable = false; |
225 | | - cookieValue = 1; |
226 | | - } |
227 | | - else { |
228 | | - cookieValue = 0; |
229 | | - } |
230 | | - if(Narayam.checkboxElement) { |
231 | | - Narayam.checkboxElement.checked = enable; |
232 | | - } |
233 | | - setCookie(Narayam.prefix+'enabled', cookieValue); |
234 | | -} |
| 287 | + if ( !haveSchemes ) { |
| 288 | + // No schemes available, don't show the tool |
| 289 | + return; |
| 290 | + } |
| 291 | + |
| 292 | + // Build enable/disable checkbox and label |
| 293 | + var $checkbox = $( '<input type="checkbox" id="narayam-toggle" />' ); |
| 294 | + $checkbox |
| 295 | + .attr( 'title', mw.msg( 'narayam-checkbox-tooltip' ) ) |
| 296 | + .click( that.toggle ); |
| 297 | + |
| 298 | + var helppage = mw.msg( 'narayam-help-page' ); |
| 299 | + var $label = $( '<label for="narayam-toggle" />' ); |
| 300 | + $label |
| 301 | + .text( mw.msg( 'narayam-toggle-ime', shortcutText() ) ) |
| 302 | + .attr( 'title', mw.msg( 'narayam-checkbox-tooltip' ) ); |
| 303 | + if ( helppage ) { |
| 304 | + // Link to the help page |
| 305 | + $label.wrapInner( $( '<a />' ).attr( 'href', mw.util.wikiGetlink( helppage ) ) ); |
| 306 | + } |
| 307 | + |
| 308 | + var $checkboxAndLabel = $( '<span />' ) |
| 309 | + .addClass( 'narayam-toggle-wrapper' ) |
| 310 | + .append( $checkbox ) |
| 311 | + .append( $label ); |
| 312 | + var $spanWithEverything = $( '<span />' ) |
| 313 | + .addClass( 'narayam-wrapper' ) |
| 314 | + .append( $select ) |
| 315 | + .append( $checkboxAndLabel ); |
| 316 | + |
| 317 | + // Put the dropdown and the checkbox at the beginning of the |
| 318 | + // search form. This seems to be the most reliable way across skins. |
| 319 | + $( '#searchform' ).prepend( $spanWithEverything ); |
| 320 | + |
| 321 | + // Restore state from cookies |
| 322 | + var savedScheme = $.cookie( 'narayam-scheme' ); |
| 323 | + if ( savedScheme && savedScheme in schemes ) { |
| 324 | + that.setScheme( savedScheme ); |
| 325 | + } else { |
| 326 | + $select.change(); |
| 327 | + } |
| 328 | + var enabledCookie = $.cookie( 'narayam-enabled' ); |
| 329 | + if ( enabledCookie == '1' || ( mw.config.get( 'wgNarayamEnableByDefault' ) && enabledCookie !== '0' ) ) { |
| 330 | + that.enable(); |
| 331 | + } |
| 332 | + }; |
| 333 | + |
| 334 | +} )(); |
235 | 335 | |
236 | | -// stop propagation of given event |
237 | | -function stopPropagation(event) { |
238 | | - event.cancelBubble = true; |
239 | | - event.returnValue = false; |
240 | | - //event.stopPropagation works in Firefox. |
241 | | - if (event.stopPropagation) event.stopPropagation(); |
242 | | - if(event.preventDefault) event.preventDefault(); |
243 | | -} |
244 | | - |
245 | | -function shortKeyPressed(event) { |
246 | | - var e = event || window.event; |
247 | | - var targetElement; |
248 | | - if(e.target) targetElement=e.target; |
249 | | - else if(e.srcElement) targetElement=e.srcElement; |
250 | | - var code; |
251 | | - if (e.keyCode) code = e.keyCode; |
252 | | - else if (e.which) code = e.which; |
253 | | - |
254 | | - var controlKey = false; |
255 | | - var shiftKey = false; |
256 | | - var altKey = false; |
257 | | - var metaKey = false; |
258 | | - if(e.ctrlKey) controlKey = true; |
259 | | - if(e.shiftKey) shiftKey = true; |
260 | | - if(e.altKey) altKey = true; |
261 | | - if(e.metaKey) metaKey = true; |
262 | | - var shortcut = Narayam.shortcut; |
263 | | - // If shortkey has been specified |
264 | | - if((shortcut.controlkey || shortcut.shiftkey || shortcut.altkey || shortcut.metakey) && |
265 | | - (shortcut.controlkey==controlKey && shortcut.shiftkey==shiftKey && shortcut.altkey==altKey && shortcut.metakey==metaKey) && |
266 | | - String.fromCharCode(code).toLowerCase()==shortcut.key.toLowerCase()) |
267 | | - { |
268 | | - Narayam.enableTrasliteration(!Narayam.enabled ); |
269 | | - stopPropagation(e); |
270 | | - return false; |
271 | | - } |
272 | | - return true; |
273 | | -} |
274 | | -// event listener for trasliterattion textfield |
275 | | -// also listen for Ctrl+M combination to disable and enable trasliteration |
276 | | -function tiKeyPressed(event) { |
277 | | - var e = event || window.event; |
278 | | - var keyCode; |
279 | | - if (e.keyCode) keyCode = e.keyCode; |
280 | | - else if (e.which) keyCode = e.which; |
281 | | - |
282 | | - //var charCode = e.charCode || e.keyCode; |
283 | | - var charCode; |
284 | | - if (e.keyCode) charCode = e.keyCode; |
285 | | - else if (e.which) charCode = e.which; |
286 | | - |
287 | | - var targetElement = (e.currentTarget || e.srcElement); |
288 | | - |
289 | | - if (keyCode == 8 ) { |
290 | | - Narayam.previous_sequence[targetElement.id] = ''; |
291 | | - return true; |
292 | | - } // Backspace |
293 | | - // If this keystroke is a function key of any kind, do not filter it |
294 | | - if (e.charCode == 0 || e.which ==0 ) return true; // Function key (Firefox and Opera), e.charCode for Firefox and e.which for Opera |
295 | | - // If control or alt or meta key pressed |
296 | | - if(e.ctrlKey || (e.altKey && !Narayam.current_scheme.extended_keyboard) || e.metaKey) { |
297 | | - //if (navigator.userAgent.indexOf("Firefox")!=-1) { |
298 | | - // return shortKeyPressed(event); |
299 | | - //} |
300 | | - return true; |
301 | | - } |
302 | | - if (charCode < 32) return true; // ASCII control character |
303 | | - if(Narayam.enabled ) |
304 | | - { |
305 | | - |
306 | | - var c = String.fromCharCode(charCode); |
307 | | - var selectionRange = GetCaretPosition(targetElement); |
308 | | - var lastSevenChars = getLastNChars(targetElement.value, selectionRange['start'], Narayam.check_str_length); |
309 | | - var oldString; |
310 | | - var newString; |
311 | | - /* |
312 | | - if(charCode ==62 && Narayam.previous_sequence[targetElement.id ].substring(Narayam.previous_sequence[targetElement.id ].length-1)=="<") |
313 | | - { |
314 | | - oldString = "<>"; |
315 | | - newString = ""; |
316 | | - Narayam.temp_disable = !Narayam.temp_disable; |
317 | | - }*/ |
318 | | - //else { |
319 | | - //if(!Narayam.temp_disable) |
320 | | - //{ |
321 | | - var transPair; |
322 | | - if(Narayam.current_scheme.extended_keyboard && e.altKey) { |
323 | | - transPair = transli(lastSevenChars+c, e, Narayam.current_scheme.rules_x); |
324 | | - } |
325 | | - else transPair = transli(lastSevenChars+c, e, Narayam.current_scheme.rules); |
326 | | - oldString = transPair[0]; |
327 | | - newString = transPair[1]; |
328 | | - //} |
329 | | - /* |
330 | | - else |
331 | | - { |
332 | | - oldString = c; |
333 | | - newString = c; |
334 | | - }*/ |
335 | | - //} |
336 | | - replaceTransStringAtCaret(targetElement, oldString.length, newString , selectionRange); |
337 | | - Narayam.previous_sequence[targetElement.id ] += c; |
338 | | - if(Narayam.previous_sequence[targetElement.id ].length > Narayam.check_str_length ) Narayam.previous_sequence[targetElement.id ] = Narayam.previous_sequence[targetElement.id ].substring(Narayam.previous_sequence[targetElement.id ].length-Narayam.check_str_length); |
339 | | - stopPropagation(e); |
340 | | - return false; |
341 | | - } |
342 | | - return true; |
343 | | -} |
344 | | - |
345 | | -function tiKeyDown(event) { |
346 | | - var e = event || window.event; |
347 | | - var targetElement; |
348 | | - if(e.target) targetElement=e.target; |
349 | | - else if(e.srcElement) targetElement=e.srcElement; |
350 | | - if(Narayam.current_scheme.extended_keyboard && e.altKey && !e.ctrlKey && !e.metaKey /*&& Narayam.temp_disable*/) stopPropagation(e); |
351 | | - else if(e.ctrlKey || e.altKey || e.metaKey) { |
352 | | - return shortKeyPressed(event); |
353 | | - } |
354 | | - return true; |
355 | | -} |
356 | | -/** |
357 | | - * This is the function to which call during window load event for trasliterating textfields. |
358 | | - * The funtion will accept any number of HTML tag IDs of textfields. |
359 | | -*/ |
360 | | -function inputRewrite(elements) { |
361 | | - var len = elements.length; |
362 | | - for(var i=0;i<len; i++) |
363 | | - { |
364 | | - var element = elements[i]; |
365 | | - // if given element has no id set |
366 | | - // we assing a temporary value |
367 | | - if(element.id ==undefined || element.id.length == 0) { |
368 | | - element.id = 'irtempid-'+Narayam.id; |
369 | | - Narayam.id = Narayam.id + 1; |
370 | | - } |
371 | | - if(element) |
372 | | - { |
373 | | - Narayam.elements.push(element); |
374 | | - Narayam.previous_sequence[element.id] = ''; |
375 | | - if(element.style) { |
376 | | - Narayam.elementBorders[element.id] = element.style.border; |
377 | | - Narayam.elementBackColors[element.id] = element.style.backgroundColor; |
378 | | - |
379 | | - } |
380 | | - if(Narayam.enabled) { |
381 | | - element.style.border = Narayam.border; |
382 | | - element.style.backgroundColor = Narayam.back_color |
383 | | - } |
384 | | - if (element.addEventListener){ |
385 | | - element.addEventListener('keydown', tiKeyDown, false); |
386 | | - element.addEventListener('keypress', tiKeyPressed, false); |
387 | | - } else if (element.attachEvent){ |
388 | | - element.attachEvent('onkeydown', tiKeyDown); |
389 | | - element.attachEvent("onkeypress", tiKeyPressed); |
390 | | - } |
391 | | - } |
392 | | - } |
393 | | -} |
394 | | - |
395 | | -function transOptionOnClick(event) |
396 | | -{ |
397 | | - var e = event || window.event; |
398 | | - var checkbox = (e.currentTarget || e.srcElement); |
399 | | - if(checkbox.checked) |
400 | | - { |
401 | | - Narayam.enableTrasliteration(true); |
402 | | - } |
403 | | - else |
404 | | - { |
405 | | - Narayam.enableTrasliteration(false); |
406 | | - } |
407 | | -} |
408 | | - |
409 | | - |
410 | | -function writingStyleLBChanged(event) { |
411 | | - var e = event || window.event; |
412 | | - var listBox = (e.currentTarget || e.srcElement); |
413 | | - Narayam.current_scheme = Narayam.schemes[listBox.selectedIndex]; |
414 | | - setCookie(Narayam.prefix+'default-index', listBox.selectedIndex); |
415 | | -} |
416 | | - |
417 | | -// Narayam setup and initialization code |
418 | | -Narayam.shortcut = {}; |
419 | | -Narayam.checkbox = {}; |
420 | | -// memory for previus key sequence |
421 | | -Narayam.previous_sequence = {}; |
422 | | -Narayam.elements = []; |
423 | | -Narayam.elementBorders = {}; |
424 | | -Narayam.elementBackColors = {}; |
425 | | -// To generate ids for elements that have no id assigned |
426 | | -Narayam.id = 0; |
427 | | - |
428 | | -// shortcut key settings |
429 | | -Narayam.shortcut.toString = function() { |
430 | | - var parts= []; |
431 | | - if(this.controlkey) parts.push('Ctrl'); |
432 | | - if(this.shiftkey) parts.push('Shift'); |
433 | | - if(this.altkey) parts.push('Alt'); |
434 | | - if(this.metakey) parts.push('Meta'); |
435 | | - parts.push(this.key.toUpperCase()); |
436 | | - return parts.join('+'); |
437 | | -} |
438 | | - |
439 | | -/** |
440 | | - * This functions is to synchronize Narayam state from cookie |
441 | | - */ |
442 | | -Narayam.translitStateSynWithCookie = function() { |
443 | | - var state = parseInt(readCookie(Narayam.prefix+'enabled' )); |
444 | | - var enable = Narayam.enabled; |
445 | | - if(state == 1) enable=true; |
446 | | - else if(state==0) enable =false; |
447 | | - Narayam.enableTrasliteration(enable); |
448 | | - var schemeIndex = parseInt(readCookie(Narayam.prefix+'default-index')); |
449 | | - if(schemeIndex > 0 && schemeIndex < Narayam.schemes.length) { |
450 | | - Narayam.listBox.selectedIndex = schemeIndex; |
451 | | - } |
452 | | - else Narayam.listBox.selectedIndex = Narayam.default_scheme_index; |
453 | | - Narayam.current_scheme = Narayam.schemes[Narayam.listBox.selectedIndex]; |
454 | | -} |
455 | | -/* Settings */ |
456 | | -Narayam.shortcut = { |
457 | | - controlkey: false, |
458 | | - altkey: false, |
459 | | - shiftkey: false, |
460 | | - metakey: false, |
461 | | - key: '', // eg: 'M' |
462 | | - toString: function() { |
463 | | - var parts= []; |
464 | | - if(Narayam.shortcut.controlkey) parts.push('Ctrl'); |
465 | | - if(Narayam.shortcut.shiftkey) parts.push('Shift'); |
466 | | - if(Narayam.shortcut.altkey) parts.push('Alt'); |
467 | | - if(Narayam.shortcut.metakey) parts.push('Meta'); |
468 | | - parts.push(Narayam.shortcut.key.toUpperCase()); |
469 | | - return parts.join('+'); |
470 | | - } |
471 | | -}; |
472 | | -Narayam.checkbox = { |
473 | | - text: '', // eg: 'To toggle ('+ Narayam.shortcut.toString()+ ')' |
474 | | - href: '', // eg: 'http://ml.wikipedia.org/wiki/Help:Typing' |
475 | | - tooltip: '' // eg: 'To write Malayalam use this tool, shortcut: ('+ Narayam.shortcut.toString()+ ')' |
476 | | -}; |
477 | | -//Narayam.default_state = true; |
478 | | -Narayam.schemes = []; // eg: [tr_ml, tr_ml_inscript] |
479 | | -Narayam.default_scheme_index = 0; // eg: 0 |
480 | | -Narayam.enabled = true; |
481 | | -Narayam.prefix = 'narayam-'; |
482 | | -Narayam.check_str_length = 6; |
483 | | -Narayam.back_color = '#FDFDCD'; |
484 | | -Narayam.border = '2px inset #FDBBBB'; |
485 | | - |
486 | | -Narayam.init = function() { |
487 | | - Narayam.current_scheme = Narayam.schemes[Narayam.default_scheme_index]; |
488 | | - this.translitStateSynWithCookie(); |
489 | | -} |
490 | | - |
491 | | -Narayam.prepareMultiSchemeListBox = function() { |
492 | | - this.listBox = document.createElement("select"); |
493 | | - if (this.listBox.addEventListener) |
494 | | - this.listBox.addEventListener("change", writingStyleLBChanged, false); |
495 | | - else if (this.listBox.attachEvent) |
496 | | - this.listBox.attachEvent("onchange", writingStyleLBChanged); |
497 | | - var numOfSchemes = Narayam.schemes.length; |
498 | | - for(var i=0; i < numOfSchemes; i++) { |
499 | | - var schemeOption = document.createElement("option"); |
500 | | - schemeOption.appendChild( document.createTextNode(Narayam.schemes[i].text) ); |
501 | | - schemeOption.value = Narayam.schemes[i].text; |
502 | | - if(Narayam.default_scheme_index==i) schemeOption.selected=true; |
503 | | - this.listBox.appendChild( schemeOption ); |
504 | | - } |
505 | | -} |
506 | | - |
507 | | -Narayam.prepareCheckBoxWithLabel = function() { |
508 | | - var checkbox = document.createElement("input"); |
509 | | - checkbox.type = "checkbox"; |
510 | | - checkbox.id = this.prefix+'cb'; |
511 | | - checkbox.value = 'searchInput'; // specifying curresponding input filed. |
512 | | - checkbox.checked = Narayam.enabled; |
513 | | - this.checkboxElement = checkbox; |
514 | | - |
515 | | - if (checkbox.addEventListener) |
516 | | - checkbox.addEventListener("click", transOptionOnClick, false); |
517 | | - else if (checkbox.attachEvent) |
518 | | - checkbox.attachEvent("onclick", transOptionOnClick); |
519 | | - |
520 | | - var label = document.createElement('label'); |
521 | | - var linktohelp = document.createElement ('a'); |
522 | | - linktohelp.href= this.checkbox.href; |
523 | | - linktohelp.title= this.checkbox.tooltip; |
524 | | - linktohelp.appendChild( document.createTextNode(this.checkbox.text) ); |
525 | | - label.appendChild(linktohelp); |
526 | | - |
527 | | - this.checkboxWL = document.createElement('span'); |
528 | | - this.checkboxWL.style.padding = 0; |
529 | | - this.checkboxWL.id = this.prefix+'cbwl'; |
530 | | - this.checkboxWL.style.margin = 0; |
531 | | - this.checkboxWL.appendChild(checkbox); |
532 | | - this.checkboxWL.appendChild(label); |
533 | | -} |
534 | | - |
535 | | -function setupNarayamForvector() { |
536 | | - Narayam.prepareMultiSchemeListBox(); |
537 | | - Narayam.prepareCheckBoxWithLabel(); |
538 | | - //Narayam.listBox.style.width = '10em'; |
539 | | - Narayam.checkboxWL.style.fontSize = '80%'; |
540 | | - var span = document.createElement("span"); |
541 | | - span.style.position = 'absolute'; |
542 | | - span.style.top = '1.4em'; |
543 | | - span.style.right = '0.5em'; |
544 | | - //span.style.right = '0em'; |
545 | | - span.appendChild(Narayam.listBox); |
546 | | - span.appendChild(Narayam.checkboxWL); |
547 | | - var container = document.getElementById('p-search'); |
548 | | - var searchform = document.getElementById('searchform'); |
549 | | - container.insertBefore(span,searchform); |
550 | | - //var searchInput = document.getElementById('searchInput'); |
551 | | - Narayam.init(); |
552 | | -} |
553 | | -/* |
554 | | -function setupNarayamForvector() { |
555 | | - Narayam.prepareMultiSchemeListBox(); |
556 | | - Narayam.prepareCheckBoxWithLabel(); |
557 | | - Narayam.listBox.style.width = '9em'; |
558 | | - var mwPanel = document.getElementById('mw-panel'); |
559 | | - var pNavigation = document.getElementById('p-navigation'); |
560 | | - var h5 = document.createElement('h5'); |
561 | | - h5.appendChild(document.createTextNode('Narayam')); |
562 | | - var bodyDiv = document.createElement('div'); |
563 | | - var label = document.createElement('label'); |
564 | | - label.appendChild(document.createTextNode('Input method:')); |
565 | | - bodyDiv.appendChild(label); |
566 | | - bodyDiv.appendChild(document.createElement('br')); |
567 | | - bodyDiv.appendChild(Narayam.listBox); |
568 | | - bodyDiv.appendChild(document.createElement('br')); |
569 | | - bodyDiv.appendChild(Narayam.checkboxWL); |
570 | | - bodyDiv.className = 'body'; |
571 | | - var portalDiv = document.createElement('div'); |
572 | | - portalDiv.className = 'portal'; |
573 | | - portalDiv.appendChild(h5); |
574 | | - portalDiv.appendChild(bodyDiv); |
575 | | - mwPanel.insertBefore(portalDiv, pNavigation) |
576 | | -}*/ |
577 | | - |
578 | | -function setupNarayamFormonobook() { |
579 | | - Narayam.prepareMultiSchemeListBox(); |
580 | | - Narayam.prepareCheckBoxWithLabel(); |
581 | | - Narayam.listBox.style.width = '9em'; |
582 | | - var searchform = document.getElementById('searchform'); |
583 | | - var searchInput = document.getElementById('searchInput'); |
584 | | - searchform.insertBefore(Narayam.listBox, searchInput); |
585 | | - searchform.insertBefore(Narayam.checkboxWL, searchInput); |
586 | | - Narayam.init(); |
587 | | -} |
\ No newline at end of file |
| 336 | +} )( jQuery ); |
Index: trunk/extensions/Narayam/ext.narayam.core-vector.css |
— | — | @@ -0,0 +1,6 @@ |
| 2 | +.narayam-wrapper { |
| 3 | + font-size: 80%; |
| 4 | + position: absolute; |
| 5 | + top: 1.4em; |
| 6 | + right: 0.5em; |
| 7 | +} |
Property changes on: trunk/extensions/Narayam/ext.narayam.core-vector.css |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 8 | + native |
Index: trunk/extensions/Narayam/ext.narayam.core.css |
— | — | @@ -0,0 +1,13 @@ |
| 2 | +.narayam-input { |
| 3 | + /* FIXME: needed to add !important because WikiEditor overrides border for #wpTextbox1 |
| 4 | + * and SimpleSearch overrides background-color for the search box. Talk to Trevor |
| 5 | + * about styling this nicely |
| 6 | + */ |
| 7 | + background-color: #FDFDCD !important; |
| 8 | + border: 2px inset #FDBBBB !important; |
| 9 | +} |
| 10 | + |
| 11 | +.narayam-wrapper { |
| 12 | + padding: 0; |
| 13 | + margin: 0; |
| 14 | +} |
Property changes on: trunk/extensions/Narayam/ext.narayam.core.css |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 15 | + native |
Index: trunk/extensions/Narayam/ml_inscript_rules.js |
— | — | @@ -4,12 +4,7 @@ |
5 | 5 | * @date 2010-09-08 |
6 | 6 | * License: GPLv3 |
7 | 7 | */ |
8 | | -if(tr_ml_inscript== undefined) var tr_ml_inscript = {}; |
9 | | -else tr_ml_inscript = {}; |
10 | | -tr_ml_inscript.text = "InScript"; |
11 | | -tr_ml_inscript.description = "Malayalam InScript"; |
12 | | - // Normal rules |
13 | | -tr_ml_inscript.rules = [ |
| 8 | +var rules = [ |
14 | 9 | ['`', '','ൊ'], |
15 | 10 | ['~', '','ഓ'], |
16 | 11 | ['_', '','ഃ'], |
— | — | @@ -77,4 +72,11 @@ |
78 | 73 | ['M', '','ശ'], |
79 | 74 | ['<', '','ഷ'], |
80 | 75 | ['/', '','യ'] |
81 | | -]; |
\ No newline at end of file |
| 76 | +]; |
| 77 | + |
| 78 | +jQuery.narayam.addScheme( 'ml-inscript', { |
| 79 | + 'namemsg': 'narayam-ml-inscript', |
| 80 | + 'extended_keyboard': false, |
| 81 | + 'lookbackLength': 0, |
| 82 | + 'rules': rules |
| 83 | +} ); |
Index: trunk/extensions/Narayam/bn_avro_rules.js |
— | — | @@ -4,64 +4,60 @@ |
5 | 5 | * @date 2010-12-05 |
6 | 6 | * License: GPLv3, CC-BY-SA 3.0 |
7 | 7 | */ |
8 | | -if(tr_bn_avro== undefined) var tr_bn_avro = {}; |
9 | | -else tr_bn_avro = {}; |
10 | | -tr_bn_avro.text = "Avro"; |
11 | | -tr_bn_avro.description = "Avro transliteration scheme for Begnali"; |
12 | | -// Normal rules |
13 | | -tr_bn_avro.rules = [ |
14 | | -['([ক-হড়ঢ়য়])্?ররi','[^o`]', '$2ৃ'], |
| 8 | + |
| 9 | +var rules = [ |
| 10 | +['([ক-হড়ঢ়য়])্?ররi','[^o`]', '$1ৃ'], |
15 | 11 | ['ররi','[^o`]', 'ঋ'], |
16 | 12 | |
17 | 13 | ['ঙহo', '', 'ঙ্ঘ'], |
18 | 14 | |
19 | | -['([ক-হড়ঢ়য়])াZ', '[^o`]', '$2্যা'], |
| 15 | +['([ক-হড়ঢ়য়])াZ', '[^o`]', '$1্যা'], |
20 | 16 | |
21 | | -['(([ক-হড়ঢ়য়])|য়)o','[^o`]', '$2'], // য় cannot be included in the range, why? everywhere else it is OK! |
22 | | -['([ক-হড়ঢ়য়])a','[^o`]', '$2া'], |
23 | | -['([ক-হড়ঢ়য়])i','[^o`]', '$2ি'], |
24 | | -['([ক-হড়ঢ়য়])(I|েe)','[^o`]', '$2ী'], |
25 | | -['([ক-হড়ঢ়য়])u','[^o`]', '$2ু'], |
26 | | -['([ক-হড়ঢ়য়])U','[^o`]', '$2ূ'], |
27 | | -['([ক-হড়ঢ়য়])o','[o`]', '$2ু'], |
28 | | -['([ক-হড়ঢ়য়])e','[^o`]', '$2ে'], |
29 | | -['([ক-হড়ঢ়য়])োI','[^o`]', '$2ৈ'], |
30 | | -['([ক-হড়ঢ়য়])O','[^o`]', '$2ো'], |
31 | | -['([ক-হড়ঢ়য়])োU','[^o`]', '$2ৌ'], |
| 17 | +['(([ক-হড়ঢ়য়])|য়)o','[^o`]', '$1'], // য় cannot be included in the range, why? everywhere else it is OK! |
| 18 | +['([ক-হড়ঢ়য়])a','[^o`]', '$1া'], |
| 19 | +['([ক-হড়ঢ়য়])i','[^o`]', '$1ি'], |
| 20 | +['([ক-হড়ঢ়য়])(I|েe)','[^o`]', '$1ী'], |
| 21 | +['([ক-হড়ঢ়য়])u','[^o`]', '$1ু'], |
| 22 | +['([ক-হড়ঢ়য়])U','[^o`]', '$1ূ'], |
| 23 | +['([ক-হড়ঢ়য়])o','[o`]', '$1ু'], |
| 24 | +['([ক-হড়ঢ়য়])e','[^o`]', '$1ে'], |
| 25 | +['([ক-হড়ঢ়য়])োI','[^o`]', '$1ৈ'], |
| 26 | +['([ক-হড়ঢ়য়])O','[^o`]', '$1ো'], |
| 27 | +['([ক-হড়ঢ়য়])োU','[^o`]', '$1ৌ'], |
32 | 28 | |
33 | | -['([ক-হড়ঢ়য়][িুেো]|[এইওউ])a','[^o`]', '$2য়া'], |
34 | | -['([ক-হড়ঢ়য়][াে]|[আএ])o', '[^o`]', '$2ও'], |
| 29 | +['([ক-হড়ঢ়য়][িুেো]|[এইওউ])a','[^o`]', '$1য়া'], |
| 30 | +['([ক-হড়ঢ়য়][াে]|[আএ])o', '[^o`]', '$1ও'], |
35 | 31 | //'চচh','[^o`]', 'চ্চ'], |
36 | 32 | |
37 | | -['([কঙলষস])(k|K)','[^o`]','$2্ক'], |
38 | | -['([ঙদল])(g|G)','[^o`]','$2্গ'], |
| 33 | +['([কঙলষস])(k|K)','[^o`]','$1্ক'], |
| 34 | +['([ঙদল])(g|G)','[^o`]','$1্গ'], |
39 | 35 | ['গg','[^o`]','জ্ঞ'], |
40 | | -['([চশ])c','[^o`]','$2্চ'], |
41 | | -['([জঞব])j','[^o`]','$2্জ'], |
| 36 | +['([চশ])c','[^o`]','$1্চ'], |
| 37 | +['([জঞব])j','[^o`]','$1্জ'], |
42 | 38 | ['নj','[^o`]','ঞ্জ'], |
43 | | -['([কটণনপলষস])T','[^o`]','$2্ট'], |
44 | | -['([ডণনল])D','[^o`]','$2্ড'], |
45 | | -['([গষহ])N','[^o`]','$2্ণ'], |
46 | | -['([কতনপশসহ])t','[^o`]','$2্ত'], |
47 | | -['([দনব])d','[^o`]','$2্দ'], |
48 | | -['([গঘণতধনপমশসহ])n','[^o`]','$2্ন'], |
49 | | -['([পমলষস])p','[^o`]','$2্প'], |
50 | | -['([স])f', '[^o`]', '$2্ফ'], |
51 | | -['([বমল])b','[^o`]','$2্ব'], |
52 | | -['([দম])(v|V)','[^o`]','$2্ভ'], |
53 | | -['([কগঙটণতদধনমলশষসহ])m','[^o`]','$2্ম'], |
54 | | -['([ক-ঘচ-ঝট-যলশ-হড়ঢ়য়])r','[^o`]','$2্র'], |
55 | | -['([কগপ-বমলশসহ])l','[^o`]','$2্ল'], |
56 | | -['([কনপ])s','[^o`]','$2্স'], |
57 | | -['([ক-হড়ঢ়য়])w','[^o`]','$2্ব'], |
58 | | -['([ক-হড়ঢ়য়])y','[^o`]','$2্য'], |
| 39 | +['([কটণনপলষস])T','[^o`]','$1্ট'], |
| 40 | +['([ডণনল])D','[^o`]','$1্ড'], |
| 41 | +['([গষহ])N','[^o`]','$1্ণ'], |
| 42 | +['([কতনপশসহ])t','[^o`]','$1্ত'], |
| 43 | +['([দনব])d','[^o`]','$1্দ'], |
| 44 | +['([গঘণতধনপমশসহ])n','[^o`]','$1্ন'], |
| 45 | +['([পমলষস])p','[^o`]','$1্প'], |
| 46 | +['([স])f', '[^o`]', '$1্ফ'], |
| 47 | +['([বমল])b','[^o`]','$1্ব'], |
| 48 | +['([দম])(v|V)','[^o`]','$1্ভ'], |
| 49 | +['([কগঙটণতদধনমলশষসহ])m','[^o`]','$1্ম'], |
| 50 | +['([ক-ঘচ-ঝট-যলশ-হড়ঢ়য়])r','[^o`]','$1্র'], |
| 51 | +['([কগপ-বমলশসহ])l','[^o`]','$1্ল'], |
| 52 | +['([কনপ])s','[^o`]','$1্স'], |
| 53 | +['([ক-হড়ঢ়য়])w','[^o`]','$1্ব'], |
| 54 | +['([ক-হড়ঢ়য়])y','[^o`]','$1্য'], |
59 | 55 | ['নc','[^o`]','ঞ্চ'], |
60 | 56 | |
61 | 57 | ['ত`','`' ,'ৎ'], |
62 | 58 | |
63 | 59 | ['ক্ক(h|H)','[^o`]','ক্ষ'], |
64 | 60 | ['কশ(h|H)','[^o`]','ক্ষ'], |
65 | | -//'([অ-ঔা-ৌ])ররk','[^o]','$2র্ক'], |
| 61 | +//'([অ-ঔা-ৌ])ররk','[^o]','$1র্ক'], |
66 | 62 | |
67 | 63 | ['ররk','(o|a|i|I|u|U|e|O|OI|OU|rri)rr','র্ক'], |
68 | 64 | ['ররg','(o|a|i|I|u|U|e|O|OI|OU|rri)rr','র্গ'], |
— | — | @@ -190,4 +186,11 @@ |
191 | 187 | ['\\$','' ,'৳'], |
192 | 188 | ['ঃ`','' ,':'], |
193 | 189 | ['`','' ,''] |
194 | | -]; |
\ No newline at end of file |
| 190 | +]; |
| 191 | + |
| 192 | +jQuery.narayam.addScheme( 'bn-avro', { |
| 193 | + 'namemsg': 'narayam-bn-avro', |
| 194 | + 'extended_keyboard': false, |
| 195 | + 'lookbackLength': 5, |
| 196 | + 'rules': rules |
| 197 | +} ); |
Index: trunk/extensions/Narayam/ta99_rules.js |
— | — | @@ -4,35 +4,32 @@ |
5 | 5 | * @date 2010-11-20 |
6 | 6 | * License: GPLv3, CC-BY-SA 3.0 |
7 | 7 | */ |
8 | | -if(tr_ta99== undefined) var tr_ta99 = {}; |
9 | | -else tr_ta99 = {}; |
10 | | -tr_ta99.text = "தமிழ்99"; |
11 | | -tr_ta99.description = "Tamil99 input method"; |
| 8 | + |
12 | 9 | // Normal rules |
13 | | -tr_ta99.rules = [ |
14 | | -['([க-ஹ])h','a', '$2க'], |
15 | | -['([க-ஹ])b','a', '$2ங'], |
16 | | -['([க-ஹ])\\[','a', '$2ச'], |
17 | | -['([க-ஹ])E','a', '$2ஜ'], |
18 | | -['([க-ஹ])\\]','a', '$2ஞ'], |
19 | | -['([க-ஹ])o','a', '$2ட'], |
20 | | -['([க-ஹ])p','a', '$2ண'], |
21 | | -['([க-ஹ])l','a', '$2த'], |
22 | | -['([க-ஹ]);','a', '$2ந'], |
23 | | -['([க-ஹ])i','a', '$2ன'], |
24 | | -['([க-ஹ])j','a', '$2ப'], |
25 | | -['([க-ஹ])k','a', '$2ம'], |
26 | | -["([க-ஹ])'",".*a$", '$2ய'], |
27 | | -['([க-ஹ])m','a', '$2ர'], |
28 | | -['([க-ஹ])u','a', '$2ற'], |
29 | | -['([க-ஹ])n','a', '$2ல'], |
30 | | -['([க-ஹ])y','a', '$2ள'], |
31 | | -['([க-ஹ])/','a', '$2ழ'], |
32 | | -['([க-ஹ])v','a', '$2வ'], |
| 10 | +var rules = [ |
| 11 | +['([க-ஹ])h','a', '$1க'], |
| 12 | +['([க-ஹ])b','a', '$1ங'], |
| 13 | +['([க-ஹ])\\[','a', '$1ச'], |
| 14 | +['([க-ஹ])E','a', '$1ஜ'], |
| 15 | +['([க-ஹ])\\]','a', '$1ஞ'], |
| 16 | +['([க-ஹ])o','a', '$1ட'], |
| 17 | +['([க-ஹ])p','a', '$1ண'], |
| 18 | +['([க-ஹ])l','a', '$1த'], |
| 19 | +['([க-ஹ]);','a', '$1ந'], |
| 20 | +['([க-ஹ])i','a', '$1ன'], |
| 21 | +['([க-ஹ])j','a', '$1ப'], |
| 22 | +['([க-ஹ])k','a', '$1ம'], |
| 23 | +["([க-ஹ])'",'a', '$1ய'], |
| 24 | +['([க-ஹ])m','a', '$1ர'], |
| 25 | +['([க-ஹ])u','a', '$1ற'], |
| 26 | +['([க-ஹ])n','a', '$1ல'], |
| 27 | +['([க-ஹ])y','a', '$1ள'], |
| 28 | +['([க-ஹ])/','a', '$1ழ'], |
| 29 | +['([க-ஹ])v','a', '$1வ'], |
33 | 30 | // void |
34 | | -['([க-ஹ])W','a', '$2ஷ'], |
35 | | -['([க-ஹ])Q','a', '$2ஸ'], |
36 | | -['([க-ஹ])R','a', '$2ஹ'], |
| 31 | +['([க-ஹ])W','a', '$1ஷ'], |
| 32 | +['([க-ஹ])Q','a', '$1ஸ'], |
| 33 | +['([க-ஹ])R','a', '$1ஹ'], |
37 | 34 | |
38 | 35 | |
39 | 36 | ['க்கh', '','க்கக்'], |
— | — | @@ -47,7 +44,7 @@ |
48 | 45 | ['ன்னi', '','ன்னன்'], |
49 | 46 | ['ப்பj', '','ப்பப்'], |
50 | 47 | ['ம்மk', '','ம்மம்'], |
51 | | -["ய்ய'$", '','ய்யய்'], |
| 48 | +["ய்ய'", '','ய்யய்'], |
52 | 49 | ['ர்ரm', '','ர்ரர்'], |
53 | 50 | ['ற்றu', '','ற்றற்'], |
54 | 51 | ['ல்லn', '','ல்லல்'], |
— | — | @@ -59,19 +56,19 @@ |
60 | 57 | ['ஸ்ஸQ', '','ஸ்ஸஸ்'], |
61 | 58 | ['ஹ்ஹR', '','ஹ்ஹஹ்'], |
62 | 59 | |
63 | | -['([க-ஹ])q', '','$2ா'], |
64 | | -['([க-ஹ])s', '','$2ி'], |
65 | | -['([க-ஹ])w', '','$2ீ'], |
66 | | -['([க-ஹ])d', '','$2ு'], |
67 | | -['([க-ஹ])e', '','$2ூ'], |
68 | | -['([க-ஹ])g', '','$2ெ'], |
69 | | -['([க-ஹ])t', '','$2ே'], |
70 | | -['([க-ஹ])r', '','$2ை'], |
71 | | -['([க-ஹ])c', '','$2ொ'], |
72 | | -['([க-ஹ])x', '','$2ோ'], |
73 | | -['([க-ஹ])z', '','$2ௌ'], |
| 60 | +['([க-ஹ])q', '','$1ா'], |
| 61 | +['([க-ஹ])s', '','$1ி'], |
| 62 | +['([க-ஹ])w', '','$1ீ'], |
| 63 | +['([க-ஹ])d', '','$1ு'], |
| 64 | +['([க-ஹ])e', '','$1ூ'], |
| 65 | +['([க-ஹ])g', '','$1ெ'], |
| 66 | +['([க-ஹ])t', '','$1ே'], |
| 67 | +['([க-ஹ])r', '','$1ை'], |
| 68 | +['([க-ஹ])c', '','$1ொ'], |
| 69 | +['([க-ஹ])x', '','$1ோ'], |
| 70 | +['([க-ஹ])z', '','$1ௌ'], |
74 | 71 | |
75 | | -['([க-ஹ])a', '','$2'], |
| 72 | +['([க-ஹ])a', '','$1'], |
76 | 73 | |
77 | 74 | ['கh', '','க்க'], |
78 | 75 | ['ஙb', '','ங்ங'], |
— | — | @@ -85,7 +82,7 @@ |
86 | 83 | ['னi', '','ன்ன'], |
87 | 84 | ['பj', '','ப்ப'], |
88 | 85 | ['மk', '','ம்ம'], |
89 | | -["ய'$", '','ய்ய'], |
| 86 | +["ய'", '','ய்ய'], |
90 | 87 | ['ரm', '','ர்ர'], |
91 | 88 | ['றu', '','ற்ற'], |
92 | 89 | ['லn', '','ல்ல'], |
— | — | @@ -184,3 +181,10 @@ |
185 | 182 | ['\\\\8', '','௮'], |
186 | 183 | ['\\\\9', '','௯'] |
187 | 184 | ]; |
| 185 | + |
| 186 | +jQuery.narayam.addScheme( 'ta99', { |
| 187 | + 'namemsg': 'narayam-ta99', |
| 188 | + 'extended_keyboard': false, |
| 189 | + 'lookbackLength': 1, |
| 190 | + 'rules': rules |
| 191 | +} ); |
Index: trunk/extensions/Narayam/Narayam.php |
— | — | @@ -17,8 +17,9 @@ |
18 | 18 | * AUTHOR |
19 | 19 | * Junaid P V <http://junaidpv.in> |
20 | 20 | * |
21 | | - * @package extensions |
22 | | - * @version 0.1 |
| 21 | + * @file |
| 22 | + * @ingroup extensions |
| 23 | + * @version 0.2 |
23 | 24 | * @copyright Copyright 2010 Junaid P V |
24 | 25 | * @license GPLv3 |
25 | 26 | */ |
— | — | @@ -26,189 +27,125 @@ |
27 | 28 | exit( 1 ); |
28 | 29 | } |
29 | 30 | |
30 | | -// register extension credits |
| 31 | + |
| 32 | +/* Configuration */ |
| 33 | + |
| 34 | +// Whether the input method should be active as default or not |
| 35 | +$wgNarayamEnabledByDefault = true; |
| 36 | + |
| 37 | +// Shortcut key for enabling and disabling Narayam |
| 38 | +// Defaults to Ctrl+M |
| 39 | +$wgNarayamShortcutKey = array( |
| 40 | + 'altKey' => false, |
| 41 | + 'ctrlKey' => true, |
| 42 | + 'shiftKey' => false, |
| 43 | + 'key' => 'm' |
| 44 | +); |
| 45 | + |
| 46 | +// Array mapping language codes and scheme names to module names |
| 47 | +// Custom schemes can be added here |
| 48 | +$wgNarayamSchemes = array( |
| 49 | + 'bn' => array( |
| 50 | + 'bn-avro' => 'ext.narayam.rules.bn-avro', |
| 51 | + 'bn-inscript' => 'ext.narayam.rules.bn-inscript', |
| 52 | + 'bn-nkb' => 'ext.narayam.rules.bn-nkb', |
| 53 | + ), |
| 54 | + 'ml' => array( |
| 55 | + 'ml' => 'ext.narayam.rules.ml', |
| 56 | + 'ml-inscript' => 'ext.narayam.rules.ml-inscript', |
| 57 | + ), |
| 58 | + 'sa' => array( |
| 59 | + 'sa' => 'ext.narayam.rules.sa', |
| 60 | + ), |
| 61 | + 'ta' => array( |
| 62 | + 'ta' => 'ext.narayam.rules.ta', |
| 63 | + 'ta99' => 'ext.narayam.rules.ta99', |
| 64 | + ), |
| 65 | +); |
| 66 | + |
| 67 | +/* Setup */ |
| 68 | + |
| 69 | +// Register extension credits |
31 | 70 | $wgExtensionCredits['other'][] = array( |
32 | 71 | 'path' => __FILE__, |
33 | 72 | 'name' => 'Narayam', |
34 | 73 | 'version' => 0.1, |
35 | | - 'author' => 'Junaid P V (http://junaidpv.in)', |
| 74 | + 'author' => array( 'Junaid P V (http://junaidpv.in)', 'Roan Kattouw' ), |
36 | 75 | 'url' => 'http://www.mediawiki.org/wiki/Extension:Narayam', |
37 | 76 | 'descriptionmsg' => 'narayam-desc' |
38 | 77 | ); |
39 | 78 | |
40 | | -/// @todo Document all settings |
41 | | -// control key included in short key combination?? |
42 | | -$wgNarayamConfig['shortcut_controlkey'] = true; |
43 | | -// alt key included in short key combination?? |
44 | | -$wgNarayamConfig['shortcut_altkey'] = false; |
45 | | -// shift key included in short key combination?? |
46 | | -$wgNarayamConfig['shortcut_shiftkey'] = false; |
47 | | -// meta key included in short key combination?? (only effects mac clients) |
48 | | -$wgNarayamConfig['shortcut_metakey'] = false; |
49 | | -// short key in short key combination |
50 | | -$wgNarayamConfig['shortcut_key'] = 'M'; |
51 | | -// list of schemes to be loaded when no one specified |
52 | | -$wgNarayamConfig['schemes'] = array( 'ml', 'ta99', 'ml_inscript' ); |
53 | | -// which scheme should come as default in the list box |
54 | | -$wgNarayamConfig['default_scheme_index'] = 0; |
55 | | -// whether the input method should be active as default or not |
56 | | -$wgNarayamConfig['enabled'] = true; |
57 | | - |
58 | | -// localization |
| 79 | +// Localization |
59 | 80 | $wgExtensionMessagesFiles['Narayam'] = dirname( __FILE__ ) . '/Narayam.i18n.php'; |
60 | 81 | |
61 | | -// register hook function |
62 | | -$wgHooks['BeforePageDisplay'][] = Narayam::getInstance(); |
| 82 | +// Register hook function |
| 83 | +$wgHooks['BeforePageDisplay'][] = 'NarayamHooks::addModules'; |
| 84 | +$wgHooks['ResourceLoaderGetConfigVars'][] = 'NarayamHooks::addConfig'; |
| 85 | +$wgHooks['MakeGlobalVariablesScript'][] = 'NarayamHooks::addVariables'; |
63 | 86 | |
64 | | -/** |
65 | | - * Narayam class |
66 | | - * |
67 | | - * (implements singleton pattern) |
68 | | - * |
69 | | - * @author Junaid P V |
70 | | - * @since 0.1 |
71 | | - * @todo Move to different file |
72 | | - * @todo No need for _-prefix for member variables |
73 | | - * @todo Support resource loader |
74 | | - */ |
75 | | -class Narayam { |
| 87 | +// Autoloader |
| 88 | +$wgAutoloadClasses['NarayamHooks'] = dirname( __FILE__ ) . '/Narayam.hooks.php'; |
76 | 89 | |
77 | | - /** |
78 | | - * One and only one instance of this class |
79 | | - * @var Narayam |
80 | | - */ |
81 | | - private static $_instance; |
82 | | - /** |
83 | | - * |
84 | | - * @var OutputPage |
85 | | - */ |
86 | | - private $_out; |
87 | | - /** |
88 | | - * |
89 | | - * @var Skin |
90 | | - */ |
91 | | - private $_skin; |
92 | | - /** |
93 | | - * Only skins listed here are supported |
94 | | - * @var array |
95 | | - */ |
96 | | - private $_supportedSkins = array( 'vector', 'monobook' ); |
97 | | - |
98 | | - /** |
99 | | - * This class uses singleton pattern. |
100 | | - */ |
101 | | - protected function __construct() {} |
102 | | - |
103 | | - /** |
104 | | - * Returns one and only object of the class |
105 | | - * @return Narayam |
106 | | - */ |
107 | | - public static function getInstance() { |
108 | | - if ( !( self::$_instance instanceof self ) ) { |
109 | | - self::$_instance = new self(); |
110 | | - } |
111 | | - return self::$_instance; |
112 | | - } |
113 | | - |
114 | | - /** |
115 | | - * Hook function for the event 'BeforePageDisplay' |
116 | | - * @param OutputPage $out |
117 | | - * @param Skin $sk |
118 | | - */ |
119 | | - public function onBeforePageDisplay( &$out, &$sk ) { |
120 | | - // If current skin is not supported do nothing |
121 | | - if ( !in_array( $sk->getSkinName(), $this->_supportedSkins ) ) { |
122 | | - return true; |
123 | | - } |
124 | | - global $wgExtensionAssetsPath, $wgNarayamConfig; |
125 | | - $this->_out = $out; |
126 | | - $this->_skin = $sk; |
127 | | - // add script tag for each scheme to be loaded |
128 | | - foreach ( $wgNarayamConfig['schemes'] as $scheme ) { |
129 | | - $out->addScriptFile( "$wgExtensionAssetsPath/Narayam/{$scheme}_rules.js" ); |
130 | | - } |
131 | | - |
132 | | - // Load Narayam.js file |
133 | | - $out->addScriptFile( "$wgExtensionAssetsPath/Narayam/Narayam.js" ); |
134 | | - |
135 | | - // Place generated JS code according to configuration settings |
136 | | - $out->addInlineScript( $this->getInitJSCode() ); |
137 | | - return true; |
138 | | - } |
139 | | - |
140 | | - function formatSchemes( $str ) { |
141 | | - return sprintf( 'tr_%s', $str ); |
142 | | - } |
143 | | - |
144 | | - /** |
145 | | - * Generate JavaScript code according to configuration settings |
146 | | - * |
147 | | - * @global array $wgNarayamConfig |
148 | | - * @param Skin $skinName |
149 | | - * @return string Generated JS code |
150 | | - * @todo Needs rewriting |
151 | | - */ |
152 | | - private function getInitJSCode() { |
153 | | - global $wgNarayamConfig; |
154 | | - $str = "Narayam.shortcut.controlkey= " . Narayam::boolToString( $wgNarayamConfig['shortcut_controlkey'] ) . ";\n"; |
155 | | - $str .= "Narayam.shortcut.altkey= " . Narayam::boolToString( $wgNarayamConfig['shortcut_altkey'] ) . ";\n"; |
156 | | - $str .= "Narayam.shortcut.shiftkey= " . Narayam::boolToString( $wgNarayamConfig['shortcut_shiftkey'] ) . ";\n"; |
157 | | - $str .= "Narayam.shortcut.metakey= " . Narayam::boolToString( $wgNarayamConfig['shortcut_metakey'] ) . ";\n"; |
158 | | - $str .= sprintf( "Narayam.shortcut.key= '%s';\n", $wgNarayamConfig['shortcut_key'] ); |
159 | | - $str .= sprintf( "Narayam.checkbox.text= '%s ('+Narayam.shortcut.toString()+')';\n", wfMsgForContent( 'narayam-toggle-ime' ) /* $wgNarayamConfig['checkbox']['text'] */ ); |
160 | | - $title = Title::newFromText( wfMsgForContent( 'narayam-help-page' ) ); |
161 | | - |
162 | | - $target = ''; |
163 | | - |
164 | | - if ( $title && $title->exists() ) { |
165 | | - $target = $title->getFullURL(); |
166 | | - } |
167 | | - |
168 | | - $str .= sprintf( "Narayam.checkbox.href= '%s';\n", $target ); |
169 | | - |
170 | | - $str .= sprintf( "Narayam.checkbox.tooltip= '%s';\n", wfMsgForContent( 'narayam-checkbox-tooltip' ) ); |
171 | | - // $str .= 'Narayam.default_state = ' . Narayam::boolToString($wgNarayamConfig['default_state']) . ";\n"; |
172 | | - $str .= "Narayam.schemes = [\n"; |
173 | | - $schemeCount = count( $wgNarayamConfig['schemes'] ); |
174 | | - |
175 | | - if ( $schemeCount > 0 ) { |
176 | | - $transformed = array_map( array( $this, 'formatSchemes' ) , $wgNarayamConfig['schemes'] ); |
177 | | - $str .= implode( ',', $transformed ); |
178 | | - } |
179 | | - |
180 | | - $str .= "];\n"; |
181 | | - $str .= sprintf( "Narayam.default_scheme_index = %d;", $wgNarayamConfig['default_scheme_index'] ); |
182 | | - for ( $i = 0; $i < $schemeCount; $i++ ) { |
183 | | - $str .= sprintf( "tr_%s.text = '%s';\n", $wgNarayamConfig['schemes'][$i], wfMsg( 'narayam-' . str_replace( '_', '-', $wgNarayamConfig['schemes'][$i] ) ) ); |
184 | | - } |
185 | | - |
186 | | - $str .= 'Narayam.enabled = ' . Narayam::boolToString( $wgNarayamConfig['enabled'] ) . ";\n"; |
187 | | - |
188 | | - $str .= "function irSetup() {\n"; |
189 | | - $str .= "var elements = getAllTextInputs();\n"; |
190 | | - $str .= "inputRewrite(elements);\n"; |
191 | | - $str .= "elements = document.getElementsByTagName('textarea');"; |
192 | | - $str .= "inputRewrite(elements);\n"; |
193 | | - // $str .= sprintf("Narayam.init(%d);\n", $wgNarayamConfig['default_scheme_index']); |
194 | | - if ( in_array( $this->_skin->getSkinName(), $this->_supportedSkins ) ) { |
195 | | - $str .= 'setupNarayamFor' . $this->_skin->getSkinName() . "();\n"; |
196 | | - } |
197 | | - $str .= "}\n"; |
198 | | - $str .= "if (window.addEventListener){\n"; |
199 | | - $str .= "window.addEventListener('load', irSetup, false);\n"; |
200 | | - $str .= "} else if (window.attachEvent){\n"; |
201 | | - $str .= "window.attachEvent('onload', irSetup);\n"; |
202 | | - $str .= "}"; |
203 | | - return $str; |
204 | | - } |
205 | | - |
206 | | - /** |
207 | | - * Convert return string representation of give bool value |
208 | | - * @param bool $value |
209 | | - * @return string |
210 | | - */ |
211 | | - public static function boolToString( $value ) { |
212 | | - return ( $value ) ? 'true' : 'false'; |
213 | | - } |
214 | | - |
215 | | -} |
| 90 | +// ResourceLoader module registration |
| 91 | +$narayamTpl = array( |
| 92 | + 'localBasePath' => dirname( __FILE__ ), |
| 93 | + 'remoteExtPath' => 'Narayam', |
| 94 | +); |
| 95 | +$wgResourceModules['ext.narayam'] = $narayamTpl + array( |
| 96 | + 'scripts' => 'ext.narayam.js', |
| 97 | + 'dependencies' => 'ext.narayam.core', |
| 98 | +); |
| 99 | +$wgResourceModules['ext.narayam.core'] = $narayamTpl + array( |
| 100 | + 'scripts' => 'Narayam.js', // TODO: Rename files |
| 101 | + 'styles' => 'ext.narayam.core.css', |
| 102 | + 'skinStyles' => array( |
| 103 | + 'monobook' => 'ext.narayam.core-monobook.css', |
| 104 | + 'vector' => 'ext.narayam.core-vector.css', |
| 105 | + ), |
| 106 | + 'messages' => array( |
| 107 | + 'narayam-checkbox-tooltip', |
| 108 | + 'narayam-help-page', |
| 109 | + 'narayam-toggle-ime', |
| 110 | + ), |
| 111 | + 'dependencies' => array( 'mediawiki.util', 'jquery.textSelection' ), |
| 112 | +); |
| 113 | +$wgResourceModules['ext.narayam.rules.bn-avro'] = $narayamTpl + array( |
| 114 | + 'scripts' => 'bn_avro_rules.js', |
| 115 | + 'messages' => array( 'narayam-bn-avro' ), |
| 116 | + 'dependencies' => 'ext.narayam.core', |
| 117 | +); |
| 118 | +$wgResourceModules['ext.narayam.rules.bn-inscript'] = $narayamTpl + array( |
| 119 | + 'scripts' => 'bn_inscript_rules.js', |
| 120 | + 'messages' => array( 'narayam-bn-inscript' ), |
| 121 | + 'dependencies' => 'ext.narayam.core', |
| 122 | +); |
| 123 | +$wgResourceModules['ext.narayam.rules.bn-nkb'] = $narayamTpl + array( |
| 124 | + 'scripts' => 'bn_nkb_rules.js', |
| 125 | + 'messages' => array( 'narayam-bn-nkb' ), |
| 126 | + 'dependencies' => 'ext.narayam.core', |
| 127 | +); |
| 128 | +$wgResourceModules['ext.narayam.rules.ml-inscript'] = $narayamTpl + array( |
| 129 | + 'scripts' => 'ml_inscript_rules.js', |
| 130 | + 'messages' => array( 'narayam-ml-inscript' ), |
| 131 | + 'dependencies' => 'ext.narayam.core', |
| 132 | +); |
| 133 | +$wgResourceModules['ext.narayam.rules.ml'] = $narayamTpl + array( |
| 134 | + 'scripts' => 'ml_rules.js', |
| 135 | + 'messages' => array( 'narayam-ml' ), |
| 136 | + 'dependencies' => 'ext.narayam.core', |
| 137 | +); |
| 138 | +$wgResourceModules['ext.narayam.rules.sa'] = $narayamTpl + array( |
| 139 | + 'scripts' => 'sa_rules.js', |
| 140 | + 'messages' => array( 'narayam-sa' ), |
| 141 | + 'dependencies' => 'ext.narayam.core', |
| 142 | +); |
| 143 | +$wgResourceModules['ext.narayam.rules.ta99'] = $narayamTpl + array( |
| 144 | + 'scripts' => 'ta99_rules.js', |
| 145 | + 'messages' => array( 'narayam-ta99' ), |
| 146 | + 'dependencies' => 'ext.narayam.core', |
| 147 | +); |
| 148 | +$wgResourceModules['ext.narayam.rules.ta'] = $narayamTpl + array( |
| 149 | + 'scripts' => 'ta_rules.js', |
| 150 | + 'messages' => array( 'narayam-ta' ), |
| 151 | + 'dependencies' => 'ext.narayam.core', |
| 152 | +); |
Index: trunk/extensions/Narayam/bn_nkb_rules.js |
— | — | @@ -6,12 +6,9 @@ |
7 | 7 | * Ministry of Science and Information & Communication Technology, Govt. of Bangladesh |
8 | 8 | * License: GPLv3, CC-BY-SA 3.0 |
9 | 9 | */ |
10 | | -if(tr_bn_nkb== undefined) var tr_bn_nkb = {}; |
11 | | -else tr_bn_nkb = {}; |
12 | | -tr_bn_nkb.text = "NKB"; |
13 | | -tr_bn_nkb.description = "Bengali National Keyboard"; |
| 10 | + |
14 | 11 | // Normal rules |
15 | | -tr_bn_nkb.rules = [ |
| 12 | +var rules = [ |
16 | 13 | ['1', '', '১'], |
17 | 14 | ['2', '', '২'], |
18 | 15 | ['3', '', '৩'], |
— | — | @@ -83,8 +80,7 @@ |
84 | 81 | ]; |
85 | 82 | |
86 | 83 | // Extended layout for National Keyboard. Works in Firefox only |
87 | | -tr_bn_nkb.extended_keyboard = true; |
88 | | -tr_bn_nkb.rules_x = [ |
| 84 | +var rules_x = [ |
89 | 85 | ['1', '', '৴'], |
90 | 86 | ['2', '', '৵'], |
91 | 87 | ['3', '', '৶'], |
— | — | @@ -131,3 +127,11 @@ |
132 | 128 | ['X', '', 'ঔ'], |
133 | 129 | ['C', '', 'ঐ'] |
134 | 130 | ]; |
| 131 | + |
| 132 | +jQuery.narayam.addScheme( 'bn-nkb', { |
| 133 | + 'namemsg': 'narayam-bn-nkb', |
| 134 | + 'extended_keyboard': true, |
| 135 | + 'lookbackLength': 0, |
| 136 | + 'rules': rules, |
| 137 | + 'rules_x': rules_x |
| 138 | +} ); |