-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathidu.html
489 lines (434 loc) · 17 KB
/
idu.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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap-slider.min.css">
<link rel="stylesheet" href="css/bootstraphacks.css">
<link rel="stylesheet" href="css/archtools.css">
<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/jspdf.debug.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrap-slider.min.js"></script>
<script src="js/loader.js"></script>
<script src="js/justgage.js"></script>
<script src="js/raphael-2.1.4.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<h2 id="title" class="text-center"></h2><hr>
</div>
<div class="row">
<div id="accordion" class="panel-group col-lg-6">
<h2 class="text-center">Questions</h2>
<div id ="question1" class="panel panel-default question">
<div class="panel-heading" data-toggle="collapse" data-parent="#accordion" href="#collapse1">
<h4 class="panel-title">
<a>Age</a>
</h4>
</div>
<div id="collapse1" class="panel-collapse collapse in" data-parent="#accordion">
<div class="panel-body">
<div id="question1Text"></div>
<br/>
<div class="answersSection">
<input class="answer1 slider" type="text" data-slider-tooltip="hide" data-slider-min="17" data-slider-max="50" data-slider-step="1" data-slider-value="17"/>
<span>Age: <span id="answer1slider">17 or younger</span></span>
</div>
</div>
</div>
</div>
<h3 id ="last6" class="collapse">In the last six months...</h3>
<div id ="question2" class="panel panel-default question collapse">
<div class="panel-heading" data-toggle="collapse" data-parent="#accordion" href="#collapse2">
<h4 class="panel-title">
<a>Methadone Maintenance</a>
</h4>
</div>
<div id="collapse2" class="panel-collapse collapse" data-parent="#accordion">
<div class="panel-body">
<div id="question2Text"></div>
<br/>
<!-- Radio Button answers -->
<div class="answer2 btn-group" data-toggle="buttons">
<label id="answer21" class="btn btn-primary">
<input type="radio" value="Yes"> Yes
</label>
<label id="answer22" class="btn btn-primary">
<input type="radio" value="No"> No
</label>
</div>
</div>
</div>
</div>
<div id ="question3" class="panel panel-default question collapse">
<div class="panel-heading" data-toggle="collapse" data-parent="#accordion" href="#collapse3">
<h4 class="panel-title">
<a>Heroin Use</a>
</h4>
</div>
<div id="collapse3" class="panel-collapse collapse" data-parent="#accordion">
<div class="panel-body">
<div id="question3Text"></div>
<br/>
<!-- Radio Button answers -->
<div class="answer3 btn-group" data-toggle="buttons">
<label id="answer31" class="btn btn-primary">
<input type="radio" value="0"> 0 times
</label>
<label id="answer32" class="btn btn-primary">
<input type="radio" value="1"> 1 or more times
</label>
</div>
</div>
</div>
</div>
<div id ="question4" class="panel panel-default question collapse">
<div class="panel-heading" data-toggle="collapse" data-parent="#accordion" href="#collapse4">
<h4 class="panel-title">
<a>Cocaine Use</a>
</h4>
</div>
<div id="collapse4" class="panel-collapse collapse" data-parent="#accordion">
<div class="panel-body">
<div id="question4Text"></div>
<br/>
<!-- Radio Button answers -->
<div class="answer4 btn-group" data-toggle="buttons">
<label id="answer41" class="btn btn-primary">
<input type="radio" value="0"> 0 times
</label>
<label id="answer42" class="btn btn-primary">
<input type="radio" value="1"> 1 or more times
</label>
</div>
</div>
</div>
</div>
<div id ="question5" class="panel panel-default question collapse">
<div class="panel-heading" data-toggle="collapse" data-parent="#accordion" href="#collapse5">
<h4 class="panel-title">
<a>Sharing Cookers</a>
</h4>
</div>
<div id="collapse5" class="panel-collapse collapse" data-parent="#accordion">
<div class="panel-body">
<div id="question5Text"></div>
<br/>
<!-- Radio Button answers -->
<div class="answer5 btn-group" data-toggle="buttons">
<label id="answer51" class="btn btn-primary">
<input type="radio" value="0"> 0 times
</label>
<label id="answer52" class="btn btn-primary">
<input type="radio" value="1"> 1 or more times
</label>
</div>
</div>
</div>
</div>
<div id ="question6" class="panel panel-default question collapse">
<div class="panel-heading" data-toggle="collapse" data-parent="#accordion" href="#collapse6">
<h4 class="panel-title">
<a>Sharing Needles</a>
</h4>
</div>
<div id="collapse6" class="panel-collapse collapse" data-parent="#accordion">
<div class="panel-body">
<div id="question6Text"></div>
<br/>
<!-- Radio Button answers -->
<div class="answer6 btn-group" data-toggle="buttons">
<label id="answer61" class="btn btn-primary">
<input type="radio" value="0"> 0 times
</label>
<label id="answer62" class="btn btn-primary">
<input type="radio" value="1"> 1 or more times
</label>
</div>
</div>
</div>
</div>
<div id ="question7" class="panel panel-default question collapse">
<div class="panel-heading" data-toggle="collapse" data-parent="#accordion" href="#collapse7">
<h4 class="panel-title">
<a>Shooting Galleries</a>
</h4>
</div>
<div id="collapse7" class="panel-collapse collapse" data-parent="#accordion">
<div class="panel-body">
<div id="question7Text"></div>
<br/>
<!-- Radio Button answers -->
<div class="answer7 btn-group" data-toggle="buttons">
<label id="answer71" class="btn btn-primary">
<input type="radio" value="0"> 0 times
</label>
<label id="answer72" class="btn btn-primary">
<input type="radio" value="1"> 1 or more times
</label>
</div>
</div>
</div>
</div>
</div>
<!--This is the fancy gauge that appears and updates dynamically based off of user input-->
<div class="col-lg-6">
<h2 class="text-center">Results and Recommendations</h2>
<div class="well">
<div id="gauge" class="gauge" style="width:350px; height:280px"></div>
</div>
<h3 class="text-center">Recommended Actions</h3>
<div class="well">
<div id="recommended-actions-display">
<ul>
<li id="recommended-actions"></li>
</ul>
</div>
</div>
</div>
</div>
<br/>
<!--This is the nav bar that goes on the bottmo-->
<nav id="navbar" class="navbar navbar-inverse navbar-fixed-bottom" >
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html"> ARCH Tools</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li><a href="msm.html">MSM</a></li>
<li class="active"><a href="idu.html">IDU</a></li>
<li ><a href="dsc.html">DSC</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a class="download-pdf" href="#"><span class="glyphicon glyphicon-save-file"></span> Save to PDF</a></li>
</ul>
</div>
</div>
</nav>
</div>
</body>
<script type="text/javascript">
$(document).ready(function(){
iduSetup();
});
var score = [0,0];
var subscore = [0,0,0,0,0];
var resultsToTake;
var iduData;
var g = new JustGage({
id: "gauge",
value: 0,
min: 0,
max: 100,
title: "HIV Risk Index",
shadowSize: 5,
shadowOpacity: 0.75,
levelColorsGradient: true
});
/**
* iduSetup - Calls getJSON to load the question text from the JSON file
*
* @return {Nothing} Returns nothing
*/
function iduSetup(){
//loads the json from the file, then sets the questions on the page
$.getJSON("ARCH-TOOLS.json", setIDUPage);
//wait for success
}
// $(".answer3").on("click",function(){
// $("#finish").collapse("show");
// });
/**
* setIDUPage - The thing that actually does the work in setting the html on the page
*
* @param {json} json The json object that was loaded from ARCH-TOOLS.json
* @return {none} Returns nothing
*/
function setIDUPage(json){
//alert("Set page");
iduData = json.tests.IDU;
resultsToTake = json.results.IDU;
$("#title").html(iduData.name);
$("#finish").collapse("hide");
//loop through the questions and set the text
for(var index in iduData.questions){
var question = iduData.questions[index];
var text = question["text"];
var num = question["number"];
//set the question text
$("#question" + num + "Text").html(text);
$("#question" + num).collapse({toggle:false});
}
//show question 1
$("#question1").collapse("show");
//can't do this in a loop, because javascript will assume
//the current value of num, which at the end will be 7
$(".answer1").on("change",function(){
//get the value of what was clicked
var value = $(this).attr("value");
if(value < 30){
score[0] = 38;
}
else if(value >= 30 && value < 40){
score[0] = 24;
}
else if(value > 40 && value < 50){
score[0] = 7;
}
else {
score[0] = 0;
}
setScore(score);
$("#last6").collapse("show");
$("#question2").collapse("show");
});
//hide the results
$("#recommended-actions-display").hide();
$(".answer1").on("change", function() {
var out;
var value = $(".answer1").data('slider').getValue();
if (value == 50){
out = '50 or older';
}
else if (value == 17) {
out = '17 or younger'
}
else {
out = value
}
$("#answer1slider").text(out);
});
$("#answer21").on("click", function(){
score[1] = 0;
setScore(score);
$("#question3").collapse("show");
});
$("#answer22").on("click", function(){
score[1] = 31;
setScore(score);
$("#question3").collapse("show");
});
$("#answer31").on("click", function(){
subscore[0] = 0;
setScore(score);
$("#question4").collapse("show");
});
$("#answer32").on("click", function(){
subscore[0] = 1;
setScore(score);
$("#question4").collapse("show");
});
$("#answer41").on("click", function(){
subscore[1] = 0;
setScore(score);
$("#question5").collapse("show");
});
$("#answer42").on("click", function(){
subscore[1] = 1;
setScore(score);
$("#question5").collapse("show");
});
$("#answer51").on("click", function(){
subscore[2] = 0;
setScore(score);
$("#question6").collapse("show");
});
$("#answer52").on("click", function(){
subscore[2] = 1;
setScore(score);
$("#question6").collapse("show");
});
$("#answer61").on("click", function(){
subscore[3] = 0;
setScore(score);
$("#question7").collapse("show");
});
$("#answer62").on("click", function(){
subscore[3] = 1;
setScore(score);
$("#question7").collapse("show");
});
$("#answer71").on("click", function(){
subscore[4] = 0;
setScore(score);
});
$("#answer72").on("click", function(){
subscore[4] = 1;
setScore(score);
});
setupSliders();
}
/**
* setScore - Sets the score on the gauge, which will update it with a new number
*
* @param {int} val The score to update the gauge to
* @return {none} Returns nothing
*/
function setScore(val){
var total = score[0] + score[1];
var sub_total = 0;
for (var i = 0, len = subscore.length; i < len; i++) {
sub_total += subscore[i];
}
switch (sub_total) {
case 1:
total += 7;
break;
case 2:
total += 21;
break;
case 3:
total += 24;
break;
case 4:
total += 24;
break;
case 5:
total += 31;
break;
case 0:
default:
break;
}
g.refresh(total);
var actionToDisplay = resultsToTake[">45"];
if(total <= 45){
actionToDisplay = resultsToTake["<45"];
}
$("#recommended-actions-display").show();
$("#recommended-actions").html(actionToDisplay);
}
$(".download-pdf").on("click",function(){
$("#gauge").find("text")[1].style.fontSize = "125px";
$("#navbar").addClass("collapse");
var pdf = new jsPDF('p', 'pt', 'letter');
pdf.addHTML($('document')[0], function () {
pdf.save('Test.pdf');
});
$("#navbar").removeClass("collapse");
$("#gauge").find("text")[1].style.fontSize = "49px";
});
/**
* setupSliders - Initializes the sliders used on this page
*
* @return {none} Returns nothing
*/
function setupSliders() {
$('.answer1').slider({
formatter: function(value) {
if (value == 60)
return 'Age: 60+'
return 'Age: ' + value;
}
});
}
</script>
</html>