From 0e5b82f3348508eb7f4291a08722522a49edd752 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 5 Nov 2018 16:03:56 +0100 Subject: Facilitate file sending in chat --- shardweb/assets/js/app.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'shardweb/assets/js') diff --git a/shardweb/assets/js/app.js b/shardweb/assets/js/app.js index 1e5ea62..f3372f1 100644 --- a/shardweb/assets/js/app.js +++ b/shardweb/assets/js/app.js @@ -20,7 +20,9 @@ import "phoenix_html" import socket from "./socket" -import routes from './phoenix-jsroutes' +function parse_links(msg) { + return msg.replace(/shard:file:([0-9A-F]{64})/gi, '$&'); +} var chat_channel = window.Gon.getAsset('chat_channel'); if (chat_channel != undefined) @@ -30,7 +32,7 @@ if (chat_channel != undefined) channel.on('shout', function (payload) { // listen to the 'shout' event var li = document.createElement("li"); // creaet new list item DOM element var name = payload.name || 'guest'; // get name from payload or set default - li.innerHTML = '<' + name + ' ' + payload.pk16 + '> ' + payload.message; // set li contents + li.innerHTML = '<' + name + ' ' + payload.pk16 + '> ' + parse_links(payload.message); // set li contents // console.log(ul.scrollTop + ' ' + ul.scrollHeight + ' ' + ul.clientHeight); var must_scroll = (ul.scrollTop >= ul.scrollHeight - ul.clientHeight - 10); -- cgit v1.2.3