Day 2 Week 2 on JFLAP

Today I added this wonderful feature into FATester – right-click menu! Now you can right click a node to toggle initial and final states. Sadly, I spent most of the time debugging. There are three main things that I learned today to remember:

1. jQuery selector returns an object different from a normal javascript object. When I used selector to select a node in the graph, the object returned can not simply be operated with methods provided by JSAV.

2. if an event is binded to an object for multiple times, the event will trigger the function as many times as the event is binded. This bothered me when I was trying to toggle initial and final states by clicking a button. If a state is toggle twice, then it is back to its original state!

3. offsets culumate. To make the right click menu appear, I am using a div and setting its position as absolute. However, I first used offset() function to do this, which made the menu move further and further to right and bottom. After searching online, I decided to switch to jQuery function .css() and changed the left and top attributes, which work as a charm.


Some screenshots of this new function:

earlier version

Before I developed this new function, users have to click Edit Node button and then click a node to change initial and final states.

toggle initial

Toggle initial state

toggle final

Toggle final state

toggle final

Having two initial states is not allowed


Besides this new function, I also added some exercises in the Linz book to the tester. There are now four problems and some test cases.

Leave a Reply

Your email address will not be published. Required fields are marked *