function initSvgGrid() {
  var grid = document.getElementById('grid');
  if (!grid) throw Error('No grid SVG element found.');
  // <line class="grid" x1="19" y1="20" x2="21" y2="20"/>
  // <line class="grid" x1="20" y1="19" x2="20" y2="21"/>
  var LEN = 2;
  for (var x = 0; x <= COLUMNS; x++) {
    var matrixX = BORDER_WIDTH + x * SQUARE_SIZE;
    for (var y = 0; y <= ROWS; y++) {
      var matrixY = TOP_ROW_HEIGHT + y * SQUARE_SIZE;
      var line = document.createElementNS(SVG_NS, 'line');
      line.setAttribute('x1', matrixX - LEN);
      line.setAttribute('y1', matrixY);
      line.setAttribute('x2', matrixX + LEN);
      line.setAttribute('y2', matrixY);
      line.classList.add('grid');
      grid.appendChild(line);
      line = document.createElementNS(SVG_NS, 'line');
      line.setAttribute('x1', matrixX);
      line.setAttribute('y1', matrixY - LEN);
      line.setAttribute('x2', matrixX);
      line.setAttribute('y2', matrixY + LEN);
      line.classList.add('grid');
      grid.appendChild(line);
    }
  }
}
// Draw the grid markers on the board.
Draw the grid markers on the board.
Draw the grid markers on the board .
function initSvgGrid() {
  var grid = document.getElementById('grid');
  if (!grid) throw Error('No grid SVG element found.');
  var LEN = 2;
  for (var x = 0; x <= COLUMNS; x++) {
    var matrixX = BORDER_WIDTH + x * SQUARE_SIZE;
    for (var y = 0; y <= ROWS; y++) {
      var matrixY = TOP_ROW_HEIGHT + y * SQUARE_SIZE;
      var line = document.createElementNS(SVG_NS, 'line');
      line.setAttribute('x1', matrixX - LEN);
      line.setAttribute('y1', matrixY);
      line.setAttribute('x2', matrixX + LEN);
      line.setAttribute('y2', matrixY);
      line.classList.add('grid');
      grid.appendChild(line);
      line = document.createElementNS(SVG_NS, 'line');
      line.setAttribute('x1', matrixX);
      line.setAttribute('y1', matrixY - LEN);
      line.setAttribute('x2', matrixX);
      line.setAttribute('y2', matrixY + LEN);
      line.classList.add('grid');
      grid.appendChild(line);
    }
  }
}
function initSvgGrid ( ) { var grid = document . getElementById ( 'grid' ) ; if ( ! grid ) throw Error ( 'No grid SVG element found.' ) ; var LEN = 2 ; for ( var x = 0 ; x <= COLUMNS ; x ++ ) { var matrixX = BORDER_WIDTH + x * SQUARE_SIZE ; for ( var y = 0 ; y <= ROWS ; y ++ ) { var matrixY = TOP_ROW_HEIGHT + y * SQUARE_SIZE ; var line = document . createElementNS ( SVG_NS , 'line' ) ; line . setAttribute ( 'x1' , matrixX - LEN ) ; line . setAttribute ( 'y1' , matrixY ) ; line . setAttribute ( 'x2' , matrixX + LEN ) ; line . setAttribute ( 'y2' , matrixY ) ; line . classList . add ( 'grid' ) ; grid . appendChild ( line ) ; line = document . createElementNS ( SVG_NS , 'line' ) ; line . setAttribute ( 'x1' , matrixX ) ; line . setAttribute ( 'y1' , matrixY - LEN ) ; line . setAttribute ( 'x2' , matrixX ) ; line . setAttribute ( 'y2' , matrixY + LEN ) ; line . classList . add ( 'grid' ) ; grid . appendChild ( line ) ; } } }
Draw the grid markers on the board.
Draw the grid markers on the board .
// <line class="grid" x1="19" y1="20" x2="21" y2="20"/> // <line class="grid" x1="20" y1="19" x2="20" y2="21"/>