|
19 | 19 | <script> |
20 | 20 |
|
21 | 21 |
|
| 22 | + function start(){ |
| 23 | + debug('start'); |
| 24 | + initdom(); |
| 25 | + |
| 26 | + }//start |
| 27 | + |
| 28 | + |
22 | 29 | </script> |
23 | 30 |
|
24 | 31 | <style> |
|
36 | 43 | {display:block;white-space:pre;font-family:monospace;margin:20px;padding:20px;background:whitesmoke} |
37 | 44 |
|
38 | 45 |
|
| 46 | + |
| 47 | + web-editor |
| 48 | + {display:block;height:200px;margin:20px;border:1px solid lightgray;padding:10px} |
| 49 | + |
| 50 | + |
| 51 | + input |
| 52 | + {font-size:16px;padding:5px 10px} |
| 53 | + input[type=button] |
| 54 | + {cursor:pointer} |
| 55 | + |
| 56 | + |
39 | 57 | </style> |
40 | 58 |
|
41 | 59 | </head> |
|
74 | 92 | This code module implements a lightweight HTTPS server that exposes direct file system operations to the browser through a simple fetch‑based API. By sending requests such as |
75 | 93 | </p> |
76 | 94 |
|
| 95 | + <div> |
| 96 | + <input value=download type=button> |
| 97 | + </div> |
| 98 | + |
77 | 99 | <code> |
78 | 100 |
|
79 | 101 | fetch("https://localhost:3000/a.txt", { headers: { mode: "load" } }) |
@@ -116,12 +138,73 @@ <h1> |
116 | 138 | Together, these commands provide a complete set of standard file I/O capabilities accessible from the browser. This member sits at the Code stage of the pipeline: more substantial than a library, since it defines a working server with a defined protocol, but not yet a full project. It serves as a foundation for building browser‑driven file management tools, developer utilities, or experimental web‑native applications. |
117 | 139 | </p> |
118 | 140 |
|
| 141 | + </div> |
| 142 | + |
| 143 | + <web-editor component h=200> |
| 144 | + |
| 145 | + [ not implemented yet ] |
119 | 146 |
|
| 147 | + </web-editor> |
| 148 | + |
120 | 149 | </body> |
121 | 150 |
|
122 | 151 | <script> |
123 | 152 |
|
124 | 153 |
|
| 154 | + var jszip; |
| 155 | + |
| 156 | + |
| 157 | + var btn = {}; |
| 158 | + |
| 159 | + |
| 160 | + //: |
| 161 | + |
| 162 | + |
| 163 | + function initdom(){ |
| 164 | + |
| 165 | + $('[value=download]').onclick = btn.download; |
| 166 | + |
| 167 | + }//initdom |
| 168 | + |
| 169 | + |
| 170 | + //: |
| 171 | + |
| 172 | + |
| 173 | + btn.download = async function(){ |
| 174 | + |
| 175 | + if(!jszip){ |
| 176 | + jszip = await import('https://cdn.jsdelivr.net/npm/jszip/+esm'); |
| 177 | + jszip = jszip.default; |
| 178 | + } |
| 179 | + |
| 180 | + var zip = new jszip(); |
| 181 | + zip.folder(`file-server`); |
| 182 | + |
| 183 | + var res = await fetch('https://raw.githubusercontent.com/javascript-2020/code/main/nodejs/server/file-server/file-server.js'); |
| 184 | + var blob = await res.blob(); |
| 185 | + zip.file(`file-server/file-server.js`,blob); |
| 186 | + |
| 187 | + zip.folder(`file-server/node_modules`); |
| 188 | + |
| 189 | + var res = await fetch('https://raw.githubusercontent.com/javascript-2020/libs/main/js/string/getmime/getmime.js'); |
| 190 | + var blob = await res.blob(); |
| 191 | + zip.file(`file-server/node_modules/getmime.js`,blob); |
| 192 | + |
| 193 | + var res = await fetch('https://raw.githubusercontent.com/javascript-2020/libs/main/nodejs/keys/keys.js'); |
| 194 | + var blob = await res.blob(); |
| 195 | + zip.file(`file-server/node_modules/keys.js`,blob); |
| 196 | + |
| 197 | + var blob = await zip.generateAsync({type:'blob'}); |
| 198 | + |
| 199 | + var url = window.URL.createObjectURL(blob); |
| 200 | + var a = document.createElement('a'); |
| 201 | + a.download = 'file-server'; |
| 202 | + a.href = url; |
| 203 | + a.click(); |
| 204 | + |
| 205 | + }//download |
| 206 | + |
| 207 | + |
125 | 208 | </script> |
126 | 209 |
|
127 | 210 | </html> |
|
0 commit comments