11/**
22 * Roundcube Bookmarks Plugin
33 *
4- * @version 2.2.0
4+ * @version 2.2.1
55 * @author Offerel
66 * @copyright Copyright (c) 2020, Offerel
77 * @license GNU General Public License, version 3
88 */
9- function h_del ( t , o ) {
9+ function h_del ( t , o , format ) {
1010 t . preventDefault ( ) ;
11- var e = rcmail . gettext ( "bookmarks_del" , "syncmarks" ) . replace ( "%b%" , o . innerHTML ) ;
11+ var e = rcmail . gettext ( "bookmarks_del" , "syncmarks" ) . replace ( "%b%" , o . innerHTML ) ;
1212 if ( 1 == confirm ( e ) ) {
13- var r = encodeURIComponent ( o . href ) ;
14- rcmail . http_post ( "syncmarks/del_url" , "_url=" + r + "&_format=html" )
15- }
16- }
17-
18- function j_del ( t , o ) {
19- t . preventDefault ( ) ;
20- var e = rcmail . gettext ( "bookmarks_del" , "syncmarks" ) . replace ( "%b%" , o . innerHTML ) ;
21- if ( 1 == confirm ( e ) ) {
22- var r = encodeURIComponent ( o . href ) ;
23- rcmail . http_post ( "syncmarks/del_url" , "_url=" + r + "&_format=json" )
13+ let r = encodeURIComponent ( o . href ) ;
14+ let i = o . attributes [ 'bid' ] [ 'value' ] ;
15+ rcmail . http_post ( "syncmarks/del_url" , "_url=" + r + "&_format=" + format + "&_bid=" + i )
2416 }
2517}
2618
@@ -33,14 +25,9 @@ function bookmarks_cmd() {
3325 }
3426}
3527
36- function add_url ( ) {
37- var t = encodeURIComponent ( prompt ( rcmail . gettext ( "bookmarks_url" , "syncmarks" ) ) ) ;
38- 0 < t . length && ( t . startsWith ( "http" ) || t . startsWith ( "ftp" ) ) && rcmail . http_post ( "syncmarks/add_url" , "_url=" + t + "&_format=html" )
39- }
40-
41- function jadd_url ( ) {
42- var t = encodeURIComponent ( prompt ( rcmail . gettext ( "bookmarks_url" , "syncmarks" ) ) ) ;
43- 0 < t . length && ( t . startsWith ( "http" ) || t . startsWith ( "ftp" ) ) && rcmail . http_post ( "syncmarks/add_url" , "_url=" + t + "&_format=json" )
28+ function add_url ( format ) {
29+ var t = encodeURIComponent ( prompt ( rcmail . gettext ( "bookmarks_url" , "syncmarks" ) ) ) ;
30+ 0 < t . length && ( t . startsWith ( "http" ) || t . startsWith ( "ftp" ) ) && rcmail . http_post ( "syncmarks/add_url" , "_url=" + t + "&_format=" + format )
4431}
4532
4633function urladded ( t ) {
@@ -50,13 +37,29 @@ function urladded(t) {
5037function get_bookmarks ( response ) {
5138 bookmarks = JSON . parse ( response . data ) ;
5239
53- if ( response . message == 'php' ) {
54- $ ( '#bmframe' ) . attr ( 'srcdoc' , bookmarks ) ;
55- document . getElementById ( "bookmarkpane" ) . style . width = "300px" ;
40+ $ ( '#bookmarkpane' ) . html ( bookmarks ) ;
41+ document . getElementById ( "bookmarkpane" ) . style . width = "300px" ;
42+ }
43+
44+ function en_noti ( ) {
45+ if ( ! ( "Notification" in window ) ) {
46+ alert ( "This browser does not support desktop notification" ) ;
5647 }
57- else {
58- $ ( '#bookmarkpane' ) . html ( bookmarks ) ;
59- document . getElementById ( "bookmarkpane" ) . style . width = "300px" ;
48+ else if ( Notification . permission === "granted" ) {
49+ var notification = new Notification ( "Syncmarks" , {
50+ body : "Notifications are now enabled for Syncmarks." ,
51+ icon : './plugins/syncmarks/bookmarks.png'
52+ } ) ;
53+ }
54+ else if ( Notification . permission !== "denied" ) {
55+ Notification . requestPermission ( ) . then ( function ( permission ) {
56+ if ( permission === "granted" ) {
57+ var notification = new Notification ( "Syncmarks" , {
58+ body : "Notifications are now enabled for Syncmarks." ,
59+ icon : './plugins/syncmarks/bookmarks.png'
60+ } ) ;
61+ }
62+ } ) ;
6063 }
6164}
6265
0 commit comments