diff --git a/index.html b/index.html index f141a0a..9e8c307 100644 --- a/index.html +++ b/index.html @@ -8,12 +8,14 @@ name="description" content="東京大学前期課程特化の履修登録支援サービス。使いやすい電子シラバスを提供します。時間割機能と必修自動登録機能で空きコマの把握も一瞬で行えます。" /> - + +
diff --git a/material-icons.css b/material-icons.css new file mode 100644 index 0000000..24663ce --- /dev/null +++ b/material-icons.css @@ -0,0 +1,36 @@ +/* https://developers.google.com/fonts/docs/material_icons?hl=ja */ + +@font-face { + font-family: "Material Icons"; + font-style: normal; + font-weight: 400; + src: + local("Material Icons"), + local("MaterialIcons-Regular"), + url(https://cdn.jsdelivr.net/npm/@material-design-icons/font@0.14.15/material-icons.woff2) + format("woff2"); +} +.material-icons { + font-family: "Material Icons"; + font-weight: normal; + font-style: normal; + font-size: 24px; /* Preferred icon size */ + display: inline-block; + line-height: 1; + text-transform: none; + letter-spacing: normal; + word-wrap: normal; + white-space: nowrap; + direction: ltr; + + /* Support for all WebKit browsers. */ + -webkit-font-smoothing: antialiased; + /* Support for Safari and Chrome. */ + text-rendering: optimizeLegibility; + + /* Support for Firefox. */ + -moz-osx-font-smoothing: grayscale; + + /* Support for IE. */ + font-feature-settings: "liga"; +} diff --git a/script.js b/script.js index ebf98b1..f6fb846 100644 --- a/script.js +++ b/script.js @@ -38,7 +38,10 @@ * @prop {HTMLTableRowElement} tableRow */ -/** DBのバージョン(年, セメスター)を表す文字列 */ +/** + * DBのバージョン(年, セメスター)を表す文字列 + * あわせて sw.js も更新すること + */ const LAST_UPDATED = "2025S"; /** * 同セメスター内のバージョンを示す整数値. diff --git a/sw.js b/sw.js new file mode 100644 index 0000000..64b8f37 --- /dev/null +++ b/sw.js @@ -0,0 +1,65 @@ +/** + * バージョンを示す整数値. + * sw.js以外の任意のhtml,jsファイルに変更がある場合この値を加算すること + * ファイルの追加がある場合は下の files も更新する + */ +const VERSION = 1; + +const files = [ + "/aboutus", + "/disclaimer", + "/errorMessage/error1.txt", + "/errorMessage/error2.txt", + "/errorMessage/error3.txt", + "/errorMessage/error4.txt", + "/errorMessage/error5.txt", + "/errorMessage/error6.txt", + "/howToUse", + "/", + "/lz-string.min.js", + "/notion", + "/resources/favicon-utcode.png", + "/resources/utc-logo.svg", + "/script.js", + "/style.css", + "/material-icons.css", + "https://cdn.jsdelivr.net/npm/@material-design-icons/font@0.14.15/material-icons.woff2", +]; + +self.addEventListener("install", (e) => { + e.waitUntil( + (async () => { + const c = await self.caches.open("main" + VERSION); + await c.addAll(files); + })(), + ); +}); +self.addEventListener("activate", (e) => { + // 古いキャッシュを削除する + e.waitUntil( + (async () => { + const keys = await self.caches.keys(); + await Promise.all( + keys + .filter((key) => key !== "main" + VERSION) + .map((key) => self.caches.delete(key)), + ); + })(), + ); +}); +self.addEventListener("fetch", (e) => { + if (e.request.url.startsWith("https://www.googletagmanager.com")) { + return; + } + e.respondWith( + (async () => { + const c = await self.caches.open("main" + VERSION); + const res = await c.match(e.request); + if (res) { + return res; + } + console.warn(`${e.request.url} is not in cache in sw.js`); + return fetch(e.request); + })(), + ); +});