Skip to content

Commit

Permalink
base2 to base16
Browse files Browse the repository at this point in the history
  • Loading branch information
taisukef committed Dec 11, 2023
1 parent d3eeb0b commit 00f45f1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sample/campus_tabularmap.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ <h1>高専カラム地図</h1>

<script type="module">
import { CSV } from "https://js.sabae.cc/CSV.js";
import { Base2 } from "https://code4fukui.github.io/Base2/Base2.js";
import { Base16 } from "https://code4fukui.github.io/Base16/Base16.js";

const data = await CSV.fetchJSON("../data/kosen_campus.csv");

Expand All @@ -18,13 +20,13 @@ <h1>高専カラム地図</h1>
c.srcElement.classList.toggle("checked");
const item = data.find(i => i.shortname2 == name);
takosen.value = JSON.stringify(item, null, 2);
location.hash = Array.from(c.srcElement.parentElement.childNodes).map(i => i.classList.contains("checked") ? "1" : "0").join("");
location.hash = Base16.encode(Base2.decode(Array.from(c.srcElement.parentElement.childNodes).map(i => i.classList.contains("checked") ? "1" : "0").join("")));
};

const hash = location.hash.substring(1);
if (hash) {
const c = tmap.childNodes[0];
hash.split("").forEach((v, idx) => {
Base2.encode(Base16.decode(hash)).split("").forEach((v, idx) => {
if (v == "1") c.childNodes[idx].classList.add("checked");
});
};
Expand Down

0 comments on commit 00f45f1

Please sign in to comment.