Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
name="description"
content="東京大学前期課程特化の履修登録支援サービス。使いやすい電子シラバスを提供します。時間割機能と必修自動登録機能で空きコマの把握も一瞬で行えます。"
/>
<link
rel="stylesheet"
href="https://fonts.googleapis.com/icon?family=Material+Icons"
/>
<link rel="stylesheet" type="text/css" href="material-icons.css" />
<link rel="stylesheet" type="text/css" href="style.css" />
<link rel="icon" href="resources/favicon-utcode.png" />
<script>
if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("/sw.js");
Copy link

Copilot AI May 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding error handling (e.g., using .catch) to the service worker registration to log any registration failures and assist with debugging offline issues.

Suggested change
navigator.serviceWorker.register("/sw.js");
navigator.serviceWorker.register("/sw.js").catch((error) => {
console.error("Service worker registration failed:", error);
});

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

要るかあ? 🤔

}
</script>
</head>
<body>
<!-- Google tag (gtag.js) -->
Expand Down
36 changes: 36 additions & 0 deletions material-icons.css
Original file line number Diff line number Diff line change
@@ -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";
}
5 changes: 4 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
* @prop {HTMLTableRowElement} tableRow
*/

/** DBのバージョン(年, セメスター)を表す文字列 */
/**
* DBのバージョン(年, セメスター)を表す文字列
* あわせて sw.js も更新すること
*/
const LAST_UPDATED = "2025S";
/**
* 同セメスター内のバージョンを示す整数値.
Expand Down
65 changes: 65 additions & 0 deletions sw.js
Original file line number Diff line number Diff line change
@@ -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);
})(),
);
});