diff --git a/customize.dist/pages.js b/customize.dist/pages.js index f9a5addc6..784fc007f 100644 --- a/customize.dist/pages.js +++ b/customize.dist/pages.js @@ -657,10 +657,6 @@ define([ return loadingScreen(); }; - Pages['/contacts2/'] = Pages['/contacts2/index.html'] = function () { - return loadingScreen(); - }; - Pages['/pad/'] = Pages['/pad/index.html'] = function () { return loadingScreen(); }; diff --git a/customize.dist/src/less2/include/modal.less b/customize.dist/src/less2/include/modal.less index 21cc69e97..ed63ea6fd 100644 --- a/customize.dist/src/less2/include/modal.less +++ b/customize.dist/src/less2/include/modal.less @@ -15,3 +15,63 @@ } } } + +.cp-modal-container { + display: none; + + z-index: 100000; + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + background-color: @colortheme_modal-dim; + + .cp-modal { + background-color: @colortheme_modal-bg; + color: @colortheme_modal-fg; + box-shadow: @colortheme_modal-shadow; + + padding: @colortheme_modal-padding; + + position: absolute; + top: 15vh; bottom: 15vh; + left: 10vw; right: 10vw; + + overflow: auto; + + font-family: @colortheme_font; + text-align: center; + + & > p { + margin-bottom: 1em; + } + + .cp-modal-form { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: center; + } + + input { + background-color: @colortheme_modal-input; + color: @colortheme_modal-fg; + border: 0; + padding: 8px 12px; + margin: 1em; + width: 300px; + } + + .cp-modal-close { + text-shadow: none; + color: inherit; + + position: absolute; + top: 0; + right: 0; + margin: @colortheme_modal-padding; + cursor: pointer; + } + } +} diff --git a/customize.dist/template.js b/customize.dist/template.js index a980270a3..062be4308 100644 --- a/customize.dist/template.js +++ b/customize.dist/template.js @@ -9,7 +9,7 @@ define([ $(function () { var $body = $('body'); var isMainApp = function () { - return /^\/(pad|code|slide|poll|whiteboard|file|media|contacts|contacts2|drive|settings|profile|todo)\/$/.test(location.pathname); + return /^\/(pad|code|slide|poll|whiteboard|file|media|contacts|drive|settings|profile|todo)\/$/.test(location.pathname); }; var infoPage = function () { @@ -55,9 +55,6 @@ $(function () { } else if (/^\/contacts\/$/.test(pathname)) { $('body').append(h('body', Pages[pathname]()).innerHTML); require([ '/contacts/main.js' ], ready); - } else if (/contacts2/.test(pathname)) { - $('body').append(h('body', Pages[pathname]()).innerHTML); - require([ '/contacts2/main.js' ], ready); } else if (/pad/.test(pathname)) { $('body').append(h('body', Pages[pathname]()).innerHTML); require([ '/pad/main.js' ], ready); diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index ed955b373..dfeb46371 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -301,6 +301,7 @@ define(function () { out.fm_filesDataName = "Tous les fichiers"; out.fm_templateName = "Modèles"; out.fm_searchName = "Recherche"; + out.fm_recentPadsName = "Pads récents"; out.fm_searchPlaceholder = "Rechercher..."; out.fm_newButton = "Nouveau"; out.fm_newButtonTitle = "Créer un nouveau pad ou un dossier, importer un fichier dans le dossier courant"; @@ -332,6 +333,7 @@ define(function () { out.fm_info_root = "Créez ici autant de dossiers que vous le souhaitez pour trier vos fichiers."; out.fm_info_unsorted = 'Contient tous les pads que vous avez ouvert et qui ne sont pas triés dans "Documents" ou déplacés vers la "Corbeille".'; // "My Documents" should match with the "out.fm_rootName" key, and "Trash" with "out.fm_trashName" out.fm_info_template = "Contient tous les fichiers que vous avez sauvés en tant que modèle afin de les réutiliser lors de la création d'un nouveau pad."; + out.fm_info_recent = "Liste les derniers pads que vous avez modifiés ou ouverts."; out.updated_0_fm_info_trash = "Vider la corbeille permet de libérer de l'espace dans votre CryptDrive"; out.fm_info_trash = out.updated_0_fm_info_trash; out.fm_info_allFiles = 'Contient tous les fichiers de "Documents", "Fichiers non triés" et "Corbeille". Vous ne pouvez pas supprimer ou déplacer des fichiers depuis cet endroit.'; // Same here diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index d5aa373df..661254f5d 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -303,6 +303,7 @@ define(function () { out.fm_filesDataName = "All files"; out.fm_templateName = "Templates"; out.fm_searchName = "Search"; + out.fm_recentPadsName = "Recent pads"; out.fm_searchPlaceholder = "Search..."; out.fm_newButton = "New"; out.fm_newButtonTitle = "Create a new pad or folder, import a file in the current folder"; @@ -334,6 +335,7 @@ define(function () { out.fm_info_root = "Create as many nested folders here as you want to sort your files."; out.fm_info_unsorted = 'Contains all the files you\'ve visited that are not yet sorted in "Documents" or moved to the "Trash".'; // "My Documents" should match with the "out.fm_rootName" key, and "Trash" with "out.fm_trashName" out.fm_info_template = 'Contains all the pads stored as templates and that you can re-use when you create a new pad.'; + out.fm_info_recent = "List the recently modified or opened pads."; out.updated_0_fm_info_trash = 'Empty your trash to free space in your CryptDrive.'; out.fm_info_trash = out.updated_0_fm_info_trash; out.fm_info_allFiles = 'Contains all the files from "Documents", "Unsorted" and "Trash". You can\'t move or remove files from here.'; // Same here diff --git a/www/common/common-messaging.js b/www/common/common-messaging.js index e4f2d20e3..7d75a7393 100644 --- a/www/common/common-messaging.js +++ b/www/common/common-messaging.js @@ -6,62 +6,16 @@ define([ '/bower_components/marked/marked.min.js', '/common/common-realtime.js', - - // displayAvatar - // whenRealtimeSyncs - // getRealtime -> removeFromFriendList - /* UI - Messages - confirm - fixHTML - displayAvatar - clearOwnedChannel - alert - - - pushMsg - removeFromFriendList - - onDirectMessage - getNetwork - getProxy - pushMsg - - Init - getNetwork - getProxy - onDirectMessage - removeFromFriendList - notify - onMessage - - */ - ], function ($, Crypto, Curve, Hash, Marked, Realtime) { var Msg = { inputs: [], }; - - var Types = { - message: 'MSG', - update: 'UPDATE', - unfriend: 'UNFRIEND', - mapId: 'MAP_ID', - mapIdAck: 'MAP_ID_ACK' - }; - // TODO // - mute a channel (hide notifications or don't open it?) - - var ready = []; var pending = {}; var pendingRequests = []; - var parseMessage = function (content) { - return Marked(content); - }; - var createData = Msg.createData = function (proxy, hash) { return { channel: hash || Hash.createChannelId(), @@ -82,13 +36,6 @@ define([ return proxy.friends ? proxy.friends[pubkey] : undefined; }; - var removeFromFriendList = function (proxy, realtime, curvePublic, cb) { - if (!proxy.friends) { return; } - var friends = proxy.friends; - delete friends[curvePublic]; - Realtime.whenRealtimeSyncs(realtime, cb); - }; - var getFriendList = Msg.getFriendList = function (proxy) { if (!proxy.friends) { proxy.friends = {}; } return proxy.friends; @@ -101,7 +48,6 @@ define([ }); }; - Msg.getFriendChannelsList = function (proxy) { var list = []; eachFriend(proxy, function (friend) { @@ -110,500 +56,9 @@ define([ return list; }; - // Messaging tools - var avatars = {}; - // TODO make this internal to the messenger var channels = Msg.channels = window.channels = {}; - var UI = Msg.UI = {}; - - UI.init = function (common, $listContainer, $msgContainer) { - var ui = { - containers: { - friendList: $listContainer, - messages: $msgContainer, - }, - }; - - ui.addToFriendList = function (data, display, remove) { - var $block = ui.containers.friendBlock; - - var $friend = $('
', {'class': 'friend avatar'}).appendTo($block); - $friend.data('key', data.curvePublic); - var $rightCol = $('', {'class': 'right-col'}); - $('', {'class': 'name'}).text(data.displayName).appendTo($rightCol); - var $remove = $('', {'class': 'remove fa fa-user-times'}).appendTo($rightCol); - $remove.attr('title', common.Messages.contacts_remove); - $friend.dblclick(function () { - if (data.profile) { - window.open('/profile/#' + data.profile); - } - }); - $friend.click(function () { - display(data.curvePublic); - }); - $remove.click(function (e) { - e.stopPropagation(); - common.confirm(common.Messages._getKey('contacts_confirmRemove', [ - common.fixHTML(data.displayName) - ]), function (yes) { - if (!yes) { return; } - remove(data.curvePublic); - }, null, true); - }); - if (data.avatar && avatars[data.avatar]) { - $friend.append(avatars[data.avatar]); - $friend.append($rightCol); - } else { - common.displayAvatar($friend, data.avatar, data.displayName, function ($img) { - if (data.avatar && $img) { - avatars[data.avatar] = $img[0].outerHTML; - } - $friend.append($rightCol); - }); - } - $('', {'class': 'status'}).appendTo($friend); - }; - - ui.createFriendList = function (friends, display, remove) { - var $block = ui.containers.friendBlock = $('
'); - eachFriend(friends, function (friend) { - ui.addToFriendList(friend, display, remove); - }); - $block.appendTo($listContainer); - }; - - ui.notify = function (curvePublic) { - var $friend = $listContainer.find('.friend').filter(function (idx, el) { - return $(el).data('key') === curvePublic; - }); - $friend.addClass('notify'); - }; - - ui.unnotify = function (curvePublic) { - var $friend = $listContainer.find('.friend').filter(function (idx, el) { - return $(el).data('key') === curvePublic; - }); - $friend.removeClass('notify'); - }; - - ui.update = function (curvePublic, types) { - var proxy = common.getProxy(); - var data = getFriend(proxy, curvePublic); - var chan = channels[data.channel]; - if (!chan.ready) { - chan.updateOnReady = (chan.updateOnReady || []).concat(types); - return; - } - var $friend = $listContainer.find('.friend').filter(function (idx, el) { - return $(el).data('key') === curvePublic; - }); - if (types.indexOf('displayName') >= 0) { - $friend.find('.name').text(data.displayName); - } - if (types.indexOf('avatar') >= 0) { - $friend.find('.default').remove(); - $friend.find('media-tag').remove(); - if (data.avatar && avatars[data.avatar]) { - $friend.prepend(avatars[data.avatar]); - } else { - common.displayAvatar($friend, data.avatar, data.displayName, function ($img) { - if (data.avatar && $img) { - avatars[data.avatar] = $img[0].outerHTML; - } - }); - } - } - }; - - ui.updateStatus = function (curvePublic, online) { - ui.getFriend(curvePublic).find('.status') - .attr('class', 'status ' + (online? 'online' : 'offline')); - }; - - ui.getChannel = function (curvePublic) { - var $chat = $msgContainer.find('.chat').filter(function (idx, el) { - return $(el).data('key') === curvePublic; - }); - return $chat.length? $chat: null; - }; - - ui.hideInfo = function () { - $msgContainer.find('.info').hide(); - }; - - ui.showInfo = function () { - $msgContainer.find('.info').show(); - }; - - ui.createChat = function (curvePublic) { - return $('
', {'class':'chat'}) - .data('key', curvePublic).appendTo($msgContainer); - }; - - ui.hideChat = function () { - $msgContainer.find('.chat').hide(); - }; - - ui.getFriend = function (curvePublic) { - return $listContainer.find('.friend').filter(function (idx, el) { - return $(el).data('key') === curvePublic; - }); - }; - - ui.remove = function (curvePublic) { - var $friend = ui.getFriend(curvePublic); - var $chat = ui.getChannel(curvePublic); - $friend.remove(); - if ($chat) { $chat.remove(); } - ui.showInfo(); - }; - - ui.createMessage = function (msg, name) { - var $msg = $('
', {'class': 'message'}) - .attr('title', msg.time ? new Date(msg.time).toLocaleString(): '?'); - - if (name) { - $('
', {'class':'sender'}).text(name).appendTo($msg); - } - - $('
', {'class':'content'}).html(parseMessage(msg.text)).appendTo($msg); - return $msg; - }; - - ui.setEditable = function (bool) { - bool = !bool; - var input = ui.input; - if (!input) { return; } - - if (bool) { - input.setAttribute('disabled', bool); - } else { - input.removeAttribute('disabled'); - } - - if (common.Messages) { - // set placeholder - var placeholder = bool? - common.Messages.disconnected: - common.Messages.contacts_typeHere; - input.setAttribute('placeholder', placeholder); - } - }; - - ui.createChatBox = function (proxy, $container, curvePublic) { - var data = getFriend(proxy, curvePublic); - - // Input - var channel = channels[data.channel]; - - var $header = $('
', { - 'class': 'header', - }).appendTo($container); - - var $avatar = $('
', {'class': 'avatar'}).appendTo($header); - - // more history... - $('', { - 'class': 'more-history', - }) - .text('get more history') - .click(function () { - console.log("GETTING HISTORY"); - channel.getPreviousMessages(); - }) - .appendTo($header); - - var $removeHistory = $('', { - 'class': 'remove-history fa fa-eraser', - title: common.Messages.contacts_removeHistoryTitle - }) - .click(function () { - common.confirm(common.Messages.contacts_confirmRemoveHistory, function (yes) { - if (!yes) { return; } - common.clearOwnedChannel(data.channel, function (e) { - if (e) { - console.error(e); - common.alert(common.Messages.contacts_removeHistoryServerError); - return; - } - }); - }); - }); - $removeHistory.appendTo($header); - - $('
', {'class': 'messages'}).appendTo($container); - var $inputBlock = $('
', {'class': 'input'}).appendTo($container); - - var $input = $('