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