Skip to content

Commit 9e953c4

Browse files
save file
1 parent f24d0c1 commit 9e953c4

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

blog/25-07-23/http2-server/http2-server.html

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,15 @@
147147

148148
#editor-root
149149
{border:1px solid lightblue;border-radius:5px;padding:10px;overflow:hidden;}
150+
#editor-root>div
151+
{margin:10px}
152+
153+
154+
input
155+
{font-size:16px;padding:5px 10px;box-sizing:border-box}
156+
input[type=button]
157+
{cursor:pointer}
158+
150159

151160
a.link-stable
152161
{color:blue}
@@ -206,6 +215,10 @@ <h1 class=title>
206215

207216
<div id=editor-root>
208217

218+
<div>
219+
<input value=download type=button>
220+
</div>
221+
209222
<editor id=server type=nodejs component v2.0 src='ex/ex1.js'>
210223
</editor>
211224

@@ -221,13 +234,39 @@ <h1 class=title>
221234

222235
<script>
223236

224-
237+
238+
var btn = {};
239+
240+
241+
//:
242+
243+
225244
function initdom(rootnode){
226245

246+
$('[value=download]').onclick = btn.download;
247+
227248
server.initdom(rootnode,{fullsize:true});
228249

229250
}//initdom
230251

252+
253+
//:
254+
255+
256+
btn.download = function(){
257+
258+
var txt = server.getvalue();
259+
var blob = new Blob([txt]);
260+
var url = window.URL.createObjectURL(blob);
261+
262+
var a = document.createElement('a');
263+
a.download = 'http2-example-server.js';
264+
a.href = url;
265+
a.click();
266+
267+
}//download
268+
269+
231270

232271
</script>
233272

0 commit comments

Comments
 (0)