You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by ss...@apache.org on 2012/01/08 20:25:28 UTC

svn commit: r1228927 - in /shindig/trunk: content/samplecontainer/examples/commoncontainer/ features/src/main/javascript/features/container.util/ features/src/main/javascript/features/core.io/ features/src/main/javascript/features/core.json/ features/s...

Author: ssievers
Date: Sun Jan  8 19:25:28 2012
New Revision: 1228927

URL: http://svn.apache.org/viewvc?rev=1228927&view=rev
Log:
Changing equality checks against undefined to typeof checks against 'undefined

Modified:
    shindig/trunk/content/samplecontainer/examples/commoncontainer/cconviews.js
    shindig/trunk/features/src/main/javascript/features/container.util/util.js
    shindig/trunk/features/src/main/javascript/features/core.io/io.js
    shindig/trunk/features/src/main/javascript/features/core.json/json-flatten.js
    shindig/trunk/features/src/main/javascript/features/i18n/datetimeparse.js
    shindig/trunk/features/src/main/javascript/features/open-views/viewenhancements-container.js
    shindig/trunk/features/src/main/javascript/features/shindig.container/shindig-container.js
    shindig/trunk/features/src/main/javascript/features/shindig.uri/uri.js
    shindig/trunk/features/src/test/javascript/features/osapi/batchtest.js

Modified: shindig/trunk/content/samplecontainer/examples/commoncontainer/cconviews.js
URL: http://svn.apache.org/viewvc/shindig/trunk/content/samplecontainer/examples/commoncontainer/cconviews.js?rev=1228927&r1=1228926&r2=1228927&view=diff
==============================================================================
--- shindig/trunk/content/samplecontainer/examples/commoncontainer/cconviews.js (original)
+++ shindig/trunk/content/samplecontainer/examples/commoncontainer/cconviews.js Sun Jan  8 19:25:28 2012
@@ -43,10 +43,10 @@ CommonContainer.views.createElementForGa
   var surfaceView = 'default';
   var viewTarget = 'default';
 
-  if (opt_view !== undefined) {
+  if (typeof opt_view != 'undefined') {
     surfaceView = opt_view;
   }
-  if (opt_viewTarget !== undefined) {
+  if (typeof opt_viewTarget != 'undefined') {
     viewTarget = opt_viewTarget;
   }
 
@@ -77,7 +77,7 @@ CommonContainer.views.createElementForGa
 CommonContainer.views.createElementForUrl = function(opt_viewTarget) {
   var viewTarget = 'dialog';
 
-  if (opt_viewTarget !== undefined) {
+  if (typeof opt_viewTarget != 'undefined') {
     viewTarget = opt_viewTarget;
   }
 
@@ -138,7 +138,7 @@ function openInDialog(modaldialog, view,
   var dialog = document.createElement('div');
   dialog.id = 'dialog_' + dialog_counter;
 
-  if (opt_gadgetMetadata !== undefined) {
+  if (typeof opt_gadgetMetadata != 'undefined') {
     // open gadget, get the title from gadgetMetadata
     dialog.title = opt_gadgetMetadata['modulePrefs'].title;
   }
@@ -246,7 +246,7 @@ function openInNewTab(gadgetMetadata) {
             // If there is gadget inside, close the gadget
             var iframes = $(this).parent().get(0)
             .getElementsByTagName('iframe');
-            if (iframes.lenth > 0 && iframes[0].id !== undefined) {
+            if (iframes.lenth > 0 && (typeof iframes[0].id != 'undefined')) {
               var site = CommonContainer
               .getGadgetSiteByIframeId_(iframes[0].id);
               CommonContainer.closeGadget(site);
@@ -292,8 +292,8 @@ function openInNewTab(gadgetMetadata) {
 
   // add new tab with new id and new title
   var tab_title = 'new tab ';
-  if (gadgetMetadata !== undefined &&
-          gadgetMetadata['modulePrefs'].title !== undefined) {
+  if ((typeof gadgetMetadata != 'undefined') &&
+          (typeof gadgetMetadata['modulePrefs'].title != 'undefined')) {
     // open gadget, get the title from gadgetMetadata
     tab_title = gadgetMetadata['modulePrefs'].title;
     if (tab_title.length > 7) {
@@ -302,7 +302,7 @@ function openInNewTab(gadgetMetadata) {
   }
   $tabs.tabs('add', '#tabs-' + tab_counter, tab_title);
 
-  if (gadgetMetadata !== undefined) {
+  if (typeof gadgetMetadata != 'undefined') {
     // rendering gadget's header
     var gadgetSiteId = 'gadget-site-' + newTabId;
     var gadgetTemplate = '<div class="portlet">' +
@@ -321,7 +321,7 @@ function openInNewTab(gadgetMetadata) {
   tab_counter++;
 
   // return the div
-  if (gadgetMetadata !== undefined) {
+  if (typeof gadgetMetadata != 'undefined') {
     return document.getElementById('gadget-site-' + newTabId);
   } else {
     return document.getElementById(tab_content_id);
@@ -343,7 +343,7 @@ function closeDialog(site) {
   if (site && site.getActiveGadgetHolder()) {
     // get iframe id
     iframeId = site.getActiveGadgetHolder().getIframeId();
-    if (iframeId !== undefined) {
+    if (typeof iframeId != 'undefined') {
       var iframeNode = document.getElementById(iframeId);
       // get dialog widget id
       widgetId = iframeNode.parentNode.id;

Modified: shindig/trunk/features/src/main/javascript/features/container.util/util.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/container.util/util.js?rev=1228927&r1=1228926&r2=1228927&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/container.util/util.js (original)
+++ shindig/trunk/features/src/main/javascript/features/container.util/util.js Sun Jan  8 19:25:28 2012
@@ -35,7 +35,7 @@ osapi.container.util = {};
  * @return {*} value of json at key, if valid. Otherwise, return defaultValue.
  */
 osapi.container.util.getSafeJsonValue = function(json, key, defaultValue) {
-  return (json[key] != undefined && json[key] != null) ?
+  return (typeof(json[key]) != 'undefined' && json[key] != null) ?
       json[key] : defaultValue;
 };
 

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=1228927&r1=1228926&r2=1228927&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 Sun Jan  8 19:25:28 2012
@@ -369,7 +369,7 @@ gadgets.io = function() {
         st = shindig.auth.getSecurityToken();
       } else {
         // Unauthenticated GET requests are cacheable
-        if (httpMethod === 'GET' && refreshInterval === undefined) {
+        if (httpMethod === 'GET' && typeof refreshInterval == 'undefined') {
           refreshInterval = 3600;
         }
       }
@@ -522,7 +522,7 @@ gadgets.io = function() {
       }
       var params = opt_params || {};
       var refresh = params['REFRESH_INTERVAL'];
-      if (refresh === undefined) {
+      if (typeof refresh == 'undefined') {
         refresh = '3600';
       }
 

Modified: shindig/trunk/features/src/main/javascript/features/core.json/json-flatten.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.json/json-flatten.js?rev=1228927&r1=1228926&r2=1228927&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.json/json-flatten.js (original)
+++ shindig/trunk/features/src/main/javascript/features/core.json/json-flatten.js Sun Jan  8 19:25:28 2012
@@ -27,12 +27,12 @@
 gadgets.json.flatten = function(obj) {
   var flat = {};
 
-  if (obj === null || obj === undefined) return flat;
+  if (obj === null || typeof obj == 'undefined') return flat;
 
   for (var k in obj) {
     if (obj.hasOwnProperty(k)) {
       var value = obj[k];
-      if (null === value || undefined === value) {
+      if (null === value || typeof value == 'undefined') {
         continue;
       }
       flat[k] = (typeof value === 'string') ? value : gadgets.json.stringify(value);

Modified: shindig/trunk/features/src/main/javascript/features/i18n/datetimeparse.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/i18n/datetimeparse.js?rev=1228927&r1=1228926&r2=1228927&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/i18n/datetimeparse.js (original)
+++ shindig/trunk/features/src/main/javascript/features/i18n/datetimeparse.js Sun Jan  8 19:25:28 2012
@@ -890,12 +890,12 @@ gadgets.i18n.DateTimeParse.MyDate_.proto
 gadgets.i18n.DateTimeParse.MyDate_.prototype.calcDate_ =
     function(date, validation) {
   // year 0 is 1 BC, and so on.
-  if (this.era != undefined && this.year != undefined &&
+  if ((typeof this.era != 'undefined') && (typeof this.year != 'undefined') &&
       this.era == 0 && this.year > 0) {
     this.year = -(this.year - 1);
   }
 
-  if (this.year != undefined) {
+  if (typeof this.year != 'undefined') {
     date.setFullYear(this.year);
   }
 
@@ -908,37 +908,37 @@ gadgets.i18n.DateTimeParse.MyDate_.proto
   date.setDate(1); // every month has a 1st day, this can actually be anything
   // less than 29.
 
-  if (this.month != undefined) {
+  if (typeof this.month != 'undefined') {
     date.setMonth(this.month);
   }
 
-  if (this.day != undefined) {
+  if (typeof this.day != 'undefined') {
     date.setDate(this.day);
   } else {
     date.setDate(org_date);
   }
 
-  if (this.hours == undefined) {
+  if (typeof this.hours == 'undefined') {
     this.hours = date.getHours();
   }
 
   // adjust ampm
-  if (this.ampm != undefined && this.ampm > 0) {
+  if ((typeof this.ampm != 'undefined') && this.ampm > 0) {
     if (this.hours < 12) {
       this.hours += 12;
     }
   }
   date.setHours(this.hours);
 
-  if (this.minutes != undefined) {
+  if (typeof this.minutes != 'undefined') {
     date.setMinutes(this.minutes);
   }
 
-  if (this.seconds != undefined) {
+  if (typeof this.seconds != 'undefined') {
     date.setSeconds(this.seconds);
   }
 
-  if (this.milliseconds != undefined) {
+  if (typeof this.milliseconds != 'undefined') {
     date.setMilliseconds(this.milliseconds);
   }
 
@@ -949,16 +949,16 @@ gadgets.i18n.DateTimeParse.MyDate_.proto
   // Don't need to check the day of week as it is guaranteed to be
   // correct or return false below.
   if (validation &&
-      (this.year != undefined && this.year != date.getFullYear() ||
-      this.month != undefined && this.month != date.getMonth() ||
-      this.dayOfMonth != undefined && this.dayOfMonth != date.getDate() ||
+      ((typeof this.year != 'undefined') && this.year != date.getFullYear() ||
+      (typeof this.month != 'undefined') && this.month != date.getMonth() ||
+      (typeof this.dayOfMonth != 'undefined') && this.dayOfMonth != date.getDate() ||
       this.hours >= 24 || this.minutes >= 60 || this.seconds >= 60 ||
       this.milliseconds >= 1000)) {
     return false;
   }
 
   // adjust time zone
-  if (this.tzOffset != undefined) {
+  if (typeof this.tzOffset != 'undefined') {
     var offset = date.getTimezoneOffset();
     date.setTime(date.getTime() + (this.tzOffset - offset) * 60 * 1000);
   }
@@ -975,8 +975,8 @@ gadgets.i18n.DateTimeParse.MyDate_.proto
   }
 
   // dayOfWeek, validation only
-  if (this.dayOfWeek != undefined) {
-    if (this.day == undefined) {
+  if (typeof this.dayOfWeek != 'undefined') {
+    if (typeof this.day == 'undefined') {
       // adjust to the nearest day of the week
       var adjustment = (7 + this.dayOfWeek - date.getDay()) % 7;
       if (adjustment > 3) {

Modified: shindig/trunk/features/src/main/javascript/features/open-views/viewenhancements-container.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/open-views/viewenhancements-container.js?rev=1228927&r1=1228926&r2=1228927&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/open-views/viewenhancements-container.js (original)
+++ shindig/trunk/features/src/main/javascript/features/open-views/viewenhancements-container.js Sun Jan  8 19:25:28 2012
@@ -90,8 +90,8 @@
         gadgetUrl = '',
         orig_site = context.getGadgetSiteByIframeId_(this.f);
 
-    if (orig_site !== undefined &&
-            orig_site.getActiveGadgetHolder() !== undefined) {
+    if ((typeof orig_site != 'undefined') &&
+            (typeof orig_site.getActiveGadgetHolder() != 'undefined')) {
       // get url through gadget holder
       gadgetUrl = orig_site.getActiveGadgetHolder().getUrl();
     }
@@ -119,7 +119,7 @@
        * result[gadgetUrl] : metadata
        */
       var metadata = {};
-      if (result !== undefined && result[gadgetUrl] !== undefined) {
+      if ((typeof result != 'undefined') && (typeof result[gadgetUrl] != 'undefined')) {
         if (result[gadgetUrl].error) {
           gadgets.error('Failed to preload gadget : ' + gadgetUrl);
           if (navigateCallback != null) {
@@ -140,7 +140,7 @@
 
       site.ownerId_ = siteOwnerId;
 
-      if (view !== undefined && view !== '') {
+      if ((typeof view != 'undefined') && view !== '') {
         renderParams[osapi.container.RenderParam.VIEW] = view;
       }
       renderParams[osapi.container.RenderParam.WIDTH] = '100%';

Modified: shindig/trunk/features/src/main/javascript/features/shindig.container/shindig-container.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/shindig.container/shindig-container.js?rev=1228927&r1=1228926&r2=1228927&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/shindig.container/shindig-container.js (original)
+++ shindig/trunk/features/src/main/javascript/features/shindig.container/shindig-container.js Sun Jan  8 19:25:28 2012
@@ -617,7 +617,7 @@ shindig.BaseIfrGadget.prototype.buildUse
 
 shindig.BaseIfrGadget.prototype.showUserPrefsDialog = function(opt_show) {
   var userPrefsDialog = document.getElementById(this.getUserPrefsDialogId());
-  userPrefsDialog.style.display = (opt_show || opt_show === undefined)
+  userPrefsDialog.style.display = (opt_show || typeof opt_show == 'undefined')
       ? '' : 'none';
 };
 

Modified: shindig/trunk/features/src/main/javascript/features/shindig.uri/uri.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/shindig.uri/uri.js?rev=1228927&r1=1228926&r2=1228927&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/shindig.uri/uri.js (original)
+++ shindig/trunk/features/src/main/javascript/features/shindig.uri/uri.js Sun Jan  8 19:25:28 2012
@@ -76,7 +76,7 @@ shindig.uri = (function() {
       for (var i = 0, j = params.length; i < j; ++i) {
         var key = params[i][0];
         var val = params[i][1];
-        if (val === undefined) {
+        if (typeof val == 'undefined') {
           continue;
         }
         str.push(esc(key) + (val !== null ? '=' + esc(val) : ''));
@@ -233,10 +233,10 @@ shindig.uri = (function() {
       setQP: setQP,
       setFP: setFP,
       setExistingP: function(key, val) {
-        if (getQP(key, val) !== undefined) {
+        if (typeof(getQP(key, val)) != 'undefined') {
           setQP(key, val);
         }
-        if (getFP(key, val) !== undefined) {
+        if (typeof(getFP(key, val)) != 'undefined') {
           setFP(key, val);
         }
         return bundle;

Modified: shindig/trunk/features/src/test/javascript/features/osapi/batchtest.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/test/javascript/features/osapi/batchtest.js?rev=1228927&r1=1228926&r2=1228927&view=diff
==============================================================================
--- shindig/trunk/features/src/test/javascript/features/osapi/batchtest.js (original)
+++ shindig/trunk/features/src/test/javascript/features/osapi/batchtest.js Sun Jan  8 19:25:28 2012
@@ -105,7 +105,7 @@ BatchTest.prototype.testEmptyBatch = fun
   var that = this;
   batch.execute(function(data) {
     that.assertTrue("Data should be returned", data);
-    that.assertTrue("Data should be empty", data.length === undefined);
+    that.assertTrue("Data should be empty", typeof data.length == 'undefined');
   });
 };
 
@@ -115,7 +115,7 @@ BatchTest.prototype.testEmptyBatch = fun
  * @param fn (Function) The function which should have these properties
  */
 BatchTest.prototype.assertBatchMembers = function(fn) {
-  this.assertTrue('Should have produced a batch', fn !== undefined);
+  this.assertTrue('Should have produced a batch', typeof fn != 'undefined');
   this.assertTrue('Should have an execute method', fn.execute);
   this.assertTrue('Should have an add method', fn.add);
 };