-
Notifications
You must be signed in to change notification settings - Fork 25
/
helper.js
44 lines (42 loc) · 951 Bytes
/
helper.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
// Generated by CoffeeScript 1.10.0
var helperFn;
helperFn = function(window, $) {
var gConfig;
gConfig = window.gConfig;
return window.helper = {
getRandomInt: function(min, max) {
if (min == null) {
min = 1;
}
if (max == null) {
max = 10;
}
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min;
},
sendMessage: function(config) {
var dfd;
dfd = $.Deferred();
chrome.runtime.sendMessage(config, function(response) {
return dfd.resolve(response);
});
return dfd;
},
getJson: function(url, data) {
return this.sendMessage({
url: url,
data: data,
type: 'getJson'
});
},
postJson: function(url, data) {
return this.sendMessage({
url: url,
data: data,
type: 'postJson'
});
}
};
};
helperFn(this, $);