summaryrefslogtreecommitdiff
path: root/javascripts/uifunc.js
diff options
context:
space:
mode:
Diffstat (limited to 'javascripts/uifunc.js')
-rw-r--r--javascripts/uifunc.js56
1 files changed, 43 insertions, 13 deletions
diff --git a/javascripts/uifunc.js b/javascripts/uifunc.js
index 007305a..fd608f5 100644
--- a/javascripts/uifunc.js
+++ b/javascripts/uifunc.js
@@ -1,4 +1,4 @@
-//
+// enable/disable if input length is > 0
function checkLength(el, bId) {
if(el.value.length > 0) {
enable(bId);
@@ -7,17 +7,12 @@ function checkLength(el, bId) {
};
};
-//
-function enable(id) {
- $(id).removeAttr("disabled");
-};
-
-//
-function disable(id) {
- $(id).attr("disabled","disabled");
-};
+// enable a disabled form item
+function enable(id) { $(id).removeAttr("disabled"); };
+// disable a form item
+function disable(id) { $(id).attr("disabled","disabled"); };
-//
+// call of RegexParser.parse() from UI
function uiParse() {
var parser = new RegexParser();
nfa = parser.parse($('#regex').attr('value'));
@@ -34,14 +29,35 @@ function uiParse() {
enable('#word');
var dfa = new Nfa2Dfa(nfa);
var ttable = dfa.do();
- graph();
+ window.g = graph();
disable('#regex');
disable('#parseButton');
};
$('#parseMessage').effect("highlight", {}, 1000);
+
+ s = 'abc';
+ /*g.mover = g.paper.circle(
+ g.nodes[0][1][0].cx.baseVal.value,
+ g.nodes[0][1][0].cy.baseVal.value, 30
+ ).attr({fill:'#00f', stroke: 'none', opacity: 0.5});
+ for (var i=0; i < s.length; i++) {
+ (function(g, i) {
+ setTimeout(function() {
+ var state = g.nodes[i];
+ var x = state[1][0].cx.baseVal.value;
+ var y = state[1][0].cy.baseVal.value;
+ g.mover.animateAlong(
+ g.paper.path(
+ 'M'+x+state[1][0].r.baseVal.value+','+y+' '+g.connections[i].line.attr('path').toString().substring(1)
+ +'L'+(g.nodes[i+1][1][0].cx.baseVal.value+(i*2))+','+g.nodes[i+1][1][0].cy.baseVal.value
+ ).attr({stroke:'none', 'stroke-width':4})
+ , 2000)
+ }, 2000*i);
+ })(g, i);
+ };*/
};
-//
+// call of NfaSimulator.simulate() from UI
function uiSimulate() {
var simulator = new NfaSimulator(nfa);
var check = simulator.simulate($('#word').attr('value'));
@@ -60,3 +76,17 @@ function uiSimulate() {
};
$('#checkMessage').effect("highlight", {}, 1000);
};
+
+
+function getKey(e, set) {
+ var key = String.fromCharCode(e.which);
+ if (set.indexOf(key) >= 0 || e.which == 8) {
+ return true;
+ }
+ return false;
+};
+
+//
+function graphMove(symbol) {
+ true;
+};