rework "are you sure?" and make it work on subscribing to posts and reverting admin actions
parent
b515b8bd15
commit
acbfbb07ce
|
@ -97,30 +97,16 @@ function vote(type, id, dir) {
|
|||
|
||||
function pick(kind, canbuy1, canbuy2) {
|
||||
const buy1 = document.getElementById('buy1')
|
||||
const buy1go = document.getElementById('buy1-go')
|
||||
if (canbuy1 && kind != "grass")
|
||||
{
|
||||
buy1.disabled=false;
|
||||
buy1go.disabled=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
buy1.disabled=true;
|
||||
buy1go.disabled=true;
|
||||
}
|
||||
|
||||
const buy2 = document.getElementById('buy2')
|
||||
const buy2go = document.getElementById('buy2-go')
|
||||
if (canbuy2 && kind != "benefactor")
|
||||
{
|
||||
buy2.disabled=false;
|
||||
buy2go.disabled=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
buy2.disabled=true;
|
||||
buy2go.disabled=true;
|
||||
}
|
||||
|
||||
let ownednum = Number(document.getElementById(`${kind}-owned`).textContent);
|
||||
document.getElementById('giveaward').disabled = (ownednum == 0);
|
||||
|
|
|
@ -338,3 +338,18 @@ function timestamp(str, ti) {
|
|||
const date = new Date(ti*1000);
|
||||
document.getElementById(str).setAttribute("data-bs-original-title", formatDate(date));
|
||||
};
|
||||
|
||||
function areyousure(t) {
|
||||
if (t.value) {
|
||||
t.type = 'submit';
|
||||
t.value = 'Are you sure?'
|
||||
}
|
||||
else
|
||||
{
|
||||
t.innerHTML = t.innerHTML.replace(t.textContent, 'Are you sure?')
|
||||
}
|
||||
t.setAttribute("onclick", t.dataset.click);
|
||||
|
||||
if (t.dataset.dismiss)
|
||||
t.setAttribute("data-bs-dismiss", t.dataset.dismiss);
|
||||
}
|
||||
|
|
|
@ -374,7 +374,7 @@ class Submission(Base):
|
|||
body += " - <b>WINNER!</b>"
|
||||
|
||||
if not winner and v and v.admin_level >= PERMS['POST_BETS_DISTRIBUTE']:
|
||||
body += f'''<button class="btn btn-primary distribute" onclick="this.nextElementSibling.classList.remove('d-none');this.classList.add('d-none')">Declare winner</button><button class="btn btn-primary distribute d-none" onclick="post_toast(this,'/distribute/{o.id}',true)">Are you sure?</button>'''
|
||||
body += f'''<button class="btn btn-primary distribute" data-click="post_toast(this,'/distribute/{o.id}',true)" onclick="areyousure(this)">Declare winner</button>'''
|
||||
body += "</div>"
|
||||
else:
|
||||
input_type = 'radio' if o.exclusive else 'checkbox'
|
||||
|
|
|
@ -32,11 +32,9 @@
|
|||
|
||||
<input autocomplete="off" id="giveaward" class="awardbtn btn btn-primary mt-3" style="float:right" type="submit" onclick="giveaward(this)" value="Give Award" data-bs-dismiss="modal" disabled>
|
||||
|
||||
<button id="buy1" class="awardbtn btn btn-primary mt-3 mx-3 {% if SITE_NAME == 'WPD' %}d-none{% endif %}" type="button" disabled style="float:right" onclick="this.classList.add('d-none');document.getElementById('buy1-go').classList.remove('d-none')">Buy with marseybux</button>
|
||||
<button id="buy1-go" class="awardbtn btn btn-primary mt-3 mx-3 d-none" type="button" disabled style="float:right" onclick="buy(true)">Are you sure?</button>
|
||||
<button id="buy1" class="awardbtn btn btn-primary mt-3 mx-3 {% if SITE_NAME == 'WPD' %}d-none{% endif %}" type="button" disabled style="float:right" data-click="buy(true)" onclick="areyousure(this)">Buy with marseybux</button>
|
||||
|
||||
<button id="buy2" class="awardbtn btn btn-primary mt-3" type="button" disabled style="float:right" onclick="this.classList.add('d-none');document.getElementById('buy2-go').classList.remove('d-none')">Buy</button>
|
||||
<button id="buy2-go" class="awardbtn btn btn-primary mt-3 d-none" type="button" disabled style="float:right" onclick="buy()">Are you sure?</button>
|
||||
<button id="buy2" class="awardbtn btn btn-primary mt-3" type="button" disabled style="float:right" data-click="buy()" onclick="areyousure(this)">Buy</button>
|
||||
<pre>
|
||||
</pre>
|
||||
</div>
|
||||
|
|
|
@ -642,9 +642,9 @@
|
|||
{% endif %}
|
||||
|
||||
{% if not c.ghost %}
|
||||
<a id="unblock2-{{c.id}}" data-bs-dismiss="modal" class="text-success list-group-item {% if not c.is_blocking %}d-none{% endif %}" role="button" onclick="post_toast(this,'/settings/unblock?username={{c.author.username}}','block2-{{c.id}}','unblock2-{{c.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-eye-slash text-success mr-2"></i>Unblock user</a>
|
||||
<a id="prompt2-{{c.id}}" data-bs-dismiss="modal" class="blockuser list-group-item d-none text-danger" role="button" onclick="post_toast(this,'/settings/block?username={{c.author.username}}','prompt2-{{c.id}}','unblock2-{{c.id}}','d-none')"><i class="fas fa-eye-slash fa-fw text-danger mr-2"></i>Are you sure?</a>
|
||||
<a id="block2-{{c.id}}" class="{% if c.is_blocking %}d-none{% endif %} list-group-item text-danger" role="button" onclick="document.getElementById('block2-{{c.id}}').classList.toggle('d-none');document.getElementById('prompt2-{{c.id}}').classList.toggle('d-none');"><i class="fas fa-eye-slash fa-fw text-danger mr-2"></i>Block user</a>
|
||||
<a id="unblock2-{{c.id}}" data-bs-dismiss="modal" class="text-success list-group-item {% if not c.is_blocking %}d-none{% endif %}" role="button" onclick="post_toast(this,'/settings/unblock?username={{c.author.username}}','block2-{{c.id}}','unblock2-{{c.id}}','d-none')"><i class="fas fa-eye-slash text-success mr-2"></i>Unblock user</a>
|
||||
|
||||
<a id="block2-{{c.id}}" class="{% if c.is_blocking %}d-none{% endif %} list-group-item text-danger" role="button" data-click="post_toast(this,'/settings/block?username={{c.author.username}}','block2-{{c.id}}','unblock2-{{c.id}}','d-none')" onclick="areyousure(this)" data-dismiss="modal"><i class="fas fa-eye-slash fa-fw text-danger mr-2"></i>Block user</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
|
|
|
@ -124,14 +124,10 @@
|
|||
<td class="shop-table-actions" style="width:unset">
|
||||
{% if hat.id not in owned_hat_ids %}
|
||||
<div id="if-not-owned-{{hat.id}}">
|
||||
<a id="buy1-{{hat.id}}" class="btn btn-success {% if v.coins < hat.price %}disabled{% endif %}" role="button" onclick="this.classList.add('d-none');document.getElementById('buy1-go-{{hat.id}}').classList.remove('d-none')"><span class="m-auto">Buy</span></a>
|
||||
|
||||
<a id="buy1-go-{{hat.id}}" class="d-none btn btn-success {% if v.coins < hat.price %}disabled{% endif %}" role="button" onclick="post_toast(this, '/buy_hat/{{hat.id}}', 'if-not-owned-{{hat.id}}', 'if-owned-{{hat.id}}', 'd-none', (xhr)=>{if(xhr.status == 200)document.getElementById('user-coins-amount').innerHTML-={{hat.price}}})"><span class="m-auto">Are you sure?</span></a>
|
||||
<a id="buy1-{{hat.id}}" class="btn btn-success {% if v.coins < hat.price %}disabled{% endif %}" role="button" data-click="post_toast(this, '/buy_hat/{{hat.id}}', 'if-not-owned-{{hat.id}}', 'if-owned-{{hat.id}}', 'd-none', (xhr)=>{if(xhr.status == 200)document.getElementById('user-coins-amount').innerHTML-={{hat.price}}})" onclick="areyousure(this)"><span class="m-auto">Buy</span></a>
|
||||
|
||||
{% if FEATURES['PROCOINS'] %}
|
||||
<a id="buy2-{{hat.id}}" class="marseybux btn btn-success {% if v.procoins < hat.price %}disabled{% endif %}" role="button" onclick="this.classList.add('d-none');document.getElementById('buy2-go-{{hat.id}}').classList.remove('d-none')"><span class="m-auto">MBux</span></a>
|
||||
|
||||
<a id="buy2-go-{{hat.id}}" class="d-none marseybux btn btn-success {% if v.procoins < hat.price %}disabled{% endif %}" role="button" onclick="post_toast(this, '/buy_hat/{{hat.id}}?mb=true', 'if-not-owned-{{hat.id}}', 'if-owned-{{hat.id}}', 'd-none', (xhr)=>{if(xhr.status == 200)document.getElementById('user-bux-amount').innerHTML-={{hat.price}}})"><span class="m-auto">Are you sure?</span></a>
|
||||
<a id="buy2-{{hat.id}}" class="marseybux btn btn-success {% if v.procoins < hat.price %}disabled{% endif %}" role="button" data-click="post_toast(this, '/buy_hat/{{hat.id}}?mb=true', 'if-not-owned-{{hat.id}}', 'if-owned-{{hat.id}}', 'd-none', (xhr)=>{if(xhr.status == 200)document.getElementById('user-bux-amount').innerHTML-={{hat.price}}})" onclick="areyousure(this)"><span class="m-auto">MBux</span></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
|
|
@ -59,8 +59,8 @@
|
|||
<form action="/live/remove" method="post">
|
||||
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
||||
<input type="hidden" name="id" value="{{id}}">
|
||||
<input autocomplete="off" class="btn btn-primary ml-auto donttrigger" onclick="this.nextElementSibling.classList.remove('d-none');this.classList.add('d-none')" value="Remove" style="width:75px">
|
||||
<input autocomplete="off" class="btn btn-primary ml-auto d-none donttrigger" type="submit" onclick="disable(this)" value="Are you sure?">
|
||||
|
||||
<input autocomplete="off" class="btn btn-primary ml-auto donttrigger" data-click="disable(this)" onclick="areyousure(this)" value="Remove">
|
||||
</form>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
@ -85,8 +85,7 @@
|
|||
<form action="/live/remove" method="post">
|
||||
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
||||
<input type="hidden" name="id" value="{{id}}">
|
||||
<input autocomplete="off" class="btn btn-primary ml-auto donttrigger" onclick="this.nextElementSibling.classList.remove('d-none');this.classList.add('d-none')" value="Remove" style="width:75px">
|
||||
<input autocomplete="off" class="btn btn-primary ml-auto d-none donttrigger" type="submit" onclick="disable(this)" value="Are you sure?">
|
||||
<input autocomplete="off" class="btn btn-primary ml-auto donttrigger" data-click="disable(this)" onclick="areyousure(this)" value="Remove">
|
||||
</form>
|
||||
</td>
|
||||
{% endif %}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<a class="list-inline-item copy-link" role="button" data-clipboard-text="{% if SITE == 'rdrama.net' %}https://rdrama.org{{p.shortlink}}{% else %}{{p.permalink}}{% endif %}"><i class="fas fa-copy"></i>Copy link</a>
|
||||
|
||||
{% if v %}
|
||||
<a id="subscribe-{{p.id}}" class="{% if p.id in v.subscribed_idlist %}d-none{% endif %} list-inline-item" role="button" onclick="post_toast(this,'/subscribe/{{p.id}}','subscribe-{{p.id}}','unsubscribe-{{p.id}}','d-none')"><i class="fas fa-eye"></i>Subscribe</a>
|
||||
<a id="subscribe-{{p.id}}" class="{% if p.id in v.subscribed_idlist %}d-none{% endif %} list-inline-item" role="button" data-click="post_toast(this,'/subscribe/{{p.id}}','subscribe-{{p.id}}','unsubscribe-{{p.id}}','d-none')" onclick="areyousure(this)"><i class="fas fa-eye"></i>Subscribe</a>
|
||||
<a id="unsubscribe-{{p.id}}" class="{% if p.id not in v.subscribed_idlist %}d-none{% endif %} list-inline-item" role="button" onclick="post_toast(this,'/unsubscribe/{{p.id}}','subscribe-{{p.id}}','unsubscribe-{{p.id}}','d-none')"><i class="fas fa-eye-slash"></i>Unsubscribe</a>
|
||||
{% endif %}
|
||||
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
<button class="nobackground btn btn-link btn-block btn-lg text-left text-muted" data-bs-toggle="modal" data-bs-dismiss="modal" data-bs-target="#awardModal" data-url='/award/post/{{p.id}}' onclick="document.getElementById('giveaward').dataset.action = this.dataset.url"><i class="fas fa-gift text-center text-muted mr-2"></i>Give Award</button>
|
||||
{%- endif %}
|
||||
|
||||
<button id="subscribe2-{{p.id}}" class="{% if p.id in v.subscribed_idlist %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-muted" role="button" onclick="post_toast(this,'/subscribe/{{p.id}}','subscribe2-{{p.id}}','unsubscribe2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-eye text-center text-muted mr-2"></i>Subscribe</button>
|
||||
<button id="subscribe2-{{p.id}}" class="{% if p.id in v.subscribed_idlist %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-muted" role="button" data-click="post_toast(this,'/subscribe/{{p.id}}','subscribe2-{{p.id}}','unsubscribe2-{{p.id}}','d-none')" onclick="areyousure(this)" data-dismiss="modal"><i class="fas fa-eye text-center text-muted mr-2"></i>Subscribe</button>
|
||||
|
||||
<button id="unsubscribe2-{{p.id}}" class="{% if not p.id in v.subscribed_idlist %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-muted" role="button" onclick="post_toast(this,'/unsubscribe/{{p.id}}','subscribe2-{{p.id}}','unsubscribe2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-eye-slash text-center text-muted mr-2"></i>Unsubscribe</button>
|
||||
|
||||
<button id="save2-{{p.id}}" class="{% if p.id in v.saved_idlist %}d-none{% endif %} nobackground btn btn-link btn-block btn-lg text-left text-muted" role="button" onclick="post_toast(this,'/save_post/{{p.id}}','save2-{{p.id}}','unsave2-{{p.id}}','d-none')" data-bs-dismiss="modal"><i class="fas fa-save text-center text-muted mr-2"></i>Save</button>
|
||||
|
@ -46,8 +47,7 @@
|
|||
{% else %}
|
||||
{% if not p.ghost %}
|
||||
<button id="unblock2-{{p.id}}" class="nobackground btn btn-link btn-block btn-lg text-success text-left{% if not p.is_blocking %} d-none{% endif %}" data-bs-dismiss="modal" onclick="post_toast(this,'/settings/unblock?username={{p.author.username}}','block2-{{p.id}}','unblock2-{{p.id}}','d-none')"><i class="fas fa-eye mr-2 text-success"></i>Unblock user</button>
|
||||
<button id="prompt2-{{p.id}}" class="blockuser nobackground btn btn-link btn-block btn-lg text-danger text-left d-none" data-bs-dismiss="modal" onclick="post_toast(this,'/settings/block?username={{p.author.username}}','prompt2-{{p.id}}','unblock2-{{p.id}}','d-none')"><i class="fas fa-eye-slash mr-2 text-danger"></i>Are you sure?</button>
|
||||
<button id="block2-{{p.id}}" class="blockuser nobackground btn btn-link btn-block btn-lg text-danger text-left{% if p.is_blocking %} d-none{% endif %}" onclick="document.getElementById('block2-{{p.id}}').classList.toggle('d-none');document.getElementById('prompt2-{{p.id}}').classList.toggle('d-none');"><i class="fas fa-eye-slash mr-2 text-danger"></i>Block user</button>
|
||||
<button id="block2-{{p.id}}" class="blockuser nobackground btn btn-link btn-block btn-lg text-danger text-left" data-click="post_toast(this,'/settings/block?username={{p.author.username}}','block2-{{p.id}}','unblock2-{{p.id}}','d-none')" onclick="areyousure(this)" data-dismiss="modal"><i class="fas fa-eye-slash mr-2 text-danger"></i>Block user</button>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
|
|
|
@ -102,13 +102,11 @@
|
|||
{% set kind = a['kind'] %}
|
||||
<td class="shop-table-actions">
|
||||
{% if kind != "benefactor" %}
|
||||
<a id="buy1-{{loop.index}}" class="btn btn-success {% if v.coins < a['price'] %}disabled{% endif %}" role="button" onclick="this.classList.add('d-none');document.getElementById('buy1-go-{{loop.index}}').classList.remove('d-none')"><span class="m-auto">Buy</span></a>
|
||||
<a id="buy1-go-{{loop.index}}" class="d-none btn btn-success {% if v.coins < a['price'] %}disabled{% endif %}" role="button" onclick="post_toast(this,'/buy/{{kind}}')"><span class="m-auto">Are you sure?</span></a>
|
||||
<a id="buy1-{{loop.index}}" class="btn btn-success {% if v.coins < a['price'] %}disabled{% endif %}" role="button" data-click="post_toast(this,'/buy/{{kind}}')" onclick="areyousure(this)"><span class="m-auto">Buy</span></a>
|
||||
{% endif %}
|
||||
{% if FEATURES['PROCOINS'] %}
|
||||
{% if kind != "grass" %}
|
||||
<a id="buy2-{{loop.index}}" class="marseybux btn btn-success {% if v.procoins < a['price'] %}disabled{% endif %}" role="button" onclick="this.classList.add('d-none');document.getElementById('buy2-go-{{loop.index}}').classList.remove('d-none')"><span class="m-auto">Buy with MBux</span></a>
|
||||
<a id="buy2-go-{{loop.index}}" class="d-none marseybux btn btn-success {% if v.procoins < a['price'] %}disabled{% endif %}" role="button" onclick="post_toast(this,'/buy/{{kind}}?mb=true')"><span class="m-auto">Are you sure?</span></a>
|
||||
<a id="buy2-{{loop.index}}" class="marseybux btn btn-success {% if v.procoins < a['price'] %}disabled{% endif %}" role="button" data-click="post_toast(this,'/buy/{{kind}}?mb=true')" onclick="areyousure(this)"><span class="m-auto">Buy with MBux</span></a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
|
|
|
@ -227,7 +227,7 @@
|
|||
<a id="unadmin" class="{% if u.admin_level < 1 %}d-none{% endif %} btn btn-primary" href="javascript:void(0)" onclick="post_toast(this,'/@{{u.username}}/remove_admin','admin','unadmin','d-none')">Remove admin</a>
|
||||
{% endif %}
|
||||
{% if v.admin_level >= PERMS['ADMIN_ACTIONS_REVERT'] %}
|
||||
<a class="btn btn-primary" role="button" onclick="post_toast(this,'/@{{u.username}}/revert_actions')">Revert admin actions</a>
|
||||
<a class="btn btn-primary" role="button" data-click="post_toast(this,'/@{{u.username}}/revert_actions')" onclick="areyousure(this)">Revert admin actions</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
@ -498,7 +498,7 @@
|
|||
{% endif %}
|
||||
|
||||
{% if v.admin_level >= PERMS['ADMIN_ACTIONS_REVERT'] %}
|
||||
<a class="btn btn-primary" role="button" onclick="post_toast(this,'/@{{u.username}}/revert_actions')">Revert admin actions</a>
|
||||
<a class="btn btn-primary" role="button" data-click="post_toast(this,'/@{{u.username}}/revert_actions')" onclick="areyousure(this)">Revert admin actions</a>
|
||||
{% endif %}
|
||||
|
||||
<form class="d-none toggleable" id='message-mobile' action="/@{{u.username}}/message" onsubmit="submitFormAjax(event)">
|
||||
|
|
Loading…
Reference in New Issue