This commit is contained in:
2022-08-23 12:56:54 +03:00
2 changed files with 8 additions and 6 deletions

View File

@@ -71,7 +71,7 @@ class Mirva:
def create_config(self): def create_config(self):
self.config = configparser.ConfigParser() self.config = configparser.RawConfigParser()
self.config.read(self.config_file) self.config.read(self.config_file)
config_changed = False config_changed = False
if not "SITE" in self.config: if not "SITE" in self.config:
@@ -129,7 +129,7 @@ class Mirva:
self.posts.append(post) self.posts.append(post)
def get_config(self): def get_config(self):
self.config = configparser.ConfigParser() self.config = configparser.RawConfigParser()
self.config.read(self.config_file) self.config.read(self.config_file)
def write_config(self): def write_config(self):

View File

@@ -2,11 +2,13 @@ let current = -1;
let currentScrolled = -1; let currentScrolled = -1;
let scrollTimer = null; let scrollTimer = null;
let scrollEventTimer = null; let scrollEventTimer = null;
let defaultScroll = "smooth";
function r(f) { function r(f) {
/in/.test(document.readyState) ? setTimeout('r(' + f + ')', 9) : f() /in/.test(document.readyState) ? setTimeout('r(' + f + ')', 9) : f()
} }
r(function() { r(function() {
defaultScroll = typeof document.body.dataset.scroll === "string" ? document.body.dataset.scroll : "smooth";
create_nav(); create_nav();
document.onkeydown = keyboard_entry; document.onkeydown = keyboard_entry;
}); });
@@ -37,7 +39,7 @@ function create_button(direction, to, next) {
button.classList.add("navigation_button"); button.classList.add("navigation_button");
button.onclick = function() { button.onclick = function() {
to.parentElement.scrollIntoView({ to.parentElement.scrollIntoView({
behavior: "smooth" behavior: defaultScroll
}); });
current = next; current = next;
}; };
@@ -132,7 +134,7 @@ function keyboard_entry(ev) {
return return
} }
if (current == -1) { if (current == -1) {
window.scrollTo({ top: 0, behavior: 'smooth' }); window.scrollTo({ top: 0, behavior: defaultScroll });
return return
} }
current = Math.max(0, current); current = Math.max(0, current);
@@ -145,7 +147,7 @@ function keyboard_entry(ev) {
clearTimeout(scrollTimer); clearTimeout(scrollTimer);
} else { } else {
posts[current].parentElement.scrollIntoView({ posts[current].parentElement.scrollIntoView({
behavior: "smooth" behavior: defaultScroll
}); });
} }
scrollTimer = setTimeout(function() { scrollTimer = setTimeout(function() {
@@ -153,4 +155,4 @@ function keyboard_entry(ev) {
}, },
200 200
); );
} }