-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkirtan.html
108 lines (86 loc) · 3.25 KB
/
kirtan.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
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/[email protected]"></script>
<script src="https://unpkg.com/@jspsych/[email protected]"></script>
<script src="https://unpkg.com/@jspsych/[email protected]"></script>
<script src="https://unpkg.com/@jspsych/[email protected]"></script>
<script src="https://unpkg.com/@jspsych/[email protected]"></script>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/css/jspsych.css" />
<script src="./js/helper.js"></script>
</head>
<body></body>
<script>
var group,stage,participant,session
participant=window.localStorage.getItem('participant')
session=window.localStorage.getItem('session')
group=window.localStorage.getItem('group')
stage=window.localStorage.getItem('stage')
let url= new URL(window.location.href);
let params = new URLSearchParams(url.search);
group=params.get('group')
stage=parseInt(params.get('stage'))
var download=parseInt(params.get('download'))
if(isNaN(download)) download=0
window.localStorage.setItem('kirtan_markers','[]')
var kirtan_markers=[]
if(!stage) stage=2
if(!group) group='M'
window.localStorage.setItem('stage',2)
window.localStorage.setItem('group','M')
console.log(group,stage,participant,session,kirtan_markers)
/* initialize jsPsych */
const jsPsych = initJsPsych({show_progress_bar: true});
let timeline=[]
const preload = {
type: jsPsychPreload,
auto_preload: true
}
timeline.push(preload);
let welcome = {
type: jsPsychHtmlKeyboardResponse,
stimulus: `<h1> Welcome to the experiment.<h1>
<h1 style='color:blue'> Press any key to play the meditative kirtan. </h1>
<ul>
<li>Please close your eyes and try to hear each and every word attentively<li>
<li>Thereafter, You will be asked certain questions</li>
</ul>
`
};
timeline.push(welcome);
let kirtan_file='audio/AgnidevPrabhu2015.mp3'
const trial = {
type: jsPsychAudioKeyboardResponse,
stimulus: kirtan_file,
choices: "NO_KEYS",
prompt:`
<img src="img/speaker.png" alt="Speaker Image" width="200" height="200">
<h1> Close your eyes and listen to Kirtan very attentively`,
post_trial_gap: 1000,
trial_ends_after_audio: true,
on_start: () => {
let temp={timestamp:getTimeInSec(),marker:201}
triggerKeyPress(temp['marker'])
kirtan_markers=addToMarkers(temp,'kirtan_markers')
},
on_finish: ()=>{
let temp={timestamp:getTimeInSec(),marker:202}
triggerKeyPress(temp['marker'])
kirtan_markers=addToMarkers(temp,'kirtan_markers')
}
};
timeline.push(trial);
const end = {
type: jsPsychHtmlKeyboardResponse,
stimulus: ()=>{
window.localStorage.setItem('stage',stage+1)
window.location.href=`exp.html?stage=${stage+1}&group=M`
},
choices: "NO_KEYS",
on_start: () => {
if(download > 0) saveToCsv(kirtan_markers)
},
};
timeline.push(end)
jsPsych.run(timeline);
</script>