|
|
@@ -2,6 +2,7 @@ $(document).ready(function() {
|
|
|
|
|
|
var lastOpenedBoxData; // Stores JSON-data of last opened editBox
|
|
|
var notifications = []; // Stores noty-Notifications
|
|
|
+ var reminders = []; // Stores reminder-noty-Notifications
|
|
|
|
|
|
function noty_error_retry() {
|
|
|
notifications.push(
|
|
|
@@ -13,6 +14,48 @@ $(document).ready(function() {
|
|
|
}));
|
|
|
}
|
|
|
|
|
|
+ window.noty_reminder = noty_reminder;
|
|
|
+
|
|
|
+ function noty_reminder(reminderID) {
|
|
|
+ var reminderID = reminderID;
|
|
|
+ reminders[reminderID] = noty({
|
|
|
+ layout : 'topCenter',
|
|
|
+ text : 'Erinnerung:<br>',
|
|
|
+ type : 'alert',
|
|
|
+ buttons : [
|
|
|
+ {addClass: 'btn btn-primary', text: 'OK', onClick: function(noty) {
|
|
|
+ data = {
|
|
|
+ reminderID: reminderID
|
|
|
+ };
|
|
|
+
|
|
|
+ $.getJSON("ajax.php?action=setReminderReminded", data, function(r) {
|
|
|
+ if(r['status'] == "OK") {
|
|
|
+ noty.close();
|
|
|
+ reminders[reminderID] = undefined;
|
|
|
+ } else {
|
|
|
+ noty_error_retry();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }},
|
|
|
+ {addClass: 'btn btn-danger', text: 'Snooze', onClick: function(noty) {
|
|
|
+ data = {
|
|
|
+ reminderID: reminderID
|
|
|
+ };
|
|
|
+
|
|
|
+ $.getJSON("ajax.php?action=setReminderSnooze", data, function(r) {
|
|
|
+ if(r['status'] == "OK") {
|
|
|
+ noty.close();
|
|
|
+ reminders[reminderID] = undefined;
|
|
|
+ } else {
|
|
|
+ noty_error_retry();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }}
|
|
|
+ ]
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
function getUrlGetParameter(val) {
|
|
|
var result = "Not found",
|
|
|
tmp = [];
|
|
|
@@ -26,6 +69,28 @@ $(document).ready(function() {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ function handleEvents() {
|
|
|
+ data = {
|
|
|
+ userID: $("body").attr("data-user-id")
|
|
|
+ };
|
|
|
+
|
|
|
+ $.getJSON("ajax.php?action=getEvents", data, function(r) {
|
|
|
+ switch (r['type']) {
|
|
|
+ case 'reminder':
|
|
|
+ r['reminders'].forEach(function(item) {
|
|
|
+ if(reminders[item['id']] == undefined) {
|
|
|
+ noty_reminder(item['id']);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ console.log("unknown event type:" + r['type']);
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
function addSpinner(element) {
|
|
|
element.append("<div class=\"spinner\"><div class=\"bounce1\"></div><div class=\"bounce2\"></div><div class=\"bounce3\"></div></div>");
|
|
|
}
|
|
|
@@ -507,4 +572,7 @@ $(document).ready(function() {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
+ handleEvents();
|
|
|
+ setInterval(handleEvents, 60000);
|
|
|
+
|
|
|
});
|