Moved the if(enabled) to notification api
This commit is contained in:
parent
4586e7e12a
commit
e4fae9ca53
|
@ -86,10 +86,10 @@ gpower = new JustGage({
|
||||||
});
|
});
|
||||||
|
|
||||||
function stateNotification(state) {
|
function stateNotification(state) {
|
||||||
if (state == true && laststate != true && laststate != null && enabledNotifications) {
|
if (state == true && laststate != true && laststate != null) {
|
||||||
laststate = true;
|
laststate = true;
|
||||||
showNotification("CTDO - Status", "Der Chaostreff ist nun offen.", "/img/green.png", 4);
|
showNotification("CTDO - Status", "Der Chaostreff ist nun offen.", "/img/green.png", 4);
|
||||||
} else if (state == false && laststate != false && laststate != null && enabledNotifications) {
|
} else if (state == false && laststate != false && laststate != null) {
|
||||||
laststate = false;
|
laststate = false;
|
||||||
showNotification("CTDO - Staus", "Der Chaostreff ist nun geschlossen", "/img/red.png", 4);
|
showNotification("CTDO - Staus", "Der Chaostreff ist nun geschlossen", "/img/red.png", 4);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -26,25 +26,27 @@ function toggleNotifications() {
|
||||||
|
|
||||||
|
|
||||||
function showNotification(name, body, icon, timeout) {
|
function showNotification(name, body, icon, timeout) {
|
||||||
var instance = new Notification(
|
if (enabledNotifications) {
|
||||||
name, {
|
var instance = new Notification(
|
||||||
body: body,
|
name, {
|
||||||
icon: icon
|
body: body,
|
||||||
}
|
icon: icon
|
||||||
);
|
}
|
||||||
|
);
|
||||||
|
|
||||||
instance.onclick = function () {
|
instance.onclick = function () {
|
||||||
// Something to do
|
// Something to do
|
||||||
};
|
};
|
||||||
instance.onerror = function () {
|
instance.onerror = function () {
|
||||||
// Something to do
|
// Something to do
|
||||||
};
|
};
|
||||||
instance.onshow = function () {
|
instance.onshow = function () {
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
instance.close();
|
instance.close();
|
||||||
}, timeout * 1000);
|
}, timeout * 1000);
|
||||||
};
|
};
|
||||||
instance.onclose = function () {
|
instance.onclose = function () {
|
||||||
// Something to do
|
// Something to do
|
||||||
};
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue