These are chat archives for jdubray/sam

10th
Jun 2018
Jean-Jacques Dubray
@jdubray
Jun 10 2018 03:31

@zevenbergm I guess it would be similar, each cell would be tagged with a computed id:

function props(ids) {
    return ids.map( id => id.indexOf('table') < 0 ? 
              `'${id}' : document.getElementById('${id}').value`
            :  `'${id}': getArray('$(id)')
        ).join(', ')
}

where:

getArray( tableName ) {
     let table = document.getElementById(tableName);
     let arr = []
     for (let i = 0, row; row = table.rows[i]; i++) {
         let tableRow = []
         for (let j = 0, col; col = row.cells[j]; j++) {
            tableRow.push(col)
         }
         arr.push(tableRow)  
     }
     return arr
}