• exec/load/table.js

    From echicken@1:103/705 to CVS commit on Thu Sep 27 12:43:31 2018
    exec/load table.js NONE 1.1
    Update of /cvsroot/sbbs/exec/load
    In directory cvs:/tmp/cvs-serv1930

    Added Files:
    table.js
    Log Message:
    Turn an array of arrays of strings into a table for textmode display.
    Scales to terminal width and wraps cell contents.
    Uses DokuWiki-style ':::' row-span and empty-cell col-span, but is
    otherwise separate from wiki syntax, so committing as its own thing. table(data[, line_color[, heading_color[, cell_color[, width]]])


    --- SBBSecho 3.06-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From echicken@1:103/705 to CVS commit on Thu Sep 27 13:07:05 2018
    exec/load table.js 1.1 1.2
    Update of /cvsroot/sbbs/exec/load
    In directory cvs:/tmp/cvs-serv4848

    Modified Files:
    table.js
    Log Message:
    Remove whitespace.


    --- SBBSecho 3.06-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From echicken@1:103/705 to CVS commit on Thu Sep 27 13:15:03 2018
    exec/load table.js 1.2 1.3
    Update of /cvsroot/sbbs/exec/load
    In directory cvs:/tmp/cvs-serv5847

    Modified Files:
    table.js
    Log Message:
    Don't mangle table data, just strip whitespace prior to display.


    --- SBBSecho 3.06-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Kirkman@1:103/705 to echicken on Wed Oct 3 19:56:06 2018
    Re: exec/load/table.js
    By: echicken to CVS commit on Thu Sep 27 2018 12:43 pm

    Log Message:
    Turn an array of arrays of strings into a table for textmode display. Scales to terminal width and wraps cell contents.
    Uses DokuWiki-style ':::' row-span and empty-cell col-span, but is otherwise separate from wiki syntax, so committing as its own thing. table(data[, line_color[, heading_color[, cell_color[, width]]])

    Interesting... Can't wait to check that out! Sounds like something I might want to switch to in my Sports Stats code.

    --Josh

    ////--------------------------------------------------
    BiC -=- http://breakintochat.com -=- bbs wiki and blog

    ---
    ■ Synchronet
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From echicken@1:103/705 to Kirkman on Wed Oct 3 22:49:04 2018
    Re: exec/load/table.js
    By: Kirkman to echicken on Wed Oct 03 2018 19:56:06

    Interesting... Can't wait to check that out! Sounds like something I might want to switch to in my Sports Stats code.

    Pretty simple to use:

    load('table.js');
    var data = [['the','heading','row'],['the','next','row']]; // and so on
    // data, line colour, heading colour, cell colour, width
    var t = table(data, '\1h\1c', '\1h\1w', '\1n\1w', 79);
    console.putmsg(t);

    All arguments except 'data' are optional.

    You can do column-spanning cells by leaving the next cell to the right empty:

    var data = [['a cell','a colspan cell','']];

    Or row-spanning cells with ':::' in the cells to span:

    var data = [['this cell spans three rows'],[':::'],[':::']];

    And combinations of the above. Cell content wrapping for column spanning cells is still a to-do item. Wrapping within normal cells works.

    wiki-markup.js is worth taking a peek at as well, since table.js was created in support of it. Handles most of the DokuWiki markup syntax, and renders to HTML, console, or Frame. May be useful at some point. (Use the same routine in a script to generate markup whether for the console or for the web, then just render it for the appropriate view.)

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com - 416-273-7230
    ■ Synchronet ■ electronic chicken bbs - bbs.electronicchicken.com
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Kirkman@1:103/705 to echicken on Thu Oct 4 18:41:53 2018
    Re: exec/load/table.js
    By: echicken to Kirkman on Wed Oct 03 2018 10:49 pm

    load('table.js');
    var data = [['the','heading','row'],['the','next','row']]; // and so on
    // data, line colour, heading colour, cell colour, width
    var t = table(data, '\1h\1c', '\1h\1w', '\1n\1w', 79);
    console.putmsg(t);

    Can you specify cell size/width (so that, for example, box scores are all formatted the same when stacked over each other)?

    --Josh

    ////--------------------------------------------------
    BiC -=- http://breakintochat.com -=- bbs wiki and blog

    ---
    ■ Synchronet
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From echicken@1:103/705 to Kirkman on Thu Oct 4 21:55:33 2018
    Re: exec/load/table.js
    By: Kirkman to echicken on Thu Oct 04 2018 18:41:53

    Can you specify cell size/width (so that, for example, box scores are all formatted the same when stacked over each other)?

    There isn't a good way to force a table or column width right now. This was made to automatically size to the terminal width. Cells in the same column in
    a table are the same width of course, but separate tables with different contents may be different sizes.

    It strips trailing whitespace off of cell contents. I might be able to change that, and then padding out cell contents with spaces might be one way to force a column width. Right now all you could do is front-pad with spaces, or pad one side or the other with some printable character (periods maybe).

    Word wrapping within cells complicates this somewhat. If your cell contents overflow the maximum possible cell width, they will be wrapped. Whitespace would not be any help there.

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com - 416-273-7230
    ■ Synchronet ■ electronic chicken bbs - bbs.electronicchicken.com
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Digital Man@1:103/705 to echicken on Thu Oct 4 19:56:36 2018
    Re: exec/load/table.js
    By: echicken to Kirkman on Thu Oct 04 2018 09:55 pm

    Re: exec/load/table.js
    By: Kirkman to echicken on Thu Oct 04 2018 18:41:53

    Can you specify cell size/width (so that, for example, box scores are all formatted the same when stacked over each other)?

    There isn't a good way to force a table or column width right now. This was made to automatically size to the terminal width. Cells in the same column in
    a table are the same width of course, but separate tables with different contents may be different sizes.

    It strips trailing whitespace off of cell contents. I might be able to change that, and then padding out cell contents with spaces might be one way to force a column width. Right now all you could do is front-pad with spaces, or pad one side or the other with some printable character (periods maybe).

    Does it also do the left/right/center alignment (of table cells) thing that dokuwiki does?

    digital man

    Synchronet/BBS Terminology Definition #14:
    DOCSIS = Data Over Cable Service Interface Specification
    Norco, CA WX: 65.8°F, 79.0% humidity, 5 mph ENE wind, 0.14 inches rain/24hrs --- SBBSecho 3.06-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From echicken@1:103/705 to Digital Man on Thu Oct 4 23:41:25 2018
    Re: exec/load/table.js
    By: Digital Man to echicken on Thu Oct 04 2018 19:56:36

    Does it also do the left/right/center alignment (of table cells) thing that dokuwiki does?

    Not yet; that's something I've been meaning to add.

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com - 416-273-7230
    ■ Synchronet ■ electronic chicken bbs - bbs.electronicchicken.com
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Digital Man@1:103/705 to echicken on Thu Oct 4 23:13:57 2018
    Re: exec/load/table.js
    By: echicken to Digital Man on Thu Oct 04 2018 11:41 pm

    Re: exec/load/table.js
    By: Digital Man to echicken on Thu Oct 04 2018 19:56:36

    Does it also do the left/right/center alignment (of table cells) thing that dokuwiki does?

    Not yet; that's something I've been meaning to add.

    Ah, thanks. It's one of the feature I do use.

    digital man

    Synchronet/BBS Terminology Definition #45:
    SEXPOTS = Synchronet External Plain Old Telephone System (POTS) service
    Norco, CA WX: 62.0°F, 89.0% humidity, 1 mph ESE wind, 0.14 inches rain/24hrs --- SBBSecho 3.06-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Kirkman@1:103/705 to echicken on Fri Oct 5 09:13:43 2018
    Re: exec/load/table.js
    By: echicken to Kirkman on Thu Oct 04 2018 09:55 pm

    Right now all you could do is front-pad with
    spaces, or pad one side or the other with some printable character (periods maybe).

    That's not too different from what I'm doing now. I have to pad each piece of the box score to a certain width. I'll definitely play around with it, sounds like a very useful library.

    The only case where there might be an issue is baseball. Extra-innings games have no limit, so in theory there could be more innings than there is available width to display them. In Sports Stats, I try to make more room when this occurs by removing padding, etc. But still, not much you can do about the rare 20-inning game. I just let it break if it's particularly extreme.

    --Josh

    ////--------------------------------------------------
    BiC -=- http://breakintochat.com -=- bbs wiki and blog

    ---
    ■ Synchronet
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From echicken@1:103/705 to CVS commit on Fri Oct 5 20:41:32 2018
    exec/load table.js 1.3 1.4
    Update of /cvsroot/sbbs/exec/load
    In directory cvs:/tmp/cvs-serv7714

    Modified Files:
    table.js
    Log Message:
    DokuWiki-style right/centre aligns.
    Front-pad cell contents with 2+ spaces for right align.
    Pad each end with 2+ spaces for centre align.
    No attempt has been made to make this play nicely with colspans,
    but it does work with wrapped cells.


    --- SBBSecho 3.06-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)