-
Notifications
You must be signed in to change notification settings - Fork 1
/
webdictionary.js
61 lines (47 loc) · 1.25 KB
/
webdictionary.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
(function(){
var pluginName = "webdictionary";
var plugin = function(){
$lib = AtKit.lib();
// Internationalisation
AtKit.addLocalisationMap("en", {
"webdictionary_title" : "Use the dictionary"
});
// Web Dictionary
AtKit.addButton(
'webdictionary',
AtKit.localisation("webdictionary_title"),
AtKit.getPluginURL() + 'images/dictionary.png',
function(dialogs, functions){
try{
var b=window.getSelection(),a=b?b.toString().replace(/(^\W+|\W+$)/g,''):'';
if(!a){
a=prompt('Enter a word to look up');
if(!a)return
}
var c='http://dictionary.reference.com/search?r=1&q='+encodeURIComponent(a);window.open(c)
}
catch(d){
alert('Error:\n'+d.message)
}
},
null, null
);
};
if(typeof window['AtKit'] == "undefined"){
window.AtKitLoaded = function(){
var eventAction = null;
this.subscribe = function(fn) {
eventAction = fn;
};
this.fire = function(sender, eventArgs) {
if (eventAction != null) {
eventAction(sender, eventArgs);
}
};
}
window['AtKitLoaded'] = new AtKitLoaded();
window['AtKitLoaded'].subscribe(function(){ AtKit.registerPlugin(pluginName, plugin); });
} else {
AtKit.registerPlugin(pluginName, plugin);
}
})();