/ Published in: JavaScript
URL: http://homepage.mac.com/dr_turgeon/sources/Branch.js
Expand |
Embed | Plain Text
/*---------------------------------------------------------------------------*/ /* expandable generic node object */ function Branch(N){var T=this;T.P='[object Tree]';T.N=T.I=T.P;if(N){T.N=N;T.I='window["'+T.N+'"]'}}; Branch.prototype.grow=function(N){ if(!N)return;var T=this;var Tt=T[N]=new Branch(); Tt.N=N; Tt.I=''+T.I+'["'+N+'"]'; Tt.P=T}; Branch.prototype.toString=function(){return this.I}; function /* a convenient preparation of a branch */ Tree(str){return window[str]=new Branch(str)} /*---------------------------------------------------------------------------*/ /* test msg */ var t1 = Tree('t1'); t1.grow('b1'); t1.b1.grow('l1'); log = trite(['N' ,'I' ,'P' ])+ trite([ t1.N , t1.I , t1.P ])+ trite([ t1.b1.N , t1.b1.I , t1.b1.P ])+ trite([ t1.b1.l1.N , t1.b1.l1.I , t1.b1.l1.P ]); log = '<table>'+ log +'</table>'; /*---------------------------------------------------------------------------*/
You need to login to post a comment.
