This repository has been archived on 2022-05-10. You can view files and clone it, but cannot push or open issues or pull requests.
tghandbook/src/index.ts

34 lines
1023 B
TypeScript
Raw Normal View History

2020-06-17 09:43:21 +00:00
import TabManager from "./TabManager";
2020-06-19 18:26:43 +00:00
import sections from "./sections";
2020-06-17 09:43:21 +00:00
2020-06-19 18:26:43 +00:00
const sectionListContainer = document.getElementById("section-list");
2020-06-17 09:43:21 +00:00
const tabListContainer = document.getElementById("tab-list");
const tabContentContainer = document.getElementById("tabs");
2020-06-19 18:26:43 +00:00
const manager = new TabManager(
sectionListContainer,
tabListContainer,
tabContentContainer
);
2020-06-17 09:43:21 +00:00
2020-06-19 18:26:43 +00:00
sections.forEach((section) => {
manager.createSection(section.name);
section.tabs.forEach((tab) => {
manager.openTab(section.name, tab.page, { icon: tab.icon, text: tab.text });
});
2020-06-17 09:43:21 +00:00
});
2020-06-18 11:54:09 +00:00
2020-06-19 18:26:43 +00:00
// Set first page as active
manager.setActive("Medical", "Guide_to_chemistry");
2020-06-18 11:54:09 +00:00
if ("serviceWorker" in navigator) {
const x = process.env.SUBPATH ? `${process.env.SUBPATH}/sw.js` : "sw.js";
2020-06-18 11:54:09 +00:00
navigator.serviceWorker
.register(x)
.then((registration) => {
console.log("Registration successful, scope is:", registration.scope);
})
.catch((error) => {
console.log("Service worker registration failed, error:", error);
});
}