aboutsummaryrefslogtreecommitdiff
path: root/weblog/static
diff options
context:
space:
mode:
authorYaroslav de la Peña Smirnov <contact@yaroslavps.com>2018-10-08 00:03:23 +0300
committerYaroslav de la Peña Smirnov <contact@yaroslavps.com>2018-10-08 00:03:23 +0300
commitd42e64a09e6e1898d4423d786bc48a47a8b8fc0e (patch)
treeacae3bc901930b88742111c9da438c787cbd5707 /weblog/static
parentbb97581d650e2d994e7b2e63297dbb2d8784f5f3 (diff)
downloadw3blog-d42e64a09e6e1898d4423d786bc48a47a8b8fc0e.tar.gz
w3blog-d42e64a09e6e1898d4423d786bc48a47a8b8fc0e.zip
dynamic (no infinite) scrolling working on categories, index (not archive)
Diffstat (limited to 'weblog/static')
-rwxr-xr-xweblog/static/weblog/js/weblog.js20
1 files changed, 19 insertions, 1 deletions
diff --git a/weblog/static/weblog/js/weblog.js b/weblog/static/weblog/js/weblog.js
index 3d93770..f885da2 100755
--- a/weblog/static/weblog/js/weblog.js
+++ b/weblog/static/weblog/js/weblog.js
@@ -12,5 +12,23 @@ function toggleNode(caller){
target.classList.toggle('show');
}
-function loadBlogPosts(page = 2, category = null){
+function loadBlogPosts(url, page = 2){
+ var req = new XMLHttpRequest();
+ function insert(){
+ if (this.status == 200 && this.readyState == 4){
+ var blog_content = document.querySelector(".blog-content");
+ try{
+ var nxtpage_button = document.querySelector(".nxtpage-button");
+ nxtpage_button.insertAdjacentHTML("beforebegin", this.responseText);
+ }
+ catch(er){
+ console.log("error "+er);
+ blog_content.insertAdjacentHTML("beforeend", this.responseText);
+ }
+ console.log(this.responseText);
+ }
+ }
+ req.addEventListener("readystatechange", insert);
+ req.open("GET", url, true);
+ req.send();
}