Skip to content

Commit d234572

Browse files
save file
1 parent e05c2d1 commit d234572

1 file changed

Lines changed: 67 additions & 17 deletions

File tree

‎utils/editors/html-editor/html-editor.html‎

Lines changed: 67 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
editor.initmod({mode:'html',on});
124124
autosave.initmod({save:btn.save});
125125

126-
mod.base.add({log,complete,source,focus,editor,filemod});
126+
mod.base.add({complete,source,focus,editor,filemod});
127127

128128
await mod.auto();
129129

@@ -151,7 +151,7 @@
151151
<style id=page-inline>
152152

153153
#hdr
154-
{padding:5px 5px;height:30px;display:flex;align-items:center;gap:10px}
154+
{padding:5px 5px;height:30px;display:flex;/*align-items:center;*/gap:10px;flex-wrap:wrap}
155155

156156
.icon
157157
{border:1px solid gray;border-radius:3px;box-sizing:border-box;width:30px;height:30px;cursor:pointer}
@@ -195,6 +195,11 @@
195195
.visually-hidden
196196
{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);border:0}
197197

198+
.radio
199+
{border:1px solid lightgray;padding:2px 10px;border-radius:5px;cursor:pointer;display:flex;align-items:center}
200+
.radio *
201+
{cursor:pointer}
202+
198203
.menu-item
199204
{gap:20px}
200205
.menu-item .menu-label
@@ -235,6 +240,13 @@ <h4 slot=version>v3.0</h4>
235240
<img id=prettier class=icon title=prettier>
236241
<img id=syntax-chk class=icon title=syntax>
237242

243+
<div id=output-root class=radio>
244+
<input type=checkbox checked>
245+
<label>
246+
output
247+
</label>
248+
</div>
249+
238250
<span class=spc></span>
239251

240252
<img id=horiz class=icon src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAAAXNSR0IArs4c6QAAAPhJREFUSEtjZICChoaGKE5OzvIfP35o/f//nwUmTg2akZHxDwcHx7Xv3793NjQ0LAOZyQgimpubJ/Hz88fZ2dnxKyoqMrCwUNVehj9//jDcv3+f4dChQx8/fvy4qLa2No8R5FMhIaFp8fHx/NS2ED20QA5YuHDhx3fv3mUxdnZ2XnR3d9dTVVWlRqgSNOP27dsMO3fuvMTY2Nj4u6CggIXWvoW5COTrCRMm/AEF9f/S0lKCLqWmgu7uboZRi6kZojjNGg1qugQzyJLRoKZ/UNPNRiSLRksuuoT6aHaiSzCPllx0C2Z4UA9YY2/AmrcD1qAfsC7MQHXaANO37pOxy/mWAAAAAElFTkSuQmCC'>
@@ -275,6 +287,7 @@ <h4 slot=version>v3.0</h4>
275287
var set = {};
276288

277289

290+
278291
async function initdom(rootnode){ //c
279292
debug('initdom');
280293
root = rootnode;
@@ -292,6 +305,7 @@ <h4 slot=version>v3.0</h4>
292305
$('#run').onclick = btn.run;
293306
$(root,'#prettier').onclick = btn.prettier;
294307
$(root,'#syntax-chk').onclick = btn.syntax;
308+
$.chkbox(root,'#output-root',btn.output);
295309

296310
$('#horiz').onclick = horiz;
297311
$('#vert').onclick = vert;
@@ -362,7 +376,7 @@ <h4 slot=version>v3.0</h4>
362376

363377
btn.run = function(){
364378
debug('btn.run');
365-
run.sandbox();
379+
run();
366380

367381
}//run
368382

@@ -406,23 +420,24 @@ <h4 slot=version>v3.0</h4>
406420
debug('btn.syntax');
407421
console.clear();
408422
console.log('syntax');
409-
var html = editor.getValue();
410-
var index = 0;
411-
var ec = true;
423+
var html = editor.getValue();
424+
var index = 0;
425+
var ec = true;
412426
while(ec){
413427

414-
var i1 = html.indexOf('<scr'+'ipt>',index);
415-
if(i1==-1){
428+
var i1a = html.indexOf('<scr'+'ipt',index);
429+
if(i1a==-1){
416430
return;
417431
}
432+
var i1 = html.indexOf('>',i1a);
418433

419-
var str = html.slice(0,i1);
420-
var lines = str.split('\n').length;
434+
var str = html.slice(0,i1a);
435+
var lines = str.split('\n').length;
421436

422-
var i2 = html.indexOf('</scr'+'ipt>',i1);
423-
index = i2+7;
437+
var i2 = html.indexOf('</scr'+'ipt',i1);
438+
index = i2+7;
424439

425-
var js = html.slice(i1+8,i2);
440+
var js = html.slice(i1+8,i2);
426441
//console.log(js);
427442
var result = syntax(js);
428443
//console.log(i1,i2,lines,result);
@@ -442,6 +457,38 @@ <h4 slot=version>v3.0</h4>
442457
}//syntax
443458

444459

460+
{
461+
462+
let w;
463+
let h;
464+
465+
btn.output = function(chk){console.log(chk);
466+
467+
if(output.__host.style.display=='none'){
468+
if(ui.mode=='vert'){
469+
editor.__host.style.width = w;
470+
}else{
471+
editor.__host.style.height = h;
472+
}
473+
output.__host.style.display = '';
474+
slider.node.style.display = '';
475+
}else{
476+
output.__host.style.display = 'none';
477+
slider.node.style.display = 'none';
478+
if(ui.mode=='vert'){
479+
w = editor.__host.style.width;
480+
editor.__host.style.width = '100%';
481+
}else{
482+
h = editor.__host.style.height;
483+
editor.__host.style.height = '100%';
484+
}
485+
}
486+
487+
}//show-output
488+
489+
}
490+
491+
445492
//:
446493

447494

@@ -538,6 +585,8 @@ <h4 slot=version>v3.0</h4>
538585

539586
function horiz(){
540587

588+
if(output.__host.style.display=='none')return;
589+
541590
//localStorage.setItem('orientation','horiz');
542591

543592
ui.mode = 'horiz';
@@ -556,6 +605,8 @@ <h4 slot=version>v3.0</h4>
556605

557606
function vert(){
558607

608+
if(output.__host.style.display=='none')return;
609+
559610
//localStorage.setItem('orientation','vert');
560611

561612
ui.mode = 'vert';
@@ -575,8 +626,7 @@ <h4 slot=version>v3.0</h4>
575626
//:
576627

577628

578-
var run = {};
579-
629+
580630
run.srcdoc = function(){
581631
debug('run.srcdoc');
582632
if(autosave.checked){
@@ -591,15 +641,15 @@ <h4 slot=version>v3.0</h4>
591641
}//run
592642

593643

594-
run.sandbox = function(){
644+
function run(){
595645
debug('run.sandbox');
596646
if(autosave.checked){
597647
debug('autosave');
598648
filemod.save();
599649
}
600650

601651
var html = editor.getValue();
602-
output.sandbox(html);
652+
output.run(html);
603653

604654
}//sandbox
605655

0 commit comments

Comments
 (0)