"use strict"; Vue.component('tf-message', { props: ['message', 'messages', 'votes'], data: function() { return { showRaw: false } }, computed: { content_json: function() { try { return JSON.parse(this.message.content); } catch { return undefined; } }, content_raw: function() { try { return JSON.stringify(JSON.parse(this.message.content), null, 2); } catch { return this.message.content; } } }, methods: { markdown: function(md) { var reader = new commonmark.Parser({safe: true}); var writer = new commonmark.HtmlRenderer(); return writer.render(reader.parse(md)); }, set_reply: function() { g_data.reply_root = this.content_json.root || this.message.id; g_data.reply_branch = this.message.id; }, vote: function(event) { var reaction = event.srcElement.innerText; var message = this.message.id; if (confirm('Are you sure you want to react with ' + reaction + ' to ' + message + '?')) { window.parent.postMessage( { appendMessage: { type: 'vote', vote: { link: message, value: 1, expression: reaction, }, }, }, '*'); } }, show_message: function() { window.parent.postMessage({action: 'setHash', hash: this.message.id}, '*'); }, }, template: `

percent

{{new Date(message.timestamp)}} {{message.id}}
Show Raw Message

{{message.id}}

{{content_raw}}
{{mention.name}}
{{content_json.name || 'tildefriends-app'}}
{{content_json.following ? '==>' : '=/=>'}}
{{message.content}}
{{vote + (votes[message.id][vote].length > 1 ? ' (' + votes[message.id][vote].length + ')' : '')}} reply Like thumb_up
`, });