simplify 3 js functions

remotes/1693176582716663532/tmp_refs/heads/watchparty
Aevann1 2022-10-10 06:56:39 +02:00
parent 472aedb14e
commit db929c7615
5 changed files with 12 additions and 12 deletions

View File

@ -1,5 +1,5 @@
function removeFollower(event, username) {
post_toast(event.target,'/remove_follow/' + username);
function removeFollower(t, username) {
post_toast(t,'/remove_follow/' + username);
let table = document.getElementById("followers-table");
table.removeChild(event.target.parentElement.parentElement);
}
table.removeChild(t.parentElement.parentElement);
}

View File

@ -1,5 +1,5 @@
function removeFollowing(event, username) {
post_toast(event.target,'/unfollow/' + username);
function removeFollowing(t, username) {
post_toast(t,'/unfollow/' + username);
let table = document.getElementById("followers-table");
table.removeChild(event.target.parentElement.parentElement);
}
table.removeChild(t.parentElement.parentElement);
}

View File

@ -24,7 +24,7 @@
<td>{% include "user_in_table.html" %}</td>
<td {% if follow.created_utc > 1599343262 %}data-time="{{follow.created_utc}}"{% endif %}></td>
{% if v.id == u.id %}
<td><div class="btn btn-danger pr-2" onclick="removeFollower(event, '{{user.username}}')">Remove follow</div></td>
<td><div class="btn btn-danger pr-2" onclick="removeFollower(this, '{{user.username}}')">Remove follow</div></td>
{% endif %}
</tr>
{% endfor %}

View File

@ -22,7 +22,7 @@
<td>{{loop.index}}</td>
<td>{% include "user_in_table.html" %}</td>
{% if v.id == u.id %}
<td><div class="btn btn-danger" onclick="removeFollowing(event, '{{user.username}}')">Unfollow</div></td>
<td><div class="btn btn-danger" onclick="removeFollowing(this, '{{user.username}}')">Unfollow</div></td>
{% endif %}
</tr>
{% endfor %}
@ -31,4 +31,4 @@
<script defer src="{{'js/following.js' | asset}}"></script>
{% endblock %}
{% endblock %}

View File

@ -213,7 +213,7 @@
document.addEventListener('DOMContentLoaded', function() {
const tt = bootstrap.Tooltip.getOrCreateInstance(document.getElementById('mobile-prompt'))
tt.show()
document.getElementsByClassName('tooltip')[0].onclick = function(event){
document.getElementsByClassName('tooltip')[0].onclick = function() {
tt.hide()
var xhr = new XMLHttpRequest();
xhr.withCredentials=true;