From c272506529ea5fde9352a600417b2eaa6a230a6a Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Tue, 17 Aug 2010 15:33:02 +0200 Subject: release --- javascripts/Nfa.js | 3 + javascripts/Nfa2Dfa.js | 4 +- javascripts/NfaSimulator.js | 3 + javascripts/NfaState.js | 3 + javascripts/RegexParser.js | 5 +- javascripts/Stack.js | 3 + javascripts/globals.js | 23 +- javascripts/graph.js | 21 +- javascripts/lib/jquery.bgiframe.js | 104 ++++++++ javascripts/lib/jquery.dimensions.js | 504 +++++++++++++++++++++++++++++++++++ javascripts/lib/jquery.tooltip.js | 294 ++++++++++++++++++++ javascripts/ui.js | 297 +++++++++++++++++++++ javascripts/uifunc.js | 234 ---------------- regexvis.html | 180 ++++++++----- stylesheets/jquery.tooltip.css | 13 + stylesheets/styles.css | 56 ++-- 16 files changed, 1412 insertions(+), 335 deletions(-) create mode 100644 javascripts/lib/jquery.bgiframe.js create mode 100644 javascripts/lib/jquery.dimensions.js create mode 100644 javascripts/lib/jquery.tooltip.js create mode 100644 javascripts/ui.js delete mode 100644 javascripts/uifunc.js create mode 100644 stylesheets/jquery.tooltip.css diff --git a/javascripts/Nfa.js b/javascripts/Nfa.js index a214700..eab1d6c 100644 --- a/javascripts/Nfa.js +++ b/javascripts/Nfa.js @@ -2,6 +2,8 @@ * Nfa * NFA consisting of several NfaStates, following Thompson's algorithm. */ + + function Nfa(symbol) { this.startState = null; this.finalState = null; @@ -60,3 +62,4 @@ Nfa.prototype.kleene = function() { return this; }; + diff --git a/javascripts/Nfa2Dfa.js b/javascripts/Nfa2Dfa.js index f38b2cf..a29683e 100644 --- a/javascripts/Nfa2Dfa.js +++ b/javascripts/Nfa2Dfa.js @@ -3,6 +3,7 @@ * Convert a NFA to a DFA utilizing epsilon closure. */ + // Compare two NfaStates for equality. function StateCmp(a, b) { if (a.id == b.id) { @@ -11,7 +12,7 @@ function StateCmp(a, b) { return false }; -// Compare two stacks filled with NfaStates for euqality. +// Compare two stacks filled with NfaStates for equality. function NfaStackCmp(x, y) { var b = true; if (x.length != y.length) { return false } @@ -114,3 +115,4 @@ Nfa2Dfa.prototype.move = function(str, p) { }; return q; }; + diff --git a/javascripts/NfaSimulator.js b/javascripts/NfaSimulator.js index c5a035f..d8ad9a2 100644 --- a/javascripts/NfaSimulator.js +++ b/javascripts/NfaSimulator.js @@ -2,6 +2,8 @@ * NfaSimulator * Simulate a NFA with a word. Check if regular expression produces word. */ + + function NfaSimulator(nfa) { this.startState = nfa.getStartState(); this.finalState = nfa.getFinalState(); @@ -64,3 +66,4 @@ NfaSimulator.prototype.move = function(symbol) { }; }; }; + diff --git a/javascripts/NfaState.js b/javascripts/NfaState.js index 4291295..3453466 100644 --- a/javascripts/NfaState.js +++ b/javascripts/NfaState.js @@ -2,6 +2,8 @@ * NfaState * Represents a state of a NFA (following Thompson's algorithm). */ + + function NfaState(symbol) { if(!symbol) { this.symbol = EPSILON; @@ -20,3 +22,4 @@ NfaState.prototype.setFollowUp = function(index, state) { if (! ((index == 0) || (index==1)) ) return; this.followUps[index] = state; }; + diff --git a/javascripts/RegexParser.js b/javascripts/RegexParser.js index 42251af..63b8558 100644 --- a/javascripts/RegexParser.js +++ b/javascripts/RegexParser.js @@ -3,6 +3,8 @@ * Parsing a regular expression using recursive descent method. * parse() returns a NFA (constructed following Thompson's algrotihm). */ + + function RegexParser() {}; // Accessor functions @@ -123,4 +125,5 @@ RegexParser.prototype.parse = function(regex) { nfa = null; }; return nfa; -} +}; + diff --git a/javascripts/Stack.js b/javascripts/Stack.js index 4ccd74e..3349ffb 100644 --- a/javascripts/Stack.js +++ b/javascripts/Stack.js @@ -2,6 +2,8 @@ * Stack * Simple implementation of a stack using Array(). */ + + function Stack() { this.a = new Array(); this.length = 0; @@ -53,3 +55,4 @@ Stack.prototype.str = function(separator) { }; return a.join(separator); }; + diff --git a/javascripts/globals.js b/javascripts/globals.js index e48018d..3a5a495 100644 --- a/javascripts/globals.js +++ b/javascripts/globals.js @@ -1,13 +1,16 @@ // globals -var EPSILON = '~'; -var NEXTSTATE = 0; -var EMPTYSYMBOL = '%'; -var ALPHABET = 'abcd'+EMPTYSYMBOL; -var ALPHABETS = ALPHABET+'()|*'; -var REDELIMITER = '$'; +var EPSILON = '~'; // internal use, symbol for 'non-symbol' +var NEXTSTATE = 0; // internal use, state indices, begin at 0 +var STOPSYMBOL = '%'; // internal use, stop symbol +var ALPHABET = 'abcd'+STOPSYMBOL; // used alphabet, need to include stop symbol +var SPECIALS = '()|*'; // symbol with special meaning in a regex +var ALPHABETS = ALPHABET+SPECIALS; // include special symbols +var REDELIMITER = '$'; // internal use, delimiter for regex -var ttable = new Object(); -var g; -var graphit = true; -var lock = false; +var ttable = new Object(); // transition table, internal use +var g; // graph object (used by Raphael) +var graphit = true; // draw a graph? value set by checkbox +var lock = false; // lock for graph animation +var alphabetEdit = false; // are we currently editing the alphabet? +var alphabetEditable = true; // is the alphabet still editable? diff --git a/javascripts/graph.js b/javascripts/graph.js index 70b67d8..17dcaaf 100644 --- a/javascripts/graph.js +++ b/javascripts/graph.js @@ -1,4 +1,4 @@ -// Source: http://raphaeljs.com/graffle.html (extended with labels and arrow heads) +// source: http://raphaeljs.com/graffle.html (extended with labels and arrow heads) Raphael.fn.connection = function (obj1, obj2, line, bg, strokeColor, symbol, labelFontSize, name1, name2) { if (obj1.line && obj1.from && obj1.to) { line = obj1; @@ -79,11 +79,15 @@ Raphael.fn.connection = function (obj1, obj2, line, bg, strokeColor, symbol, lab return ret; }; }; -// Source: http://stackoverflow.com/questions/2627436/svg-animation-along-path-with-raphael + + +// source: http://stackoverflow.com/questions/2627436/svg-animation-along-path-with-raphael Raphael.fn.circlePath = function(x , y, r) { return "M"+x+","+(y-r)+"A"+r+","+r+",0,1,1,"+(x-0.1)+","+(y-r)+" z"; }; -// The nodes + + +// nodes Raphael.fn.aNode = function(x, y, r, isFinal, hasSelfConn, strokeWidth, strokeColor,labelText, labelFontSize, name) { var res = this.set(); @@ -143,15 +147,9 @@ Raphael.fn.aNode = function(x, y, r, isFinal, hasSelfConn, name: name }; }; -// Source: http://www.davidcramer.net/code/63/dir-in-javascript.html -function dir(object) { - methods = []; - for (z in object) if (typeof(z) != 'number') methods.push(z); - return methods.join(', '); -}; -// Drawing the graph. +// drawing a graph function graph() { var nodeRadius = 30; var nodeRadiusHi = nodeRadius + 10; @@ -180,6 +178,7 @@ function graph() { up = function () { this.animate({r:nodeRadius, opacity:nodeOpacity}, 500, ">"); }; + // nodes var nodes = []; var nodeById = []; @@ -221,6 +220,7 @@ function graph() { nx = nx + nxOffset; i++; }; + // connections var connections = []; var k = l = 0; @@ -252,3 +252,4 @@ function graph() { graphNodeByName: graphNodeByName }; }; + diff --git a/javascripts/lib/jquery.bgiframe.js b/javascripts/lib/jquery.bgiframe.js new file mode 100644 index 0000000..5d270f3 --- /dev/null +++ b/javascripts/lib/jquery.bgiframe.js @@ -0,0 +1,104 @@ +/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net) + * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) + * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. + * + * $LastChangedDate: 2007-06-20 03:23:36 +0200 (Mi, 20 Jun 2007) $ + * $Rev: 2110 $ + * + * Version 2.1 + */ + +(function($){ + +/** + * The bgiframe is chainable and applies the iframe hack to get + * around zIndex issues in IE6. It will only apply itself in IE + * and adds a class to the iframe called 'bgiframe'. The iframe + * is appeneded as the first child of the matched element(s) + * with a tabIndex and zIndex of -1. + * + * By default the plugin will take borders, sized with pixel units, + * into account. If a different unit is used for the border's width, + * then you will need to use the top and left settings as explained below. + * + * NOTICE: This plugin has been reported to cause perfromance problems + * when used on elements that change properties (like width, height and + * opacity) a lot in IE6. Most of these problems have been caused by + * the expressions used to calculate the elements width, height and + * borders. Some have reported it is due to the opacity filter. All + * these settings can be changed if needed as explained below. + * + * @example $('div').bgiframe(); + * @before

Paragraph

+ * @result