-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathjspsych-mouseview-start.js
83 lines (71 loc) · 2.67 KB
/
jspsych-mouseview-start.js
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
/*
* jspsych-mouseview-start
* Alex Anwyl-Irvine
*
* Mouseview.js Start overlay and tracking plugin
* documentation: www.github.com/u01ai11/MouseView.js
*/
jsPsych.plugins["Mouseview-Start"] = (function() {
var plugin = {};
plugin.info = {
name: "Mouseview-Start",
parameters: {
aperture_size: {
type: jsPsych.plugins.parameterType.STRING, // BOOL, STRING, INT, FLOAT, FUNCTION, KEYCODE, SELECT, HTML_STRING, IMAGE, AUDIO, VIDEO,
default: "5%",
description: "The percentage size of the view-window for mouse tracking"
},
aperture_gauss: {
type: jsPsych.plugins.parameterType.INT,
default: 10,
description: "The SD of the gaussian blur for edge of the overlay apperture"
},
overlay_colour: {
type: jsPsych.plugins.parameterType.STRING,
default: "Black",
description: "The colour of the obsfucation overlay"
},
overlay_alpha: {
type: jsPsych.plugins.parameterType.FLOAT,
default: 0.8,
description: "The transparancy from 0-1 of the obverlay"
},
overlay_gaussian: {
type: jsPsych.plugins.parameterType.INT,
default: 20,
description: "The SD of the gaussian blur for the content underneath the overlay"
},
overlay_gaussian_update: {
type: jsPsych.plugins.parameterType.INT,
default: 500,
description: "The millisecond interval to wait for recapturing underneath for the blurring"
}
}
}
plugin.trial = function(display_element, trial) {
// define callback for when overlay complete
var on_complete = () => {
var trial_data = {
window_h: mouseview.params.overHeight,
window_w: mouseview.params.overWidth
}
mouseview.startTracking() // start tracking mouse movements
jsPsych.finishTrial(trial_data) // log the height and width then move on
}
var setup_mouseview = () => {
mouseview.params.apertureSize = trial.aperture_size
mouseview.params.apertureGauss = trial.aperture_gauss
mouseview.params.overlayColour = trial.overlay_colour
mouseview.params.overlayAlpha = trial.overlay_alpha
mouseview.params.overlayGaussian = trial.overlay_gaussian
mouseview.params.overlayGaussianInterval = trial.overlay_gaussian_update
mouseview.params.overlayGaussianFunc = on_complete
mouseview.init()
}
var el = document.createElement('script')
el.onload = setup_mouseview
el.src = "https://mouseview.org/MouseView.js"
document.head.appendChild(el)
};
return plugin;
})();