-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.html
90 lines (86 loc) · 3.48 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<html lang="en">
<head>
<title>Webpub manifest viewer</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<link href="webapp.webmanifest" rel="manifest" type="application/manifest+json">
<link rel="apple-touch-icon" href="cover.jpg" type="image/jpeg">
<link rel="stylesheet" href="main.css">
<script src="require.js"></script>
<script src="fetch.js"></script>
<script src="url.js"></script>
<script src="promise.js"></script>
<script src="webpub-viewer.js"></script>
</head>
<body>
<div id="viewer">
</div>
<script>
//https://github.com/NYPL-Simplified/webpub-viewer
//https://github.com/NYPL-Simplified/webpub-viewer/tree/master/examples
//https://github.com/NYPL-Simplified/web-reader-landing-page/blob/master/book_index.html.template
var getURLQueryParams = function() {
var params = {};
var query = window.location.search;
if (query && query.length) {
query = query.substring(1);
var keyParams = query.split('&');
for (var x = 0; x < keyParams.length; x++) {
var keyVal = keyParams[x].split('=');
if (keyVal.length > 1) {
params[keyVal[0]] = decodeURIComponent(keyVal[1]);
}
}
}
return params;
};
require(["LocalStorageStore", "ServiceWorkerCacher", "IFrameNavigator", "ColumnsPaginatedBookView", "ScrollingBookView", "LocalAnnotator", "BookSettings"],
function (LocalStorageStore, ServiceWorkerCacher, IFrameNavigator, ColumnsPaginatedBookView, ScrollingBookView, LocalAnnotator, BookSettings) {
var element = document.getElementById("viewer");
var urlParams = getURLQueryParams();
var webpubManifestUrl = new URL(urlParams['url']);
var store = new LocalStorageStore.default({ prefix: webpubManifestUrl.href });
var cacher = new ServiceWorkerCacher.default({
store: store,
manifestUrl: webpubManifestUrl,
serviceWorkerUrl: new URL("sw.js", window.location.href),
staticFileUrls: [
new URL(window.location.href),
new URL("index.html", window.location.href),
new URL("main.css", window.location.href),
new URL("require.js", window.location.href),
new URL("fetch.js", window.location.href),
new URL("url.js", window.location.href),
new URL("promise.js", window.location.href),
new URL("webpub-viewer.js", window.location.href)
]
});
var paginator = new ColumnsPaginatedBookView.default();
var scroller = new ScrollingBookView.default();
var annotator = new LocalAnnotator.default({ store: store });
var settingsStore = new LocalStorageStore.default({ prefix: "webpub-viewer" });
var fontSizes = [ 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32 ];
var defaultFontSize = 20;
BookSettings.default.create({
store: settingsStore,
bookViews: [paginator, scroller],
fontSizesInPixels: fontSizes,
defaultFontSizeInPixels: defaultFontSize
}).then(function (settings) {
IFrameNavigator.default.create({
element: element,
manifestUrl: webpubManifestUrl,
store: store,
cacher: cacher,
settings: settings,
annotator: annotator,
paginator: paginator,
scroller: scroller
});
});
});
</script>
</body>
</html>