diff --git a/README b/README index 00f46fc..f34f226 100644 --- a/README +++ b/README @@ -50,6 +50,10 @@ There is a user list on the left. Clicking on a user opens a menu with actions that can be applied to that user. Clicking on ones own username opens a menu with actions that are global to the group. +### Chat pane + +Double-clicking on a message opens a contextual menu. + ### Text box Typing a string in the text box at the bottom of the chat pane sends diff --git a/static/galene.js b/static/galene.js index d8fdb41..8678c97 100644 --- a/static/galene.js +++ b/static/galene.js @@ -2952,6 +2952,19 @@ function addToChatbox(peerId, dest, nick, time, privileged, history, kind, messa if(dest) container.classList.add('message-private'); + if(peerId) { + container.dataset.peerId = peerId; + container.dataset.username = nick; + container.addEventListener('click', function(e) { + if(e.detail !== 2) + return; + let elt = e.currentTarget; + if(!elt || !(elt instanceof HTMLElement)) + throw new Error("Couldn't find chat message div"); + chatMessageMenu(elt); + }); + } + /** @type{HTMLElement} */ let body; if(message instanceof HTMLElement) { @@ -3027,6 +3040,34 @@ function addToChatbox(peerId, dest, nick, time, privileged, history, kind, messa return message; } +/** + * @param {HTMLElement} elt + */ +function chatMessageMenu(elt) { + if(!(serverConnection && serverConnection.permissions && + serverConnection.permissions.indexOf('op') >= 0)) + return; + + let peerId = elt.dataset.peerId; + if(!peerId) + return; + let username = elt.dataset.username; + let u = username ? ' ' + username : ''; + + let items = []; + items.push({label: 'Identify user' + u, onClick: () => { + serverConnection.userAction('identify', peerId); + }}); + items.push({label: 'Kick out user' + u, onClick: () => { + serverConnection.userAction('kick', peerId); + }}); + + /** @ts-ignore */ + new Contextual({ + items: items, + }); +} + /** * @param {string|HTMLElement} message */