diff --git a/customize.dist/main.js b/customize.dist/main.js index 77fd2eaa3..73c39ced5 100644 --- a/customize.dist/main.js +++ b/customize.dist/main.js @@ -2,7 +2,8 @@ define([ 'jquery', '/customize/application_config.js', '/common/cryptpad-common.js', -], function ($, Config, Cryptpad) { + '/common/common-interface.js', +], function ($, Config, Cryptpad, UI) { window.APP = { Cryptpad: Cryptpad, @@ -57,34 +58,6 @@ define([ $('#name').focus(); } - var displayCreateButtons = function () { - var $parent = $('#buttons'); - var options = []; - var $container = $('
', {'class': 'cp-dropdown-container'}).appendTo($parent); - Config.availablePadTypes.forEach(function (el) { - if (el === 'drive') { return; } - if (!Cryptpad.isLoggedIn() && Config.registeredOnlyTypes && - Config.registeredOnlyTypes.indexOf(el) !== -1) { return; } - options.push({ - tag: 'a', - attributes: { - 'class': 'newdoc', - 'href': '/' + el + '/', - 'target': '_blank' - }, - content: Messages['button_new' + el] // Pretty name of the language value - }); - }); - var dropdownConfig = { - text: Messages.login_makeAPad, // Button initial text - options: options, // Entries displayed in the menu - container: $container - }; - var $block = Cryptpad.createDropdown(dropdownConfig); - $block.find('button').addClass('btn').addClass('btn-primary'); - $block.appendTo($parent); - }; - /* Log in UI */ var Login; // deferred execution to avoid unnecessary asset loading @@ -144,17 +117,17 @@ define([ switch (err) { case 'NO_SUCH_USER': Cryptpad.removeLoadingScreen(function () { - Cryptpad.alert(Messages.login_noSuchUser); + UI.alert(Messages.login_noSuchUser); }); break; case 'INVAL_USER': Cryptpad.removeLoadingScreen(function () { - Cryptpad.alert(Messages.login_invalUser); + UI.alert(Messages.login_invalUser); }); break; case 'INVAL_PASS': Cryptpad.removeLoadingScreen(function () { - Cryptpad.alert(Messages.login_invalPass); + UI.alert(Messages.login_invalPass); }); break; default: // UNHANDLED ERROR @@ -166,27 +139,6 @@ define([ }, 100); }); /* End Log in UI */ - - var addButtonHandlers = function () { - $('button.register').click(function () { - var username = $('#name').val(); - var passwd = $('#password').val(); - sessionStorage.login_user = username; - sessionStorage.login_pass = passwd; - document.location.href = '/register/'; - }); - $('button.gotodrive').click(function () { - document.location.href = '/drive/'; - }); - - $('button#loggedInLogout').click(function () { - $('#user-menu .logout').click(); - }); - }; - - displayCreateButtons(); - - addButtonHandlers(); console.log("ready"); }); }); diff --git a/customize.dist/messages.js b/customize.dist/messages.js index 7230a719d..e1142e2df 100644 --- a/customize.dist/messages.js +++ b/customize.dist/messages.js @@ -30,7 +30,6 @@ if (language && map[language]) { req.push('/customize/translations/messages.' + define(req, function($, Default, Language) { map.en = 'English'; var defaultLanguage = 'en'; -console.log(messages); if (!Language || language === defaultLanguage || !map[language]) { messages = $.extend(true, messages, Default); @@ -39,7 +38,6 @@ console.log(messages); // Add the translated keys to the returned object messages = $.extend(true, messages, Default, Language); } -console.log(messages); messages._languages = map; messages._languageUsed = language; diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index a94907da8..ba7dbb893 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -488,12 +488,12 @@ define(function () { out.settings_resetTipsButton = "Réinitialiser les astuces visibles dans CryptDrive"; out.settings_resetTipsDone = "Toutes les astuces sont de nouveau visibles."; - out.settings_thumbnails = "Vignettes"; - out.settings_disableThumbnailsAction = "Désactiver la création de vignettes dans CryptDrive"; - out.settings_disableThumbnailsDescription = "Des vignettes de vos pads sont automatiquement créées et stockées dans votre navigateur. Vous pouvez désactiver cette fonctionnalité."; + out.settings_thumbnails = "Miniatures"; + out.settings_disableThumbnailsAction = "Désactiver la création de miniatures dans CryptDrive"; + out.settings_disableThumbnailsDescription = "Des miniatures de vos pads sont automatiquement créées et stockées dans votre navigateur. Vous pouvez désactiver cette fonctionnalité."; out.settings_resetThumbnailsAction = "Nettoyer"; - out.settings_resetThumbnailsDescription = "Nettoyer toutes les vignettes stockées dans votre navigateur."; - out.settings_resetThumbnailsDone = "Toutes les vignettes ont été effacées."; + out.settings_resetThumbnailsDescription = "Nettoyer toutes les miniatures stockées dans votre navigateur."; + out.settings_resetThumbnailsDone = "Toutes les miniatures ont été effacées."; out.settings_importTitle = "Importer les pads récents de ce navigateur dans votre CryptDrive"; out.settings_import = "Importer"; diff --git a/www/common/common-messaging.js b/www/common/common-messaging.js index 679c1a747..e640b86a8 100644 --- a/www/common/common-messaging.js +++ b/www/common/common-messaging.js @@ -3,10 +3,12 @@ define([ '/bower_components/chainpad-crypto/crypto.js', '/common/curve.js', '/common/common-hash.js', + '/common/common-util.js', + '/customize/messages.js', '/bower_components/marked/marked.min.js', '/common/common-realtime.js', -], function ($, Crypto, Curve, Hash, Marked, Realtime) { +], function ($, Crypto, Curve, Hash, Util, Messages, Marked, Realtime) { var Msg = { inputs: [], }; @@ -98,7 +100,7 @@ define([ var msg; if (sender === network.historyKeeper) { return; } try { - var parsed = common.parsePadUrl(window.location.href); + var parsed = Hash.parsePadUrl(window.location.href); if (!parsed.hashData) { return; } var chan = parsed.hashData.channel; // Decrypt @@ -132,11 +134,11 @@ define([ todo(true); return; } - var confirmMsg = common.Messages._getKey('contacts_request', [ - common.fixHTML(msgData.displayName) + var confirmMsg = Messages._getKey('contacts_request', [ + Util.fixHTML(msgData.displayName) ]); common.onFriendRequest(confirmMsg, todo); - //common.confirm(confirmMsg, todo, null, true); + //UI.confirm(confirmMsg, todo, null, true); return; } if (msg[0] === "FRIEND_REQ_OK") { @@ -147,12 +149,12 @@ define([ addToFriendList(common, msgData, function (err) { if (err) { return void common.onFriendComplete({ - logText: common.Messages.contacts_addError, + logText: Messages.contacts_addError, netfluxId: sender }); } common.onFriendComplete({ - logText: common.Messages.contacts_added, + logText: Messages.contacts_added, netfluxId: sender }); var msg = ["FRIEND_REQ_ACK", chan]; @@ -165,7 +167,7 @@ define([ var i = pendingRequests.indexOf(sender); if (i !== -1) { pendingRequests.splice(i, 1); } common.onFriendComplete({ - logText: common.Messages.contacts_rejected, + logText: Messages.contacts_rejected, netfluxId: sender }); common.changeDisplayName(proxy[common.displayNameKey]); @@ -177,12 +179,12 @@ define([ addToFriendList(common, data, function (err) { if (err) { return void common.onFriendComplete({ - logText: common.Messages.contacts_addError, + logText: Messages.contacts_addError, netfluxId: sender }); } common.onFriendComplete({ - logText: common.Messages.contacts_added, + logText: Messages.contacts_added, netfluxId: sender }); }); @@ -201,7 +203,7 @@ define([ Msg.inviteFromUserlist = function (common, netfluxId) { var network = common.getNetwork(); - var parsed = common.parsePadUrl(window.location.href); + var parsed = Hash.parsePadUrl(window.location.href); if (!parsed.hashData) { return; } // Message var chan = parsed.hashData.channel; diff --git a/www/common/common-realtime.js b/www/common/common-realtime.js index ab7d0abfb..26c33c4d4 100644 --- a/www/common/common-realtime.js +++ b/www/common/common-realtime.js @@ -1,7 +1,8 @@ define([ '/customize/application_config.js', '/customize/messages.js', -], function (AppConfig, Messages) { + '/common/common-interface.js', +], function (AppConfig, Messages, UI) { var common = {}; common.infiniteSpinnerDetected = false; @@ -44,7 +45,7 @@ define([ infiniteSpinnerHandlers.forEach(function (ish) { ish(); }); // inform the user their session is in a bad state - Cryptpad.confirm(Messages.realtime_unrecoverableError, function (yes) { + UI.confirm(Messages.realtime_unrecoverableError, function (yes) { if (!yes) { return; } window.parent.location.reload(); }); diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index 33e7be295..f955f8206 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -4,13 +4,14 @@ define([ '/common/cryptpad-common.js', '/common/common-util.js', '/common/common-language.js', + '/common/common-interface.js', '/common/media-tag.js', '/common/tippy.min.js', '/customize/application_config.js', 'css!/common/tippy.css', -], function ($, Config, Cryptpad, Util, Language, MediaTag, Tippy, AppConfig) { - var UI = {}; +], function ($, Config, Cryptpad, Util, UI, Language, MediaTag, Tippy, AppConfig) { + var UIElements = {}; var Messages = Cryptpad.Messages; /** @@ -24,17 +25,14 @@ define([ * - base64ToHex * - getBlobPathFromHex * - bytesToMegabytes - * createUserAdminMenu - * - fixHTML - * - createDropdown */ - UI.updateTags = function (common, href) { + UIElements.updateTags = function (common, href) { var sframeChan = common.getSframeChannel(); sframeChan.query('Q_TAGS_GET', href || null, function (err, res) { if (err || res.error) { if (res.error === 'NO_ENTRY') { - Cryptpad.alert(Messages.tags_noentry); + UI.alert(Messages.tags_noentry); } return void console.error(err || res.error); } @@ -48,7 +46,7 @@ define([ }); }; - UI.createButton = function (common, type, rightside, data, callback) { + UIElements.createButton = function (common, type, rightside, data, callback) { var AppConfig = common.getAppConfig(); var button; var size = "17px"; @@ -93,7 +91,7 @@ define([ target: data.target }; if (data.filter && !data.filter(file)) { - Cryptpad.log('Invalid avatar (type or size)'); + UI.log('Invalid avatar (type or size)'); return; } data.FM.handleFile(file, ev); @@ -142,11 +140,11 @@ define([ title: title, toSave: toSave }, function () { - Cryptpad.alert(Messages.templateSaved); + UI.alert(Messages.templateSaved); common.feedback('TEMPLATE_CREATED'); }); }; - Cryptpad.prompt(Messages.saveTemplatePrompt, title, todo); + UI.prompt(Messages.saveTemplatePrompt, title, todo); }); } break; @@ -162,12 +160,12 @@ define([ .click(common.prepareFeedback(type)) .click(function() { var msg = common.isLoggedIn() ? Messages.forgetPrompt : Messages.fm_removePermanentlyDialog; - Cryptpad.confirm(msg, function (yes) { + UI.confirm(msg, function (yes) { if (!yes) { return; } sframeChan.query('Q_MOVE_TO_TRASH', null, function (err) { if (err) { return void callback(err); } var cMsg = common.isLoggedIn() ? Messages.movedToTrash : Messages.deleted; - Cryptpad.alert(cMsg, undefined, true); + UI.alert(cMsg, undefined, true); callback(); return; }); @@ -220,7 +218,7 @@ define([ title: Messages.tags_title, }) .click(common.prepareFeedback(type)) - .click(function () { UI.updateTags(common, null); }); + .click(function () { UIElements.updateTags(common, null); }); break; default: button = $('