--- a/src/pyams_notify/skin/resources/js/pyams_notify.min.js Wed Jun 26 11:13:16 2019 +0200
+++ b/src/pyams_notify/skin/resources/js/pyams_notify.min.js Wed Jun 26 18:55:20 2019 +0200
@@ -1,1 +1,1 @@
-!function(t,n){"use strict";var o=n.MyAMS,e={connection:null,initConnection:function(){var n=t("[data-ams-notify-server]","#user-activity").data("ams-notify-server");if(n){var o="ws";"https:"===window.location.protocol&&(o+="s");var i=t.WebSocket(o+"://"+n+"/subscribe");i.onopen=e.onSocketOpened,i.onmessage=e.onSocketMessage,i.onerror=e.onSocketError,i.onclose=e.onSocketClosed,e.connection=i,setInterval(e.checkConnection,3e4)}},checkConnection:function(){null!==e.connection&&e.connection.readyState!==WebSocket.CLOSED||e.initConnection()},onSocketOpened:function(t){n.console&&n.console.debug("WS notifications connection opened"),o.ajax&&o.ajax.post("get-notifications-context.json",{},function(t){""!==t.principal.id&&(e.connection.send(JSON.stringify({action:"subscribe",principal:t.principal,context:t.context})),o.ajax.post("get-user-notifications.json",{},e.showNotifications))})},onSocketMessage:function(t){var i=JSON.parse(t.data),a=i.status;"error"===a?(n.console&&n.console.error(t.data),o.skin&&o.skin.smallBox(a,{title:i.error,content:i.message})):(e.notifyOnDesktop(i),e.notifyInWebpage(i))},onSocketError:function(t){n.console&&n.console.log(t)},onSocketClosed:function(t){e.connection=null,n.console&&n.console.debug("WS connection closed")},notifyOnDesktop:function(t){function n(){var n={title:t.title,body:t.message,icon:t.source.avatar};new Notification(n.title,n).onclick=function(){t.url&&window.open(t.url)}}window.Notification&&"denied"!==Notification.permission&&("default"===Notification.permission?Notification.requestPermission(function(t){"granted"===t&&n()}):n())},createNotification:function(n){var o=t("<li></li>"),e=t("<span></span>"),i=t("<a></a>").addClass("msg").attr("href",n.url);return n.source.avatar?t("<img>").addClass("air air-top-left margin-top-2").attr("src",n.source.avatar).appendTo(i):t("<i></i>").addClass("fa fa-2x fa-user air air-top-left img margin-left-5 margin-top-2").appendTo(i),t("<time></time>").text(n.timestamp).appendTo(i),t("<span></span>").addClass("from").text(n.source.title).appendTo(i),t("<span></span>").addClass("msg-body").text(n.message).appendTo(i),i.appendTo(e),e.appendTo(o),o},notifyInWebpage:function(n){var i=t(".badge","#user-activity >span"),a=parseInt(i.text());i.text(a+1);var c=t(".notification-body","#user-activity");e.createNotification(n).prependTo(c),o.skin&&o.skin.checkNotification()},showNotifications:function(n){var i=n.timestamp,a=n.notifications,c=t(".badge","#user-activity >span"),s=t(".notification-body","#user-activity"),r=t("li",s).length;if(s.empty(),a.length>0){s.prev("p").hide();for(var p=0;p<a.length;p++){var f=a[p];e.createNotification(f).appendTo(s)}var l=t("li",s).length;c.text(l-r)}else s.prev("p").show(),c.text("");var d=t("#activity-update");d.text(d.data("ams-base-label").replace(/\{0\}/,i)),o.skin&&o.skin.checkNotification()},refreshNotifications:function(){return function(){o.ajax&&o.ajax.post("get-user-notifications.json",{},e.showNotifications)}}};n.PyAMS_notify=e,o.ajax&&o.ajax.check(t.WebSocket,"/--static--/pyams_notify/js/jquery-WebSocket"+o.devext+".js",function(){e.initConnection()})}(jQuery,this);
+!function(t,n){"use strict";var o=n.MyAMS,e={connection:null,initConnection:function(){var n=t("[data-ams-notify-server]","#user-activity").data("ams-notify-server");if(n){var o="ws";"https:"===window.location.protocol&&(o+="s");var i=t.WebSocket(o+"://"+n+"/subscribe");i.onopen=e.onSocketOpened,i.onmessage=e.onSocketMessage,i.onerror=e.onSocketError,i.onclose=e.onSocketClosed,e.connection=i,setInterval(e.checkConnection,3e4)}},checkConnection:function(){null!==e.connection&&e.connection.readyState!==WebSocket.CLOSED||e.initConnection()},onSocketOpened:function(t){n.console&&n.console.debug("WS notifications connection opened"),o.ajax&&o.ajax.post("get-notifications-context.json",{},function(t){""!==t.principal.id&&(e.connection.send(JSON.stringify({action:"subscribe",host:window.location.host,principal:t.principal,context:t.context})),o.ajax.post("get-user-notifications.json",{},e.showNotifications))})},onSocketMessage:function(t){var i=JSON.parse(t.data),a=i.status;"error"===a?(n.console&&n.console.error(t.data),o.skin&&o.skin.smallBox(a,{title:i.error,content:i.message})):(e.notifyOnDesktop(i),e.notifyInWebpage(i))},onSocketError:function(t){n.console&&n.console.log(t)},onSocketClosed:function(t){e.connection=null,n.console&&n.console.debug("WS connection closed")},notifyOnDesktop:function(t){function n(){var n={title:t.title,body:t.message,icon:t.source.avatar};new Notification(n.title,n).onclick=function(){t.url&&window.open(t.url)}}window.Notification&&"denied"!==Notification.permission&&("default"===Notification.permission?Notification.requestPermission(function(t){"granted"===t&&n()}):n())},createNotification:function(n){var o=t("<li></li>"),e=t("<span></span>"),i=t("<a></a>").addClass("msg").attr("href",n.url);return n.source.avatar?t("<img>").addClass("air air-top-left margin-top-2").attr("src",n.source.avatar).appendTo(i):t("<i></i>").addClass("fa fa-2x fa-user air air-top-left img margin-left-5 margin-top-2").appendTo(i),t("<time></time>").text(n.timestamp).appendTo(i),t("<span></span>").addClass("from").text(n.source.title).appendTo(i),t("<span></span>").addClass("msg-body").text(n.message).appendTo(i),i.appendTo(e),e.appendTo(o),o},notifyInWebpage:function(n){var i=t(".badge","#user-activity >span"),a=parseInt(i.text());i.text(a+1);var c=t(".notification-body","#user-activity");e.createNotification(n).prependTo(c),o.skin&&o.skin.checkNotification()},showNotifications:function(n){var i=n.timestamp,a=n.notifications,c=t(".badge","#user-activity >span"),s=t(".notification-body","#user-activity"),r=t("li",s).length;if(s.empty(),a.length>0){s.prev("p").hide();for(var p=0;p<a.length;p++){var f=a[p];e.createNotification(f).appendTo(s)}var l=t("li",s).length;c.text(l-r)}else s.prev("p").show(),c.text("");var d=t("#activity-update");d.text(d.data("ams-base-label").replace(/\{0\}/,i)),o.skin&&o.skin.checkNotification()},refreshNotifications:function(){return function(){o.ajax&&o.ajax.post("get-user-notifications.json",{},e.showNotifications)}}};n.PyAMS_notify=e,o.ajax&&o.ajax.check(t.WebSocket,"/--static--/pyams_notify/js/jquery-WebSocket"+o.devext+".js",function(){e.initConnection()})}(jQuery,this);