@@ -111,18 +111,24 @@ satus.aes.decrypt = async function(text, password) {
111111 name : 'AES-GCM' ,
112112 iv : new Uint8Array ( iv )
113113 } ;
114-
115- return new TextDecoder ( ) . decode ( await crypto . subtle . decrypt (
116- algorithm ,
117- await crypto . subtle . importKey (
118- 'raw' ,
119- await crypto . subtle . digest ( 'SHA-256' , new TextEncoder ( ) . encode ( password ) ) ,
114+
115+ try {
116+ var data = new TextDecoder ( ) . decode ( await crypto . subtle . decrypt (
120117 algorithm ,
121- false ,
122- [ 'decrypt' ]
123- ) ,
124- new Uint8Array ( atob ( text . slice ( 24 ) ) . match ( / [ \s \S ] / g) . map ( ch => ch . charCodeAt ( 0 ) ) )
125- ) ) ;
118+ await crypto . subtle . importKey (
119+ 'raw' ,
120+ await crypto . subtle . digest ( 'SHA-256' , new TextEncoder ( ) . encode ( password ) ) ,
121+ algorithm ,
122+ false ,
123+ [ 'decrypt' ]
124+ ) ,
125+ new Uint8Array ( atob ( text . slice ( 24 ) ) . match ( / [ \s \S ] / g) . map ( ch => ch . charCodeAt ( 0 ) ) )
126+ ) ) ;
127+ } catch ( err ) {
128+ return false ;
129+ }
130+
131+ return data ;
126132} ;
127133
128134/*--------------------------------------------------------------
@@ -820,8 +826,8 @@ satus.storage.import = function(name, callback) {
820826 chrome . storage . local . get ( function ( items ) {
821827 satus . storage . data = items ;
822828
823- if ( callback ) {
824- callback ( items ) ;
829+ if ( name ) {
830+ name ( items ) ;
825831 }
826832 } ) ;
827833 } else {
@@ -1967,6 +1973,14 @@ Satus.components.dialog = function(element) {
19671973
19681974 function keydown ( event ) {
19691975 if ( event . keyCode === 27 ) {
1976+ if ( element . clickclose === false ) {
1977+ return false ;
1978+ }
1979+
1980+ if ( typeof element . onclickclose === 'function' ) {
1981+ element . onclickclose ( ) ;
1982+ }
1983+
19701984 event . preventDefault ( ) ;
19711985
19721986 close ( ) ;
@@ -1992,11 +2006,25 @@ Satus.components.dialog = function(element) {
19922006 }
19932007 }
19942008
1995- component_scrim . addEventListener ( 'click' , close ) ;
1996- window . addEventListener ( 'keydown' , keydown ) ;
2009+ component_scrim . addEventListener ( 'click' , function ( ) {
2010+ if ( element . clickclose === false ) {
2011+ return false ;
2012+ }
2013+
2014+ if ( typeof element . onclickclose === 'function' ) {
2015+ element . onclickclose ( ) ;
2016+ }
2017+
2018+ close ( ) ;
2019+ } ) ;
2020+ window . addEventListener ( 'keydown' , function ( event ) {
2021+ keydown ( event ) ;
2022+ } ) ;
19972023
19982024 component . appendChild ( component_scrim ) ;
19992025 component . appendChild ( component_surface ) ;
2026+
2027+ component . close = close ;
20002028
20012029 // OPTIONS
20022030
0 commit comments