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