Skip to content

Commit

Permalink
Updated TimerTable
Browse files Browse the repository at this point in the history
  • Loading branch information
programarivm committed Mar 14, 2024
1 parent 28e68ed commit c784874
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions examples/timer-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ <h5>Timer</h5>
<div id="chessboard"></div>
</div>
<div class="col-md-6">
<table id="timerTable" class="table table-hover">
<tbody></tbody>
<table id="timerTable" class="table">
<tbody class="h4"></tbody>
</table>
</div>
</div>
Expand Down
6 changes: 2 additions & 4 deletions examples/timer-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ const timerTable = new TimerTable(
document.querySelector('#timerTable tbody'),
{
turn: 'w',
timer: {
w: 300,
b: 300
}
w: 300,
b: 300
}
);

Expand Down
14 changes: 7 additions & 7 deletions src/TimerTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ export class TimerTable extends AbstractComponent {

count() {
if (this.props.turn === Pgn.symbol.WHITE) {
if (this.props.timer.w > 0) {
this.props.timer.w -= 1;
if (this.props.w > 0) {
this.props.w -= 1;
}
} else {
if (this.props.timer.b > 0) {
this.props.timer.b -= 1;
if (this.props.b > 0) {
this.props.b -= 1;
}
}

Expand All @@ -31,15 +31,15 @@ export class TimerTable extends AbstractComponent {
this._el.replaceChildren();
const tr = document.createElement('tr');
const wTd = document.createElement('td');
const wText = document.createTextNode(this._convert(this.props.timer.w));
const wText = document.createTextNode(this._convert(this.props.w));
const bTd = document.createElement('td');
const bText = document.createTextNode(this._convert(this.props.timer.b));
const bText = document.createTextNode(this._convert(this.props.b));
wTd.classList.add('text-end');
wTd.appendChild(wText);
bTd.appendChild(bText);
tr.appendChild(wTd);
tr.appendChild(bTd);

this._el.appendChild(tr);
}
}

0 comments on commit c784874

Please sign in to comment.