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) {
|
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;
|
document.getElementById('kind').value=kind;
|
||||||
try {document.getElementsByClassName('picked')[0].classList.toggle('picked');} catch(e) {console.log(e)}
|
try {document.getElementsByClassName('picked')[0].classList.toggle('picked');} catch(e) {console.log(e)}
|
||||||
document.getElementById(kind).classList.toggle('picked')
|
document.getElementById(kind).classList.toggle('picked')
|
||||||
|
@ -94,3 +97,68 @@ function bruh(kind) {
|
||||||
document.getElementById('note').placeholder = "Note to include in award notification";
|
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
|
JOAN_ID = 28
|
||||||
MOOSE_ID = 1904
|
MOOSE_ID = 1904
|
||||||
AEVANN_ID = 1
|
AEVANN_ID = 1
|
||||||
|
Q_ID = 1480
|
||||||
LAWLZ_ID = 3833
|
LAWLZ_ID = 3833
|
||||||
LLM_ID = 253
|
LLM_ID = 253
|
||||||
DAD_ID = 2513
|
DAD_ID = 2513
|
||||||
|
@ -176,6 +177,7 @@ elif SITE == "pcmemes.net":
|
||||||
JOAN_ID = 0
|
JOAN_ID = 0
|
||||||
MOOSE_ID = 0
|
MOOSE_ID = 0
|
||||||
AEVANN_ID = 1
|
AEVANN_ID = 1
|
||||||
|
Q_ID = 0
|
||||||
LAWLZ_ID = 0
|
LAWLZ_ID = 0
|
||||||
LLM_ID = 0
|
LLM_ID = 0
|
||||||
DAD_ID = 0
|
DAD_ID = 0
|
||||||
|
@ -203,6 +205,7 @@ else:
|
||||||
JOAN_ID = 0
|
JOAN_ID = 0
|
||||||
MOOSE_ID = 0
|
MOOSE_ID = 0
|
||||||
AEVANN_ID = 0
|
AEVANN_ID = 0
|
||||||
|
Q_ID = 0
|
||||||
LAWLZ_ID = 0
|
LAWLZ_ID = 0
|
||||||
LLM_ID = 0
|
LLM_ID = 0
|
||||||
DAD_ID = 0
|
DAD_ID = 0
|
||||||
|
@ -288,8 +291,8 @@ BADGES = {
|
||||||
'description': 'Contributed at least $100'
|
'description': 'Contributed at least $100'
|
||||||
},
|
},
|
||||||
26: {
|
26: {
|
||||||
'name': 'Rightoid Agendaposter',
|
'name': 'Rightoid',
|
||||||
'description': 'Forced to use the agendaposter theme'
|
'description': 'Forced to use the rightoid theme'
|
||||||
},
|
},
|
||||||
27: {
|
27: {
|
||||||
'name': 'Lolcow',
|
'name': 'Lolcow',
|
||||||
|
@ -656,8 +659,8 @@ AWARDS = {
|
||||||
},
|
},
|
||||||
"agendaposter": {
|
"agendaposter": {
|
||||||
"kind": "agendaposter",
|
"kind": "agendaposter",
|
||||||
"title": "Rightoid Agendaposter",
|
"title": "Rightoid",
|
||||||
"description": "Forces the agendaposter theme on the recipient for 24 hours.",
|
"description": "Forces the rightoid theme on the recipient for 24 hours.",
|
||||||
"icon": "fas fa-snooze",
|
"icon": "fas fa-snooze",
|
||||||
"color": "text-purple",
|
"color": "text-purple",
|
||||||
"price": 2500
|
"price": 2500
|
||||||
|
|
|
@ -84,7 +84,7 @@ def shop(v):
|
||||||
@auth_required
|
@auth_required
|
||||||
def buy(v, award):
|
def buy(v, award):
|
||||||
if award == 'benefactor' and not request.values.get("mb"):
|
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)
|
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
|
else: cutoff = now - 86400
|
||||||
posts = posts.filter(Submission.created_utc >= cutoff)
|
posts = posts.filter(Submission.created_utc >= cutoff)
|
||||||
|
|
||||||
if sort != "hot": posts = posts.filter_by(is_banned=False, 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, 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:
|
if v and v.admin_level == 0:
|
||||||
blocking = [x[0] for x in g.db.query(
|
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):
|
if not (v and v.shadowbanned):
|
||||||
posts = posts.join(User, User.id == Submission.author_id).filter(User.shadowbanned == None)
|
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
|
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)))
|
posts = posts.order_by(-1000000*(Submission.realupvotes + 1 + Submission.comment_count/5)/(func.power(((ti - Submission.created_utc)/1000), 1.23)))
|
||||||
elif sort == "new":
|
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]
|
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)
|
pins = g.db.query(Submission).filter(Submission.stickied != None, Submission.is_banned == False)
|
||||||
if v and v.admin_level == 0:
|
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()]
|
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 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-dialog modal-dialog-scrollable modal-dialog-centered awardmodal" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
@ -13,14 +13,10 @@
|
||||||
<input autocomplete="off" type="hidden" name="formkey", value="{{v.formkey}}">
|
<input autocomplete="off" type="hidden" name="formkey", value="{{v.formkey}}">
|
||||||
<div class="card-columns award-columns awards-wrapper">
|
<div class="card-columns award-columns awards-wrapper">
|
||||||
{% for award in v.user_awards %}
|
{% for award in v.user_awards %}
|
||||||
{% if award.owned %}
|
<a role="button" id="{{award.kind}}" class="card" onclick="bruh('{{award.kind}}')">
|
||||||
<a role="button" id="{{award.kind}}" class="card" onclick="bruh('{{award.kind}}')">
|
|
||||||
{% else %}
|
|
||||||
<a role="button" id="{{award.kind}}" class="card disabled">
|
|
||||||
{% endif %}
|
|
||||||
<i class="{{award.icon}} {{award.color}}"></i>
|
<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="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>
|
</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
@ -28,14 +24,25 @@
|
||||||
<input autocomplete="off" id="kind" name="kind" value="" hidden>
|
<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>
|
<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>
|
<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>
|
||||||
|
|
||||||
|
|
||||||
</pre>
|
</pre>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -79,4 +86,8 @@
|
||||||
.awardmodal {
|
.awardmodal {
|
||||||
max-width: 90% !important;
|
max-width: 90% !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toast {
|
||||||
|
z-index: 7000 !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
Loading…
Add table
Add a link
Reference in a new issue