This repository was archived by the owner on Mar 6, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +46
-1
lines changed Expand file tree Collapse file tree 2 files changed +46
-1
lines changed Original file line number Diff line number Diff line change 5
5
< meta charset ='utf-8 '>
6
6
< link rel ='stylesheet ' type ='text/css ' href ='/web/Style.css '>
7
7
< script language ='javascript ' type ='text/javascript ' src ='/web/Javascript.js '> </ script >
8
- < script language ='javascript ' type ='text/javascript ' src ='/web/handlefiles.js '> </ script >
8
+ < script language ='javascript ' type ='text/javascript ' src ='/web/handlefiles.js '> </ script >
9
9
< link rel ='stylesheet ' href ='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css ' >
10
+
11
+ < script language ='javascript ' type ='text/javascript ' src ='https://cdn.jsdelivr.net/gh/Stuk/jszip@main/dist/jszip.js '> </ script >
12
+ < script language ='javascript ' type ='text/javascript ' src ='https://cdn.jsdelivr.net/gh/Stuk/jszip-utils@master/dist/jszip-utils.js '> </ script >
13
+ < script language ='javascript ' type ='text/javascript ' src ='https://cdn.jsdelivr.net/gh/eligrey/FileSaver.js@master/dist/FileSaver.js '> </ script >
14
+
10
15
< title > HandleFiles</ title >
11
16
</ head >
12
17
< body >
50
55
< input type ='button ' style ='font-size:18px ' class ='fa ' value =' ' onclick ='downloadFile() ' title ='download to pc '/>
51
56
< input type ='button ' onclick ='uploadFile() ' style ='font-size:18px ' class ='fa ' value =' ' title ='store it '/>
52
57
< input type ='button ' onclick ='deleteFile() ' style ='font-size:18px ' class ='fa ' value =' ' title ='delete it '/>
58
+ < input type ='button ' onclick ='backup() ' style ='font-size:18px ' class ='fa ' value =' ' title ='backup complete filesystem as zip '/>
53
59
< span id ='response '> </ span >
54
60
</ td >
55
61
</ tr >
Original file line number Diff line number Diff line change @@ -241,4 +241,43 @@ function deleteFile() {
241
241
requestData ( JSON . stringify ( data ) ) ;
242
242
init ( pathOfFile ) ;
243
243
} else { setResponse ( false , 'Filename is empty, Please define it.' ) ; }
244
+ }
245
+
246
+ // ***********************************
247
+ // backup complete filesystem of ESP by zipfile
248
+ //
249
+ // https://gist.github.com/noelvo/4502eea719f83270c8e9
250
+ // ***********************************
251
+ function backup ( ) {
252
+ var url = [ ] ;
253
+
254
+ for ( let i = 0 ; i < DirJson . length ; i ++ ) {
255
+ DirJson [ i ] . content . forEach ( function ( file ) {
256
+ if ( file . isDir == 0 ) {
257
+ //console.log(DirJson[i].path, file.name)
258
+ url . push ( DirJson [ i ] . path + "/" + file . name )
259
+ }
260
+ } )
261
+ }
262
+ compressed_img ( url , "backup" ) ;
263
+ }
264
+
265
+ function compressed_img ( urls , nombre ) {
266
+ var zip = new JSZip ( ) ;
267
+ var count = 0 ;
268
+ var name = nombre + ".zip" ;
269
+ urls . forEach ( function ( url ) {
270
+ JSZipUtils . getBinaryContent ( url , function ( err , data ) {
271
+ if ( err ) {
272
+ throw err ;
273
+ }
274
+ zip . file ( url , data , { binary :true } ) ;
275
+ count ++ ;
276
+ if ( count == urls . length ) {
277
+ zip . generateAsync ( { type :'blob' } ) . then ( function ( content ) {
278
+ saveAs ( content , name ) ;
279
+ } ) ;
280
+ }
281
+ } ) ;
282
+ } ) ;
244
283
}
You can’t perform that action at this time.
0 commit comments