Move lottery to own page (#296)

remotes/1693045480750635534/spooky-22
outruncolors 2022-05-30 21:40:38 -05:00 committed by GitHub
parent b85f23becb
commit c2f598a17f
7 changed files with 183 additions and 199 deletions

View File

@ -45,3 +45,10 @@ def lottery_active(v):
lottery, participants = get_active_lottery_stats()
return {"message": "", "stats": {"user": v.lottery_stats, "lottery": lottery, "participants": participants}}
@app.get("/lottery")
@auth_required
@lottery_required
def lottery(v):
lottery_stats, participant_stats = get_active_lottery_stats()
return render_template("lottery.html", v=v, lottery_stats=lottery_stats, participant_stats=participant_stats)

View File

@ -8,7 +8,6 @@
{% if v %}
{% include "award_modal.html" %}
{% include "lottery_modal.html" %}
{% endif %}
<div style="display:none" id="popover">

View File

@ -88,11 +88,8 @@
{% if v and v.can_gamble and LOTTERY_ENABLED %}
<span data-bs-toggle="tooltip" data-bs-placement="bottom" title="Lottershe">
<a
href="#"
class="mobile-nav-icon d-md-none"
data-bs-toggle="modal"
data-bs-dismiss="modal"
data-bs-target="#lotteryModal">
href="/lottery"
class="mobile-nav-icon d-md-none">
<i class="fas fa-ticket align-middle text-gray-500"></i>
</a>
</span>
@ -144,11 +141,8 @@
data-bs-placement="bottom"
title="Lottershe">
<a
href="#"
class="nav-link"
data-bs-toggle="modal"
data-bs-dismiss="modal"
data-bs-target="#lotteryModal">
href="/lottery"
class="nav-link">
<i class="fas fa-ticket"></i>
</a>
</span>

View File

@ -0,0 +1,171 @@
{% extends "default.html" %}
{% block content %}
<div>
<div class="lottery-page--wrapper">
<div class="lottery-page--image">
<img src="/assets/images/rDrama/lottery.webp?v=2" />
<img
id="lotteryTicketPulled"
src="/assets/images/rDrama/lottery_active.webp?v=2"
style="display: none"
/>
</div>
<div class="lottery-page--stats">
{% if v.admin_level > 2 %}
<div
class="lottery-page--stat"
style="position: relative; padding-top: 1rem; overflow: hidden;"
>
<i
class="fas fa-broom"
style="
position: absolute;
bottom: -4px;
right: -4px;
font-size: 50px;
color: var(--gray-600);
"
>
</i>
<button
type="button"
class="btn btn-danger"
id="endLotterySession"
style="display: none"
onclick="endLotterySession()"
>
End Current Session
</button>
<button
type="button"
class="btn btn-success"
id="startLotterySession"
style="display: none"
onclick="startLotterySession()"
>
Start New Session
</button>
</div>
{% endif %}
<div class="lottery-page--stat">
<div class="lottery-page--stat-keys">
<div>Prize</div>
<div>Time Left</div>
<div>Tickets Sold</div>
<div>Participants</div>
</div>
<div class="lottery-page--stat-values">
<div>
<img
id="prize-image"
alt="coins"
class="mr-1 ml-1"
data-bs-toggle="tooltip"
data-bs-placement="bottom"
height="13"
src="/assets/images/rDrama/coins.webp?v=2"
title=""
aria-label="coins"
data-bs-original-title="coins"
style="display: none; position: relative; top: -2px"
/>
<span id="prize">-</span>
</div>
<div id="timeLeft">-</div>
<div id="ticketsSoldThisSession">-</div>
<div id="participantsThisSession">-</div>
</div>
</div>
<div class="lottery-page--stat">
<div class="lottery-page--stat-keys">
<div>Your Held Tickets</div>
<div>Lifetime Held Tickets</div>
<div>Lifetime Winnings</div>
</div>
<div class="lottery-page--stat-values">
<div id="ticketsHeldCurrent">-</div>
<div id="ticketsHeldTotal">-</div>
<div id="winnings">-</div>
</div>
</div>
<button
type="button"
class="btn btn-success lottery-page--action"
id="purchaseTicket"
onclick="purchaseLotteryTicket()"
>
Purchase 1 for
<img
alt="coins"
class="mr-1 ml-1"
data-bs-toggle="tooltip"
data-bs-placement="bottom"
height="13"
src="/assets/images/rDrama/coins.webp?v=2"
title=""
aria-label="coins"
data-bs-original-title="coins"
/>
12
</button>
</div>
</div>
<!-- Success -->
<div
class="toast"
id="lottery-post-success"
style="
position: fixed;
bottom: 1.5rem;
margin: 0 auto;
left: 0;
right: 0;
width: unset;
z-index: 1000;
"
role="alert"
aria-live="assertive"
aria-atomic="true"
data-bs-animation="true"
data-bs-autohide="true"
data-bs-delay="5000"
>
<div class="toast-body bg-success text-center text-white">
<i class="fas fa-comment-alt-smile mr-2"></i
><span id="lottery-post-success-text"></span>
</div>
</div>
<!-- Error -->
<div
class="toast"
id="lottery-post-error"
style="
position: fixed;
bottom: 1.5rem;
margin: 0 auto;
left: 0;
right: 0;
width: unset;
z-index: 1000;
"
role="alert"
aria-live="assertive"
aria-atomic="true"
data-bs-animation="true"
data-bs-autohide="true"
data-bs-delay="5000"
>
<div class="toast-body bg-danger text-center text-white">
<i class="fas fa-exclamation-circle mr-2"></i
><span id="lottery-post-error-text"></span>
</div>
</div>
</div>
<script src="{{asset('js/lottery.js')}}" data-cfasync="false"></script>
</div>
{% endblock %}

View File

@ -1,186 +0,0 @@
{% if LOTTERY_ENABLED %}
<div
class="modal fade lottery-modal"
id="lotteryModal"
tabindex="-1"
role="dialog"
aria-labelledby="lotteryModalTitle"
aria-hidden="true"
>
<div class="modal-dialog lottery-modal--dialog" role="document">
<div class="modal-content lottery-modal--content">
<button
class="close lottery-modal--close"
data-bs-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true"><i class="far fa-times"></i></span>
</button>
<div class="lottery-modal--wrapper">
<div class="lottery-modal--image">
<img src="/assets/images/rDrama/lottery_modal.webp?v=2" />
<img
id="lotteryTicketPulled"
src="/assets/images/rDrama/lottery_modal_active.webp?v=2"
style="display: none"
/>
</div>
<div class="lottery-modal--stats">
{% if v.admin_level > 2 %}
<div
class="lottery-modal--stat"
style="position: relative; padding-top: 1rem; overflow: hidden;"
>
<i
class="fas fa-broom"
style="
position: absolute;
bottom: -4px;
right: -4px;
font-size: 50px;
color: var(--gray-600);
"
>
</i>
<button
type="button"
class="btn btn-danger"
id="endLotterySession"
style="display: none"
onclick="endLotterySession()"
>
End Current Session
</button>
<button
type="button"
class="btn btn-success"
id="startLotterySession"
style="display: none"
onclick="startLotterySession()"
>
Start New Session
</button>
</div>
{% endif %}
<div class="lottery-modal--stat">
<div class="lottery-modal--stat-keys">
<div>Prize</div>
<div>Time Left</div>
<div>Tickets Sold</div>
<div>Participants</div>
</div>
<div class="lottery-modal--stat-values">
<div>
<img
id="prize-image"
alt="coins"
class="mr-1 ml-1"
data-bs-toggle="tooltip"
data-bs-placement="bottom"
height="13"
src="/assets/images/rDrama/coins.webp?v=2"
title=""
aria-label="coins"
data-bs-original-title="coins"
style="display: none; position: relative; top: -2px"
/>
<span id="prize">-</span>
</div>
<div id="timeLeft">-</div>
<div id="ticketsSoldThisSession">-</div>
<div id="participantsThisSession">-</div>
</div>
</div>
<div class="lottery-modal--stat">
<div class="lottery-modal--stat-keys">
<div>Your Held Tickets</div>
<div>Lifetime Held Tickets</div>
<div>Lifetime Winnings</div>
</div>
<div class="lottery-modal--stat-values">
<div id="ticketsHeldCurrent">-</div>
<div id="ticketsHeldTotal">-</div>
<div id="winnings">-</div>
</div>
</div>
<button
type="button"
class="btn btn-success lottery-modal--action"
id="purchaseTicket"
onclick="purchaseLotteryTicket()"
>
Purchase 1 for
<img
alt="coins"
class="mr-1 ml-1"
data-bs-toggle="tooltip"
data-bs-placement="bottom"
height="13"
src="/assets/images/rDrama/coins.webp?v=2"
title=""
aria-label="coins"
data-bs-original-title="coins"
/>
12
</button>
</div>
</div>
</div>
</div>
<!-- Success -->
<div
class="toast"
id="lottery-post-success"
style="
position: fixed;
bottom: 1.5rem;
margin: 0 auto;
left: 0;
right: 0;
width: unset;
z-index: 1000;
"
role="alert"
aria-live="assertive"
aria-atomic="true"
data-bs-animation="true"
data-bs-autohide="true"
data-bs-delay="5000"
>
<div class="toast-body bg-success text-center text-white">
<i class="fas fa-comment-alt-smile mr-2"></i
><span id="lottery-post-success-text"></span>
</div>
</div>
<!-- Error -->
<div
class="toast"
id="lottery-post-error"
style="
position: fixed;
bottom: 1.5rem;
margin: 0 auto;
left: 0;
right: 0;
width: unset;
z-index: 1000;
"
role="alert"
aria-live="assertive"
aria-atomic="true"
data-bs-animation="true"
data-bs-autohide="true"
data-bs-delay="5000"
>
<div class="toast-body bg-danger text-center text-white">
<i class="fas fa-exclamation-circle mr-2"></i
><span id="lottery-post-error-text"></span>
</div>
</div>
</div>
<script src="{{asset('js/lottery_modal.js')}}" data-cfasync="false"></script>
{% endif %}

View File

@ -2,7 +2,6 @@
{% if v %}
{% include "award_modal.html" %}
{% include "lottery_modal.html" %}
{% endif %}
{% if request.host == 'pcmemes.net' %}

View File

@ -18,7 +18,7 @@ set CACHE_VER = {
'js/award_modal.js': 253,
'js/bootstrap.js': 258,
'js/header.js': 269,
'js/lottery_modal.js': 250,
'js/lottery.js': 250,
'images/badges/': 1017,
}