merged
This commit is contained in:
@@ -19,6 +19,8 @@ or `pipx install https://bitbucket.org/MoonQ/mirva/get/master.zip`
|
||||
|
||||
Use the command line tool `mirva` to render web sites.
|
||||
|
||||
note: Arrow keys left/right on web page move between images.
|
||||
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
__version__ = "20220124.0"
|
||||
__version__ = "20211114.0"
|
||||
|
||||
|
||||
def get_version():
|
||||
|
||||
@@ -159,43 +159,7 @@ Released : 20110306
|
||||
<link rel="shortcut icon" href="{resource}/mirva.ico"/>
|
||||
<title>{page_title}</title>
|
||||
<link href="{resource}/style.css" rel="stylesheet" type="text/css" media="screen" />
|
||||
<script>
|
||||
function r(f){{/in/.test(document.readyState)?setTimeout('r('+f+')',9):f()}}
|
||||
r(function(){{
|
||||
create_nav();
|
||||
}});
|
||||
function create_nav() {{
|
||||
let navis = document.getElementsByClassName("navigation");
|
||||
for (let i = 0; i<navis.length; i++) {{
|
||||
if (i==navis.length-1) {{
|
||||
navis[i].appendChild(create_button("up", navis[0]));
|
||||
continue;
|
||||
}}
|
||||
if (navis[i-1]) {{
|
||||
navis[i].appendChild(create_button("up", navis[i-1]));
|
||||
}} else {{
|
||||
navis[i].appendChild(create_button("up", document.body));
|
||||
}}
|
||||
if (navis[i+1]) {{
|
||||
navis[i].appendChild(create_button("down", navis[i+1]));
|
||||
}}
|
||||
|
||||
}}
|
||||
}}
|
||||
function create_button(direction, to) {{
|
||||
let container = document.createElement('div');
|
||||
container.classList.add("float_" + direction);
|
||||
let button = document.createElement('img');
|
||||
button.src = "{resource}/arrow_" + direction + ".png";
|
||||
button.classList.add("navigation_button");
|
||||
button.onclick = function(){{
|
||||
to.parentElement.scrollIntoView({{behavior: "smooth"}});
|
||||
}};
|
||||
container.appendChild(button);
|
||||
return container
|
||||
}}
|
||||
|
||||
</script>
|
||||
<script src="{resource}/mirva.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
@@ -304,6 +268,7 @@ function create_button(direction, to) {{
|
||||
"arrow_down.png",
|
||||
"banner.jpg",
|
||||
"mirva.ico",
|
||||
"mirva.js",
|
||||
):
|
||||
if os.path.exists(os.path.join(self.resource_dir, f)):
|
||||
continue
|
||||
|
||||
82
mirva/resources/mirva.js
Normal file
82
mirva/resources/mirva.js
Normal file
@@ -0,0 +1,82 @@
|
||||
let current=-1;
|
||||
function r(f){/in/.test(document.readyState)?setTimeout('r('+f+')',9):f()}
|
||||
r(function(){
|
||||
create_nav();
|
||||
document.onkeydown = keyboard_entry;
|
||||
document.onwheel = scroll_event;
|
||||
|
||||
});
|
||||
function create_nav() {
|
||||
let navis = document.getElementsByClassName("navigation");
|
||||
for (let i = 0; i<navis.length; i++) {
|
||||
if (i==navis.length-1) {
|
||||
navis[i].appendChild(create_button("up", navis[0], 0));
|
||||
continue;
|
||||
}
|
||||
if (navis[i-1]) {
|
||||
navis[i].appendChild(create_button("up", navis[i-1], i-1));
|
||||
} else {
|
||||
navis[i].appendChild(create_button("up", document.body, 0));
|
||||
}
|
||||
if (navis[i+1]) {
|
||||
navis[i].appendChild(create_button("down", navis[i+1], i+1));
|
||||
}
|
||||
}
|
||||
}
|
||||
function create_button(direction, to, next) {
|
||||
let container = document.createElement('div');
|
||||
container.classList.add("float_" + direction);
|
||||
let button = document.createElement('img');
|
||||
button.src = ".mirva/arrow_" + direction + ".png";
|
||||
button.classList.add("navigation_button");
|
||||
button.onclick = function(){
|
||||
to.parentElement.scrollIntoView({behavior: "smooth"});
|
||||
current = next;
|
||||
};
|
||||
container.appendChild(button);
|
||||
return container
|
||||
}
|
||||
function is_visible(el) {
|
||||
let rect = el.getBoundingClientRect();
|
||||
return rect.top < window.innerHeight && rect.bottom >= 0;
|
||||
}
|
||||
function scroll_event(ev) {
|
||||
let navis = document.getElementsByClassName("navigation");
|
||||
for (let i = 0; i<navis.length; i++) {
|
||||
if (is_visible(navis[i])) {
|
||||
current = i -1;
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
function keyboard_entry(ev) {
|
||||
let kC = ev.keyCode;
|
||||
let ctrlDown = ev.ctrlKey || ev.metaKey;
|
||||
if (ctrlDown) {
|
||||
return;
|
||||
}
|
||||
if ([32,33,34,35,36,37,38,39,40].indexOf(kC) == -1) {
|
||||
return
|
||||
}
|
||||
let navis = document.getElementsByClassName("navigation");
|
||||
if (kC == '36') { // home
|
||||
current = -1;
|
||||
return
|
||||
}
|
||||
else if (kC == '35') { // end
|
||||
current = navis.length;
|
||||
return
|
||||
}
|
||||
else if (kC == '39') { // right
|
||||
current += 1;
|
||||
}
|
||||
else if (kC == '37') { // left
|
||||
current -= 1;
|
||||
} else {
|
||||
setTimeout(scroll_event, 100);
|
||||
return
|
||||
}
|
||||
current = Math.max(0, current);
|
||||
current = Math.min(navis.length-1, current);
|
||||
navis[current].parentElement.scrollIntoView({behavior: "smooth"});
|
||||
}
|
||||
Reference in New Issue
Block a user