Skip to content

Commit

Permalink
remove delimiter param, added logic to handle it instead
Browse files Browse the repository at this point in the history
  • Loading branch information
jadeddelta committed Oct 26, 2024
1 parent 39c28de commit 23e839b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
3 changes: 1 addition & 2 deletions packages/plugin-spr/examples/delimiter.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@

const trial = {
type: jsPsychSpr,
unstructured_reading_string: "this %is the %reading string and it is %super super long, i wonder %what will be %coming next.",
unstructured_reading_string: "this ^is the ^reading string and it is ^super super long, i wonder ^what will be ^coming next.",
mode: 1,
delimiting: true,
};

jsPsych.run([trial])
Expand Down
25 changes: 6 additions & 19 deletions packages/plugin-spr/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ const info = <const>{
type: ParameterType.KEYS,
default: [" "],
},
/** To be removed */
delimiting: {
type: ParameterType.BOOL,
default: false,
},
},
data: {
/* The representation of the `structured_reading_string` that was used. Combined with the mode, this
Expand Down Expand Up @@ -149,22 +144,15 @@ class SprPlugin implements JsPsychPlugin<Info> {
else throw console.error("Mode declared incorrectly, must be between 1 and 3.");

// creates inital reading string -> TODO: should instead use mode to determine
if (trial.structured_reading_string.length > 0)
if (trial.structured_reading_string.length > 0) {
this.structured_reading_string = trial.structured_reading_string;
else if (trial.delimiting) {
this.structured_reading_string = this.createReadingString(
trial.unstructured_reading_string,
trial.chunk_size,
trial.line_size,
"%"
);
console.log("delimiting is true", this.structured_reading_string);
} else
} else {
this.structured_reading_string = this.createReadingString(
trial.unstructured_reading_string,
trial.chunk_size,
trial.line_size
);
}

this.jsPsych.pluginAPI.getKeyboardResponse({
callback_function: (info) => this.onSpacebarPress(info),
Expand All @@ -181,11 +169,10 @@ class SprPlugin implements JsPsychPlugin<Info> {
private createReadingString(
unstructured_reading_string: string,
chunk_size: number,
line_size: number,
delimiter?: string
line_size: number
): string[] {
const split_text = delimiter
? unstructured_reading_string.split(delimiter)
const split_text = unstructured_reading_string.includes("^")
? unstructured_reading_string.split("^")
: unstructured_reading_string.split(" ");
const res = [];

Expand Down

0 comments on commit 23e839b

Please sign in to comment.