2015-09-05 18:04:41 +00:00
|
|
|
var Notification = window.Notification || window.mozNotification || window.webkitNotification;
|
|
|
|
var data;
|
|
|
|
var laststate;
|
|
|
|
|
|
|
|
Notification.requestPermission(function (permission) {
|
|
|
|
// console.log(permission);
|
|
|
|
});
|
|
|
|
|
|
|
|
function showopen() {
|
|
|
|
var instance = new Notification(
|
|
|
|
"CTDO - Status", {
|
|
|
|
body: "Der Chaostreff Dortmund ist nun offen.",
|
|
|
|
icon: "/img/green.png"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
instance.onclick = function () {
|
|
|
|
// Something to do
|
|
|
|
};
|
|
|
|
instance.onerror = function () {
|
|
|
|
// Something to do
|
|
|
|
};
|
|
|
|
instance.onshow = function () {
|
|
|
|
setTimeout(function(){
|
|
|
|
instance.close();
|
|
|
|
}, 3000);
|
|
|
|
};
|
|
|
|
instance.onclose = function () {
|
|
|
|
// Something to do
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function showclose() {
|
|
|
|
var instance = new Notification(
|
|
|
|
"CTDO - Status", {
|
|
|
|
body: "Der Chaostreff Dortmund ist nun geschlossen.",
|
|
|
|
icon: "/img/red.png"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
instance.onclick = function () {
|
|
|
|
// Something to do
|
|
|
|
};
|
|
|
|
instance.onerror = function () {
|
|
|
|
// Something to do
|
|
|
|
};
|
|
|
|
instance.onshow = function () {
|
|
|
|
setTimeout(function(){
|
|
|
|
instance.close();
|
|
|
|
}, 3000);
|
|
|
|
};
|
|
|
|
instance.onclose = function () {
|
|
|
|
// Something to do
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-09-11 19:10:21 +00:00
|
|
|
function showctdo() {
|
|
|
|
var instance = new Notification(
|
|
|
|
"CTDO - Easteregg", {
|
|
|
|
body: "Was? Nein! Wieso?",
|
|
|
|
icon: "/img/yellow.png"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
instance.onclick = function () {
|
|
|
|
showctdo;
|
|
|
|
};
|
|
|
|
instance.onerror = function () {
|
|
|
|
// Something to do
|
|
|
|
};
|
|
|
|
instance.onshow = function () {
|
|
|
|
setTimeout(function(){
|
|
|
|
instance.close();
|
|
|
|
}, 3000);
|
|
|
|
};
|
|
|
|
instance.onclose = function () {
|
|
|
|
// Something to do
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-09-05 18:04:41 +00:00
|
|
|
window.setInterval(function(){
|
|
|
|
$.getJSON("/api/simple/v2", function(data){
|
|
|
|
var html = [];
|
|
|
|
|
|
|
|
$.each(data, function(index, value){
|
|
|
|
if (index == 'state' && value == false && laststate != false) {
|
|
|
|
laststate = false;
|
|
|
|
showclose();
|
|
|
|
}
|
|
|
|
else if (index == 'state' && value == true && laststate != true) {
|
|
|
|
laststate = true;
|
|
|
|
showopen();
|
|
|
|
}else {
|
|
|
|
// Nothing
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}, 60000);
|