Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Commit

Permalink
chore: dry the code
Browse files Browse the repository at this point in the history
  • Loading branch information
lishaduck committed Nov 17, 2023
1 parent ced5426 commit 6d84251
Show file tree
Hide file tree
Showing 9 changed files with 211 additions and 347 deletions.
33 changes: 17 additions & 16 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,47 @@
<title>PHS Map</title>
</head>

<body onload="startApp()" class="lightmodebg">
<header class="w3-container w3-theme w3-padding-16" id="myHeader">
<body onload="window.startApp()" class="lightmodebg">
<header class="w3-container w3-theme w3-padding-16" id="my-header">
<!-- Side Navigation -->
<nav id="my-sidenav" class="sidenav">
<a
aria-label="close navigation"
href="javascript:void(0)"
class="closebtn no-bounce colored-a font-36px"
onclick="closeNav()"
onclick="window.toggleNav(false)"
>
<i class="fa-solid fa-xmark"></i>
</a>
<p></p>
<button
id="darkModeButton"
onclick="darkMode()"
onclick="window.toggleDarkMode()"
class="smallbutton w3-button w3-theme"
>
Dark Mode
</button>
<p></p>
<button
class="clearDataButton smallbutton w3-button w3-theme"
onclick="clearAll()"
onclick="window.clearAll()"
>
Clear All Site Data
</button>
<p></p>
<div class="no-bounce align-centered"></div>
</nav>

<i class="fa-solid fa-bars" onclick="openNav()"></i>
<span onclick="window.toggleNav(true)">
<i class="fa-solid fa-bars"></i>
</span>

<div class="w3-center">
<h1 class="w3-animate-top phs">PHS</h1>
<h5 id="gradeLvl" class="w3-large w3-animate-top"></h5>
<h2 class="w3-xxxlarge w3-animate-left">Treasure Map</h2>
<h2 class="lgreen w3-xxlarge w3-animate-left">Schedules</h2>
</div>
<a class="no-bounce colored-a" href="#myFooter" aria-label="Go down!">
<a class="no-bounce colored-a" href="#my-footer" aria-label="Go down!">
<span class="w3-xlarge">
<i class="fa-solid fa-circle-chevron-down"></i>
</span>
Expand Down Expand Up @@ -83,14 +84,14 @@ <h2 class="lgreen w3-xxlarge w3-animate-left">Schedules</h2>
<div class="item">
<canvas id="my-canvas"></canvas>
</div>
<button id="lvl0" onclick="lvl0()">Level 0</button>
<button id="lvl1" onclick="lvl1()">Level 1</button>
<button id="lvl2" onclick="lvl2()">Level 2</button>
<button id="lvl0" onclick="window.lvl(0)">Level 0</button>
<button id="lvl1" onclick="window.lvl(1)">Level 1</button>
<button id="lvl2" onclick="window.lvl(2)">Level 2</button>
<a
id="download"
download="PHS-Map.jpg"
href=""
onclick="downloadImg(this);"
onclick="window.downloadImg(this);"
>
Download Current Map
</a>
Expand All @@ -104,7 +105,7 @@ <h3>How to use!</h3>
<button
class="lime plusbuttonsml add"
aria-label="add"
onclick="addProf()"
onclick="window.addProf()"
>
<i class="fa-solid fa-plus"></i>
</button>
Expand Down Expand Up @@ -142,17 +143,17 @@ <h3>How to use!</h3>
<button
class="lime plusbutton add"
aria-label="add"
onclick="addProf()"
onclick="window.addProf()"
>
<i class="fa-solid fa-plus"></i>
</button>
</div>
</div>
<footer
class="footer w3-container w3-theme-dark w3-padding-16"
id="myFooter"
id="my-footer"
>
<a class="no-bounce colored-a" href="#myHeader" aria-label="Go up!">
<a class="no-bounce colored-a" href="#my-header" aria-label="Go up!">
<span class="w3-xlarge">
<i class="fa-solid fa-circle-chevron-up"></i>
</span>
Expand Down
13 changes: 13 additions & 0 deletions src/data/data-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
type Lvl = 1 | 2 | 0;
const Levels = { one: 1, two: 2, zero: 0 } as const;
type Room = readonly [...Coords, Lvl];
type StairList = Record<number, Coords>;
type Level = number[][];
type Coords = readonly [number, number];
type Building = Record<string, Room>;
type Profile = [...[string, string]];
type Profiles = [null?, ...(string | string[])[]];
type ProfilesList = [Profiles?, ...Profile[]];

export type { Lvl, Room, StairList, Level, ProfilesList };
export { Levels, type Building };
4 changes: 3 additions & 1 deletion src/data/level0.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const level0: number[][] = [
import type { Level } from "./data-types";

export const level0: Level = [
[
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Expand Down
4 changes: 3 additions & 1 deletion src/data/level1.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const level1: number[][] = [
import type { Level } from "./data-types";

export const level1: Level = [
[
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Expand Down
4 changes: 3 additions & 1 deletion src/data/level2.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const level2: number[][] = [
import type { Level } from "./data-types";

export const level2: Level = [
[
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Expand Down
4 changes: 3 additions & 1 deletion src/data/rooms.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const rooms: Record<string, readonly [number, number, number]> = {
import type { Building } from "./data-types";

export const rooms: Building = {
H100: [68, 12, 1],
H102: [58, 8, 1],
H103: [58, 19, 1],
Expand Down
6 changes: 4 additions & 2 deletions src/data/stairs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const stairs: Record<number, readonly [number, number]> = {
import type { StairList } from "./data-types";

const stairs: StairList = {
0: [23, 13],
1: [63, 16],
2: [103, 16],
Expand All @@ -9,7 +11,7 @@ const stairs: Record<number, readonly [number, number]> = {
7: [92, 121],
} as const;

const btmStairs: Record<number, readonly [number, number]> = {
const btmStairs: StairList = {
0: [90, 154],
1: [71, 154],
};
Expand Down
Loading

0 comments on commit 6d84251

Please sign in to comment.