This commit is contained in:
Aevann1 2022-01-24 03:08:40 +02:00
parent 953a1fdc86
commit 39b6e6b67e
2 changed files with 76 additions and 66 deletions

View file

@ -1,14 +1,18 @@
let loaded = false;
const fav = document.getElementById('EMOJIS_favorite')
const search_bar = document.getElementById('emoji_search')
const search_container = document.getElementById('emoji-tab-search')
let emojis = 1
function loadEmojis(form) {
if (loaded == false)
if (emojis == 1)
{
const xhr = new XMLHttpRequest();
xhr.open("GET", '/marsey_list', true);
xhr.setRequestHeader('xhr', 'xhr');
var f = new FormData();
xhr.onload = function() {
const emojis = {
emojis = {
'marsey': JSON.parse(xhr.response),
'platy': ['plarsy','platyabused','platyblizzard','platyboxer','platydevil','platyfear','platygirlmagic','platygolong','platyhaes','platyking','platylove','platyneet','platyold','platypatience','platypopcorn','platyrich','platysarcasm','platysilly','platysleeping','platythink','platytired','platytuxedomask','platyblush','platybruh','platycaveman','platycheer','platydown','platyeyes','platyheart','platylol','platymicdrop','platynooo','platysalute','platyseethe','platythumbsup','platywave'],
@ -25,14 +29,19 @@ function loadEmojis(form) {
'wolf': ['wolfangry','wolfbrains','wolfcry','wolfdead','wolfdevilish','wolffacepalm','wolfhappy','wolfidea','wolfkoala','wolflaugh','wolflove','wolfmeditate','wolfphone','wolfrainbow','wolfroses','wolfsad','wolfsfear','wolfsleep','wolftear','wolfthink','wolfthumbsup','wolfupsidedown','wolfvictory','wolfwave','wolfwink'],
'misc': ['etika','sneed','retardedchildren','bruh','autism','doot','kylieface','queenyes','wholesomeseal','chadyescapy','gigachadglow','gigachadorthodox','gigachad','gigachad2','gigachad3']}
'misc': ['etika','sneed','retardedchildren','bruh','autism','doot','kylieface','queenyes','wholesomeseal','chadyescapy','gigachadglow','gigachadorthodox','gigachad','gigachad2','gigachad3']
}
loadEmojis(form);
}
xhr.send(f);
}
else {
fav.setAttribute('data-form-destination', form)
document.getElementById('EMOJIS_favorite').setAttribute('data-form-destination', form)
const commentBox = document.getElementById(form);
const commentBox = document.getElementById(form)
commentBox.setAttribute('data-curr-pos', commentBox.selectionStart);
if (document.getElementById('EMOJIS_favorite').innerHTML == "")
if (fav.innerHTML == "")
{
let str = ""
const favorite_emojis = JSON.parse(localStorage.getItem("favorite_emojis"))
@ -45,10 +54,12 @@ function loadEmojis(form) {
for (const emoji of Object.keys(sortable).slice(0, 25))
str += `<button class="btn m-1 px-0 emoji2" onclick="getEmoji('${emoji}')" data-bs-toggle="tooltip" title=":${emoji}:" delay:="0"><img loading="lazy" width=50 src="/static/assets/images/emojis/${emoji}.webp" alt="${emoji}-emoji"></button>`
document.getElementById('EMOJIS_favorite').innerHTML = str
fav.innerHTML = str
}
}
if (search_bar.value == "") {
search_container.innerHTML = ""
document.getElementById("tab-content").classList.remove("d-none");
if (document.getElementById("EMOJIS_marsey").innerHTML == "")
{
for (const [k, v] of Object.entries(emojis)) {
@ -67,46 +78,45 @@ function loadEmojis(form) {
}
container.innerHTML = str
document.getElementById('emoji-tab-search').innerHTML = ""
}
}
loaded == true;
}
xhr.send(f);
}
}
document.getElementById("emoji_search").oninput = function () {
else {
let str = ''
for (let i = 0; i < emojis.length; i++) {
let arr = emojis[i].emojis
let container = document.getElementById(`EMOJIS_${emojis[i].type}`)
for (let j = 0; j < arr.length; j++) {
if (arr[j].match(search_bar.value.toLowerCase()) || search_bar.value.toLowerCase().match(arr[j])) {
str += `<button class="btn m-1 px-0 emoji2" onclick="getEmoji('${arr[j]}')" style="background: None!important; width:60px; overflow: hidden; border: none;" data-bs-toggle="tooltip" title=":${arr[j]}:" delay:="0"><img loading="lazy" width=50 src="/static/assets/images/emojis/${arr[j]}.webp" alt="${arr[j]}-emoji"></button>`;
}
}
if (i == 0)
for (const [key, value] of Object.entries(emojis)) {
if (key == "marsey")
{
let arr2 = emojis[i].emojis;
for (const [key, value] of Object.entries(arr2)) {
for (const [key, v] of Object.entries(value)) {
if (str.includes(`'${key}'`)) continue;
if (key.match(search_bar.value.toLowerCase()) || search_bar.value.toLowerCase().match(key) || value.match(search_bar.value.toLowerCase())) {
if (key.match(search_bar.value.toLowerCase()) || search_bar.value.toLowerCase().match(key) || v.match(search_bar.value.toLowerCase())) {
str += `<button class="btn m-1 px-0 emoji2" onclick="getEmoji('${key}')" data-bs-toggle="tooltip" title=":${key}:" delay:="0"><img loading="lazy" width=50 src="/static/assets/images/emojis/${key}.webp" alt="${key}-emoji"></button>`;
}
}
container.innerHTML = ""
}
else
{
for (let i = 0; i < value.length; i++) {
if (value[i].match(search_bar.value.toLowerCase()) || search_bar.value.toLowerCase().match(value[i])) {
str += `<button class="btn m-1 px-0 emoji2" onclick="getEmoji('${value[i]}')" style="background: None!important; width:60px; overflow: hidden; border: none;" data-bs-toggle="tooltip" title=":${value[i]}:" delay:="0"><img loading="lazy" width=50 src="/static/assets/images/emojis/${value[i]}.webp" alt="${value[i]}-emoji"></button>`;
}
}
document.getElementById('emoji-tab-search').innerHTML = str
}
}
document.getElementById("tab-content").classList.add("d-none");
search_container.innerHTML = str
}
search_bar.oninput = function () {
loadEmojis(form);
};
}
}
function getEmoji(searchTerm) {
const form = document.getElementById('EMOJIS_favorite').getAttribute('data-form-destination')
const commentBox = document.getElementById(form);
const form = fav.getAttribute('data-form-destination')
const commentBox = document.getElementById(form)
const old = commentBox.value;
const curPos = parseInt(commentBox.getAttribute('data-curr-pos'));

View file

@ -48,7 +48,7 @@
<div class="modal-body p-0" id="emoji-modal-body">
<div id="emoji-tab-search"></div>
<div id="no-emojis-found"></div>
<div class="tab-content">
<div id="tab-content" class="tab-content">
<div class="tab-pane fade show active" id="emoji-tab-favorite">
<div class="d-flex flex-wrap py-3 pl-2" id="EMOJIS_favorite"></div>
</div>