forked from sanitz/hudson-chrome-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.js
52 lines (46 loc) · 1.89 KB
/
options.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
hudson.options = function(conf) {
var hudsonUrlTextbox, pollIntervallTextbox, notificationsCheckbox, saveButton, saveStatus;
function showSaveStatus(show) {
saveStatus.style.display = show ? '' : "none";
saveButton.disabled = show;
}
function display() {
hudsonUrlTextbox.value = conf.hudsonURL();
pollIntervallTextbox.value = conf.pollIntervall();
notificationsCheckbox.checked = conf.notifications();
saveButton.disabled = true;
}
return {
save : function () {
conf.set({
hudsonURL : hudsonUrlTextbox.value,
pollIntervall: pollIntervallTextbox.value,
notifications: notificationsCheckbox.checked
});
showSaveStatus(true);
display();
chrome.extension.getBackgroundPage().hudson.init();
},
markDirty : function () {
showSaveStatus(false)
},
init : function () {
hudsonUrlTextbox = document.getElementById("hudson-url"),
pollIntervallTextbox = document.getElementById("poll-intervall"),
notificationsCheckbox = document.getElementById("desktop-notifications"),
saveButton = document.getElementById("save-button");
saveStatus = document.getElementById("save-status");
display();
}
};
}(hudson.conf);
//set event handlers
window.onload = setEventHandlers;
function setEventHandlers(){
document.getElementById("hudson-url").oninput = hudson.options.markDirty;
document.getElementById("desktop-notifications").onchange = hudson.options.markDirty;
document.getElementById("poll-intervall").oninput = hudson.options.markDirty;
document.getElementById("save-button").onclick = hudson.options.save;
document.getElementById("cancel-button").onclick = hudson.options.save;
hudson.options.init();
}