escape_id moves into plugin.js
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Wed, 2 Oct 2013 15:36:45 +0000 (17:36 +0200)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Wed, 2 Oct 2013 15:36:45 +0000 (17:36 +0200)
manifold/static/js/plugin.js
plugins/googlemap/static/js/googlemap.js
unfold/static/js/unfold-helper.js

index 3745f64..07ba9b7 100644 (file)
@@ -189,7 +189,7 @@ var Plugin = Class.extend({
 
     id_from_key: function(key_field, value) {
         
-        return key_field + manifold.separator + unfold.escape_id(value).replace(/\\/g, '');
+        return key_field + manifold.separator + this.escape_id(value).replace(/\\/g, '');
     },
 
     // we do not need to carry around all the nonsense about backslashing dots in hrns
@@ -205,6 +205,15 @@ var Plugin = Class.extend({
        return id_in.replace(/\\\./g,"-").replace(/\\/g,"-").replace(/\./g,"-");
     },
 
+    // escape (read: backslashes) some meta-chars in input
+    escape_id: function(id) {
+        if( id !== undefined){
+            return id.replace( /(:|\.|\[|\])/g, "\\$1" );
+        }else{
+            return "undefined-id";
+        }
+    },
+
     id_from_record: function(method, record) {
         var keys = manifold.metadata.get_key(method);
         if (!keys)
index 34b2b8d..345a2b9 100644 (file)
@@ -102,7 +102,7 @@ googlemap_debug_detailed=false;
                 throw "Not implemented";
                 break;
             }
-           return unfold.escape_id(key_value).replace(/\\/g, '');
+           return this.escape_id(key_value).replace(/\\/g, '');
        },          
 
        // return { marker: gmap_marker, ul : <ul DOM> }
@@ -174,7 +174,7 @@ googlemap_debug_detailed=false;
            var checkbox = this.create_record_checkbox (record, ul, false);
            if ( ! this.key in record ) return;
             var key_value = record[this.key];
-           var hrn = unfold.escape_id(key_value).replace(/\\/g, '');
+           var hrn = this.escape_id(key_value).replace(/\\/g, '');
             this.by_hrn[hrn] = {
                checkbox: checkbox,
                // xxx Thierry sept 2013
index 7248567..0595dde 100644 (file)
@@ -31,14 +31,6 @@ var unfold = {
         } else {
             return value;
         }
-    },
-
-    escape_id: function(id) {
-        if( id !== undefined){
-            return id.replace( /(:|\.|\[|\])/g, "\\$1" );
-        }else{
-            return "undefined-id";
-        }
     }
 
 } // global unfold