2023-02-20 23:15:13 +00:00
|
|
|
<script>
|
|
|
|
window.page = {{page_obj.number}};
|
2023-04-26 08:38:34 +00:00
|
|
|
window.has_next_page = {{1 if has_next_page else 0}};
|
2023-02-20 23:15:13 +00:00
|
|
|
window.loading_page = false;
|
|
|
|
$(function() {
|
2023-04-02 22:57:32 +00:00
|
|
|
function getQueryParams() {
|
|
|
|
var queryParams = {};
|
|
|
|
var query = window.location.search.substring(1);
|
|
|
|
var vars = query.split("&");
|
|
|
|
for (var i = 0; i < vars.length; i++) {
|
|
|
|
var pair = vars[i].split("=");
|
|
|
|
queryParams[pair[0]] = decodeURIComponent(pair[1]);
|
|
|
|
}
|
|
|
|
return queryParams;
|
|
|
|
}
|
|
|
|
|
2023-04-26 08:38:34 +00:00
|
|
|
function loadNextPage() {
|
|
|
|
window.loading_page = true;
|
|
|
|
var params = {
|
|
|
|
"only_content": 1,
|
|
|
|
"page": window.page + 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
params = Object.assign({}, getQueryParams(), params);
|
|
|
|
|
|
|
|
$.get("{{feed_content_url}}", params)
|
|
|
|
.done(function(data) {
|
|
|
|
$(".has_next").remove();
|
|
|
|
$(".middle-content").append(data);
|
|
|
|
window.loading_page = false;
|
|
|
|
window.has_next_page = parseInt($(".has_next").attr("value"));
|
|
|
|
window.page++;
|
2024-02-05 23:02:49 +00:00
|
|
|
renderKatex($('.middle-content')[0]);
|
2023-04-26 08:38:34 +00:00
|
|
|
onWindowReady();
|
|
|
|
activateBlogBoxOnClick();
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-02-20 23:15:13 +00:00
|
|
|
$(window).on("scroll", function() {
|
|
|
|
if (window.loading_page || !window.has_next_page) return;
|
|
|
|
var distanceFromBottom = $(document).height() - ($(window).scrollTop() + $(window).height());
|
2023-04-26 08:38:34 +00:00
|
|
|
var isDesktop = window.matchMedia('(min-width: 800px)').matches;
|
2023-02-20 23:15:13 +00:00
|
|
|
|
2023-04-26 08:38:34 +00:00
|
|
|
if (isDesktop && distanceFromBottom < 500) {
|
|
|
|
loadNextPage();
|
2023-02-20 23:15:13 +00:00
|
|
|
}
|
|
|
|
});
|
2023-04-26 08:38:34 +00:00
|
|
|
|
|
|
|
$(document).on("click", ".view-next-page", () => {
|
|
|
|
if (window.loading_page || !window.has_next_page) return;
|
|
|
|
var isDesktop = window.matchMedia('(min-width: 800px)').matches;
|
|
|
|
if (isDesktop) return;
|
|
|
|
$(".view-next-page").remove();
|
|
|
|
loadNextPage();
|
|
|
|
});
|
2023-02-20 23:15:13 +00:00
|
|
|
});
|
|
|
|
</script>
|