Commits

Ginés Martínez Sánchez committed c4fe141 Draft

writing inter event example

  • Participants
  • Parent commits 09ebac0

Comments (0)

Files changed (1)

File ginsfsm/examples/inter_event/ap1_banco/banco/pyramid_app/static/cliente.js

     /********************************************
      *      Auxiliary
      ********************************************/
+    function escriba_algo(self, texto, $element) {
+        
+    }
 
     /********************************************
      *      Configure events
             self.send_event(self, 'EV_REGISTER_USER', kw);
         });
 
-
-/*
-        self.$outer_box.hover(function() {
-            self.$outer_box.addClass(self.config.extra_clickable_hover_cls);
-        }, function() {
-            self.$outer_box.removeClass(self.config.extra_clickable_hover_cls);
-        });
-
-        self.$outer_box.on("mousedown", self, function(event){
-            event.stopPropagation();
-            var self = event.data;
-            self.send_event(self, 'EV_MOUSEDOWN');
-        });
-        self.$outer_box.on("mouseup", self, function(event){
-            event.preventDefault();
-            event.stopPropagation();
-            var self = event.data;
-            self.send_event(self, 'EV_MOUSEUP');
-        });
-*/
-
-        /*--------------------------------*
-         *      Notifies
-         *--------------------------------*/
-/*
-        if (self.config.notify_to) {
-            self.subscribe_event(
-                'EV_COMMAND',
-                self.config.notify_to,
-                {change_original_event_name: self.config.command_event_name}
-            );
-        }
-*/
         return 1;
     }
 
     /***************************************************************
      *      Actions
      ***************************************************************/
-    function ac_paint(self, event) {
+    function ac_register_user(self, event) {
+        /*
+         *  user_name =
+         */
+        var user_name = event.kw.user_name;
+        if (!user_name) {
+            escriba_algo(self, "Escriba su nombre", self.$registro_nombre);
+            return 1;
+        }
+        self.logger("user " + user_name);
         return 1;
     }
 
-    function ac_setcontent(self, event) {
-        /*
-         *  content = kw.content
-         */
-        //self.config.label = event.kw.content;
-        //self.$content.html(self.config.label);
+    function ac_unregister_user(self, event) {
         return 1;
     }
 
     var CLIENTE_FSM = {
         'event_list': [
             'EV_COMMAND: output',
-            'EV_PAINT',
-            'EV_SETTEXT'
+            'EV_UNREGISTER_USER',
+            'EV_REGISTER_USER'
         ],
         'state_list': [
             'ST_INIT',                       /* Estado inicial */
         'machine': {
             'ST_INIT':
             [
-                ['EV_PAINT',        ac_paint,           undefined],
-                ['EV_SETTEXT',      ac_setcontent,      undefined],
+                ['EV_REGISTER_USER',        ac_register_user,       undefined]
             ],
             'ST_REGISTERED':
             [
-                ['EV_PAINT',        ac_paint,           undefined],
-                ['EV_SETTEXT',      ac_setcontent,      undefined],
+                ['EV_UNREGISTER_USER',      ac_unregister_user,     undefined]
             ]
         }
     }
          *  Initial paint
          *  Paint will set $head and $tail insert point.
          *-------------------------------------------------*/
-        //self.send_event(self, 'EV_PAINT');
+        //self.send_event(self, 'EV_REGISTER_USER');
 
         /*---------------------------------*
          *      Build jquery link list.
             var cur_st = self.get_current_state();
             if (cur_st !== 'ST_PRESSED') {
                 self.set_new_state('ST_PRESSED');
-                self.send_event(self, 'EV_PAINT');
+                self.send_event(self, 'EV_REGISTER_USER');
             }
         } else {
             var cur_st = self.get_current_state();
             if (cur_st !== 'ST_NORMAL') {
                 self.set_new_state('ST_NORMAL');
-                self.send_event(self, 'EV_PAINT');
+                self.send_event(self, 'EV_REGISTER_USER');
             }
         }
         */
         var self = this;
         if (enabled) {
             self.set_new_state('ST_NORMAL');
-            self.send_event(self, 'EV_PAINT');
+            self.send_event(self, 'EV_REGISTER_USER');
         } else {
             self.set_new_state('ST_DISABLED');
-            self.send_event(self, 'EV_PAINT');
+            self.send_event(self, 'EV_REGISTER_USER');
         }
         */
     }