-
Notifications
You must be signed in to change notification settings - Fork 48
/
index.html
184 lines (162 loc) · 5.95 KB
/
index.html
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<!DOCTYPE html>
<html lang="en">
<head>
<title>StoryMapJS Embed</title>
<meta charset="utf-8">
<meta name="description" content="StoryMapJS Embed">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<!-- build:css //s3.amazonaws.com/cdn.knightlab.com/libs/storymapjs/latest/css/storymap.css -->
<link rel="stylesheet" href="/build/css/storymap.css">
<!-- endbuild -->
<!-- build:js //s3.amazonaws.com/cdn.knightlab.com/libs/storymapjs/latest/js/storymap-min.js -->
<script type="text/javascript" src="/build/js/storymap.js"></script>
<!-- endbuild -->
<style>
html, body {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
}
</style>
<!-- HTML5 shim, for IE6-8 support of HTML elements--><!--[if lt IE 9]>
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
</head>
<body>
<div id="storymap-embed"></div>
<!-- Google Analytics: don't mess with this stuff -->
<!-- named tracker notes from https://developers.google.com/analytics/devguides/collection/gajs/ -->
<!-- multi-domain tracking notes from https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSite -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-27829802-2', 'knightlab.com'); /* StoryMap Embed analytics only. Not KnightLab broadly */
ga('send', 'pageview');
ga('send', 'event', 'StoryMapJS', 'EmbeddedIn', document.referrer)
</script>
<!-- End Google Analytics -->
<script type="text/javascript">
function parseQuerystring() {
var nvpair = {};
var qs = window.location.search.replace('?', '');
var pairs = qs.split('&');
for(var i = 0; i < pairs.length; i++) {
var p = pairs[i].split('=');
nvpair[p[0]] = p[1];
}
return nvpair;
}
function getScriptPath(scriptname) {
var scriptTags = document.getElementsByTagName('script');
for(var i = 0; i < scriptTags.length; i++) {
if(scriptTags[i].src.match(scriptname)) {
script_path = scriptTags[i].src;
return script_path.split('?')[0].split('/').slice(0, -1).join('/');
}
}
return '';
}
function url_join(url, concat) { // see http://stackoverflow.com/questions/2676178/joining-relative-urls
function build(parts,container) {
for (var i = 0, l = parts.length; i < l; i ++) {
if (parts[i] == '..') {
container.pop();
} else if (parts[i] == '.') {
continue;
} else {
container.push(parts[i]);
}
}
}
var url_parts = [ ];
build(url.split('/'),url_parts);
build(concat.split('/'),url_parts);
return url_parts.join('/');
}
var storymap = null;
var params = parseQuerystring();
var storymap_url = decodeURIComponent(params['url']);
var options = {
script_path: getScriptPath(/storymap(-min)?\.js/),
start_at_slide: 0
};
if(params.hasOwnProperty('start_at_slide')) {
options.start_at_slide = parseInt(params.start_at_slide);
}
function storymap_onload(d) {
trace('embed: storymap data loaded');
if (d && d.storymap) {
if(d.storymap.map_type) {
options.map_type = d.storymap.map_type;
}
if(d.storymap.map_subdomains) {
options.map_subdomains = d.storymap.map_subdomains;
}
if(d.storymap.language) {
options.language = d.storymap.language;
}
var font = "stock:default";
if(d.font_css) {
font = d.font_css;
}
if(font.indexOf("stock:") == 0) {
var font_name = font.split(':')[1];
var base_url = url_join(options.script_path,"../css/fonts");
font = url_join(base_url, "font." + font_name + ".css");
} else if(!font.match('^(http|https|//)')) {
font = url_join(options.script_path, font);
}
VCO.Load.css(font,function(){ trace('font loaded: ' + font);});
storymap = new VCO.StoryMap('storymap-embed', d, options);
}
}
function storymap_getjson() {
if('withCredentials' in new XMLHttpRequest()) {
// Supports cross-domain requests
trace('embed: loading data via XMLHttpRequest');
VCO.getJSON(storymap_url, storymap_onload);
} else if(typeof XDomainRequest !== "undefined") {
// Use IE-specific "CORS" code with XDR
trace('embed: loading data via XDomainRequest');
var xdr = new XDomainRequest();
xdr.onload = function() {
storymap_onload(JSON.parse(xdr.responseText));
};
xdr.onerror = function() { /* doit */ };
xdr.onprogress = function() {};
xdr.open("get", storymap_url);
xdr.send();
}
}
window.onload = function() {
if(storymap_url.match('\\.js$')) {
trace('embed: loading data via script injection');
var loaded = false;
var script = document.createElement("script");
script.type = "text/javascript";
script.src = storymap_url;
script.onload = script.onreadystatechange = function() {
if(!loaded && (!(d = this.readyState) || d == "loaded" || d == "complete")) {
loaded = true;
storymap_onload(storymap_json);
}
}
// document.head not standard before HTML5
var insertionPoint = document.head || document.getElementsByTagName('head').item(0) || document.documentElement.childNodes[0];
insertionPoint.appendChild(script);
} else {
storymap_getjson();
}
}
window.onresize = function(event) {
if(storymap) {
storymap.updateDisplay();
}
}
</script>
</body>
</html>