diff --git a/examples/twenty/index.html b/examples/twenty/index.html
index 6dab7cf..03f788f 100644
--- a/examples/twenty/index.html
+++ b/examples/twenty/index.html
@@ -22,7 +22,7 @@
var bookCacheUrl = new URL("appcache.html", window.location.href);
var store = new LocalStorageStore.default(webpubManifestUrl.href);
- var cacher = new ServiceWorkerCacher.default(store, webpubManifestUrl, "../../sw.js", bookCacheUrl);
+ var cacher = new ServiceWorkerCacher.default(store, webpubManifestUrl, "../sw.js", bookCacheUrl);
var paginator = new ColumnsPaginatedBookView.default();
var scroller = new ScrollingBookView.default();
diff --git a/src/ApplicationCacheCacher.ts b/src/ApplicationCacheCacher.ts
index 41def20..3cee0e9 100644
--- a/src/ApplicationCacheCacher.ts
+++ b/src/ApplicationCacheCacher.ts
@@ -19,6 +19,7 @@ export default class ApplicationCacheCacher implements Cacher {
private readonly bookCacheUrl: URL;
protected bookCacheElement: HTMLIFrameElement;
private statusUpdateCallback: (status: CacheStatus) => void = () => {};
+ private status: CacheStatus = CacheStatus.Uncached;
public constructor(bookCacheUrl: URL) {
this.bookCacheUrl = bookCacheUrl;
@@ -32,16 +33,20 @@ export default class ApplicationCacheCacher implements Cacher {
this.updateStatus();
this.bookCacheElement.addEventListener("load", () => {
- this.updateStatus();
+ try {
+ this.updateStatus();
- const bookCache = this.bookCacheElement.contentWindow.applicationCache;
+ const bookCache = this.bookCacheElement.contentWindow.applicationCache;
- bookCache.oncached = this.updateStatus.bind(this);
- bookCache.onchecking = this.updateStatus.bind(this);
- bookCache.ondownloading = this.updateStatus.bind(this);
- bookCache.onerror = this.handleError.bind(this);
- bookCache.onnoupdate = this.updateStatus.bind(this);
- bookCache.onupdateready = this.updateStatus.bind(this);
+ bookCache.oncached = this.updateStatus.bind(this);
+ bookCache.onchecking = this.updateStatus.bind(this);
+ bookCache.ondownloading = this.updateStatus.bind(this);
+ bookCache.onerror = this.handleError.bind(this);
+ bookCache.onnoupdate = this.updateStatus.bind(this);
+ bookCache.onupdateready = this.updateStatus.bind(this);
+ } catch (err) {
+ this.handleError();
+ }
});
return new Promise(resolve => resolve());
@@ -52,6 +57,10 @@ export default class ApplicationCacheCacher implements Cacher {
this.updateStatus();
}
+ public getStatus(): CacheStatus {
+ return this.status;
+ }
+
protected updateStatus() {
let status: CacheStatus;
let appCacheStatus = window.applicationCache.UNCACHED;
@@ -77,10 +86,12 @@ export default class ApplicationCacheCacher implements Cacher {
status = CacheStatus.Downloaded;
}
+ this.status = status;
this.statusUpdateCallback(status);
}
protected handleError() {
+ this.status = CacheStatus.Error;
this.statusUpdateCallback(CacheStatus.Error);
}
}
\ No newline at end of file
diff --git a/src/BookSettings.ts b/src/BookSettings.ts
index d65706f..0717ab3 100644
--- a/src/BookSettings.ts
+++ b/src/BookSettings.ts
@@ -21,7 +21,6 @@ const optionTemplate = (liClassName: string, buttonClassName: string, label: str
const offlineTemplate = `
-
`;
@@ -37,12 +36,6 @@ const increaseSvg = `