File tree Expand file tree Collapse file tree 1 file changed +17
-18
lines changed Expand file tree Collapse file tree 1 file changed +17
-18
lines changed Original file line number Diff line number Diff line change 1515 file = "" ;
1616 }
1717 const mimeType = index < 0 ? "" : file . substring ( "data:" . length , index ) ;
18+
19+ function write ( selector , text ) {
20+ const e = document . querySelector ( selector ) ;
21+ if ( typeof text === "object" ) {
22+ for ( const [ k , v ] of Object . entries ( text ) ) {
23+ e [ k ] = v ;
24+ }
25+ } else {
26+ e . innerText = text ;
27+ }
28+ }
1829 </ script >
1930</ head >
2031< body >
2132 < h1 > Undata</ h1 >
2233 < p > Mime type: < span id ="mimeType "> </ span > </ p >
23- < script > ( function ( ) {
24- const a = document . querySelector ( "#mimeType" ) ?? undefined ;
25- if ( a !== undefined ) {
26- a . innerText = mimeType ;
27- }
28- } ) ( ) ; </ script >
29- < p > File length: < script >
30- ( function ( ) { const length = Math . max ( 0 , file . length ) ; document . write ( length ) ; } ) ( ) ;
31- </ script > characters.</ p >
34+ < p > File length: < span id ="fileLength "> </ span > characters.</ p >
3235 < p > < a id ="download " download ="undata "> DOWNLOAD</ a > </ p >
33- < script > ( function ( ) {
34- const a = document . querySelector ( "#download" ) ?? undefined ;
35- if ( a !== undefined ) {
36- a . href = file ;
37- }
38- if ( file === "" ) {
39- a . innerText = "INVALID FILE" ;
40- }
41- } ) ( ) ; </ script >
4236 < h2 > WARNING: The file you are about to download could come from anyone and could contain any data. Download at your own risk.</ h2 >
37+ < script >
38+ write ( "#mimeType" , mimeType ) ;
39+ write ( "#fileLength" , file . length ) ;
40+ write ( "#download" , { href : file , innerText : file === "" ? "INVALID FILE" : "DOWNLOAD" } ) ;
41+ </ script >
4342</ body >
4443</ html >
You can’t perform that action at this time.
0 commit comments