same as last commit
parent
0325295b89
commit
7ee7933773
|
@ -1,5 +1,4 @@
|
|||
function submitAddAlt(element) {
|
||||
if (!element || !element.form) return;
|
||||
function submitAddAlt(element, username) {
|
||||
const isLinking = element.id == 'add-alt-form-link';
|
||||
const otherElement = isLinking ? document.getElementById('add-alt-form-delink') : document.getElementById('add-alt-form-link');
|
||||
if (!otherElement) return;
|
||||
|
@ -10,7 +9,7 @@ function submitAddAlt(element) {
|
|||
const form = new FormData();
|
||||
if (!isLinking) form.append('deleted', 'true');
|
||||
form.append('other_username', document.getElementById('link-input-other').value);
|
||||
const xhr = createXhrWithFormKey('/@{{u.username}}/alts/', 'POST', form);
|
||||
const xhr = createXhrWithFormKey(`/@${username}/alts/`, 'POST', form);
|
||||
xhr[0].onload = function() {
|
||||
let data;
|
||||
try {
|
||||
|
@ -21,7 +20,7 @@ function submitAddAlt(element) {
|
|||
}
|
||||
if (xhr[0].status >= 200 && xhr[0].status < 300) {
|
||||
showToast(true, getMessageFromJsonData(true, data));
|
||||
window.location.reload();
|
||||
location.reload();
|
||||
} else {
|
||||
showToast(false, getMessageFromJsonData(false, data));
|
||||
element.disabled = false;
|
||||
|
|
|
@ -11,6 +11,7 @@ function execute(element, attr) {
|
|||
window[name](...args);
|
||||
}
|
||||
catch (e) {
|
||||
console.log(e)
|
||||
console.log(name)
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +55,10 @@ for (const element of onchange) {
|
|||
|
||||
const onsubmit = document.querySelectorAll('[data-onsubmit]');
|
||||
for (const element of onsubmit) {
|
||||
element.onsubmit = ()=>{execute(element, 'onsubmit')};
|
||||
element.onsubmit = (event)=>{
|
||||
event.preventDefault();
|
||||
execute(element, 'onsubmit')
|
||||
};
|
||||
}
|
||||
|
||||
const onfocus = document.querySelectorAll('[data-onfocus]');
|
||||
|
|
|
@ -6,7 +6,7 @@ function removeComment(t,comment_id,button1,button2,cls) {
|
|||
button2,
|
||||
cls,
|
||||
() => {
|
||||
if (window.location.pathname == '/admin/reported/comments')
|
||||
if (location.pathname == '/admin/reported/comments')
|
||||
{
|
||||
document.getElementById("post-info-"+comment_id).remove()
|
||||
document.getElementById("comment-"+comment_id).remove()
|
||||
|
@ -31,7 +31,7 @@ function approveComment(t,comment_id,button1,button2,cls) {
|
|||
button2,
|
||||
cls,
|
||||
() => {
|
||||
if (window.location.pathname == '/admin/reported/comments')
|
||||
if (location.pathname == '/admin/reported/comments')
|
||||
{
|
||||
document.getElementById("post-info-"+comment_id).remove()
|
||||
document.getElementById("comment-"+comment_id).remove()
|
||||
|
|
|
@ -92,7 +92,7 @@ function delete_commentModal(t, id) {
|
|||
{
|
||||
},
|
||||
() => {
|
||||
if (window.location.pathname == '/admin/reported/comments')
|
||||
if (location.pathname == '/admin/reported/comments')
|
||||
{
|
||||
document.getElementById("post-info-"+id).remove()
|
||||
document.getElementById("comment-"+id).remove()
|
||||
|
|
|
@ -113,7 +113,7 @@ function postToastSwitch(t, url, button1, button2, cls, extraActionsOnSuccess, m
|
|||
, method);
|
||||
}
|
||||
|
||||
if (window.location.pathname != '/submit')
|
||||
if (location.pathname != '/submit')
|
||||
{
|
||||
document.addEventListener('keydown', (e) => {
|
||||
if(!((e.ctrlKey || e.metaKey) && e.key === "Enter")) return;
|
||||
|
@ -353,10 +353,8 @@ function prepare_to_pause(audio) {
|
|||
});
|
||||
}
|
||||
|
||||
function sendFormXHR(e, extraActionsOnSuccess) {
|
||||
const form = e.target;
|
||||
function sendFormXHR(form, extraActionsOnSuccess) {
|
||||
const xhr = new XMLHttpRequest();
|
||||
e.preventDefault();
|
||||
|
||||
formData = new FormData(form);
|
||||
|
||||
|
@ -388,8 +386,8 @@ function sendFormXHR(e, extraActionsOnSuccess) {
|
|||
xhr.send(formData);
|
||||
}
|
||||
|
||||
function sendFormXHRSwitch(e) {
|
||||
sendFormXHR(e,
|
||||
function sendFormXHRSwitch(form) {
|
||||
sendFormXHR(form,
|
||||
() => {
|
||||
e.target.previousElementSibling.classList.remove('d-none');
|
||||
e.target.classList.add('d-none');
|
||||
|
|
|
@ -4,7 +4,7 @@ function delete_postModal(t, id) {
|
|||
{
|
||||
},
|
||||
() => {
|
||||
if (window.location.pathname == '/admin/reported/posts')
|
||||
if (location.pathname == '/admin/reported/posts')
|
||||
{
|
||||
document.getElementById("flaggers-"+id).remove()
|
||||
document.getElementById("post-"+id).remove()
|
||||
|
|
|
@ -53,7 +53,7 @@ function startLotterySession() {
|
|||
|
||||
if (ensureIntent()) {
|
||||
return handleLotteryRequest("start", "POST", () =>
|
||||
window.location.reload()
|
||||
location.reload()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ function endLotterySession() {
|
|||
checkLotteryStats();
|
||||
|
||||
if (ensureIntent()) {
|
||||
return handleLotteryRequest("end", "POST", () => window.location.reload());
|
||||
return handleLotteryRequest("end", "POST", () => location.reload());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
function removeMod(e) {
|
||||
sendFormXHR(e,
|
||||
function removeMod(form) {
|
||||
sendFormXHR(form,
|
||||
() => {
|
||||
e.target.parentElement.parentElement.remove();
|
||||
form.parentElement.parentElement.remove();
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ function removePost(t,post_id,button1,button2,cls) {
|
|||
button2,
|
||||
cls,
|
||||
() => {
|
||||
if (window.location.pathname == '/admin/reported/posts')
|
||||
if (location.pathname == '/admin/reported/posts')
|
||||
{
|
||||
document.getElementById("flaggers-"+post_id).remove()
|
||||
document.getElementById("post-"+post_id).remove()
|
||||
|
@ -28,7 +28,7 @@ function approvePost(t,post_id,button1,button2,cls) {
|
|||
button2,
|
||||
cls,
|
||||
() => {
|
||||
if (window.location.pathname == '/admin/reported/posts')
|
||||
if (location.pathname == '/admin/reported/posts')
|
||||
{
|
||||
document.getElementById("flaggers-"+post_id).remove()
|
||||
document.getElementById("post-"+post_id).remove()
|
||||
|
|
|
@ -75,12 +75,12 @@ function transferBux(t, mobile=false) {
|
|||
setTimeout(_ => this.disabled = false, 2000);
|
||||
}
|
||||
|
||||
function sendMessage(e) {
|
||||
function sendMessage(form) {
|
||||
document.getElementById('message').classList.add('d-none');
|
||||
document.getElementById('message-mobile').classList.add('d-none');
|
||||
document.getElementById('message-preview').classList.add('d-none');
|
||||
document.getElementById('message-preview-mobile').classList.add('d-none');
|
||||
sendFormXHR(e,
|
||||
sendFormXHR(form,
|
||||
() => {
|
||||
document.getElementById('input-message').value = ''
|
||||
document.getElementById('input-message-mobile').value = ''
|
||||
|
|
|
@ -57,12 +57,10 @@
|
|||
Adding linked will link the two alts together manually, while adding delinked will attempt to delink alts whereever possible.<br>
|
||||
You're on your own for reversing any propagation though.
|
||||
</p>
|
||||
<form data-nonce="{{g.nonce}}" data-onsubmit="return false;">
|
||||
<label for="link-input-other">Other Username</label>
|
||||
<input autocomplete="off" id="link-input-other" type="text" class="form-control mb-2" name="other_username" placeholder="Other Username">
|
||||
<button id="add-alt-form-link" class="btn btn-danger mr-3" data-areyousure="submitAddAlt(this)" data-nonce="{{g.nonce}}" data-onclick="areyousure(this)">Add Alt Linked</button>
|
||||
<button id="add-alt-form-delink" class="btn btn-danger" data-areyousure="submitAddAlt(this)" data-nonce="{{g.nonce}}" data-onclick="areyousure(this)">Add Alt Delinked</button>
|
||||
</form>
|
||||
<button id="add-alt-form-link" class="btn btn-danger mr-3" data-areyousure="submitAddAlt(this, '{{u.username}}')" data-nonce="{{g.nonce}}" data-onclick="areyousure(this)">Add Alt Linked</button>
|
||||
<button id="add-alt-form-delink" class="btn btn-danger" data-areyousure="submitAddAlt(this, '{{u.username}}')" data-nonce="{{g.nonce}}" data-onclick="areyousure(this)">Add Alt Delinked</button>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
|
|
|
@ -240,7 +240,6 @@
|
|||
|
||||
<div class="modal fade" id="blockmodal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<form class="m-auto" action="/settings/block" id="block-form" method="post" data-nonce="{{g.nonce}}" data-onsubmit="return false;">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Block user</h5>
|
||||
|
@ -257,7 +256,6 @@
|
|||
<button type="button" class="btn btn-primary" id="blockUserButton" data-nonce="{{g.nonce}}" data-onclick="block_user()">Block user</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<td data-time="{{mod.created_utc}}"></td>
|
||||
<td>
|
||||
{% if v.id == user.id or v.mod_date(sub.name) and v.mod_date(sub.name) < mod.created_utc %}
|
||||
<form action="/h/{{sub}}/remove_mod" method="post" data-nonce="{{g.nonce}}" data-onsubmit="removeMod(event)">
|
||||
<form action="/h/{{sub}}/remove_mod" method="post" data-nonce="{{g.nonce}}" data-onsubmit="removeMod(this)">
|
||||
<input type="hidden" name="formkey" value="{{v|formkey}}">
|
||||
<input type="hidden" name="uid" value="{{user.id}}">
|
||||
<input autocomplete="off" class="btn btn-primary ml-auto" type="submit" data-nonce="{{g.nonce}}" data-onclick="disable(this)" value="{% if v.id == user.id %}Resign{% else %}Remove Mod{% endif %}">
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
{% if v.admin_level >= PERMS['USER_TITLE_CHANGE'] %}
|
||||
<div class="body d-lg-flex border-bottom mb-2">
|
||||
<div class="w-lg-100">
|
||||
<form action="/admin/title_change/{{u.id}}" method="post" data-nonce="{{g.nonce}}" data-onsubmit="sendFormXHR(event)">
|
||||
<form action="/admin/title_change/{{u.id}}" method="post" data-nonce="{{g.nonce}}" data-onsubmit="sendFormXHR(this)">
|
||||
<input type="hidden" name="formkey" value="{{v|formkey}}">
|
||||
<input maxlength=100 autocomplete="off" id="customtitlebody-{{deviceType}}" type="text" name="title" class="form-control" placeholder='Enter a flair here' value="{% if u.customtitleplain %}{{u.customtitleplain}}{% endif %}">
|
||||
<div class="d-flex mt-2">
|
||||
|
@ -44,7 +44,7 @@
|
|||
{% if v.admin_level >= PERMS['USER_BAN'] %}
|
||||
<button type="button" id="unban-{{deviceType}}" class="mt-1 {% if not u.is_suspended %}d-none{% endif %} btn btn-success" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unban_user/{{u.id}}','ban-{{deviceType}}','unban-{{deviceType}}','d-none')">Unban user</button>
|
||||
|
||||
<form id="ban-{{deviceType}}" class="my-3 {% if u.is_suspended %}d-none{% endif %}" action="/ban_user/{{u.id}}" method="post" data-nonce="{{g.nonce}}" data-onsubmit="sendFormXHRSwitch(event)">
|
||||
<form id="ban-{{deviceType}}" class="my-3 {% if u.is_suspended %}d-none{% endif %}" action="/ban_user/{{u.id}}" method="post" data-nonce="{{g.nonce}}" data-onsubmit="sendFormXHRSwitch(this)">
|
||||
<input type="hidden" name="formkey" value="{{v|formkey}}">
|
||||
<input autocomplete="off" style="font-size:11px" type="text" class="form-control" maxlength="256" name="reason" placeholder="Ban Reason" data-nonce="{{g.nonce}}" data-undisablelement="user-ban-submit-{{deviceType}}" required>
|
||||
<input autocomplete="off" style="font-size:11px" type="number" step="any" class="form-control" name="days" placeholder="Days (blank = permanent)">
|
||||
|
@ -58,7 +58,7 @@
|
|||
{% if v.admin_level >= PERMS['USER_SHADOWBAN'] %}
|
||||
<button type="button" id="unshadowban-{{deviceType}}" class="mt-1 {% if not u.shadowbanned %}d-none{% endif %} btn btn-success" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unshadowban/{{u.id}}','shadowban-{{deviceType}}','unshadowban-{{deviceType}}','d-none')">Unshadowban user</button>
|
||||
|
||||
<form id="shadowban-{{deviceType}}" class="my-3 {% if u.shadowbanned %}d-none{% endif %}" action="/shadowban/{{u.id}}" method="post" data-nonce="{{g.nonce}}" data-onsubmit="sendFormXHRSwitch(event)">
|
||||
<form id="shadowban-{{deviceType}}" class="my-3 {% if u.shadowbanned %}d-none{% endif %}" action="/shadowban/{{u.id}}" method="post" data-nonce="{{g.nonce}}" data-onsubmit="sendFormXHRSwitch(this)">
|
||||
<input type="hidden" name="formkey" value="{{v|formkey}}">
|
||||
<input autocomplete="off" style="font-size:11px" type="text" class="form-control" maxlength="256" name="reason" placeholder="Shadowban Reason" data-nonce="{{g.nonce}}" data-undisablelement="user-shadowban-submit-{{deviceType}}" required>
|
||||
<input autocomplete="off" id="user-shadowban-submit-{{deviceType}}" type="submit" data-nonce="{{g.nonce}}" data-onclick="disable(this)" class="btn btn-danger" value="Shadowban user" disabled>
|
||||
|
@ -67,7 +67,7 @@
|
|||
{% if v.admin_level >= PERMS['USER_AGENDAPOSTER'] %}
|
||||
<button type="button" id="unagendaposter-{{deviceType}}" class="mt-1 {% if not u.agendaposter %}d-none{% endif %} btn btn-success" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unagendaposter/{{u.id}}','agendaposter-{{deviceType}}','unagendaposter-{{deviceType}}','d-none')">Unchud</button>
|
||||
|
||||
<form id="agendaposter-{{deviceType}}" class="my-3 {% if u.agendaposter %}d-none{% endif %}" action="/agendaposter/{{u.id}}" method="post" data-nonce="{{g.nonce}}" data-onsubmit="sendFormXHRSwitch(event)">
|
||||
<form id="agendaposter-{{deviceType}}" class="my-3 {% if u.agendaposter %}d-none{% endif %}" action="/agendaposter/{{u.id}}" method="post" data-nonce="{{g.nonce}}" data-onsubmit="sendFormXHRSwitch(this)">
|
||||
<input type="hidden" name="formkey" value="{{v|formkey}}">
|
||||
<input autocomplete="off" type="number" step="any" name="days" class="form-control" placeholder="Days (0 or blank = permanent)">
|
||||
<input type="submit" data-nonce="{{g.nonce}}" data-onclick="disable(this)" class="btn btn-danger" value="Chud">
|
||||
|
@ -90,12 +90,12 @@
|
|||
<button type="button" id="unmute-user-{{deviceType}}" class="mb-1 {% if not u.is_muted %}d-none{% endif %} btn btn-success" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/unmute_user/{{u.id}}','mute-user-{{deviceType}}','unmute-user-{{deviceType}}','d-none')">Unmute</button>
|
||||
{% endif %}
|
||||
{% if v and v.admin_level >= PERMS['POST_COMMENT_MODERATION'] %}
|
||||
<form action="/admin/unnuke_user" method="post" data-nonce="{{g.nonce}}" data-onsubmit="sendFormXHR(event)">
|
||||
<form action="/admin/unnuke_user" method="post" data-nonce="{{g.nonce}}" data-onsubmit="sendFormXHR(this)">
|
||||
<input type="hidden" name="formkey", value="{{v|formkey}}">
|
||||
<input type="hidden" name="user" value="{{u.username}}">
|
||||
<input type="submit" data-nonce="{{g.nonce}}" data-onclick="disable(this)" class="btn btn-success" value="Approve User's Content">
|
||||
</form>
|
||||
<form class="mt-1" action="/admin/nuke_user" method="post" data-nonce="{{g.nonce}}" data-onsubmit="sendFormXHR(event)">
|
||||
<form class="mt-1" action="/admin/nuke_user" method="post" data-nonce="{{g.nonce}}" data-onsubmit="sendFormXHR(this)">
|
||||
<input type="hidden" name="formkey", value="{{v|formkey}}">
|
||||
<input type="hidden" name="user" value="{{u.username}}">
|
||||
<input type="submit" data-nonce="{{g.nonce}}" data-onclick="disable(this)" class="btn btn-danger" value="Remove User's Content">
|
||||
|
|
|
@ -151,7 +151,7 @@
|
|||
<button type="button" class="btn btn-primary" data-nonce="{{g.nonce}}" data-onclick="postToastReload(this,'/settings/block?username={{u.username}}')">Block</button>
|
||||
</div>
|
||||
</div>
|
||||
<form class="d-none toggleable" id="message" action="/@{{u.username}}/message" data-nonce="{{g.nonce}}" data-onsubmit="sendMessage(event)">
|
||||
<form class="d-none toggleable" id="message" action="/@{{u.username}}/message" data-nonce="{{g.nonce}}" data-onsubmit="sendMessage(this)">
|
||||
<input type="hidden" name="formkey" value="{{v|formkey}}">
|
||||
<textarea autocomplete="off" id="input-message" form="message" name="message" rows="3" minlength="1" maxlength="10000" class="form-control b2 mt-1" data-preview="message-preview" data-nonce="{{g.nonce}}" data-oninput="markdown(this)" required></textarea>
|
||||
<button type="button" class="btn btn-secondary format d-inline-block m-0 fas fa-smile-beam" data-nonce="{{g.nonce}}" data-onclick="loadEmojis('input-message')" data-bs-toggle="modal" data-bs-target="#emojiModal" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Add Emoji"></button>
|
||||
|
@ -452,7 +452,7 @@
|
|||
</div>
|
||||
|
||||
{% if v and v.id != u.id %}
|
||||
<form class="d-none toggleable" id='message-mobile' action="/@{{u.username}}/message" data-nonce="{{g.nonce}}" data-onsubmit="sendMessage(event)">
|
||||
<form class="d-none toggleable" id='message-mobile' action="/@{{u.username}}/message" data-nonce="{{g.nonce}}" data-onsubmit="sendMessage(this)">
|
||||
<input class="mt-1" type="hidden" name="formkey" value="{{v|formkey}}">
|
||||
<textarea autocomplete="off" id="input-message-mobile" form="message-mobile" name="message" rows="3" minlength="1" maxlength="10000" class="form-control" data-preview="message-preview-mobile" data-nonce="{{g.nonce}}" data-oninput="markdown(this)" required></textarea>
|
||||
<button type="button" class="mt-1 btn btn-secondary format d-inline-block m-0 fas fa-smile-beam" data-nonce="{{g.nonce}}" data-onclick="loadEmojis('input-message-mobile')" data-bs-toggle="modal" data-bs-target="#emojiModal" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Add Emoji"></button>
|
||||
|
|
Loading…
Reference in New Issue