Add undo/redo all buttons for fast history traversal

This commit is contained in:
Juhani Krekelä 2021-01-11 01:11:38 +02:00
parent 5c49337357
commit 7f2a0cd884
1 changed files with 24 additions and 2 deletions

View File

@ -211,11 +211,19 @@
<input type="button" value="Redo" onclick="redoMove()">
<input type="button" value="Flip board" onclick="flipBoard()">
</form>
<p><form id="shipping">
</p>
<p>
<form id="rewind">
<input type="button" value="Undo all" onclick="undoAll()">
<input type="button" value="Redo all" onclick="redoAll()">
</form>
</p>
<p>
<form id="shipping">
<input type="button" value="Download moves" onclick="download()">
<input type="file" id="moveupload" name="moveupload">
<button type="button"><label for="moveupload">Upload moves</label></button>
</form></p>
</form>
</p>
<p>
<form id="options">
@ -650,6 +658,20 @@
return true;
}
function undoAll() {
while (moveHistory.length > 0) {
undoMove();
}
}
function redoAll() {
while (moveFuture.length > 0) {
if (!redoMove()) {
break;
}
}
}
function flipBoard() {
let oldBoard = document.getElementById('board').firstElementChild;