forked from margondaselatan/IndieValues
-
Notifications
You must be signed in to change notification settings - Fork 0
/
results.html
231 lines (211 loc) · 9.59 KB
/
results.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<head>
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:400,700" rel="stylesheet">
<link href='style.css' rel='stylesheet' type='text/css'>
<title>IndieValues Results</title>
<link rel="icon" type="x-icon" href="icon.png">
<link rel="shortcut icon" type="x-icon" href="icon.png">
<meta charset="utf-8">
<script>
version = "Test Edition #1" //Remember to update this before making changes to the test itself!
</script>
</head>
<script type="application/javascript"
src="members.js">
</script>
<body>
<h1>IndieValues</h1>
<hr>
<h1>Results</h1>
<h2>Popularity Axis: <span class="weight-300" id="popularity-label"></span></h2>
<div class="axis">
<img id="img-obscure" src="value_images/obscure.png" height="128pt"/>
<div class="bar obscure" id="bar-obscure"><div class="text-wrapper" id="obscure"></div></div>
<div class="bar mainstream" id="bar-mainstream"><div class="text-wrapper" id="mainstream"></div></div>
<img id="img-mainstream" src="value_images/mainstream.png" height="128pt"/>
</div>
<h2>Era Axis: <span class="weight-300" id="periodic-label"></span></h2>
<div class="axis">
<img id="img-modern" src="value_images/modern.png" height="128pt"/>
<div class="bar modern" id="bar-modern"><div class="text-wrapper" id="modern"></div></div>
<div class="bar oldies" id="bar-oldies"><div class="text-wrapper" id="oldies"></div></div>
<img id="img-oldies" src="value_images/oldies.png" height="128pt"/>
</div>
<h2>Compositional Axis: <span class="weight-300" id="compositional-label"></span></h2>
<div class="axis">
<img id="img-melody" src="value_images/melody.png" height="128pt"/>
<div class="bar melody" id="bar-melody"><div class="text-wrapper" id="melody"></div></div>
<div class="bar rhythm" id="bar-rhythm"><div class="text-wrapper" id="rhythm"></div></div>
<img id="img-rhythm" src="value_images/rhythm.png" height="128pt"/>
</div>
<h2>Innovation Axis: <span class="weight-300" id="innovation-label"></span></h2>
<div class="axis">
<img id="img-conventional" src="value_images/conventional.png" height="128pt"/>
<div class="bar conventional" id="bar-conventional"><div class="text-wrapper" id="conventional"></div></div>
<div class="bar experimental" id="bar-experimental"><div class="text-wrapper" id="experimental"></div></div>
<img id="img-experimental" src="value_images/experimental.png" height="128pt"/>
</div>
<center>
<h2>Closest Match:</h2>
</center>
<div class="match-grid">
<div id="match-im">
<img class="smpimg" id="smpimg-im">
</div>
<h2 id="member-label-h">
<span class="weight-300" id="member-label"></span>
</h2>
</div>
<br/>
<hr/>
<img src="" id="banner">
<button class="button" onclick="location.href='index.html';">Back</button> <br>
<script>
function getQueryVariable(variable)
{
var query = window.location.search.substring(1)
var vars = query.split("&")
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=")
if(pair[0] == variable) {return pair[1]}
}
return(NaN);
}
function setBarValue(name, value) {
innerel = document.getElementById(name)
outerel = document.getElementById("bar-" + name)
outerel.style.width = (value + "%")
innerel.innerHTML = (value + "%")
if (innerel.offsetWidth + 20 > outerel.offsetWidth) {
innerel.style.visibility = "hidden"
}
}
poplArray = ["Underground","Obscure","Less Popular","Both Mainstream and Obscure","More Popular","Mainstream","Trendy"]
periArray = ["Ancient","Old-Timer Music","Somewhat Old Music","Both Oldies and Modern","Slightly New Music","Modern","Brand New Releases"]
compArray = ["Melody-Dominated","Melodic","Emphasis on Melody","Balanced","Emphasis on Rhythm","Rhythm","Rhythm-Dominated"]
inovArray = ["Avant-Garde","Experimental","Innovative","Neutral","Easy Listening","Conventional","Formulaic"]
function setLabel(val,ary) {
if (val > 100) { return "" } else
if (val > 80) { return ary[0] } else
if (val > 70) { return ary[1] } else
if (val > 55) { return ary[2] } else
if (val >= 45) { return ary[3] } else
if (val >= 30) { return ary[4] } else
if (val >= 20) { return ary[5] } else
if (val >= 0) { return ary[6] } else
{ return "" }
}
obscure = getQueryVariable("p")
oldies = getQueryVariable("e")
melody = getQueryVariable("c")
experimental = getQueryVariable("i")
mainstream = (100 - obscure ).toFixed(1)
modern = (100 - oldies ).toFixed(1)
rhythm = (100 - melody ).toFixed(1)
conventional = (100 - experimental ).toFixed(1)
setBarValue("mainstream", mainstream)
setBarValue("obscure", obscure)
setBarValue("oldies", oldies)
setBarValue("modern", modern)
setBarValue("melody", melody)
setBarValue("rhythm", rhythm)
setBarValue("conventional", conventional)
setBarValue("experimental", experimental)
document.getElementById("popularity-label").innerHTML = setLabel(obscure, poplArray)
document.getElementById("periodic-label").innerHTML = setLabel(oldies, periArray)
document.getElementById("compositional-label").innerHTML = setLabel(melody, compArray)
document.getElementById("innovation-label").innerHTML = setLabel(experimental, inovArray)
member = ""
membdist = Infinity
for (var i = 0; i < members.length; i++) {
dist = 0
dist += Math.pow(Math.abs(members[i].stats.popl - obscure), 2)
dist += Math.pow(Math.abs(members[i].stats.comp - melody), 2)
dist += Math.pow(Math.abs(members[i].stats.peri - oldies), 1.73856063)
dist += Math.pow(Math.abs(members[i].stats.inov - experimental), 1.73856063)
if (dist < membdist) {
member = members[i].name
membdist = dist
}
}
imgSrc = `member_images/circ_${member.substring(0, 3).toLowerCase()}.png`
document.getElementById("smpimg-im").src = imgSrc;
document.getElementById("member-label").innerHTML = member
function createImage(src, x, y, w, h) {
img = new Image ()
img.src = src
img.onLoad = function() {
ctx.drawImage(img, x, y, w, h)
}
}
window.onload = function() {
var c = document.createElement("canvas")
var ctx = c.getContext("2d")
c.width = 800;
c.height = 650;
ctx.fillStyle = "#EEEEEE"
ctx.fillRect(0,0,800,650);
img = document.getElementById("img-obscure")
ctx.drawImage(img, 20, 170, 100, 100);
img = document.getElementById("img-mainstream")
ctx.drawImage(img, 680, 170, 100, 100)
img = document.getElementById("img-modern")
ctx.drawImage(img, 20, 290, 100, 100)
img = document.getElementById("img-oldies")
ctx.drawImage(img, 680, 290, 100, 100)
img = document.getElementById("img-melody")
ctx.drawImage(img, 20, 410, 100, 100)
img = document.getElementById("img-rhythm")
ctx.drawImage(img, 680, 410, 100, 100)
img = document.getElementById("img-conventional")
ctx.drawImage(img, 20, 530, 100, 100)
img = document.getElementById("img-experimental")
ctx.drawImage(img, 680, 530, 100, 100)
ctx.fillStyle="#222222"
ctx.fillRect(120, 180, 560, 80)
ctx.fillRect(120, 300, 560, 80)
ctx.fillRect(120, 420, 560, 80)
ctx.fillRect(120, 540, 560, 80)
ctx.fillStyle="#ff9800"
ctx.fillRect(120, 184, 5.6*obscure-2, 72)
ctx.fillStyle="#03a9f4"
ctx.fillRect(682-5.6*mainstream, 184, 5.6*mainstream-2, 72)
ctx.fillStyle="#f44336"
ctx.fillRect(120, 304, 5.6*modern-2, 72)
ctx.fillStyle="#00897b"
ctx.fillRect(682-5.6*oldies, 304, 5.6*oldies-2, 72)
ctx.fillStyle="#8bc34a"
ctx.fillRect(120, 424, 5.6*melody-2, 72)
ctx.fillStyle="#9c27b0"
ctx.fillRect(682-5.6*rhythm, 424, 5.6*rhythm-2, 72)
ctx.fillStyle="#ffeb3b"
ctx.fillRect(120, 544, 5.6*conventional-2, 72)
ctx.fillStyle="#3f51b5"
ctx.fillRect(682-5.6*experimental, 544, 5.6*experimental-2, 72)
ctx.fillStyle="#222222"
ctx.font="700 80px Montserrat"
ctx.textAlign="left"
ctx.fillText("IndieValues", 20, 90)
ctx.font="50px Montserrat"
ctx.fillText(member, 20, 140)
ctx.textAlign="left"
if (obscure > 30) {ctx.fillText(obscure + "%", 130, 237.5)}
if (modern > 30) {ctx.fillText(modern + "%", 130, 357.5)}
if (melody > 30) {ctx.fillText(melody + "%", 130, 477.5)}
if (conventional > 30) {ctx.fillText(conventional + "%", 130, 597.5)}
ctx.textAlign="right"
if (mainstream > 30) {ctx.fillText(mainstream + "%", 670, 237.5)}
if (oldies > 30) {ctx.fillText(oldies + "%", 670, 357.5)}
if (rhythm > 30) {ctx.fillText(rhythm + "%", 670, 477.5)}
if (experimental > 30) {ctx.fillText(experimental + "%", 670, 597.5)}
ctx.font="300 30px Montserrat"
ctx.fillText("s.id/indievalues", 780, 60)
ctx.fillText(version, 780, 90)
ctx.textAlign="center"
ctx.fillText("Popularity Axis: " + document.getElementById("popularity-label").innerHTML, 400, 175)
ctx.fillText("Era Axis: " + document.getElementById("periodic-label").innerHTML, 400, 295)
ctx.fillText("Compositional Axis: " + document.getElementById("compositional-label").innerHTML, 400, 415)
ctx.fillText("Innovation Axis: " + document.getElementById("innovation-label").innerHTML, 400, 535)
document.getElementById("banner").src = c.toDataURL();
}
</script>
</body>