summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/js/external.js
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/js/external.js')
-rw-r--r--apps/files_sharing/js/external.js38
1 files changed, 28 insertions, 10 deletions
diff --git a/apps/files_sharing/js/external.js b/apps/files_sharing/js/external.js
index bc02ecfaf97..5c476b2d43d 100644
--- a/apps/files_sharing/js/external.js
+++ b/apps/files_sharing/js/external.js
@@ -1,4 +1,13 @@
-$(document).ready(function () {
+/*
+ * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
+ *
+ * This file is licensed under the Affero General Public License version 3
+ * or later.
+ *
+ * See the COPYING-README file.
+ *
+ */
+(function () {
var getParameterByName = function (query, name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\#&]" + name + "=([^&#]*)"),
@@ -8,10 +17,10 @@ $(document).ready(function () {
var addExternalShare = function (remote, token, owner, name, password) {
return $.post(OC.generateUrl('apps/files_sharing/external'), {
- remote : remote,
- token : token,
- owner : owner,
- name : name,
+ remote: remote,
+ token: token,
+ owner: owner,
+ name: name,
password: password
});
};
@@ -31,15 +40,15 @@ $(document).ready(function () {
}
};
if (!passwordProtected) {
- OC.dialogs.confirm('Add ' + name + ' from ' + owner + '@' + remoteClean, 'Add Share', callback, true);
+ OC.dialogs.confirm(t('files_sharing', 'Add {name} from {owner}@{remote}', {name: name, owner: owner, remote: remoteClean})
+ , 'Add Share', callback, true);
} else {
- OC.dialogs.prompt('Add ' + name + ' from ' + owner + '@' + remoteClean, 'Add Share', callback, true, 'Password', true);
+ OC.dialogs.prompt(t('files_sharing', 'Add {name} from {owner}@{remote}', {name: name, owner: owner, remote: remoteClean})
+ , 'Add Share', callback, true, 'Password', true);
}
};
- if (OCA.Files) {// only run in the files app
- var hash = location.hash;
- location.hash = '';
+ OCA.Sharing.showAddExternalDialog = function (hash) {
var remote = getParameterByName(hash, 'remote');
var owner = getParameterByName(hash, 'owner');
var name = getParameterByName(hash, 'name');
@@ -49,5 +58,14 @@ $(document).ready(function () {
if (remote && token && owner && name) {
showAddExternalDialog(remote, token, owner, name, passwordProtected);
}
+ };
+})();
+
+$(document).ready(function () {
+ // FIXME: HACK: do not init when running unit tests, need a better way
+ if (!window.TESTING && OCA.Files) {// only run in the files app
+ var hash = location.hash;
+ location.hash = '';
+ OCA.Sharing.showAddExternalDialog(hash);
}
});