summaryrefslogtreecommitdiffstats
path: root/core/js/js.js
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-01-24 12:44:31 +0100
committerVincent Petry <pvince81@owncloud.com>2014-01-24 12:44:31 +0100
commit41b6d4b702e8ed32f7ea51edffd0005639f77138 (patch)
tree23b3ffa6bcb16115f4eed84680f5962c5b3484da /core/js/js.js
parent9fa788c452403646cc5c2a7c0fe875879e7082fa (diff)
downloadnextcloud-server-41b6d4b702e8ed32f7ea51edffd0005639f77138.tar.gz
nextcloud-server-41b6d4b702e8ed32f7ea51edffd0005639f77138.zip
Added OC.buidQueryString() utility function
Makes it possible to create query strings by passing a JavaScript hash map and automatically encodes the keys and values.
Diffstat (limited to 'core/js/js.js')
-rw-r--r--core/js/js.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/core/js/js.js b/core/js/js.js
index e84f482d672..976027dd06b 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -364,6 +364,34 @@ var OC={
}
return result;
},
+
+ /**
+ * Builds a URL query from a JS map.
+ * @param params parameter map
+ * @return string containing a URL query (without question) mark
+ */
+ buildQueryString: function(params) {
+ var s = '';
+ var first = true;
+ if (!params) {
+ return s;
+ }
+ for (var key in params) {
+ var value = params[key];
+ if (first) {
+ first = false;
+ }
+ else {
+ s += '&';
+ }
+ s += encodeURIComponent(key);
+ if (value !== null && typeof(value) !== 'undefined') {
+ s += '=' + encodeURIComponent(value);
+ }
+ }
+ return s;
+ },
+
/**
* Opens a popup with the setting for an app.
* @param appid String. The ID of the app e.g. 'calendar', 'contacts' or 'files'.