Page 2 of 2

Re: Request for a feature

Posted: Thu Mar 16, 2017 7:46 pm
by chessnagar
>>> It's not as straight forward with random puzzles since you can't just do +1 and -1 for going to next and previous.
Actually, it is not complicated as we think.

In the old dhtml chess, I added that functionality to my site using an additional variable. right after solving the puzzle, we have to store the game index value in this variable so that it will be available after the next game is loaded. So after the next game loaded, if the user clicks "Prev", then we can pass this index value to load the previous game.

Limitation is that it will only load one previous game and at the beginning you can't go back to previous game (as there is none). But it should be fine as most of the times user want to review the previous tactic as it was amazing or surprising or unbelievable.

Some sample code from previous version:
var gameIndexCache; //defined globally
function switchGame()
{
document.getElementById('hintInner').innerHTML='Well done - problem solved.';
if(slideShowStarted){
setTimeout('displayLoadMessage()',1000);
setTimeout("chessObj.showRandomGame()",2500); // Wait two seconds before displaying next game
}else{
chessObj.showRandomGame(); // Show it immidieately if it's the first game
slideShowStarted=true;
}
gameIndexCache = chessObj.getCurrentGameIndex(); ///ADDED THIS
}
function loadRandomGame()
{
chessObj.showRandomGame(); // Show it immidieately if it's the first game
gameIndexCache = chessObj.getCurrentGameIndex(); ///////ADDED THIS
}

<input type="button" value="< Prev" onclick="chessObj.showGame(gameIndexCache);return false">

Re: Request for a feature

Posted: Thu Mar 16, 2017 9:02 pm
by alf
You're right, it might be sufficient to just go back one game. I will take care of that one tomorrow. A commaseparated string of id's might also work.

Re: Request for a feature

Posted: Fri Mar 17, 2017 5:55 pm
by alf
The problem with previous and next puzzle when random is on has been solved in the latest version:

version 1.0.51.