diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/app.js | 1 | ||||
| -rw-r--r-- | src/reader.js | 18 |
2 files changed, 13 insertions, 6 deletions
diff --git a/src/app.js b/src/app.js index 2bed544..ef29043 100644 --- a/src/app.js +++ b/src/app.js @@ -33,6 +33,7 @@ class AppCommon { urlParam(name){ try { const results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href); + if (!results) return 0; return decodeURIComponent(results[1].replace(/\+/g, " ")) || 0; } catch (e) { return 0; diff --git a/src/reader.js b/src/reader.js index 3340203..aa9f103 100644 --- a/src/reader.js +++ b/src/reader.js @@ -498,7 +498,8 @@ class ReaderClass extends AppCommon { // get our stuff from resource loader and inject into iframe content - const base_url = window.location.href.match(/^.*\//)[0]; + const match = window.location.href.match(/^.*\//); + const base_url = match ? match[0] : window.location.href; $(contents.document.head) .append($("<style type='text/css'>") @@ -1186,8 +1187,9 @@ class ReaderClass extends AppCommon { if (typeof EpubeApp != "undefined") { window.setTimeout(function() { - const bg_color = window.getComputedStyle(document.querySelector("body"), null) - .getPropertyValue("background-color"); + const body = document.querySelector("body"); + const bg_color = body ? window.getComputedStyle(body, null) + .getPropertyValue("background-color") : ""; let match = bg_color.match(/rgb\((\d{1,}), (\d{1,}), (\d{1,})\)/); @@ -1197,8 +1199,9 @@ class ReaderClass extends AppCommon { EpubeApp.setStatusBarColor(parseInt(match[1]), parseInt(match[2]), parseInt(match[3])); } - const accent_color = window.getComputedStyle(document.querySelector(".header .title"), null) - .getPropertyValue("color"); + const title = document.querySelector(".header .title"); + const accent_color = title ? window.getComputedStyle(title, null) + .getPropertyValue("color") : ""; match = accent_color.match(/rgb\((\d{1,}), (\d{1,}), (\d{1,})\)/); @@ -1260,7 +1263,10 @@ class ReaderClass extends AppCommon { if (this.book && this.book.rendition) this.book.rendition.getContents().forEach((rendition) => { - width += parseInt(rendition.window.getComputedStyle(rendition.document.querySelector('body')).getPropertyValue('padding-left')); + const body = rendition.document.querySelector('body'); + + if (body) + width += parseInt(rendition.window.getComputedStyle(body).getPropertyValue('padding-left')); }); console.log(`resizing side columns to ${width} px`); |
