From c413fcf1c5fdc970becfad0ad4897a512b12551b Mon Sep 17 00:00:00 2001 From: benweet Date: Mon, 23 Dec 2013 23:41:33 +0100 Subject: [PATCH] Added option for Dropbox restricted permissions --- public/res/core.js | 13 ++++++++++++- public/res/helpers/dropboxHelper.js | 7 ++++--- public/res/settings.js | 2 ++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/public/res/core.js b/public/res/core.js index 714638e4..6fcf0f9f 100644 --- a/public/res/core.js +++ b/public/res/core.js @@ -131,8 +131,12 @@ define([ utils.setInputRadio("radio-settings-mode", storage.mode || '_ace_'); // Commit message utils.setInputValue("#input-settings-publish-commit-msg", settings.commitMsg); + // Gdrive multi-accounts + utils.setInputValue("#input-settings-gdrive-multiaccount", settings.gdriveMultiAccount); // Gdrive full access utils.setInputChecked("#input-settings-gdrive-full-access", settings.gdriveFullAccess); + // Dropbox full access + utils.setInputChecked("#input-settings-dropbox-full-access", settings.dropboxFullAccess); // Template utils.setInputValue("#textarea-settings-publish-template", settings.template); // PDF template @@ -171,8 +175,12 @@ define([ var mode = utils.getInputRadio("radio-settings-mode"); // Commit message newSettings.commitMsg = utils.getInputTextValue("#input-settings-publish-commit-msg", event); + // Gdrive multi-accounts + newSettings.gdriveMultiAccount = utils.getInputIntValue("#input-settings-gdrive-multiaccount"); // Gdrive full access newSettings.gdriveFullAccess = utils.getInputChecked("#input-settings-gdrive-full-access"); + // Drobox full access + newSettings.dropboxFullAccess = utils.getInputChecked("#input-settings-dropbox-full-access"); // Template newSettings.template = utils.getInputTextValue("#textarea-settings-publish-template", event); // PDF template @@ -190,6 +198,9 @@ define([ eventMgr.onSaveSettings(newSettings.extensionSettings, event); if(!event.isPropagationStopped()) { + if(settings.dropboxFullAccess !== newSettings.dropboxFullAccess) { + storage.removeItem('dropbox.lastChangeId'); + } $.extend(settings, newSettings); storage.settings = JSON.stringify(settings); storage.themeV3 = theme; @@ -924,7 +935,7 @@ define([ }); $(".action-import-docs-settings-confirm").click(function() { storage.clear(); - var allowedKeys = /^file\.|^focusMode$|^folder\.|^publish\.|^settings$|^sync\.|^google\.\d+\.|^themeV3$|^mode$|^version$|^welcomeTour$/; + var allowedKeys = /^file\.|^focusMode$|^folder\.|^publish\.|^settings$|^sync\.|^google\.|^themeV3$|^mode$|^version$|^welcomeTour$/; _.each(newstorage, function(value, key) { if(allowedKeys.test(key)) { storage[key] = value; diff --git a/public/res/helpers/dropboxHelper.js b/public/res/helpers/dropboxHelper.js index 9afafafb..ea8b05a2 100644 --- a/public/res/helpers/dropboxHelper.js +++ b/public/res/helpers/dropboxHelper.js @@ -6,9 +6,10 @@ define([ "core", "storage", "logger", + "settings", "eventMgr", "classes/AsyncTask", -], function($, _, constants, core, storage, logger, eventMgr, AsyncTask) { +], function($, _, constants, core, storage, logger, settings, eventMgr, AsyncTask) { var client; var authenticated = false; @@ -39,8 +40,8 @@ define([ timeout: constants.AJAX_TIMEOUT }).done(function() { client = new Dropbox.Client({ - key: constants.DROPBOX_APP_KEY, - secret: constants.DROPBOX_APP_SECRET + key: settings.dropboxFullAccess === true ? constants.DROPBOX_APP_KEY : constants.DROPBOX_RESTRICTED_APP_KEY, + secret: settings.dropboxFullAccess === true ? constants.DROPBOX_APP_SECRET : constants.DROPBOX_RESTRICTED_APP_SECRET }); client.authDriver(new Dropbox.AuthDriver.Popup({ receiverUrl: constants.BASE_URL + "html/dropbox-oauth-receiver.html", diff --git a/public/res/settings.js b/public/res/settings.js index 60266a89..47ebb266 100644 --- a/public/res/settings.js +++ b/public/res/settings.js @@ -12,7 +12,9 @@ define([ maxWidth: 960, defaultContent: "\n\n\n> Written with [StackEdit](" + constants.MAIN_URL + ").", commitMsg: "Published with " + constants.MAIN_URL, + gdriveMultiAccount: 1, gdriveFullAccess: true, + dropboxFullAccess: true, template: [ '\n', '\n',