bug of emoji

This commit is contained in:
cutls 2020-05-15 11:15:01 +09:00
parent bc616ba118
commit 917cd322fc

View File

@ -56,8 +56,8 @@ function emojiGet(parse, started) {
fetch(start, { fetch(start, {
method: 'GET', method: 'GET',
headers: { headers: {
'content-type': 'application/json' 'content-type': 'application/json',
} },
}) })
.then(function (response) { .then(function (response) {
if (!response.ok) { if (!response.ok) {
@ -77,7 +77,7 @@ function emojiGet(parse, started) {
$('#emoji-list').text('Parsing...') $('#emoji-list').text('Parsing...')
var md = { var md = {
categorized: {}, categorized: {},
uncategorized: [] uncategorized: [],
} }
var if_categorized = false var if_categorized = false
Object.keys(json).forEach(function (key) { Object.keys(json).forEach(function (key) {
@ -95,14 +95,14 @@ function emojiGet(parse, started) {
md['categorized'][cat].push({ md['categorized'][cat].push({
shortcode: emoji.shortcode, shortcode: emoji.shortcode,
url: emoji.url, url: emoji.url,
listed: listed listed: listed,
}) })
if_categorized = true if_categorized = true
} else { } else {
md['uncategorized'].push({ md['uncategorized'].push({
shortcode: emoji.shortcode, shortcode: emoji.shortcode,
url: emoji.url, url: emoji.url,
listed: listed listed: listed,
}) })
} }
}) })
@ -136,8 +136,8 @@ function emojiGet(parse, started) {
fetch(start, { fetch(start, {
method: 'POST', method: 'POST',
headers: { headers: {
'content-type': 'application/json' 'content-type': 'application/json',
} },
}) })
.then(function (response) { .then(function (response) {
if (!response.ok) { if (!response.ok) {
@ -165,7 +165,7 @@ function emojiGet(parse, started) {
md['uncategorized'].push({ md['uncategorized'].push({
shortcode: emoji.name, shortcode: emoji.name,
url: emoji.url, url: emoji.url,
listed: true listed: true,
}) })
}) })
md['if_categorized'] = false md['if_categorized'] = false
@ -198,10 +198,7 @@ function emojiList(target, reaction) {
} else { } else {
var misskeyReact = false var misskeyReact = false
} }
if ( if (misskeyReact && localStorage.getItem('emojiReaction_' + acct_id) != 'true') {
misskeyReact &&
localStorage.getItem('emojiReaction_' + acct_id) != 'true'
) {
console.error('Disabled') console.error('Disabled')
clear() clear()
hide() hide()
@ -225,8 +222,8 @@ function emojiList(target, reaction) {
var obj = [ var obj = [
{ {
divider: true, divider: true,
cat: lang.lang_emoji_uncat cat: lang.lang_emoji_uncat,
} },
] ]
var cats = raw['uncategorized'] var cats = raw['uncategorized']
obj = obj.concat(cats) obj = obj.concat(cats)
@ -235,8 +232,8 @@ function emojiList(target, reaction) {
obj = obj.concat([ obj = obj.concat([
{ {
divider: true, divider: true,
cat: key cat: key,
} },
]) ])
obj = obj.concat(cats) obj = obj.concat(cats)
}) })
@ -280,9 +277,7 @@ function emojiList(target, reaction) {
} else { } else {
var shortcode = emoji.shortcode var shortcode = emoji.shortcode
} }
html = html = html + `<a onclick="emojiReaction('${shortcode}')" class="pointer"><img src="${emoji.url}" width="20" title="${emoji.shortcode}"></a>`
html +
`<a onclick="emojiReaction('${shortcode}')" class="pointer"><img src="${emoji.url}" width="20" title="${emoji.shortcode}"></a>`
} }
} }
} else { } else {
@ -290,9 +285,7 @@ function emojiList(target, reaction) {
html = html + '<p style="margin-bottom:0">' + emoji.cat + '</p>' html = html + '<p style="margin-bottom:0">' + emoji.cat + '</p>'
} else { } else {
if (emoji.listed) { if (emoji.listed) {
html = html = html + `<a onclick="emojiInsert(':${emoji.shortcode}:')" class="pointer"><img src="${emoji.url}" width="20" title="${emoji.shortcode}"></a>`
html +
`<a onclick="emojiInsert(':${emoji.shortcode}:')" class="pointer"><img src="${emoji.url}" width="20" title="${emoji.shortcode}"></a>`
} }
} }
} }
@ -310,7 +303,7 @@ function emojiInsert(code, del) {
var blankBefore = ' ' var blankBefore = ' '
var blankAfter = ' ' var blankAfter = ' '
} }
var textarea = document.querySelector('#textarea') var textarea = document.getElementById('textarea')
var sentence = textarea.value var sentence = textarea.value
var len = sentence.length var len = sentence.length
var pos = textarea.selectionStart var pos = textarea.selectionStart
@ -334,8 +327,11 @@ function emojiInsert(code, del) {
} else { } else {
var word = blankBefore + code + blankAfter var word = blankBefore + code + blankAfter
} }
var go = pos - delLen + word.length
sentence = before + word + after sentence = before + word + after
textarea.value = sentence textarea.value = sentence
textarea.focus()
textarea.setSelectionRange(go, go)
} }
//改行挿入 //改行挿入
function brInsert(code) { function brInsert(code) {