From 7822b2c7400a714f46d5cd351f9da64cd17b3281 Mon Sep 17 00:00:00 2001 From: cutls Date: Tue, 7 Apr 2020 13:02:20 +0900 Subject: [PATCH] Fix: CW toggle --- app/js/post/secure.js | 6 +++--- app/js/tl/misskeyparse.js | 12 +++++------- app/js/tl/parse.js | 10 +++++----- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/app/js/post/secure.js b/app/js/post/secure.js index ce66d7f6..9440344b 100644 --- a/app/js/post/secure.js +++ b/app/js/post/secure.js @@ -96,9 +96,9 @@ function cw() { } } //TLでコンテントワーニングを表示トグル -function cw_show(id) { - $('.cw_hide_' + id).toggleClass('cw') - $('.cw-long-' + id).toggleClass('hide') +function cw_show(e) { + $(e).parent().parent().find('.cw_hide').toggleClass('cw') + $(e).parent().find('.cw_long').toggleClass('hide') } $(function() { $('#cw-text').on('change', function(event) { diff --git a/app/js/tl/misskeyparse.js b/app/js/tl/misskeyparse.js index 3e1731e5..32e95077 100644 --- a/app/js/tl/misskeyparse.js +++ b/app/js/tl/misskeyparse.js @@ -360,22 +360,20 @@ function misskeyParse(obj, mix, acct_id, tlid, popup, mutefilter) { if ((toot.cw || toot.cw == "") && cw) { var content = escapeHTML(toot.text); var spoil = escapeHTMLtemp(toot.cw); - var spoiler = "cw cw_hide_" + toot.id; + var spoiler = "cw cw_hide"; var api_spoil = "gray"; - var spoiler_show = '' + lang.lang_parse_cwshow + '
'; + var spoiler_show = '' + lang.lang_parse_cwshow + '
'; } else { var ct1 = nl2br(toot.text).split('
').length - 2; var ct2 = nl2br(toot.text).split('
').length - 2; if (ct1 > ct2) { var ct = ct1; } else { var ct = ct2; } if ((sent < ct && $.mb_strlen($.strip_tagstemp(toot.text)) > 5) || ($.strip_tagstemp(toot.text).length > ltr && $.mb_strlen($.strip_tagstemp(toot.text)) > 5)) { var content = '' + lang.lang_parse_fulltext + '
' + escapeHTMLtemp(toot.text) - var spoil = '' + $.mb_substr($.strip_tagstemp( + var spoil = '' + $.mb_substr($.strip_tagstemp( toot.text), 0, 100) + '' + lang.lang_parse_autofold + ''; - var spoiler = "cw cw_hide_" + toot.id; - var spoiler_show = '' + lang.lang_parse_more + '
'; + var spoiler = "cw cw_hide"; + var spoiler_show = '' + lang.lang_parse_more + '
'; } else { var content = escapeHTMLtemp(toot.text); if (toot.cw) { diff --git a/app/js/tl/parse.js b/app/js/tl/parse.js index f065e7ed..607b1212 100644 --- a/app/js/tl/parse.js +++ b/app/js/tl/parse.js @@ -516,9 +516,9 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) { } if (toot.spoiler_text && cw) { var spoil = escapeHTML(toot.spoiler_text) - var spoiler = 'cw cw_hide_' + toot.id + var spoiler = 'cw cw_hide' var api_spoil = 'gray' - var spoiler_show = `${lang.lang_parse_cwshow}
` + var spoiler_show = `${lang.lang_parse_cwshow}
` } else { if (content) { var ct1 = content.split('

').length + content.split('
').length - 2 @@ -538,14 +538,14 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) { ($.mb_strlen($.strip_tags(content)) > ltr && $.mb_strlen($.strip_tags(content)) > 5) ) { var content = `${lang.lang_parse_fulltext}
` + content - var spoil = `${$.mb_substr( + var spoil = `${$.mb_substr( $.strip_tags(content), 0, 100 )} ${lang.lang_parse_autofold}` - var spoiler = 'cw cw_hide_' + toot.id - var spoiler_show = ` + var spoiler = 'cw cw_hide' + var spoiler_show = ` ${lang.lang_parse_more}
` } else {