• exec/load/table.js

    From echicken@VERT to CVS commit on Thursday, September 27, 2018 19:43:00
    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]]])



    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From echicken@VERT to CVS commit on Thursday, September 27, 2018 20:07:00
    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.



    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From echicken@VERT to CVS commit on Thursday, September 27, 2018 20:15:00
    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.



    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Kirkman@VERT/GUARDIAN to echicken on Thursday, October 04, 2018 02:56:00
    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
  • From echicken@VERT/ECBBS to Kirkman on Thursday, October 04, 2018 05:49:00
    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
  • From Kirkman@VERT/GUARDIAN to echicken on Friday, October 05, 2018 01:41:00
    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
  • From echicken@VERT/ECBBS to Kirkman on Friday, October 05, 2018 04:55:00
    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
  • From Digital Man@VERT to echicken on Friday, October 05, 2018 02:56:00
    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.8F, 79.0% humidity, 5 mph ENE wind, 0.14 inches rain/24hrs

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From echicken@VERT/ECBBS to Digital Man on Friday, October 05, 2018 06:41:00
    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
  • From Digital Man@VERT to echicken on Friday, October 05, 2018 06:13:00
    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.0F, 89.0% humidity, 1 mph ESE wind, 0.14 inches rain/24hrs

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From Kirkman@VERT/GUARDIAN to echicken on Friday, October 05, 2018 16:13:00
    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
  • From echicken@VERT to CVS commit on Saturday, October 06, 2018 03:41:00
    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.



    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net