diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2013-01-02 11:54:21 -0500 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2013-01-02 11:59:17 -0500 |
commit | d65cb7ae0954e89de0a1b56170ffab683c39e3cc (patch) | |
tree | 6646c7acaa8795c6fd250d56a6e127ba2bf8f056 /apps/files_external/js | |
parent | a69de3a8f1dd3ef9a17b0f65b7058681eebb6145 (diff) | |
download | nextcloud-server-d65cb7ae0954e89de0a1b56170ffab683c39e3cc.tar.gz nextcloud-server-d65cb7ae0954e89de0a1b56170ffab683c39e3cc.zip |
Fix 'Grant Access' button for multiple Google Drive mount points and prevent multiple scripts being added
Diffstat (limited to 'apps/files_external/js')
-rw-r--r-- | apps/files_external/js/google.js | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/apps/files_external/js/google.js b/apps/files_external/js/google.js index a3b3e9cb3d2..89daa0078e8 100644 --- a/apps/files_external/js/google.js +++ b/apps/files_external/js/google.js @@ -1,18 +1,27 @@ $(document).ready(function() { - $('#externalStorage tbody tr.OC_Filestorage_Google').each(function() { - var configured = $(this).find('[data-parameter="configured"]'); + $('#externalStorage tbody tr.OC_Filestorage_Google').each(function(index, tr) { + setupGoogleRow(tr); + }); + + $('#selectBackend').live('change', function() { + if ($(this).val() == 'OC_Filestorage_Google') { + setupGoogleRow($('#externalStorage tbody>tr:last').prev('tr')); + } + }); + + function setupGoogleRow(tr) { + var configured = $(tr).find('[data-parameter="configured"]'); if ($(configured).val() == 'true') { - $(this).find('.configuration').append('<span id="access" style="padding-left:0.5em;">'+t('files_external', 'Access granted')+'</span>'); + $(tr).find('.configuration').append('<span id="access" style="padding-left:0.5em;">'+t('files_external', 'Access granted')+'</span>'); } else { - var token = $(this).find('[data-parameter="token"]'); - var token_secret = $(this).find('[data-parameter="token_secret"]'); + var token = $(tr).find('[data-parameter="token"]'); + var token_secret = $(tr).find('[data-parameter="token_secret"]'); var params = {}; window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m, key, value) { params[key] = value; }); if (params['oauth_token'] !== undefined && params['oauth_verifier'] !== undefined && decodeURIComponent(params['oauth_token']) == $(token).val()) { - var tr = $(this); $.post(OC.filePath('files_external', 'ajax', 'google.php'), { step: 2, oauth_verifier: params['oauth_verifier'], request_token: $(token).val(), request_token_secret: $(token_secret).val() }, function(result) { if (result && result.status == 'success') { $(token).val(result.access_token); @@ -22,13 +31,14 @@ $(document).ready(function() { $(tr).find('.configuration').append('<span id="access" style="padding-left:0.5em;">'+t('files_external', 'Access granted')+'</span>'); } else { OC.dialogs.alert(result.data.message, t('files_external', 'Error configuring Google Drive storage')); + onGoogleInputsChange(tr); } }); } else { - onGoogleInputsChange(this); + onGoogleInputsChange(tr); } } - }); + } $('#externalStorage tbody tr.OC_Filestorage_Google td').live('paste', function() { var tr = $(this).parent(); |