You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by do...@apache.org on 2008/09/06 01:48:10 UTC

svn commit: r692583 - in /incubator/shindig/trunk/javascript: container/cookiebaseduserprefstore.js container/cookies.js samplecontainer/samplecontainer.js

Author: doll
Date: Fri Sep  5 16:48:10 2008
New Revision: 692583

URL: http://svn.apache.org/viewvc?rev=692583&view=rev
Log:
SHINDIG-32 Finally renamed the goog.net.cookies class to be in the shindig namespace

Modified:
    incubator/shindig/trunk/javascript/container/cookiebaseduserprefstore.js
    incubator/shindig/trunk/javascript/container/cookies.js
    incubator/shindig/trunk/javascript/samplecontainer/samplecontainer.js

Modified: incubator/shindig/trunk/javascript/container/cookiebaseduserprefstore.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/container/cookiebaseduserprefstore.js?rev=692583&r1=692582&r2=692583&view=diff
==============================================================================
--- incubator/shindig/trunk/javascript/container/cookiebaseduserprefstore.js (original)
+++ incubator/shindig/trunk/javascript/container/cookiebaseduserprefstore.js Fri Sep  5 16:48:10 2008
@@ -38,7 +38,7 @@
 gadgets.CookieBasedUserPrefStore.prototype.getPrefs = function(gadget) {
   var userPrefs = {};
   var cookieName = this.USER_PREFS_PREFIX + gadget.id;
-  var cookie = goog.net.cookies.get(cookieName);
+  var cookie = shindig.cookies.get(cookieName);
   if (cookie) {
     var pairs = cookie.split('&');
     for (var i = 0; i < pairs.length; i++) {
@@ -62,8 +62,8 @@
 
   var cookieName = this.USER_PREFS_PREFIX + gadget.id;
   var cookieValue = pairs.join('&');
-  goog.net.cookies.set(cookieName, cookieValue);
+  shindig.cookies.set(cookieName, cookieValue);
 };
 
 gadgets.Container.prototype.userPrefStore =
-    new gadgets.CookieBasedUserPrefStore();
\ No newline at end of file
+    new gadgets.CookieBasedUserPrefStore();

Modified: incubator/shindig/trunk/javascript/container/cookies.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/container/cookies.js?rev=692583&r1=692582&r2=692583&view=diff
==============================================================================
--- incubator/shindig/trunk/javascript/container/cookies.js (original)
+++ incubator/shindig/trunk/javascript/container/cookies.js Fri Sep  5 16:48:10 2008
@@ -23,19 +23,18 @@
 /**
  * Namespace for cookie functions
  */
-// goog.provide('goog.net.cookies');
+
 // TODO: find the official solution for a cookies library
-var goog = goog || {};
-goog.net = goog.net || {};
-goog.net.cookies = goog.net.cookies || {};
+var shindig = shindig || {};
+shindig.cookies = shindig.cookies || {};
 
 
-goog.JsType_ = {
+shindig.cookies.JsType_ = {
   UNDEFINED: 'undefined'
 };
 
-goog.isDef = function(val) {
-  return typeof val != goog.JsType_.UNDEFINED;
+shindig.cookies.isDef = function(val) {
+  return typeof val != shindig.cookies.JsType_.UNDEFINED;
 };
 
 
@@ -59,7 +58,7 @@
  *                            is null (i.e. let browser use full request host
  *                            name).
  */
-goog.net.cookies.set = function(name, value, opt_maxAge, opt_path, opt_domain) {
+shindig.cookies.set = function(name, value, opt_maxAge, opt_path, opt_domain) {
   // we do not allow '=' or ';' in the name
   if (/;=/g.test(name)) {
     throw new Error('Invalid cookie name "' + name + '"');
@@ -69,7 +68,7 @@
     throw new Error('Invalid cookie value "' + value + '"');
   }
 
-  if (!goog.isDef(opt_maxAge)) {
+  if (!shindig.cookies.isDef(opt_maxAge)) {
     opt_maxAge = -1;
   }
 
@@ -110,7 +109,7 @@
  *                            returns opt_default or undefined if opt_default is
  *                            not provided.
  */
-goog.net.cookies.get = function(name, opt_default) {
+shindig.cookies.get = function(name, opt_default) {
   var nameEq = name + "=";
   var cookie = String(document.cookie);
   for (var pos = -1; (pos = cookie.indexOf(nameEq, pos + 1)) >= 0;) {
@@ -149,9 +148,9 @@
  *                            provided, the default is null (i.e. cookie at
  *                            full request host name).
  */
-goog.net.cookies.remove = function(name, opt_path, opt_domain) {
-  var rv = goog.net.cookies.containsKey(name);
-  goog.net.cookies.set(name, '', 0, opt_path, opt_domain);
+shindig.cookies.remove = function(name, opt_path, opt_domain) {
+  var rv = shindig.cookies.containsKey(name);
+  shindig.cookies.set(name, '', 0, opt_path, opt_domain);
   return rv;
 };
 
@@ -161,7 +160,7 @@
  * @private
  * @return {Object} An object with keys and values
  */
-goog.net.cookies.getKeyValues_ = function() {
+shindig.cookies.getKeyValues_ = function() {
   var cookie = String(document.cookie);
   var parts = cookie.split(/\s*;\s*/);
   var keys = [], values = [], index, part;
@@ -184,8 +183,8 @@
  * Gets the names for all the cookies
  * @return {Array} An array with the names of the cookies
  */
-goog.net.cookies.getKeys = function() {
-  return goog.net.cookies.getKeyValues_().keys;
+shindig.cookies.getKeys = function() {
+  return shindig.cookies.getKeyValues_().keys;
 };
 
 
@@ -193,8 +192,8 @@
  * Gets the values for all the cookies
  * @return {Array} An array with the values of the cookies
  */
-goog.net.cookies.getValues = function() {
-  return goog.net.cookies.getKeyValues_().values;
+shindig.cookies.getValues = function() {
+  return shindig.cookies.getKeyValues_().values;
 };
 
 
@@ -202,7 +201,7 @@
  * Whether there are any cookies for this document
  * @return {boolean}
  */
-goog.net.cookies.isEmpty = function() {
+shindig.cookies.isEmpty = function() {
   return document.cookie == '';
 };
 
@@ -211,7 +210,7 @@
  * Returns the number of cookies for this document
  * @return {number}
  */
-goog.net.cookies.getCount = function() {
+shindig.cookies.getCount = function() {
   var cookie = String(document.cookie);
   if (cookie == '') {
     return 0;
@@ -226,12 +225,12 @@
  * @param {string} key The name of the cookie to test for
  * @return {boolean}
  */
-goog.net.cookies.containsKey = function(key) {
+shindig.cookies.containsKey = function(key) {
   var sentinel = {};
   // if get does not find the key it returns the default value. We therefore
   // compare the result with an object to ensure we do not get any false
   // positives.
-  return goog.net.cookies.get(key, sentinel) !== sentinel;
+  return shindig.cookies.get(key, sentinel) !== sentinel;
 };
 
 
@@ -241,9 +240,9 @@
  * @param {string} value The value to check for
  * @return {boolean}
  */
-goog.net.cookies.containsValue = function(value) {
+shindig.cookies.containsValue = function(value) {
   // this O(n) in any case so lets do the trivial thing.
-  var values = goog.net.cookies.getKeyValues_().values;
+  var values = shindig.cookies.getKeyValues_().values;
   for (var i = 0; i < values.length; i++) {
     if (values[i] == value) {
       return true;
@@ -256,10 +255,10 @@
 /**
  * Removes all cookies for this document
  */
-goog.net.cookies.clear = function() {
-  var keys = goog.net.cookies.getKeyValues_().keys;
+shindig.cookies.clear = function() {
+  var keys = shindig.cookies.getKeyValues_().keys;
   for (var i = keys.length - 1; i >= 0; i--) {
-    goog.net.cookies.remove(keys[i]);
+    shindig.cookies.remove(keys[i]);
   }
 };
 
@@ -270,4 +269,4 @@
  * browsers/proxies that interpret 4K as 4000 rather than 4096
  * @type number
  */
-goog.net.cookies.MAX_COOKIE_LENGTH = 3950;
+shindig.cookies.MAX_COOKIE_LENGTH = 3950;

Modified: incubator/shindig/trunk/javascript/samplecontainer/samplecontainer.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/samplecontainer/samplecontainer.js?rev=692583&r1=692582&r2=692583&view=diff
==============================================================================
--- incubator/shindig/trunk/javascript/samplecontainer/samplecontainer.js (original)
+++ incubator/shindig/trunk/javascript/samplecontainer/samplecontainer.js Fri Sep  5 16:48:10 2008
@@ -136,12 +136,12 @@
 
   shindig.samplecontainer.initGadget = function() {
     // Fetch cookies
-    var cookieGadgetUrl = decodeURIComponent(goog.net.cookies.get(gadgetUrlCookie));
+    var cookieGadgetUrl = decodeURIComponent(shindig.cookies.get(gadgetUrlCookie));
     if (cookieGadgetUrl && cookieGadgetUrl != "undefined") {
       gadgetUrl = cookieGadgetUrl;
     }
 
-    var cookieStateFileUrl = decodeURIComponent(goog.net.cookies.get(stateFileUrlCookie));
+    var cookieStateFileUrl = decodeURIComponent(shindig.cookies.get(stateFileUrlCookie));
     if (cookieStateFileUrl && cookieStateFileUrl != "undefined") {
       stateFileUrl = cookieStateFileUrl;
     }
@@ -181,7 +181,7 @@
     setEvilBit();
 
     stateFileUrl = document.getElementById("stateFileUrl").value;
-    goog.net.cookies.set(stateFileUrlCookie, encodeURIComponent(stateFileUrl));
+    shindig.cookies.set(stateFileUrlCookie, encodeURIComponent(stateFileUrl));
 
     viewerId = document.getElementById("viewerId").value;
     ownerId = document.getElementById("ownerId").value;
@@ -189,7 +189,7 @@
 
     gadget.secureToken = escape(generateSecureToken());
     gadget.specUrl = gadgetUrl;
-    goog.net.cookies.set(gadgetUrlCookie, encodeURIComponent(gadgetUrl));
+    shindig.cookies.set(gadgetUrlCookie, encodeURIComponent(gadgetUrl));
 
     reloadStateFile(function() {
       gadgets.container.renderGadgets();
@@ -208,4 +208,4 @@
     );
   };
 
-})();
\ No newline at end of file
+})();