From e3f484d8766be78542fb2a806d378395df6e2ecc Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 19 Dec 2016 17:53:03 +0100 Subject: [PATCH] File manager in the home page, lint --- customize.dist/fsStore.js | 2 +- customize.dist/index.html | 11 +++--- customize.dist/main.css | 5 +++ customize.dist/main.js | 9 +++-- customize.dist/src/cryptpad.less | 6 +++ customize.dist/src/fragments/index.html | 7 ++-- customize.dist/translations/messages.fr.js | 2 + customize.dist/translations/messages.js | 3 +- www/file/main.js | 45 ++++++++++++++-------- www/poll/test/main.js | 2 +- 10 files changed, 61 insertions(+), 31 deletions(-) diff --git a/customize.dist/fsStore.js b/customize.dist/fsStore.js index f4bc6c21c..19a7e9de3 100644 --- a/customize.dist/fsStore.js +++ b/customize.dist/fsStore.js @@ -33,7 +33,7 @@ define([ // implement in alternative store Store.setBatch = function (map, cb) { Object.keys(map).forEach(function (key) { - safeSet(key, val); + safeSet(key, map[key]); }); cb(void 0, map); }; diff --git a/customize.dist/index.html b/customize.dist/index.html index 134683e07..a175cc1ff 100644 --- a/customize.dist/index.html +++ b/customize.dist/index.html @@ -40,7 +40,7 @@
-

Unity is Strength - Collaboration is Key

+

Unity is Strength - Collaboration is Key

@@ -65,9 +65,9 @@ OUPS Afin de pouvoir réaliser le cryptage depuis votre navigateur, Javascript est vraiment requis.

-
+
(Open in a new tab) - - + --> +
diff --git a/customize.dist/main.css b/customize.dist/main.css index e60adb50f..b9c517a63 100644 --- a/customize.dist/main.css +++ b/customize.dist/main.css @@ -321,6 +321,11 @@ tr { font-size: medium; padding-bottom: 1em; } +#fileManagerIframe { + width: 100%; + height: 500px; + margin-top: 15px; +} /* buttons */ .create, .action { diff --git a/customize.dist/main.js b/customize.dist/main.js index 732bce4b8..52804a105 100644 --- a/customize.dist/main.js +++ b/customize.dist/main.js @@ -123,16 +123,19 @@ define([ if (recentPads.length) { recentPads.sort(Cryptpad.mostRecent); - makeRecentPadsTable(recentPads); + $('iframe').attr('style', ''); + $tryit.removeAttr('data-localization'); + $tryit.text(Messages.recentPadsIframe); + //makeRecentPadsTable(recentPads); } - if (hasRecent) { + /*if (hasRecent) { $('table').attr('style', ''); // Race condition here, this is triggered before the localization in HTML // so we have to remove the data-localization attr $tryit.removeAttr('data-localization'); $tryit.text(Messages.recentPads); - } + }*/ }); }; diff --git a/customize.dist/src/cryptpad.less b/customize.dist/src/cryptpad.less index 1900fead5..07fc138aa 100644 --- a/customize.dist/src/cryptpad.less +++ b/customize.dist/src/cryptpad.less @@ -150,6 +150,12 @@ p, pre, td, a, table, tr { padding-bottom: 1em; } +#fileManagerIframe { + width: 100%; + height: 500px; + margin-top: 15px; +} + /* buttons */ .create, .action { @thick: 2px; diff --git a/customize.dist/src/fragments/index.html b/customize.dist/src/fragments/index.html index d37dca8ba..7ba94d117 100644 --- a/customize.dist/src/fragments/index.html +++ b/customize.dist/src/fragments/index.html @@ -25,9 +25,9 @@ OUPS Afin de pouvoir réaliser le cryptage depuis votre navigateur, Javascript est vraiment requis.

-
+
(Open in a new tab) - + +
diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index fbc2a3c25..652d0943c 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -104,6 +104,7 @@ define(function () { out.tryIt = 'Essayez-le !'; out.recentPads = 'Vos documents récents (stockés uniquement dans votre navigateur)'; + out.recentPadsIframe = 'Vos documents récents'; out.okButton = 'OK (Entrée)'; out.cancelButton = 'Annuler (Echap)'; @@ -217,6 +218,7 @@ define(function () { out.main_about = 'À propos'; out.main_about_p1 = 'Vous pouvez en apprendre davantage sur notre politique de confidentialité et nos conditions d\'utilisation.'; out.main_about_p2 = 'Si vous avez des questions ou commentaires, vous pouvez nous tweeter, ouvrir une issue sur Github, venir dire bonjour sur IRC (irc.freenode.net), ou nous envoyer un email.'; + out.main_openFileManager = 'Ouvrir dans un nouvel onglet'; out.table_type = 'Type'; out.table_link = 'Lien'; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index 81c0eb0f8..5aebf625b 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -107,6 +107,7 @@ define(function () { out.tryIt = 'Try it out!'; out.recentPads = 'Your recent pads (stored only in your browser)'; + out.recentPadsIframe = 'Your recent pads'; out.okButton = 'OK (enter)'; out.cancelButton = 'Cancel (esc)'; @@ -219,8 +220,8 @@ define(function () { out.main_howitworks_p1 = 'CryptPad uses a variant of the Operational transformation algorithm which is able to find distributed consensus using a Nakamoto Blockchain, a construct popularized by Bitcoin. This way the algorithm can avoid the need for a central server to resolve Operational Transform Edit Conflicts and without the need for resolving conflicts, the server can be kept unaware of the content which is being edited on the pad.'; out.main_about = 'About'; out.main_about_p1 = 'You can read more about our privacy policy and terms of service.'; - out.main_about_p2 = 'If you have any questions or comments, you can tweet us, open an issue on github, come say hi on irc (irc.freenode.net), or send us an email.'; + out.main_openFileManager = 'Open in a new tab'; out.table_type = 'Type'; out.table_link = 'Link'; diff --git a/www/file/main.js b/www/file/main.js index ed1b64ecc..e35bb2c2d 100644 --- a/www/file/main.js +++ b/www/file/main.js @@ -227,7 +227,7 @@ define([ appStatus._onReady.forEach(function (h) { h(); }); - _onReady = []; + appStatus._onReady = []; } } }; @@ -348,6 +348,7 @@ define([ // Open the selected context menu on the closest "li" element var openContextMenu = function (e, $menu) { module.hideMenu(); + e.stopPropagation(); var path = $(e.target).closest('li').data('path'); if (!path) { return; } @@ -744,13 +745,14 @@ define([ var SORT_FILE_DESC = 'sortFilesDesc'; var onSortByClick = function (e) { var $span = $(this); + var value; if ($span.hasClass('foldername')) { - var value = files[SORT_FOLDER_DESC]; + value = files[SORT_FOLDER_DESC]; files[SORT_FOLDER_DESC] = value ? false : true; refresh(); return; } - var value = files[SORT_FILE_BY]; + value = files[SORT_FILE_BY]; var descValue = files[SORT_FILE_DESC]; if ($span.hasClass('filename')) { if (value === '') { @@ -1234,7 +1236,7 @@ define([ var i = 0; var space = 10; path.forEach(function (s) { - if (i === 0) { s = rootName(s) } + if (i === 0) { s = rootName(s); } $div.append($('', {'style': 'margin: 0 0 0 ' + i * space + 'px;'}).text(s)); $div.append($('
')); i++; @@ -1263,7 +1265,7 @@ define([ else if ($(this).hasClass('newfolder')) { var onCreated = function (info) { module.newFolder = info.newPath; - module.displayDirectory(path);; + module.displayDirectory(path); }; filesOp.createNewFolder(path, null, onCreated); } @@ -1437,14 +1439,9 @@ define([ Cryptpad.styleAlerts(); if (window.location.hash && window.location.hash === "#iframe") { - $('.top-bar').hide(); - $('#pad-iframe').css({ - top: "0px", - height: "100%" - }); $iframe.find('body').addClass('iframe'); window.location.hash = ""; - homePageIframe = true; + APP.homePageIframe = true; } var hash = window.location.hash.slice(1) || localStorage.FS_hash; @@ -1465,8 +1462,8 @@ define([ rt.proxy.on('create', function (info) { var realtime = module.realtime = info.realtime; - var editHash = !readOnly ? Cryptpad.getEditHashFromKeys(info.channel, secret.keys) : undefined; - var viewHash = Cryptpad.getViewHashFromKeys(info.channel, secret.keys); + var editHash = APP.editHash = !readOnly ? Cryptpad.getEditHashFromKeys(info.channel, secret.keys) : undefined; + var viewHash = APP.viewHash = Cryptpad.getViewHashFromKeys(info.channel, secret.keys); APP.hash = readOnly ? viewHash : editHash; if (!readOnly && (!window.location.hash || !localStorage.FS_hash)) { @@ -1478,7 +1475,7 @@ define([ logging: true, }); - userList = APP.userList = info.userList; + var userList = APP.userList = info.userList; var config = { readOnly: readOnly, ifrw: window, @@ -1490,8 +1487,23 @@ define([ var $bar = APP.$bar; var $rightside = $bar.find('.' + Toolbar.constants.rightside); var $userBlock = $bar.find('.' + Toolbar.constants.username); - var $editShare = $bar.find('.' + Toolbar.constants.editShare); - var $viewShare = $bar.find('.' + Toolbar.constants.viewShare); + + if (APP.homePageIframe) { + var $linkToMain = $bar.find('.cryptpad-link a'); + $linkToMain.attr('href', '#'); + $linkToMain.attr('title', ''); + $linkToMain.css('cursor', 'default'); + $linkToMain.off('click'); + } + + if (!readOnly) { + var $backupButton = Cryptpad.createButton('', true); + $backupButton.on('click', function() { + var url = window.location.origin + window.location.pathname + '#' + editHash; + Cryptpad.alert("Backup URL for this pad. It is highly recommended that you do not share it with other people.
Anybody with that URL can remove all the files in your file manager.
" + url); + }); + $userBlock.append($backupButton); + } }).on('ready', function () { module.files = rt.proxy; @@ -1506,6 +1518,7 @@ define([ } initLocalStorage(); init(rt.proxy); + APP.userList.onChange(); }) .on('disconnect', function (info) { setEditable(false); diff --git a/www/poll/test/main.js b/www/poll/test/main.js index 0979ec4e9..3f72e47ac 100644 --- a/www/poll/test/main.js +++ b/www/poll/test/main.js @@ -660,7 +660,7 @@ define([ }); }; - var disconnect = function () { + var disconnect = function (info) { //setEditable(false); // TODO if (info.error) { Cryptpad.alert(Messages.websocketError);