Skip to content

Commit

Permalink
undo.js: check whether state changed before pushing onto undo stack
Browse files Browse the repository at this point in the history
  • Loading branch information
trey0 committed Oct 17, 2012
1 parent 748394c commit a460a02
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions geocamTiePoint/static/geocamTiePoint/js/undo.js
Expand Up @@ -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) {
Expand All @@ -58,6 +70,5 @@ function actionPerformed() {
undoStackG.push(redoStackG.pop());
}
}
pushState(undoStackG);
return pushState(undoStackG);
}

0 comments on commit a460a02

Please sign in to comment.