Skip to content

Commit

Permalink
remove unused dev stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamcha committed Apr 22, 2024
1 parent e4a29d5 commit 5229c85
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 58 deletions.
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,7 @@
"lint": "eslint src",
"build": "vite build --base=./"
},
"dependencies": {
"@types/node": "^20.12.7",
"@types/service_worker_api": "^0.0.9",
"prettier": "^3.2.5",
"sass": "^1.75.0",
"typescript": "^5.4.5",
"vite": "^5.2.10",
"vite-plugin-pwa": "^0.19.8"
},
"dependencies": {},
"browserslist": [
"last 2 Chrome versions",
"last 2 Firefox versions"
Expand All @@ -30,13 +22,21 @@
"runtimeCaching": [
{
"urlPattern": [
"i"
"i",
""
],
"handler": "cacheFirst"
}
]
},
"devDependencies": {
"@types/node": "^20.12.7",
"@types/service_worker_api": "^0.0.9",
"prettier": "^3.2.5",
"sass": "^1.75.0",
"typescript": "^5.4.5",
"vite": "^5.2.10",
"vite-plugin-pwa": "^0.19.8",
"@eslint/js": "^9.1.1",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
Expand Down
60 changes: 12 additions & 48 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ import { nextAnimationFrame } from "./utils.ts";
import { gotoPage, searchBox } from "./scripts/search.ts";
import { getCurrentPage } from "./scripts/history.ts";

import unknown from "@assets/images/tab-icons/unknown.svg";

// Enable single page mode for developing scripts
// const devSinglePage = ["Medical", "Infections"];
const devSinglePage = null;

async function load() {
const sectionListContainer = document.getElementById("section-list")!;
const tabListContainer = document.getElementById("tab-list")!;
Expand All @@ -21,57 +15,27 @@ async function load() {
);
manager.setLoading(true);

// De-comment to disable caching and force processing
// manager.cacheEnabled = false;

await nextAnimationFrame();

// Add loading "bar"
const spinnerContainer = document.querySelector("#tabs > .speen")!;
const icons = document.createElement("div");
icons.className = "loading-icons";

let promises: Promise<void>[] = [];
if (devSinglePage != null) {
manager.createSection(devSinglePage[0]);
promises = [manager.openTab(devSinglePage[0], devSinglePage[1], {})];
} else {
sections.forEach((section) =>
section.tabs.forEach((tab) => {
const iconElement = document.createElement("img");
iconElement.dataset.tab = tab.page;
iconElement.src = tab.icon || unknown;
iconElement.title = tab.page.replace(/_/gi, " ");
icons.appendChild(iconElement);
}),
);
spinnerContainer.appendChild(icons);
const promises = sections.flatMap((section) => {
manager.createSection(section.name);

promises = sections.flatMap((section) => {
manager.createSection(section.name);

return section.tabs.map(async (tab) => {
// Load page
await manager.openTab(section.name, tab, {});
// Remove icon from loading
icons.querySelector(`img[data-tab="${tab.page}"]`)?.remove();
});
return section.tabs.map(async (tab) => {
// Load page
await manager.openTab(section.name, tab, {});
});
}
});

Promise.all(promises).then(() => {
// Remove app-wide loading
manager.setLoading(false);
if (devSinglePage) {
manager.setActive(devSinglePage[1]);
} else {
const { path, hash } = getCurrentPage();

// Try to open page from URL, open landing page if fail
if (!gotoPage(path, hash)) {
manager.setActive("$Welcome");
manager.showSection("Medical");
}
const { path, hash } = getCurrentPage();

// Try to open page from URL, open landing page if fail
if (!gotoPage(path, hash)) {
manager.setActive("$Welcome");
manager.showSection("Medical");
}
});
}
Expand Down

0 comments on commit 5229c85

Please sign in to comment.