index.tsx
⎇
Raw
1/* @refresh reload */
2import { render } from "solid-js/web";
3import "./style.css";
4
5import App from "./App";
6import { loadDataFromDB } from "./offline";
7
8const root = document.getElementById("root");
9if (!(root instanceof HTMLElement)) {
10 throw new Error(
11 "Root element not found. Did you forget to add it to your index.html? Or maybe the id attribute got misspelled?",
12 );
13}
14
15function hasTouch() {
16 return (
17 "ontouchstart" in document.documentElement ||
18 navigator.maxTouchPoints > 0 ||
19 ("msMaxTouchPoints" in navigator &&
20 typeof navigator.msMaxTouchPoints === "number" &&
21 navigator.msMaxTouchPoints > 0)
22 );
23}
24
25if (hasTouch()) {
26 // remove all the :hover stylesheets
27 try {
28 // prevent exception on browsers not supporting DOM styleSheets properly
29 for (const si in document.styleSheets) {
30 const styleSheet = document.styleSheets[si];
31 if (!styleSheet.cssRules) continue;
32
33 for (let ri = styleSheet.cssRules.length - 1; ri >= 0; ri--) {
34 const rule = styleSheet.cssRules[ri];
35 if (!("selectorText" in rule) || typeof rule.selectorText !== "string" || !rule.selectorText) continue;
36
37 if (rule.selectorText.match(":hover")) {
38 styleSheet.deleteRule(ri);
39 }
40 }
41 }
42 } catch {}
43}
44
45loadDataFromDB()
46 .then(() => {
47 root.innerHTML = "";
48 render(() => <App />, root);
49 })
50 .catch((e) => {
51 root.innerHTML = e.toString();
52 });
53