function vote(type, id, dir) { const upvotes = document.getElementsByClassName(type + '-' + id + '-up'); const downvotes = document.getElementsByClassName(type + '-' + id + '-down'); const scoretexts = document.getElementsByClassName(type + '-score-' + id); for (let i=0; i 0) { document.getElementsByClassName('picked')[0].classList.toggle('picked'); } document.getElementById(kind).classList.toggle('picked') if (kind == "chud") { document.getElementById('phrase_section').classList.remove("d-none") note_section.classList.add("d-none") } else { document.getElementById('phrase_section').classList.add("d-none") note_section.classList.remove("d-none") } if (kind == "emoji") { if (giveaward_button.dataset.url.startsWith('/award/post/')) document.getElementById('emoji_behavior_section').classList.remove("d-none") document.getElementById('note').setAttribute("style", "min-height:35px;max-height:35px;height:35px;min-width:min(300px,80vw)") gif_button.classList.add('d-none') } else { document.getElementById('emoji_behavior_section').classList.add("d-none") document.getElementById('note').removeAttribute("style") gif_button.classList.remove('d-none') } if (kind == "flairlock") { document.getElementById('notelabel').innerHTML = "New flair:"; document.getElementById('note').placeholder = "Insert new flair here, or leave empty to add 1 day to the duration of the current flair."; document.getElementById('note').maxLength = 100; } else if (kind == "namelock") { document.getElementById('notelabel').innerHTML = "New username:"; document.getElementById('note').placeholder = "Insert new username here, or leave empty to add 1 day to the duration of the current username."; document.getElementById('note').maxLength = 25; } else if (kind == "emoji") { document.getElementById('notelabel').innerHTML = "Emoji name:"; document.getElementById('note').placeholder = "Insert one site emoji here."; document.getElementById('note').maxLength = 33; } else { document.getElementById('notelabel').innerHTML = "Note (optional):"; document.getElementById('note').placeholder = "Note to include in award notification"; document.getElementById('note').maxLength = 200; } const ownednum = Number(document.getElementById(`${kind}-owned`).textContent); if (kind == 'grass') global_currency = 'coins' else if (kind == 'benefactor') global_currency = 'marseybux' else global_currency = 'coins/marseybux' if (ownednum > 0) { document.getElementById('award_price').textContent = `${ownednum} owned`; giveaward_button.classList.remove('d-none'); document.getElementById('buyandgiveaward').classList.add('d-none'); } else { document.getElementById('award_price').textContent = `Price: ${price} ${global_currency}`; giveaward_button.classList.add('d-none'); document.getElementById('buyandgiveaward').classList.remove('d-none'); } } function giveaward(t) { const kind = document.getElementById('kind').value; const note_id = (kind == "chud" ? "chud_phrase" : "note") postToast(t, t.dataset.url, { "kind": kind, "note": document.getElementById(note_id).value, "emoji_behavior": document.getElementById("emoji_behavior").value }, () => { let owned = document.getElementById(`${kind}-owned`) let ownednum = Number(owned.textContent) - 1; owned.textContent = ownednum let ownedblock = document.getElementById(`${kind}-owned-block`) if (ownednum > 0) { ownedblock.textContent = `${ownednum} owned`; document.getElementById('award_price').textContent = `${ownednum} owned`; } else { ownedblock.textContent = `Price: ${global_price}` document.getElementById('award_price').textContent = `Price: ${global_price} ${global_currency}`; } } ); } const awardtabs = document.getElementsByClassName('award-tab'); const awardsections = document.getElementsByClassName('award-section'); function switchAwardTab() { for (const element of awardtabs) element.classList.toggle('active') for (const element of awardsections) element.classList.toggle('d-none') }