Skip to content

Commit 39b64e1

Browse files
save file
1 parent 9ee772b commit 39b64e1

1 file changed

Lines changed: 102 additions & 10 deletions

File tree

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

Lines changed: 102 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,18 @@
5050

5151
var df=true,did='code-explorer-html';
5252

53+
var debug,$,editor,fn
54+
;
5355

5456
obj.initmod = function(...list){
5557

56-
list..forEach(params=>{
58+
list.forEach(params=>{
59+
60+
debug = mod.rd(params,'debug',debug);
61+
$ = mod.rd(params,'$',$);
62+
editor = mod.rd(params,'editor',editor);
63+
fn = mod.rd(params,'fn',fn);
64+
5765
});
5866

5967
}//initmod
@@ -62,6 +70,9 @@
6270
//:
6371

6472

73+
var item;
74+
75+
6576
//:
6677

6778

@@ -73,13 +84,101 @@
7384

7485

7586
obj.initdom = async function(){
87+
88+
shadow = host.shadowRoot;
89+
90+
item = $(shadow,'.html');
91+
item.remove();
92+
7693
}//initdom
7794

7895

7996
//:
8097

8198

82-
parse.html = function(txt){
99+
obj.update = update;
100+
101+
function update(view){
102+
103+
var txt = editor.getvalue();
104+
var list = parse(txt);
105+
106+
var colours = {
107+
head : 'darkslategray',
108+
body : 'darkslategray',
109+
script : 'firebrick',
110+
template : 'forestgreen',
111+
style : 'dodgerblue',
112+
};
113+
console.log(list);
114+
view.replaceChildren();
115+
116+
list.forEach(o=>{
117+
118+
var node = item.cloneNode(true);
119+
120+
$(node,'.line').textContent = o.line;
121+
$(node,'.indent').style.width = (o.indent*3)+'px';
122+
123+
$(node,'.name').textContent = o.name;
124+
if(colours[o.name]){
125+
node.style.color = colours[o.name];
126+
}
127+
if(o.name.includes('-')){
128+
node.style.color = 'hsl(33,100%,30%)';
129+
}
130+
131+
var f=false;
132+
if(o.attrs.component){
133+
var regex = /\bv\d+(?:\.\d+)*(?!\s*=\s*)\b/;
134+
var v;
135+
for(var key in o.attrs){
136+
137+
if(regex.test(key)){
138+
v = key;
139+
break;
140+
}
141+
142+
}//for
143+
if(v){
144+
$(node,'.v').textContent = v;
145+
f = true;
146+
}
147+
}
148+
if(!f){
149+
$(node,'.v').remove();
150+
}
151+
152+
if(o.attrs.id){
153+
$(node,'.id').textContent = o.attrs.id;
154+
}else{
155+
$(node,'.id').remove();
156+
}
157+
158+
if(o.attrs.class){
159+
$(node,'.class').textContent = o.attrs.class;
160+
}else{
161+
$(node,'.class').remove();
162+
}
163+
164+
165+
166+
if(o.name=='script'){
167+
}
168+
169+
170+
171+
172+
node.onclick = e=>editor.gotoline(o.line,o.col);
173+
174+
view.append(node);
175+
176+
});
177+
178+
}//html
179+
180+
181+
function parse(txt){
83182

84183
var list = [];
85184
var regex = /<\/?[a-z][a-z0-9\-]*\b[^>]*>/gi;
@@ -97,15 +196,8 @@
97196
//console.log(tag);
98197
var match = tag.match(/^<\s*([a-z0-9\-]+)/i);
99198
var name = match ? match[1].toLowerCase() : '';
100-
101-
/*
102-
var match = tag.match(/^<\s*\/?\s*([a-z0-9\-]+)/i);
103-
var name = match ? match[1].toLowerCase() : '';
104-
console.log(name);
105-
*/
106-
107199
if(!name){
108-
//debugger;
200+
//debugger;
109201
console.log('parse.html error',tag);
110202
}
111203

0 commit comments

Comments
 (0)