This repository has been archived by the owner on Oct 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
conf.js
55 lines (48 loc) · 1.57 KB
/
conf.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
var hudson = hudson || {};
hudson.conf = function () {
var default_url = "http://ci.hudson-labs.org/",
default_pollIntervall = 10,
default_notifications = true;
function setPollIntervall(minutes) {
var pollIntervall = parseInt(minutes);
if (0 < pollIntervall && pollIntervall < (24 * 60)) {
localStorage.pollIntervall = pollIntervall;
}
}
function setHudsonURL(url) {
var slash = '/';
if (slash !== url.substr( url.length - slash.length, slash.length ) ) {
url = url + slash;
}
localStorage.hudsonUrl = url;
}
function setNotificationsEnabled(enabled) {
localStorage.notifications = enabled;
}
function get(name, defaultValue) {
return function() {
if (localStorage[name]) {
return localStorage[name];
}
return defaultValue;
}
}
function getBoolean(name, defaultValue) {
return function() {
return get(name, defaultValue)() === 'true';
}
}
return {
pollIntervall : get('pollIntervall', default_pollIntervall),
hudsonURL : get('hudsonUrl', default_url),
notifications : getBoolean('notifications', default_notifications),
set : function (values) {
setPollIntervall(values.pollIntervall);
setHudsonURL(values.hudsonURL);
setNotificationsEnabled(values.notifications);
},
apiURL : function() {
return this.hudsonURL() + "api/json/";
}
}
}();