From a460a0264a949ae771d740aee29f9734a0f70f9a Mon Sep 17 00:00:00 2001 From: Trey Smith Date: Wed, 17 Oct 2012 13:17:06 -0700 Subject: [PATCH] undo.js: check whether state changed before pushing onto undo stack --- geocamTiePoint/static/geocamTiePoint/js/undo.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/geocamTiePoint/static/geocamTiePoint/js/undo.js b/geocamTiePoint/static/geocamTiePoint/js/undo.js index e91318f..84c8a8a 100644 --- a/geocamTiePoint/static/geocamTiePoint/js/undo.js +++ b/geocamTiePoint/static/geocamTiePoint/js/undo.js @@ -33,7 +33,19 @@ function setStateJson(stateJson) { } function pushState(stack) { - stack.push(getStateJson()); + var json = getStateJson(); + + var isNew; + if (undoStackG.length < 1) { + isNew = true; + } else { + var prev = undoStackG[undoStackG.length - 1]; + isNew = (prev != json); + } + if (isNew) { + stack.push(json); + } + return isNew; } function popState(stack) { @@ -58,6 +70,5 @@ function actionPerformed() { undoStackG.push(redoStackG.pop()); } } - pushState(undoStackG); + return pushState(undoStackG); } -