summaryrefslogtreecommitdiff
path: root/javascripts
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2010-06-29 09:11:38 +0200
committerPatrick Simianer <p@simianer.de>2010-06-29 09:11:38 +0200
commit8d67caae222e1652936ecc6cc7a237f67fc320c5 (patch)
treefe6c8e2cde90c441eefeec5eb0f39dc8965a49a2 /javascripts
parent706c599baabf1fbc00fd142195beebe637a1b4af (diff)
presentation done
Diffstat (limited to 'javascripts')
-rw-r--r--javascripts/globals.js2
-rw-r--r--javascripts/graph.js2
-rw-r--r--javascripts/uifunc.js44
3 files changed, 36 insertions, 12 deletions
diff --git a/javascripts/globals.js b/javascripts/globals.js
index 56b31d8..e48018d 100644
--- a/javascripts/globals.js
+++ b/javascripts/globals.js
@@ -9,3 +9,5 @@ var REDELIMITER = '$';
var ttable = new Object();
var g;
var graphit = true;
+var lock = false;
+
diff --git a/javascripts/graph.js b/javascripts/graph.js
index 6b8fbf4..70b67d8 100644
--- a/javascripts/graph.js
+++ b/javascripts/graph.js
@@ -116,7 +116,7 @@ Raphael.fn.aNode = function(x, y, r, isFinal, hasSelfConn,
// arrow head
var ahSize = r/8;
var ahRef = selfConn.getPointAtLength(selfConn.getTotalLength()-1)
- var ahAngle = Math.atan2(ahRef.x-p2.x,p2.x-ahRef.y);
+ var ahAngle = Math.atan2(ahRef.x-p2.x,p2.x-(-ahRef.y));
ahAngle = (ahAngle / (2 * Math.PI)) * 360;
var ah = this.path("M" + ahRef.x + " " + ahRef.y +
" L" + (ahRef.x - ahSize) + " " + (ahRef.y - ahSize) +
diff --git a/javascripts/uifunc.js b/javascripts/uifunc.js
index 99b975d..f14b6b2 100644
--- a/javascripts/uifunc.js
+++ b/javascripts/uifunc.js
@@ -20,7 +20,7 @@ function graph_inprogress() {
$('#word').removeClass('success');
$('#word').removeClass('failure');
$('#word').addClass('inprogress');
- window.g.mover.attr({fill: '#ffff88'});
+ window.g.mover.attr({fill: 'yellow'});//'#ffff88'});
};
function graph_success() {
$('#checkMessage').html('Word accepted');
@@ -30,7 +30,7 @@ function graph_success() {
$('#word').removeClass('inprogress');
$('#word').addClass('success');
$('#checkMessage').effect("highlight", {}, 1000);
- window.g.mover.attr({fill: '#cdeb8b'});
+ window.g.mover.attr({fill: 'green'});//'#cdeb8b'});
};
function graph_failure() {
$('#checkMessage').html('Word not accepted');
@@ -40,7 +40,7 @@ function graph_failure() {
$('#word').removeClass('inprogress');
$('#word').addClass('failure');
$('#checkMessage').effect("highlight", {}, 1000);
- window.g.mover.animate({fill: '#b02b2c'}, 250);
+ window.g.mover.animate({fill: 'red'});//'#b02b2c'}, 250);
};
// Call of RegexParser.parse() from UI.
@@ -108,6 +108,19 @@ function getKey(e, set) {
// Moving inside the graph by input symbols.
// setTimeout ?
function graphMoveByInput(e) {
+ if (lock) {
+ if (failedInputs) {
+ lock = false;
+ } else {
+ //var w = $('#word').attr('value');
+ //$('#word').attr('value', w.substr(0, w.length-1));
+ lock = false;
+ return false;
+ }
+ } else {
+ lock = true;
+ }
+
// no graph
if(!graphit) return;
@@ -138,7 +151,7 @@ function graphMoveByInput(e) {
var mx = g.mover.attr('cx');
var my = g.mover.attr('cy');
var ll = g.paper.path('M'+mx+','+my+' '+mx+','+(my-25)+'Z').attr({stroke: 0});
- g.mover.animateAlong(ll, 250, "bounce");
+ window.setTimeout(function() { g.mover.animateAlong(ll, 250, "bounce"); }, 250);
window.inSameState.pop();
if (ttable[window.gCurrentState.name].isFinal) {
graph_success();
@@ -150,10 +163,10 @@ function graphMoveByInput(e) {
// go back one state
window.gPrevState = gPrevStates.pop();
- g.mover.animate(
- {cx:gPrevState.node[1][0].cx.baseVal.value, cy:gPrevState.node[1][0].cy.baseVal.value},
- 750, "bounce"
- );
+ window.setTimeout(function() {
+ g.mover.animate({cx:gPrevState.node[1][0].cx.baseVal.value, cy:gPrevState.node[1][0].cy.baseVal.value}, 250);
+ lock = false;
+ }, 250);
window.gCurrentState = gPrevState;
if (ttable[window.gCurrentState.name].isFinal) {
graph_success();
@@ -178,8 +191,15 @@ function graphMoveByInput(e) {
// no state change
if(gNextState.name == gCurrentState.name) {
- g.mover.animateAlong(gCurrentState.node[4], 500);
+ window.setTimeout(function() {
+ g.mover.animateAlong(gCurrentState.node[4], 350);lock = false;
+ }, 125);
window.inSameState.push(true);
+ if (ttable[window.gCurrentState.name].isFinal) {
+ graph_success();
+ } else {
+ graph_inprogress();
+ };
return;
} else {
// state change
@@ -198,9 +218,10 @@ function graphMoveByInput(e) {
).attr({stroke:'none'});
(function(g, line) {
setTimeout(function() {
- g.mover.animateAlong(line, 500)
+ g.mover.animateAlong(line, 250);
+ lock = false;
return line;
- }, 1);
+ }, 250);
})(g, line);
};
window.gPrevStates.push(gCurrentState);
@@ -210,3 +231,4 @@ function graphMoveByInput(e) {
graph_success();
};
};
+