]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-13766, move common functions to javascript-static.js"
authordongsheng <dongsheng>
Sun, 16 Aug 2009 04:14:46 +0000 (04:14 +0000)
committerdongsheng <dongsheng>
Sun, 16 Aug 2009 04:14:46 +0000 (04:14 +0000)
lib/javascript-static.js
repository/repository.src.js

index 98e86ebad472c887e99a922d91b9f89c1ee46c75..c4111a9e1929e10c7c503f6c5cc7f9d6e30f248f 100644 (file)
@@ -1125,6 +1125,31 @@ function build_querystring(obj) {
     }
     return list.join('&');
 }
+
+function stripHTML(str) {
+    var re = /<\S[^><]*>/g;
+    var ret = str.replace(re, "");
+    return ret;
+}
+
+function json_decode(json) {
+    try {
+        var obj = YAHOO.lang.JSON.parse(json);
+    } catch (e) {
+        alert(e.toString());
+    }
+    return obj;
+}
+
+function json_encode(data) {
+    try {
+        var json = YAHOO.lang.JSON.stringify(data);
+    } catch (e) {
+        alert(e.toString());
+    }
+    return json;
+}
+
 /**
  * Finds all help icons on the page and initiates YUI tooltips for
  * each of them, which load a truncated version of the help's content
index 95b256662696fb2c6a9993999a47f208f98a4026..1facb7db1e173c9bb1b22093655428099db44a9b 100644 (file)
@@ -971,11 +971,6 @@ repository_client.postdata = function(obj) {
     return str;
 }
 
-repository_client.stripHTML = function(str){
-    var re= /<\S[^><]*>/g
-    var ret = str.replace(re, "")
-    return ret;
-}
 repository_client.popup = function(client_id, url) {
     window.open(url,'repo_auth', 'location=0,status=0,scrollbars=0,width=500,height=300');
     cached_client_id = client_id;
@@ -1121,7 +1116,7 @@ repository_client.parse_json = function(txt, source) {
     try {
         var ret = YAHOO.lang.JSON.parse(txt);
     } catch(e) {
-        alert(fp_lang.invalidjson+' - |'+source+'| -'+this.stripHTML(txt));
+        alert(fp_lang.invalidjson+' - |'+source+'| -'+stripHTML(txt));
     }
     return ret;
 }