|
1 | 1 |
|
2 | 2 |
|
3 | | -<!-- headers |
4 | | - cross-origin-isolate |
5 | | ---> |
6 | | - |
7 | | - |
8 | 3 | <!DOCTYPE html> |
9 | 4 |
|
10 | 5 | <html lang=en> |
|
40 | 35 | } |
41 | 36 | </script> |
42 | 37 |
|
| 38 | + <!--https://www.opengraph.xyz/--> |
| 39 | + <meta property=og:title content='JS Console'> |
| 40 | + <meta property=og:description content='Run, test, and debug JavaScript instantly in your browser. A fast, lightweight online JS console built for developers who value speed and simplicity.'> |
| 41 | + <meta property=og:image:width content=1280> |
| 42 | + <meta property=og:image:height content=720> |
| 43 | + <meta property=og:url content='https://ext-code.com/utils/editors/js-console/js-console.html'> |
| 44 | + <meta property=og:type content=website> |
| 45 | + <meta property=og:site_name content=ext-code.com> |
| 46 | + <!-- |
| 47 | + <meta property=og:image content='https://ext-code.com/utils/editors/html-editor/images/og-image.webp'> |
| 48 | + --> |
| 49 | + |
43 | 50 |
|
44 | 51 | <script src='https://cdn.jsdelivr.net/npm/ace-builds@1.37.0/src-min-noconflict/ace.js'></script> |
45 | 52 | <script src="https://cdn.jsdelivr.net/npm/prettier@2.8.8/standalone.js"></script> |
46 | 53 | <script src="https://cdn.jsdelivr.net/npm/prettier@2.8.8/parser-babel.js"></script> |
47 | 54 | <script src="https://cdn.jsdelivr.net/npm/terser/dist/bundle.min.js"></script> |
| 55 | + <script src='https://ext-code.com/libs/js/external/espree/espree.js'></script> |
48 | 56 |
|
| 57 | + <script src='https://libs.ext-code.com/js/dom/component/v3.0/component.js?hdr'></script> |
49 | 58 |
|
50 | | - <script src='https://libs.ext-code.com/js/dom/component/component.js'></script> |
51 | | - |
52 | | - <script init> |
53 | | - console.clear(); |
54 | | - console.log('js-console-v2.0.html'); |
55 | | - console.log(); |
56 | | - console.json=v=>console.log(JSON.stringify(v,null,4)); |
57 | | - var version='v2.0'; |
| 59 | + <script> |
| 60 | + console.log('js-console-v3.0.html'); |
| 61 | + var version='v3.0'; |
58 | 62 | var df=true,did='js-console'; |
59 | 63 |
|
60 | 64 | var ace; |
61 | 65 | var obfuscator; |
62 | 66 | var espree; |
63 | 67 |
|
64 | | - var ext; |
65 | | - var $; |
66 | | - var datatype; |
67 | | - var menumod; |
68 | | - var keydown; |
69 | | - var debug; |
70 | | - var ls; |
71 | | - |
72 | 68 | var menu; |
73 | 69 |
|
74 | 70 | var hdr; |
75 | | - var mainmenu; |
76 | 71 | var filemod; |
77 | 72 | var autosave; |
78 | 73 | var publish; |
|
86 | 81 |
|
87 | 82 | async function init(){ |
88 | 83 | debug('init',version); |
89 | | - //keydown = keydown(); |
90 | | - menu = menumod(); |
91 | | - |
92 | | - |
93 | | - mod.base.add({ext,$,datatype,keydown,menu,menumod,ace,ls}); |
94 | | - |
95 | | - |
| 84 | + debug('crossOriginIsolated',window.crossOriginIsolated); |
96 | 85 | hdr = mod['editors-hdr']; |
97 | | - mainmenu = mod['main-menu']; |
98 | 86 | filemod = mod['file-mod']; |
99 | 87 | autosave = mod['auto-save']; |
100 | 88 | publish = mod['publish-ui']; |
101 | 89 | editor = mod['web-editor']; |
102 | | - output = mod['output-console'] |
| 90 | + output = mod['output-console']; |
103 | 91 | log = mod['log-mod']; |
104 | 92 |
|
| 93 | + mod.base.add({filemod,complete,source,focus}); |
105 | 94 |
|
106 | | - menu.initmod({keydown}); |
| 95 | + autosave.initmod({save:btn.save}); |
| 96 | + editor.initmod({on,mode:'javascript'}); |
107 | 97 |
|
108 | | - hdr.initmod({ext,$,menu}); |
109 | | - mainmenu.initmod({ext,$,menu,editor,filemod}); |
110 | | - filemod.initmod({ext,$,menu,menumod,complete,source,focus,log}); |
111 | | - autosave.initmod({$,menu,keydown,log,save:btn.save}); |
112 | | - publish.initmod({ext,$,ui,menu,source,complete,log}); |
113 | | - editor.initmod({ext,$,menu,ace,on}); |
114 | | - output.initmod({ext,$}); |
115 | | - log.initmod({ext,$}); |
| 98 | + await mod.auto(); |
116 | 99 |
|
| 100 | + hdr['page-source'].url('v3.0/js-console-v3.0.html'); |
117 | 101 |
|
118 | | - await Promise.all([ |
119 | | - mainmenu.init(), |
120 | | - hdr.init(), |
121 | | - filemod.init(), |
122 | | - autosave.init(), |
123 | | - publish.init(), |
124 | | - editor.init(), |
125 | | - output.init(), |
126 | | - log.init(), |
127 | | - ]); |
128 | | - |
129 | | - |
130 | | - //: |
131 | | - |
132 | | - |
133 | | - icon.def = $('[rel*=icon]').href; |
| 102 | + icon.def = $('[rel*=icon]').href; |
134 | 103 |
|
135 | 104 | window.onfocus = ()=>editor && editor.focus(); |
136 | 105 | keydown.add(kd); |
|
146 | 115 | }//init |
147 | 116 |
|
148 | 117 |
|
149 | | - //: |
150 | | - |
151 | | - |
152 | | -(async()=>{ |
153 | | - |
154 | | - mod.stack.add; |
155 | | - |
156 | | - ({ext} = await import('https://libs.ext-code.com/js/io/ext-loader/ext-loader.m.js')); |
157 | | - |
158 | | - var lsmod; |
159 | | - |
160 | | - var promise = ext.load.libs( |
161 | | - 'js/dom/$.js', |
162 | | - 'js/core/datatype.js', |
163 | | - 'js/dom/menumod/menumod.js', |
164 | | - 'js/dom/keydown/keydown.js', |
165 | | - 'js/debug/debug.js', |
166 | | - 'js/core/ls-mod/ls-mod.js', |
167 | | - ); |
168 | | - [$,datatype,menumod,keydown,debug,lsmod] = await promise; |
169 | | - |
170 | | - ls = lsmod(); |
171 | | - |
172 | | - mod.stack.complete; |
173 | | - |
174 | | -})(); |
175 | | - |
176 | | - |
177 | | - </script init> |
| 118 | + </script> |
178 | 119 |
|
179 | 120 |
|
180 | 121 | <link rel=stylesheet href='/utils/css/utils.css' crossorigin=anonymous> |
|
216 | 157 | } |
217 | 158 |
|
218 | 159 | #run |
219 | | - {color:blue;font-weight:bold} |
| 160 | + {color:blue;font-weight:bold;margin-left:20px} |
220 | 161 | #iframe-root |
221 | 162 | {border:1px solid lightgray;padding:5px 10px;display:flex;align-items:center;border-radius:5px} |
222 | 163 | #iframe-root input |
223 | 164 | {margin-left:10px} |
224 | 165 | #async-root |
225 | | - {border:1px solid lightgray;padding:5px 10px;display:flex;align-items:center;border-radius:5px} |
| 166 | + {border:1px solid lightgray;padding:5px 10px;display:flex;align-items:center;border-radius:5px;cursor:pointer;margin-right:20px} |
226 | 167 | #async-root input |
227 | 168 | {margin-left:10px} |
228 | 169 |
|
|
257 | 198 | <body> |
258 | 199 |
|
259 | 200 | <editors-hdr component=grp> |
260 | | - <img class=title src='images/js-console.png' style='top:5px;height:35px'> |
261 | | - <time slot=date datetime=2025-10-30>30 Oct 2025</time> |
| 201 | + <img slot=title src='images/js-console.png' style='top:-10px;height:75px'> |
| 202 | + <h1 slot=seo-hdr class=visually-hidden>html editor</h1> |
| 203 | + <h4 slot=version>v3.0</h4> |
| 204 | + <time slot=date datetime=2026-01-24>24 Jan 2026</time> |
262 | 205 | </editors-hdr> |
263 | 206 |
|
264 | 207 |
|
|
275 | 218 |
|
276 | 219 | <publish-ui component></publish-ui> |
277 | 220 |
|
278 | | - <button id=run>run</button> |
279 | | - |
280 | | - <div id=iframe-root> |
281 | | - <span> |
282 | | - iframe |
283 | | - </span> |
284 | | - <input id=iframe type=checkbox checked> |
285 | | - </div> |
| 221 | + <button id=run title='ctrl+enter'>run</button> |
286 | 222 |
|
287 | 223 | <div id=async-root> |
288 | 224 | <span> |
|
309 | 245 |
|
310 | 246 | <div id=page-slider style='width:10px;cursor:ew-resize'></div> |
311 | 247 |
|
312 | | - <output-console component=page></output-console> |
| 248 | + <output-console v3.0 component=page></output-console> |
313 | 249 |
|
314 | 250 | </div> |
315 | 251 |
|
|
347 | 283 |
|
348 | 284 |
|
349 | 285 | async function initdom(rootnode){ //c |
350 | | - console.log('initdom'); |
| 286 | + debug('initdom'); |
351 | 287 | root = rootnode; |
352 | 288 |
|
353 | 289 | keydown.initdom(); |
354 | 290 | menu.add.style(); |
355 | 291 |
|
| 292 | + var btn1 = document.createElement('input'); |
| 293 | + btn1.type = 'button'; |
| 294 | + btn1.value = 'isolate'; |
| 295 | + $(hdr.__host.shadowRoot,'#btns').append(btn1); |
| 296 | + btn1.onclick = btn.isolate; |
| 297 | + |
356 | 298 |
|
357 | 299 | $(root,'#save').onclick = btn.save; |
358 | 300 |
|
|
366 | 308 |
|
367 | 309 |
|
368 | 310 | $(root,'#run').onclick = run; |
369 | | - mode.iframe = $(root,'#iframe'); |
370 | | - mode.async = $(root,'#async'); |
| 311 | + mode.async = $.chkbox(root,'#async-root'); |
371 | 312 |
|
372 | 313 | $(root,'#syntax-chk').onclick = btn.syntax; |
373 | 314 | $(root,'#prettier').onclick = btn.prettier; |
|
385 | 326 |
|
386 | 327 | slider.node = $.slider('web-editor','#page-slider','output-console',slider,ui); |
387 | 328 |
|
388 | | - |
| 329 | + /* |
389 | 330 | await Promise.all([ |
390 | 331 | hdr.initdom(), |
391 | 332 | mainmenu.initdom(root), |
|
396 | 337 | output.initdom(root), |
397 | 338 | log.initdom(), |
398 | 339 | ]); |
| 340 | + */ |
399 | 341 |
|
400 | 342 |
|
401 | 343 |
|
|
426 | 368 | var url = new URL(window.location); |
427 | 369 | var params = url.searchParams; |
428 | 370 |
|
429 | | - mode.iframe.checked = params.has('iframe'); |
430 | 371 | mode.async.checked = params.has('async'); |
431 | 372 |
|
432 | 373 | }//query |
|
463 | 404 | //: |
464 | 405 |
|
465 | 406 |
|
| 407 | + btn.isolate = function(){ |
| 408 | + |
| 409 | + var url = window.location.toString(); |
| 410 | + var i1 = url.indexOf('?'); |
| 411 | + if(i1!=-1){ |
| 412 | + url = urls.lice(0,i1); |
| 413 | + }else{ |
| 414 | + url += '?isolate'; |
| 415 | + } |
| 416 | + window.location = url; |
| 417 | + |
| 418 | + }//isolate |
| 419 | + |
| 420 | + |
466 | 421 | btn.save = function(e){ |
467 | 422 |
|
468 | 423 | filemod.save(); |
|
471 | 426 |
|
472 | 427 |
|
473 | 428 | btn.syntax = function(){ |
474 | | - |
| 429 | + debug('btn.syntax'); |
475 | 430 | var js = editor.getValue(); |
476 | 431 | var result = syntax(js); |
477 | 432 | var str = JSON.stringify(result,null,4); |
|
485 | 440 |
|
486 | 441 |
|
487 | 442 | btn.prettier = function(){ |
488 | | - |
| 443 | + debug('btn.prettier'); |
489 | 444 | var js = editor.getvalue(); |
490 | 445 |
|
491 | 446 | var options = { |
|
522 | 477 |
|
523 | 478 |
|
524 | 479 | btn.terser = async function(){ |
525 | | - |
| 480 | + debug('btn.terser'); |
526 | 481 | var js = editor.getvalue(); |
527 | 482 |
|
528 | 483 | var options = { |
|
562 | 517 |
|
563 | 518 |
|
564 | 519 | btn.obfuscator = function(){ |
565 | | - |
| 520 | + debug('btn.obfuscator'); |
566 | 521 | var js = editor.getvalue(); |
567 | 522 |
|
568 | 523 | var err; |
|
610 | 565 |
|
611 | 566 | }//title |
612 | 567 |
|
| 568 | + //: |
| 569 | + |
| 570 | + |
| 571 | + window.addEventListener('message',e=>{console.log(e); |
| 572 | + |
| 573 | + var json = e.data; |
| 574 | + if(json.sandbox){ |
| 575 | + output.on.message(json); |
| 576 | + } |
| 577 | + |
| 578 | + }); |
| 579 | + |
| 580 | + |
613 | 581 | //: |
614 | 582 |
|
615 | 583 |
|
|
0 commit comments