|
100 | 100 |
|
101 | 101 |
|
102 | 102 |
|
| 103 | + |
103 | 104 | var btn = {}; |
104 | 105 | var sort = {}; |
105 | 106 | sort.alpha = {}; |
|
160 | 161 |
|
161 | 162 | function update(){ //d |
162 | 163 | //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); |
165 | 168 | console.log(list); |
166 | 169 | view.replaceChildren(); |
167 | 170 |
|
|
186 | 189 |
|
187 | 190 |
|
188 | 191 |
|
189 | | - function parse(txt){ |
| 192 | + var parse = {}; |
| 193 | + |
| 194 | + |
| 195 | + parse.javascript = function(txt){ |
190 | 196 |
|
191 | 197 | list = {}; |
| 198 | + |
192 | 199 | list.fn = parse.fn(txt); |
| 200 | + list.fn.forEach(o=>o.line=lineno(txt,o.index)); |
| 201 | + |
193 | 202 | 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 |
194 | 236 |
|
195 | | - }//parse |
| 237 | + }//html |
196 | 238 |
|
197 | 239 |
|
198 | 240 | parse.fn = function(txt){ |
|
234 | 276 |
|
235 | 277 | var args = parse.fn.args(txt,i1); |
236 | 278 |
|
237 | | - var line = lineno(txt,i1); |
238 | | - return {line,name,args}; |
| 279 | + return {index:i1,name,args}; |
239 | 280 |
|
240 | 281 | }//type1 |
241 | 282 |
|
|
267 | 308 |
|
268 | 309 | var args = parse.fn.args(txt,i1); |
269 | 310 |
|
270 | | - var line = lineno(txt,i1); |
271 | | - return {line,name,args}; |
| 311 | + return {index:i1,name,args}; |
272 | 312 |
|
273 | 313 | }//type2 |
274 | 314 |
|
|
0 commit comments