Skip to content

Commit 211d4d4

Browse files
save file
1 parent 7b7887e commit 211d4d4

1 file changed

Lines changed: 27 additions & 16 deletions

File tree

utils/editors/srcdoc/v2.0/srcdoc-v2.0.html

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@
102102
body
103103
{height:calc(100% - 16px);display:flex;flex-direction:column;font-family:arial}
104104

105+
#github-root
106+
{border:1px solid lightgray;padding:5px 10px;border-radius:3px;cursor:pointer}
107+
105108
.icon
106109
{border:1px solid gray;border-radius:3px;box-sizing:border-box;width:30px;height:30px;cursor:pointer}
107110

@@ -154,6 +157,10 @@ <h1 slot=seo-hdr class=visually-hidden>
154157

155158

156159
<div id=url-root>
160+
<div id=github-root>
161+
github
162+
<input type=checkbox>
163+
</div>
157164
<img class='copy icon'>
158165
<img class='paste icon'>
159166
<input id=url autocomplete=off spellcheck=false>
@@ -170,6 +177,7 @@ <h1 slot=seo-hdr class=visually-hidden>
170177

171178
var srchdrs;
172179

180+
var chk = {};
173181
var input;
174182
var iframe;
175183

@@ -185,7 +193,7 @@ <h1 slot=seo-hdr class=visually-hidden>
185193
debug('initdom');
186194
await vm.initdom();
187195

188-
var [viewport,obj2] = await Promise.all([vm.new(),mod.component('srcdoc-headers',{component:'page'})]);
196+
var [viewport,obj2] = await Promise.all([vm.new({initdom:{icons:{remove:false}}}),mod.component('srcdoc-headers',{component:'page'})]);
189197
viewport.hide();
190198
viewport.pos({x:200,y:200,w:630,h:250});
191199
viewport.body.append(obj2.__host);
@@ -194,6 +202,7 @@ <h1 slot=seo-hdr class=visually-hidden>
194202

195203
root = document.body;
196204

205+
chk.github = $.chkbox(root,'#github-root');
197206
input = $(root,'#url');
198207

199208
$(root,'.copy').onclick = btn.copy;
@@ -227,37 +236,39 @@ <h1 slot=seo-hdr class=visually-hidden>
227236

228237

229238
btn.go = async function(){
230-
239+
debug('btn.go');
231240
var url = input.value;
232-
var result = github.parse(url);
233-
if(result.error){
234-
alert(result.error);
235-
return;
236-
}
237241

238-
if(!result.token){
239-
result.token = localStorage['github-token'];
242+
if(chk.github.checked){
243+
debug('github');
244+
var result = github.parse(url);
245+
if(result.error){
246+
alert(result.error);
247+
return;
248+
}
249+
250+
if(!result.token){
251+
result.token = localStorage['github-token'];
252+
}
253+
254+
if(result.token){
255+
result.api = true;
256+
}
257+
url = github.build(result);
240258
}
241259

242-
if(result.token){
243-
result.api = true;
244-
}
245-
var url = github.build(result);
246260

247261
var err;
248-
249262
try{
250263

251264
var res = await fetch(url);
252265

253266
}//try
254-
255267
catch(err2){
256268

257269
err = err2;
258270

259271
}//catch
260-
261272
if(err){
262273
alert(err.toString());
263274
return;

0 commit comments

Comments
 (0)