Skip to content

Commit f1516e4

Browse files
save file
1 parent 5521a44 commit f1516e4

1 file changed

Lines changed: 53 additions & 15 deletions

File tree

‎utils/editors/html/code-explorer/v1.0/code-explorer-v1.0.html‎

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
</div>
6161

6262
<div id=view>
63+
6364
<div class='fn item'>
6465
<div class=line>
6566
</div>
@@ -70,9 +71,22 @@
7071
<div class=args>
7172
</div>
7273
</div>
74+
7375
<div class='label item'>
7476
</div>
75-
</div>
77+
78+
<div class='html item'>
79+
<div class=line>
80+
</div>
81+
<div class=name>
82+
</div>
83+
<div class=id>
84+
</div>
85+
<div class=class>
86+
</div>
87+
</div>
88+
89+
</div view>
7690

7791
</template>
7892

@@ -224,7 +238,23 @@
224238
console.log(list);
225239
view.replaceChildren();
226240

241+
list.forEach(o=>{
227242

243+
var node = ui.html.cloneNode(true);
244+
$(node,'.line').textContent = o.line;
245+
$(node,'.name').textContent = o.name;
246+
if(o.attrs.id){
247+
$(node,'.id').textContent = o.attrs.id;
248+
}else{
249+
$(node,'.id').remove();
250+
}
251+
if(o.attrs.class){
252+
$(node,'.class').textContent = o.attrs.class;
253+
}else{
254+
$(node,'.class').remove();
255+
}
256+
257+
});
228258

229259
}//html
230260

@@ -338,7 +368,7 @@
338368
if(!valid(name))return;
339369

340370
var args = parse.fn.args(txt,i1);
341-
var indent = parse.fn.indent(txt,i1);
371+
var indent = parse.indent(txt,i1);
342372

343373
return {index:i1,name,args,indent};
344374

@@ -371,7 +401,7 @@
371401
if(!valid(name))return;
372402

373403
var args = parse.fn.args(txt,i1);
374-
var indent = parse.fn.indent(txt,i1);
404+
var indent = parse.indent(txt,i1);
375405

376406
return {index:i1,name,args,indent};
377407

@@ -389,7 +419,7 @@
389419
}//args
390420

391421

392-
parse.fn.indent = function(txt,i1){
422+
parse.indent = function(txt,i1){
393423

394424
var i2 = txt.lastIndexOf('\n',i1);
395425
var i3 = txt.indexOf('\n',i1);
@@ -474,6 +504,7 @@
474504

475505
parse.html = function(txt){
476506

507+
var list = [];
477508
var regex = /<\/?[a-z][a-z0-9]*\b[^>]*>/gi;
478509

479510
while(true){
@@ -485,30 +516,35 @@
485516
var tag = match[0];
486517

487518
if(!tag.startsWith('</')){
488-
console.log(tag);
489-
/*
490-
var i1 = tagname.indexOf(' ');
491-
var name = tagname.slice(2,i1);
492-
var i2 = tagname.indexOf('>');
493-
var attrs = tagname.slice(i1+1,i2);
494-
*/
519+
//console.log(tag);
495520
var match = tag.match(/^<\s*([a-z0-9\-]+)/i);
496521
var name = match ? match[1].toLowerCase() : '';
497522
if(!name)debugger;
498523
if(name){
499524
var parser = new DOMParser();
500525
var doc = parser.parseFromString(tag,'text/html');
501526
var element = doc.querySelector(name);
502-
var attributes = {};
527+
var attrs = {};
503528

504529
for(var i=0;i<element.attributes.length;i++){
505530

506-
var attr = element.attributes[i];
507-
attributes[attr.name] = (attr.value==='' ? true : attr.value);
531+
var attr = element.attributes[i];
532+
attrs[attr.name] = (attr.value==='' ? true : attr.value);
508533

509534
}//for
510535

511-
console.log(name,attributes);
536+
//console.log(name,attributes);
537+
var line = lineno(txt,index);
538+
var indent = parse.indent(txt,index);
539+
540+
var o = {
541+
index,
542+
line,
543+
indent,
544+
name,
545+
attrs
546+
};
547+
list.push(o);
512548
}
513549

514550

@@ -518,6 +554,8 @@
518554

519555
}//while
520556

557+
return list;
558+
521559

522560
}//html
523561

0 commit comments

Comments
 (0)