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.js CHANGED
@@ -67,7 +67,7 @@ var autoBind = (self, {include, exclude} = {}) => {
67
67
  return self;
68
68
  };
69
69
 
70
- var version = "7.3.0";
70
+ var version = "7.3.1";
71
71
 
72
72
  class MigrationError extends Error {
73
73
  constructor(message = "The global `jsPsych` variable is no longer available in jsPsych v7.") {
@@ -900,15 +900,15 @@ class MediaAPI {
900
900
  callback_error({ source: source, error: e });
901
901
  });
902
902
  };
903
- request.onerror = function (e) {
903
+ request.onerror = (e) => {
904
904
  let err = e;
905
- if (this.status == 404) {
905
+ if (request.status == 404) {
906
906
  err = "404";
907
907
  }
908
908
  callback_error({ source: source, error: err });
909
909
  };
910
- request.onloadend = function (e) {
911
- if (this.status == 404) {
910
+ request.onloadend = (e) => {
911
+ if (request.status == 404) {
912
912
  callback_error({ source: source, error: "404" });
913
913
  }
914
914
  };
@@ -965,20 +965,21 @@ class MediaAPI {
965
965
  callback_complete();
966
966
  return;
967
967
  }
968
- for (var i = 0; i < images.length; i++) {
969
- var img = new Image();
970
- img.onload = function () {
968
+ for (let i = 0; i < images.length; i++) {
969
+ const img = new Image();
970
+ const src = images[i];
971
+ img.onload = () => {
971
972
  n_loaded++;
972
- callback_load(img.src);
973
+ callback_load(src);
973
974
  if (n_loaded === images.length) {
974
975
  callback_complete();
975
976
  }
976
977
  };
977
- img.onerror = function (e) {
978
- callback_error({ source: img.src, error: e });
978
+ img.onerror = (e) => {
979
+ callback_error({ source: src, error: e });
979
980
  };
980
- img.src = images[i];
981
- this.img_cache[images[i]] = img;
981
+ img.src = src;
982
+ this.img_cache[src] = img;
982
983
  this.preload_requests.push(img);
983
984
  }
984
985
  }
@@ -996,9 +997,9 @@ class MediaAPI {
996
997
  const request = new XMLHttpRequest();
997
998
  request.open("GET", video, true);
998
999
  request.responseType = "blob";
999
- request.onload = function () {
1000
- if (this.status === 200 || this.status === 0) {
1001
- const videoBlob = this.response;
1000
+ request.onload = () => {
1001
+ if (request.status === 200 || request.status === 0) {
1002
+ const videoBlob = request.response;
1002
1003
  video_buffers[video] = URL.createObjectURL(videoBlob); // IE10+
1003
1004
  n_loaded++;
1004
1005
  callback_load(video);
@@ -1007,15 +1008,15 @@ class MediaAPI {
1007
1008
  }
1008
1009
  }
1009
1010
  };
1010
- request.onerror = function (e) {
1011
+ request.onerror = (e) => {
1011
1012
  let err = e;
1012
- if (this.status == 404) {
1013
+ if (request.status == 404) {
1013
1014
  err = "404";
1014
1015
  }
1015
1016
  callback_error({ source: video, error: err });
1016
1017
  };
1017
- request.onloadend = function (e) {
1018
- if (this.status == 404) {
1018
+ request.onloadend = (e) => {
1019
+ if (request.status == 404) {
1019
1020
  callback_error({ source: video, error: "404" });
1020
1021
  }
1021
1022
  };
@@ -1872,7 +1873,8 @@ function shuffleNoRepeats(arr, equalityTest) {
1872
1873
  // test to make sure the new neighbor isn't equal to the old one
1873
1874
  while (equalityTest(random_shuffle[i + 1], random_shuffle[random_pick]) ||
1874
1875
  equalityTest(random_shuffle[i + 1], random_shuffle[random_pick + 1]) ||
1875
- equalityTest(random_shuffle[i + 1], random_shuffle[random_pick - 1])) {
1876
+ equalityTest(random_shuffle[i + 1], random_shuffle[random_pick - 1]) ||
1877
+ equalityTest(random_shuffle[i], random_shuffle[random_pick])) {
1876
1878
  random_pick = Math.floor(Math.random() * (random_shuffle.length - 2)) + 1;
1877
1879
  }
1878
1880
  const new_neighbor = random_shuffle[random_pick];