preview.js
// setup box for the board (l, t), highlighting jumps if needed
setup box for the board (l, t), highlighting jumps if needed
setup box for the board ( l t ) highlighting jumps if needed
update(l_curr, t_curr) {
    let l = shift_timeline(l_curr, this.dl, Board.game);
    let t = t_curr + this.dt;
    let board = t >= 0 ? Board.game.get_board(l, t) : null;
    let is_center = (this.dl == 0) && (this.dt == 0);
    if (!board) {
      this.box.border.type = 'bg';
      this.box.style.bg = is_center ? SELECTION_HILITE : "black";
      this.box.style.border.bg = is_center ? SELECTION_HILITE : "black";
      this.box.setContent(this.draw_content(l, t));
    } else {
      let is_jump = false;
      if (t >= 0) {
        let tl = Board.game.get_timeline(l_curr);
        if (tl) {
          let move = tl.moves[t_curr - tl.begins_at - (tl.synthetic ? 0 : 1)];
          if (move) {
            let jump_l, jump_t;
            if (move.kind === MOVE_KIND.JUMP_OUT) {
              let turn_correction = t_curr % 2 ? 1 : (move.to[0] == l_curr ? 0 : 2);
              [jump_l, jump_t] = [move.to[0], 2 * move.to[1] + turn_correction];
            } else if (move.kind === MOVE_KIND.JUMP_IN) {
              let turn_correction = t_curr % 2 ? 1 : (move.from[0] == l_curr ? 0 : 2);
              [jump_l, jump_t] = [move.from[0], 2 * move.from[1] + turn_correction];
            }
            is_jump = (jump_l == l) && (jump_t == t);
          }
        }
      }
      this.box.style.border.fg = t % 2 ? "gray" : "white";
      this.box.style.bg = is_center ? SELECTION_HILITE : (is_jump ? JUMP_HILITE : "black");
      this.box.style.border.bg = is_center ? SELECTION_HILITE : (is_jump ? JUMP_HILITE : "black");
      this.box.border.type = 'line';
      this.box.setContent(this.draw_content(l, t, board));
    }
  }
update ( l_curr , t_curr ) { let l = shift_timeline ( l_curr , this . dl , Board . game ) ; let t = t_curr + this . dt ; let board = t >= 0 ? Board . game . get_board ( l , t ) : null ; let is_center = ( this . dl == 0 ) && ( this . dt == 0 ) ; if ( ! board ) { this . box . border . type = 'bg' ; this . box . style . bg = is_center ? SELECTION_HILITE : "black" ; this . box . style . border . bg = is_center ? SELECTION_HILITE : "black" ; this . box . setContent ( this . draw_content ( l , t ) ) ; } else { let is_jump = false ; if ( t >= 0 ) { let tl = Board . game . get_timeline ( l_curr ) ; if ( tl ) { let move = tl . moves [ t_curr - tl . begins_at - ( tl . synthetic ? 0 : 1 ) ] ; if ( move ) { let jump_l , jump_t ; if ( move . kind === MOVE_KIND . JUMP_OUT ) { let turn_correction = t_curr % 2 ? 1 : ( move . to [ 0 ] == l_curr ? 0 : 2 ) ; [ jump_l , jump_t ] = [ move . to [ 0 ] , 2 * move . to [ 1 ] + turn_correction ] ; } else if ( move . kind === MOVE_KIND . JUMP_IN ) { let turn_correction = t_curr % 2 ? 1 : ( move . from [ 0 ] == l_curr ? 0 : 2 ) ; [ jump_l , jump_t ] = [ move . from [ 0 ] , 2 * move . from [ 1 ] + turn_correction ] ; } is_jump = ( jump_l == l ) && ( jump_t == t ) ; } } } this . box . style . border . fg = t % 2 ? "gray" : "white" ; this . box . style . bg = is_center ? SELECTION_HILITE : ( is_jump ? JUMP_HILITE : "black" ) ; this . box . style . border . bg = is_center ? SELECTION_HILITE : ( is_jump ? JUMP_HILITE : "black" ) ; this . box . border . type = 'line' ; this . box . setContent ( this . draw_content ( l , t , board ) ) ; } }
setup box for the board (l, t), highlighting jumps if needed
setup box for the board ( l t ) highlighting jumps if needed
// if the move for the current board (l_curr, t_curr) is a jump, // highlight the board we're jumping from/to