bvv
This commit is contained in:
parent
ae56403979
commit
255bc5ca6b
5 changed files with 101 additions and 19 deletions
|
@ -81,7 +81,10 @@ function awardModal(link) {
|
|||
}
|
||||
|
||||
function bruh(kind) {
|
||||
document.getElementById('giveaward').disabled=false;
|
||||
document.getElementById('buy1').disabled=false;
|
||||
document.getElementById('buy2').disabled=false;
|
||||
let ownednum = Number(document.getElementById(`${kind}-owned`).textContent);
|
||||
document.getElementById('giveaward').disabled = (ownednum == 0);
|
||||
document.getElementById('kind').value=kind;
|
||||
try {document.getElementsByClassName('picked')[0].classList.toggle('picked');} catch(e) {console.log(e)}
|
||||
document.getElementById(kind).classList.toggle('picked')
|
||||
|
@ -94,3 +97,68 @@ function bruh(kind) {
|
|||
document.getElementById('note').placeholder = "Note to include in award notification";
|
||||
}
|
||||
}
|
||||
|
||||
function bruh2(kind) {
|
||||
console.log(kind)
|
||||
let buy1 = document.getElementById('buy1')
|
||||
if (kind == "grass") buy1.disabled=true;
|
||||
else buy1.disabled=false;
|
||||
let buy2 = document.getElementById('buy1')
|
||||
if (kind == "benefactor") buy2.disabled=true;
|
||||
else buy2.disabled=false;
|
||||
document.getElementById('giveaward').disabled=true;
|
||||
document.getElementById('kind').value=kind;
|
||||
let picked = document.getElementsByClassName('picked')[0]
|
||||
if (picked) picked.classList.remove('picked')
|
||||
document.getElementById(kind).classList.toggle('picked')
|
||||
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";
|
||||
}
|
||||
else {
|
||||
document.getElementById('notelabel').innerHTML = "Note (optional):";
|
||||
document.getElementById('note').placeholder = "Note to include in award notification";
|
||||
}
|
||||
}
|
||||
|
||||
function buy(mb) {
|
||||
document.getElementById('toast-post-error-text').innerText = "Error, please try again later."
|
||||
const kind = document.getElementById('kind').value;
|
||||
const xhr = new XMLHttpRequest();
|
||||
url = `/buy/${kind}`
|
||||
if (mb) url += "?mb=true"
|
||||
xhr.open("POST", url, true);
|
||||
xhr.setRequestHeader('xhr', 'xhr');
|
||||
var form = new FormData()
|
||||
form.append("formkey", formkey());
|
||||
|
||||
if(typeof data === 'object' && data !== null) {
|
||||
for(let k of Object.keys(data)) {
|
||||
form.append(k, data[k]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
form.append("formkey", formkey());
|
||||
xhr.withCredentials=true;
|
||||
|
||||
xhr.onload = function() {
|
||||
let data
|
||||
try {data = JSON.parse(xhr.response)}
|
||||
catch(e) {console.log(e)}
|
||||
if (xhr.status >= 200 && xhr.status < 300 && data && data["message"]) {
|
||||
document.getElementById('toast-post-success-text2').innerText = data["message"];
|
||||
new bootstrap.Toast(document.getElementById('toast-post-success2')).show();
|
||||
document.getElementById('giveaward').disabled=false;
|
||||
let owned = document.getElementById(`${kind}-owned`)
|
||||
let ownednum = Number(owned.textContent);
|
||||
owned.textContent = ownednum + 1
|
||||
} else {
|
||||
if (data && data["error"]) document.getElementById('toast-post-error-text2').innerText = data["error"];
|
||||
new bootstrap.Toast(document.getElementById('toast-post-error2')).show();
|
||||
}
|
||||
};
|
||||
|
||||
xhr.send(form);
|
||||
|
||||
}
|
|
@ -149,6 +149,7 @@ if SITE == 'rdrama.net':
|
|||
JOAN_ID = 28
|
||||
MOOSE_ID = 1904
|
||||
AEVANN_ID = 1
|
||||
Q_ID = 1480
|
||||
LAWLZ_ID = 3833
|
||||
LLM_ID = 253
|
||||
DAD_ID = 2513
|
||||
|
@ -176,6 +177,7 @@ elif SITE == "pcmemes.net":
|
|||
JOAN_ID = 0
|
||||
MOOSE_ID = 0
|
||||
AEVANN_ID = 1
|
||||
Q_ID = 0
|
||||
LAWLZ_ID = 0
|
||||
LLM_ID = 0
|
||||
DAD_ID = 0
|
||||
|
@ -203,6 +205,7 @@ else:
|
|||
JOAN_ID = 0
|
||||
MOOSE_ID = 0
|
||||
AEVANN_ID = 0
|
||||
Q_ID = 0
|
||||
LAWLZ_ID = 0
|
||||
LLM_ID = 0
|
||||
DAD_ID = 0
|
||||
|
@ -288,8 +291,8 @@ BADGES = {
|
|||
'description': 'Contributed at least $100'
|
||||
},
|
||||
26: {
|
||||
'name': 'Rightoid Agendaposter',
|
||||
'description': 'Forced to use the agendaposter theme'
|
||||
'name': 'Rightoid',
|
||||
'description': 'Forced to use the rightoid theme'
|
||||
},
|
||||
27: {
|
||||
'name': 'Lolcow',
|
||||
|
@ -656,8 +659,8 @@ AWARDS = {
|
|||
},
|
||||
"agendaposter": {
|
||||
"kind": "agendaposter",
|
||||
"title": "Rightoid Agendaposter",
|
||||
"description": "Forces the agendaposter theme on the recipient for 24 hours.",
|
||||
"title": "Rightoid",
|
||||
"description": "Forces the rightoid theme on the recipient for 24 hours.",
|
||||
"icon": "fas fa-snooze",
|
||||
"color": "text-purple",
|
||||
"price": 2500
|
||||
|
|
|
@ -84,7 +84,7 @@ def shop(v):
|
|||
@auth_required
|
||||
def buy(v, award):
|
||||
if award == 'benefactor' and not request.values.get("mb"):
|
||||
return {"error": "You can only buy this award with marseybux."}, 403
|
||||
return {"error": "You can only buy the Benefactor award with marseybux."}, 403
|
||||
|
||||
AWARDS = deepcopy(AWARDS2)
|
||||
|
||||
|
|
|
@ -219,8 +219,8 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
|
|||
else: cutoff = now - 86400
|
||||
posts = posts.filter(Submission.created_utc >= cutoff)
|
||||
|
||||
if sort != "hot": posts = posts.filter_by(is_banned=False, private=False, deleted_utc = 0)
|
||||
else: posts = posts.filter_by(is_banned=False, stickied=None, private=False, deleted_utc = 0)
|
||||
if sort == "hot" or v.id == Q_ID: posts = posts.filter_by(is_banned=False, stickied=None, private=False, deleted_utc = 0)
|
||||
else: posts = posts.filter_by(is_banned=False, private=False, deleted_utc = 0)
|
||||
|
||||
if v and v.admin_level == 0:
|
||||
blocking = [x[0] for x in g.db.query(
|
||||
|
@ -247,7 +247,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
|
|||
if not (v and v.shadowbanned):
|
||||
posts = posts.join(User, User.id == Submission.author_id).filter(User.shadowbanned == None)
|
||||
|
||||
if sort == "hot":
|
||||
if sort == "hot" or v.id == Q_ID:
|
||||
ti = int(time.time()) + 3600
|
||||
posts = posts.order_by(-1000000*(Submission.realupvotes + 1 + Submission.comment_count/5)/(func.power(((ti - Submission.created_utc)/1000), 1.23)))
|
||||
elif sort == "new":
|
||||
|
@ -272,7 +272,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
|
|||
|
||||
posts = posts[:size]
|
||||
|
||||
if sort == "hot" and page == 1:
|
||||
if (sort == "hot" or v.id == Q_ID) and page == 1:
|
||||
pins = g.db.query(Submission).filter(Submission.stickied != None, Submission.is_banned == False)
|
||||
if v and v.admin_level == 0:
|
||||
blocking = [x[0] for x in g.db.query(UserBlock.target_id).filter_by(user_id=v.id).all()]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<script src="/static/assets/js/award_modal.js?a=202"></script>
|
||||
<script src="/static/assets/js/award_modal.js?a=208"></script>
|
||||
<div class="modal fade" id="awardModal" tabindex="-1" role="dialog" aria-labelledby="awardModalTitle" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-scrollable modal-dialog-centered awardmodal" role="document">
|
||||
<div class="modal-content">
|
||||
|
@ -13,14 +13,10 @@
|
|||
<input autocomplete="off" type="hidden" name="formkey", value="{{v.formkey}}">
|
||||
<div class="card-columns award-columns awards-wrapper">
|
||||
{% for award in v.user_awards %}
|
||||
{% if award.owned %}
|
||||
<a role="button" id="{{award.kind}}" class="card" onclick="bruh('{{award.kind}}')">
|
||||
{% else %}
|
||||
<a role="button" id="{{award.kind}}" class="card disabled">
|
||||
{% endif %}
|
||||
<a role="button" id="{{award.kind}}" class="card" onclick="bruh('{{award.kind}}')">
|
||||
<i class="{{award.icon}} {{award.color}}"></i>
|
||||
<div class="pt-2" style="font-weight: bold; font-size: 14px; color:#E1E1E1">{{award.title}}</div>
|
||||
<div class="text-muted">{{award.owned}} owned</div>
|
||||
<div class="text-muted"><span id="{{award.kind}}-owned">{{award.owned}}</span> owned</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
@ -28,14 +24,25 @@
|
|||
<input autocomplete="off" id="kind" name="kind" value="" hidden>
|
||||
<textarea autocomplete="off" id="note" maxlength="200" name="note" class="form-control" placeholder="Note to include in award notification..."></textarea>
|
||||
<input autocomplete="off" id="giveaward" class="btn btn-primary mt-3" style="float:right" type="submit" value="Give Award" disabled>
|
||||
<button id="buy1" class="btn btn-primary mt-3 mx-3" type="button" disabled style="float:right" onclick="buy(true)">Buy with Marseybux</button>
|
||||
<button id="buy2" class="btn btn-primary mt-3" type="button" disabled style="float:right" onclick="buy()">Buy with coins</button>
|
||||
<pre>
|
||||
|
||||
|
||||
</pre>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="toast" id="toast-post-success2" style="position: fixed; bottom: 1.5rem; margin: 0 auto; left: 0; right: 0; width: 275px; 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="toast-post-success-text2">Action successful!</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="toast" id="toast-post-error2" style="position: fixed; bottom: 1.5rem; margin: 0 auto; left: 0; right: 0; width: 275px; 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="toast-post-error-text2">Error, please try again later.</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
|
@ -79,4 +86,8 @@
|
|||
.awardmodal {
|
||||
max-width: 90% !important;
|
||||
}
|
||||
|
||||
toast {
|
||||
z-index: 7000 !important;
|
||||
}
|
||||
</style>
|
Loading…
Add table
Add a link
Reference in a new issue