From e2d031c76a4c610ef96378d28834f76afc91aac4 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 19 Jul 2017 10:29:59 +0200 Subject: [PATCH] Add support for markdown syntax in contacts --- www/common/common-messaging.js | 56 ++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/www/common/common-messaging.js b/www/common/common-messaging.js index 51777b607..59b2f16c6 100644 --- a/www/common/common-messaging.js +++ b/www/common/common-messaging.js @@ -1,8 +1,9 @@ define([ 'jquery', '/bower_components/chainpad-crypto/crypto.js', - '/common/curve.js' -], function ($, Crypto, Curve) { + '/common/curve.js', + '/bower_components/marked/marked.min.js', +], function ($, Crypto, Curve, Marked) { var Msg = {}; var Types = { @@ -19,6 +20,10 @@ define([ var ready = []; var pending = {}; + var parseMessage = function (content) { + return Marked(content); + }; + var createData = Msg.createData = function (common, hash) { var proxy = common.getProxy(); return { @@ -199,6 +204,7 @@ define([ var onChannelReady = function (common, chanId) { if (ready.indexOf(chanId) !== -1) { return; } ready.push(chanId); + channels[chanId].updateStatus(); var friends = getFriendList(common); if (ready.length === Object.keys(friends).length) { // All channels are ready @@ -220,8 +226,9 @@ define([ if (!isId) { return; } var decryptedMsg = channel.encryptor.decrypt(msg); + console.log(decryptedMsg); var parsed = JSON.parse(decryptedMsg); - if (parsed[0] !== Types.mapId && parsed[0] !== Types.mapidAck) { return; } + if (parsed[0] !== Types.mapId && parsed[0] !== Types.mapIdAck) { return; } if (parsed[2] !== sender || !parsed[1]) { return; } channel.mapId[sender] = parsed[1]; @@ -300,7 +307,9 @@ define([ // Input var channel = channels[data.channel]; - var $input = $('', {type: 'text'}).appendTo($inputBlock); + var $input = $('