|
40 | 40 | </script> |
41 | 41 |
|
42 | 42 |
|
43 | | - <script src='https://libs.ext-code.com/js/dom/component/v3.0/component.js'></script> |
| 43 | + <script src='https://libs.ext-code.com/js/dom/component/v3.0/component.js?hdr'></script> |
44 | 44 |
|
45 | 45 | <script init> |
46 | 46 | console.clear(); |
|
61 | 61 | var menu; |
62 | 62 |
|
63 | 63 |
|
64 | | - async function init(){ |
| 64 | + async function ready(){ |
65 | 65 | debug('init',version); |
66 | | - menu = menumod(); |
67 | | - |
68 | | - mod.base.add({ext,$,datatype,keydown,menu,menumod}); |
69 | | - |
70 | | - |
71 | | - await initdom(document.body); |
| 66 | + vm.initmod({mod}); |
| 67 | + await vm.init(); |
72 | 68 |
|
| 69 | + await initdom(); |
73 | 70 |
|
74 | 71 | }//init |
75 | 72 |
|
|
81 | 78 | ({ext} = await import('https://libs.ext-code.com/js/io/ext-loader/ext-loader.m.js')); |
82 | 79 |
|
83 | 80 | var promise = ext.load.libs( |
84 | | - 'js/dom/$.js', |
85 | | - 'js/core/datatype.js', |
86 | | - 'js/dom/menumod/menumod.js', |
87 | | - 'js/dom/keydown/keydown.js', |
88 | | - 'js/debug/debug.js', |
89 | 81 | 'js/io/github/github.js', |
| 82 | + 'js/dom/viewport-manager/v1.0.0/viewport-manager-v1.0.0.js', |
90 | 83 | ); |
91 | | - [$,datatype,menumod,keydown,debug,github] = await promise; |
| 84 | + [github,vm] = await promise; |
| 85 | + |
| 86 | + vm = vm(); |
92 | 87 |
|
93 | 88 | mod.stack.complete; |
94 | 89 |
|
|
107 | 102 | body |
108 | 103 | {height:calc(100% - 16px);display:flex;flex-direction:column;font-family:arial} |
109 | 104 |
|
| 105 | + #github-root |
| 106 | + {border:1px solid lightgray;padding:5px 10px;border-radius:3px;cursor:pointer;display:flex;align-items:center;gap:5px} |
| 107 | + |
110 | 108 | .icon |
111 | 109 | {border:1px solid gray;border-radius:3px;box-sizing:border-box;width:30px;height:30px;cursor:pointer} |
112 | 110 |
|
|
129 | 127 | {font-size:16px;padding:5px 10px} |
130 | 128 | input[type=button] |
131 | 129 | {cursor:pointer} |
| 130 | + input[type=checkbox] |
| 131 | + {cursor:pointer;margin:0;width:16px;height:16px;box-sizing:border-box} |
132 | 132 |
|
| 133 | + |
| 134 | + #hdrs-icon |
| 135 | + { |
| 136 | + content:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAMAAAAM7l6QAAAA7VBMVEVHcEwCAQQAAAAgIiMWIjFVW11VW14LDRMAAAAgIiMDAAEAAACvu78pQF0YJjZBRkgSGigKCwwGBwseICFdY2UzUXUyTG/m+Pzs/f/q/P8hM0uLlJjBz9Pj9fk6XYfn+f05W4Tc7fFkeaU7XolKUlx0fICcvf+YuPyHpOCEody+zM6OrOl2jr82V39CS2AwTXDm9/uVtPUtNEV+mNBSYocfKz5IVXVvhrc1VHkoQF0eJDJWZ45rgLBOXX05Q1jW5urE09Y7X4pze39gdKCBi40/S2dGU3JQV1t0fX/N3OC7ycwkOVS7yMyowOnh8/dPgjyxAAAAF3RSTlMABi2y7Oztsyi1Ei6xx+fo6nN0s+a1ukIGjSwAAAE0SURBVCjPpdNpU4JAGMBxQUnyPiqhbNcwFxJQbsW8z+z6/h+nBcEWxHrhn1l48Zud2ZnlSaUui2LzNE2zVI7OUSxNlGcpzLVKBle6K2aKt6UMWaWGN2f7LRU/OABaZKCfpTx23aGtfrhtEK0dsKqCIRiqi3a0xYHt+zPZPr89nKnjcXrO8Ylx87THTdhIDDZDhgn9svaUkBYyv989n7Tb8yF3p+ZLLHPa5Y7cEyVTVqRXK1iCLvYiPN4IG9kxTHlrmIJtK5h5kkfGFA22CA0cJIwcSZzMSR5YioOUCeYJGlsiEr++IcG6LMpIl5G3vA9SZofd15iNlRBrZQRHwzxbLzuxluvjbgiTbgTCkP+6kn+4/q49xtMa3uuzjv/kapk5qVC4uWKYctUfA/qknD8b/hhc0g/wRVKEMCnUEAAAAABJRU5ErkJggg==); |
| 137 | + } |
| 138 | + |
| 139 | + |
133 | 140 | </style> |
134 | 141 |
|
135 | 142 | </head> |
136 | 143 |
|
137 | 144 |
|
138 | 145 | <body> |
139 | 146 |
|
| 147 | + |
| 148 | + <editors-hdr v2.0 component=grp> |
| 149 | + <img slot=title src='images/srcdoc.png' style='top:-5px;height:70px' alt='html editor'> |
| 150 | + <h1 slot=seo-hdr class=visually-hidden> |
| 151 | + html editor |
| 152 | + </h1> |
| 153 | + |
| 154 | + <time slot=date datetime=2026-04-23> |
| 155 | + 23 Apr 2026 |
| 156 | + </time> |
| 157 | + |
| 158 | + </editors-hdr> |
| 159 | + |
| 160 | + |
140 | 161 | <div id=url-root> |
| 162 | + <div id=github-root> |
| 163 | + github |
| 164 | + <input type=checkbox> |
| 165 | + </div> |
141 | 166 | <img class='copy icon'> |
142 | 167 | <img class='paste icon'> |
143 | 168 | <input id=url autocomplete=off spellcheck=false> |
| 169 | + <img id=hdrs-icon class=icon title='request headers'> |
144 | 170 | <input type=button value=go> |
145 | | - |
146 | 171 | </div> |
147 | 172 |
|
148 | 173 | <iframe></iframe> |
|
152 | 177 |
|
153 | 178 | <script> |
154 | 179 |
|
155 | | - |
| 180 | + var hdrs; |
| 181 | + |
| 182 | + var chk = {}; |
156 | 183 | var input; |
157 | 184 | var iframe; |
158 | 185 |
|
|
164 | 191 | //: |
165 | 192 |
|
166 | 193 |
|
167 | | - function initdom(){ |
| 194 | + async function initdom(){ |
168 | 195 | debug('initdom'); |
| 196 | + await vm.initdom(); |
| 197 | + |
| 198 | + var vparams = {initmod:{icons:{remove:false}}}; |
| 199 | + var [viewport,headers] = await Promise.all([vm.new(vparams),mod.component('srcdoc-headers',{component:'page'})]); |
| 200 | + viewport.hide(); |
| 201 | + viewport.pos({x:200,y:200,w:730,h:250}); |
| 202 | + viewport.body.append(headers.__host); |
| 203 | + hdrs = {viewport,headers}; |
| 204 | + |
| 205 | + |
169 | 206 | root = document.body; |
170 | 207 |
|
| 208 | + chk.github = $.chkbox(root,'#github-root'); |
171 | 209 | input = $(root,'#url'); |
172 | 210 |
|
173 | 211 | $(root,'.copy').onclick = btn.copy; |
174 | 212 | $(root,'.paste').onclick = btn.paste; |
175 | 213 |
|
| 214 | + $(root,'#hdrs-icon').onclick = btn['hdrs-icon']; |
176 | 215 | $(root,'[value=go]').onclick = btn.go; |
177 | 216 |
|
178 | 217 |
|
|
200 | 239 |
|
201 | 240 |
|
202 | 241 | btn.go = async function(){ |
203 | | - |
| 242 | + debug('btn.go'); |
204 | 243 | var url = input.value; |
205 | | - var result = github.parse(url); |
206 | | - if(result.error){ |
207 | | - alert(result.error); |
208 | | - return; |
209 | | - } |
210 | 244 |
|
211 | | - if(!result.token){ |
212 | | - result.token = localStorage['github-token']; |
213 | | - } |
214 | | - |
215 | | - if(result.token){ |
216 | | - result.api = true; |
| 245 | + if(chk.github.checked){ |
| 246 | + debug('github'); |
| 247 | + var result = github.parse(url); |
| 248 | + if(result.error){ |
| 249 | + alert(result.error); |
| 250 | + return; |
| 251 | + } |
| 252 | + |
| 253 | + if(!result.token){ |
| 254 | + result.token = localStorage['github-token']; |
| 255 | + } |
| 256 | + |
| 257 | + if(result.token){ |
| 258 | + result.api = true; |
| 259 | + } |
| 260 | + url = github.build(result); |
217 | 261 | } |
218 | | - var url = github.build(result); |
219 | 262 |
|
| 263 | + debug(url); |
| 264 | + var headers = hdrs.headers.headers; |
| 265 | + debug.json(headers); |
220 | 266 | var err; |
221 | | - |
222 | 267 | try{ |
223 | 268 |
|
224 | | - var res = await fetch(url); |
| 269 | + var res = await fetch(url,{headers}); |
225 | 270 |
|
226 | 271 | }//try |
227 | | - |
228 | 272 | catch(err2){ |
229 | 273 |
|
230 | 274 | err = err2; |
231 | 275 |
|
232 | 276 | }//catch |
233 | | - |
234 | 277 | if(err){ |
235 | 278 | alert(err.toString()); |
236 | 279 | return; |
|
251 | 294 | }//go |
252 | 295 |
|
253 | 296 |
|
| 297 | + btn['hdrs-icon'] = async function(){ |
| 298 | + |
| 299 | + if(hdrs.viewport.status=='hidden'){ |
| 300 | + hdrs.viewport.show(); |
| 301 | + }else{ |
| 302 | + hdrs.viewport.hide(); |
| 303 | + } |
| 304 | + |
| 305 | + }//hdrs-icon |
| 306 | + |
| 307 | + |
254 | 308 | //: |
255 | 309 |
|
256 | 310 |
|
|
0 commit comments