some more js sanity checks
parent
9224045bd1
commit
2a0d8d43bc
|
@ -114,9 +114,7 @@ function poll_vote_1(oid, parentid, kind) {
|
|||
}
|
||||
|
||||
function bet_vote(t, oid) {
|
||||
postToast(t, `/vote/post/option/${oid}`,
|
||||
{
|
||||
},
|
||||
postToast(t, `/vote/post/option/${oid}`, null,
|
||||
() => {
|
||||
for(let el of document.getElementsByClassName('bet')) {
|
||||
el.disabled = true;
|
||||
|
|
|
@ -88,9 +88,7 @@ function toggleEdit(id){
|
|||
|
||||
function delete_commentModal(t, id) {
|
||||
document.getElementById("deleteCommentButton").onclick = function() {
|
||||
postToast(t, `/delete/comment/${id}`,
|
||||
{
|
||||
},
|
||||
postToast(t, `/delete/comment/${id}`, null,
|
||||
() => {
|
||||
if (window.location.pathname == '/admin/reported/comments')
|
||||
{
|
||||
|
|
|
@ -79,9 +79,7 @@ function postToast(t, url, data, extraActionsOnSuccess, method="POST") {
|
|||
}
|
||||
|
||||
function postToastReload(t, url, method="POST") {
|
||||
postToast(t, url,
|
||||
{
|
||||
},
|
||||
postToast(t, url, null,
|
||||
() => {
|
||||
location.reload()
|
||||
}
|
||||
|
@ -89,9 +87,7 @@ function postToastReload(t, url, method="POST") {
|
|||
}
|
||||
|
||||
function postToastSwitch(t, url, button1, button2, cls, extraActionsOnSuccess, method="POST") {
|
||||
postToast(t, url,
|
||||
{
|
||||
},
|
||||
postToast(t, url, null,
|
||||
(xhr) => {
|
||||
if (button1)
|
||||
{
|
||||
|
|
|
@ -28,8 +28,8 @@ function addSearchParam(e) {
|
|||
searchInput.focus();
|
||||
}
|
||||
|
||||
function block_user() {
|
||||
var usernameField = document.getElementById("exile-username");
|
||||
function blockUser() {
|
||||
var usernameField = document.getElementById("block-username");
|
||||
var isValidUsername = usernameField.checkValidity();
|
||||
username = usernameField.value;
|
||||
if (isValidUsername) {
|
||||
|
@ -50,3 +50,11 @@ function block_user() {
|
|||
xhr.send(f)
|
||||
}
|
||||
}
|
||||
|
||||
function unblockUser(t, url) {
|
||||
postToast(t, url, null,
|
||||
() => {
|
||||
t.parentElement.parentElement.remove();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
function delete_postModal(t, id) {
|
||||
document.getElementById("deletePostButton").onclick = function() {
|
||||
postToast(t, `/delete_post/${id}`,
|
||||
{
|
||||
},
|
||||
postToast(t, `/delete_post/${id}`, null,
|
||||
() => {
|
||||
if (window.location.pathname == '/admin/reported/posts')
|
||||
{
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
function pinPost(t, id) {
|
||||
postToast(t, `/sticky/${id}`,
|
||||
{
|
||||
},
|
||||
postToast(t, `/sticky/${id}`, null,
|
||||
(xhr) => {
|
||||
if(xhr.status == 201) {
|
||||
t.innerHTML = t.innerHTML.replace(t.textContent, 'Pin for 1 hour');
|
||||
|
@ -15,9 +13,7 @@ function pinPost(t, id) {
|
|||
}
|
||||
|
||||
function unpinPost(t, id) {
|
||||
postToast(t, `/unsticky/${id}`,
|
||||
{
|
||||
},
|
||||
postToast(t, `/unsticky/${id}`, null,
|
||||
() => {
|
||||
t.classList.add('d-none');
|
||||
const prev = t.previousElementSibling;
|
||||
|
|
|
@ -8,36 +8,3 @@ const twoStepModal = bootstrap.Modal.getOrCreateInstance(document.getElementById
|
|||
function emailVerifyText() {
|
||||
document.getElementById("email-verify-text").innerHTML = "Verification email sent! Please check your inbox.";
|
||||
}
|
||||
|
||||
function block_user() {
|
||||
const usernameField = document.getElementById("block-username");
|
||||
const isValidUsername = usernameField.checkValidity();
|
||||
username = usernameField.value;
|
||||
if (isValidUsername) {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open("post", "/settings/block");
|
||||
xhr.setRequestHeader('xhr', 'xhr');
|
||||
f=new FormData();
|
||||
f.append("username", username);
|
||||
f.append("formkey", formkey());
|
||||
xhr.onload=function(){
|
||||
if (xhr.status<300) {
|
||||
location.reload();
|
||||
}
|
||||
else {
|
||||
showToast(false, "Error, please try again later.");
|
||||
}
|
||||
}
|
||||
xhr.send(f)
|
||||
}
|
||||
}
|
||||
|
||||
function unblock_user(t, url) {
|
||||
postToast(t, url,
|
||||
{
|
||||
},
|
||||
() => {
|
||||
t.parentElement.parentElement.remove();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -177,7 +177,7 @@
|
|||
{% include "user_in_table.html" %}
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-primary" onclick="unblock_user(this, '/settings/unblock?username={{user.username}}&formkey={{v|formkey}}')">Unblock</button>
|
||||
<button type="button" class="btn btn-primary" onclick="unblockUser(this, '/settings/unblock?username={{user.username}}&formkey={{v|formkey}}')">Unblock</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
|
@ -270,7 +270,7 @@
|
|||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-link text-muted" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-primary" id="blockUserButton" onclick="block_user()">Block user</button>
|
||||
<button type="button" class="btn btn-primary" id="blockUserButton" onclick="blockUser()">Block user</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
Loading…
Reference in New Issue