2020-07-10 23:33:12 +10:00
|
|
|
const defaultemojiList = ['activity', 'flag', 'food', 'nature', 'object', 'people', 'place', 'symbol']
|
|
|
|
const defaultemoji = {
|
2020-01-28 04:07:36 +11:00
|
|
|
activity: activity,
|
|
|
|
flag: flag,
|
|
|
|
food: food,
|
|
|
|
nature: nature,
|
|
|
|
object: object,
|
|
|
|
people: people,
|
|
|
|
place: place,
|
|
|
|
symbol: symbol
|
|
|
|
}
|
2020-07-10 23:33:12 +10:00
|
|
|
let defaultemojiname = {
|
|
|
|
activity: 'Activities',
|
|
|
|
flag: 'Flags',
|
|
|
|
food: 'Foods',
|
|
|
|
nature: 'Nature',
|
|
|
|
object: 'Tools',
|
|
|
|
people: 'People',
|
|
|
|
place: 'Places',
|
|
|
|
symbol: 'Symbols'
|
|
|
|
}
|
2020-01-28 04:07:36 +11:00
|
|
|
if (lang == 'ja') {
|
2020-07-10 23:33:12 +10:00
|
|
|
defaultemojiname = {
|
2020-01-28 04:07:36 +11:00
|
|
|
activity: '活動',
|
|
|
|
flag: '国旗',
|
|
|
|
food: '食べ物',
|
|
|
|
nature: '自然',
|
|
|
|
object: 'もの',
|
|
|
|
people: 'ひと',
|
|
|
|
place: '場所',
|
|
|
|
symbol: '記号'
|
|
|
|
}
|
2018-07-29 17:37:54 +10:00
|
|
|
}
|
|
|
|
|
2019-05-19 17:39:30 +10:00
|
|
|
function defaultEmoji(target) {
|
2020-07-10 23:33:12 +10:00
|
|
|
let announcement = false
|
|
|
|
if (document.querySelector('#media').value == 'announcement') {
|
|
|
|
announcement = true
|
|
|
|
}
|
|
|
|
const json = defaultemoji[target]
|
|
|
|
const keymap = Object.keys(json)
|
|
|
|
let emojis = ''
|
|
|
|
for (let i = 0; i < json.length; i++) {
|
|
|
|
const key = keymap[i]
|
|
|
|
const emoji = json[key]
|
|
|
|
let def = `<a data-shortcode="${emoji['shortcode']}" class="pointer defEmoji">`
|
|
|
|
if (announcement) {
|
|
|
|
def = `<a data-shortcode="${emoji['shortcode']}" class="pointer defEmoji">`
|
|
|
|
}
|
2020-01-28 04:07:36 +11:00
|
|
|
emojis =
|
|
|
|
emojis +
|
|
|
|
`${def}
|
|
|
|
<span style="
|
2020-05-23 14:54:51 +10:00
|
|
|
width: 20px; height: 20px; display: inline-block; background-image: url('../../img/sheet.png'); background-size: 4900%;
|
2020-01-28 04:07:36 +11:00
|
|
|
background-position:${emoji['css']};"></span>
|
|
|
|
</a>`
|
2020-07-10 23:33:12 +10:00
|
|
|
}
|
|
|
|
document.querySelector('#emoji-list').innerHTML = emojis
|
|
|
|
document.querySelector('#now-emoji').innerText = lang.lang_defaultemojis_text.replace('{{cat}}', defaultemojiname[target])
|
|
|
|
document.querySelector('.emoji-control').classList.add('hide')
|
|
|
|
const targets = document.querySelectorAll('.defEmoji')
|
|
|
|
for (let j = 0; j < targets.length; j++) {
|
|
|
|
const target = targets[j]
|
|
|
|
const sc = target.getAttribute('data-shortcode')
|
|
|
|
target.addEventListener('click', () => defEmoji(sc))
|
|
|
|
}
|
2018-03-13 04:41:38 +11:00
|
|
|
}
|
2020-07-10 23:33:12 +10:00
|
|
|
|
2019-05-19 17:39:30 +10:00
|
|
|
function customEmoji() {
|
2020-07-10 23:33:12 +10:00
|
|
|
document.querySelector('#emoji-suggest').value = ''
|
|
|
|
document.querySelector('.emoji-control').classList.remove('hide')
|
2020-01-28 04:07:36 +11:00
|
|
|
emojiList('home')
|
2018-03-14 05:31:31 +11:00
|
|
|
}
|
2020-07-10 23:33:12 +10:00
|
|
|
|
2019-05-19 17:39:30 +10:00
|
|
|
function defEmoji(target) {
|
2020-07-10 23:33:12 +10:00
|
|
|
const textarea = document.querySelector('#textarea')
|
|
|
|
let selin = textarea.selectionStart
|
2020-01-28 04:07:36 +11:00
|
|
|
if (!selin) {
|
|
|
|
selin = 0
|
|
|
|
}
|
2020-07-10 23:33:12 +10:00
|
|
|
const hex = emojipack[target].unified.split('-')
|
|
|
|
let emoji = twemoji.convert.fromCodePoint(hex[0])
|
2020-01-28 04:07:36 +11:00
|
|
|
if (hex.length === 2) {
|
|
|
|
emoji = twemoji.convert.fromCodePoint(hex[0]) + twemoji.convert.fromCodePoint(hex[1])
|
|
|
|
}
|
2020-07-10 23:33:12 +10:00
|
|
|
const now = textarea.value
|
|
|
|
const before = now.substr(0, selin)
|
|
|
|
const after = now.substr(selin, now.length)
|
|
|
|
const newt = before + emoji + after
|
|
|
|
textarea.value = newt
|
|
|
|
textarea.focus()
|
2020-01-28 04:07:36 +11:00
|
|
|
}
|