forked from LeftValues/leftvalues.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresults.html
350 lines (315 loc) · 17.1 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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="format-detection" content="telephone=no">
<title>FemScale - Feminist Perspective Scale Online</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@100;300;400;500;700;900&display=swap" rel="stylesheet">
<link href='reset.css' rel='stylesheet' type='text/css'>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.5.1/chart.min.js"></script>
<link href='style.css' rel='stylesheet' type='text/css'>
<script type="application/javascript" src="ideologies.js"></script>
<link rel="icon" type="image/png" href="favicon/icon-16x16.png" sizes="16x16" />
<link rel="icon" type="image/png" href="favicon/icon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="favicon/icon-192x192.png">
<link rel="apple-touch-icon" type="image/png" href="favicon/apple-touch-icon-180x180.png">
</head>
<body>
<h1 class="top">FemScale</h1>
<select id="langPicker"></select>
<hr>
<h1 data-i18n="result_h1">Results</h1>
<div class="info_wrapper">
<div class="section-wrapper">
<h2 data-i18n="result_h2_match">Closest Match:</h2>
<div class="text-wrapper">
<h3 id="ideology-label" class="ideology_result">loading</h3>
<p data-i18n="result_p">Send these results by copying and pasting the URL or using the download link below!</p>
<div class="share">
<input id="copyTarget" type="text" value="https://femscale.github.io" readonly> <button id="btnCopyurl" onclick="copyToClipboard()">Copy</button> <p id="twitter-share-button"><a href="https://twitter.com/share?url=https://femscale.github.io&text=I%20am%20a%20feminist%21%20What%20about%20you%3F&hashtags=femscale" class="twitter-share-button">Tweet!</a></p>
</div>
</div>
</div>
</div>
<div class="result_wrapper">
<div class="nopadding_section-wrapper">
<div class="image-wrapper">
<div class="share">
<a id="btnDownload" download="femscale_results.png" href="">Download</a>
</div>
<canvas id="myChart"></canvas>
<p class="ref" data-i18n="result_p_ref">Values for mean subscale scores ("avg.") are cited from Table 4, Column "Nonstudent sample" published in the following:</p><span class='reference'>Henley, N. M., Meng, K., Brien, D. O., McCarthy, W. J., Sockloskie, R. J. (1998). Developing a scale to measure the diversity of feminist attitudes. Psychology of Women Quarterly, 22, 317–348. <a href='https://doi.org/10.1111/j.1471-6402.1998.tb00158.x'>https://doi.org/10.1111/j.1471-6402.1998.tb00158.x</a></span>
</div>
</div>
<div class="section-wrapper">
<div class="text-wrapper">
<p style="font-style: italic" data-i18n="coming_soon">Short desriptions for each perspectives coming soon!</p>
<p id="ideodesc-label"></p>
</div>
</div>
</div>
<div class="result_wrapper">
<div class="section-wrapper">
<h2 data-i18n="result_h2_next_matches">Next closest matches</h2>
<div class="text-wrapper">
<p data-i18n="result_p_next_matches">With your closest match as 100% and farthest as 0%, here is how closely you matched the other ideologies. Want to know more? Check out our <a href='additional_info.html'>Additional Info</a> page!</p>
<p><ol id="next-matches"></ol></p>
</div>
</div>
</div>
<hr>
<div class="index_wrapper">
<div class="nopadding_section-wrapper">
<h2 data-i18n="result_h2_feedback">Feedback</h2>
<div class="text-wrapper">
<p data-i18n="result_p_feedback">FemScale respects your privacy. However, we still want a way to get your feedback. If you can help us, please fill out <a href='https://forms.gle/VfKqtp6vNMKBMoRm8'>this form</a> (English and Japanese available)! <b>We will ask you to paste the Results URL (or type in the Results by hand).</b> Also, please help us improve the quiz at our <a href='https://github.com/femscale/femscale.github.io'>GitHub Page</a>!</p>
</div>
</div>
<div class="section-wrapper">
<h2 data-i18n="result_h2_otherquiz">Other political quizzes</h2>
<div class="text-wrapper">
<p data-i18n="result_p_otherquiz">Want to know more about your political views and values? Check out <a href='https://leftvalues.github.io/'>LeftValues</a> if you are left-leaning, and <a href='https://rightvaluestest.github.io'>RightValues</a> if you are right-leaning. Also, don't forget to check out the original <a href='https://8values.github.io/'>8values</a>!</p>
</div>
</div>
</div>
<div class="result_wrapper">
<div class="section-wrapper">
<h2 data-i18n="index_h2_notice">Notice</h2>
<div class="text-wrapper">
<p data-i18n="notice_important">All questions are copyrighted by Henley (1989, 1997). <b>We are not affiliated, associated, authorized, endorsed by, or in any way officially connected with the copyright holder</b>. We use this Scale solely to educate those who are interested in feminism and its values.</p>
<p data-i18n="notice_before">The following notice is by Henley, the original creator of FPS-2:</p>
<p data-i18n="notice_quote" class="quote">
"The Feminist Perspectives Scale, Copyright 1989, 1997 by Nancy M. Henley. Permission is given for its use, or use of any part of it, without charge, for research and educational purposes only. This scale is expressly not to be used for personnel screening (business, military, academic, or any other type). Anyone with knowledge of its use for such screening is urged to contact N. M. Henley, Psychology Department, UCLA, Los Angeles, CA 90024-1563, giving date, user, and any other pertinent information known. This notice must appear on all copies of the scale reproduced."</p>
</div>
</div>
</div>
<HR>
<section>
<button data-i18n="result_back" class="button start" onclick="location.href='index.html';">Restart</button><br>
</section>
<!-- JavaScript for the test itself -->
<script type="application/javascript" src="i18n.js"></script>
<script>
/* global i18n, loadTranslation, ideologies */
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 getIdeologyNameByIndex (name) {
return i18n.getString(`ideology_${name}_name`)
};
function getIdeologyDescriptionByIndex (name) {
return i18n.getString(`ideology_${name}_desc`)
};
function getAxisNameByIndex (name) {
return i18n.getString(`axis_${name}`)
};
function tweetText (name) {
return i18n.getString(`tweet_text_${name}`)
};
const conservative = getQueryVariable('a')
const liberal = getQueryVariable('b')
const radical = getQueryVariable('c')
const socialist = getQueryVariable('d')
const cultural = getQueryVariable('e')
const womanism = getQueryVariable('f')
const femscore = (liberal /5 + radical /5 + socialist/5 + cultural/5 + womanism/5).toFixed(2)
const conservative_dev = ((conservative - 32.11) / 9.62 * 10 + 50).toFixed(2)
const liberal_dev = ((liberal - 49.89 ) / 8.31 * 10 + 50).toFixed(2)
const radical_dev = ((radical - 37.29) / 10.67 * 10 + 50).toFixed(2)
const socialist_dev = ((socialist -35.47)/10.11 * 10 + 50).toFixed(2)
const cultural_dev = ((cultural - 37.46)/8.56 *10 + 50).toFixed(2)
const womanism_dev = ((womanism - 43.22)/9.09 * 10 + 50).toFixed(2)
const conservative_henley1998 = ((32.11-10)/60*100).toFixed(2)
const liberal_henley1998 = ((49.89-10)/60*100).toFixed(2)
const radical_henley1998 = ((37.29-10)/60*100).toFixed(2)
const socialist_henley1998 = ((35.47-10)/60*100).toFixed(2)
const cultural_henley1998 = ((37.46-10)/60*100).toFixed(2)
const womanism_henley1998 = ((43.22-10)/60*100).toFixed(2)
const femscore_henley1998 = ((204.59-50)/300*100).toFixed(2)
loadTranslation().then(() => {
let ideology = ''
let ideodesc = ''
const ideologyIndexAndDistance = []
var closestMatch = {}
let index = 0
for (const name of Object.keys(ideologies)) {
let dist = 0
dist += Math.pow(Math.abs(ideologies[name].a - conservative_dev), 2)
dist += Math.pow(Math.abs(ideologies[name].b - liberal_dev), 2)
dist += Math.pow(Math.abs(ideologies[name].c - radical_dev), 2)
dist += Math.pow(Math.abs(ideologies[name].d - socialist_dev), 2)
dist += Math.pow(Math.abs(ideologies[name].e - cultural_dev), 2)
dist += Math.pow(Math.abs(ideologies[name].f - womanism_dev), 2)
// ideologyToDistance[name] = dist
ideologyIndexAndDistance.push({
distance: dist,
name,
index
})
index++
}
ideologyIndexAndDistance.sort(function (a, b) {
return a.distance - b.distance
})
const distances = ideologyIndexAndDistance.map(function (indexAndDistance) {
return indexAndDistance.distance
})
const closestDistance = distances[0]
const farthestDistance = distances[distances.length - 1]
const distanceSpan = farthestDistance - closestDistance
closestMatch = ideologyIndexAndDistance[0]
const closestMatchIdeologyname = getIdeologyNameByIndex(closestMatch.name)
document.getElementById('ideology-label').innerHTML = closestMatchIdeologyname
const current_url = location.href;
const current_url_encoded = encodeURIComponent(current_url);
const tweetTextBefore = tweetText('before');
const tweetTextAfter = tweetText('after');
const tweetTextResult = tweetText('result');
const concatenated_str = tweetTextBefore + closestMatchIdeologyname + tweetTextAfter;
const con_encoded = encodeURIComponent(concatenated_str);
document.getElementById('twitter-share-button').innerHTML = '<a href=\"https://twitter.com/share?url=' + current_url_encoded + '&text=' + con_encoded + '&hashtags=FemScale\">Tweet!</a>';
document.getElementById('ideodesc-label').innerHTML = getIdeologyDescriptionByIndex(closestMatch.name);
const nextMatches = document.getElementById('next-matches')
nextMatches.innerHTML = ideologyIndexAndDistance.slice(1).map(function (indexAndDistance) {
const name = indexAndDistance.name
ideology = getIdeologyNameByIndex(name)
ideodesc = getIdeologyDescriptionByIndex(name)
const relativeDistance = 1 - (indexAndDistance.distance - closestDistance) / distanceSpan;
const relativeDistancePercent = Math.round(relativeDistance * 1000) / 10;
return '<li>' + ideology + ': ' + relativeDistancePercent + '%</li>'
}).join('\n')
var month = new Array();
month= ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep","Oct", "Nov", "Dec"];
let today = new Date();
const dd = String(today.getDate()).padStart(2, '0');
const mm = month[today.getMonth()];
const yy = (today.getFullYear() - 2000);
today = mm + ' ' + dd + ', ' + '\''+yy;
Chart.defaults.font.size = 16;
Chart.defaults.font.family = "'Noto Sans', 'Atkinson Hyperlegible', sans-serif";
Chart.register({
id: 'custom_canvas_background_color',
beforeDraw: (chart) => {
let ctx = chart.canvas.getContext('2d');
ctx.save();
ctx.globalCompositeOperation = 'destination-over';
ctx.fillStyle = '#eee';
ctx.fillRect(0, 0, chart.width, chart.height);
ctx.restore();
}
});
let ctx = document.getElementById('myChart').getContext('2d');
let myChart = new Chart(ctx,{
type: 'radar',
data: {
labels: [['Con: '+ Math.round(conservative)], ['LF: '+ Math.round(liberal)], ['RF: '+ Math.round(radical)], ['SF: '+ Math.round(socialist)], ['CF: '+ Math.round(cultural)], ['Wo: '+ Math.round(womanism)],['FS: '+ Math.round(femscore)]],
datasets: [{
label: 'Your Score',
data: [conservative, liberal, radical, socialist, cultural, womanism, femscore],
fill: true,
backgroundColor: 'rgba(187, 0, 156, 0.4)',
borderColor: 'rgb(187, 0, 156)',
pointBackgroundColor: 'rgb(187, 0, 156)',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: 'rgb(187, 0, 156)'
}, {
label: 'avg.',
data: [conservative_henley1998, liberal_henley1998, radical_henley1998, socialist_henley1998, cultural_henley1998, womanism_henley1998, femscore_henley1998],
fill: false,
borderColor: 'rgb(126, 126, 126)',
pointBackgroundColor: 'rgb(0, 000, 0)',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: 'rgb(126, 126, 126)'
}]
},
options: {
aspectRatio:0.7,
layout: {
padding: 8,
},
responsive: true,
maintainAspectRatio:true,
scales: {
r: {
min: 0,
max: 100,
pointLabels:{
font:{size: 12, weight: 'bold'}
},
ticks: {
stepSize: 20,
backdropColor: '#eee'
}
}
},
plugins: {
legend:{
labels: {
font: {size: 16}
}
},
tooltip:{
mode: 'index',
intersect: false,
/* callbacks:{
title: function(tooltipItem, data) {
return tooltipItem.xLabel;
},
label: function(tooltipItem, data){
return data.datasets[tooltipItem.datasetIndex].label + ': ' + tooltipItem.yLabel;
},
}*/
},
elements: {
line: {
borderWidth: 3
}
},
title: {
display: true,
text: [tweetTextResult + closestMatchIdeologyname + '!', "femscale.github.io"+ ' (' + today + ')'],
font:{size: 25},
},
subtitle: {
display: true,
position: 'bottom',
font:{size: 14},
text: ['Con: ' + getIdeologyNameByIndex("conservative") + ', LF: ' + getIdeologyNameByIndex("liberal-feminist") + ', RF: '+ getIdeologyNameByIndex("radical-feminist")+',', 'SF: '+getIdeologyNameByIndex("socialist-feminist") + ', CF: '+ getIdeologyNameByIndex("cultural-feminist") + ', Wo: '+ getIdeologyNameByIndex("womanism")+',', 'FS: FemScore. avg. based on Henley et al. (1998).'],
}
} //plugins
} //options
}); //myChart
function copyResultURL(){
const inputTarget = document.getElementById('copyTarget');
inputTarget.value = current_url;
}
copyResultURL()
}) // end loadtranslation
document.getElementById("btnDownload").addEventListener('click', function(){
var base64_url = document.getElementById("myChart").toDataURL("image/png");
this.href = base64_url;
});
function copyToClipboard() {
var copyTarget = document.getElementById("copyTarget");
copyTarget.select();
document.execCommand("Copy");
alert("Copied result URL!");
}
</script>
</body>
</html>