Add undo/redo all buttons for fast history traversal
This commit is contained in:
parent
5c49337357
commit
7f2a0cd884
26
takhta.html
26
takhta.html
|
@ -211,11 +211,19 @@
|
||||||
<input type="button" value="Redo" onclick="redoMove()">
|
<input type="button" value="Redo" onclick="redoMove()">
|
||||||
<input type="button" value="Flip board" onclick="flipBoard()">
|
<input type="button" value="Flip board" onclick="flipBoard()">
|
||||||
</form>
|
</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="button" value="Download moves" onclick="download()">
|
||||||
<input type="file" id="moveupload" name="moveupload">
|
<input type="file" id="moveupload" name="moveupload">
|
||||||
<button type="button"><label for="moveupload">Upload moves</label></button>
|
<button type="button"><label for="moveupload">Upload moves</label></button>
|
||||||
</form></p>
|
</form>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<form id="options">
|
<form id="options">
|
||||||
|
@ -650,6 +658,20 @@
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function undoAll() {
|
||||||
|
while (moveHistory.length > 0) {
|
||||||
|
undoMove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function redoAll() {
|
||||||
|
while (moveFuture.length > 0) {
|
||||||
|
if (!redoMove()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function flipBoard() {
|
function flipBoard() {
|
||||||
let oldBoard = document.getElementById('board').firstElementChild;
|
let oldBoard = document.getElementById('board').firstElementChild;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue