Skip to content

Commit b7b7441

Browse files
save file
1 parent 5f57e6f commit b7b7441

1 file changed

Lines changed: 48 additions & 8 deletions

File tree

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

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100

101101

102102

103+
103104
var btn = {};
104105
var sort = {};
105106
sort.alpha = {};
@@ -160,8 +161,10 @@
160161

161162
function update(){ //d
162163
//var d=debug('update');
163-
var txt = editor.getvalue();
164-
parse(txt);
164+
var mode = editor.mode;
165+
debug(mode);
166+
var txt = editor.getvalue();
167+
parse[mode](txt);
165168
console.log(list);
166169
view.replaceChildren();
167170

@@ -186,13 +189,52 @@
186189

187190

188191

189-
function parse(txt){
192+
var parse = {};
193+
194+
195+
parse.javascript = function(txt){
190196

191197
list = {};
198+
192199
list.fn = parse.fn(txt);
200+
list.fn.forEach(o=>o.line=lineno(txt,o.index));
201+
193202
list.label = parse.label(txt);
203+
list.label.forEach(o=>o.line=lineno(txt,o.index));
204+
205+
}//js
206+
207+
208+
parse.html = function(txt){
209+
210+
list = {};
211+
list.fn = [];
212+
list.label = [];
213+
214+
var index = 0;
215+
var ec = true;
216+
while(ec){
217+
218+
var i1 = txt.indexOf('<scr'+'ipt>';,index);
219+
if(i1==-1)break;
220+
var i2 = txt.indexOf('</scr'+'ipt',index);
221+
if(i2==-1)break;
222+
223+
var line = lineno(i1+6);
224+
var str = txt.slice(i1+6,i2);
225+
226+
var arr = parse.fn(txt);
227+
arr.forEach(o=>{
228+
229+
o.index += i1+6
230+
o.line += line;
231+
232+
});
233+
list.fn.push(...arr);
234+
235+
}//while
194236

195-
}//parse
237+
}//html
196238

197239

198240
parse.fn = function(txt){
@@ -234,8 +276,7 @@
234276

235277
var args = parse.fn.args(txt,i1);
236278

237-
var line = lineno(txt,i1);
238-
return {line,name,args};
279+
return {index:i1,name,args};
239280

240281
}//type1
241282

@@ -267,8 +308,7 @@
267308

268309
var args = parse.fn.args(txt,i1);
269310

270-
var line = lineno(txt,i1);
271-
return {line,name,args};
311+
return {index:i1,name,args};
272312

273313
}//type2
274314

0 commit comments

Comments
 (0)