浏览代码

Grasping at straws

Trevor Elliott 3 年之前
父节点
当前提交
738556da2f
共有 2 个文件被更改,包括 6 次插入6 次删除
  1. 5 5
      js/index.js
  2. 1 1
      lc/app.py

+ 5 - 5
js/index.js

@@ -27,6 +27,11 @@ let confirmDelete = (url, id) => {
 };
 
 document.addEventListener("DOMContentLoaded", () => {
+  if ('serviceWorker' in navigator) {
+    // TODO(trevor) does it matter if this fails?
+    navigator.serviceWorker.register('/service-worker.js')
+  }
+
   $(".deletelink").each((idx, elem) => {
     $(elem).on("click", (event) => {
       confirmDelete(event.target.dataset.url, event.target.dataset.linkId);
@@ -69,8 +74,3 @@ document.addEventListener("DOMContentLoaded", () => {
   });
 
 });
-
-if ('serviceWorker' in navigator) {
-  // TODO(trevor) does it matter if this fails?
-  navigator.serviceWorker.register('/service-worker')
-}

+ 1 - 1
lc/app.py

@@ -292,7 +292,7 @@ class PinboardImport(Endpoint):
         return self.api_ok(u.base_url())
 
 
-@endpoint("/service-worker")
+@endpoint("/service-worker.js")
 class ServiceWorker(Endpoint):
     def route(self, *args, **kwargs):
         return flask.send_file("../js/serviceWorker.js", mimetype="text/javascript")