Skip to content

Commit 90baee9

Browse files
save file
1 parent 77f33f6 commit 90baee9

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

utils/editors/js-console/html/output-console/v3.0/output-console-v3.0.html

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,11 @@
419419
}//run
420420

421421

422+
423+
424+
//:
425+
426+
422427
build.sandbox = function(){
423428

424429
var attr = sandbox_def;
@@ -472,7 +477,7 @@
472477
}//iframe
473478

474479

475-
obj.run.iframe2 = async function(js,params={}){
480+
obj.run.iframe = async function(js,params={}){
476481
debug('run.iframe2');
477482
var resolve,promise=new Promise(res=>resolve=res);
478483

@@ -512,6 +517,55 @@
512517
}//iframe
513518

514519

520+
//:
521+
522+
523+
obj.run.iframe.host = async function(js,params={}){
524+
debug('run.iframe.host');
525+
var resolve,promise=new Promise(res=>resolve=res);
526+
527+
if(iframe){
528+
iframe.remove();
529+
}
530+
531+
iframe = document.createElement('iframe');
532+
iframe.srcdoc = '';
533+
iframe.onload = onload;
534+
root.append(iframe);
535+
536+
return promise;
537+
538+
539+
async function onload(){
540+
541+
var win = iframe.contentWindow;
542+
win.focus();
543+
win.console.log = log;
544+
win.console.clear = clear;
545+
win.console.error = error;
546+
win.console.write = write;
547+
548+
if(!chk.persist){
549+
clear();
550+
}
551+
552+
if(params.async){
553+
js = '(async()=>{\n'+js+'\n})()';
554+
}
555+
556+
var result = await win.eval(js);
557+
resolve(result);
558+
559+
//iframe.remove();
560+
561+
}//onload
562+
563+
}//host
564+
565+
566+
//:
567+
568+
515569
obj.kill = function(){return kill()}
516570

517571
function kill(){

0 commit comments

Comments
 (0)