-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
38 lines (32 loc) · 1.01 KB
/
index.js
File metadata and controls
38 lines (32 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { html, useState, render } from './src/utils.js';
import cases from './src/algorithms.js';
import Cube from './src/cube.js';
import Nav from './src/nav.js';
let vh = window.innerHeight * 0.01;
document.documentElement.style.setProperty('--vh', `${vh}px`);
const App = () => {
const [route, go] = useState(parseInt(location.search.slice(1)));
let current = cases[route];
return html`
<${Cube} key="cube" case=${current} />
<${Nav} go=${go} route=${route} links=${cases} />
`;
};
render(html` <${App} /> `, document.body);
if ('serviceWorker' in navigator) {
window.addEventListener('load', function () {
navigator.serviceWorker.register('/sw.js').then(
function (registration) {
// Registration was successful
console.log(
'ServiceWorker registration successful with scope: ',
registration.scope
);
},
function (err) {
// registration failed :(
console.log('ServiceWorker registration failed: ', err);
}
);
});
}