-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyncmarks.min.js
1 lines (1 loc) · 2.51 KB
/
syncmarks.min.js
1
function h_del(t,e,n){t.preventDefault();var o=rcmail.gettext("bookmarks_del","syncmarks").replace("%b%",e.innerHTML);if(1==confirm(o)){let t=encodeURIComponent(e.href),o=e.attributes.bid.value;rcmail.http_post("syncmarks/del_url","_url="+t+"&_format="+n+"&_bid="+o)}}function bookmarks_cmd(){if("300"!=document.getElementById("bookmarkpane").clientWidth){let t=document.createElement("div");t.classList.add("db-spinner"),t.id="db-spinner",document.getElementById("layout").parentNode.appendChild(t),rcmail.http_post("syncmarks/get_bookmarks","_url=2")}else document.getElementById("bookmarkpane").style.width="0"}function add_url(t){var e=encodeURIComponent(prompt(rcmail.gettext("bookmarks_url","syncmarks")));console.log(t),0<e.length&&(e.startsWith("http")||e.startsWith("ftp"))&&rcmail.http_post("syncmarks/add_url","_url="+e+"&_format="+t)}function url_removed(t){console.log(t.message),document.getElementById("bookmarkpane").style.width="0"}function urladded(t){console.log(t.message),0<t.data.length&&$("#bookmarkpane").html(t.data)}function get_bookmarks(t){bookmarks=JSON.parse(t.data),$("#bookmarkpane").html(bookmarks),document.getElementById("bookmarkpane").style.width="300px";let e=document.getElementById("db-spinner");setTimeout(function(){e.parentNode&&e.parentNode.removeChild(e)},400)}function en_noti(t){if(t.checked)if("Notification"in window)if("granted"===Notification.permission)new Notification("Syncmarks",{body:"Notifications will be enabled for Syncmarks.",icon:"./plugins/syncmarks/bookmarks.png"});else"denied"!==Notification.permission&&Notification.requestPermission().then(function(t){if("granted"===t)new Notification("Syncmarks",{body:"Notifications will be enabled for Syncmarks.",icon:"./plugins/syncmarks/bookmarks.png"})});else alert("This browser does not support desktop notification")}function get_notifications(t){let e=JSON.parse(t);e.forEach(function(t){show_noti(t)})}function show_noti(t){if("granted"!==Notification.permission)Notification.requestPermission();else{let e=new Notification(t.title,{body:t.url,icon:"./plugins/syncmarks/bookmarks.png",requireInteraction:!0});e.onclick=function(){window.open(t.url),rcmail.http_post("syncmarks/del_not","&_nkey="+t.nkey)}}}window.rcmail&&rcmail.addEventListener("init",function(t){}),$(document).ready(function(){$("#7f3f3c06-5b85-4e7f-b527-d061478e9446").on("click",bookmarks_cmd),document.getElementById("bookmarkpane").addEventListener("click",function(t){"A"==t.target.tagName&&bookmarks_cmd()})}),rcmail.addEventListener("plugin.sendNotifications",get_notifications);