-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
39 lines (36 loc) · 1.06 KB
/
popup.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
var red = "#AC3931";
var green = "#4FCC54"
window.onload = function() {
var message = "";
document.getElementById("login").onclick = function() {
chrome.extension.sendMessage({
type: "login"
});
};
chrome.extension.sendMessage({
type: "get-status"
},
function(response) {
renderError(response.error);
renderStatus(response.message);
renderToggle(response.onoff, response.boolv);
});
document.getElementById("onoff").onclick = function() {
chrome.extension.sendMessage({
type: "toggle"
},
function(response) {
renderToggle(response.onoff, response.boolv);
});
}
}
function renderToggle(onOrOff, boolv) {
document.getElementById("onoff").textContent = onOrOff;
document.getElementById("onoff").style.background = (boolv) ? green : red;
}
function renderError(message) {
document.getElementById("error").innerText = message;
}
function renderStatus(message) {
document.getElementById("status").innerHTML = message;
}