vcxvcxx
This commit is contained in:
parent
fd5aeb3df3
commit
722201623a
2 changed files with 136 additions and 137 deletions
|
@ -1,9 +1,15 @@
|
|||
let marseys, EMOJIS_STRINGS;
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", '/marsey_list', true);
|
||||
xhr.setRequestHeader('xhr', 'xhr');
|
||||
var form = new FormData()
|
||||
xhr.onload = function() {
|
||||
let marseys, EMOJIS_STRINGS, commentFormID;
|
||||
|
||||
function commentForm(form) {
|
||||
commentFormID = form;
|
||||
};
|
||||
|
||||
function loadEmojis(form) {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", '/marsey_list', true);
|
||||
xhr.setRequestHeader('xhr', 'xhr');
|
||||
var f = new FormData()
|
||||
xhr.onload = function() {
|
||||
marseys = JSON.parse(xhr.response)
|
||||
EMOJIS_STRINGS = [
|
||||
{
|
||||
|
@ -43,48 +49,6 @@ xhr.onload = function() {
|
|||
emojis: ['etika','sneed','retardedchildren','bruh','autism','doot','kylieface','queenyes','wholesomeseal','chadyescapy','gigachadglow','gigachadorthodox','gigachad','gigachad2','gigachad3']
|
||||
},
|
||||
]
|
||||
};
|
||||
xhr.send(form);
|
||||
|
||||
var commentFormID;
|
||||
|
||||
function commentForm(form) {
|
||||
commentFormID = form;
|
||||
};
|
||||
|
||||
function getEmoji(searchTerm) {
|
||||
const form = document.getElementById('EMOJIS_favorite').getAttribute('data-form-destination')
|
||||
const commentBox = document.getElementById(form);
|
||||
const old = commentBox.value;
|
||||
const curPos = parseInt(commentBox.getAttribute('data-curr-pos'));
|
||||
|
||||
const firstHalf = old.slice(0, curPos)
|
||||
const lastHalf = old.slice(curPos)
|
||||
|
||||
let emoji = ':' + searchTerm + ':'
|
||||
const previousChar = firstHalf.slice(-1)
|
||||
if (firstHalf.length > 0 && previousChar !== " " && previousChar !== "\n") {
|
||||
emoji = " " + emoji
|
||||
}
|
||||
if (lastHalf.length > 0 && lastHalf[0] !== " ") {
|
||||
emoji = emoji + " "
|
||||
}
|
||||
|
||||
commentBox.value = firstHalf + emoji + lastHalf;
|
||||
|
||||
const newPos = curPos + emoji.length
|
||||
|
||||
commentBox.setAttribute('data-curr-pos', newPos.toString());
|
||||
|
||||
if (typeof checkForRequired === "function") checkForRequired();
|
||||
|
||||
const favorite_emojis = JSON.parse(localStorage.getItem("favorite_emojis")) || {}
|
||||
if (favorite_emojis[searchTerm]) favorite_emojis[searchTerm] += 1
|
||||
else favorite_emojis[searchTerm] = 1
|
||||
localStorage.setItem("favorite_emojis", JSON.stringify(favorite_emojis))
|
||||
}
|
||||
|
||||
function loadEmojis(form) {
|
||||
|
||||
let search_bar = document.getElementById("emoji_search");
|
||||
let search_container = document.getElementById('emoji-tab-search')
|
||||
|
@ -117,6 +81,7 @@ function loadEmojis(form) {
|
|||
const marseys = document.getElementById("EMOJIS_marsey")
|
||||
if (marseys.innerHTML == "")
|
||||
{
|
||||
console.log(EMOJIS_STRINGS)
|
||||
for (let i = 0; i < EMOJIS_STRINGS.length; i++) {
|
||||
let type = EMOJIS_STRINGS[i].type
|
||||
let container = document.getElementById(`EMOJIS_${type}`)
|
||||
|
@ -169,4 +134,38 @@ function loadEmojis(form) {
|
|||
search_bar.oninput = function () {
|
||||
loadEmojis(form);
|
||||
};
|
||||
};
|
||||
xhr.send(f);
|
||||
}
|
||||
|
||||
function getEmoji(searchTerm) {
|
||||
const form = document.getElementById('EMOJIS_favorite').getAttribute('data-form-destination')
|
||||
const commentBox = document.getElementById(form);
|
||||
const old = commentBox.value;
|
||||
const curPos = parseInt(commentBox.getAttribute('data-curr-pos'));
|
||||
|
||||
const firstHalf = old.slice(0, curPos)
|
||||
const lastHalf = old.slice(curPos)
|
||||
|
||||
let emoji = ':' + searchTerm + ':'
|
||||
const previousChar = firstHalf.slice(-1)
|
||||
if (firstHalf.length > 0 && previousChar !== " " && previousChar !== "\n") {
|
||||
emoji = " " + emoji
|
||||
}
|
||||
if (lastHalf.length > 0 && lastHalf[0] !== " ") {
|
||||
emoji = emoji + " "
|
||||
}
|
||||
|
||||
commentBox.value = firstHalf + emoji + lastHalf;
|
||||
|
||||
const newPos = curPos + emoji.length
|
||||
|
||||
commentBox.setAttribute('data-curr-pos', newPos.toString());
|
||||
|
||||
if (typeof checkForRequired === "function") checkForRequired();
|
||||
|
||||
const favorite_emojis = JSON.parse(localStorage.getItem("favorite_emojis")) || {}
|
||||
if (favorite_emojis[searchTerm]) favorite_emojis[searchTerm] += 1
|
||||
else favorite_emojis[searchTerm] = 1
|
||||
localStorage.setItem("favorite_emojis", JSON.stringify(favorite_emojis))
|
||||
}
|
|
@ -86,7 +86,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/static/assets/js/emoji_modal.js?a=225"></script>
|
||||
<script src="/static/assets/js/emoji_modal.js?a=226"></script>
|
||||
|
||||
<style>
|
||||
a.emojitab {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue