-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathclient.js
103 lines (90 loc) · 2.39 KB
/
client.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
'use strict';
import navBar from "./utils/navBar";
import React from "react";
import { render } from "react-dom";
import { Provider } from "react-redux";
import Store from "./apps/Programmes/Store";
import TicketButton from './apps/TicketButton';
import Programmes from "./apps/Programmes/Programmes";
import { extractSort, composeSort, byMoment, byString } from './utils/helperFuncs'
import langs from "../data/langs";
import schedule from "../data/schedule";
import speakers from "../data/speakers";
import sponsors from "../data/sponsors";
import timeLengths from "../data/timeLengths";
import topics from "../data/topics";
import venues from "../data/venues";
navBar();
let ticketDiv = document.getElementById('ticket');
if ((typeof ticketDiv !== "undefined") && (ticketDiv !== null)) {
render((
<TicketButton
className="btn btn-lg btn-hkosc button-front-mobile-ticket"
target="_blank"
href="https://hkoscon2016.eventbrite.com/?aff=website" />
),
ticketDiv
);
}
// translate data into array that's suitable for
// store to filter
function topicStoreAll(data = {topics: {}}) {
let all = [];
for (let id in data.topics) {
let topic = topics[id];
all.push({
topic,
category: [topic.category],
target_audience: topic.target_audience,
level: topic.level
});
}
return all;
}
// mapStoreData maps data to store object
// with the help of the mapAll function
// to translate `topics` to `all`
function mapStoreData(mapAll, data) {
// helps to extract attributes inside variables
// for sorting
const extractor = (item) => {
return item.topic || {};
};
// sort all items in data by its
// .topic.start and .topic.venue values
const all = mapAll(data).sort(
extractSort(extractor)(composeSort(
byMoment('start', 'desc'),
byString('venue')
))
);
return {
data,
all,
filters: {},
attributes: {
filterShow: false
},
display: all
};
}
// map all useful data to store as `data`
const store = Store(mapStoreData(topicStoreAll, {
langs,
schedule,
speakers,
sponsors,
topics,
timeLengths,
venues
}));
const timetableDiv = document.getElementById('timetable');
if ((typeof timetableDiv !== "undefined") && (timetableDiv !== null)) {
render((
<Provider store={store}>
<Programmes/>
</Provider>
),
timetableDiv
);
}