jspsych 7.3.0 → 7.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -71,7 +71,7 @@ var autoBind = (self, {include, exclude} = {}) => {
71
71
  return self;
72
72
  };
73
73
 
74
- var version = "7.3.0";
74
+ var version = "7.3.1";
75
75
 
76
76
  class MigrationError extends Error {
77
77
  constructor(message = "The global `jsPsych` variable is no longer available in jsPsych v7.") {
@@ -904,15 +904,15 @@ class MediaAPI {
904
904
  callback_error({ source: source, error: e });
905
905
  });
906
906
  };
907
- request.onerror = function (e) {
907
+ request.onerror = (e) => {
908
908
  let err = e;
909
- if (this.status == 404) {
909
+ if (request.status == 404) {
910
910
  err = "404";
911
911
  }
912
912
  callback_error({ source: source, error: err });
913
913
  };
914
- request.onloadend = function (e) {
915
- if (this.status == 404) {
914
+ request.onloadend = (e) => {
915
+ if (request.status == 404) {
916
916
  callback_error({ source: source, error: "404" });
917
917
  }
918
918
  };
@@ -969,20 +969,21 @@ class MediaAPI {
969
969
  callback_complete();
970
970
  return;
971
971
  }
972
- for (var i = 0; i < images.length; i++) {
973
- var img = new Image();
974
- img.onload = function () {
972
+ for (let i = 0; i < images.length; i++) {
973
+ const img = new Image();
974
+ const src = images[i];
975
+ img.onload = () => {
975
976
  n_loaded++;
976
- callback_load(img.src);
977
+ callback_load(src);
977
978
  if (n_loaded === images.length) {
978
979
  callback_complete();
979
980
  }
980
981
  };
981
- img.onerror = function (e) {
982
- callback_error({ source: img.src, error: e });
982
+ img.onerror = (e) => {
983
+ callback_error({ source: src, error: e });
983
984
  };
984
- img.src = images[i];
985
- this.img_cache[images[i]] = img;
985
+ img.src = src;
986
+ this.img_cache[src] = img;
986
987
  this.preload_requests.push(img);
987
988
  }
988
989
  }
@@ -1000,9 +1001,9 @@ class MediaAPI {
1000
1001
  const request = new XMLHttpRequest();
1001
1002
  request.open("GET", video, true);
1002
1003
  request.responseType = "blob";
1003
- request.onload = function () {
1004
- if (this.status === 200 || this.status === 0) {
1005
- const videoBlob = this.response;
1004
+ request.onload = () => {
1005
+ if (request.status === 200 || request.status === 0) {
1006
+ const videoBlob = request.response;
1006
1007
  video_buffers[video] = URL.createObjectURL(videoBlob); // IE10+
1007
1008
  n_loaded++;
1008
1009
  callback_load(video);
@@ -1011,15 +1012,15 @@ class MediaAPI {
1011
1012
  }
1012
1013
  }
1013
1014
  };
1014
- request.onerror = function (e) {
1015
+ request.onerror = (e) => {
1015
1016
  let err = e;
1016
- if (this.status == 404) {
1017
+ if (request.status == 404) {
1017
1018
  err = "404";
1018
1019
  }
1019
1020
  callback_error({ source: video, error: err });
1020
1021
  };
1021
- request.onloadend = function (e) {
1022
- if (this.status == 404) {
1022
+ request.onloadend = (e) => {
1023
+ if (request.status == 404) {
1023
1024
  callback_error({ source: video, error: "404" });
1024
1025
  }
1025
1026
  };
@@ -1876,7 +1877,8 @@ function shuffleNoRepeats(arr, equalityTest) {
1876
1877
  // test to make sure the new neighbor isn't equal to the old one
1877
1878
  while (equalityTest(random_shuffle[i + 1], random_shuffle[random_pick]) ||
1878
1879
  equalityTest(random_shuffle[i + 1], random_shuffle[random_pick + 1]) ||
1879
- equalityTest(random_shuffle[i + 1], random_shuffle[random_pick - 1])) {
1880
+ equalityTest(random_shuffle[i + 1], random_shuffle[random_pick - 1]) ||
1881
+ equalityTest(random_shuffle[i], random_shuffle[random_pick])) {
1880
1882
  random_pick = Math.floor(Math.random() * (random_shuffle.length - 2)) + 1;
1881
1883
  }
1882
1884
  const new_neighbor = random_shuffle[random_pick];