From e02a779c14874bba98547a38fb9367abd0963f23 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 27 Sep 2017 10:31:35 +0200 Subject: [PATCH] Use secure drive as default drive --- customize.dist/src/less2/main.less | 2 +- www/{newdrive => drive}/app-drive.less | 0 www/drive/index.html | 23 +- www/drive/inner.html | 73 +- www/drive/inner.js | 3041 +++++++++++++++++- www/drive/main.js | 3070 +------------------ www/newdrive/inner.html | 63 - www/newdrive/main.js | 53 - www/{drive => olddrive}/file.less | 0 www/{newdrive => olddrive}/index.html | 23 +- www/olddrive/inner.html | 60 + www/olddrive/inner.js | 7 + www/{newdrive/inner.js => olddrive/main.js} | 1211 ++++---- www/{drive => olddrive}/tests.js | 0 14 files changed, 3813 insertions(+), 3813 deletions(-) rename www/{newdrive => drive}/app-drive.less (100%) delete mode 100644 www/newdrive/inner.html delete mode 100644 www/newdrive/main.js rename www/{drive => olddrive}/file.less (100%) rename www/{newdrive => olddrive}/index.html (52%) create mode 100644 www/olddrive/inner.html create mode 100644 www/olddrive/inner.js rename www/{newdrive/inner.js => olddrive/main.js} (73%) rename www/{drive => olddrive}/tests.js (100%) diff --git a/customize.dist/src/less2/main.less b/customize.dist/src/less2/main.less index ed0d0bd0d..51450db27 100644 --- a/customize.dist/src/less2/main.less +++ b/customize.dist/src/less2/main.less @@ -22,7 +22,7 @@ html.cp-app-print { .app-print_main(); } -body.cp-app-drive { @import "../../../newdrive/app-drive.less"; } +body.cp-app-drive { @import "../../../drive/app-drive.less"; } body.cp-app-pad { @import "../../../pad/app-pad.less"; } body.cp-app-code { @import "../../../code/app-code.less"; } body.cp-app-slide { @import "../../../slide/app-slide.less"; } diff --git a/www/newdrive/app-drive.less b/www/drive/app-drive.less similarity index 100% rename from www/newdrive/app-drive.less rename to www/drive/app-drive.less diff --git a/www/drive/index.html b/www/drive/index.html index 02f92a5b3..e3f7eacc4 100644 --- a/www/drive/index.html +++ b/www/drive/index.html @@ -1,18 +1,19 @@ - + - CryptDrive - + CryptPad - + + + - + diff --git a/www/olddrive/inner.html b/www/olddrive/inner.html new file mode 100644 index 000000000..0b26aa7a1 --- /dev/null +++ b/www/olddrive/inner.html @@ -0,0 +1,60 @@ + + + + + + + + +
+
+
+
+
+
+
+
+ + + + + +
+ + + diff --git a/www/olddrive/inner.js b/www/olddrive/inner.js new file mode 100644 index 000000000..e1779778b --- /dev/null +++ b/www/olddrive/inner.js @@ -0,0 +1,7 @@ +define([ + 'less!/bower_components/components-font-awesome/css/font-awesome.min.css', + 'css!/bower_components/bootstrap/dist/css/bootstrap.min.css', + 'less!/drive/file.less', + 'less!/customize/src/less/cryptpad.less', + 'less!/customize/src/less/toolbar.less', +], function () {}); diff --git a/www/newdrive/inner.js b/www/olddrive/main.js similarity index 73% rename from www/newdrive/inner.js rename to www/olddrive/main.js index 9c1072954..d7766b75f 100644 --- a/www/newdrive/inner.js +++ b/www/olddrive/main.js @@ -1,56 +1,44 @@ define([ 'jquery', + '/bower_components/chainpad-listmap/chainpad-listmap.js', '/bower_components/chainpad-crypto/crypto.js', - '/bower_components/textpatcher/TextPatcher.js', - '/common/toolbar3.js', + '/bower_components/textpatcher/TextPatcher.amd.js', 'json.sortify', '/common/cryptpad-common.js', - '/common/common-util.js', - '/common/cryptget.js', - '/bower_components/nthen/index.js', - '/common/sframe-common.js', - '/common/common-realtime.js', '/common/userObject.js', + '/common/toolbar2.js', '/customize/application_config.js', + '/common/cryptget.js', '/common/mergeDrive.js', - '/common/sframe-chainpad-listmap.js', - 'css!/bower_components/bootstrap/dist/css/bootstrap.min.css', 'less!/bower_components/components-font-awesome/css/font-awesome.min.css', - 'less!/customize/src/less2/main.less', -], function ( - $, - Crypto, - TextPatcher, - Toolbar, - JSONSortify, - Cryptpad, - Util, - Cryptget, - nThen, - SFCommon, - CommonRealtime, - FO, - AppConfig, - Merge, - Listmap) -{ + 'less!/customize/src/less/cryptpad.less', +], function ($, Listmap, Crypto, TextPatcher, JSONSortify, Cryptpad, FO, Toolbar, AppConfig, Get, Merge) { + var module = window.MODULE = {}; + var Messages = Cryptpad.Messages; + //var saveAs = window.saveAs; + + // Use `$(function () {});` to make sure the html is loaded before doing anything else + $(function () { + var ifrw = $('#pad-iframe')[0].contentWindow; + + Cryptpad.addLoadingScreen(); + var onConnectError = function () { + Cryptpad.errorLoadingScreen(Messages.websocketError); + }; var APP = window.APP = { editable: false, Cryptpad: Cryptpad, + loggedIn: Cryptpad.isLoggedIn(), mobile: function () { return $('body').width() <= 600; } // Menu and content area are not inline-block anymore for mobiles }; - var stringify = function (obj) { + var stringify = APP.stringify = function (obj) { return JSONSortify(obj); }; - var onConnectError = function () { - Cryptpad.errorLoadingScreen(Messages.websocketError); - }; - var E_OVER_LIMIT = 'E_OVER_LIMIT'; var SEARCH = "search"; @@ -66,11 +54,10 @@ define([ var RECENT = "recent"; var RECENT_NAME = Messages.fm_recentPadsName; - var LS_LAST = "app-drive-lastOpened"; - var LS_OPENED = "app-drive-openedFolders"; - var LS_VIEWMODE = "app-drive-viewMode"; - var LS_SEARCHCURSOR = "app-drive-searchCursor"; - var FOLDER_CONTENT_ID = "cp-app-drive-content-folder"; + var LOCALSTORAGE_LAST = "cryptpad-file-lastOpened"; + var LOCALSTORAGE_OPENED = "cryptpad-file-openedFolders"; + var LOCALSTORAGE_VIEWMODE = "cryptpad-file-viewMode"; + var FOLDER_CONTENT_ID = "folderContent"; var config = {}; var DEBUG = config.DEBUG = true; @@ -82,12 +69,10 @@ define([ }; var log = config.log = Cryptpad.log; - var localStore = window.cryptpadStore; - APP.store = {}; var getLastOpenedFolder = function () { var path; try { - path = APP.store[LS_LAST] ? JSON.parse(APP.store[LS_LAST]) : [ROOT]; + path = localStorage[LOCALSTORAGE_LAST] ? JSON.parse(localStorage[LOCALSTORAGE_LAST]) : [ROOT]; } catch (e) { path = [ROOT]; } @@ -95,75 +80,84 @@ define([ }; var setLastOpenedFolder = function (path) { if (path[0] === SEARCH) { return; } - APP.store[LS_LAST] = JSON.stringify(path); - localStore.put(LS_LAST, JSON.stringify(path)); + localStorage[LOCALSTORAGE_LAST] = JSON.stringify(path); + }; + + var initLocalStorage = function () { + try { + var store = JSON.parse(localStorage[LOCALSTORAGE_OPENED]); + if (!$.isArray(store)) { + localStorage[LOCALSTORAGE_OPENED] = '[]'; + } + } catch (e) { + localStorage[LOCALSTORAGE_OPENED] = '[]'; + } }; var wasFolderOpened = function (path) { - var stored = JSON.parse(APP.store[LS_OPENED] || '[]'); - return stored.indexOf(JSON.stringify(path)) !== -1; + var store = JSON.parse(localStorage[LOCALSTORAGE_OPENED]); + return store.indexOf(JSON.stringify(path)) !== -1; }; var setFolderOpened = function (path, opened) { var s = JSON.stringify(path); - var stored = JSON.parse(APP.store[LS_OPENED] || '[]'); - if (opened && stored.indexOf(s) === -1) { - stored.push(s); + var store = JSON.parse(localStorage[LOCALSTORAGE_OPENED]); + if (opened && store.indexOf(s) === -1) { + store.push(s); } if (!opened) { - var idx = stored.indexOf(s); + var idx = store.indexOf(s); if (idx !== -1) { - stored.splice(idx, 1); + store.splice(idx, 1); } } - APP.store[LS_OPENED] = JSON.stringify(stored); - localStore.put(LS_OPENED, JSON.stringify(stored)); + localStorage[LOCALSTORAGE_OPENED] = JSON.stringify(store); }; var getViewModeClass = function () { - var mode = APP.store[LS_VIEWMODE]; - if (mode === 'list') { return 'cp-app-drive-content-list'; } - return 'cp-app-drive-content-grid'; + var mode = localStorage[LOCALSTORAGE_VIEWMODE]; + if (mode === 'list') { return 'list'; } + return 'grid'; }; var getViewMode = function () { - return APP.store[LS_VIEWMODE] || 'grid'; + return localStorage[LOCALSTORAGE_VIEWMODE] || 'grid'; }; var setViewMode = function (mode) { if (typeof(mode) !== "string") { logError("Incorrect view mode: ", mode); return; } - APP.store[LS_VIEWMODE] = mode; - localStore.put(LS_VIEWMODE, mode); + localStorage[LOCALSTORAGE_VIEWMODE] = mode; }; var setSearchCursor = function () { - var $input = $('#cp-app-drive-tree-search-input'); - APP.store[LS_SEARCHCURSOR] = $input[0].selectionStart; - localStore.put(LS_SEARCHCURSOR, $input[0].selectionStart); + var $input = APP.$iframe.find('#searchInput'); + localStorage.searchCursor = $input[0].selectionStart; }; var getSearchCursor = function () { - return APP.store[LS_SEARCHCURSOR] || 0; + return localStorage.searchCursor || 0; }; +/* var now = function () { + return new Date().getTime(); + }; */ + var setEditable = function (state) { APP.editable = state; if (!state) { - APP.$content.addClass('cp-app-drive-readonly'); - $('[draggable="true"]').attr('draggable', false); + APP.$iframe.find('#content').addClass('readonly'); + APP.$iframe.find('[draggable="true"]').attr('draggable', false); } else { - APP.$content.removeClass('cp-app-drive-readonly'); - $('[draggable="false"]').attr('draggable', true); + APP.$iframe.find('#content').removeClass('readonly'); + APP.$iframe.find('[draggable="false"]').attr('draggable', true); } }; // Icons - var $folderIcon = $('', { - "class": "fa fa-folder cp-app-drive-icon-folder cp-app-drive-content-icon" - }); + var $folderIcon = $('', {"class": "fa fa-folder folder icon"}); //var $folderIcon = $('', {src: "/customize/images/icons/folder.svg", "class": "folder icon"}); var $folderEmptyIcon = $folderIcon.clone(); - var $folderOpenedIcon = $('', {"class": "fa fa-folder-open cp-app-drive-icon-folder"}); + var $folderOpenedIcon = $('', {"class": "fa fa-folder-open folder"}); //var $folderOpenedIcon = $('', {src: "/customize/images/icons/folderOpen.svg", "class": "folder icon"}); var $folderOpenedEmptyIcon = $folderOpenedIcon.clone(); //var $upIcon = $('', {"class": "fa fa-arrow-circle-up"}); @@ -172,8 +166,8 @@ define([ var $recentIcon = $('', {"class": "fa fa-clock-o"}); var $trashIcon = $('', {"class": "fa fa-trash"}); var $trashEmptyIcon = $('', {"class": "fa fa-trash-o"}); - //var $collapseIcon = $('', {"class": "fa fa-minus-square-o cp-app-drive-icon-expcol"}); - var $expandIcon = $('', {"class": "fa fa-plus-square-o cp-app-drive-icon-expcol"}); + //var $collapseIcon = $('', {"class": "fa fa-minus-square-o expcol"}); + var $expandIcon = $('', {"class": "fa fa-plus-square-o expcol"}); var $emptyTrashIcon = $('