sneed
This commit is contained in:
parent
c1c140cd59
commit
684e2ee923
2 changed files with 194 additions and 195 deletions
|
@ -937,41 +937,6 @@ $(document).ready(function(){
|
|||
$('[data-toggle="tooltip"]').tooltip();
|
||||
});
|
||||
|
||||
block_user=function() {
|
||||
|
||||
var exileForm = document.getElementById("exile-form");
|
||||
|
||||
var exileError = document.getElementById("toast-error-message");
|
||||
|
||||
var usernameField = document.getElementById("exile-username");
|
||||
|
||||
var isValidUsername = usernameField.checkValidity();
|
||||
|
||||
username = usernameField.value;
|
||||
|
||||
if (isValidUsername) {
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("post", "/settings/block");
|
||||
xhr.withCredentials=true;
|
||||
f=new FormData();
|
||||
f.append("username", username);
|
||||
f.append("formkey", formkey());
|
||||
xhr.onload=function(){
|
||||
if (xhr.status<300) {
|
||||
window.location.reload(true);
|
||||
}
|
||||
else {
|
||||
$('#toast-exile-error').toast('dispose');
|
||||
$('#toast-exile-error').toast('show');
|
||||
exileError.textContent = JSON.parse(xhr.response)["error"];
|
||||
}
|
||||
}
|
||||
xhr.send(f)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
post_comment=function(fullname){
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,40 @@
|
|||
<html lang="en">
|
||||
<head>
|
||||
<script>
|
||||
block_user=function() {
|
||||
|
||||
var exileForm = document.getElementById("exile-form");
|
||||
|
||||
var exileError = document.getElementById("toast-error-message");
|
||||
|
||||
var usernameField = document.getElementById("exile-username");
|
||||
|
||||
var isValidUsername = usernameField.checkValidity();
|
||||
|
||||
username = usernameField.value;
|
||||
|
||||
if (isValidUsername) {
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("post", "/settings/block");
|
||||
xhr.withCredentials=true;
|
||||
f=new FormData();
|
||||
f.append("username", username);
|
||||
f.append("formkey", formkey());
|
||||
xhr.onload=function(){
|
||||
if (xhr.status<300) {
|
||||
window.location.reload(true);
|
||||
}
|
||||
else {
|
||||
$('#toast-exile-error').toast('dispose');
|
||||
$('#toast-exile-error').toast('show');
|
||||
exileError.textContent = JSON.parse(xhr.response)["error"];
|
||||
}
|
||||
}
|
||||
xhr.send(f)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//mobile prompt
|
||||
if (("standalone" in window.navigator) && // Check if "standalone" property exists
|
||||
|
@ -32,177 +66,177 @@
|
|||
|
||||
// Voting
|
||||
|
||||
var upvote = function(event) {
|
||||
var upvote = function(event) {
|
||||
|
||||
var type = event.target.dataset.contentType;
|
||||
var id = event.target.dataset.idUp;
|
||||
var type = event.target.dataset.contentType;
|
||||
var id = event.target.dataset.idUp;
|
||||
|
||||
var downvoteButton = document.getElementsByClassName(type + '-' + id + '-down');
|
||||
var upvoteButton = document.getElementsByClassName(type + '-' + id + '-up');
|
||||
var scoreText = document.getElementsByClassName(type + '-score-' + id);
|
||||
var downvoteButton = document.getElementsByClassName(type + '-' + id + '-down');
|
||||
var upvoteButton = document.getElementsByClassName(type + '-' + id + '-up');
|
||||
var scoreText = document.getElementsByClassName(type + '-score-' + id);
|
||||
|
||||
for (var j = 0; j < upvoteButton.length && j < downvoteButton.length && j < scoreText.length; j++) {
|
||||
for (var j = 0; j < upvoteButton.length && j < downvoteButton.length && j < scoreText.length; j++) {
|
||||
|
||||
var thisUpvoteButton = upvoteButton[j];
|
||||
var thisDownvoteButton = downvoteButton[j];
|
||||
var thisScoreText = scoreText[j];
|
||||
var thisScore = Number(thisScoreText.textContent);
|
||||
var thisUpvoteButton = upvoteButton[j];
|
||||
var thisDownvoteButton = downvoteButton[j];
|
||||
var thisScoreText = scoreText[j];
|
||||
var thisScore = Number(thisScoreText.textContent);
|
||||
|
||||
if (thisUpvoteButton.classList.contains('active')) {
|
||||
thisUpvoteButton.classList.remove('active')
|
||||
thisScoreText.textContent = thisScore - 1
|
||||
voteDirection = "0"
|
||||
} else if (thisDownvoteButton.classList.contains('active')) {
|
||||
thisUpvoteButton.classList.add('active')
|
||||
thisDownvoteButton.classList.remove('active')
|
||||
thisScoreText.textContent = thisScore + 2
|
||||
voteDirection = "1"
|
||||
} else {
|
||||
thisUpvoteButton.classList.add('active')
|
||||
thisScoreText.textContent = thisScore + 1
|
||||
voteDirection = "1"
|
||||
}
|
||||
|
||||
if (thisUpvoteButton.classList.contains('active')) {
|
||||
thisScoreText.classList.add('score-up')
|
||||
thisScoreText.classList.remove('score-down')
|
||||
thisScoreText.classList.remove('score')
|
||||
} else if (thisDownvoteButton.classList.contains('active')) {
|
||||
thisScoreText.classList.add('score-down')
|
||||
thisScoreText.classList.remove('score-up')
|
||||
thisScoreText.classList.remove('score')
|
||||
} else {
|
||||
thisScoreText.classList.add('score')
|
||||
thisScoreText.classList.remove('score-up')
|
||||
thisScoreText.classList.remove('score-down')
|
||||
}
|
||||
}
|
||||
|
||||
post_toast("/api/vote/" + type + "/" + id + "/" + voteDirection);
|
||||
|
||||
}
|
||||
|
||||
var downvote = function(event) {
|
||||
|
||||
var type = event.target.dataset.contentType;
|
||||
var id = event.target.dataset.idDown;
|
||||
|
||||
var downvoteButton = document.getElementsByClassName(type + '-' + id + '-down');
|
||||
var upvoteButton = document.getElementsByClassName(type + '-' + id + '-up');
|
||||
var scoreText = document.getElementsByClassName(type + '-score-' + id);
|
||||
|
||||
for (var j = 0; j < upvoteButton.length && j < downvoteButton.length && j < scoreText.length; j++) {
|
||||
|
||||
var thisUpvoteButton = upvoteButton[j];
|
||||
var thisDownvoteButton = downvoteButton[j];
|
||||
var thisScoreText = scoreText[j];
|
||||
var thisScore = Number(thisScoreText.textContent);
|
||||
|
||||
if (thisDownvoteButton.classList.contains('active')) {
|
||||
thisDownvoteButton.classList.remove('active')
|
||||
thisScoreText.textContent = thisScore + 1
|
||||
voteDirection = "0"
|
||||
} else if (thisUpvoteButton.classList.contains('active')) {
|
||||
thisDownvoteButton.classList.add('active')
|
||||
thisUpvoteButton.classList.remove('active')
|
||||
thisScoreText.textContent = thisScore - 2
|
||||
voteDirection = "-1"
|
||||
} else {
|
||||
thisDownvoteButton.classList.add('active')
|
||||
thisScoreText.textContent = thisScore - 1
|
||||
voteDirection = "-1"
|
||||
}
|
||||
|
||||
if (thisUpvoteButton.classList.contains('active')) {
|
||||
thisScoreText.classList.add('score-up')
|
||||
thisScoreText.classList.remove('score-down')
|
||||
thisScoreText.classList.remove('score')
|
||||
} else if (thisDownvoteButton.classList.contains('active')) {
|
||||
thisScoreText.classList.add('score-down')
|
||||
thisScoreText.classList.remove('score-up')
|
||||
thisScoreText.classList.remove('score')
|
||||
} else {
|
||||
thisScoreText.classList.add('score')
|
||||
thisScoreText.classList.remove('score-up')
|
||||
thisScoreText.classList.remove('score-down')
|
||||
}
|
||||
}
|
||||
|
||||
post_toast("/api/vote/" + type + "/" + id + "/" + voteDirection);
|
||||
|
||||
}
|
||||
|
||||
|
||||
var register_votes = function() {
|
||||
var upvoteButtons = document.getElementsByClassName('upvote-button')
|
||||
|
||||
var downvoteButtons = document.getElementsByClassName('downvote-button')
|
||||
|
||||
var voteDirection = 0
|
||||
|
||||
for (var i = 0; i < upvoteButtons.length; i++) {
|
||||
upvoteButtons[i].addEventListener('click', upvote, false);
|
||||
upvoteButtons[i].addEventListener('keydown', function(event) {
|
||||
if (event.keyCode === 13) {
|
||||
upvote(event)
|
||||
if (thisUpvoteButton.classList.contains('active')) {
|
||||
thisUpvoteButton.classList.remove('active')
|
||||
thisScoreText.textContent = thisScore - 1
|
||||
voteDirection = "0"
|
||||
} else if (thisDownvoteButton.classList.contains('active')) {
|
||||
thisUpvoteButton.classList.add('active')
|
||||
thisDownvoteButton.classList.remove('active')
|
||||
thisScoreText.textContent = thisScore + 2
|
||||
voteDirection = "1"
|
||||
} else {
|
||||
thisUpvoteButton.classList.add('active')
|
||||
thisScoreText.textContent = thisScore + 1
|
||||
voteDirection = "1"
|
||||
}
|
||||
}, false)
|
||||
};
|
||||
|
||||
for (var i = 0; i < downvoteButtons.length; i++) {
|
||||
downvoteButtons[i].addEventListener('click', downvote, false);
|
||||
downvoteButtons[i].addEventListener('keydown', function(event) {
|
||||
if (event.keyCode === 13) {
|
||||
downvote(event)
|
||||
if (thisUpvoteButton.classList.contains('active')) {
|
||||
thisScoreText.classList.add('score-up')
|
||||
thisScoreText.classList.remove('score-down')
|
||||
thisScoreText.classList.remove('score')
|
||||
} else if (thisDownvoteButton.classList.contains('active')) {
|
||||
thisScoreText.classList.add('score-down')
|
||||
thisScoreText.classList.remove('score-up')
|
||||
thisScoreText.classList.remove('score')
|
||||
} else {
|
||||
thisScoreText.classList.add('score')
|
||||
thisScoreText.classList.remove('score-up')
|
||||
thisScoreText.classList.remove('score-down')
|
||||
}
|
||||
}, false)
|
||||
};
|
||||
}
|
||||
|
||||
register_votes()
|
||||
|
||||
function vote_comment(comment_id, direction) {
|
||||
url="/api/vote/comment/"+ comment_id +"/"+direction;
|
||||
|
||||
callback=function(){
|
||||
thing = document.getElementById("comment-"+ comment_id+"-actions");
|
||||
uparrow1=document.getElementById("comment-"+ comment_id +"-up");
|
||||
downarrow1=document.getElementById("comment-"+ comment_id +"-down");
|
||||
scoreup1=document.getElementById("comment-"+ comment_id +"-score-up");
|
||||
scorenone1=document.getElementById("comment-"+ comment_id +"-score-none");
|
||||
scoredown1=document.getElementById("comment-"+ comment_id +"-score-down");
|
||||
|
||||
if (direction=="1") {
|
||||
thing.classList.add("upvoted");
|
||||
thing.classList.remove("downvoted");
|
||||
uparrow1.onclick=function(){vote_comment(comment_id, 0)};
|
||||
downarrow1.onclick=function(){vote_comment(comment_id, -1)};
|
||||
scoreup1.classList.remove("d-none");
|
||||
scorenone1.classList.add("d-none");
|
||||
scoredown1.classList.add("d-none");
|
||||
}
|
||||
else if (direction=="-1"){
|
||||
thing.classList.remove("upvoted");
|
||||
thing.classList.add("downvoted");
|
||||
uparrow1.onclick=function(){vote_comment(comment_id, 1)};
|
||||
downarrow1.onclick=function(){vote_comment(comment_id, 0)};
|
||||
scoreup1.classList.add("d-none");
|
||||
scorenone1.classList.add("d-none");
|
||||
scoredown1.classList.remove("d-none");
|
||||
}
|
||||
else if (direction=="0"){
|
||||
thing.classList.remove("upvoted");
|
||||
thing.classList.remove("downvoted");
|
||||
uparrow1.onclick=function(){vote_comment(comment_id, 1)};
|
||||
downarrow1.onclick=function(){vote_comment(comment_id, -1)};
|
||||
scoreup1.classList.add("d-none");
|
||||
scorenone1.classList.remove("d-none");
|
||||
scoredown1.classList.add("d-none");
|
||||
}
|
||||
|
||||
post_toast("/api/vote/" + type + "/" + id + "/" + voteDirection);
|
||||
|
||||
}
|
||||
|
||||
post(url, callback, "Unable to vote at this time. Please try again later.");
|
||||
}
|
||||
var downvote = function(event) {
|
||||
|
||||
var type = event.target.dataset.contentType;
|
||||
var id = event.target.dataset.idDown;
|
||||
|
||||
var downvoteButton = document.getElementsByClassName(type + '-' + id + '-down');
|
||||
var upvoteButton = document.getElementsByClassName(type + '-' + id + '-up');
|
||||
var scoreText = document.getElementsByClassName(type + '-score-' + id);
|
||||
|
||||
for (var j = 0; j < upvoteButton.length && j < downvoteButton.length && j < scoreText.length; j++) {
|
||||
|
||||
var thisUpvoteButton = upvoteButton[j];
|
||||
var thisDownvoteButton = downvoteButton[j];
|
||||
var thisScoreText = scoreText[j];
|
||||
var thisScore = Number(thisScoreText.textContent);
|
||||
|
||||
if (thisDownvoteButton.classList.contains('active')) {
|
||||
thisDownvoteButton.classList.remove('active')
|
||||
thisScoreText.textContent = thisScore + 1
|
||||
voteDirection = "0"
|
||||
} else if (thisUpvoteButton.classList.contains('active')) {
|
||||
thisDownvoteButton.classList.add('active')
|
||||
thisUpvoteButton.classList.remove('active')
|
||||
thisScoreText.textContent = thisScore - 2
|
||||
voteDirection = "-1"
|
||||
} else {
|
||||
thisDownvoteButton.classList.add('active')
|
||||
thisScoreText.textContent = thisScore - 1
|
||||
voteDirection = "-1"
|
||||
}
|
||||
|
||||
if (thisUpvoteButton.classList.contains('active')) {
|
||||
thisScoreText.classList.add('score-up')
|
||||
thisScoreText.classList.remove('score-down')
|
||||
thisScoreText.classList.remove('score')
|
||||
} else if (thisDownvoteButton.classList.contains('active')) {
|
||||
thisScoreText.classList.add('score-down')
|
||||
thisScoreText.classList.remove('score-up')
|
||||
thisScoreText.classList.remove('score')
|
||||
} else {
|
||||
thisScoreText.classList.add('score')
|
||||
thisScoreText.classList.remove('score-up')
|
||||
thisScoreText.classList.remove('score-down')
|
||||
}
|
||||
}
|
||||
|
||||
post_toast("/api/vote/" + type + "/" + id + "/" + voteDirection);
|
||||
|
||||
}
|
||||
|
||||
|
||||
var register_votes = function() {
|
||||
var upvoteButtons = document.getElementsByClassName('upvote-button')
|
||||
|
||||
var downvoteButtons = document.getElementsByClassName('downvote-button')
|
||||
|
||||
var voteDirection = 0
|
||||
|
||||
for (var i = 0; i < upvoteButtons.length; i++) {
|
||||
upvoteButtons[i].addEventListener('click', upvote, false);
|
||||
upvoteButtons[i].addEventListener('keydown', function(event) {
|
||||
if (event.keyCode === 13) {
|
||||
upvote(event)
|
||||
}
|
||||
}, false)
|
||||
};
|
||||
|
||||
for (var i = 0; i < downvoteButtons.length; i++) {
|
||||
downvoteButtons[i].addEventListener('click', downvote, false);
|
||||
downvoteButtons[i].addEventListener('keydown', function(event) {
|
||||
if (event.keyCode === 13) {
|
||||
downvote(event)
|
||||
}
|
||||
}, false)
|
||||
};
|
||||
}
|
||||
|
||||
register_votes()
|
||||
|
||||
function vote_comment(comment_id, direction) {
|
||||
url="/api/vote/comment/"+ comment_id +"/"+direction;
|
||||
|
||||
callback=function(){
|
||||
thing = document.getElementById("comment-"+ comment_id+"-actions");
|
||||
uparrow1=document.getElementById("comment-"+ comment_id +"-up");
|
||||
downarrow1=document.getElementById("comment-"+ comment_id +"-down");
|
||||
scoreup1=document.getElementById("comment-"+ comment_id +"-score-up");
|
||||
scorenone1=document.getElementById("comment-"+ comment_id +"-score-none");
|
||||
scoredown1=document.getElementById("comment-"+ comment_id +"-score-down");
|
||||
|
||||
if (direction=="1") {
|
||||
thing.classList.add("upvoted");
|
||||
thing.classList.remove("downvoted");
|
||||
uparrow1.onclick=function(){vote_comment(comment_id, 0)};
|
||||
downarrow1.onclick=function(){vote_comment(comment_id, -1)};
|
||||
scoreup1.classList.remove("d-none");
|
||||
scorenone1.classList.add("d-none");
|
||||
scoredown1.classList.add("d-none");
|
||||
}
|
||||
else if (direction=="-1"){
|
||||
thing.classList.remove("upvoted");
|
||||
thing.classList.add("downvoted");
|
||||
uparrow1.onclick=function(){vote_comment(comment_id, 1)};
|
||||
downarrow1.onclick=function(){vote_comment(comment_id, 0)};
|
||||
scoreup1.classList.add("d-none");
|
||||
scorenone1.classList.add("d-none");
|
||||
scoredown1.classList.remove("d-none");
|
||||
}
|
||||
else if (direction=="0"){
|
||||
thing.classList.remove("upvoted");
|
||||
thing.classList.remove("downvoted");
|
||||
uparrow1.onclick=function(){vote_comment(comment_id, 1)};
|
||||
downarrow1.onclick=function(){vote_comment(comment_id, -1)};
|
||||
scoreup1.classList.add("d-none");
|
||||
scorenone1.classList.remove("d-none");
|
||||
scoredown1.classList.add("d-none");
|
||||
}
|
||||
}
|
||||
|
||||
post(url, callback, "Unable to vote at this time. Please try again later.");
|
||||
}
|
||||
</script>
|
||||
{% if v %}
|
||||
<script src="https://js.pusher.com/beams/1.0/push-notifications-cdn.js"></script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue