This commit is contained in:
Aevann1 2022-01-22 00:48:06 +02:00
parent 2072c944cd
commit 23a3af3c2e
12 changed files with 70 additions and 55 deletions

View file

@ -18,7 +18,7 @@ function expandDesktopImage(image) {
};
window.addEventListener("hashchange", function (e) {
if(window.location.hash != "#modal") {
if(location.hash != "#modal") {
const expandImageModal = document.querySelector('#expandImageModal');
const modal = bootstrap.Modal.getInstance(expandImageModal);
modal.hide();
@ -26,7 +26,7 @@ window.addEventListener("hashchange", function (e) {
});
document.getElementById('expandImageModal').addEventListener('hidden.bs.modal', function (e) {
if(window.location.hash == "#modal") {
if(location.hash == "#modal") {
history.back();
}
});

View file

@ -915,7 +915,7 @@ function getEmoji(searchTerm) {
const favorite_emojis = JSON.parse(localStorage.getItem("favorite_emojis")) || {}
if (favorite_emojis[searchTerm]) favorite_emojis[searchTerm] += 1
else favorite_emojis[searchTerm] = 1
window.localStorage.setItem("favorite_emojis", JSON.stringify(favorite_emojis))
localStorage.setItem("favorite_emojis", JSON.stringify(favorite_emojis))
}
function loadEmojis(form) {

View file

@ -30,9 +30,9 @@ if (typeof showNewCommentCounts === 'undefined') {
delete comments[key]
}
}
window.localStorage.setItem("comment-counts", JSON.stringify(comments))
localStorage.setItem("comment-counts", JSON.stringify(comments))
}
window.localStorage.setItem(LAST_CACHE_CLEAN_ID, JSON.stringify(now))
localStorage.setItem(LAST_CACHE_CLEAN_ID, JSON.stringify(now))
}
setTimeout(cleanCache, 500)

View file

@ -1337,7 +1337,7 @@ var PusherPushNotifications = (function (exports) {
if (serviceWorkerRegistration) {
var serviceWorkerScope = serviceWorkerRegistration.scope;
var currentURL = window.location.href;
var currentURL = location.href;
var scopeMatchesCurrentPage = currentURL.startsWith(serviceWorkerScope);
if (!scopeMatchesCurrentPage) {

View file

@ -43,6 +43,6 @@ document.getElementById('file-upload').addEventListener('change', function(){
function savetext() {
let post_title = document.getElementById('post-title').value
let post_text = document.getElementById('post-text').value
window.localStorage.setItem("post_title", post_title)
window.localStorage.setItem("post_text", post_text)
localStorage.setItem("post_title", post_title)
localStorage.setItem("post_text", post_text)
}

View file

@ -1,53 +1,68 @@
let uid = document.getElementById('uid')
const playing = localStorage.getItem("playing")
if (uid)
if (!playing)
{
uid = uid.innerHTML
let uid = document.getElementById('uid')
let audio = new Audio(`/songs/${uid}`);
audio.loop=true;
function toggle() {
if (audio.paused) audio.play()
else audio.pause()
}
audio.play();
document.getElementById('userpage').addEventListener('click', () => {
if (audio.paused) audio.play();
}, {once : true});
}
else
{
let uid = document.getElementById('vid')
if (uid)
{
uid = uid.innerHTML
const paused = localStorage.getItem("paused")
let audio = new Audio(`/songs/${uid}`);
audio.loop=true;
function toggle() {
if (audio.paused)
{
audio.play()
localStorage.setItem("paused", "")
}
else
{
audio.pause()
localStorage.setItem("paused", "1")
}
if (audio.paused) audio.play()
else audio.pause()
}
if (!paused)
audio.play();
document.getElementById('userpage').addEventListener('click', () => {
if (audio.paused) audio.play();
}, {once : true});
localStorage.setItem("playing", "1")
window.addEventListener("unload", function(e) {
localStorage.setItem("playing", "")
});
}
else
{
let uid = document.getElementById('vid')
if (uid)
{
audio.play();
document.getElementById('userpage').addEventListener('click', () => {
if (audio.paused) audio.play();
}, {once : true});
uid = uid.innerHTML
const paused = localStorage.getItem("paused")
let audio = new Audio(`/songs/${uid}`);
audio.loop=true;
function toggle() {
if (audio.paused)
{
audio.play()
localStorage.setItem("paused", "")
}
else
{
audio.pause()
localStorage.setItem("paused", "1")
}
}
if (!paused)
{
audio.play();
document.getElementById('userpage').addEventListener('click', () => {
if (audio.paused) audio.play();
}, {once : true});
localStorage.setItem("playing", "1")
window.addEventListener("unload", function(e) {
localStorage.setItem("playing", "")
});
}
}
}
}

View file

@ -161,7 +161,7 @@ function submitFormAjax(e) {
myToast.show();
return true
} else if (xhr.status >= 300 && xhr.status < 400) {
window.location.href = JSON.parse(xhr.response)["redirect"]
location.href = JSON.parse(xhr.response)["redirect"]
} else {
document.getElementById('toast-post-error-text').innerText = "Error, please try again later."
try {

View file

@ -16,8 +16,8 @@
{% if success %}
<script>
history.pushState(null, null, '{{p.permalink | full_link}}');
window.localStorage.setItem("post_title", "")
window.localStorage.setItem("post_text", "")
localStorage.setItem("post_title", "")
localStorage.setItem("post_text", "")
</script>
{% endif %}
@ -878,7 +878,7 @@
const comments = JSON.parse(localStorage.getItem("comment-counts")) || {}
const newTotal = {{p.comment_count}} || ((comments['{{p.id}}'] || {c: 0}).c + 1)
comments['{{p.id}}'] = {c: newTotal, t: Date.now()}
window.localStorage.setItem("comment-counts", JSON.stringify(comments))
localStorage.setItem("comment-counts", JSON.stringify(comments))
{% endif %}
})()
</script>

View file

@ -195,9 +195,9 @@
{% endblock %}
<script>
let fetched_title = window.localStorage.getItem("post_title")
let fetched_title = localStorage.getItem("post_title")
document.getElementById('post-title').value = fetched_title
let fetched_text = window.localStorage.getItem("post_text")
let fetched_text = localStorage.getItem("post_text")
document.getElementById('post-text').value = fetched_text
function checkForRequired() {

View file

@ -698,7 +698,7 @@
<div id="username" class="d-none">{{u.username}}</div>
{% endif %}
<script src="/static/assets/js/userpage.js?a=205"></script>
<script src="/static/assets/js/userpage.js?a=206"></script>
{% endblock %}

View file

@ -114,5 +114,5 @@
<div id="username" class="d-none">{{u.username}}</div>
{% endif %}
<script src="/static/assets/js/userpage.js?a=205"></script>
<script src="/static/assets/js/userpage.js?a=206"></script>
{% endblock %}

View file

@ -48,5 +48,5 @@
<div id="username" class="d-none">{{u.username}}</div>
{% endif %}
<script src="/static/assets/js/userpage.js?a=205"></script>
<script src="/static/assets/js/userpage.js?a=206"></script>
{% endblock %}