You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by jo...@apache.org on 2009/02/27 23:03:16 UTC

svn commit: r748718 - in /incubator/shindig/trunk/features/src/main/javascript/features/core: legacy.js prefs.js

Author: johnh
Date: Fri Feb 27 22:03:16 2009
New Revision: 748718

URL: http://svn.apache.org/viewvc?rev=748718&view=rev
Log:
Legacy _IG_Prefs getX methods return unescpaed values for backward compatibility. gadgets.Prefs unmodified.

This resolves issue SHINDIG-937.


Modified:
    incubator/shindig/trunk/features/src/main/javascript/features/core/legacy.js
    incubator/shindig/trunk/features/src/main/javascript/features/core/prefs.js

Modified: incubator/shindig/trunk/features/src/main/javascript/features/core/legacy.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/features/src/main/javascript/features/core/legacy.js?rev=748718&r1=748717&r2=748718&view=diff
==============================================================================
--- incubator/shindig/trunk/features/src/main/javascript/features/core/legacy.js (original)
+++ incubator/shindig/trunk/features/src/main/javascript/features/core/legacy.js Fri Feb 27 22:03:16 2009
@@ -21,12 +21,21 @@
  // Gadget authors are explicitly discouraged from using any of them.
 
 var JSON = gadgets.json;
-var _IG_Prefs = gadgets.Prefs;
 
-// Yes, these technically modifiy gadget.Prefs as well. Unfortunately,
-// simply setting IG_Prefs.prototype to a new gadgets.Prefs object means
-// that we'd have to duplicate the gadgets.Prefs constructor.
-_IG_Prefs._parseURL = gadgets.Prefs.parseUrl;
+(function() {
+
+var instance = null;
+
+var _IG_Prefs = function() {
+  if (!instance) {
+    instance = new gadgets.Prefs();
+    instance.setDontEscape_();
+  }
+  return instance;
+};
+
+ _IG_Prefs._parseURL = gadgets.Prefs.parseUrl;
+})();
 
 function _IG_Fetch_wrapper(callback, obj) {
   callback(obj.data);

Modified: incubator/shindig/trunk/features/src/main/javascript/features/core/prefs.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/features/src/main/javascript/features/core/prefs.js?rev=748718&r1=748717&r2=748718&view=diff
==============================================================================
--- incubator/shindig/trunk/features/src/main/javascript/features/core/prefs.js (original)
+++ incubator/shindig/trunk/features/src/main/javascript/features/core/prefs.js Fri Feb 27 22:03:16 2009
@@ -46,6 +46,7 @@
 
 var instance = null;
 var prefs = {};
+var esc = gadgets.util.escapeString;
 var messages = {};
 var defaultPrefs = {};
 var language = "en";
@@ -145,7 +146,15 @@
  * @return {String} The preference; if not set, an empty string
  */
 gadgets.Prefs.prototype.getString = function(key) {
-  return prefs[key] ? gadgets.util.escapeString(prefs[key]) : "";
+  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; };
 };
 
 /**
@@ -212,7 +221,6 @@
   if (val) {
     var arr = val.split("|");
     // Decode pipe characters.
-    var esc = gadgets.util.escapeString;
     for (var i = 0, j = arr.length; i < j; ++i) {
       arr[i] = esc(arr[i].replace(/%7C/g, "|"));
     }