Sindbad~EG File Manager
(t=>{function i(){var i=this;function o(){setTimeout(function(){i.start()},3e3)}n(function(){_.defer(function(){var t=n("#peepso-wrap").length,i=n("#wpadminbar").find(".psnotification-toggle").length;(t||i)&&o()})}),peepso.observer.addAction("notification_start",o),peepso.observer.addAction("notification_titlebar",function(t){i._update_titlebar(t)},10,1)}var n,o;(peepso=peepso||{}).notification=(n=t,o=+peepsodata.sse,i.prototype={_get_latest_interval:+peepsodata.get_latest_interval||3e4,_get_latest_count:function(){peepso.disableAuth().disableError().postJson("notificationsajax.get_latest_count",null,function(t){var s;t.session_timeout?this.stop():t.success&&(s=0,n.each(t.data,function(t,i){var o,e,t=n("."+t),i=Math.max(0,i.count);s+=i,t.length&&(o=+(e=t.find(".ps-js-counter")).eq(0).text(),e.length)&&o!==i&&(e.html(i).css("display",0<i?"":"none"),0<i)&&t.data("plugin_psnotification")&&t.psnotification("clear_cache")}),this._update_titlebar(s),peepso.observer.doAction("notification_update",t))}.bind(this))},_update_titlebar:function(t){var i,o=document.title||"",e=/^\((\d+)\)\s*/;"string"==typeof t&&t.match(/^[-+]\d+$/)&&(t=+t,t=((i=o.match(e))?+i[1]:0)+t),o=o.replace(e,""),0<t&&(o="("+t+") "+o),document.title!==o&&(document.title=o)},hide:function(t){var i,o,e;void 0===t||(o=this.hide)[e="_progress_"+t]||(o[e]=!0,(i=n(".ps-js-notifications").find(".ps-js-notification--"+t).map(function(){return n(this).parent(".ps-notification__wrapper").get(0)})).css("opacity",.5),peepso.postJson("notificationsajax.hide",{note_id:t},n.proxy(function(t){delete o[e],t.success?(i.remove(),peepso.observer.doAction("notification_restart")):i.css("opacity","")},this)))},markAsRead:function(o){return n.Deferred(n.proxy(function(i){var t=o?{note_id:o}:null;peepso.postJson("notificationsajax.mark_as_read",t,n.proxy(function(t){t.success?i.resolveWith(this):t.errors&&i.rejectWith(this,[t.errors[0]])},this))},this))},markAllAsRead:function(){return this.markAsRead()},start:function(){var t;+peepsodata.currentuserid&&!this._started&&(this._started=!0,o?(t=n.proxy(function(t){"get_notifications"===t.event&&this._get_latest_count()},this),peepso.observer.addAction("peepso_sse",t,10,1)):(clearInterval(this._get_latest_timer),this._get_latest_count(),this._get_latest_timer=setInterval(n.proxy(this._get_latest_count,this),this._get_latest_interval)),n(window).on("peepso_auth_required",n.proxy(function(){clearInterval(this._get_latest_timer)},this)),peepso.observer.addFilter("pschat_mark_as_read",this.restart,10,1,this),peepso.observer.addAction("notification_restart",this.restart,10,1,this))},restart:function(){+peepsodata.currentuserid&&(o?this._get_latest_count():(clearInterval(this._get_latest_timer),this._get_latest_count(),this._get_latest_timer=setInterval(n.proxy(this._get_latest_count,this),this._get_latest_interval)))},stop:function(){clearInterval(this._get_latest_timer)}},new i)})(jQuery),(s=>{function o(i,t){var e=this;return this.popover_ct=null,this.popover_list=null,this.popover_footer=null,this.popover_header=null,this._notifications={},this.init=function(t){_opts={view_all_text:peepsodata.view_all_text,view_all_link:null,source:null,request:{per_page:10,page:1},header:null,paging:!1,fetch:null},this.opts=peepso.observer.applyFilters("peepso_notification_plugin_options",_opts),this._content_is_fetched=!1,s.extend(!0,this.opts,t),s(i).addClass("psnotification-toggle"),this.popover_ct=s("<div>"),this.popover_list=s("<div>").css({maxHeight:"min(22em, 40vh)",overflow:"auto"}),this.popover_list.bind("mousewheel",s.proxy(function(t,i){var o=s(t.currentTarget);(0<i&&0===o.scrollTop()||i<0&&o.scrollTop()==o.get(0).scrollHeight-o.innerHeight())&&t.preventDefault()},this)),s(i).append(this.popover_ct),this.opts.header&&(this.popover_header=s('<div class="ps-notif__box-header"/>'),this.popover_header.append(this.opts.header),this.popover_ct.append(this.popover_header)),this.popover_ct.append(this.popover_list),this.popover_list.addClass("ps-notifications ps-notifications--notifs"),this.popover_ct.addClass("ps-notif__box").hide(),this.opts.paging&&this.init_pagination();var t=this.opts.view_all_link,o=this.opts.view_all_text;t&&(o=_.isArray(o)?o:[o],t=_.isArray(t)?t:[t],t=_.map(t,function(t,i){return['<a href="',t,'">',o[i],"</a>"].join("")}),this.popover_footer=s('<div class="ps-notif__box-footer"></div>'),this.popover_footer.append(t.join("")),this.popover_footer.appendTo(this.popover_ct)),this.popover_list.on("mousedown.ps-notification",".ps-js-notification a",s.proxy(function(i){var o=s(i.currentTarget),e=o.closest(".ps-js-notification");!+e.data("unread")||3===i.which||i.ctrlKey||i.altKey||(2===i.which||i.metaKey||i.shiftKey||o.on("click",function(t){t.preventDefault(),t.stopPropagation()}),e.css("opacity",.5),e.removeClass("ps-notification--unread"),peepso.notification.markAsRead(e.data("id")).done(s.proxy(function(){var t=+e.closest(".ps-js-notifications").find(".ps-js-counter").text();e.css("opacity",""),e.data("unread",0),1!==i.which||i.metaKey||i.shiftKey||(o.off("click"),o[0].click()),s(".ps-js-notifications").find(".ps-js-counter").html(t-1).css("display",1<t?"":"none")},this)).fail(function(t){e.addClass("ps-notification--unread"),t&&peepso.dialog(t,{error:!0}).show()}))},this)),this.popover_list.on("mousedown click",".ps-js-mark-as-read",s.proxy(function(t){var i,o;t.preventDefault(),t.stopPropagation(),"click"===t.type&&(i=s(t.currentTarget),o=i.closest(".ps-js-notification"),i.hide(),o.css("opacity",.5),o.removeClass("ps-notification--unread"),peepso.notification.markAsRead(o.data("id")).done(s.proxy(function(){var t=+o.closest(".ps-js-notifications").find(".ps-js-counter").text();i.remove(),o.css("opacity",""),o.data("unread",0),s(".ps-js-notifications").find(".ps-js-counter").html(t-1).css("display",1<t?"":"none")},this)).fail(function(t){o.addClass("ps-notification--unread"),i.show(),t&&peepso.dialog(t,{error:!0}).show()}))},this)),this.popover_footer&&(this.popover_footer.on("click",".ps-js-mark-all-as-read",s.proxy(function(t){var i=this.popover_list.find(".ps-js-notification"),o=(i=i.filter(".ps-notification--unread")).find(".ps-js-mark-as-read");confirm(peepsodata.mark_all_as_read_confirm_text)&&(o.hide(),i.css("opacity",.5),i.removeClass("ps-notification--unread"),peepso.notification.markAllAsRead().done(function(){o.remove(),i.css("opacity",""),i.data("unread",0),s(".ps-js-notifications").find(".ps-js-counter").html(0).css("display","none")}).fail(function(t){i.addClass("ps-notification--unread"),o.show(),t&&peepso.dialog(t,{error:!0}).show()}))},this)),this.popover_footer.on("click",".ps-js-toggle-unread-only",s.proxy(function(t){t=s(t.currentTarget);this._unreadOnly=!this._unreadOnly,t.html(this._unreadOnly?peepsodata.show_all_text:peepsodata.show_unread_only_text),this.popover_list.find(".ps-notification__wrapper").remove(),this.opts.request.page=1,this._content_is_fetched=!1,this.load_page(function(){e.opts.paging&&e.popover_list.trigger("scroll")})},this)))},this.fetch=function(i){var t=this.opts.request,o=(this.opts.method||"").toLowerCase();_.isFunction(this.opts.fetch)&&!1===(t=this.opts.fetch.call(this,t))||(this._notifications={},this.fetch_stop(),this.fetch_xhr=peepso["get"===o?"getJson":"postJson"](this.opts.source,t,function(t){t.success?(e._content_is_fetched=!0,e._data=t.data,e._notifications=t.data.notifications,e._errors=!1,0<e._notifications.length&&e.opts.request.page++):t.errors&&(e._content_is_fetched=!0,e._errors=t.errors),"function"==typeof i&&i()}))},this.fetch_stop=function(){this.fetch_xhr&&(this.fetch_xhr.abort?this.fetch_xhr.abort():this.fetch_xhr.ret&&this.fetch_xhr.ret.abort&&this.fetch_xhr.ret.abort())},this.refresh=function(){this.popover_list.find(".ps-notification__wrapper").remove(),this._content_is_fetched=!1,this.load_page(function(){e.opts.paging&&e.popover_list.trigger("scroll")})},this.onClick=function(t){var i;_.isFunction(e.opts.before_click)&&!1===e.opts.before_click()||0<e.popover_ct.has(s(t.target)).length||(t.preventDefault(),t=e.opts.lazy,i=e.popover_ct.is(":visible"),e.show(),t)||i||e.load_page(function(){e.opts.paging&&e.popover_list.trigger("scroll")})},this.render=function(){s.each(this._notifications,function(t,i){var o=s("<div class='ps-notification__wrapper'></div>");o.html(i).hide(),o.appendTo(e.popover_list).fadeIn("slow")}),s(i).trigger("notifications.shown",[s.extend(i,this)]),s(document.body).hasClass("wp-admin")&&s(i).find("a").attr("target","_blank")},this.show=function(){this.popover_ct.slideToggle({duration:"fast",done:function(){s(document).on("mouseup.notification_click",function(t){s(i).is(t.target)||0!==s(i).has(t.target).length||(e.popover_ct.hide(),s(document).off("mouseup.notification_click"))})}})},this.init_pagination=function(){this.popover_list.on("scroll",function(){e._content_is_fetched&&s(this).scrollTop()+s(this).innerHeight()>=s(this)[0].scrollHeight&&(e._content_is_fetched=!1,e.load_page(function(){e._notifications&&_.isEmpty(e._notifications)?e.popover_list.off("scroll"):e.popover_list.trigger("scroll")}))})},this.load_page=function(t){var o,i;!1===this._content_is_fetched&&(o=this.popover_list.children(".ps-notification"),i=this.popover_list.children(".ps-popover-loading"),o.length&&o.remove(),i.length||(i=s("<div class='ps-popover-loading'><img src='"+peepsodata.loading_gif+"'/></div>"),this.popover_list.append(i)),this.fetch_stop(),setTimeout(function(){e.fetch(function(){i.remove(),e._errors&&(o=s('<div class="ps-notification" />'),s.each(e._errors,function(t,i){o.append(`<a class="ps-notification__inside"><div class="ps-notification__desc">${i}</div></a>`)}),e.popover_list.append(o)),e.render(),typeof t==typeof Function&&t(),"function"==typeof e.opts.after_load&&e.opts.after_load.apply(e)})},500))},this.clear_cache=function(){this.popover_list.find(".ps-notification__wrapper").remove(),this.popover_ct.hide(),this.opts.request.page=1,this._content_is_fetched=!1},this.init(t),s(i).on("click",this.onClick),this}s.fn.psnotification=function(i){return this.each(function(){if(s.data(this,"plugin_psnotification")){var t=s.data(this,"plugin_psnotification");if(_.isFunction(t[i]))return t[i].call(t)}else s.data(this,"plugin_psnotification",new o(this,i))})},peepso.observer.addAction("notification_clear_cache",function(t){s("."+(t=t||"ps-js-notifications")).psnotification("clear_cache")},10,1)})(jQuery),jQuery(function(t){});
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists