diff --git a/js/doc/list.js b/js/doc/list.js new file mode 100644 index 0000000..48c9b8d --- /dev/null +++ b/js/doc/list.js @@ -0,0 +1,76 @@ +var NL='\n',SP=' '; +function spaces(n) {var s=''; while(n) s+=SP,n--; return s;} + +/** List Constructor + * typeof @options = { + * type:string=' '|'*'|'-'|'+'|'1'|'2'|..|'a'|'b'|..|'dl', + * } + */ +function List (options) { + this.type = options.type|| '*'; + this.margin = options.margin || {left:0,right:0,top:0,bottom:0}; + this.width = options.width || 80; + this.tab = options.tab || 2; + this.tab2 = options.tab || 4; +} +/** + * Inherit from Array. Each item of the list is one array element. + */ + +List.prototype.__proto__ = Array.prototype; + +/** List formatter + * + */ +List.prototype.render +List.prototype.toString = function (){ + var i,self=this,ret='',line='',lines=[],label, + tokens, + textwidth=this.width-this.margin.left-this.margin.right-this.tab; + for(i=0;i