Skip to content
This repository has been archived by the owner on Jan 4, 2021. It is now read-only.

Commit

Permalink
v1.0.7 Undo/redo and error mgmt improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Francois-Xavier Gentilhomme committed May 13, 2015
1 parent 7b44629 commit 1a9cc59
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 20 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "myscript",
"version": "1.0.6",
"version": "1.0.7",
"main": "./dist/myscript.js",
"description": "MyScriptJS is a free and open-source JavaScript library providing the easiest way to use MyScript Cloud handwriting recognition in your web app",
"keywords": [
Expand Down
11 changes: 6 additions & 5 deletions dist/myscript.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/myscript.js.map

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions dist/myscript.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/myscript.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "myscript",
"version": "1.0.6",
"version": "1.0.7",
"main": "./dist/myscript.js",
"description": "MyScriptJS is a free and open-source JavaScript library providing the easiest way to use MyScript Cloud handwriting recognition in your web app",
"keywords": [
Expand Down
3 changes: 3 additions & 0 deletions src/common/inkManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
*/
InkManager.prototype.startInkCapture = function (x, y, t) {
if (!this.writing) {
if (this.isRedoEmpty()) {
this.clearUndoRedoStack();
}
this.currentStroke = new scope.Stroke();
this.currentStroke.addX(x);
this.currentStroke.addY(y);
Expand Down
6 changes: 2 additions & 4 deletions src/networking/networkInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@
if (request.readyState === 4) {
if (request.status >= 200 && request.status < 300) {
deferred.resolve(NetworkInterface.parse(request));
} else {
deferred.reject(NetworkInterface.parse(request));
}
}
}
Expand All @@ -72,12 +70,12 @@
if (request.status >= 200 && request.status < 300) {
deferred.resolve(NetworkInterface.parse(request));
} else {
deferred.reject('Status code was ' + request.status);
deferred.reject(new Error(request.responseText));
}
}

function onError() {
deferred.reject('Can\'t XHR ' + JSON.stringify(url));
deferred.reject(new Error('Can\'t XHR ' + url));
}

function onProgress(event) {
Expand Down
12 changes: 12 additions & 0 deletions test/unit/common/inkManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@ describe('MyScriptJS: common/inkManager.js', function () {
expect(inkManager.getUndoRedoStack()[inkManager.getUndoRedoStack().length - 1]).to.deep.equal(stroke);
});

it('Test undo/redo stack', function () {
inkManager.redo();

inkManager.startInkCapture(50, 2);
inkManager.continueInkCapture(60, 8);
inkManager.endInkCapture();

expect(inkManager.getStrokes().length).to.equal(2);
expect(inkManager.getUndoRedoStack().length).to.equal(0);
});

it('InkManager clear Undo/redo Stack', function () {
inkManager.clearUndoRedoStack();

Expand All @@ -153,6 +164,7 @@ describe('MyScriptJS: common/inkManager.js', function () {
});

it('InkManager copy', function () {
inkManager.clear();
var copyStrokes = [];
// add one stroke
inkManager.startInkCapture(50, 2);
Expand Down

0 comments on commit 1a9cc59

Please sign in to comment.