-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathindex.js
More file actions
45 lines (40 loc) · 1.01 KB
/
index.js
File metadata and controls
45 lines (40 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
39
40
41
42
43
44
45
// shims
require('document-register-element')
require('./src/ua')
require('./src/ios-prevent-body-scroll')
// analytics
var gaid = process.env.GOOGLE_ANALYTICS
window.GoogleAnalyticsObject = 'GoogleAnalytics'
window.GoogleAnalytics = function () {
window.GoogleAnalytics.q.push(arguments)
}
GoogleAnalytics.q = []
GoogleAnalytics.l = 1 * new Date()
GoogleAnalytics('create', gaid, 'auto')
if (gaid) {
var script = document.createElement('script')
script.async = 1
script.src = 'https://www.google-analytics.com/analytics.js';
document.body.appendChild(script)
}
// custom elements
require('./src/chart')
require('./src/search')
require('./src/info-card')
require('./src/blocks')
var router = require('uri-router')
var elements = [
document.querySelector('x-chart'),
document.querySelector('x-search'),
document.querySelector('x-info-card')
]
router({
routes: [
['.*', function (uri) {
elements.forEach(function (el) {
el.show(uri)
GoogleAnalytics('send', 'pageview')
})
}]
]
})