-
Notifications
You must be signed in to change notification settings - Fork 0
/
index_website.html
160 lines (135 loc) · 6.15 KB
/
index_website.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
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
<title>animated intro</title>
<link href="css/style.css" rel="stylesheet">
<script src="https://d3js.org/d3.v5.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js"></script>
<script src="build/startext.js"></script>
</head>
<body>
<aside style="display:none">
<img id="star-texture" src="https://ee2dev.github.io/startext/lib/stars-02.png">
<img id="star-texture-white" src="https://ee2dev.github.io/startext/lib/stars-02w.png">
</aside>
<script>
var myIntro = getMyIntro();
var myChart = startext.chart(myIntro);
myChart = myChart
.background(startext[myIntro.background])
.backgroundColor(myIntro.backgroundColor)
.backgroundImage(myIntro.backgroundImage)
.fontFamily(myIntro.fontFamily)
.explosionStrength(myIntro.explosionStrength)
.transitionSpeed(myIntro.transitionSpeed)
.pause(myIntro.pause)
.replay(myIntro.replay);
d3.select("body")
.append("div")
.attr("class", "chart")
.call(myChart);
function getMyIntro() {
var myIntro = [];
var nextPage;
var nextLine;
var page;
var queryVar;
var pageCounter;
var lineCounter;
page = [];
pageCounter = 0;
lineCounter = 1;
queryVar = decodeURIComponent(getAllUrlParams()["p" + pageCounter + "l" + lineCounter]);
nextPage = (queryVar !== "undefined");
while(nextPage){
nextLine = (queryVar !== "undefined");
console.log(queryVar);
console.log(nextLine);
while (nextLine){
page.push(queryVar);
lineCounter = lineCounter + 1;
queryVar = decodeURIComponent(getAllUrlParams()["p" + pageCounter + "l" + lineCounter]);
nextLine = (queryVar !== "undefined");
console.log(queryVar);
console.log(nextLine);
}
queryVar = getAllUrlParams()["p" + pageCounter + "dl"];
if (queryVar !== undefined) {
page.defaultLine = startext[queryVar];
}
myIntro.push(page);
pageCounter = pageCounter + 1;
lineCounter = 1;
page = [];
queryVar = decodeURIComponent(getAllUrlParams()["p" + pageCounter + "l" + lineCounter]);
nextPage = (queryVar !== "undefined");
}
// options
myIntro.background = decodeURIComponent(getAllUrlParams()["o0b"]);
if (myIntro.background === "COLOR") {
myIntro.backgroundColor = decodeURIComponent(getAllUrlParams()["o0a"]);
} else {
myIntro.backgroundImage = decodeURIComponent(getAllUrlParams()["o0a"]);
}
myIntro.fontFamily = decodeURIComponent(getAllUrlParams()["o1"]);
myIntro.explosionStrength = decodeURIComponent(getAllUrlParams()["o2"]);
myIntro.transitionSpeed = decodeURIComponent(getAllUrlParams()["o3"]);
myIntro.pause = decodeURIComponent(getAllUrlParams()["o4"]);
myIntro.replay = (decodeURIComponent(getAllUrlParams()["o5"]) === "true");
return myIntro;
}
// function from: https://www.sitepoint.com/get-url-parameters-with-javascript/
function getAllUrlParams(url) {
// get query string from url (optional) or window
var queryString = url ? url.split('?')[1] : window.location.search.slice(1);
// we'll store the parameters here
var obj = {};
// if query string exists
if (queryString) {
// stuff after # is not part of query string, so get rid of it
queryString = queryString.split('#')[0];
// split our query string into its component parts
var arr = queryString.split('&');
for (var i=0; i<arr.length; i++) {
// separate the keys and the values
var a = arr[i].split('=');
// in case params look like: list[]=thing1&list[]=thing2
var paramNum = undefined;
var paramName = a[0].replace(/\[\d*\]/, function(v) {
paramNum = v.slice(1,-1);
return '';
});
// set parameter value (use 'true' if empty)
var paramValue = typeof(a[1])==='undefined' ? true : a[1];
// (optional) keep case consistent
// paramName = paramName.toLowerCase();
// paramValue = paramValue.toLowerCase();
// if parameter name already exists
if (obj[paramName]) {
// convert value to array (if still string)
if (typeof obj[paramName] === 'string') {
obj[paramName] = [obj[paramName]];
}
// if no array index number specified...
if (typeof paramNum === 'undefined') {
// put the value on the end of the array
obj[paramName].push(paramValue);
}
// if array index number specified...
else {
// put the value at that index number
obj[paramName][paramNum] = paramValue;
}
}
// if param name doesn't exist yet, set it
else {
obj[paramName] = paramValue;
}
}
}
return obj;
}
</script>
</body>
</html>