mirror of https://github.com/kiwix/libkiwix.git
Superficial cleanup in static/skin/viewer.js
This commit is contained in:
parent
948435794f
commit
29efb88d48
|
@ -35,13 +35,15 @@ let currentBookTitle = null;
|
||||||
|
|
||||||
const bookUIGroup = document.getElementById('kiwix_serve_taskbar_book_ui_group');
|
const bookUIGroup = document.getElementById('kiwix_serve_taskbar_book_ui_group');
|
||||||
const homeButton = document.getElementById('kiwix_serve_taskbar_home_button');
|
const homeButton = document.getElementById('kiwix_serve_taskbar_home_button');
|
||||||
|
const contentIframe = document.getElementById('content_iframe');
|
||||||
|
|
||||||
|
|
||||||
function gotoMainPageOfCurrentBook() {
|
function gotoMainPageOfCurrentBook() {
|
||||||
location.hash = currentBook + '/';
|
location.hash = currentBook + '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
function gotoUrl(url) {
|
function gotoUrl(url) {
|
||||||
cf.src = url;
|
contentIframe.src = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function gotoRandomPage() {
|
function gotoRandomPage() {
|
||||||
|
@ -110,27 +112,26 @@ function iframeUrl2UserUrl(url, query) {
|
||||||
return url.split('/').slice(2).join('/');
|
return url.split('/').slice(2).join('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
const cf = document.getElementById('content_iframe');
|
|
||||||
|
|
||||||
function handle_visual_viewport_change() {
|
function handle_visual_viewport_change() {
|
||||||
cf.height = window.visualViewport.height - cf.offsetTop - 4;
|
contentIframe.height = window.visualViewport.height - contentIframe.offsetTop - 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
function handle_location_hash_change() {
|
function handle_location_hash_change() {
|
||||||
const hash = window.location.hash.slice(1);
|
const hash = window.location.hash.slice(1);
|
||||||
|
console.log("handle_location_hash_change: " + hash);
|
||||||
updateCurrentBookIfNeeded(hash);
|
updateCurrentBookIfNeeded(hash);
|
||||||
const iframeContentUrl = userUrl2IframeUrl(hash);
|
const iframeContentUrl = userUrl2IframeUrl(hash);
|
||||||
console.log("handle_location_hash_change: " + hash);
|
if ( iframeContentUrl != contentIframe.contentWindow.location.pathname ) {
|
||||||
if ( iframeContentUrl != cf.contentWindow.location.pathname ) {
|
contentIframe.contentWindow.location.replace(iframeContentUrl);
|
||||||
cf.contentWindow.location.replace(iframeContentUrl);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handle_content_url_change() {
|
function handle_content_url_change() {
|
||||||
document.title = cf.contentDocument.title;
|
const iframeLocation = contentIframe.contentWindow.location;
|
||||||
const iframeContentUrl = cf.contentWindow.location.pathname;
|
console.log('handle_content_url_change: ' + iframeLocation.href);
|
||||||
const iframeContentQuery = cf.contentWindow.location.search;
|
document.title = contentIframe.contentDocument.title;
|
||||||
console.log('handle_content_url_change: ' + cf.contentWindow.location.href);
|
const iframeContentUrl = iframeLocation.pathname;
|
||||||
|
const iframeContentQuery = iframeLocation.search;
|
||||||
const newHash = '#' + iframeUrl2UserUrl(iframeContentUrl, iframeContentQuery);
|
const newHash = '#' + iframeUrl2UserUrl(iframeContentUrl, iframeContentQuery);
|
||||||
const viewerURL = location.origin + location.pathname + location.search;
|
const viewerURL = location.origin + location.pathname + location.search;
|
||||||
window.location.replace(viewerURL + newHash);
|
window.location.replace(viewerURL + newHash);
|
||||||
|
|
|
@ -202,7 +202,7 @@ R"EXPECTEDRESULT( <img src="../skin/download.png?
|
||||||
/* url */ "/ROOT/viewer",
|
/* url */ "/ROOT/viewer",
|
||||||
R"EXPECTEDRESULT( <link type="text/css" href="./skin/taskbar.css?cacheid=26082885" rel="Stylesheet" />
|
R"EXPECTEDRESULT( <link type="text/css" href="./skin/taskbar.css?cacheid=26082885" rel="Stylesheet" />
|
||||||
<link type="text/css" href="./skin/css/autoComplete.css?cacheid=08951e06" rel="Stylesheet" />
|
<link type="text/css" href="./skin/css/autoComplete.css?cacheid=08951e06" rel="Stylesheet" />
|
||||||
<script type="text/javascript" src="./skin/viewer.js?cacheid=b3ef34f2" defer></script>
|
<script type="text/javascript" src="./skin/viewer.js?cacheid=d7d3dac9" defer></script>
|
||||||
<script type="text/javascript" src="./skin/autoComplete.min.js?cacheid=1191aaaf"></script>
|
<script type="text/javascript" src="./skin/autoComplete.min.js?cacheid=1191aaaf"></script>
|
||||||
const blankPageUrl = `${root}/skin/blank.html`;
|
const blankPageUrl = `${root}/skin/blank.html`;
|
||||||
<label for="kiwix_button_show_toggle"><img src="./skin/caret.png?cacheid=22b942b4" alt=""></label>
|
<label for="kiwix_button_show_toggle"><img src="./skin/caret.png?cacheid=22b942b4" alt=""></label>
|
||||||
|
|
Loading…
Reference in New Issue