Changes in document are finite automaton. It's more comfortable to set finite automaton as some matrix, instead of writing functions JavaScript, executing these change on screen. Let's consider how write finite automaton for change stile of objects depending of pressing of keyboard's keys and buttons of mouse by user. Let, for example, there is a forum (let items are list elements <li></li>).
How to make such changes in a browser window and send to server? If you locate a set of radio-buttons near each phrase, it will make document bulky and will not pleasant for user. I offer to click on phrases directly: click increase phrase state by one level, double click reduce phrase state by one level.
Let's define styles for our phrases. These styles can have different colours, font sizes, etc.
Single click by left mouse key call event click, double click by left mouse key call event double. If different tags use the same styles, then they will execute the same transformations. Transition sheet look so
class
is absent in tag)
is named as default.
For example, transition from default-state looks so
If an event is called on a not emphasized object, then it change style of only one this object. If an event is called on one of an emphasized objects, then it change style of all emphasized objects (final style of each object depends of its initial style).
Let one html-element (À) is inside another html-element (Â), transition for "Â" is specified in Transition Sheet, and user calls event on "À". If transition for "A"
Let's write down all transition tables in a separate file,
for example, "a.txt", and add following html-element inside element
head
Commands is diveded into reserved by a browser and invented by a user (for example he can invent commands cool, fine). Reserved command can be called both directly by keyboard or mouse, and from a menu, user commands can be called only from a menu.
Combination of reserved commands is possible to use.
Button enter of keyboard wake event click, button bkspace of keyboard wake event double.
mouse's | keyboard's | |
left key | right key | |
click, double | ins, del, any letter |
Keys space (which does not wake event itself) make drag-and-drop of object under mouse cursor and sends two commands: first pressing - drag (then movement of cursor by keys-arrows), second pressing - drop, commands "drag" and "drop" is called for an appropriate objects after second pressing.
Menu for object looks so (to_r5, to_r4, to_r3, to_r2, to_r1 are user's events)
Colours (and only colours) can move smoothly. When it's necessary, that colour changed not by jump, but smoothly, during some interval of time, additional property color-time is used, which defines how many seconds should be this change.
If objects, which change own style, is in tag form
,
then browser submits xml-element obj
(value of attribute name
of object is assigned to xml-attribute name
,
os = old style, ns = new style).
For example, click on a phrase of class "r1" creates the following parcel
<obj name=A event=click os=r1 ns=r2> |
input
type
=submit>
is absent in a form