space consistency

pull/225/head
Aevann 2024-03-06 02:15:10 +02:00
parent 2bc41bb010
commit 60b76d3f8d
8 changed files with 46 additions and 46 deletions

View File

@ -59,7 +59,7 @@ function updateBlackjackActions(state) {
actions.forEach(action => action.style.display = 'none');
if (state) {
if(state.actions.some((action) => action === 'HIT_SPLIT')) state.actions.push('SPLIT_ACTIONS');
if (state.actions.some((action) => action === 'HIT_SPLIT')) state.actions.push('SPLIT_ACTIONS');
// Show the correct ones.
state.actions.forEach(action => document.getElementById(`twentyone-${action}`).style.display = 'inline-block');
@ -116,16 +116,16 @@ function updateBlackjackTable(state) {
const gameCompleted = ['BLACKJACK', 'WON', 'PUSHED', 'LOST'].indexOf(state.status) !== -1 && (!state.has_player_split || ['WON', 'PUSHED', 'LOST'].indexOf(state.status_split) !== -1);
if(gameCompleted) {
if (gameCompleted) {
switch (state.status) {
case 'BLACKJACK':
updateResult(`Blackjack: Received ${state.payout} ${currency}`, "warning");
break;
case 'WON':
if(state.status_split === 'LOST') {
if (state.status_split === 'LOST') {
updateResult(`Won and Lost: Received 0 ${currency}`, "success");
}
else if(state.status_split === 'PUSHED') {
else if (state.status_split === 'PUSHED') {
updateResult(`Won and PUSHED: Received ${state.payout} ${currency}`, "success");
}
else {
@ -133,10 +133,10 @@ function updateBlackjackTable(state) {
}
break;
case 'PUSHED':
if(state.status_split === 'WON') {
if (state.status_split === 'WON') {
updateResult(`Won and PUSHED: Received ${state.payout} ${currency}`, "success");
}
else if(state.status_split === 'LOST') {
else if (state.status_split === 'LOST') {
updateResult(`Lost and Pushed: Lost ${state.wager.amount} ${currency}`, "danger");
}
else {
@ -145,10 +145,10 @@ function updateBlackjackTable(state) {
break;
case 'LOST':
if(state.status_split === 'WON') {
if (state.status_split === 'WON') {
updateResult(`Won and Lost: Received 0 ${currency}`, "success");
}
else if(state.status_split === 'PUSHED') {
else if (state.status_split === 'PUSHED') {
updateResult(`Lost and Pushed: Lost ${state.wager.amount} ${currency}`, "danger");
}
else {
@ -184,10 +184,10 @@ function updateCardsetBackgrounds(state, complete = false) {
for (const cardset of cardsets) {
['PLAYING', 'LOST', 'PUSHED', 'WON', 'BLACKJACK'].forEach(status => cardset.classList.remove(`blackjack-cardset__${status}`));
}
if(complete){
if (complete){
const wager = state.has_player_split ? state?.wager?.amount * 2 : state?.wager?.amount;
let dealerShows = state.payout < wager ? 'WON': 'LOST';
if(state.payout === wager || (state.player_doubled_down && state.status === 'PUSHED')) dealerShows = 'PUSHED'
if (state.payout === wager || (state.player_doubled_down && state.status === 'PUSHED')) dealerShows = 'PUSHED'
cardsets[0]?.classList.add(`blackjack-cardset__${dealerShows}`)
}
else {

View File

@ -280,7 +280,7 @@ function del(t) {
socket.on('delete', function(text) {
const text_spans = document.getElementsByClassName('text')
for(const span of text_spans) {
for (const span of text_spans) {
if (span.innerHTML == text)
{
span.parentElement.parentElement.parentElement.parentElement.parentElement.remove()

View File

@ -14,7 +14,7 @@ function post(url) {
};
function option_vote_0(oid, parentid, kind) {
for(let el of document.getElementsByClassName('presult-'+parentid)) {
for (let el of document.getElementsByClassName('presult-'+parentid)) {
el.classList.remove('d-none');
}
const full_oid = `option-${kind}-${oid}`
@ -27,7 +27,7 @@ function option_vote_0(oid, parentid, kind) {
}
function option_vote_1(oid, parentid, kind) {
for(let el of document.getElementsByClassName('presult-'+parentid)) {
for (let el of document.getElementsByClassName('presult-'+parentid)) {
el.classList.remove('d-none');
}
const full_oid = `option-${kind}-${oid}`
@ -56,10 +56,10 @@ function option_vote_2(t, oid, kind) {
() => {
t.disabled = true;
const parent = t.parentElement.parentElement
for(let el of parent.getElementsByClassName('bet')) {
for (let el of parent.getElementsByClassName('bet')) {
el.disabled = true;
}
for(let el of parent.getElementsByClassName('cost')) {
for (let el of parent.getElementsByClassName('cost')) {
el.classList.add('d-none')
}
const scoretext = document.getElementById('option-' + oid);

View File

@ -51,7 +51,7 @@ function postToast(t, url, data, extraActionsOnSuccess, extraActionsOnFailure) {
let form = new FormData();
if (typeof data === 'object' && data !== null) {
for(let k of Object.keys(data)) {
for (let k of Object.keys(data)) {
form.append(k, data[k]);
}
}
@ -448,11 +448,11 @@ function insertText(input, text) {
if (window.chrome !== undefined)
setTimeout(function(){
input.focus();
for(let i = 0; i < 2; i++)
for (let i = 0; i < 2; i++)
input.setSelectionRange(newPos, newPos);
input.focus();
for(let i = 0; i < 2; i++)
for (let i = 0; i < 2; i++)
input.setSelectionRange(newPos, newPos);
}, 1);
else

View File

@ -82,7 +82,7 @@ let emojiSearcher = {
}
// update stuff
for(const [emojiName, emojiDOM] of Object.entries(emojiDOMs))
for (const [emojiName, emojiDOM] of Object.entries(emojiDOMs))
emojiDOM.hidden = !resultSet.has(emojiName);
emojiNotFoundDOM.hidden = resultSet.size !== 0;
@ -112,7 +112,7 @@ function fetchEmojis() {
const bussyDOM = document.createElement("div");
for(let i = 0; i < emojis.length; i++)
for (let i = 0; i < emojis.length; i++)
{
const emoji = emojis[i];
@ -143,7 +143,7 @@ function fetchEmojis() {
}
// Create header
for(let className of classes)
for (let className of classes)
{
let classSelectorDOM = document.createElement("li");
classSelectorDOM.classList.add("nav-item");
@ -189,7 +189,7 @@ function switchEmojiTab(e)
// Special case: favorites
if (className === "favorite")
{
for(const emojiDOM of Object.values(emojiDOMs))
for (const emojiDOM of Object.values(emojiDOMs))
emojiDOM.hidden = true;
const favs = Object.keys(Object.fromEntries(
@ -203,7 +203,7 @@ function switchEmojiTab(e)
return;
}
for(const emojiDOM of Object.values(emojiDOMs))
for (const emojiDOM of Object.values(emojiDOMs))
emojiDOM.hidden = emojiDOM.dataset.className !== className;
document.getElementById('emoji-container').scrollTop = 0;
@ -217,7 +217,7 @@ async function start_search() {
emojiSearcher.addQuery(emojiSearchBarDOM.value.trim());
// Remove any selected tab, now it is meaningless
for(let i = 0; i < classesSelectorDOM.children.length; i++)
for (let i = 0; i < classesSelectorDOM.children.length; i++)
classesSelectorDOM.children[i].children[0].classList.remove("active");
}
@ -233,11 +233,11 @@ function emojiAddToInput(event)
let strToInsert = event.currentTarget.dataset.emojiName;
for(let i = 0; i < emojiSelectPostfixDOMs.length; i++)
for (let i = 0; i < emojiSelectPostfixDOMs.length; i++)
if (emojiSelectPostfixDOMs[i].checked)
strToInsert = strToInsert + emojiSelectPostfixDOMs[i].value;
for(let i = 0; i < emojiSelectSuffixDOMs.length; i++)
for (let i = 0; i < emojiSelectSuffixDOMs.length; i++)
if (emojiSelectSuffixDOMs[i].checked)
strToInsert = emojiSelectSuffixDOMs[i].value + strToInsert;

View File

@ -42,15 +42,15 @@ const emojisSearchDictionary = {
query = query.toLowerCase()
const result = new Set();
for(let i = 0; i < this.dict.length; i++)
for (let i = 0; i < this.dict.length; i++)
if (this.dict[i].tag.startsWith('@'))
{
if (this.dict[i].tag == query)
for(let j = 0; j < this.dict[i].emojiNames.length; j++)
for (let j = 0; j < this.dict[i].emojiNames.length; j++)
result.add(this.dict[i].emojiNames[j])
}
else if(this.dict[i].tag.includes(query))
for(let j = 0; j < this.dict[i].emojiNames.length; j++)
else if (this.dict[i].tag.includes(query))
for (let j = 0; j < this.dict[i].emojiNames.length; j++)
result.add(this.dict[i].emojiNames[j])
return result;
@ -85,7 +85,7 @@ function makeEmojisSearchDictionary() {
}
if (emoji.tags instanceof Array)
for(let i = 0; i < emoji.tags.length; i++)
for (let i = 0; i < emoji.tags.length; i++)
emojisSearchDictionary.updateTag(emoji.tags[i], emoji.name);
}

View File

@ -105,8 +105,8 @@ const findAllEmojiEndings = (word) => {
let currWord = word;
const currEndings = [];
while(!hasReachedNonModifer) {
if(currWord.endsWith('pat')) {
if(currEndings.indexOf(MODIFIERS.PAT) !== -1) {
if (currWord.endsWith('pat')) {
if (currEndings.indexOf(MODIFIERS.PAT) !== -1) {
hasReachedNonModifer = true;
continue;
}
@ -115,8 +115,8 @@ const findAllEmojiEndings = (word) => {
continue;
}
if(currWord.endsWith('talking')) {
if(currEndings.indexOf(MODIFIERS.TALKING) !== -1) {
if (currWord.endsWith('talking')) {
if (currEndings.indexOf(MODIFIERS.TALKING) !== -1) {
hasReachedNonModifer = true;
continue;
}
@ -125,8 +125,8 @@ const findAllEmojiEndings = (word) => {
continue;
}
if(currWord.endsWith('genocide')) {
if(currEndings.indexOf(MODIFIERS.GENOCIDE) !== -1) {
if (currWord.endsWith('genocide')) {
if (currEndings.indexOf(MODIFIERS.GENOCIDE) !== -1) {
hasReachedNonModifer = true;
continue;
}
@ -135,8 +135,8 @@ const findAllEmojiEndings = (word) => {
continue;
}
if(currWord.endsWith('love')) {
if(currEndings.indexOf(MODIFIERS.LOVE) !== -1) {
if (currWord.endsWith('love')) {
if (currEndings.indexOf(MODIFIERS.LOVE) !== -1) {
hasReachedNonModifer = true;
continue;
}
@ -145,8 +145,8 @@ const findAllEmojiEndings = (word) => {
continue;
}
if(currWord.endsWith('typing')) {
if(currEndings.indexOf(MODIFIERS.TYPING) !== -1) {
if (currWord.endsWith('typing')) {
if (currEndings.indexOf(MODIFIERS.TYPING) !== -1) {
hasReachedNonModifer = true;
continue;
}
@ -260,7 +260,7 @@ function markdown(t) {
let options = Array.from(input.matchAll(/\$\$([^\$\n]+)\$\$(?![^`]*`)/gi))
if (options != null){
for(i = 0; i < options.length; i++){
for (i = 0; i < options.length; i++){
const option = options[i][0];
const option2 = option.replace(/\$\$/g, '').replace(/\n/g, '')
input = input.replace(option, `<div class="custom-control mb-3"><input type="checkbox" class="custom-control-input" id="option-${i}"><label class="custom-control-label" for="option-${i}">${option2} - <a>0 votes</a></label></div>`);
@ -269,7 +269,7 @@ function markdown(t) {
options = Array.from(input.matchAll(/&&([^&\n]+)&&(?![^`]*`)/gi))
if (options != null){
for(i = 0; i < options.length; i++){
for (i = 0; i < options.length; i++){
const option = options[i][0];
const option2 = option.replace(/&&/g, '').replace(/\n/g, '')
input = input.replace(option, `<div class="custom-control mb-3"><input type="radio" name="choice" class="custom-control-input" id="option-${i}"><label class="custom-control-label" for="option-${i}">${option2} - <a>0 votes</a></label></div>`);

View File

@ -1,5 +1,5 @@
function toggleElement(id, id2) {
for(let el of document.getElementsByClassName('toggleable')) {
for (let el of document.getElementsByClassName('toggleable')) {
if (el.id != id) {
el.classList.add('d-none');
}
@ -26,7 +26,7 @@ function updateBux(mobile=false) {
function transferCoins(t, mobile=false) {
close_inline_emoji_modal();
for(let el of document.getElementsByClassName('toggleable')) {
for (let el of document.getElementsByClassName('toggleable')) {
el.classList.add('d-none');
}
@ -52,7 +52,7 @@ function transferCoins(t, mobile=false) {
function transferBux(t, mobile=false) {
close_inline_emoji_modal();
for(let el of document.getElementsByClassName('toggleable')) {
for (let el of document.getElementsByClassName('toggleable')) {
el.classList.add('d-none');
}