js/pgnvjs.js
// Should include all variations as well
Should include all variations as well
Should include all variations as well
function existing_move(move, moveNumber) {
            if (moveNumber == null) return existing_first_move(move);
            var prevMove = getMove(moveNumber);
            if (typeof prevMove == "undefined") return null;
            game.load(prevMove.fen);
            var pgn_move = game.move(move);
            var nextMove = getMove(prevMove.next);
            if (typeof nextMove == "undefined") return null;
            if (nextMove.notation.notation == pgn_move.san) {
                return prevMove.next;
            } else { 
                var mainMove = getMove(prevMove.next);
                for (i = 0; i < mainMove.variations.length; i++) {
                    var variation = mainMove.variations[i];
                    if (variation.notation.notation == pgn_move.san) {
                        return variation.index;
                    }
                }
            }
            return null;
        }
function existing_move ( move , moveNumber ) { if ( moveNumber == null ) return existing_first_move ( move ) ; var prevMove = getMove ( moveNumber ) ; if ( typeof prevMove == "undefined" ) return null ; game . load ( prevMove . fen ) ; var pgn_move = game . move ( move ) ; var nextMove = getMove ( prevMove . next ) ; if ( typeof nextMove == "undefined" ) return null ; if ( nextMove . notation . notation == pgn_move . san ) { return prevMove . next ; } else { var mainMove = getMove ( prevMove . next ) ; for ( i = 0 ; i < mainMove . variations . length ; i ++ ) { var variation = mainMove . variations [ i ] ; if ( variation . notation . notation == pgn_move . san ) { return variation . index ; } } } return null ; }
Should include all variations as well
Should include all variations as well
// check if there exists variations