File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed
utils/editors/js-console/html/output-console/v2.0 Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change 259259 if ( params . async ) {
260260 js = '(async()=>{\n' + js + '\n})()' ;
261261 }
262+
262263 var result = await win . eval ( js ) ;
263264 resolve ( result ) ;
264265
269270 } //iframe
270271
271272
273+ obj . run . iframe2 = async function ( js , params = { } ) {
274+ console . log ( 'run.iframe' ) ;
275+ var resolve , promise = new Promise ( res => resolve = res ) ;
276+
277+ if ( iframe ) {
278+ iframe . remove ( ) ;
279+ }
280+
281+ if ( params . async ) {
282+ js = '(async()=>{\n' + js + '\n})()' ;
283+ }
284+
285+ iframe = document . createElement ( 'iframe' ) ;
286+ obj . iframe = iframe ;
287+ iframe . srcdoc = `<script>${ js } </ script > `;
288+ iframe.onload = onload;
289+ cur.root.append(iframe);
290+
291+ return promise;
292+
293+
294+ async function onload(){
295+
296+ //setTimeout(complete,100);
297+
298+ //}//onload
299+
300+
301+ //async function complete(){
302+
303+ var win = iframe.contentWindow;
304+
305+ win.focus();
306+ win.console.log = log;
307+ win.console.clear = clear;
308+ win.console.error = error;
309+ win.console.write = write;
310+
311+ if(!chk.persist){
312+ clear();
313+ }
314+
315+
316+ //var result = await win.eval(js);
317+ //resolve(result);
318+
319+ //iframe.remove();
320+
321+ }//onload
322+
323+ }//iframe
324+
325+
272326 obj.kill = function(){return kill()}
273327
274328 function kill(){
You can’t perform that action at this time.
0 commit comments