mirror of
https://git.freesoftwareextremist.com/bloat
synced 2024-10-29 19:40:35 +00:00
fluoride: Fix like/retweet for quote posts
This commit is contained in:
parent
e5bf3159b8
commit
90eb2628f2
2 changed files with 32 additions and 29 deletions
|
@ -47,13 +47,15 @@ function updateActionForm(id, f, action) {
|
|||
f.dataset.action = action;
|
||||
}
|
||||
|
||||
function handleLikeForm(id, f) {
|
||||
function handleLikeForm(f) {
|
||||
var id = f.dataset.id;
|
||||
f.onsubmit = function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
var action = f.dataset.action;
|
||||
var forms = document.
|
||||
querySelectorAll(".status-"+id+" .status-like");
|
||||
querySelectorAll(".status-action-container-"+id+" .status-like");
|
||||
|
||||
for (var i = 0; i < forms.length; i++) {
|
||||
updateActionForm(id, forms[i], reverseActions[action]);
|
||||
}
|
||||
|
@ -70,7 +72,7 @@ function handleLikeForm(id, f) {
|
|||
if (count === 0)
|
||||
count = "";
|
||||
var counts = document.
|
||||
querySelectorAll(".status-"+id+" .status-like-count");
|
||||
querySelectorAll(".status-action-container-"+id+" .status-like-count");
|
||||
for (var i = 0; i < counts.length; i++) {
|
||||
if (count > 0) {
|
||||
counts[i].innerHTML = "(" + count + ")";
|
||||
|
@ -88,13 +90,14 @@ function handleLikeForm(id, f) {
|
|||
}
|
||||
}
|
||||
|
||||
function handleRetweetForm(id, f) {
|
||||
function handleRetweetForm(f) {
|
||||
var id = f.dataset.id;
|
||||
f.onsubmit = function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
var action = f.dataset.action;
|
||||
var forms = document.
|
||||
querySelectorAll(".status-"+id+" .status-retweet");
|
||||
querySelectorAll(".status-action-container-"+id+" .status-retweet");
|
||||
for (var i = 0; i < forms.length; i++) {
|
||||
updateActionForm(id, forms[i], reverseActions[action]);
|
||||
}
|
||||
|
@ -111,7 +114,7 @@ function handleRetweetForm(id, f) {
|
|||
if (count === 0)
|
||||
count = "";
|
||||
var counts = document.
|
||||
querySelectorAll(".status-"+id+" .status-retweet-count");
|
||||
querySelectorAll(".status-action-container-"+id+" .status-retweet-count");
|
||||
for (var i = 0; i < counts.length; i++) {
|
||||
if (count > 0) {
|
||||
counts[i].innerHTML = "(" + count + ")";
|
||||
|
@ -298,29 +301,29 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||
checkCSRFToken();
|
||||
checkAntiDopamineMode();
|
||||
|
||||
var statuses = document.querySelectorAll(".status-container");
|
||||
for (var i = 0; i < statuses.length; i++) {
|
||||
var s = statuses[i];
|
||||
var id = s.dataset.id;
|
||||
var likeForms = document.querySelectorAll(".status-like");
|
||||
for (var j = 0; j < likeForms.length; j++) {
|
||||
handleLikeForm(likeForms[j]);
|
||||
}
|
||||
|
||||
var likeForm = s.querySelector(".status-like");
|
||||
handleLikeForm(id, likeForm);
|
||||
var retweetForms = document.querySelectorAll(".status-retweet");
|
||||
for (var j = 0; j < retweetForms.length; j++) {
|
||||
handleRetweetForm(retweetForms[j]);
|
||||
}
|
||||
|
||||
var retweetForm = s.querySelector(".status-retweet");
|
||||
handleRetweetForm(id, retweetForm);
|
||||
var replyToLinks = document.querySelectorAll(".status-reply-to-link");
|
||||
for (var j = 0; j < replyToLinks.length; j++) {
|
||||
handleReplyToLink(replyToLinks[j]);
|
||||
}
|
||||
|
||||
var replyToLink = s.querySelector(".status-reply-to-link");
|
||||
handleReplyToLink(replyToLink);
|
||||
var replyLinks = document.querySelectorAll(".status-reply-link");
|
||||
for (var j = 0; j < replyLinks.length; j++) {
|
||||
handleReplyLink(replyLinks[j]);
|
||||
}
|
||||
|
||||
var replyLinks = s.querySelectorAll(".status-reply-link");
|
||||
for (var j = 0; j < replyLinks.length; j++) {
|
||||
handleReplyLink(replyLinks[j]);
|
||||
}
|
||||
|
||||
var links = s.querySelectorAll(".status-content a");
|
||||
for (var j = 0; j < links.length; j++) {
|
||||
handleStatusLink(links[j]);
|
||||
}
|
||||
var links = document.querySelectorAll(".status-content a");
|
||||
for (var j = 0; j < links.length; j++) {
|
||||
handleStatusLink(links[j]);
|
||||
}
|
||||
|
||||
var links = document.querySelectorAll(".user-profile-description a, .user-fields a");
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
{{else}}
|
||||
{{block "status" (WithContext . $.Ctx)}}
|
||||
{{with $s := .Data}}
|
||||
<div class="status-container status-{{.ID}}" data-id="{{.ID}}">
|
||||
<div class="status-container" data-id="{{.ID}}">
|
||||
<div class="status-profile-img-container">
|
||||
<a class="img-link" href="/user/{{.Account.ID}}">
|
||||
<img class="status-profile-img" src="{{.Account.Avatar}}" title="@{{.Account.Acct}}" alt="@{{.Account.Acct}}" height="48">
|
||||
|
@ -184,7 +184,7 @@
|
|||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
<div class="status-action-container">
|
||||
<div class="status-action-container status-action-container-{{.ID}}">
|
||||
<div class="status-action">
|
||||
<a href="/thread/{{.ID}}?reply=true#status-{{.ID}}">reply</a>
|
||||
<a class="status-reply-count {{if or $.Ctx.AntiDopamineMode (not .RepliesCount)}}hidden{{end}}"
|
||||
|
@ -196,7 +196,7 @@
|
|||
</div>
|
||||
<div class="status-action">
|
||||
{{$rt := "retweet"}} {{if .Reblogged}} {{$rt = "unretweet"}} {{end}}
|
||||
<form class="status-retweet" data-action="{{$rt}}" action="/{{$rt}}/{{.ID}}" method="post" target="_self">
|
||||
<form class="status-retweet" data-action="{{$rt}}" action="/{{$rt}}/{{.ID}}" method="post" target="_self" data-id="{{.ID}}">
|
||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||
<input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}">
|
||||
|
@ -212,7 +212,7 @@
|
|||
</div>
|
||||
<div class="status-action">
|
||||
{{$like := "like"}} {{if .Favourited}} {{$like = "unlike"}} {{end}}
|
||||
<form class="status-like" data-action="{{$like}}" action="/{{$like}}/{{.ID}}" method="post" target="_self">
|
||||
<form class="status-like" data-action="{{$like}}" action="/{{$like}}/{{.ID}}" method="post" target="_self" data-id="{{.ID}}">
|
||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
|
||||
<input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}">
|
||||
|
|
Loading…
Reference in a new issue