-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
45 lines (40 loc) · 1.52 KB
/
index.js
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
39
40
41
42
43
44
45
import { dispatch } from './state/state-manager.js';
import { decodeStores, decodeLocations, decodeStoreTypes } from './data/dataDecoder.js';
import { loadStoresAction, loadLocationsAction, loadStoreTypesAction } from './state/actions.js';
import { decodeRoute } from './history.js';
import './components/stores-list.js';
import './components/stores-map.js';
import './components/search-box.js';
import './components/results-number.js';
import './components/filter-panel.js';
import './components/store-details.js';
import './components/search-opener.js';
import './components/left-panel.js';
fetch('data/stores.json')
.then((response) => response.json())
.then((storesJson) => {
const stores = decodeStores(storesJson);
dispatch(loadStoresAction(stores));
});
fetch('data/store-types.json')
.then((response) => response.json())
.then((storeTypesJson) => {
const storeTypes = decodeStoreTypes(storeTypesJson);
dispatch(loadStoreTypesAction(storeTypes));
});
fetch('data/locations.json')
.then((response) => response.json())
.then((locationsJson) => {
const locations = decodeLocations(locationsJson);
dispatch(loadLocationsAction(locations));
});
decodeRoute();
document.body.addEventListener('keydown', function(ev) {
if (ev.keyCode === 9) {
document.body.classList.add('keyboardNavigation');
}
});
document.body.addEventListener('click', function(ev) {
document.body.classList.remove('keyboardNavigation');
})
window.onpopstate = decodeRoute;