+
«
{for $j = $conf->page - ($space-1); $j <= $conf->page + ($space-1); $j++}
{$j}
diff --git a/Web/static/js/al_music.js b/Web/static/js/al_music.js
index 7ee1f035..9aeab1f8 100644
--- a/Web/static/js/al_music.js
+++ b/Web/static/js/al_music.js
@@ -641,6 +641,35 @@ class bigPlayer {
duration: this.tracks["currentTrack"].length
})
}
+
+ loadContextPage(page, lesser = false) {
+ const formdata = new FormData()
+ formdata.append("context", this.context["context_type"])
+ formdata.append("context_entity", this.context["context_id"])
+ formdata.append("hash", u("meta[name=csrf]").attr("value"))
+ formdata.append("page", page)
+
+ ky.post("/audios/context", {
+ hooks: {
+ afterResponse: [
+ async (_request, _options, response) => {
+ const newArr = await response.json()
+
+ if(lesser)
+ this.tracks["tracks"] = newArr["items"].concat(this.tracks["tracks"])
+ else
+ this.tracks["tracks"] = this.tracks["tracks"].concat(newArr["items"])
+
+ this.context["playedPages"].push(String(newArr["page"]))
+
+ this.updateButtons()
+ console.info("Loaded context for page " + page)
+ }
+ ]
+ },
+ body: formdata
+ })
+ }
}
document.addEventListener("DOMContentLoaded", function() {
diff --git a/Web/static/js/al_suggestions.js b/Web/static/js/al_suggestions.js
index 1c3da3e8..befe78b7 100644
--- a/Web/static/js/al_suggestions.js
+++ b/Web/static/js/al_suggestions.js
@@ -201,7 +201,7 @@ $(document).on("click", ".sugglist a", (e) => {
})
// нажатие на пагинатор у постов предложки
-$(document).on("click", "#postz .paginator a", (e) => {
+/*$(document).on("click", "#postz .paginator a", (e) => {
e.preventDefault()
ky(e.currentTarget.href, {
@@ -228,4 +228,4 @@ $(document).on("click", "#postz .paginator a", (e) => {
]
}
})
-})
+})*/
diff --git a/Web/static/js/al_wall.js b/Web/static/js/al_wall.js
index 3278810d..8b516f11 100644
--- a/Web/static/js/al_wall.js
+++ b/Web/static/js/al_wall.js
@@ -1643,3 +1643,76 @@ $(document).on("click", ".avatarDelete", (e) => {
}),
]);
})
+
+async function __processPaginatorNextPage(page)
+{
+ const container = u('.scroll_container')
+ const container_node = '.scroll_node'
+ const parser = new DOMParser
+
+ const replace_url = new URL(location.href)
+ replace_url.searchParams.set('p', page)
+
+ const new_content = await fetch(replace_url.href)
+ const new_content_response = await new_content.text()
+ const parsed_content = parser.parseFromString(new_content_response, 'text/html')
+
+ const nodes = parsed_content.querySelectorAll(container_node)
+ nodes.forEach(node => {
+ container.append(node)
+ })
+
+ u(`.paginator:not(.paginator-at-top)`).html(parsed_content.querySelector('.paginator:not(.paginator-at-top)').innerHTML)
+ // fffffuck
+ if(u(`.paginator:not(.paginator-at-top)`).nodes[0].closest('.scroll_container')) {
+ container.nodes[0].append(u(`.paginator:not(.paginator-at-top)`).nodes[0].parentNode)
+ }
+
+ if(window.player) {
+ window.player.loadContextPage(page)
+ }
+
+ if(typeof __scrollHook != 'undefined') {
+ __scrollHook(page)
+ }
+}
+
+const showMoreObserver = new IntersectionObserver(entries => {
+ entries.forEach(async x => {
+ if(x.isIntersecting) {
+ if(u('.scroll_container').length < 1) {
+ return
+ }
+
+ const target = u(x.target)
+ if(target.length < 1 || target.hasClass('paginator-at-top')) {
+ return
+ }
+
+ const current_url = new URL(location.href)
+ if(current_url.searchParams && !isNaN(parseInt(current_url.searchParams.get('p')))) {
+ return
+ }
+
+ target.addClass('lagged')
+ const active_tab = target.find('.active')
+ const next_page = u(active_tab.nodes[0] ? active_tab.nodes[0].nextElementSibling : null)
+ if(next_page.length < 1) {
+ u('.paginator:not(.paginator-at-top)').removeClass('lagged')
+ return
+ }
+
+ const page_number = Number(next_page.html())
+ await __processPaginatorNextPage(page_number)
+ u('.paginator:not(.paginator-at-top)').removeClass('lagged')
+ }
+ })
+}, {
+ root: null,
+ rootMargin: '0px',
+ threshold: 0,
+})
+
+if(u('.paginator:not(.paginator-at-top)').length > 0) {
+ showMoreObserver.observe(u('.paginator:not(.paginator-at-top)').nodes[0])
+}
diff --git a/Web/static/js/openvk.cls.js b/Web/static/js/openvk.cls.js
index 64700084..5878945e 100644
--- a/Web/static/js/openvk.cls.js
+++ b/Web/static/js/openvk.cls.js
@@ -90,7 +90,7 @@ document.addEventListener("DOMContentLoaded", function() { //BEGIN
});
/* @rem-pai why this func wasn't named as "#_deleteDialog"? It looks universal IMO */
- u("#_noteDelete").on("click", function(e) {
+ u(document).on("click", "#_noteDelete", function(e) {
var formHtml = "
";
@@ -167,7 +167,7 @@ document.addEventListener("DOMContentLoaded", function() { //BEGIN
return false;
});
- u("#_submitUserSubscriptionAction").handle("submit", async function(e) {
+ u(document).handle("submit", "#_submitUserSubscriptionAction", async function(e) {
u(this).nodes[0].parentElement.classList.add('loading');
u(this).nodes[0].parentElement.classList.add('disable');
console.log(e.target);
@@ -518,7 +518,7 @@ function highlightText(searchText, container_selector, selectors = []) {
node.parentNode.insertBefore(tempDiv.firstChild, node)
}
node.parentNode.removeChild(node)
- } else if(node.nodeType === 1 && node.tagName !== 'SCRIPT' && node.tagName !== 'BR' && node.tagName !== 'STYLE') {
+ } else if(node.nodeType === 1 && node.tagName !== 'SCRIPT' && node.tagName !== 'BR' && node.tagName !== 'STYLE' && !node.classList.contains('highlight')) {
Array.from(node.childNodes).forEach(highlightNode);
}
}
From 389f0b4bb4ee6fff71e2259c1b41c67e87f142d5 Mon Sep 17 00:00:00 2001
From: mrilyew <99399973+mrilyew@users.noreply.github.com>
Date: Sat, 2 Nov 2024 12:13:17 +0300
Subject: [PATCH 2/3] allow comments scroll
---
Web/Presenters/templates/components/comments.xml | 8 +++++---
Web/static/js/al_comments.js | 2 +-
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/Web/Presenters/templates/components/comments.xml b/Web/Presenters/templates/components/comments.xml
index 0df0c91f..a4bf59da 100644
--- a/Web/Presenters/templates/components/comments.xml
+++ b/Web/Presenters/templates/components/comments.xml
@@ -9,9 +9,11 @@
{if sizeof($comments) > 0}
- {foreach $comments as $comment}
- {include "comment.xml", comment => $comment}
- {/foreach}
+
{include "paginator.xml", conf => (object) ["page" => $page, "count" => $count, "amount" => sizeof($comments), "perPage" => 10]}
diff --git a/Web/static/js/al_comments.js b/Web/static/js/al_comments.js
index f4172428..70c7210d 100644
--- a/Web/static/js/al_comments.js
+++ b/Web/static/js/al_comments.js
@@ -1,4 +1,4 @@
-u(".comment-reply").on("click", function(e) {
+u(document).on("click", ".comment-reply", function(e) {
let comment = u(e.target).closest(".post");
let authorId = comment.data("owner-id");
let authorNm = u(".post-author > a > b", comment.first()).text().trim();
From c4fec2bf9701ecee798df37bff1b6f285763213b Mon Sep 17 00:00:00 2001
From: mrilyew <99399973+mrilyew@users.noreply.github.com>
Date: Sat, 2 Nov 2024 13:02:34 +0300
Subject: [PATCH 3/3] rework to up button
---
Web/Presenters/templates/@layout.xml | 9 +++++++-
Web/static/css/main.css | 29 ++++++++++++++++++++++++--
Web/static/js/scroll.js | 31 +++++++++++++++++++++++-----
3 files changed, 61 insertions(+), 8 deletions(-)
diff --git a/Web/Presenters/templates/@layout.xml b/Web/Presenters/templates/@layout.xml
index b54ef44c..5e095508 100644
--- a/Web/Presenters/templates/@layout.xml
+++ b/Web/Presenters/templates/@layout.xml
@@ -82,7 +82,14 @@
{/if}
diff --git a/Web/static/css/main.css b/Web/static/css/main.css
index cb633d0a..e649df4e 100644
--- a/Web/static/css/main.css
+++ b/Web/static/css/main.css
@@ -1381,7 +1381,7 @@ textarea {
.toTop {
position: fixed;
- padding: 20px;
+ padding: 12px;
width: 100px;
height: 100%;
background-color: #f3f3f3;
@@ -1391,9 +1391,34 @@ textarea {
opacity: 0;
transition: .1s all;
z-index: 129;
+ user-select: none;
}
-body.scrolled .toTop:hover {
+.toTop > div svg {
+ display: inline-block;
+ margin-right: 2px;
+ width: 8px;
+ height: 7px;
+ fill: #3f3f3f;
+}
+
+.toTop > div span {
+ font-weight: bold;
+}
+
+.toTop.has_down #to_up, .toTop #to_back {
+ display: none;
+}
+
+.toTop.has_down #to_back {
+ display: block;
+}
+
+.toTop.has_down {
+ opacity: .3;
+}
+
+body.scrolled .toTop:hover, .toTop.has_down:hover {
opacity: .5;
cursor: pointer;
}
diff --git a/Web/static/js/scroll.js b/Web/static/js/scroll.js
index 3b652afd..dff0ca4b 100644
--- a/Web/static/js/scroll.js
+++ b/Web/static/js/scroll.js
@@ -1,14 +1,35 @@
window.addEventListener("scroll", function(e) {
if(window.scrollY < 100) {
+ if(window.temp_y_scroll) {
+ u('.toTop').addClass('has_down')
+ }
document.body.classList.toggle("scrolled", false);
} else {
document.body.classList.toggle("scrolled", true);
+ u('.toTop').removeClass('has_down')
}
});
u(".toTop").on("click", function(e) {
- window.scrollTo({
- top: 0,
- behavior: "smooth"
- });
-});
\ No newline at end of file
+ const y_scroll = window.scrollY
+ const scroll_margin = 20
+
+ if(y_scroll > 100) {
+ window.temp_y_scroll = y_scroll
+ window.scrollTo(0, scroll_margin)
+ window.scrollTo({
+ top: 0,
+ behavior: "smooth"
+ })
+ } else {
+ if(window.temp_y_scroll) {
+ window.scrollTo(0, window.temp_y_scroll - scroll_margin)
+ window.scrollTo({
+ top: window.temp_y_scroll,
+ behavior: "smooth"
+ })
+ }
+ }
+
+ u(document).trigger('scroll')
+})