Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated README.md for clarity after successfully getting the timelines example working locally. #20

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
36 changes: 24 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ This is an open repository of timelines for jsPsych. The goal of this repository

## List of available timelines

The jsPsych timelines that have been contributed by community members can be found in the `/packages` directory.
The `/packages` directory also contains two template sub-folders that can be used as a starting point for contributing a timeline (see the [Guidelines for contributing new timelines](#guidelines-for-contributing-new-timelines) section).
The jsPsych timelines that have been contributed by community members can be found in the `./packages` directory.
The `./packages` directory also contains two template sub-folders that can be used as a starting point for contributing a timeline (see the [Guidelines for contributing new timelines](#guidelines-for-contributing-new-timelines) section).



Expand All @@ -28,23 +28,35 @@ The modules in this repository can be loaded via a CDN or via NPM. The CDN is th
<script src="https://unpkg.com/@jspsych-timelines/arrow-flanker"></script>
```

This will load the timeline into the global namespace as `jsPsychTimelineArrowFlanker`. You can then use the timeline in your experiment like this:
> ⚠️ You will also need to import the jsPsych library and css CDNs, in addition to the timeline CDN:
```html
<head>
<script src="https://unpkg.com/jspsych"></script>
<script src="https://unpkg.com/@jspsych-timelines/arrow-flanker"></script>
<link rel="stylesheet" href="https://unpkg.com/jspsych/css/jspsych.css">
</head>
```

```js
const jsPsych = initJsPsych();
const timeline = jsPsychTimelineArrowFlanker.createTimeline(jsPsych, {options});
jsPsych.run([timeline]);
This will load the timeline into the global namespace as `jsPsychTimelineArrowFlankerTask`. You can then use the timeline in your experiment like this:

```html
<script>
const jsPsych = initJsPsych();
const options = { fixation_duration: 400 };
const timeline = jsPsychTimelineArrowFlankerTask.createTimeline(jsPsych, options);
jsPsych.run([timeline]);
</script>
```

In the above example, `timeline` is a jsPsych timeline object that can be added to other timelines or used as the main timeline. The `options` parameter is an object that contains options for the timeline. The options are described in the documentation for each timeline.
In the above example, `timeline` is a jsPsych timeline object that can be added to other timelines or used as the main timeline. The `options` parameter is an object that contains jsPsych timeline properties (in this case, `fixation_duration: 400`) to configure jsPsych properties present in the imported timeline. The configurable options are described in the documentation for each timeline.

## Structure

Each timeline module exports a `createTimeline()` method. This method returns an object with a `timeline` property that can be inserted into a jsPsych timeline.
Notice that each timeline module exports a `createTimeline()` method. This method returns an object with a `timeline` property that can be inserted into a jsPsych timeline and can be run without the optional `options` parameter to keep default timeline property settings.

```js
const timeline = jsPsychTimelineModule.createTimeline(jsPsych, {options})
jsPsych.run([timeline])
const timeline = jsPsychTimelineModule.createTimeline(jsPsych, { options });
jsPsych.run([timeline]);
```

Timeline modules may also export a `timelineUnits` objects and a `utils` object.
Expand All @@ -71,4 +83,4 @@ We welcome timelines of all kinds!

### What if my timeline requires a custom plugin?

If your timeline requires a custom plugin, we'd recommend adding the plugin to [jspsych-contrib](https://github.com/jspsych/jspsych-contrib) before submitting the timeline here. This will make it easier for other researchers to use your plugin in their own experiments. Currently, this repository is aimed at timelines that use plugins that are published on `npm`.
If your timeline requires a custom plugin, we'd recommend adding the plugin to [jspsych-contrib](https://github.com/jspsych/jspsych-contrib) before submitting the timeline here. This will make it easier for other researchers to use your plugin in their own experiments. Currently, this repository is aimed at timelines that use plugins that are published on `npm`.