From f62267f8a158add367c75d280a875b93b374c24f Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 7 Mar 2017 18:39:21 +0100 Subject: [PATCH 01/12] Ability to import local pads in the user object --- www/common/mergeDrive.js | 101 +++++++++++++++++++++++++++++++++++++++ www/drive/main.js | 23 ++------- www/settings/main.js | 22 ++++++++- 3 files changed, 127 insertions(+), 19 deletions(-) create mode 100644 www/common/mergeDrive.js diff --git a/www/common/mergeDrive.js b/www/common/mergeDrive.js new file mode 100644 index 000000000..9071bf71c --- /dev/null +++ b/www/common/mergeDrive.js @@ -0,0 +1,101 @@ +require.config({ paths: { 'json.sortify': '/bower_components/json.sortify/dist/JSON.sortify' } }); +define([ + '/common/cryptpad-common.js', + '/common/cryptget.js', + 'json.sortify' +], function (Cryptpad, Crypt, Sortify) { + var exp = {}; + + var getType = function (el) { + if (el === null) { return "null"; } + return Array.isArray(el) ? "array" : typeof(el); + }; + + var findAvailableKey = function (obj, key) { + if (typeof (obj[key]) === "undefined") { return key; } + var i = 1; + var nkey = key; + while (typeof (obj[nkey]) !== "undefined") { + nkey = key + '_' + i; + } + return nkey; + }; + + var copy = function (el) { + if (typeof (el) !== "object") { return el; } + return JSON.parse(JSON.stringify(el)); + }; + + var deduplicate = function (array) { + var a = array.slice(); + for(var i=0; i', {'class': 'importLocalPads'}); + var $label = $('