[Pkg-owncloud-commits] [owncloud] 22/134: adding new javascript function OC.generateUrl(url, params)

David Prévot taffit at moszumanska.debian.org
Fri Apr 18 21:43:57 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 87d385303fe27074d9915f11ee2c1562bbe30d3b
Author: Thomas Müller <thomas.mueller at tmit.eu>
Date:   Thu Mar 6 00:17:48 2014 +0100

    adding new javascript function OC.generateUrl(url, params)
---
 core/js/js.js | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/core/js/js.js b/core/js/js.js
index c79d5e8..7f45a9b 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -175,6 +175,30 @@ var OC={
 	appswebroots:(typeof oc_appswebroots !== 'undefined') ? oc_appswebroots:false,
 	currentUser:(typeof oc_current_user!=='undefined')?oc_current_user:false,
 	coreApps:['', 'admin','log','search','settings','core','3rdparty'],
+
+	/**
+	 * Generates the absolute url for the given relative url, which can contain parameters.
+	 *
+	 * @returns {string}
+	 * @param {string} url
+	 * @param params
+	 */
+	generateUrl: function(url, params) {
+		var _build = function (text, vars) {
+			return text.replace(/{([^{}]*)}/g,
+				function (a, b) {
+					var r = vars[b];
+					return typeof r === 'string' || typeof r === 'number' ? r : a;
+				}
+			);
+		};
+		if (url.charAt(0) !== '/') {
+			url = '/' + url;
+
+		}
+		return OC.webroot + '/index.php' + _build(url, params);
+	},
+
 	/**
 	 * get an absolute url to a file in an appen
 	 * @param app the id of the app the file belongs to

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list