From 498636a7c6aed2cb77cd35acf36905c2439b398b Mon Sep 17 00:00:00 2001 From: sbosse Date: Mon, 21 Jul 2025 23:14:57 +0200 Subject: [PATCH] Mon 21 Jul 22:43:21 CEST 2025 --- js/doc/list.js | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 js/doc/list.js 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