diff --git a/CHANGES.md b/CHANGES.md index 81ac0da4..81e6122e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -52,6 +52,8 @@ * Change IPT urls to reduce 301 redirection * Add detection of file-system having no support for link creation (e.g. Unraid shares) * Add catch exceptions when unable to cache a requests response +* Update PNotify to latest master (2014-12-25) for desktop notifications +* Add desktop notifications [develop changelog] * Change uT params from unicode to str.format as magnet URLs worked but sending files in POST bodies failed diff --git a/gui/slick/js/ajaxNotifications.js b/gui/slick/js/ajaxNotifications.js index 92b2fc22..80937167 100644 --- a/gui/slick/js/ajaxNotifications.js +++ b/gui/slick/js/ajaxNotifications.js @@ -7,25 +7,30 @@ PNotify.prototype.options.width = '340px'; PNotify.prototype.options.shadow = false; PNotify.prototype.options.addclass = 'stack-bottomright'; PNotify.prototype.options.stack = {'dir1': 'up', 'dir2': 'left', 'firstpos1': 25, 'firstpos2': 25}; +PNotify.desktop.permission(); function check_notifications() { - if(document.visibilityState == 'visible') { - $.getJSON(message_url, function(data){ - $.each(data, function(name,data){ - new PNotify({ - type: data.type, - hide: data.type == 'notice', - title: data.title, - text: data.message, - history: false - }); - }); - }); - } - - setTimeout(check_notifications, 3000) + if(document.visibilityState == 'visible') { + $.getJSON(message_url, function(data){ + $.each(data, function(name,data){ + new PNotify({ + type: data.type, + hide: data.type == 'notice', + title: data.title, + text: data.message.replace(/<\/?i>/ig, '*'), + history: false, + desktop: { + desktop: true, + icon: '../images/ico/apple-touch-icon-180x180.png' + } + }); + }); + }); + } + + setTimeout(check_notifications, 3000) } $(document).ready(function(){ - check_notifications(); + check_notifications(); }); \ No newline at end of file diff --git a/gui/slick/js/lib/pnotify.custom.min.js b/gui/slick/js/lib/pnotify.custom.min.js index 704c85ae..0d558570 100644 --- a/gui/slick/js/lib/pnotify.custom.min.js +++ b/gui/slick/js/lib/pnotify.custom.min.js @@ -1,42 +1 @@ -/* -PNotify 2.0.1 sciactive.com/pnotify/ -(C) 2014 Hunter Perrin -license GPL/LGPL/MPL -*/ -(function(c){"function"===typeof define&&define.amd?define("pnotify",["jquery"],c):c(jQuery)})(function(c){var p={dir1:"down",dir2:"left",push:"bottom",spacing1:25,spacing2:25,context:c("body")},f,g,h=c(window),m=function(){g=c("body");PNotify.prototype.options.stack.context=g;h=c(window);h.bind("resize",function(){f&&clearTimeout(f);f=setTimeout(function(){PNotify.positionAll(!0)},10)})};PNotify=function(b){this.parseOptions(b);this.init()};c.extend(PNotify.prototype,{version:"2.0.1",options:{title:!1, -title_escape:!1,text:!1,text_escape:!1,styling:"bootstrap3",addclass:"",cornerclass:"",auto_display:!0,width:"300px",min_height:"16px",type:"notice",icon:!0,opacity:1,animation:"fade",animate_speed:"slow",position_animate_speed:500,shadow:!0,hide:!0,delay:8E3,mouse_reset:!0,remove:!0,insert_brs:!0,destroy:!0,stack:p},modules:{},runModules:function(b,a){var c,e;for(e in this.modules)if(c="object"===typeof a&&e in a?a[e]:a,"function"===typeof this.modules[e][b])this.modules[e][b](this,"object"===typeof this.options[e]? -this.options[e]:{},c)},state:"initializing",timer:null,styles:null,elem:null,container:null,title_container:null,text_container:null,animating:!1,timerHide:!1,init:function(){var b=this;this.modules={};c.extend(!0,this.modules,PNotify.prototype.modules);this.styles="object"===typeof this.options.styling?this.options.styling:PNotify.styling[this.options.styling];this.elem=c("
",{"class":"ui-pnotify "+this.options.addclass,css:{display:"none"},mouseenter:function(a){if(b.options.mouse_reset&& -"out"===b.animating){if(!b.timerHide)return;b.cancelRemove()}b.options.hide&&b.options.mouse_reset&&b.cancelRemove()},mouseleave:function(a){b.options.hide&&b.options.mouse_reset&&b.queueRemove();PNotify.positionAll()}});this.container=c("",{"class":this.styles.container+" ui-pnotify-container "+("error"===this.options.type?this.styles.error:"info"===this.options.type?this.styles.info:"success"===this.options.type?this.styles.success:this.styles.notice)}).appendTo(this.elem);""!==this.options.cornerclass&& -this.container.removeClass("ui-corner-all").addClass(this.options.cornerclass);this.options.shadow&&this.container.addClass("ui-pnotify-shadow");!1!==this.options.icon&&c("",{"class":"ui-pnotify-icon"}).append(c("",{"class":!0===this.options.icon?"error"===this.options.type?this.styles.error_icon:"info"===this.options.type?this.styles.info_icon:"success"===this.options.type?this.styles.success_icon:this.styles.notice_icon:this.options.icon})).prependTo(this.container);this.title_container= -c("",{"class":"ui-pnotify-title"}).appendTo(this.container);!1===this.options.title?this.title_container.hide():this.options.title_escape?this.title_container.text(this.options.title):this.title_container.html(this.options.title);this.text_container=c("",{"class":"ui-pnotify-text"}).appendTo(this.container);!1===this.options.text?this.text_container.hide():this.options.text_escape?this.text_container.text(this.options.text):this.text_container.html(this.options.insert_brs?String(this.options.text).replace(/\n/g, -"i.addpos2&&(i.addpos2=s.height());break;case"left":case"right":s.outerWidth(!0)>i.addpos2&&(i.addpos2=s.width())}if("number"==typeof i.nextpos1)if(i.animation&&(c>i.nextpos1||r.top||r.bottom||r.right||r.left))switch(i.dir1){case"down":r.top=i.nextpos1+"px";break;case"up":r.bottom=i.nextpos1+"px";break;case"left":r.right=i.nextpos1+"px";break;case"right":r.left=i.nextpos1+"px"}else s.css(a,i.nextpos1+"px");switch((r.top||r.bottom||r.right||r.left)&&s.animate(r,{duration:this.options.position_animate_speed,queue:!1}),i.dir1){case"down":case"up":i.nextpos1+=s.height()+("undefined"==typeof i.spacing1?25:i.spacing1);break;case"left":case"right":i.nextpos1+=s.width()+("undefined"==typeof i.spacing1?25:i.spacing1)}}return this}},queuePosition:function(t,o){return i&&clearTimeout(i),o||(o=10),i=setTimeout(function(){PNotify.positionAll(t)},o),this},cancelRemove:function(){return this.timer&&window.clearTimeout(this.timer),"closing"===this.state&&(this.elem.stop(!0),this.state="open",this.animating="in",this.elem.css("height","auto").animate({width:this.options.width,opacity:this.options.opacity},"fast")),this},queueRemove:function(){var t=this;return this.cancelRemove(),this.timer=window.setTimeout(function(){t.remove(!0)},isNaN(this.options.delay)?0:this.options.delay),this}}),t.extend(PNotify,{notices:[],removeAll:function(){t.each(PNotify.notices,function(){this.remove&&this.remove(!1)})},positionAll:function(o){if(i&&clearTimeout(i),i=null,PNotify.notices&&PNotify.notices.length)t.each(PNotify.notices,function(){var t=this.options.stack;t&&(t.nextpos1=t.firstpos1,t.nextpos2=t.firstpos2,t.addpos2=0,t.animation=o)}),t.each(PNotify.notices,function(){this.position()});else{var s=PNotify.prototype.options.stack;s&&(delete s.nextpos1,delete s.nextpos2)}},styling:{jqueryui:{container:"ui-widget ui-widget-content ui-corner-all",notice:"ui-state-highlight",notice_icon:"ui-icon ui-icon-info",info:"",info_icon:"ui-icon ui-icon-info",success:"ui-state-default",success_icon:"ui-icon ui-icon-circle-check",error:"ui-state-error",error_icon:"ui-icon ui-icon-alert"},bootstrap2:{container:"alert",notice:"",notice_icon:"icon-exclamation-sign",info:"alert-info",info_icon:"icon-info-sign",success:"alert-success",success_icon:"icon-ok-sign",error:"alert-error",error_icon:"icon-warning-sign"},bootstrap3:{container:"alert",notice:"alert-warning",notice_icon:"glyphicon glyphicon-exclamation-sign",info:"alert-info",info_icon:"glyphicon glyphicon-info-sign",success:"alert-success",success_icon:"glyphicon glyphicon-ok-sign",error:"alert-danger",error_icon:"glyphicon glyphicon-warning-sign"}}}),PNotify.styling.fontawesome=t.extend({},PNotify.styling.bootstrap3),t.extend(PNotify.styling.fontawesome,{notice_icon:"fa fa-exclamation-circle",info_icon:"fa fa-info",success_icon:"fa fa-check",error_icon:"fa fa-warning"}),document.body?n():t(n),PNotify}),function(t){"function"==typeof define&&define.amd?define("pnotify.desktop",["jquery","pnotify"],t):t(jQuery,PNotify)}(function(t,i){var o,s=function(t,i){return(s="Notification"in window?function(t,i){return new Notification(t,i)}:"mozNotification"in navigator?function(t,i){return navigator.mozNotification.createNotification(t,i.body,i.icon).show()}:"webkitNotifications"in window?function(t,i){return window.webkitNotifications.createNotification(i.icon,t,i.body)}:function(){return null})(t,i)};i.prototype.options.desktop={desktop:!1,icon:null,tag:null},i.prototype.modules.desktop={tag:null,icon:null,genNotice:function(t,i){this.icon=null===i.icon?"http://sciactive.com/pnotify/includes/desktop/"+t.options.type+".png":i.icon===!1?null:i.icon,(null===this.tag||null!==i.tag)&&(this.tag=null===i.tag?"PNotify-"+Math.round(1e6*Math.random()):i.tag),t.desktop=s(t.options.title,{icon:this.icon,body:t.options.text,tag:this.tag}),"close"in t.desktop||(t.desktop.close=function(){t.desktop.cancel()}),t.desktop.onclick=function(){t.elem.trigger("click")},t.desktop.onclose=function(){"closing"!==t.state&&"closed"!==t.state&&t.remove()}},init:function(t,s){s.desktop&&(o=i.desktop.checkPermission(),0==o&&this.genNotice(t,s))},update:function(t,i){0==o&&i.desktop&&this.genNotice(t,i)},beforeOpen:function(t,i){0==o&&i.desktop&&t.elem.css({left:"-10000px",display:"none"})},afterOpen:function(t,i){0==o&&i.desktop&&(t.elem.css({left:"-10000px",display:"none"}),"show"in t.desktop&&t.desktop.show())},beforeClose:function(t,i){0==o&&i.desktop&&t.elem.css({left:"-10000px",display:"none"})},afterClose:function(t,i){0==o&&i.desktop&&(t.elem.css({left:"-10000px",display:"none"}),t.desktop.close())}},i.desktop={permission:function(){"undefined"!=typeof Notification&&"requestPermission"in Notification?Notification.requestPermission():"webkitNotifications"in window&&window.webkitNotifications.requestPermission()},checkPermission:function(){return"undefined"!=typeof Notification&&"permission"in Notification?"granted"==Notification.permission?0:1:"webkitNotifications"in window?window.webkitNotifications.checkPermission():1}},o=i.desktop.checkPermission()}),function(t){"function"==typeof define&&define.amd?define("pnotify.buttons",["jquery","pnotify"],t):t(jQuery,PNotify)}(function(t,i){i.prototype.options.buttons={closer:!0,closer_hover:!0,sticker:!0,sticker_hover:!0,labels:{close:"Close",stick:"Stick"}},i.prototype.modules.buttons={myOptions:null,closer:null,sticker:null,init:function(i,o){var s=this;this.myOptions=o,i.elem.on({mouseenter:function(){!s.myOptions.sticker||i.options.nonblock&&i.options.nonblock.nonblock||s.sticker.trigger("pnotify_icon").css("visibility","visible"),!s.myOptions.closer||i.options.nonblock&&i.options.nonblock.nonblock||s.closer.css("visibility","visible")},mouseleave:function(){s.myOptions.sticker_hover&&s.sticker.css("visibility","hidden"),s.myOptions.closer_hover&&s.closer.css("visibility","hidden")}}),this.sticker=t("
",{"class":"ui-pnotify-sticker",css:{cursor:"pointer",visibility:o.sticker_hover?"hidden":"visible"},click:function(){i.options.hide=!i.options.hide,i.options.hide?i.queueRemove():i.cancelRemove(),t(this).trigger("pnotify_icon")}}).bind("pnotify_icon",function(){t(this).children().removeClass(i.styles.pin_up+" "+i.styles.pin_down).addClass(i.options.hide?i.styles.pin_up:i.styles.pin_down)}).append(t("",{"class":i.styles.pin_up,title:o.labels.stick})).prependTo(i.container),(!o.sticker||i.options.nonblock&&i.options.nonblock.nonblock)&&this.sticker.css("display","none"),this.closer=t("",{"class":"ui-pnotify-closer",css:{cursor:"pointer",visibility:o.closer_hover?"hidden":"visible"},click:function(){i.remove(!1),s.sticker.css("visibility","hidden"),s.closer.css("visibility","hidden")}}).append(t("",{"class":i.styles.closer,title:o.labels.close})).prependTo(i.container),(!o.closer||i.options.nonblock&&i.options.nonblock.nonblock)&&this.closer.css("display","none")},update:function(t,i){this.myOptions=i,!i.closer||t.options.nonblock&&t.options.nonblock.nonblock?this.closer.css("display","none"):i.closer&&this.closer.css("display","block"),!i.sticker||t.options.nonblock&&t.options.nonblock.nonblock?this.sticker.css("display","none"):i.sticker&&this.sticker.css("display","block"),this.sticker.trigger("pnotify_icon"),i.sticker_hover?this.sticker.css("visibility","hidden"):t.options.nonblock&&t.options.nonblock.nonblock||this.sticker.css("visibility","visible"),i.closer_hover?this.closer.css("visibility","hidden"):t.options.nonblock&&t.options.nonblock.nonblock||this.closer.css("visibility","visible")}},t.extend(i.styling.jqueryui,{closer:"ui-icon ui-icon-close",pin_up:"ui-icon ui-icon-pin-w",pin_down:"ui-icon ui-icon-pin-s"}),t.extend(i.styling.bootstrap2,{closer:"icon-remove",pin_up:"icon-pause",pin_down:"icon-play"}),t.extend(i.styling.bootstrap3,{closer:"glyphicon glyphicon-remove",pin_up:"glyphicon glyphicon-pause",pin_down:"glyphicon glyphicon-play"}),t.extend(i.styling.fontawesome,{closer:"fa fa-times",pin_up:"fa fa-pause",pin_down:"fa fa-play"})}); \ No newline at end of file