You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by li...@apache.org on 2010/09/15 03:40:15 UTC

svn commit: r997163 [2/37] - in /shindig/trunk/features/src/main/javascript/features: caja/ com.google.gadgets.analytics/ container/ core.config/ core.io/ core.json/ core.legacy/ core.log/ core.prefs/ core.util/ dynamic-height.util/ dynamic-height/ fla...

Modified: shindig/trunk/features/src/main/javascript/features/caja/caja.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/caja/caja.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/caja/caja.js (original)
+++ shindig/trunk/features/src/main/javascript/features/caja/caja.js Wed Sep 15 01:39:49 2010
@@ -23,7 +23,7 @@
 
 var valijaMaker = undefined;
 
-(function(){
+(function() {
   var imports = ___.copy(___.sharedImports);
   imports.loader = {
     provide: ___.func(function(v) { valijaMaker = v; })
@@ -33,4 +33,4 @@ var valijaMaker = undefined;
   ___.getNewModuleHandler().handleUncaughtException = function(e) {
     throw e;
   };
- })();
+})();

Modified: shindig/trunk/features/src/main/javascript/features/caja/taming.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/caja/taming.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/caja/taming.js (original)
+++ shindig/trunk/features/src/main/javascript/features/caja/taming.js Wed Sep 15 01:39:49 2010
@@ -18,11 +18,11 @@
 
 /**
  * @fileoverview Caja is a whitelisting javascript sanitizing rewriter.
- * This file tames the APIs that are exposed to a gadget
+ * This file tames the APIs that are exposed to a gadget.
  */
 
 var caja___ = (function() {
-    // URI policy: Rewrites all uris in a cajoled gadget
+  // URI policy: Rewrites all uris in a cajoled gadget
   var uriCallback = {
     rewrite: function rewrite(uri, mimeTypes) {
       uri = String(uri);
@@ -48,34 +48,34 @@ var caja___ = (function() {
   }
   function whitelistCtors(schemas) {
     var length = schemas.length;
-    for (var i=0; i < length; i++) {
+    for (var i = 0; i < length; i++) {
       var schema = schemas[i];
       if (typeof schema[0][schema[1]] === 'function') {
         ___.markCtor(schema[0][schema[1]] /* func */, schema[2] /* parent */, schema[1] /* name */);
       } else {
-        gadgets.warn("Error taming constructor: " + schema[0] + "." + schema[1]);
+        gadgets.warn('Error taming constructor: ' + schema[0] + '.' + schema[1]);
       }
     }
   }
   function whitelistFuncs(schemas) {
     var length = schemas.length;
-    for (var i=0; i < length; i++) {
+    for (var i = 0; i < length; i++) {
       var schema = schemas[i];
       if (typeof schema[0][schema[1]] === 'function') {
         ___.markInnocent(schema[0][schema[1]], schema[1]);
       } else {
-        gadgets.warn("Error taming function: " + schema[0] + "." + schema[1]);
+        gadgets.warn('Error taming function: ' + schema[0] + '.' + schema[1]);
       }
     }
   }
   function whitelistMeths(schemas) {
     var length = schemas.length;
-    for (var i=0; i < length; i++) {
+    for (var i = 0; i < length; i++) {
       var schema = schemas[i];
       if (typeof schema[0].prototype[schema[1]] == 'function') {
         ___.grantInnocentMethod(schema[0].prototype, schema[1]);
       } else {
-        gadgets.warn("Error taming method: " + schema[0] + "." + schema[1]);
+        gadgets.warn('Error taming method: ' + schema[0] + '.' + schema[1]);
       }
     }
   }
@@ -83,20 +83,20 @@ var caja___ = (function() {
   function enable() {
     var imports = ___.copy(___.sharedImports);
     imports.outers = imports;
-    
+
     var gadgetRoot = document.getElementById('cajoled-output');
     gadgetRoot.className = 'g___';
     document.body.appendChild(gadgetRoot);
-    
+
     imports.htmlEmitter___ = new HtmlEmitter(gadgetRoot);
     attachDocumentStub('-g___', uriCallback, imports, gadgetRoot);
-    
+
     imports.$v = valijaMaker.CALL___(imports.outers);
-    
+
     ___.getNewModuleHandler().setImports(imports);
-    
+
     fire(imports);
-    
+
     imports.outers.gadgets = ___.tame(window.gadgets);
     imports.outers.opensocial = ___.tame(window.opensocial);
     ___.grantRead(imports.outers, 'gadgets');

Modified: shindig/trunk/features/src/main/javascript/features/com.google.gadgets.analytics/analytics.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/com.google.gadgets.analytics/analytics.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/com.google.gadgets.analytics/analytics.js (original)
+++ shindig/trunk/features/src/main/javascript/features/com.google.gadgets.analytics/analytics.js Wed Sep 15 01:39:49 2010
@@ -21,11 +21,11 @@
 	gadgets.analytics = function(trackingCode) {
 		this.tracker = _gat._getTracker(trackingCode);
 	};
-	
+
 	gadgets.analytics.prototype.reportPageview = function(path) {
 		this.tracker._trackPageview(path);
 	};
-	
+
 	/**
 	 * label and value are optional
 	 */

Modified: shindig/trunk/features/src/main/javascript/features/com.google.gadgets.analytics/taming.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/com.google.gadgets.analytics/taming.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/com.google.gadgets.analytics/taming.js (original)
+++ shindig/trunk/features/src/main/javascript/features/com.google.gadgets.analytics/taming.js Wed Sep 15 01:39:49 2010
@@ -24,7 +24,7 @@
 var tamings___ = tamings___ || [];
 tamings___.push(function(imports) {
   caja___.whitelistCtors([
-      [gadgets, 'analytics', Object]
+    [gadgets, 'analytics', Object]
   ]);
   caja___.whitelistMeths([
     [gadgets.analytics, 'reportPageview'],

Modified: shindig/trunk/features/src/main/javascript/features/container/container.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/container/container.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/container/container.js (original)
+++ shindig/trunk/features/src/main/javascript/features/container/container.js Wed Sep 15 01:39:49 2010
@@ -56,7 +56,7 @@ shindig.container.Container = function(o
       ? Boolean(shindig.container.util.getSafeJsonValue(config,
           shindig.container.ContainerConfig.RENDER_DEBUG, false))
       : (param === '1');
-    
+
   /**
    * @type {boolean}
    */
@@ -78,10 +78,10 @@ shindig.container.Container = function(o
 
   /**
    * result from calling window.setInterval()
-   * @type {number|null}
+   * @type {?number}
    */
   this.tokenRefreshTimer_ = null;
-  
+
   this.registerRpcServices_();
 
   this.onConstructed(config);
@@ -90,7 +90,7 @@ shindig.container.Container = function(o
 
 /**
  * Create a new gadget site.
- * @param {Element} gadgetEl HTML element into which to render
+ * @param {Element} gadgetEl HTML element into which to render.
  * @param {Element=} opt_bufferEl Optional HTML element for double buffering.
  * @return {shindig.container.GadgetSite} site created for client to hold to.
  */
@@ -267,7 +267,7 @@ shindig.container.ContainerRender.CLASS 
 // Whether to turn off debugging.
 shindig.container.ContainerRender.DEBUG = 'debug';
 // The starting/default gadget iframe height (in pixels).
-shindig.container.ContainerRender.HEIGHT ='height';
+shindig.container.ContainerRender.HEIGHT = 'height';
 // Whether to turn off debugging.
 shindig.container.ContainerRender.TEST = 'test';
 // The gadget view name.
@@ -293,7 +293,7 @@ shindig.container.Container.prototype.sc
   if (this.isRefreshTokensEnabled_() && !this.tokenRefreshTimer_) {
     var self = this;
     this.tokenRefreshTimer_ = window.setInterval(function() {
-        self.refreshTokens_();
+      self.refreshTokens_();
     }, this.tokenRefreshInterval_);
   }
 };

Modified: shindig/trunk/features/src/main/javascript/features/container/gadget_holder.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/container/gadget_holder.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/container/gadget_holder.js (original)
+++ shindig/trunk/features/src/main/javascript/features/container/gadget_holder.js Wed Sep 15 01:39:49 2010
@@ -99,7 +99,7 @@ shindig.container.GadgetHolder.prototype
 
 
 /**
- * @return {string|null} The unique string ID for gadget iframe.
+ * @return {?string} The unique string ID for gadget iframe.
  */
 shindig.container.GadgetHolder.prototype.getIframeId = function() {
   return this.iframeId_;
@@ -107,7 +107,7 @@ shindig.container.GadgetHolder.prototype
 
 
 /**
- * @return {Object|null} The metadata of gadget.
+ * @return {?Object} The metadata of gadget.
  */
 shindig.container.GadgetHolder.prototype.getGadgetInfo = function() {
   return this.gadgetInfo_;
@@ -123,7 +123,7 @@ shindig.container.GadgetHolder.prototype
 
 
 /**
- * @return {string|null} The URL of current gadget.
+ * @return {?string} The URL of current gadget.
  */
 shindig.container.GadgetHolder.prototype.getUrl = function() {
   return (this.gadgetInfo_) ? this.gadgetInfo_['url'] : null;
@@ -131,7 +131,7 @@ shindig.container.GadgetHolder.prototype
 
 
 /**
- * @return {string|null} The view of current gadget.
+ * @return {?string} The view of current gadget.
  */
 shindig.container.GadgetHolder.prototype.getView = function() {
   return this.renderParams_[shindig.container.RenderParam.VIEW];
@@ -209,18 +209,18 @@ shindig.container.GadgetHolder.IFRAME_ID
  */
 shindig.container.GadgetHolder.prototype.getIframeHtml_ = function() {
   var iframeParams = {
-      'id': this.iframeId_,
-      'name': this.iframeId_,
-      'src': this.getIframeUrl_(),
-      'scrolling': 'no',
-      'marginwidth': '0',
-      'marginheight': '0',
-      'frameborder': '0',
-      'vspace': '0',
-      'hspace': '0',
-      'class': this.renderParams_[shindig.container.RenderParam.CLASS],
-      'height': this.renderParams_[shindig.container.RenderParam.HEIGHT],
-      'width': this.renderParams_[shindig.container.RenderParam.WIDTH]
+    'id': this.iframeId_,
+    'name': this.iframeId_,
+    'src': this.getIframeUrl_(),
+    'scrolling': 'no',
+    'marginwidth': '0',
+    'marginheight': '0',
+    'frameborder': '0',
+    'vspace': '0',
+    'hspace': '0',
+    'class': this.renderParams_[shindig.container.RenderParam.CLASS],
+    'height': this.renderParams_[shindig.container.RenderParam.HEIGHT],
+    'width': this.renderParams_[shindig.container.RenderParam.WIDTH]
   };
 
   // Do not use DOM API (createElement(), setAttribute()), since it is slower,
@@ -262,7 +262,7 @@ shindig.container.GadgetHolder.prototype
   if (this.securityToken_) {
     uri.setExistingP('st', this.securityToken_);
   }
-  
+
   uri.setFP('mid', String(this.siteId_));
 
   if (this.hasViewParams_()) {

Modified: shindig/trunk/features/src/main/javascript/features/container/gadget_site.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/container/gadget_site.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/container/gadget_site.js (original)
+++ shindig/trunk/features/src/main/javascript/features/container/gadget_site.js Wed Sep 15 01:39:49 2010
@@ -26,7 +26,7 @@
 
 /**
  * @param {shindig.container.Service} service To fetch gadgets metadata, token.
- * @param {Element} gadgetEl Element into which to render the gadget
+ * @param {Element} gadgetEl Element into which to render the gadget.
  * @param {Element=} opt_bufferEl Optional element for double buffering.
  * @constructor
  */
@@ -203,7 +203,7 @@ shindig.container.GadgetSite.prototype.g
 shindig.container.GadgetSite.prototype.navigateTo = function(
     gadgetUrl, viewParams, renderParams, opt_callback) {
   var callback = opt_callback || function() {};
-  
+
   // If metadata has been loaded/cached.
   var gadgetInfo = this.service_.getCachedGadgetMetadata(gadgetUrl);
   if (gadgetInfo) {

Modified: shindig/trunk/features/src/main/javascript/features/container/init.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/container/init.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/container/init.js (original)
+++ shindig/trunk/features/src/main/javascript/features/container/init.js Wed Sep 15 01:39:49 2010
@@ -51,7 +51,7 @@
     var scriptEls = document.getElementsByTagName('script');
     var uri = null;
     if (scriptEls.length > 0) {
-      uri = shindig.uri(scriptEls[scriptEls.length - 1].src)
+      uri = shindig.uri(scriptEls[scriptEls.length - 1].src);
       // In case script URI is relative, resolve it against window.location
       uri.resolve(shindig.uri(window.location));
     }

Modified: shindig/trunk/features/src/main/javascript/features/container/service.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/container/service.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/container/service.js (original)
+++ shindig/trunk/features/src/main/javascript/features/container/service.js Wed Sep 15 01:39:49 2010
@@ -34,14 +34,14 @@ shindig.container.Service = function(opt
    * @type {string}
    */
   this.apiHost_ = String(shindig.container.util.getSafeJsonValue(config,
-     shindig.container.ServiceConfig.API_HOST, window.__API_URI.getOrigin()));
-  
+      shindig.container.ServiceConfig.API_HOST, window.__API_URI.getOrigin()));
+
   /**
    * @type {string}
    */
   this.apiPath_ = String(shindig.container.util.getSafeJsonValue(config,
       shindig.container.ServiceConfig.API_PATH, '/api/rpc/cs'));
-  
+
   /**
    * Map of gadget URLs to cached gadgetInfo response.
    * @type {Object}
@@ -54,7 +54,7 @@ shindig.container.Service = function(opt
    */
   this.cachedTokens_ = {};
 
-  this.initializeOsapi_(); 
+  this.initializeOsapi_();
 
   this.onConstructed(config);
 };
@@ -83,8 +83,8 @@ shindig.container.Service.prototype.getG
     if (response.error) {
       // Hides internal server error.
       callback({
-          error : 'Failed to retrieve gadget metadata.',
-          errorCode : 'NOLOAD'
+        error: 'Failed to retrieve gadget metadata.',
+        errorCode: 'NOLOAD'
       });
     } else {
       for (var id in response) {
@@ -109,8 +109,8 @@ shindig.container.Service.prototype.getG
     if (response.error) {
       // Hides internal server error.
       callback({
-          error : 'Failed to retrieve gadget token.',
-          errorCode : 'NOLOAD'
+        error: 'Failed to retrieve gadget token.',
+        errorCode: 'NOLOAD'
       });
     } else {
       for (var id in response) {
@@ -146,17 +146,17 @@ shindig.container.Service.prototype.getC
  */
 shindig.container.Service.prototype.initializeOsapi_ = function() {
   var endPoint = this.apiHost_ + this.apiPath_;
-  
+
   var osapiServicesConfig = {};
-  osapiServicesConfig['gadgets.rpc'] = [ 'container.listMethods' ];
+  osapiServicesConfig['gadgets.rpc'] = ['container.listMethods'];
   osapiServicesConfig[endPoint] = [
     'gadgets.metadata.get',
     'gadgets.token.get'
   ];
 
   gadgets.config.init({
-    'osapi': { 'endPoints': [ endPoint ] },
-    'osapi.services': osapiServicesConfig 
+    'osapi': { 'endPoints': [endPoint] },
+    'osapi.services': osapiServicesConfig
   });
 };
 
@@ -172,7 +172,7 @@ shindig.container.Service.prototype.init
  * @enum {string}
  */
 shindig.container.ServiceConfig = {};
-// Host to fetch gadget information, via XHR. 
+// Host to fetch gadget information, via XHR.
 shindig.container.ServiceConfig.API_HOST = 'apiHost';
-// Path to fetch gadget information, via XHR. 
+// Path to fetch gadget information, via XHR.
 shindig.container.ServiceConfig.API_PATH = 'apiPath';

Modified: shindig/trunk/features/src/main/javascript/features/core.config/config.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.config/config.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.config/config.js (original)
+++ shindig/trunk/features/src/main/javascript/features/core.config/config.js Wed Sep 15 01:39:49 2010
@@ -62,7 +62,7 @@ gadgets.config = function() {
 
   return {
     'register':
-    /**
+        /**
      * Registers a configurable component and its configuration parameters.
      * Multiple callbacks may be registered for a single component if needed.
      *
@@ -71,7 +71,7 @@ gadgets.config = function() {
      *     the name of a fully qualified javascript object reference
      *     (e.g. "gadgets.io").
      * @param {Object=} opt_validators Mapping of option name to validation
-     *     functions that take the form function(data) {return isValid(data);}
+     *     functions that take the form function(data) {return isValid(data);}.
      * @param {function(Object)=} opt_callback A function to be invoked when a
      *     configuration is registered. If passed, this function will be invoked
      *     immediately after a call to init has been made. Do not assume that
@@ -85,21 +85,21 @@ gadgets.config = function() {
      * @name register
      * @function
      */
-    function(component, opt_validators, opt_callback) {
-      var registered = components[component];
-      if (!registered) {
-        registered = [];
-        components[component] = registered;
-      }
+        function(component, opt_validators, opt_callback) {
+          var registered = components[component];
+          if (!registered) {
+            registered = [];
+            components[component] = registered;
+          }
 
-      registered.push({
-        validators: opt_validators || {},
-        callback: opt_callback
-      });
-    },
+          registered.push({
+            validators: opt_validators || {},
+            callback: opt_callback
+          });
+        },
 
     'get':
-    /**
+        /**
      * Retrieves configuration data on demand.
      *
      * @param {string=} opt_component The component to fetch. If not provided
@@ -110,12 +110,12 @@ gadgets.config = function() {
      * @name get
      * @function
      */
-    function(opt_component) {
-      if (opt_component) {
-        return configuration[opt_component] || {};
-      }
-      return configuration;
-    },
+        function(opt_component) {
+          if (opt_component) {
+            return configuration[opt_component] || {};
+          }
+          return configuration;
+        },
 
     /**
      * Initializes the configuration.
@@ -124,7 +124,7 @@ gadgets.config = function() {
      * @param {boolean=} opt_noValidation True if you want to skip validation.
      * @throws {Error} If there is a configuration error.
      * @member gadgets.config
-     * @name init 
+     * @name init
      * @function
      */
     'init': function(config, opt_noValidation) {
@@ -208,7 +208,7 @@ gadgets.config = function() {
      * @function
      */
     'ExistsValidator': function(data) {
-      return typeof data !== "undefined";
+      return typeof data !== 'undefined';
     },
 
     /**
@@ -219,7 +219,7 @@ gadgets.config = function() {
      * @function
      */
     'NonEmptyStringValidator': function(data) {
-      return typeof data === "string" && data.length > 0;
+      return typeof data === 'string' && data.length > 0;
     },
 
     /**
@@ -230,7 +230,7 @@ gadgets.config = function() {
      * @function
      */
     'BooleanValidator': function(data) {
-      return typeof data === "boolean";
+      return typeof data === 'boolean';
     },
 
     /**

Modified: shindig/trunk/features/src/main/javascript/features/core.io/io.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.io/io.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.io/io.js (original)
+++ shindig/trunk/features/src/main/javascript/features/core.io/io.js Wed Sep 15 01:39:49 2010
@@ -46,15 +46,15 @@ gadgets.io = function() {
    * Internal facility to create an xhr request.
    */
   function makeXhr() {
-    var x; 
+    var x;
     if (typeof shindig != 'undefined' &&
         shindig.xhrwrapper &&
         shindig.xhrwrapper.createXHR) {
       return shindig.xhrwrapper.createXHR();
     } else if (typeof ActiveXObject != 'undefined') {
-      x = new ActiveXObject("Msxml2.XMLHTTP");
+      x = new ActiveXObject('Msxml2.XMLHTTP');
       if (!x) {
-        x = new ActiveXObject("Microsoft.XMLHTTP");
+        x = new ActiveXObject('Microsoft.XMLHTTP');
       }
       return x;
     }
@@ -62,16 +62,16 @@ gadgets.io = function() {
     else if (typeof XMLHttpRequest != 'undefined' || window.XMLHttpRequest) {
       return new window.XMLHttpRequest();
     }
-    else throw("no xhr available");
+    else throw ('no xhr available');
   }
 
   /**
    * Checks the xobj for errors, may call the callback with an error response
    * if the error is fatal.
    *
-   * @param {Object} xobj The XHR object to check
-   * @param {function(Object)} callback The callback to call if the error is fatal
-   * @return {boolean} true if the xobj is not ready to be processed
+   * @param {Object} xobj The XHR object to check.
+   * @param {function(Object)} callback The callback to call if the error is fatal.
+   * @return {boolean} true if the xobj is not ready to be processed.
    */
   function hadError(xobj, callback) {
     if (xobj.readyState !== 4) {
@@ -79,22 +79,22 @@ gadgets.io = function() {
     }
     try {
       if (xobj.status !== 200) {
-      	var error = ("" + xobj.status);
-      	if(xobj.responseText) {
-      	  error = error + " " + xobj.responseText;
+      	var error = ('' + xobj.status);
+      	if (xobj.responseText) {
+      	  error = error + ' ' + xobj.responseText;
       	}
         callback({
-          errors : [error],
-          rc : xobj.status,
-          text : xobj.responseText
-          });
+          errors: [error],
+          rc: xobj.status,
+          text: xobj.responseText
+        });
         return true;
       }
-    } catch(e) {
+    } catch (e) {
       callback({
-         errors : [e.number + " Error not specified"],
-          rc : e.number,
-          text : e.description
+        errors: [e.number + ' Error not specified'],
+        rc: e.number,
+        text: e.description
       });
       return true;
     }
@@ -128,24 +128,24 @@ gadgets.io = function() {
    * @param {function(Object)} callback
    * @param {Object} params
    * @param {Object} xobj
-   */ 
+   */
   function processResponse(url, callback, params, xobj) {
     if (hadError(xobj, callback)) {
       return;
     }
     var txt = xobj.responseText;
-    
+
     // remove unparseable cruft used to prevent cross-site script inclusion
     var offset = txt.indexOf(UNPARSEABLE_CRUFT) + UNPARSEABLE_CRUFT.length;
 
     // If no cruft then just return without a callback - avoid JS errors
     // TODO craft an error response?
     if (offset < UNPARSEABLE_CRUFT.length) return;
-    txt = txt.substr(offset)
+    txt = txt.substr(offset);
 
     // We are using eval directly here  because the outer response comes from a
     // trusted source, and json parsing is slow in IE.
-    var data = eval("(" + txt + ")");
+    var data = eval('(' + txt + ')');
     data = data[url];
     // Save off any transient OAuth state the server wants back later.
     if (data.oauthState) {
@@ -168,52 +168,52 @@ gadgets.io = function() {
     // Sometimes rc is not present, generally when used
     // by jsonrpccontainer, so assume 200 in its absence.
     var resp = {
-     text: data.body,
-     rc: data.rc || 200,
-     headers: data.headers,
-     oauthApprovalUrl: data.oauthApprovalUrl,
-     oauthError: data.oauthError,
-     oauthErrorText: data.oauthErrorText,
-     errors: []
+      text: data.body,
+      rc: data.rc || 200,
+      headers: data.headers,
+      oauthApprovalUrl: data.oauthApprovalUrl,
+      oauthError: data.oauthError,
+      oauthErrorText: data.oauthErrorText,
+      errors: []
     };
 
-    if (resp.rc < 200 || resp.rc >= 400){
-    	resp.errors = [resp.rc + " Error"];
+    if (resp.rc < 200 || resp.rc >= 400) {
+    	resp.errors = [resp.rc + ' Error'];
     } else if (resp.text) {
       if (resp.rc >= 300 && resp.rc < 400) {
         // Redirect pages will usually contain arbitrary
         // HTML which will fail during parsing, inadvertently
         // causing a 500 response. Thus we treat as text.
-        params.CONTENT_TYPE = "TEXT";
+        params.CONTENT_TYPE = 'TEXT';
       }
       switch (params.CONTENT_TYPE) {
-        case "JSON":
-        case "FEED":
+        case 'JSON':
+        case 'FEED':
           resp.data = gadgets.json.parse(resp.text);
           if (!resp.data) {
-            resp.errors.push("500 Failed to parse JSON");
+            resp.errors.push('500 Failed to parse JSON');
             resp.rc = 500;
             resp.data = null;
           }
           break;
-        case "DOM":
+        case 'DOM':
           var dom;
           if (typeof ActiveXObject != 'undefined') {
-            dom = new ActiveXObject("Microsoft.XMLDOM");
+            dom = new ActiveXObject('Microsoft.XMLDOM');
             dom.async = false;
             dom.validateOnParse = false;
             dom.resolveExternals = false;
             if (!dom.loadXML(resp.text)) {
-              resp.errors.push("500 Failed to parse XML");
+              resp.errors.push('500 Failed to parse XML');
               resp.rc = 500;
             } else {
               resp.data = dom;
             }
           } else {
             var parser = new DOMParser();
-            dom = parser.parseFromString(resp.text, "text/xml");
-            if ("parsererror" === dom.documentElement.nodeName) {
-              resp.errors.push("500 Failed to parse XML");
+            dom = parser.parseFromString(resp.text, 'text/xml');
+            if ('parsererror' === dom.documentElement.nodeName) {
+              resp.errors.push('500 Failed to parse XML');
               resp.rc = 500;
             } else {
               resp.data = dom;
@@ -224,22 +224,22 @@ gadgets.io = function() {
           resp.data = resp.text;
           break;
       }
-  }
+    }
     return resp;
   }
 
   /**
    * Sends an XHR post or get request
    *
-   * @param {string} realUrl The url to fetch data from that was requested by the gadget
-   * @param {string} proxyUrl The url to proxy through
-   * @param {function()} callback The function to call once the data is fetched
-   * @param {Object} paramData The params to use when processing the response
-   * @param {function(string,function(Object),Object,Object)} 
+   * @param {string} realUrl The url to fetch data from that was requested by the gadget.
+   * @param {string} proxyUrl The url to proxy through.
+   * @param {function()} callback The function to call once the data is fetched.
+   * @param {Object} paramData The params to use when processing the response.
+   * @param {function(string,function(Object),Object,Object)}
    *     processResponseFunction The function that should process the
-   *     response from the sever before calling the callback
+   *     response from the sever before calling the callback.
    * @param {string=} opt_contentType - Optional content type defaults to
-   *     'application/x-www-form-urlencoded'
+   *     'application/x-www-form-urlencoded'.
    */
   function makeXhrRequest(realUrl, proxyUrl, callback, paramData, method,
       params, processResponseFunction, opt_contentType) {
@@ -248,7 +248,7 @@ gadgets.io = function() {
     if (proxyUrl.indexOf('//') == 0) {
       proxyUrl = document.location.protocol + proxyUrl;
     }
-    
+
     xhr.open(method, proxyUrl, true);
     if (callback) {
       xhr.onreadystatechange = gadgets.util.makeClosure(
@@ -269,14 +269,14 @@ gadgets.io = function() {
    * directive. The preloader will only satisfy a request for a specific piece
    * of content once.
    *
-   * @param {Object} postData The definition of the request to be executed by the proxy
-   * @param {Object} params The params to use when processing the response
-   * @param {function(Object)} callback The function to call once the data is fetched
-   * @return {boolean} true if the request can be satisfied by the preloaded 
-   *         content false otherwise
+   * @param {Object} postData The definition of the request to be executed by the proxy.
+   * @param {Object} params The params to use when processing the response.
+   * @param {function(Object)} callback The function to call once the data is fetched.
+   * @return {boolean} true if the request can be satisfied by the preloaded
+   *         content false otherwise.
    */
   function respondWithPreload(postData, params, callback) {
-    if (gadgets.io.preloaded_ && postData.httpMethod === "GET") {
+    if (gadgets.io.preloaded_ && postData.httpMethod === 'GET') {
       for (var i = 0; i < gadgets.io.preloaded_.length; i++) {
         var preload = gadgets.io.preloaded_[i];
         if (preload && (preload.id === postData.url)) {
@@ -284,7 +284,7 @@ gadgets.io = function() {
           delete gadgets.io.preloaded_[i];
 
           if (preload.rc !== 200) {
-            callback({rc: preload.rc, errors : [preload.rc + " Error"]});
+            callback({rc: preload.rc, errors: [preload.rc + ' Error']});
           } else {
             if (preload.oauthState) {
               oauthState = preload.oauthState;
@@ -308,18 +308,18 @@ gadgets.io = function() {
   }
 
   /**
-   * @param {Object} configuration Configuration settings
+   * @param {Object} configuration Configuration settings.
    * @private
    */
-  function init (configuration) {
-    config = configuration["core.io"] || {};
+  function init(configuration) {
+    config = configuration['core.io'] || {};
   }
 
   var requiredConfig = {
     proxyUrl: new gadgets.config.RegExValidator(/.*%(raw)?url%.*/),
     jsonProxyUrl: gadgets.config.NonEmptyStringValidator
   };
-  gadgets.config.register("core.io", requiredConfig, init);
+  gadgets.config.register('core.io', requiredConfig, init);
 
   return /** @scope gadgets.io */ {
     /**
@@ -332,108 +332,108 @@ gadgets.io = function() {
      *    {contentType: gadgets.io.ContentType.FEED});
      * </pre>
      *
-     * @param {string} url The URL where the content is located
+     * @param {string} url The URL where the content is located.
      * @param {function(Object)} callback The function to call with the data from
-     *     the URL once it is fetched
+     *     the URL once it is fetched.
      * @param {Object.<gadgets.io.RequestParameters, Object>=} opt_params
      *     Additional
      *     <a href="gadgets.io.RequestParameters.html">parameters</a>
-     *     to pass to the request
+     *     to pass to the request.
      *
      * @member gadgets.io
      */
-    makeRequest : function (url, callback, opt_params) {
+    makeRequest: function(url, callback, opt_params) {
       // TODO: This method also needs to respect all members of
       // gadgets.io.RequestParameters, and validate them.
 
       var params = opt_params || {};
 
-      var httpMethod = params.METHOD || "GET";
+      var httpMethod = params.METHOD || 'GET';
       var refreshInterval = params.REFRESH_INTERVAL;
 
       // Check if authorization is requested
       var auth, st;
-      if (params.AUTHORIZATION && params.AUTHORIZATION !== "NONE") {
+      if (params.AUTHORIZATION && params.AUTHORIZATION !== 'NONE') {
         auth = params.AUTHORIZATION.toLowerCase();
         st = shindig.auth.getSecurityToken();
       } else {
         // Unauthenticated GET requests are cacheable
-        if (httpMethod === "GET" && refreshInterval === undefined) {
+        if (httpMethod === 'GET' && refreshInterval === undefined) {
           refreshInterval = 3600;
         }
       }
 
       // Include owner information?
       var signOwner = true;
-      if (typeof params.OWNER_SIGNED !== "undefined") {
+      if (typeof params.OWNER_SIGNED !== 'undefined') {
         signOwner = params.OWNER_SIGNED;
       }
 
       // Include viewer information?
       var signViewer = true;
-      if (typeof params.VIEWER_SIGNED !== "undefined") {
+      if (typeof params.VIEWER_SIGNED !== 'undefined') {
         signViewer = params.VIEWER_SIGNED;
       }
 
       var headers = params.HEADERS || {};
-      if (httpMethod === "POST" && !headers["Content-Type"]) {
-        headers["Content-Type"] = "application/x-www-form-urlencoded";
+      if (httpMethod === 'POST' && !headers['Content-Type']) {
+        headers['Content-Type'] = 'application/x-www-form-urlencoded';
       }
 
       var urlParams = gadgets.util.getUrlParameters();
 
       var paramData = {
         url: url,
-        httpMethod : httpMethod,
+        httpMethod: httpMethod,
         headers: gadgets.io.encodeValues(headers, false),
-        postData : params.POST_DATA || "",
-        authz : auth || "",
-        st : st || "",
-        contentType : params.CONTENT_TYPE || "TEXT",
-        numEntries : params.NUM_ENTRIES || "3",
-        getSummaries : !!params.GET_SUMMARIES,
-        signOwner : signOwner,
-        signViewer : signViewer,
-        gadget : urlParams.url,
-        container : urlParams.container || urlParams.synd || "default",
+        postData: params.POST_DATA || '',
+        authz: auth || '',
+        st: st || '',
+        contentType: params.CONTENT_TYPE || 'TEXT',
+        numEntries: params.NUM_ENTRIES || '3',
+        getSummaries: !!params.GET_SUMMARIES,
+        signOwner: signOwner,
+        signViewer: signViewer,
+        gadget: urlParams.url,
+        container: urlParams.container || urlParams.synd || 'default',
         // should we bypass gadget spec cache (e.g. to read OAuth provider URLs)
-        bypassSpecCache : gadgets.util.getUrlParameters().nocache || "",
-        getFullHeaders : !!params.GET_FULL_HEADERS
+        bypassSpecCache: gadgets.util.getUrlParameters().nocache || '',
+        getFullHeaders: !!params.GET_FULL_HEADERS
       };
 
       // OAuth goodies
-      if (auth === "oauth" || auth === "signed") {
+      if (auth === 'oauth' || auth === 'signed') {
         if (gadgets.io.oauthReceivedCallbackUrl_) {
           paramData.OAUTH_RECEIVED_CALLBACK = gadgets.io.oauthReceivedCallbackUrl_;
           gadgets.io.oauthReceivedCallbackUrl_ = null;
         }
-        paramData.oauthState = oauthState || "";
+        paramData.oauthState = oauthState || '';
         // Just copy the OAuth parameters into the req to the server
         for (var opt in params) {
           if (params.hasOwnProperty(opt)) {
-            if (opt.indexOf("OAUTH_") === 0) {
+            if (opt.indexOf('OAUTH_') === 0) {
               paramData[opt] = params[opt];
             }
           }
         }
       }
 
-      var proxyUrl = config.jsonProxyUrl.replace("%host%", document.location.host);
+      var proxyUrl = config.jsonProxyUrl.replace('%host%', document.location.host);
 
       // FIXME -- processResponse is not used in call
       if (!respondWithPreload(paramData, params, callback, processResponse)) {
-        if (httpMethod === "GET" && refreshInterval > 0) {
+        if (httpMethod === 'GET' && refreshInterval > 0) {
           // this content should be cached
           // Add paramData to the URL
-          var extraparams = "?refresh=" + refreshInterval + '&'
+          var extraparams = '?refresh=' + refreshInterval + '&'
               + gadgets.io.encodeValues(paramData);
 
           makeXhrRequest(url, proxyUrl + extraparams, callback,
-              null, "GET", params, processResponse);
+              null, 'GET', params, processResponse);
 
         } else {
           makeXhrRequest(url, proxyUrl, callback,
-              gadgets.io.encodeValues(paramData), "POST", params,
+              gadgets.io.encodeValues(paramData), 'POST', params,
               processResponse);
         }
       }
@@ -442,7 +442,7 @@ gadgets.io = function() {
     /**
      * @private
      */
-    makeNonProxiedRequest : function (relativeUrl, callback, opt_params, opt_contentType) {
+    makeNonProxiedRequest: function(relativeUrl, callback, opt_params, opt_contentType) {
       var params = opt_params || {};
       makeXhrRequest(relativeUrl, relativeUrl, callback, params.POST_DATA,
           params.METHOD, params, processNonProxiedResponse, opt_contentType);
@@ -453,7 +453,7 @@ gadgets.io = function() {
      *
      * @private
      */
-    clearOAuthState : function () {
+    clearOAuthState: function() {
       oauthState = undefined;
     },
 
@@ -461,14 +461,14 @@ gadgets.io = function() {
      * Converts an input object into a URL-encoded data string.
      * (key=value&amp;...)
      *
-     * @param {Object} fields The post fields you wish to encode
+     * @param {Object} fields The post fields you wish to encode.
      * @param {boolean=} opt_noEscaping An optional parameter specifying whether
      *     to turn off escaping of the parameters. Defaults to false.
      * @return {string} The processed post data in www-form-urlencoded format.
      *
      * @member gadgets.io
      */
-    encodeValues : function (fields, opt_noEscaping) {
+    encodeValues: function(fields, opt_noEscaping) {
       var escape = !opt_noEscaping;
 
       var buf = [];
@@ -478,46 +478,46 @@ gadgets.io = function() {
           if (!first) {
             first = true;
           } else {
-            buf.push("&");
+            buf.push('&');
           }
           buf.push(escape ? encodeURIComponent(i) : i);
-          buf.push("=");
+          buf.push('=');
           buf.push(escape ? encodeURIComponent(fields[i]) : fields[i]);
         }
       }
-      return buf.join("");
+      return buf.join('');
     },
 
     /**
      * Gets the proxy version of the passed-in URL.
      *
-     * @param {string} url The URL to get the proxy URL for
+     * @param {string} url The URL to get the proxy URL for.
      * @param {Object.<gadgets.io.RequestParameters, Object>=} opt_params Optional Parameter Object.
      *     The following properties are supported:
      *       .REFRESH_INTERVAL The number of seconds that this
      *           content should be cached.  Defaults to 3600.
      *
-     * @return {string} The proxied version of the URL
+     * @return {string} The proxied version of the URL.
      * @member gadgets.io
      */
-    getProxyUrl : function (url, opt_params) {
+    getProxyUrl: function(url, opt_params) {
       var params = opt_params || {};
       var refresh = params.REFRESH_INTERVAL;
       if (refresh === undefined) {
-        refresh = "3600";
+        refresh = '3600';
       }
 
       var urlParams = gadgets.util.getUrlParameters();
 
       var rewriteMimeParam =
-          params.rewriteMime ? "&rewriteMime=" + encodeURIComponent(params.rewriteMime) : "";
-      var ret = config.proxyUrl.replace("%url%", encodeURIComponent(url)).
-          replace("%host%", document.location.host).
-          replace("%rawurl%", url).
-          replace("%refresh%", encodeURIComponent(refresh)).
-          replace("%gadget%", encodeURIComponent(urlParams.url)).
-          replace("%container%", encodeURIComponent(urlParams.container || urlParams.synd || "default")).
-          replace("%rewriteMime%", rewriteMimeParam);
+          params.rewriteMime ? '&rewriteMime=' + encodeURIComponent(params.rewriteMime) : '';
+      var ret = config.proxyUrl.replace('%url%', encodeURIComponent(url)).
+          replace('%host%', document.location.host).
+          replace('%rawurl%', url).
+          replace('%refresh%', encodeURIComponent(refresh)).
+          replace('%gadget%', encodeURIComponent(urlParams.url)).
+          replace('%container%', encodeURIComponent(urlParams.container || urlParams.synd || 'default')).
+          replace('%rewriteMime%', rewriteMimeParam);
       if (ret.indexOf('//') == 0) {
         ret = window.location.protocol + ret;
       }
@@ -527,40 +527,40 @@ gadgets.io = function() {
 }();
 
 gadgets.io.RequestParameters = gadgets.util.makeEnum([
-  "METHOD",
-  "CONTENT_TYPE",
-  "POST_DATA",
-  "HEADERS",
-  "AUTHORIZATION",
-  "NUM_ENTRIES",
-  "GET_SUMMARIES",
-  "GET_FULL_HEADERS",
-  "REFRESH_INTERVAL",
-  "OAUTH_SERVICE_NAME",
-  "OAUTH_USE_TOKEN",
-  "OAUTH_TOKEN_NAME",
-  "OAUTH_REQUEST_TOKEN",
-  "OAUTH_REQUEST_TOKEN_SECRET",
-  "OAUTH_RECEIVED_CALLBACK"
+  'METHOD',
+  'CONTENT_TYPE',
+  'POST_DATA',
+  'HEADERS',
+  'AUTHORIZATION',
+  'NUM_ENTRIES',
+  'GET_SUMMARIES',
+  'GET_FULL_HEADERS',
+  'REFRESH_INTERVAL',
+  'OAUTH_SERVICE_NAME',
+  'OAUTH_USE_TOKEN',
+  'OAUTH_TOKEN_NAME',
+  'OAUTH_REQUEST_TOKEN',
+  'OAUTH_REQUEST_TOKEN_SECRET',
+  'OAUTH_RECEIVED_CALLBACK'
 ]);
 
 /**
  * @const
  */
 gadgets.io.MethodType = gadgets.util.makeEnum([
-  "GET", "POST", "PUT", "DELETE", "HEAD"
+  'GET', 'POST', 'PUT', 'DELETE', 'HEAD'
 ]);
 
 /**
  * @const
  */
 gadgets.io.ContentType = gadgets.util.makeEnum([
-  "TEXT", "DOM", "JSON", "FEED"
+  'TEXT', 'DOM', 'JSON', 'FEED'
 ]);
 
 /**
  * @const
  */
 gadgets.io.AuthorizationType = gadgets.util.makeEnum([
-  "NONE", "SIGNED", "OAUTH"
+  'NONE', 'SIGNED', 'OAUTH'
 ]);

Modified: shindig/trunk/features/src/main/javascript/features/core.json/json.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.json/json.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.json/json.js (original)
+++ shindig/trunk/features/src/main/javascript/features/core.json/json.js Wed Sep 15 01:39:49 2010
@@ -66,12 +66,12 @@ if (window.JSON && window.JSON.parse && 
     };
   })();
 } else {
-/**
+  /**
  * Port of the public domain JSON library by Douglas Crockford.
  * See: http://www.json.org/json2.js
  */
-  gadgets['json'] = function () {
-  
+  gadgets['json'] = function() {
+
     /**
      * Formats integers to 2 digits.
      * @param {number} n
@@ -80,16 +80,16 @@ if (window.JSON && window.JSON.parse && 
     function f(n) {
       return n < 10 ? '0' + n : n;
     }
-  
-    Date.prototype.toJSON = function () {
+
+    Date.prototype.toJSON = function() {
       return [this.getUTCFullYear(), '-',
-             f(this.getUTCMonth() + 1), '-',
-             f(this.getUTCDate()), 'T',
-             f(this.getUTCHours()), ':',
-             f(this.getUTCMinutes()), ':',
-             f(this.getUTCSeconds()), 'Z'].join("");
+        f(this.getUTCMonth() + 1), '-',
+        f(this.getUTCDate()), 'T',
+        f(this.getUTCHours()), ':',
+        f(this.getUTCMinutes()), ':',
+        f(this.getUTCSeconds()), 'Z'].join('');
     };
-  
+
     // table of character substitutions
     /**
      * @const
@@ -104,7 +104,7 @@ if (window.JSON && window.JSON.parse && 
       '"' : '\\"',
       '\\': '\\\\'
     };
-  
+
     /**
      * Converts a json object into a string.
      * @param {*} value
@@ -118,90 +118,90 @@ if (window.JSON && window.JSON.parse && 
           l,          // Length.
           r = /["\\\x00-\x1f\x7f-\x9f]/g,
           v;          // The member value.
-  
+
       switch (typeof value) {
-      case 'string':
-      // If the string contains no control characters, no quote characters, and no
-      // backslash characters, then we can safely slap some quotes around it.
-      // Otherwise we must also replace the offending characters with safe ones.
-        return r.test(value) ?
-            '"' + value.replace(r, function (a) {
-              var c = m[a];
-              if (c) {
-                return c;
-              }
-              c = a.charCodeAt();
-              return '\\u00' + Math.floor(c / 16).toString(16) +
-                  (c % 16).toString(16);
+        case 'string':
+          // If the string contains no control characters, no quote characters, and no
+          // backslash characters, then we can safely slap some quotes around it.
+          // Otherwise we must also replace the offending characters with safe ones.
+          return r.test(value) ?
+              '"' + value.replace(r, function(a) {
+                var c = m[a];
+                if (c) {
+                  return c;
+                }
+                c = a.charCodeAt();
+                return '\\u00' + Math.floor(c / 16).toString(16) +
+                   (c % 16).toString(16);
               }) + '"' : '"' + value + '"';
-      case 'number':
-      // JSON numbers must be finite. Encode non-finite numbers as null.
-        return isFinite(value) ? String(value) : 'null';
-      case 'boolean':
-      case 'null':
-        return String(value);
-      case 'object':
-      // Due to a specification blunder in ECMAScript,
-      // typeof null is 'object', so watch out for that case.
-        if (!value) {
-          return 'null';
-        }
-        // toJSON check removed; re-implement when it doesn't break other libs.
-        a = [];
-        if (typeof value.length === 'number' &&
-            !value.propertyIsEnumerable('length')) {
-          // The object is an array. Stringify every element. Use null as a
-          // placeholder for non-JSON values.
-          l = value.length;
-          for (i = 0; i < l; i += 1) {
-            a.push(stringify(value[i]) || 'null');
+        case 'number':
+          // JSON numbers must be finite. Encode non-finite numbers as null.
+          return isFinite(value) ? String(value) : 'null';
+        case 'boolean':
+        case 'null':
+          return String(value);
+        case 'object':
+          // Due to a specification blunder in ECMAScript,
+          // typeof null is 'object', so watch out for that case.
+          if (!value) {
+            return 'null';
           }
-          // Join all of the elements together and wrap them in brackets.
-          return '[' + a.join(',') + ']';
-        }
-        // Otherwise, iterate through all of the keys in the object.
-        for (k in value) {
-          if (k.match('___$'))
-            continue;
-          if (value.hasOwnProperty(k)) {
-            if (typeof k === 'string') {
-              v = stringify(value[k]);
-              if (v) {
-                a.push(stringify(k) + ':' + v);
+          // toJSON check removed; re-implement when it doesn't break other libs.
+          a = [];
+          if (typeof value.length === 'number' &&
+              !value.propertyIsEnumerable('length')) {
+            // The object is an array. Stringify every element. Use null as a
+            // placeholder for non-JSON values.
+            l = value.length;
+            for (i = 0; i < l; i += 1) {
+              a.push(stringify(value[i]) || 'null');
+            }
+            // Join all of the elements together and wrap them in brackets.
+            return '[' + a.join(',') + ']';
+          }
+          // Otherwise, iterate through all of the keys in the object.
+          for (k in value) {
+            if (k.match('___$'))
+              continue;
+            if (value.hasOwnProperty(k)) {
+              if (typeof k === 'string') {
+                v = stringify(value[k]);
+                if (v) {
+                  a.push(stringify(k) + ':' + v);
+                }
               }
             }
           }
-        }
-        // Join all of the member texts together and wrap them in braces.
-        return '{' + a.join(',') + '}';
+          // Join all of the member texts together and wrap them in braces.
+          return '{' + a.join(',') + '}';
       }
-      return "undefined";
+      return 'undefined';
     }
-  
+
     return {
       'stringify': stringify,
-      'parse': function (text) {
-      // Parsing happens in three stages. In the first stage, we run the text against
-      // regular expressions that look for non-JSON patterns. We are especially
-      // concerned with '()' and 'new' because they can cause invocation, and '='
-      // because it can cause mutation. But just to be safe, we want to reject all
-      // unexpected forms.
-      
-      // We split the first stage into 4 regexp operations in order to work around
-      // crippling inefficiencies in IE's and Safari's regexp engines. First we
-      // replace all backslash pairs with '@' (a non-JSON character). Second, we
-      // replace all simple value tokens with ']' characters. Third, we delete all
-      // open brackets that follow a colon or comma or that begin the text. Finally,
-      // we look to see that the remaining characters are only whitespace or ']' or
-      // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
-  
+      'parse': function(text) {
+        // Parsing happens in three stages. In the first stage, we run the text against
+        // regular expressions that look for non-JSON patterns. We are especially
+        // concerned with '()' and 'new' because they can cause invocation, and '='
+        // because it can cause mutation. But just to be safe, we want to reject all
+        // unexpected forms.
+
+        // We split the first stage into 4 regexp operations in order to work around
+        // crippling inefficiencies in IE's and Safari's regexp engines. First we
+        // replace all backslash pairs with '@' (a non-JSON character). Second, we
+        // replace all simple value tokens with ']' characters. Third, we delete all
+        // open brackets that follow a colon or comma or that begin the text. Finally,
+        // we look to see that the remaining characters are only whitespace or ']' or
+        // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
+
         if (/^[\],:{}\s]*$/.test(text.replace(/\\["\\\/b-u]/g, '@').
             replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
             replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
           return eval('(' + text + ')');
         }
         // If the text is not JSON parseable, then return false.
-  
+
         return false;
       }
     };
@@ -209,10 +209,10 @@ if (window.JSON && window.JSON.parse && 
 }
 /**
  * Flatten an object to a stringified values. Useful for dealing with
- * json->querystring transformations. 
- * 
+ * json->querystring transformations.
+ *
  * @param obj {Object}
- * @return {Object} object with only string values
+ * @return {Object} object with only string values.
  * @private not in official specification yet
  */
 
@@ -231,4 +231,4 @@ gadgets['json'].flatten = function(obj) 
     }
   }
   return flat;
-}
+};

Modified: shindig/trunk/features/src/main/javascript/features/core.json/taming.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.json/taming.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.json/taming.js (original)
+++ shindig/trunk/features/src/main/javascript/features/core.json/taming.js Wed Sep 15 01:39:49 2010
@@ -23,6 +23,6 @@
  */
 var tamings___ = tamings___ || [];
 tamings___.push(function(imports) {
-    ___.tamesTo(gadgets.json.stringify, safeJSON.stringify);
-    ___.tamesTo(gadgets.json.parse, safeJSON.parse);
+  ___.tamesTo(gadgets.json.stringify, safeJSON.stringify);
+  ___.tamesTo(gadgets.json.parse, safeJSON.parse);
 });

Modified: shindig/trunk/features/src/main/javascript/features/core.legacy/legacy.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.legacy/legacy.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.legacy/legacy.js (original)
+++ shindig/trunk/features/src/main/javascript/features/core.legacy/legacy.js Wed Sep 15 01:39:49 2010
@@ -41,13 +41,13 @@ var _IG_Prefs = (function() {
     return instance;
   };
 
- _IG_Prefs._parseURL = gadgets.Prefs.parseUrl;
+  _IG_Prefs._parseURL = gadgets.Prefs.parseUrl;
 
   return _IG_Prefs;
 })();
 
 function _IG_Fetch_wrapper(callback, obj) {
-  callback(obj.data ? obj.data : "");
+  callback(obj.data ? obj.data : '');
 }
 
 /**
@@ -84,7 +84,7 @@ function _IG_FetchXmlContent(url, callba
   } else {
     params['REFRESH_INTERVAL'] = 3600;
   }
-  params.CONTENT_TYPE = "DOM";
+  params.CONTENT_TYPE = 'DOM';
   var cb = gadgets.util.makeClosure(null, _IG_Fetch_wrapper, callback);
   gadgets.io.makeRequest(url, cb, params);
 }
@@ -96,7 +96,7 @@ function _IG_FetchXmlContent(url, callba
 function _IG_FetchFeedAsJSON(url, callback, numItems, getDescriptions,
                              opt_params) {
   var params = opt_params || {};
-  params.CONTENT_TYPE = "FEED";
+  params.CONTENT_TYPE = 'FEED';
   params.NUM_ENTRIES = numItems;
   params.GET_SUMMARIES = getDescriptions;
   gadgets.io.makeRequest(url,
@@ -179,7 +179,7 @@ function _IG_RegisterOnloadHandler(callb
   gadgets.util.registerOnLoadHandler(callback);
 }
 
-/** 
+/**
  * _IG_Callback takes the arguments in the scope the callback is executed and
  * places them first in the argument array. MakeClosure takes the arguments
  * from the scope at callback construction and pushes them first in the array
@@ -192,7 +192,7 @@ function _IG_Callback(handler_func, var_
     var combined_args = Array.prototype.slice.call(arguments);
     // call the handler with all args combined
     handler_func.apply(null,
-      combined_args.concat(Array.prototype.slice.call(orig_args, 1)));
+        combined_args.concat(Array.prototype.slice.call(orig_args, 1)));
   };
 }
 
@@ -220,7 +220,7 @@ function _gel(el) {
  * @deprecated
  */
 function _gelstn(tag) {
-  if (tag === "*" && document.all) {
+  if (tag === '*' && document.all) {
     return document.all;
   }
   return document.getElementsByTagName ?
@@ -286,7 +286,7 @@ function _hesc(str) {
  * @deprecated
  */
 function _striptags(str) {
-  return str.replace(/<\/?[^>]+>/g, "");
+  return str.replace(/<\/?[^>]+>/g, '');
 }
 
 /**
@@ -297,7 +297,7 @@ function _striptags(str) {
  * @deprecated
  */
 function _trim(str) {
-  return str.replace(/^\s+|\s+$/g, "");
+  return str.replace(/^\s+|\s+$/g, '');
 }
 
 /**
@@ -307,12 +307,12 @@ function _trim(str) {
  * @deprecated
  */
 function _toggle(el) {
-  el = (typeof el === "string") ? _gel(el) : el;
+  el = (typeof el === 'string') ? _gel(el) : el;
   if (el !== null) {
-    if (el.style.display.length === 0 || el.style.display === "block") {
-      el.style.display = "none";
-    } else if (el.style.display === "none") {
-      el.style.display = "block";
+    if (el.style.display.length === 0 || el.style.display === 'block') {
+      el.style.display = 'none';
+    } else if (el.style.display === 'none') {
+      el.style.display = 'block';
     }
   }
 }
@@ -328,7 +328,7 @@ var _uid = (function() {
    * @return {number} a unique number.
    * @deprecated
    */
-  return function () {
+  return function() {
     return _legacy_uidCounter++;
   };
 })();
@@ -360,7 +360,7 @@ function _max(a, b) {
  */
 function _exportSymbols(name, sym) {
   var attach = window;
-  var parts = name.split(".");
+  var parts = name.split('.');
   for (var i = 0, j = parts.length; i < j; i++) {
     var part = parts[i];
     attach[part] = attach[part] || {};
@@ -376,9 +376,9 @@ function _exportSymbols(name, sym) {
  * @param {Object} src
  * @param {string} etype
  * @param {function} func
- * TODO - implement
+ * TODO - implement.
  */
 function _IG_AddDOMEventHandler(src, etype, func) {
-  gadgets.warn("_IG_AddDOMEventHandler not implemented - see SHINDIG-198");
+  gadgets.warn('_IG_AddDOMEventHandler not implemented - see SHINDIG-198');
 }
 

Modified: shindig/trunk/features/src/main/javascript/features/core.log/log.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.log/log.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.log/log.js (original)
+++ shindig/trunk/features/src/main/javascript/features/core.log/log.js Wed Sep 15 01:39:49 2010
@@ -37,118 +37,118 @@
  */
 
 gadgets['log'] = (function() {
-   /** @const */
-   var info_=1;
-   /** @const */
-   var warning_=2;
-   /** @const */
-   var error_=3;
-   /** @const */
-   var none_=4;
+  /** @const */
+  var info_ = 1;
+  /** @const */
+  var warning_ = 2;
+  /** @const */
+  var error_ = 3;
+  /** @const */
+  var none_ = 4;
 
-/**
+  /**
  * Log an informational message
- * @param {Object} message - the message to log
+ * @param {Object} message - the message to log.
  * @member gadgets
  * @name log
  * @function
  */
-var log = function(message) {
-  logAtLevel(info_, message);
-};
- 
-/**
+  var log = function(message) {
+    logAtLevel(info_, message);
+  };
+
+  /**
  * Log a warning
- * @param {Object} message - the message to log
- * @static 
+ * @param {Object} message - the message to log.
+ * @static
  */
-gadgets.warn = function(message) {
-  logAtLevel(warning_, message);
-};
+  gadgets.warn = function(message) {
+    logAtLevel(warning_, message);
+  };
 
-/**
+  /**
  * Log an error
- * @param {Object} message - The message to log
- * @static 
+ * @param {Object} message - The message to log.
+ * @static
  */
-gadgets.error = function(message) {
-  logAtLevel(error_, message);
-};
+  gadgets.error = function(message) {
+    logAtLevel(error_, message);
+  };
 
-/**
+  /**
  * Sets the log level threshold.
  * @param {number} logLevel - New log level threshold.
  * @static
  * @member gadgets.log
  * @name setLogLevel
  */
-gadgets['setLogLevel'] = function(logLevel) {
-  logLevelThreshold_ = logLevel;
-};
+  gadgets['setLogLevel'] = function(logLevel) {
+    logLevelThreshold_ = logLevel;
+  };
 
-/**
+  /**
  * Logs a log message if output console is available, and log threshold is met.
  * @param {number} level - the level to log with. Optional, defaults to gadgets.log.INFO.
- * @param {Object} message - The message to log
+ * @param {Object} message - The message to log.
  * @private
  */
- function logAtLevel(level, message) {
-  if (level < logLevelThreshold_ || !_console) {
-    return;
-  }
-
-  if (level === warning_ && _console.warn) {
-    _console.warn(message);
-  } else if (level === error_ && _console.error) {
-    _console.error(message);
-  } else if (_console.log) {
-    _console.log(message);
-  }
-};
+  function logAtLevel(level, message) {
+    if (level < logLevelThreshold_ || !_console) {
+      return;
+    }
+
+    if (level === warning_ && _console.warn) {
+      _console.warn(message);
+    } else if (level === error_ && _console.error) {
+      _console.error(message);
+    } else if (_console.log) {
+      _console.log(message);
+    }
+  };
 
-/**
+  /**
  * Log level for informational logging.
  * @static
  * @const
  * @member gadgets.log
  * @name INFO
  */
-log['INFO'] = info_;
+  log['INFO'] = info_;
 
-/**
+  /**
  * Log level for warning logging.
  * @static
  * @const
  * @member gadgets.log
  * @name WARNING
  */
-log['WARNING'] = warning_;
+  log['WARNING'] = warning_;
 
-/**
+  /**
  * Log level for no logging
  * @static
  * @const
  * @member gadgets.log
  * @name NONE
  */
-log['NONE'] = none_;
+  log['NONE'] = none_;
 
-/**
+  /**
  * Current log level threshold.
  * @type {number}
  * @private
  */
-var logLevelThreshold_ = info_;
+  var logLevelThreshold_ = info_;
 
 
 
-/**
+  /**
  * Console to log to
  * @private
  * @static
  */
-var _console = window.console ? window.console :
-                       window.opera   ? window.opera.postError : undefined;
+  var _console = window.console ? window.console :
+                       window.opera ? window.opera.postError : undefined;
 
-   return log; 
+  return log;
 })();

Modified: shindig/trunk/features/src/main/javascript/features/core.prefs/prefs.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.prefs/prefs.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.prefs/prefs.js (original)
+++ shindig/trunk/features/src/main/javascript/features/core.prefs/prefs.js Wed Sep 15 01:39:49 2010
@@ -44,49 +44,49 @@
 
 (function() {
 
-var instance = null;
-var prefs = {};
-var esc = gadgets.util.escapeString;
-var messages = {};
-var defaultPrefs = {};
-var language = "en";
-var country = "US";
-var moduleId = 0;
+  var instance = null;
+  var prefs = {};
+  var esc = gadgets.util.escapeString;
+  var messages = {};
+  var defaultPrefs = {};
+  var language = 'en';
+  var country = 'US';
+  var moduleId = 0;
 
-/**
+  /**
  * Parses all parameters from the url and stores them
  * for later use when creating a new gadgets.Prefs object.
  */
-function parseUrl() {
-  var params = gadgets.util.getUrlParameters();
-  for (var i in params) {
-    if (params.hasOwnProperty(i)) {
-      if (i.indexOf("up_") === 0 && i.length > 3) {
-        prefs[i.substr(3)] = String(params[i]);
-      } else if (i === "country") {
-        country = params[i];
-      } else if (i === "lang") {
-        language = params[i];
-      } else if (i === "mid") {
-        moduleId = params[i];
+  function parseUrl() {
+    var params = gadgets.util.getUrlParameters();
+    for (var i in params) {
+      if (params.hasOwnProperty(i)) {
+        if (i.indexOf('up_') === 0 && i.length > 3) {
+          prefs[i.substr(3)] = String(params[i]);
+        } else if (i === 'country') {
+          country = params[i];
+        } else if (i === 'lang') {
+          language = params[i];
+        } else if (i === 'mid') {
+          moduleId = params[i];
+        }
       }
     }
   }
-}
 
-/**
+  /**
  * Sets default pref values for values left unspecified in the
  * rendering call, but with default_value provided in the spec.
  */
-function mergeDefaults() {
-  for (var name in defaultPrefs) {
-    if (typeof prefs[name] === 'undefined') {
-      prefs[name] = defaultPrefs[name];
+  function mergeDefaults() {
+    for (var name in defaultPrefs) {
+      if (typeof prefs[name] === 'undefined') {
+        prefs[name] = defaultPrefs[name];
+      }
     }
   }
-}
 
-/**
+  /**
  * @class
  * Provides access to user preferences, module dimensions, and messages.
  *
@@ -104,108 +104,108 @@ var lang = prefs.getLang();</pre>
  * simple answer is that it's how the spec is written. The spec is written this
  * way for legacy compatibility with igoogle.
  */
-gadgets.Prefs = function() {
-  if (!instance) {
-    parseUrl();
-    mergeDefaults();
-    instance = this;
-  }
-  return instance;
-};
+  gadgets.Prefs = function() {
+    if (!instance) {
+      parseUrl();
+      mergeDefaults();
+      instance = this;
+    }
+    return instance;
+  };
 
-/**
+  /**
  * Sets internal values
  * @return {boolean} True if the prefs is modified.
  */
-gadgets.Prefs.setInternal_ = function(key, value) {
-  var wasModified = false;
-  if (typeof key === "string") {
-    if (!prefs.hasOwnProperty(key) || prefs[key] !== value) {
-      wasModified = true;
-    }
-    prefs[key] = value;
-  } else {
-    for (var k in key) {
-      if (key.hasOwnProperty(k)) {
-        var v = key[k];
-        if (!prefs.hasOwnProperty(k) || prefs[k] !== v) {
-          wasModified = true;
+  gadgets.Prefs.setInternal_ = function(key, value) {
+    var wasModified = false;
+    if (typeof key === 'string') {
+      if (!prefs.hasOwnProperty(key) || prefs[key] !== value) {
+        wasModified = true;
+      }
+      prefs[key] = value;
+    } else {
+      for (var k in key) {
+        if (key.hasOwnProperty(k)) {
+          var v = key[k];
+          if (!prefs.hasOwnProperty(k) || prefs[k] !== v) {
+            wasModified = true;
+          }
+          prefs[k] = v;
         }
-        prefs[k] = v;
       }
     }
-  }
-  return wasModified;
-};
+    return wasModified;
+  };
 
-/**
+  /**
  * Initializes message bundles.
  */
-gadgets.Prefs.setMessages_ = function(msgs) {
-  messages = msgs;
-};
+  gadgets.Prefs.setMessages_ = function(msgs) {
+    messages = msgs;
+  };
 
-/**
+  /**
  * Initializes default user prefs values.
  */
-gadgets.Prefs.setDefaultPrefs_ = function(defprefs) {
-  defaultPrefs = defprefs;
-};
+  gadgets.Prefs.setDefaultPrefs_ = function(defprefs) {
+    defaultPrefs = defprefs;
+  };
 
-/**
+  /**
  * Retrieves a preference as a string.
  * Returned value will be html entity escaped.
  *
- * @param {string} key The preference to fetch
- * @return {string} The preference; if not set, an empty string
+ * @param {string} key The preference to fetch.
+ * @return {string} The preference; if not set, an empty string.
  */
-gadgets.Prefs.prototype.getString = function(key) {
-  if (key === ".lang") { key = "lang"; }
-  return prefs[key] ? esc(prefs[key]) : "";
-};
+  gadgets.Prefs.prototype.getString = function(key) {
+    if (key === '.lang') { key = 'lang'; }
+    return prefs[key] ? esc(prefs[key]) : '';
+  };
 
-/*
+  /*
  * Indicates not to escape string values when retrieving them.
  * This is an internal detail used by _IG_Prefs for backward compatibility.
  */
-gadgets.Prefs.prototype.setDontEscape_ = function() {
-  esc = function(k) { return k; };
-};
+  gadgets.Prefs.prototype.setDontEscape_ = function() {
+    esc = function(k) { return k; };
+  };
 
-/**
+  /**
  * Retrieves a preference as an integer.
- * @param {string} key The preference to fetch
- * @return {number} The preference; if not set, 0
+ * @param {string} key The preference to fetch.
+ * @return {number} The preference; if not set, 0.
  */
-gadgets.Prefs.prototype.getInt = function(key) {
-  var val = parseInt(prefs[key], 10);
-  return isNaN(val) ? 0 : val;
-};
+  gadgets.Prefs.prototype.getInt = function(key) {
+    var val = parseInt(prefs[key], 10);
+    return isNaN(val) ? 0 : val;
+  };
 
-/**
+  /**
  * Retrieves a preference as a floating-point value.
- * @param {string} key The preference to fetch
- * @return {number} The preference; if not set, 0
+ * @param {string} key The preference to fetch.
+ * @return {number} The preference; if not set, 0.
  */
-gadgets.Prefs.prototype.getFloat = function(key) {
-  var val = parseFloat(prefs[key]);
-  return isNaN(val) ? 0 : val;
-};
+  gadgets.Prefs.prototype.getFloat = function(key) {
+    var val = parseFloat(prefs[key]);
+    return isNaN(val) ? 0 : val;
+  };
 
-/**
+  /**
  * Retrieves a preference as a boolean.
- * @param {string} key The preference to fetch
- * @return {boolean} The preference; if not set, false
+ * @param {string} key The preference to fetch.
+ * @return {boolean} The preference; if not set, false.
  */
-gadgets.Prefs.prototype.getBool = function(key) {
-  var val = prefs[key];
-  if (val) {
-    return val === "true" || val === true || !!parseInt(val, 10);
-  }
-  return false;
-};
+  gadgets.Prefs.prototype.getBool = function(key) {
+    var val = prefs[key];
+    if (val) {
+      return val === 'true' || val === true || !!parseInt(val, 10);
+    }
+    return false;
+  };
 
-/**
+  /**
  * Stores a preference.
  * To use this call,
  * the gadget must require the feature setprefs.
@@ -216,81 +216,81 @@ gadgets.Prefs.prototype.getBool = functi
  * this call.
  * </p>
  *
- * @param {string} key The pref to store
- * @param {Object} val The values to store
+ * @param {string} key The pref to store.
+ * @param {Object} val The values to store.
  */
-gadgets.Prefs.prototype.set = function(key, value) {
-  throw new Error("setprefs feature required to make this call.");
-};
+  gadgets.Prefs.prototype.set = function(key, value) {
+    throw new Error('setprefs feature required to make this call.');
+  };
 
-/**
+  /**
  * Retrieves a preference as an array.
  * UserPref values that were not declared as lists are treated as
  * one-element arrays.
  *
- * @param {string} key The preference to fetch
- * @return {Array.<string>} The preference; if not set, an empty array
+ * @param {string} key The preference to fetch.
+ * @return {Array.<string>} The preference; if not set, an empty array.
  */
-gadgets.Prefs.prototype.getArray = function(key) {
-  var val = prefs[key];
-  if (val) {
-    var arr = val.split("|");
-    // Decode pipe characters.
-    for (var i = 0, j = arr.length; i < j; ++i) {
-      arr[i] = esc(arr[i].replace(/%7C/g, "|"));
+  gadgets.Prefs.prototype.getArray = function(key) {
+    var val = prefs[key];
+    if (val) {
+      var arr = val.split('|');
+      // Decode pipe characters.
+      for (var i = 0, j = arr.length; i < j; ++i) {
+        arr[i] = esc(arr[i].replace(/%7C/g, '|'));
+      }
+      return arr;
     }
-    return arr;
-  }
-  return [];
-};
+    return [];
+  };
 
-/**
+  /**
  * Stores an array preference.
  * To use this call,
  * the gadget must require the feature setprefs.
  *
- * @param {string} key The pref to store
- * @param {Array} val The values to store
+ * @param {string} key The pref to store.
+ * @param {Array} val The values to store.
  */
-gadgets.Prefs.prototype.setArray = function(key, val) {
-  throw new Error("setprefs feature required to make this call.");
-};
+  gadgets.Prefs.prototype.setArray = function(key, val) {
+    throw new Error('setprefs feature required to make this call.');
+  };
 
-/**
+  /**
  * Fetches an unformatted message.
- * @param {string} key The message to fetch
- * @return {string} The message
+ * @param {string} key The message to fetch.
+ * @return {string} The message.
  */
-gadgets.Prefs.prototype.getMsg = function(key) {
-  return messages[key] || "";
-};
+  gadgets.Prefs.prototype.getMsg = function(key) {
+    return messages[key] || '';
+  };
 
-/**
+  /**
  * Gets the current country, returned as ISO 3166-1 alpha-2 code.
  *
- * @return {string} The country for this module instance
+ * @return {string} The country for this module instance.
  */
-gadgets.Prefs.prototype.getCountry = function() {
-  return country;
-};
+  gadgets.Prefs.prototype.getCountry = function() {
+    return country;
+  };
 
-/**
+  /**
  * Gets the current language the gadget should use when rendering, returned as a
  * ISO 639-1 language code.
  *
- * @return {string} The language for this module instance
+ * @return {string} The language for this module instance.
  */
-gadgets.Prefs.prototype.getLang = function() {
-  return language;
-};
+  gadgets.Prefs.prototype.getLang = function() {
+    return language;
+  };
 
-/**
+  /**
  * Gets the module id for the current instance.
  *
- * @return {string | number} The module id for this module instance
+ * @return {string | number} The module id for this module instance.
  */
-gadgets.Prefs.prototype.getModuleId = function() {
-  return moduleId;
-};
+  gadgets.Prefs.prototype.getModuleId = function() {
+    return moduleId;
+  };
 
 })();

Modified: shindig/trunk/features/src/main/javascript/features/core.prefs/taming.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.prefs/taming.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.prefs/taming.js (original)
+++ shindig/trunk/features/src/main/javascript/features/core.prefs/taming.js Wed Sep 15 01:39:49 2010
@@ -24,7 +24,7 @@
 var tamings___ = tamings___ || [];
 tamings___.push(function(imports) {
   caja___.whitelistCtors([
-      [gadgets, 'Prefs', Object]
+    [gadgets, 'Prefs', Object]
   ]);
   caja___.whitelistMeths([
     [gadgets.Prefs, 'getArray'],

Modified: shindig/trunk/features/src/main/javascript/features/core.util/util.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.util/util.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.util/util.js (original)
+++ shindig/trunk/features/src/main/javascript/features/core.util/util.js Wed Sep 15 01:39:49 2010
@@ -30,23 +30,23 @@
 gadgets['util'] = function() {
   /**
    * Parses URL parameters into an object.
-   * @param {string} url - the url parameters to parse
-   * @return {Array.<string>} The parameters as an array
+   * @param {string} url - the url parameters to parse.
+   * @return {Array.<string>} The parameters as an array.
    */
   function parseUrlParams(url) {
     // Get settings from url, 'hash' takes precedence over 'search' component
     // don't use document.location.hash due to browser differences.
     var query;
-    var queryIdx = url.indexOf("?");
-    var hashIdx = url.indexOf("#");
+    var queryIdx = url.indexOf('?');
+    var hashIdx = url.indexOf('#');
     if (hashIdx === -1) {
       query = url.substr(queryIdx + 1);
     } else {
       // essentially replaces "#" with "&"
-      query = [url.substr(queryIdx + 1, hashIdx - queryIdx - 1), "&",
-               url.substr(hashIdx + 1)].join("");
+      query = [url.substr(queryIdx + 1, hashIdx - queryIdx - 1), '&',
+               url.substr(hashIdx + 1)].join('');
     }
-    return query.split("&");
+    return query.split('&');
   }
 
   var parameters = null;
@@ -62,35 +62,35 @@ gadgets['util'] = function() {
    * If the value is "false", the character is removed entirely, otherwise
    * it will be replaced with an html entity.
    */
-  
+
   var escapeCodePoints = {
-   // nul; most browsers truncate because they use c strings under the covers.
-   0 : false,
-   // new line
-   10 : true,
-   // carriage return
-   13 : true,
-   // double quote
-   34 : true,
-   // single quote
-   39 : true,
-   // less than
-   60 : true,
-   // greater than
-   62 : true,
-   // Backslash
-   92 : true,
-   // line separator
-   8232 : true,
-   // paragraph separator
-   8233 : true
+    // nul; most browsers truncate because they use c strings under the covers.
+    0 : false,
+    // new line
+    10 : true,
+    // carriage return
+    13 : true,
+    // double quote
+    34 : true,
+    // single quote
+    39 : true,
+    // less than
+    60 : true,
+    // greater than
+    62 : true,
+    // Backslash
+    92 : true,
+    // line separator
+    8232 : true,
+    // paragraph separator
+    8233 : true
   };
 
   /**
    * Regular expression callback that returns strings from unicode code points.
    *
-   * @param {Array} match Ignored
-   * @param {number} value The codepoint value to convert
+   * @param {Array} match Ignored.
+   * @param {number} value The codepoint value to convert.
    * @return {string} The character corresponding to value.
    */
   function unescapeEntity(match, value) {
@@ -101,10 +101,10 @@ gadgets['util'] = function() {
    * Initializes feature parameters.
    */
   function init(config) {
-    features = config["core.util"] || {};
+    features = config['core.util'] || {};
   }
   if (gadgets.config) {
-    gadgets.config.register("core.util", null, init);
+    gadgets.config.register('core.util', null, init);
   }
 
   return /** @scope gadgets.util */ {
@@ -114,12 +114,12 @@ gadgets['util'] = function() {
      *
      * @param {string=} opt_url Optional URL whose parameters to parse.
      *                         Defaults to window's current URL.
-     * @return {Object} Parameters passed into the query string
+     * @return {Object} Parameters passed into the query string.
      * @member gadgets.util
      * @private Implementation detail.
      */
-    'getUrlParameters' : function (opt_url) {
-      var no_opt_url = typeof opt_url === "undefined";
+    'getUrlParameters' : function(opt_url) {
+      var no_opt_url = typeof opt_url === 'undefined';
       if (parameters !== null && no_opt_url) {
         // "parameters" is a cache of current window params only.
         return parameters;
@@ -137,7 +137,7 @@ gadgets['util'] = function() {
         // difference to IG_Prefs, is that args doesn't replace spaces in
         // argname. Unclear on if it should do:
         // argname = argname.replace(/\+/g, " ");
-        value = value.replace(/\+/g, " ");
+        value = value.replace(/\+/g, ' ');
         parsed[argName] = unesc(value);
       }
       if (no_opt_url) {
@@ -155,19 +155,19 @@ gadgets['util'] = function() {
      *
      * @param {Object} scope The execution scope; may be null if there is no
      *     need to associate a specific instance of an object with this
-     *     callback
+     *     callback.
      * @param {function(Object,Object)} callback The callback to invoke when this is run;
-     *     any arguments passed in will be passed after your initial arguments
-     * @param {Object} var_args Initial arguments to be passed to the callback
+     *     any arguments passed in will be passed after your initial arguments.
+     * @param {Object} var_args Initial arguments to be passed to the callback.
      *
      * @member gadgets.util
      * @private Implementation detail.
      */
-    'makeClosure' : function (scope, callback, var_args) {
+    'makeClosure' : function(scope, callback, var_args) {
       // arguments isn't a real array, so we copy it into one.
       var baseArgs = [];
       for (var i = 2, j = arguments.length; i < j; ++i) {
-       baseArgs.push(arguments[i]);
+        baseArgs.push(arguments[i]);
       }
       return function() {
         // append new arguments.
@@ -188,7 +188,7 @@ gadgets['util'] = function() {
      *
      * @private Implementation detail.
      */
-    'makeEnum' : function (values) {
+    'makeEnum' : function(values) {
       var i, v, obj = {};
       for (i = 0; (v = values[i]); ++i) {
         obj[v] = v;
@@ -199,46 +199,46 @@ gadgets['util'] = function() {
     /**
      * Gets the feature parameters.
      *
-     * @param {string} feature The feature to get parameters for
-     * @return {Object} The parameters for the given feature, or null
+     * @param {string} feature The feature to get parameters for.
+     * @return {Object} The parameters for the given feature, or null.
      *
      * @member gadgets.util
      */
-    'getFeatureParameters' : function (feature) {
-      return typeof features[feature] === "undefined" ? null : features[feature];
+    'getFeatureParameters' : function(feature) {
+      return typeof features[feature] === 'undefined' ? null : features[feature];
     },
 
     /**
      * Returns whether the current feature is supported.
      *
-     * @param {string} feature The feature to test for
-     * @return {boolean} True if the feature is supported
+     * @param {string} feature The feature to test for.
+     * @return {boolean} True if the feature is supported.
      *
      * @member gadgets.util
      */
-    'hasFeature' : function (feature) {
-      return typeof features[feature] !== "undefined";
+    'hasFeature' : function(feature) {
+      return typeof features[feature] !== 'undefined';
     },
-    
+
     /**
      * Returns the list of services supported by the server
      * serving this gadget.
      *
-     * @return {Object} List of Services that enumerate their methods
+     * @return {Object} List of Services that enumerate their methods.
      *
      * @member gadgets.util
      */
-    'getServices' : function () {
+    'getServices' : function() {
       return services;
     },
 
     /**
      * Registers an onload handler.
-     * @param {function()} callback The handler to run
+     * @param {function()} callback The handler to run.
      *
      * @member gadgets.util
      */
-    'registerOnLoadHandler' : function (callback) {
+    'registerOnLoadHandler' : function(callback) {
       onLoadHandlers.push(callback);
     },
 
@@ -246,7 +246,7 @@ gadgets['util'] = function() {
      * Runs all functions registered via registerOnLoadHandler.
      * @private Only to be used by the container, not gadgets.
      */
-    'runOnLoadHandlers' : function () {
+    'runOnLoadHandlers' : function() {
       for (var i = 0, j = onLoadHandlers.length; i < j; ++i) {
         onLoadHandlers[i]();
       }
@@ -263,21 +263,21 @@ gadgets['util'] = function() {
      * string to string map.
      * Otherwise, does not attempt to modify the input.
      *
-     * @param {Object} input The object to escape
+     * @param {Object} input The object to escape.
      * @param {boolean=} opt_escapeObjects Whether to escape objects.
-     * @return {Object} The escaped object
+     * @return {Object} The escaped object.
      * @private Only to be used by the container, not gadgets.
      */
     'escape' : function(input, opt_escapeObjects) {
       if (!input) {
         return input;
-      } else if (typeof input === "string") {
+      } else if (typeof input === 'string') {
         return gadgets.util.escapeString(input);
-      } else if (typeof input === "array") {
+      } else if (typeof input === 'array') {
         for (var i = 0, j = input.length; i < j; ++i) {
           input[i] = gadgets.util.escape(input[i]);
         }
-      } else if (typeof input === "object" && opt_escapeObjects) {
+      } else if (typeof input === 'object' && opt_escapeObjects) {
         var newObject = {};
         for (var field in input) {
           if (input.hasOwnProperty(field)) {
@@ -298,8 +298,8 @@ gadgets['util'] = function() {
      * TODO: Parsing the string would probably be more accurate and faster than
      * a bunch of regular expressions.
      *
-     * @param {string} str The string to escape
-     * @return {string} The escaped string
+     * @param {string} str The string to escape.
+     * @return {string} The escaped string.
      */
     'escapeString' : function(str) {
       if (!str) return str;
@@ -308,13 +308,13 @@ gadgets['util'] = function() {
         ch = str.charCodeAt(i);
         shouldEscape = escapeCodePoints[ch];
         if (shouldEscape === true) {
-          out.push("&#", ch, ";");
+          out.push('&#', ch, ';');
         } else if (shouldEscape !== false) {
           // undefined or null are OK.
           out.push(str.charAt(i));
         }
       }
-      return out.join("");
+      return out.join('');
     },
 
     /**
@@ -331,7 +331,7 @@ gadgets['util'] = function() {
 
     /**
      * Attach an event listener to given DOM element (Not a gadget standard)
-     * 
+     *
      * @param {Object} elem  DOM element on which to attach event.
      * @param {string} eventName  Event type to listen for.
      * @param {function()} callback  Invoked when specified event occurs.
@@ -343,13 +343,13 @@ gadgets['util'] = function() {
       } else if (typeof elem.attachEvent != 'undefined') {
         elem.attachEvent('on' + eventName, callback);
       } else {
-        gadgets.warn("cannot attachBrowserEvent: " + eventName);
+        gadgets.warn('cannot attachBrowserEvent: ' + eventName);
       }
     },
 
     /**
      * Remove event listener. (Shindig internal implementation only)
-     * 
+     *
      * @param {Object} elem  DOM element from which to remove event.
      * @param {string} eventName  Event type to remove.
      * @param {function()} callback  Listener to remove.
@@ -359,10 +359,10 @@ gadgets['util'] = function() {
     'removeBrowserEvent': function(elem, eventName, callback, useCapture) {
       if (elem.removeEventListener) {
         elem.removeEventListener(eventName, callback, useCapture);
-      } else if (elem.detachEvent){
+      } else if (elem.detachEvent) {
         elem.detachEvent('on' + eventName, callback);
       } else {
-        gadgets.warn("cannot removeBrowserEvent: " + eventName);
+        gadgets.warn('cannot removeBrowserEvent: ' + eventName);
       }
     }
   };

Modified: shindig/trunk/features/src/main/javascript/features/dynamic-height.util/dynamic-height-util.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/dynamic-height.util/dynamic-height-util.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/dynamic-height.util/dynamic-height-util.js (original)
+++ shindig/trunk/features/src/main/javascript/features/dynamic-height.util/dynamic-height-util.js Wed Sep 15 01:39:49 2010
@@ -30,7 +30,7 @@ gadgets.window = gadgets.window || {};
    * Detects the inner dimensions of a frame.
    * See: http://www.quirksmode.org/viewport/compatibility.html for more
    * information.
-   * @returns {Object} An object with width and height properties.
+   * @return {Object} An object with width and height properties.
    * @member gadgets.window
    */
   gadgets.window.getViewportDimensions = function() {

Modified: shindig/trunk/features/src/main/javascript/features/dynamic-height/dynamic-height.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/dynamic-height/dynamic-height.js?rev=997163&r1=997162&r2=997163&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/dynamic-height/dynamic-height.js (original)
+++ shindig/trunk/features/src/main/javascript/features/dynamic-height/dynamic-height.js Wed Sep 15 01:39:49 2010
@@ -40,11 +40,11 @@ gadgets.window = gadgets.window || {};
    *
    * @param {Element} elem the element with the attribute to look for.
    * @param {string} attr the CSS attribute name of interest.
-   * @returns {number} the value of the px attr of the elem.
+   * @return {number} the value of the px attr of the elem.
    * @private
    */
   function parseIntFromElemPxAttribute(elem, attr) {
-    var style = window.getComputedStyle(elem, "");
+    var style = window.getComputedStyle(elem, '');
     var value = style.getPropertyValue(attr);
     value.match(/^([0-9]+)/);
     return parseInt(RegExp.$1, 10);
@@ -58,12 +58,12 @@ gadgets.window = gadgets.window || {};
    * containing parent element. Not counting "float" elements may lead to
    * undercounting.
    *
-   * @returns {number} the height of the gadget.
+   * @return {number} the height of the gadget.
    * @private
    */
   function getHeightForWebkit() {
     var result = 0;
-    var queue = [ document.body ];
+    var queue = [document.body];
 
     while (queue.length > 0) {
       var elem = queue.shift();
@@ -75,18 +75,18 @@ gadgets.window = gadgets.window || {};
             typeof child.scrollHeight !== 'undefined') {
           // scrollHeight already accounts for border-bottom, padding-bottom.
           var bottom = child.offsetTop + child.scrollHeight +
-              parseIntFromElemPxAttribute(child, "margin-bottom");
+              parseIntFromElemPxAttribute(child, 'margin-bottom');
           result = Math.max(result, bottom);
         }
         queue.push(child);
       }
-    } 
+    }
 
     // Add border, padding and margin of the containing body.
     return result
-        + parseIntFromElemPxAttribute(document.body, "border-bottom")
-        + parseIntFromElemPxAttribute(document.body, "margin-bottom")
-        + parseIntFromElemPxAttribute(document.body, "padding-bottom");
+        + parseIntFromElemPxAttribute(document.body, 'border-bottom')
+        + parseIntFromElemPxAttribute(document.body, 'margin-bottom')
+        + parseIntFromElemPxAttribute(document.body, 'padding-bottom');
   }
 
   /**
@@ -125,7 +125,7 @@ gadgets.window = gadgets.window || {};
         // Based on studying the values output by different browsers,
         // use the value that's NOT equal to the viewport height found above.
         newHeight = docEl.scrollHeight !== vh ?
-                     docEl.scrollHeight : docEl.offsetHeight;
+            docEl.scrollHeight : docEl.offsetHeight;
       } else if (navigator.userAgent.indexOf('AppleWebKit') >= 0) {
         // In Webkit:
         // Property scrollHeight and offsetHeight will only increase in value.
@@ -166,7 +166,7 @@ gadgets.window = gadgets.window || {};
         !isNaN(newHeight) &&
         !(heightAutoCalculated && newHeight === 0)) {
       oldHeight = newHeight;
-      gadgets.rpc.call(null, "resize_iframe", null, newHeight);
+      gadgets.rpc.call(null, 'resize_iframe', null, newHeight);
     }
   };
 }());