From 21cb78e192601e115a9cf906b799d6696074a32f Mon Sep 17 00:00:00 2001 From: cel Date: Mon, 26 Nov 2018 22:48:24 -1000 Subject: chess: preserve "full" toggle state in navigation --- lib/render-msg.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib/render-msg.js') diff --git a/lib/render-msg.js b/lib/render-msg.js index 7d50ef8..474d3e9 100644 --- a/lib/render-msg.js +++ b/lib/render-msg.js @@ -15,6 +15,9 @@ function RenderMsg(render, app, msg, opts) { var content = this.value.content this.c = content || {} this.isMissing = !content + this.hasFullLink = + this.c.type === 'chess_move' || + this.c.type === 'ssb_chess_move' if (typeof opts === 'boolean') opts = {raw: opts} this.opts = opts || {} @@ -120,8 +123,10 @@ RenderMsg.prototype.wrap = function (content, cb) { title: date.toLocaleString(), href: this.msg.key ? this.toUrl(this.msg.key) : undefined }, htime(date)), ' ', - h('code', h('a.ssb-id', - {href: this.toUrl(this.msg.key)}, this.msg.key)), + h('code', h('a.ssb-id', { + href: this.toUrl(this.msg.key) + + (this.hasFullLink && this.opts.full ? '?full' : '') + }, this.msg.key)), channel ? [' ', h('a', {href: this.toUrl(channel)}, channel)] : '')), h('td.msg-right', this.actions()) ), h('tr', @@ -173,7 +178,7 @@ RenderMsg.prototype.actions = function (mini) { h('a', {href: this.render.toUrl('/about/' + encodeURIComponent(this.msg.key))}, 'about'), ' '] : '', this.c.type === 'ssb-igo' && (lastMove = this.c.values[0] && this.c.values[0].lastMove) ? [ h('a', {href: this.render.toUrl(lastMove)}, 'previous'), ' '] : '', - /^(ssb_)?chess_/.test(this.c.type) ? [ + this.hasFullLink ? [ h('a', {href: this.toUrl(this.msg.key) + '?full', title: 'view full game board'}, 'full'), ' '] : '', typeof this.c.text === 'string' ? [ -- cgit v1.2.3