Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +16 -13
templates/index.html
CHANGED
|
@@ -166,19 +166,22 @@
|
|
| 166 |
let currentFiles = [];
|
| 167 |
let currentDirs = [];
|
| 168 |
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
.
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
});
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
|
|
|
|
|
|
|
|
|
| 182 |
// ディレクトリを読み込む関数
|
| 183 |
function loadDirectory(dir = '') {
|
| 184 |
fetch(`/get_file_json?dir=${encodeURIComponent(dir)}`)
|
|
|
|
| 166 |
let currentFiles = [];
|
| 167 |
let currentDirs = [];
|
| 168 |
|
| 169 |
+
if ('serviceWorker' in navigator) {
|
| 170 |
+
window.addEventListener('load', function() {
|
| 171 |
+
navigator.serviceWorker.register('/sw.js')
|
| 172 |
+
.then(function(registration) {
|
| 173 |
+
console.log('ServiceWorker registration successful with scope: ', registration.scope);
|
| 174 |
+
|
| 175 |
+
// 定期的にキャッシュを更新
|
| 176 |
+
setInterval(() => {
|
| 177 |
+
registration.update();
|
| 178 |
+
}, 60 * 60 * 1000); // 1時間ごとに更新
|
| 179 |
+
})
|
| 180 |
+
.catch(function(err) {
|
| 181 |
+
console.log('ServiceWorker registration failed: ', err);
|
| 182 |
+
});
|
| 183 |
+
});
|
| 184 |
+
}
|
| 185 |
// ディレクトリを読み込む関数
|
| 186 |
function loadDirectory(dir = '') {
|
| 187 |
fetch(`/get_file_json?dir=${encodeURIComponent(dir)}`)
|