summaryrefslogtreecommitdiff
path: root/index.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2017-02-26 00:14:30 +0300
committerAndrew Dolgov <[email protected]>2017-02-26 00:14:30 +0300
commitb8ae4b31c129031e89e4c7fb9801d6761513dd73 (patch)
tree4522dc5c059837a8c143c2a90c1dc562db0915ff /index.php
parentf858879a3d13bcec694a5e2493fbfe3a1a233e13 (diff)
experimental service worker offline stuff
Diffstat (limited to 'index.php')
-rw-r--r--index.php68
1 files changed, 60 insertions, 8 deletions
diff --git a/index.php b/index.php
index cf10045..ead1231 100644
--- a/index.php
+++ b/index.php
@@ -28,6 +28,7 @@
<link rel="shortcut icon" sizes="192x192" href="img/favicon_hires.png">
<link rel="manifest" href="manifest.json">
<meta name="mobile-web-app-capable" content="yes">
+ <script src="js/index.js"></script>
</head>
<body>
@@ -65,6 +66,23 @@
</div>
</div>
+<script type="text/javascript">
+ $(document).ready(function() {
+
+ if ('serviceWorker' in navigator) {
+ navigator.serviceWorker
+ .register('worker.js')
+ .then(function() {
+ console.log("service worker registered");
+ });
+
+ $(window).on('offline', function() {
+ window.location.reload();
+ });
+ }
+
+ });
+</script>
<div class="container">
@@ -176,17 +194,51 @@
$data_result = $db->query("SELECT * FROM data WHERE book = " . $line["id"] . " LIMIT 3");
- while ($data_line = $data_result->fetchArray(SQLITE3_ASSOC)) {
- if ($data_line["format"] != "ORIGINAL_EPUB") {
- $label_class = $data_line["format"] == "EPUB" ? "label-success" : "label-primary";
+ /*print "<span class=\"label label-default\">
+ <span class=\"glyphicon glyphicon-download-alt\">
+ </span>";*/
- $download_link = "backend.php?op=download&id=" . $data_line["id"];
- print "<a target=\"_blank\" href=\"$download_link\"><span class=\"label $label_class\">" . $data_line["format"] . "</span></a> ";
- }
- }
+ print "</div>";
+ ?>
+ <div class="dropdown" style="white-space : nowrap">
+ <a href="#" data-toggle="dropdown" role="button">
+ More...
+ <span class="caret"></span>
+ </a>
+
+ <ul class="dropdown-menu" aria-labelledby="dLabel">
+
+ <!-- <?php if ($line["series_name"]) {
+ $series_link = "?" . http_build_query(["query" => $line["series_name"]]);
+ $series_full = $line["series_name"] . " [" . $line["series_index"] . "]";
+
+ print "<li><a title=\"".htmlspecialchars($series_full)."\"
+ href=\"$series_link\">$series_full</a></li>";
+ }
+ ?> -->
+
+ <?php if ($line["epub_id"]) { ?>
+ <li><a href="#" onclick="return offline_cache(this)"
+ data-book-id="<?php echo $line["id"] ?>" class="offline" title="">Make available offline</a></li>
+ <li class="divider"></li>
+ <?php } ?>
+
+ <?php while ($data_line = $data_result->fetchArray(SQLITE3_ASSOC)) {
+ if ($data_line["format"] != "ORIGINAL_EPUB") {
+ $label_class = $data_line["format"] == "EPUB" ? "label-success" : "label-primary";
+
+ $download_link = "backend.php?op=download&id=" . $data_line["id"];
+
+ print "<li><a target=\"_blank\" href=\"$download_link\">Download: <span class=\"label $label_class\">" .
+ $data_line["format"] . "</span></a></li>";
+ }
+ } ?>
+ </ul>
+ </div>
+
+ <?php
- print "</div>";
print "</div>";
print "</div>";