mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-11 16:18:11 +00:00
Updating extensions - missing documentation within extensions
This commit is contained in:
parent
bdf4fc3eee
commit
95a2203e27
@ -1,4 +1,6 @@
|
||||
import { JsPsych, JsPsychExtension, JsPsychExtensionInfo } from "jspsych";
|
||||
import { JsPsych, JsPsychExtension, JsPsychExtensionInfo, ParameterType } from "jspsych";
|
||||
|
||||
import { version } from "../package.json";
|
||||
|
||||
interface InitializeParameters {
|
||||
/**
|
||||
@ -24,9 +26,75 @@ interface OnStartParameters {
|
||||
events?: Array<string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://www.jspsych.org/latest/extensions/mouse-tracking/
|
||||
*/
|
||||
class MouseTrackingExtension implements JsPsychExtension {
|
||||
static info: JsPsychExtensionInfo = {
|
||||
name: "mouse-tracking",
|
||||
version: version,
|
||||
data: {
|
||||
/**
|
||||
* An array of objects containing mouse movement data for the trial. Each object has an `x`, a `y`, a `t`, and an
|
||||
* `event` property. The `x` and `y` properties specify the mouse coordinates in pixels relative to the top left
|
||||
* corner of the viewport and `t` specifies the time in milliseconds since the start of the trial. The `event`
|
||||
* will be either 'mousemove', 'mousedown', or 'mouseup' depending on which event was generated.
|
||||
*/
|
||||
mouse_tracking_data: {
|
||||
type: ParameterType.COMPLEX,
|
||||
array: true,
|
||||
nested: {
|
||||
x: {
|
||||
type: ParameterType.INT,
|
||||
},
|
||||
y: {
|
||||
type: ParameterType.INT,
|
||||
},
|
||||
t: {
|
||||
type: ParameterType.INT,
|
||||
},
|
||||
event: {
|
||||
type: ParameterType.STRING,
|
||||
},
|
||||
},
|
||||
},
|
||||
/**
|
||||
* An object contain the pixel coordinates of elements on the screen specified by the `.targets` parameter. Each key
|
||||
* in this object will be a `selector` property, containing the CSS selector string used to find the element. The object
|
||||
* corresponding to each key will contain `x` and `y` properties specifying the top-left corner of the object, `width`
|
||||
* and `height` values, plus `top`, `bottom`, `left`, and `right` parameters which specify the
|
||||
* [bounding rectangle](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect) of the element.
|
||||
*/
|
||||
mouse_tracking_targets: {
|
||||
type: ParameterType.COMPLEX,
|
||||
nested: {
|
||||
x: {
|
||||
type: ParameterType.INT,
|
||||
},
|
||||
y: {
|
||||
type: ParameterType.INT,
|
||||
},
|
||||
width: {
|
||||
type: ParameterType.INT,
|
||||
},
|
||||
height: {
|
||||
type: ParameterType.INT,
|
||||
},
|
||||
top: {
|
||||
type: ParameterType.INT,
|
||||
},
|
||||
bottom: {
|
||||
type: ParameterType.INT,
|
||||
},
|
||||
left: {
|
||||
type: ParameterType.INT,
|
||||
},
|
||||
right: {
|
||||
type: ParameterType.INT,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
constructor(private jsPsych: JsPsych) {}
|
||||
|
@ -1,9 +1,21 @@
|
||||
import autoBind from "auto-bind";
|
||||
import { JsPsych, JsPsychExtension, JsPsychExtensionInfo } from "jspsych";
|
||||
import { JsPsych, JsPsychExtension, JsPsychExtensionInfo, ParameterType } from "jspsych";
|
||||
|
||||
import { version } from "../package.json";
|
||||
|
||||
/**
|
||||
* https://www.jspsych.org/latest/extensions/record-video/
|
||||
*/
|
||||
class RecordVideoExtension implements JsPsychExtension {
|
||||
static info: JsPsychExtensionInfo = {
|
||||
name: "record-video",
|
||||
version: version,
|
||||
data: {
|
||||
/** [Base 64 encoded](https://developer.mozilla.org/en-US/docs/Glossary/Base64) representation of the video data. */
|
||||
record_video_data: {
|
||||
type: ParameterType.STRING,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
constructor(private jsPsych: JsPsych) {
|
||||
|
@ -1,4 +1,6 @@
|
||||
import { JsPsych, JsPsychExtension, JsPsychExtensionInfo } from "jspsych";
|
||||
import { JsPsych, JsPsychExtension, JsPsychExtensionInfo, ParameterType } from "jspsych";
|
||||
|
||||
import { version } from "../package.json";
|
||||
|
||||
// we have to add webgazer to the global window object because webgazer attaches itself to
|
||||
// the window when it loads
|
||||
@ -39,9 +41,56 @@ interface OnStartParameters {
|
||||
targets: Array<string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* https://www.jspsych.org/latest/extensions/webgazer/
|
||||
*/
|
||||
class WebGazerExtension implements JsPsychExtension {
|
||||
static info: JsPsychExtensionInfo = {
|
||||
name: "webgazer",
|
||||
version: version,
|
||||
data: {
|
||||
/** An array of objects containing gaze data for the trial. Each object has an `x`, a `y`, and a `t` property. The `x` and
|
||||
* `y` properties specify the gaze location in pixels and `t` specifies the time in milliseconds since the start of the trial.
|
||||
*/
|
||||
webgazer_data: {
|
||||
type: ParameterType.INT,
|
||||
array: true,
|
||||
},
|
||||
/** An object contain the pixel coordinates of elements on the screen specified by the `.targets` parameter. Each key in this
|
||||
* object will be a `selector` property, containing the CSS selector string used to find the element. The object corresponding
|
||||
* to each key will contain `x` and `y` properties specifying the top-left corner of the object, `width` and `height` values,
|
||||
* plus `top`, `bottom`, `left`, and `right` parameters which specify the [bounding rectangle](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect) of the element.
|
||||
*/
|
||||
webgazer_targets: {
|
||||
type: ParameterType.COMPLEX,
|
||||
nested: {
|
||||
x: {
|
||||
type: ParameterType.INT,
|
||||
},
|
||||
y: {
|
||||
type: ParameterType.INT,
|
||||
},
|
||||
width: {
|
||||
type: ParameterType.INT,
|
||||
},
|
||||
height: {
|
||||
type: ParameterType.INT,
|
||||
},
|
||||
top: {
|
||||
type: ParameterType.INT,
|
||||
},
|
||||
bottom: {
|
||||
type: ParameterType.INT,
|
||||
},
|
||||
left: {
|
||||
type: ParameterType.INT,
|
||||
},
|
||||
right: {
|
||||
type: ParameterType.INT,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
constructor(private jsPsych: JsPsych) {}
|
||||
|
@ -1,5 +1,9 @@
|
||||
import { ParameterInfos } from "./plugins";
|
||||
|
||||
export interface JsPsychExtensionInfo {
|
||||
name: string;
|
||||
version?: string;
|
||||
data?: ParameterInfos;
|
||||
}
|
||||
|
||||
export interface JsPsychExtension {
|
||||
|
Loading…
Reference in New Issue
Block a user