Commits

Rune Halvorsen committed a26d0c7

Incorporated review feedback

Comments (0)

Files changed (4)

templates/js/js-build_application.mako

   throw "window.app does already exist";
 }
 window.app = {};
-MessageMixin.apply(window.app); // Give the app object message handling powers
+window.cls.MessageMixin.apply(window.app); // Give the app object message handling powers
 
 window.app.build_application = function(on_services_created, on_services_enabled)
 {
 
   var create_raw_interface = function(service_name)
   {
-    var service_class = function()
+    var ServiceClass = function()
     {
       this.name = service_name;
+      this.is_implemented = false;
     }
-    var service_implementation = function(){};
-    service_implementation.prototype = new cls.ServiceBase();
-    service_class.prototype = new service_implementation();
-    service_class.prototype.constructor = service_class;
-    MessageMixin.apply(service_class.prototype);
-    window.services.add(new service_class());
+    ServiceClass.prototype = new cls.ServiceBase();
+    ServiceClass.prototype.constructor = ServiceClass;  // this is not really needed
+    window.services.add(new ServiceClass());
   }
 
   // ensure that the static methods on cls.ServiceBase exist.

templates/js/messagebroker.js

  *
  * @requires MessageMixin
  */
-function MessageBroker() {
+
+window.cls || ( window.cls = {} );
+
+cls.MessageBroker = function() {
    // message broker is a singleton
-   if(arguments.callee.instance)
+   if(cls.MessageBroker.instance)
    {
-     return arguments.callee.instance;
+     return cls.MessageBroker.instance;
    }
-   arguments.callee.instance = this;
+   cls.MessageBroker.instance = this;
 
-   MessageMixin.apply(this); // mixin happens here.
+   cls.MessageMixin.apply(this); // mixin happens here.
    // At this point message broker instance has addListener and post
-}
-MessageBroker.getInstance = function() { return new MssageBroker(); };
+};
+cls.MessageBroker.getInstance = function() { return new MessageBroker(); };

templates/js/messagemixin.js

  *
  */
 
-function MessageMixin()
+window.cls || ( window.cls = {} );
+
+cls.MessageMixin = function()
 {
 
   /**
    */
   this.remove_listener = function(name, cb)
   {
-    if (! this._mm_listeners) { return false; }
+    if (! this._mm_listeners) { return; }
     var cur = null;
     var listeners = this._mm_listeners[ name ] || [];
     var i = 0;
         i--;
       }
     }
-    return true;
   };
   this.removeListener = this.remove_listener;
 
    */
   this.post_message = function( name, msg )
   {
-    if (! this._mm_listeners) { return false; }
+    if (! this._mm_listeners) { return; }
+    if (msg === undefined || msg === null || isNaN(msg)) {
+      msg = {};
+    }
     msg = msg || {};
-    var listeners = this._mm_listeners[ name ] || [];
+    var listeners = this._mm_listeners[ name ];
     var cb = null;
     var i = 0;
     msg.type = name;
     msg.target = this;
-    for( ; cb = listeners[i]; i++)
+    if( listeners )
     {
-      cb(msg);
+      for( ; cb = listeners[i]; i++)
+      {
+        cb(msg);
+      }
     }
-    return true;
   };
   this.post = this.post_message;
 }

templates/js/tag_manager.js

  */
 window.cls.TagManager = function()
 {
-  if(arguments.callee.instance)
+  if(cls.TagManager.instance)
   {
-    return arguments.callee.instance;
+    return cls.TagManager.instance;
   }
-  arguments.callee.instance = this;
+  cls.TagManager.instance = this;
 
   const
   OBJECT = 0,