From 7ee7933773fdd6df461b3560afa44c0f4f35404b Mon Sep 17 00:00:00 2001
From: Aevann
Date: Fri, 30 Dec 2022 14:52:59 +0200
Subject: [PATCH] same as last commit
---
files/assets/js/admin/alts.js | 7 +++---
files/assets/js/bottom.js | 6 ++++-
files/assets/js/comments_admin.js | 4 +--
files/assets/js/comments_v.js | 2 +-
files/assets/js/core.js | 10 +++-----
files/assets/js/delete_post_modal.js | 2 +-
files/assets/js/lottery.js | 4 +--
files/assets/js/remove_mod.js | 6 ++---
files/assets/js/submission_admin.js | 4 +--
files/assets/js/userpage_v.js | 4 +--
files/templates/admin/alts.html | 10 +++-----
files/templates/settings/security.html | 32 +++++++++++-------------
files/templates/sub/mods.html | 2 +-
files/templates/userpage/admintools.html | 12 ++++-----
files/templates/userpage/banner.html | 4 +--
15 files changed, 53 insertions(+), 56 deletions(-)
diff --git a/files/assets/js/admin/alts.js b/files/assets/js/admin/alts.js
index e188327fd..7477d0753 100644
--- a/files/assets/js/admin/alts.js
+++ b/files/assets/js/admin/alts.js
@@ -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;
diff --git a/files/assets/js/bottom.js b/files/assets/js/bottom.js
index cccca24aa..3176429bd 100644
--- a/files/assets/js/bottom.js
+++ b/files/assets/js/bottom.js
@@ -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]');
diff --git a/files/assets/js/comments_admin.js b/files/assets/js/comments_admin.js
index ed249b9ce..3a6df7a4b 100644
--- a/files/assets/js/comments_admin.js
+++ b/files/assets/js/comments_admin.js
@@ -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()
diff --git a/files/assets/js/comments_v.js b/files/assets/js/comments_v.js
index fea41607a..a718494be 100644
--- a/files/assets/js/comments_v.js
+++ b/files/assets/js/comments_v.js
@@ -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()
diff --git a/files/assets/js/core.js b/files/assets/js/core.js
index 13d31a4b7..b376342b4 100644
--- a/files/assets/js/core.js
+++ b/files/assets/js/core.js
@@ -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');
diff --git a/files/assets/js/delete_post_modal.js b/files/assets/js/delete_post_modal.js
index 1bf02b2cc..6b5d1e215 100644
--- a/files/assets/js/delete_post_modal.js
+++ b/files/assets/js/delete_post_modal.js
@@ -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()
diff --git a/files/assets/js/lottery.js b/files/assets/js/lottery.js
index 3e4179ffa..7ffc7a1c8 100644
--- a/files/assets/js/lottery.js
+++ b/files/assets/js/lottery.js
@@ -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());
}
}
diff --git a/files/assets/js/remove_mod.js b/files/assets/js/remove_mod.js
index 12e8b8960..3c27be11a 100644
--- a/files/assets/js/remove_mod.js
+++ b/files/assets/js/remove_mod.js
@@ -1,7 +1,7 @@
-function removeMod(e) {
- sendFormXHR(e,
+function removeMod(form) {
+ sendFormXHR(form,
() => {
- e.target.parentElement.parentElement.remove();
+ form.parentElement.parentElement.remove();
}
)
}
diff --git a/files/assets/js/submission_admin.js b/files/assets/js/submission_admin.js
index b0817bd61..fe3c0f62b 100644
--- a/files/assets/js/submission_admin.js
+++ b/files/assets/js/submission_admin.js
@@ -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()
diff --git a/files/assets/js/userpage_v.js b/files/assets/js/userpage_v.js
index 532aeab0d..87f921b65 100644
--- a/files/assets/js/userpage_v.js
+++ b/files/assets/js/userpage_v.js
@@ -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 = ''
diff --git a/files/templates/admin/alts.html b/files/templates/admin/alts.html
index 6f0fe17c4..d568756a0 100644
--- a/files/templates/admin/alts.html
+++ b/files/templates/admin/alts.html
@@ -57,12 +57,10 @@
Adding linked will link the two alts together manually, while adding delinked will attempt to delink alts whereever possible.
You're on your own for reversing any propagation though.
-
+
+
+
+
{% endif %}
diff --git a/files/templates/settings/security.html b/files/templates/settings/security.html
index 55b0b1929..d7ec44b35 100644
--- a/files/templates/settings/security.html
+++ b/files/templates/settings/security.html
@@ -240,24 +240,22 @@
diff --git a/files/templates/sub/mods.html b/files/templates/sub/mods.html
index 7b5000034..4f194602d 100644
--- a/files/templates/sub/mods.html
+++ b/files/templates/sub/mods.html
@@ -21,7 +21,7 @@
|
{% if v.id == user.id or v.mod_date(sub.name) and v.mod_date(sub.name) < mod.created_utc %}
- |