|
2446 | 2446 | </span>
|
2447 | 2447 | </a>
|
2448 | 2448 |
|
2449 |
| - <nav class="md-nav" aria-label="Requirements for a plugin"> |
2450 |
| - <ul class="md-nav__list"> |
2451 |
| - |
2452 |
| - <li class="md-nav__item"> |
2453 |
| - <a href="#templates" class="md-nav__link"> |
| 2449 | +</li> |
| 2450 | + |
| 2451 | + <li class="md-nav__item"> |
| 2452 | + <a href="#plugin-templates" class="md-nav__link"> |
2454 | 2453 | <span class="md-ellipsis">
|
2455 |
| - Templates |
| 2454 | + Plugin templates |
2456 | 2455 | </span>
|
2457 | 2456 | </a>
|
2458 | 2457 |
|
2459 |
| -</li> |
2460 |
| - |
2461 |
| - </ul> |
2462 |
| - </nav> |
2463 |
| - |
2464 | 2458 | </li>
|
2465 | 2459 |
|
2466 | 2460 | <li class="md-nav__item">
|
|
2590 | 2584 | </span>
|
2591 | 2585 | </a>
|
2592 | 2586 |
|
2593 |
| -</li> |
2594 |
| - |
2595 |
| - <li class="md-nav__item"> |
2596 |
| - <a href="#plugin-templates" class="md-nav__link"> |
2597 |
| - <span class="md-ellipsis"> |
2598 |
| - Plugin templates |
2599 |
| - </span> |
2600 |
| - </a> |
2601 |
| - |
2602 | 2587 | </li>
|
2603 | 2588 |
|
2604 | 2589 | </ul>
|
|
2923 | 2908 | </span>
|
2924 | 2909 | </a>
|
2925 | 2910 |
|
2926 |
| - <nav class="md-nav" aria-label="Requirements for a plugin"> |
2927 |
| - <ul class="md-nav__list"> |
2928 |
| - |
2929 |
| - <li class="md-nav__item"> |
2930 |
| - <a href="#templates" class="md-nav__link"> |
| 2911 | +</li> |
| 2912 | + |
| 2913 | + <li class="md-nav__item"> |
| 2914 | + <a href="#plugin-templates" class="md-nav__link"> |
2931 | 2915 | <span class="md-ellipsis">
|
2932 |
| - Templates |
| 2916 | + Plugin templates |
2933 | 2917 | </span>
|
2934 | 2918 | </a>
|
2935 | 2919 |
|
2936 |
| -</li> |
2937 |
| - |
2938 |
| - </ul> |
2939 |
| - </nav> |
2940 |
| - |
2941 | 2920 | </li>
|
2942 | 2921 |
|
2943 | 2922 | <li class="md-nav__item">
|
|
3067 | 3046 | </span>
|
3068 | 3047 | </a>
|
3069 | 3048 |
|
3070 |
| -</li> |
3071 |
| - |
3072 |
| - <li class="md-nav__item"> |
3073 |
| - <a href="#plugin-templates" class="md-nav__link"> |
3074 |
| - <span class="md-ellipsis"> |
3075 |
| - Plugin templates |
3076 |
| - </span> |
3077 |
| - </a> |
3078 |
| - |
3079 | 3049 | </li>
|
3080 | 3050 |
|
3081 | 3051 | </ul>
|
@@ -3104,8 +3074,9 @@ <h2 id="requirements-for-a-plugin">Requirements for a plugin<a class="headerlink
|
3104 | 3074 | <li><a href="#trial">A <code>trial()</code> method</a> that accepts an <code>HTMLElement</code> as its first argument and an <code>object</code> of trial parameters as its second argument. There is an optional third argument to <a href="#asynchronous-loading">handle the <code>on_load</code> event</a> in certain cirumstances. The <code>trial()</code> method should <em>either</em> invoke <code>jsPsych.finishTrial()</code> or should be an <code>async</code> function that returns a data object to <a href="#save-data">end the trial and save data</a>.</li>
|
3105 | 3075 | <li><a href="#static-info">A static <code>info</code> property</a> on the class that contains an object describing the plugin's parameters, data generated, and version.</li>
|
3106 | 3076 | </ul>
|
3107 |
| -<h3 id="templates">Templates<a class="headerlink" href="#templates" title="Permanent link">¶</a></h3> |
3108 |
| -<p>Plugins can be written in either plain JavaScript or in TypeScript. Template files for both <a href="https://github.com/jspsych/jspsych-contrib/blob/main/templates/plugin-template-js/src/index.js">JavaScript</a> and <a href="https://github.com/jspsych/jspsych-contrib/blob/main/templates/plugin-template-ts/src/index.ts">TypeScript</a> are available in the <a href="https://github.com/jspsych/jspsych-contrib/">jspsych-contrib repository</a>.</p> |
| 3077 | +<h2 id="plugin-templates">Plugin templates<a class="headerlink" href="#plugin-templates" title="Permanent link">¶</a></h2> |
| 3078 | +<p>Templates for plugins are available in the <a href="https://github.com/jspsych/jspsych-contrib">jspsych-contrib</a> repository. Plugins can be written in either plain <a href="https://github.com/jspsych/jspsych-contrib/blob/main/templates/plugin-template-js/src/index.js">JavaScript</a> or in <a href="https://github.com/jspsych/jspsych-contrib/blob/main/templates/plugin-template-ts/src/index.ts">TypeScript</a>.</p> |
| 3079 | +<p>To get started with a template, we recommend using the CLI tool that we have published in jspsych-contrib. This automates the setup of a new plugin in either JavaScript or TypeScript. Additional information about the CLI tool is available in the <a href="https://github.com/jspsych/jspsych-contrib?tab=readme-ov-file#creating-a-new-plugin-or-extension"><code>README</code></a> of jspsych-contrib. </p> |
3109 | 3080 | <h2 id="plugin-components">Plugin components<a class="headerlink" href="#plugin-components" title="Permanent link">¶</a></h2>
|
3110 | 3081 | <h3 id="constructor">constructor()<a class="headerlink" href="#constructor" title="Permanent link">¶</a></h3>
|
3111 | 3082 | <p>The plugin's <code>constructor()</code> will be passed a reference to the instance of the <code>JsPsych</code> class that is running the experiment. The constructor should store this reference so that the plugin can access functionality from the core library and its modules.</p>
|
@@ -3351,8 +3322,6 @@ <h2 id="simulation-mode">Simulation mode<a class="headerlink" href="#simulation-
|
3351 | 3322 | <h2 id="advice-for-writing-plugins">Advice for writing plugins<a class="headerlink" href="#advice-for-writing-plugins" title="Permanent link">¶</a></h2>
|
3352 | 3323 | <p>If you are developing a plugin with the aim of including it in the main jsPsych repository we encourage you to follow the <a href="../contributing/#contributing-to-the-codebase">contribution guidelines</a>. </p>
|
3353 | 3324 | <p>We also recommend that you make your plugin <em>as general as possible</em>. Consider using parameters to give the user of the plugin as many options for customization as possible. For example, if you have any text that displays in the plugin including things like button labels, implement the text as a parameter. This allows users running experiments in other languages to replace text values as needed.</p>
|
3354 |
| -<h2 id="plugin-templates">Plugin templates<a class="headerlink" href="#plugin-templates" title="Permanent link">¶</a></h2> |
3355 |
| -<p>Templates for plugins are available in the <a href="https://github.com/jspsych/jspsych-contrib">jspsych-contrib</a> repository. There is a command-line tool for generating a new plugin from these templates in that repository. See the README file in the jspsych-contrib repository for more information.</p> |
3356 | 3325 |
|
3357 | 3326 |
|
3358 | 3327 |
|
|
0 commit comments