| const S = `0${dt.getSeconds()}`.slice(-2) | const S = `0${dt.getSeconds()}`.slice(-2) | ||||
| return `${H}:${M}:${S}` | return `${H}:${M}:${S}` | ||||
| }, | }, | ||||
| outboundLinks: (vnode) => { | |||||
| vnode.dom.querySelectorAll('a').forEach(anchor => { | |||||
| anchor.target = '_blank' | |||||
| anchor.rel = 'noopener' | |||||
| }) | |||||
| }, | |||||
| view() { | view() { | ||||
| return m('.chat', | return m('.chat', | ||||
| m('.posts', | m('.posts', | ||||
| State.posts.map(post => m('.post', {oncreate: scrollIntoView}, | State.posts.map(post => m('.post', {oncreate: scrollIntoView}, | ||||
| m('.ts', Chat.prettifyTime(post.ts)), | m('.ts', Chat.prettifyTime(post.ts)), | ||||
| m('.source', post.source || '~'), | m('.source', post.source || '~'), | ||||
| m('.text', m.trust(DOMPurify.sanitize(marked(post.value)))), | |||||
| m('.text', {oncreate: Chat.outboundLinks}, | |||||
| m.trust(DOMPurify.sanitize(marked(post.value))) | |||||
| ), | |||||
| )), | )), | ||||
| ), | ), | ||||
| m(TextBox), | m(TextBox), |