diff options
author | Robin Appelman <icewind@owncloud.com> | 2014-05-14 13:29:03 +0200 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2014-06-14 10:13:24 +0200 |
commit | cf5a72c10398bb18817cff8ca4dfba4429a97123 (patch) | |
tree | d9ede2e59296746411c2781c1fe074d38af3235d /apps/files_sharing/js/public.js | |
parent | d7de35376d7e068abdfb49e8336feab25e313662 (diff) | |
download | nextcloud-server-cf5a72c10398bb18817cff8ca4dfba4429a97123.tar.gz nextcloud-server-cf5a72c10398bb18817cff8ca4dfba4429a97123.zip |
Add interface for adding a public share to a different ownCloud instance
Diffstat (limited to 'apps/files_sharing/js/public.js')
-rw-r--r-- | apps/files_sharing/js/public.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js index a2248405d22..48db89532b4 100644 --- a/apps/files_sharing/js/public.js +++ b/apps/files_sharing/js/public.js @@ -186,5 +186,41 @@ $(document).ready(function() { }); }; } + + $('.save-form').submit(function (event) { + event.preventDefault(); + + var remote = $(this).find('input[type="text"]').val(); + var token = $('#sharingToken').val(); + var location = window.location.protocol + '//' + window.location.host + OC.webroot; + var owner = $('#save').data('owner'); + var name = $('#save').data('name'); + + var url = remote + '/index.php/apps/files#' + 'remote=' + encodeURIComponent(location) // our location is the remote for the other server + + "&token=" + encodeURIComponent(token) + "&owner=" + encodeURIComponent(owner) + "&name=" + encodeURIComponent(name); + + + if (remote.indexOf('://') > 0) { + window.location = url; + } else { + // if no protocol is specified, we automatically detect it by testing https and http + // this check needs to happen on the server due to the Content Security Policy directive + $.get(OC.generateUrl('apps/files_sharing/testremote'), {remote: remote}).then(function (protocol) { + if (protocol !== 'http' && protocol !== 'https') { + OC.dialogs.alert(t('files_sharing', 'No ownCloud installation found at {remote}', {remote: remote}), + t('files_sharing', 'Invalid ownCloud url')); + } else { + window.location = protocol + '://' + url; + } + }); + } + }); + + $('#save > button').click(function () { + $(this).hide(); + $('.header-right').addClass('active'); + $('.save-form').css('display', 'inline'); + $('#remote_address').focus(); + }); }); |