Skip to content

Commit 341f5ac

Browse files
save file
1 parent 5f243ac commit 341f5ac

File tree

1 file changed

+57
-17
lines changed

1 file changed

+57
-17
lines changed

html-components/list/web-editor/web-editor.html

Lines changed: 57 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
var hdr;
4747
var log;
4848

49-
var latest;
49+
var editor;
5050

5151

5252
async function init(){
@@ -56,19 +56,19 @@
5656
hdr = mod['html-components-hdr'];
5757
log = mod['log-mod'];
5858

59-
latest = mod['latest'];
59+
editor = mod['editor'];
6060

6161

6262
hdr.initmod({ext,$,menu});
6363
log.initmod({ext,$});
6464

65-
latest.initmod({ext,$,menu,ace});
65+
editor.initmod({ext,$,menu,ace});
6666

6767

6868
await Promise.all([
6969
hdr.init(),
7070
log.init(),
71-
latest.init(),
71+
editor.init(),
7272
]);
7373

7474

@@ -107,7 +107,9 @@
107107
#latest
108108
{display:block;margin-top:50px;border:1px solid blue;border-radius:10px;padding:10px}
109109

110-
110+
h3
111+
{color:blue}
112+
111113
code
112114
{display:block;white-space:pre;background:whitesmoke}
113115

@@ -306,17 +308,55 @@ <h3>
306308
</div>
307309

308310

309-
<h3>
310-
Files
311-
</h3>
312-
313-
<div>
314-
latest
315-
<br>
316-
v2.0
317-
</div>
318-
319-
<web-editor component id=latest fullsize src='https://libs.ext-code.com/html/web-editor/web-editor.html'></web-editor>
311+
<section files>
312+
<h3>
313+
Files
314+
</h3>
315+
316+
<div list>
317+
<div>
318+
latest
319+
</div>
320+
<div>
321+
v2.0
322+
</div>
323+
</div>
324+
325+
<script>
326+
327+
mod.stack.push(()=>{
328+
329+
var base = 'https://libs.ext-code.com/html/web-editor/';
330+
var get = url=>fetch(url).then(res=>res.text());
331+
332+
$.all('[files] [list] div').forEach(div=>{
333+
334+
div.onclick = async e=>{
335+
336+
var txt = div.textContent;
337+
var src;
338+
switch(txt){
339+
340+
case 'latest' : src='web-editor.html'; break;
341+
case 'v2.0' : src='v2.0/web-editor-v2.0.html'; break;
342+
343+
}//switch
344+
345+
var txt = await get(base+src);
346+
editor.setValue(txt);
347+
editor.filename(src);
348+
349+
}//onclick
350+
351+
});
352+
353+
});
354+
355+
</script>
356+
357+
<web-editor component id=editor fullsize src='https://libs.ext-code.com/html/web-editor/web-editor.html'></web-editor>
358+
359+
</section>
320360

321361

322362
<log-mod component></log-mod>
@@ -340,7 +380,7 @@ <h3>
340380
hdr.initdom();
341381
log.initdom();
342382

343-
latest.initdom();
383+
editor.initdom();
344384

345385
}//initdom
346386

0 commit comments

Comments
 (0)