From b35ecbf79cf5ae7fecaa38cdc4e254de0e6757e9 Mon Sep 17 00:00:00 2001 From: cutls Date: Sun, 24 Nov 2019 23:07:21 +0900 Subject: [PATCH] hashtag --- app/js/tl/card.js | 56 ++++----------------------------------- app/js/tl/misskeyparse.js | 2 +- app/js/tl/parse.js | 4 +-- app/js/tl/tag.js | 7 ++--- app/js/ui/tips.js | 2 +- 5 files changed, 13 insertions(+), 58 deletions(-) diff --git a/app/js/tl/card.js b/app/js/tl/card.js index 1f6e99c2..ce6b06d8 100644 --- a/app/js/tl/card.js +++ b/app/js/tl/card.js @@ -9,24 +9,21 @@ function additional(acct_id, tlid) { $('#timeline-container .hashtag, #timeline-container [rel=tag]').each(function(i, elem) { var tags = $(this) .attr('href') - .match(/https?:\/\/([-a-zA-Z0-9@.]+)\/tags\/([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/) + .match(/https?:\/\/([-a-zA-Z0-9@.]+)\/tags?\/([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/) if (tags) { var tagThis = tags[2] } else { - var tagThis = $(this).attr('data-tag') + var tagThis = $(this).attr('data-regTag') } if (tagThis) { - $(this).attr('onclick', "tagShow('" + tagThis + "')") - $(this).attr('href', '#') + $(this).attr('href', "javascript:tagShow('" + tagThis + "')") + } }) //トゥートサムネ $('#timeline_' + tlid + ' .toot a:not(.parsed)').each(function(i, elem) { - var domain = localStorage.getItem('domain_' + acct_id) - var at = localStorage.getItem('acct_' + acct_id + '_at') - var card = localStorage.getItem('card_' + tlid) var text = $(this).attr('href') if (text) { if (text.indexOf('twimg.com') === -1) { @@ -48,48 +45,6 @@ function additional(acct_id, tlid) { } if (urls) { $(this).remove() - } else if (!card) { - var id = $(this) - .parents('.cvo') - .attr('toot-id') - if (localStorage.getItem('mode_' + domain) == 'misskey') { - var start = 'https://' + domain + '/url?url=' + text - fetch(start, { - method: 'GET', - headers: { - 'content-type': 'application/json' - } - //body: JSON.stringify({}) - }) - .then(function(response) { - if (!response.ok) { - response.text().then(function(text) { - setLog(response.url, response.status, text) - }) - } - return response.json() - }) - .catch(function(error) { - todo(error) - setLog(start, 'JSON', error) - console.error(error) - }) - .then(function(json) { - if (json.title) { - $('[toot-id=' + id + '] .additional').html( - 'URL' + - lang.lang_cards_check + - ':
Title:' + - escapeHTML(json.title) + - '
' + - escapeHTML(json.description) + - '
' - ) - $('[toot-id=' + id + '] a:not(.parsed)').addClass('parsed') - $('[toot-id=' + id + ']').addClass('parsed') - } - }) - } } else { $(this).attr('title', text) } @@ -139,8 +94,7 @@ function additional(acct_id, tlid) { var id = $(this) .parents('.cvo') .attr('toot-id') - $(this).attr('href', '#') - $(this).attr('onclick', "imgv('" + id + "','" + i + "')") + $(this).attr('href', `javascript:imgv('${id}','${i}')`) $(this).attr('data-type', 'image') $(this).attr('id', id + '-image-' + i) $(this).attr('data-url', ilink) diff --git a/app/js/tl/misskeyparse.js b/app/js/tl/misskeyparse.js index 34f3d1b4..5d49ecd7 100644 --- a/app/js/tl/misskeyparse.js +++ b/app/js/tl/misskeyparse.js @@ -520,7 +520,7 @@ function misskeyParse(obj, mix, acct_id, tlid, popup, mutefilter) { if (tagck) { Object.keys(toot.tags).forEach(function (key4) { var tag = toot.tags[key4]; - var tags = '#' + tag + '#' + tag + ':#' + tag + '#' + tag + ':TL Toot ' + 'Pin '; content = content.replace("#" + tag, tags); diff --git a/app/js/tl/parse.js b/app/js/tl/parse.js index 310a044f..765a278e 100644 --- a/app/js/tl/parse.js +++ b/app/js/tl/parse.js @@ -689,7 +689,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) { var featured = ` Feature ` tags = tags + - `#${tag.name}: + `#${tag.name}: Pin ` + ">Pin${featured} ` }) tags = '
' + tags + '
' } diff --git a/app/js/tl/tag.js b/app/js/tl/tag.js index 74500403..57aa8a02 100644 --- a/app/js/tl/tag.js +++ b/app/js/tl/tag.js @@ -10,7 +10,8 @@ if (location.search) { } //よく使うタグ function tagShow(tag) { - $('[data-tag=' + decodeURI(tag).toLowerCase() + ']').toggleClass('hide') + console.log('[data-regTag=' + decodeURI(tag).toLowerCase() + ']') + $('[data-regTag=' + decodeURI(tag).toLowerCase() + ']').toggleClass('hide') } //タグ追加 function tagPin(tag) { @@ -69,7 +70,7 @@ function favTag() { tags = tags + `#${tag} - ${nowon}  + ${nowon}  TL   @@ -124,7 +125,7 @@ function trendTag() { tags = tags + `#${tag} -   +   TL  Toot diff --git a/app/js/ui/tips.js b/app/js/ui/tips.js index ff2b6763..a2d97955 100644 --- a/app/js/ui/tips.js +++ b/app/js/ui/tips.js @@ -111,7 +111,7 @@ function trendTagonTip() { ` #${escapeHTML(tag)} -   +   TL  Toot
`