Skip to content

Commit 1a78e0f

Browse files
save file
1 parent bcd3372 commit 1a78e0f

File tree

1 file changed

+51
-20
lines changed

1 file changed

+51
-20
lines changed

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

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@
5252
isolate
5353
</span>
5454

55-
<span id=allow-scripts class=radio>
56-
<input type=checkbox checked disabled>
57-
allow-scripts
58-
</span>
5955
<span id=allow-modals class=radio>
6056
<input type=checkbox checked>
6157
allow-modals
@@ -67,7 +63,7 @@
6763

6864
<div style='flex:1'></div>
6965

70-
<span id=console-show class=radio>
66+
<span id=console class=radio>
7167
<input type=checkbox checked>
7268
console
7369
</span>
@@ -105,7 +101,7 @@
105101
version : 'v2.0',
106102
};
107103

108-
var df=false,did='output-console'
104+
var df=true,did='output-console'
109105
;
110106

111107

@@ -144,9 +140,11 @@
144140
var sandbox_allow = `clipboard-write; clipboard-read; camera; microphone; geolocation; accelerometer; gyroscope; magnetometer; payment; usb; serial; bluetooth;
145141
xr-spatial-tracking; autoplay; encrypted-media; picture-in-picture; screen-wake-lock; web-share`;
146142

147-
143+
var fn = {};
148144
var chk = {};
149145
var btn = {};
146+
var btn.console = {};
147+
obj.on = {};
150148

151149

152150
//:
@@ -174,11 +172,19 @@
174172
debug('initdom');
175173
shadow = host.shadowRoot;
176174

177-
chk.persist = $.chkbox(shadow,'#console-persist',false);
178-
chk.log = $.chkbox(shadow,'#console-log',false);
175+
176+
chk.isolate = $.chkbox(shadow,'#isolate');
177+
178+
chk['allow-modals'] = $.chkbox(shadow,'#allow-modals');
179+
chk['allow-popups'] = $.chkbox(shadow,'#allow-popups');
180+
181+
chk.console = $.chkbox(shadow,'#console');
182+
chk['console-echo'] = $.chkbox(shadow,'#console-echo');
183+
chk['console-persist'] = $.chkbox(shadow,'#console-persist',false);
184+
$.chkbox(shadow,'#console-clear',btn.console.clear);
185+
179186
chk.wrap = $.chkbox(shadow,'#word-wrap',wrap);
180187

181-
$(shadow,'#clear').onclick = btn.clear;
182188
$(shadow,'#kill').onclick = btn.kill;
183189

184190

@@ -192,21 +198,16 @@
192198
}//initdom
193199

194200

195-
btn.kill = function(){
196-
debug('btn.kill');
197-
kill();
198-
199-
}//kill
200201

201202

202-
btn.clear = function(){
203+
btn.console.clear = function(){
203204
debug('btn.clear');
204205
clear();
205206

206207
}//clear
207208

208209

209-
function wrap(chk){
210+
btn.wrap = function(chk){
210211
//console.log('wrap',v);
211212
if(chk.checked){
212213
output.style.whiteSpace = 'pre-wrap';
@@ -217,6 +218,28 @@
217218
}//wrap
218219

219220

221+
btn.kill = function(){
222+
debug('btn.kill');
223+
kill();
224+
225+
}//kill
226+
227+
228+
//:
229+
230+
231+
obj.on.message = function(json){
232+
console.log('output.message',json);
233+
var {name,args} = json;
234+
//webconsole[name].apply(null,args);
235+
fn[name].apply(null,args);
236+
237+
}//message
238+
239+
240+
//:
241+
242+
220243
obj.run = async function(js,params={}){
221244
debug('run');
222245
var sandbox = (()=>{
@@ -310,6 +333,7 @@
310333
build.sandbox();
311334
iframe.setAttribute('allow',sandbox_allow);
312335
iframe.src = sandbox_url;
336+
debug(sandbox_url);
313337
iframe.style.cssText = 'display:none';
314338
iframe.onload = onload;
315339

@@ -323,16 +347,17 @@
323347
async function onload(){
324348

325349

326-
327-
if(!chk.persist){
350+
if(!chk['console-persist'].checked){
328351
clear();
329352
}
330353

331354

332355
if(params.async){
333356
js = '(async()=>{\n'+js+'\n})()';
334357
}
335-
var result = await win.eval(js);
358+
359+
iframe.contentWindow.postMessage({type:'run',js});
360+
//var result = await win.eval(js);
336361

337362

338363
resolve(result);
@@ -389,6 +414,7 @@
389414

390415

391416
obj.clear = function(){return clear()}
417+
fn.clear = function(){return clear.apply(null,arguments)};
392418

393419
function clear(){
394420

@@ -402,6 +428,7 @@
402428

403429

404430
obj.log = function(){return log.apply(log,arguments)};
431+
fn.log = function(){return log.apply(null,arguments)};
405432

406433
function log(){
407434

@@ -436,6 +463,7 @@
436463

437464

438465
obj.groupCollapsed = function(){return groupCollapsed.apply(null,arguments)}
466+
fn[groupCollapsed = function(){return groupCollapsed.apply(null,arguments)}
439467

440468
function groupCollapsed(...args){
441469

@@ -451,6 +479,7 @@
451479

452480

453481
obj.error = function(){return error.apply(null,arguments)}
482+
fn.error = function(){return error.apply(null,arguments)}
454483

455484
function error(){
456485

@@ -467,6 +496,7 @@
467496

468497

469498
obj.node = function(){return node.apply(null,arguments)}
499+
fn.node = function(){return node.apply(null,arguments)}
470500

471501
function node(node){
472502

@@ -481,6 +511,7 @@
481511

482512

483513
obj.write = function(){return write.apply(null,arguments)}
514+
fn.write = function(){return write.apply(null,arguments)}
484515

485516
function write(){
486517

0 commit comments

Comments
 (0)