code: function scanTable($table) {
          var m = [];
          var tableWidth = 0;
          var tableHeight = 0;
          $table.children('thead,tbody,tfoot').children('tr').each(function (y, row) {
              $(row).children('td,th').each(function (x, cell) {
                  var $cell = $(cell),
                      cspan = $cell.attr('colspan') | 0,
                      rspan = $cell.attr('rowspan') | 0,
                      tx, ty;
                  cspan = cspan ? cspan : 1;
                  rspan = rspan ? rspan : 1;
                  for (; m[y] && m[y][x]; ++x);  //skip already occupied cells in current row
                  for (tx = x; tx < x + cspan; ++tx) {  //mark matrix elements occupied by current cell with true
                      for (ty = y; ty < y + rspan; ++ty) {
                          if (!m[ty]) {  //fill missing rows
                              m[ty] = [];
                          }
                          m[ty][tx] = true;
                      }
                  }
                  var pos = {top: y, left: x, bottom: y + rspan - 1, right: x + cspan - 1};
                  $cell.data('cellPos', pos);
                  tableWidth = Math.max(tableWidth, pos.right);
                  tableHeight = Math.max(tableHeight, pos.bottom);
                  // $cell.text(x + ', ' + y + ' | ' + pos.right + ',' + pos.bottom);
              });
          });
          $table.data('tableSize', {width: tableWidth + 1, height: tableHeight + 1});
      }
docs: /* scan individual table and set "cellPos" data in the form { left: x-coord, top: y-coord }