bug of emoji
This commit is contained in:
parent
bc616ba118
commit
917cd322fc
|
@ -56,31 +56,31 @@ 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) {
|
||||||
response.text().then(function(text) {
|
response.text().then(function (text) {
|
||||||
setLog(response.url, response.status, text)
|
setLog(response.url, response.status, text)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return response.json()
|
return response.json()
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function (error) {
|
||||||
todo(error)
|
todo(error)
|
||||||
setLog(start, 'JSON', error)
|
setLog(start, 'JSON', error)
|
||||||
console.error(error)
|
console.error(error)
|
||||||
})
|
})
|
||||||
.then(function(json) {
|
.then(function (json) {
|
||||||
if (parse == 'true') {
|
if (parse == 'true') {
|
||||||
$('#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) {
|
||||||
var emoji = json[key]
|
var emoji = json[key]
|
||||||
if (emoji.visible_in_picker) {
|
if (emoji.visible_in_picker) {
|
||||||
var listed = true
|
var listed = true
|
||||||
|
@ -95,26 +95,26 @@ 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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
console.log(md)
|
console.log(md)
|
||||||
//絵文字をマストドン公式と同順にソート
|
//絵文字をマストドン公式と同順にソート
|
||||||
md['uncategorized'].sort(function(a, b) {
|
md['uncategorized'].sort(function (a, b) {
|
||||||
if (a.shortcode < b.shortcode) return -1
|
if (a.shortcode < b.shortcode) return -1
|
||||||
if (a.shortcode > b.shortcode) return 1
|
if (a.shortcode > b.shortcode) return 1
|
||||||
return 0
|
return 0
|
||||||
})
|
})
|
||||||
Object.keys(md['categorized']).forEach(function(key) {
|
Object.keys(md['categorized']).forEach(function (key) {
|
||||||
md['categorized'][key].sort(function(a, b) {
|
md['categorized'][key].sort(function (a, b) {
|
||||||
if (a.shortcode < b.shortcode) return -1
|
if (a.shortcode < b.shortcode) return -1
|
||||||
if (a.shortcode > b.shortcode) return 1
|
if (a.shortcode > b.shortcode) return 1
|
||||||
return 0
|
return 0
|
||||||
|
@ -136,23 +136,23 @@ 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) {
|
||||||
response.text().then(function(text) {
|
response.text().then(function (text) {
|
||||||
setLog(response.url, response.status, text)
|
setLog(response.url, response.status, text)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return response.json()
|
return response.json()
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function (error) {
|
||||||
todo(error)
|
todo(error)
|
||||||
setLog(start, 'JSON', error)
|
setLog(start, 'JSON', error)
|
||||||
console.error(error)
|
console.error(error)
|
||||||
})
|
})
|
||||||
.then(function(json) {
|
.then(function (json) {
|
||||||
if (json.enableEmojiReaction) {
|
if (json.enableEmojiReaction) {
|
||||||
localStorage.setItem('emojiReaction_' + acct_id, 'true')
|
localStorage.setItem('emojiReaction_' + acct_id, 'true')
|
||||||
} else {
|
} else {
|
||||||
|
@ -160,19 +160,19 @@ function emojiGet(parse, started) {
|
||||||
}
|
}
|
||||||
var emojis = json.emojis
|
var emojis = json.emojis
|
||||||
var md = { uncategorized: [] }
|
var md = { uncategorized: [] }
|
||||||
Object.keys(emojis).forEach(function(key) {
|
Object.keys(emojis).forEach(function (key) {
|
||||||
var emoji = emojis[key]
|
var emoji = emojis[key]
|
||||||
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
|
||||||
if (parse == 'true') {
|
if (parse == 'true') {
|
||||||
$('#emoji-list').text('Parsing...')
|
$('#emoji-list').text('Parsing...')
|
||||||
//絵文字をマストドン公式と同順にソート
|
//絵文字をマストドン公式と同順にソート
|
||||||
md['uncategorized'].sort(function(a, b) {
|
md['uncategorized'].sort(function (a, b) {
|
||||||
if (a.shortcode < b.shortcode) return -1
|
if (a.shortcode < b.shortcode) return -1
|
||||||
if (a.shortcode > b.shortcode) return 1
|
if (a.shortcode > b.shortcode) return 1
|
||||||
return 0
|
return 0
|
||||||
|
@ -193,15 +193,12 @@ function emojiGet(parse, started) {
|
||||||
function emojiList(target, reaction) {
|
function emojiList(target, reaction) {
|
||||||
$('#now-emoji').text(lang.lang_emoji_custom)
|
$('#now-emoji').text(lang.lang_emoji_custom)
|
||||||
var acct_id = $('#post-acct-sel').val()
|
var acct_id = $('#post-acct-sel').val()
|
||||||
if(reaction && $('#media').val() == 'misskey') {
|
if (reaction && $('#media').val() == 'misskey') {
|
||||||
var misskeyReact = true
|
var misskeyReact = true
|
||||||
} 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,18 +222,18 @@ 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)
|
||||||
Object.keys(raw['categorized']).forEach(function(key) {
|
Object.keys(raw['categorized']).forEach(function (key) {
|
||||||
var cats = raw['categorized'][key]
|
var cats = raw['categorized'][key]
|
||||||
obj = obj.concat([
|
obj = obj.concat([
|
||||||
{
|
{
|
||||||
divider: true,
|
divider: true,
|
||||||
cat: key
|
cat: key,
|
||||||
}
|
},
|
||||||
])
|
])
|
||||||
obj = obj.concat(cats)
|
obj = obj.concat(cats)
|
||||||
})
|
})
|
||||||
|
@ -275,14 +272,12 @@ 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) {
|
||||||
if(misskeyReact) {
|
if (misskeyReact) {
|
||||||
var shortcode = `:${emoji.shortcode}:`
|
var shortcode = `:${emoji.shortcode}:`
|
||||||
} 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) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user