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

Ability to display wait message above loading graphics during upload #114

Merged
merged 3 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sixty-dots-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@jspsych-contrib/plugin-pipe": minor
---

Added ability to display wait message above loading graphics during upload.
1 change: 1 addition & 0 deletions packages/plugin-pipe/docs/jspsych-pipe.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ In addition to the [parameters available in all plugins](https://www.jspsych.org
| action | string | undefined | The action to perform. Possible values are `save`, `saveBase64`, and `condition`. |
| filename | null | undefined | The filename to use when saving data. It should be unique. If the file already exists, no data will be saved. |
| data_string | string | null | The string of data to save. If action is `save` then this can be text data in any format (e.g., CSV, JSON, TXT, etc.). If `action` is `saveBase64`, then this should be a base64 encoded string and the `filename` should have the appropriate extension. |
| wait_message | HTML_string | `<p>Saving data. Please do not close this page.</p>` | An HTML message to be displayed above the loading graphics in the experiment during data upload. |


## Data Generated
Expand Down
15 changes: 9 additions & 6 deletions packages/plugin-pipe/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ const info = <const>{
type: ParameterType.STRING,
default: null,
},
/**
* An HTML message to be displayed above the loading graphics in the experiment during data upload.
*/
wait_message: {
type: ParameterType.HTML_STRING,
default: `<p>Saving data. Please do not close this page.</p>`,
},
},
};

Expand Down Expand Up @@ -70,11 +77,6 @@ class PipePlugin implements JsPsychPlugin<Info> {
const progressCSS = `
.spinner {
animation: rotate 2s linear infinite;
z-index: 2;
position: absolute;
top: 50%;
left: 50%;
margin: -25px 0 0 -25px;
width: 50px;
height: 50px;
}
Expand Down Expand Up @@ -108,7 +110,8 @@ class PipePlugin implements JsPsychPlugin<Info> {
`;

const progressHTML = `
<style>${progressCSS}</style>
<style>${progressCSS}</style>
${trial.wait_message}
<svg class="spinner" viewBox="0 0 50 50">
<circle class="path" cx="25" cy="25" r="20" fill="none" stroke-width="5"></circle>
</svg>`;
Expand Down