maidr 2.14.7 → 2.14.8
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/maidr.js +1374 -1820
- package/dist/maidr.min.js +1 -1
- package/package.json +1 -1
package/dist/maidr.js
CHANGED
|
@@ -205,6 +205,13 @@ class Constants {
|
|
|
205
205
|
* @memberof BasicChartProperties
|
|
206
206
|
*/
|
|
207
207
|
navigation = 1; // 0 = row navigation (up/down), 1 = col navigation (left/right)
|
|
208
|
+
/**
|
|
209
|
+
* The orientation of the chart. 'horz' = horizontal, 'vert' = vertical
|
|
210
|
+
* @type {string}
|
|
211
|
+
* @default 'horz'
|
|
212
|
+
* @memberof BasicChartProperties
|
|
213
|
+
*/
|
|
214
|
+
plotOrientation = 'horz';
|
|
208
215
|
|
|
209
216
|
/**
|
|
210
217
|
* @namespace AudioProperties
|
|
@@ -1367,6 +1374,24 @@ class Menu {
|
|
|
1367
1374
|
.setAttribute('aria-live', constants.ariaMode);
|
|
1368
1375
|
|
|
1369
1376
|
document.getElementById('init_llm_on_load').checked = constants.autoInitLLM;
|
|
1377
|
+
const scatter = document.getElementsByClassName('highlight_point');
|
|
1378
|
+
const heatmap = document.getElementById('highlight_rect');
|
|
1379
|
+
const line = document.getElementById('highlight_point');
|
|
1380
|
+
|
|
1381
|
+
if (scatter !== null && scatter.length > 0) {
|
|
1382
|
+
for (let i = 0; i < scatter.length; i++) {
|
|
1383
|
+
scatter[i].setAttribute('stroke', constants.colorSelected);
|
|
1384
|
+
scatter[i].setAttribute('fill', constants.colorSelected);
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
if (heatmap !== null) {
|
|
1389
|
+
heatmap.setAttribute('stroke', constants.colorSelected);
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
if (line !== null) {
|
|
1393
|
+
line.setAttribute('stroke', constants.colorSelected);
|
|
1394
|
+
}
|
|
1370
1395
|
}
|
|
1371
1396
|
|
|
1372
1397
|
/**
|
|
@@ -7956,67 +7981,107 @@ class Segmented {
|
|
|
7956
7981
|
* @class
|
|
7957
7982
|
*/
|
|
7958
7983
|
class Control {
|
|
7984
|
+
/**
|
|
7985
|
+
* Elements that are active and accept the standard control scheme (ie, arrow keys etc)
|
|
7986
|
+
*/
|
|
7987
|
+
controlElements = [constants.chart, constants.brailleInput];
|
|
7988
|
+
allControlElements = [
|
|
7989
|
+
constants.chart,
|
|
7990
|
+
constants.brailleInput,
|
|
7991
|
+
constants.review_container,
|
|
7992
|
+
];
|
|
7993
|
+
/**
|
|
7994
|
+
* We store whether the l key is pressed for preset mode
|
|
7995
|
+
*/
|
|
7996
|
+
pressedL = false;
|
|
7997
|
+
|
|
7959
7998
|
/**
|
|
7960
7999
|
* Creates a new instance of the Controls class.
|
|
7961
8000
|
* @constructor
|
|
7962
8001
|
*/
|
|
7963
8002
|
constructor() {
|
|
8003
|
+
constants.lastx = 0;
|
|
8004
|
+
|
|
8005
|
+
this.InitChartClass();
|
|
8006
|
+
this.SetBTSControls();
|
|
8007
|
+
this.SetPrefixControls();
|
|
7964
8008
|
this.SetControls();
|
|
7965
8009
|
}
|
|
7966
8010
|
|
|
7967
8011
|
/**
|
|
7968
|
-
*
|
|
7969
|
-
*
|
|
7970
|
-
|
|
7971
|
-
|
|
7972
|
-
|
|
8012
|
+
* We initialize the chart class.
|
|
8013
|
+
* We do this here because of javascript screwyness, it has to be done after Init, before controls are set, and in this file.
|
|
8014
|
+
*/
|
|
8015
|
+
InitChartClass() {
|
|
8016
|
+
if ([].concat(singleMaidr.type).includes('bar')) {
|
|
8017
|
+
window.plot = new BarChart();
|
|
8018
|
+
} else if ([].concat(singleMaidr.type).includes('box')) {
|
|
8019
|
+
window.plot = new BoxPlot();
|
|
8020
|
+
} else if ([].concat(singleMaidr.type).includes('heat')) {
|
|
8021
|
+
window.plot = new HeatMap();
|
|
8022
|
+
singleMaidr.rect = new HeatMapRect();
|
|
8023
|
+
} else if (
|
|
8024
|
+
[].concat(singleMaidr.type).includes('point') ||
|
|
8025
|
+
[].concat(singleMaidr.type).includes('smooth')
|
|
8026
|
+
) {
|
|
8027
|
+
window.plot = new ScatterPlot();
|
|
8028
|
+
window.layer0Point = new Layer0Point();
|
|
8029
|
+
window.layer1Point = new Layer1Point();
|
|
8030
|
+
} else if ([].concat(singleMaidr.type).includes('hist')) {
|
|
8031
|
+
window.plot = new Histogram();
|
|
8032
|
+
} else if (
|
|
8033
|
+
[].concat(singleMaidr.type).includes('stacked_bar') ||
|
|
8034
|
+
[].concat(singleMaidr.type).includes('stacked_normalized_bar') ||
|
|
8035
|
+
[].concat(singleMaidr.type).includes('dodged_bar')
|
|
8036
|
+
) {
|
|
8037
|
+
window.plot = new Segmented();
|
|
8038
|
+
}
|
|
8039
|
+
}
|
|
8040
|
+
|
|
8041
|
+
/**
|
|
8042
|
+
* Sets up event listeners for the main BTS controls:
|
|
8043
|
+
* - B: braille mode
|
|
8044
|
+
* - T: text mode
|
|
8045
|
+
* - S: sonification mode
|
|
8046
|
+
* - R: review mode
|
|
8047
|
+
*
|
|
7973
8048
|
* @returns {void}
|
|
7974
8049
|
*/
|
|
7975
|
-
|
|
8050
|
+
SetBTSControls() {
|
|
7976
8051
|
// global controls
|
|
7977
8052
|
|
|
7978
8053
|
// variable initialization
|
|
7979
|
-
let controlElements = [
|
|
7980
|
-
constants.chart,
|
|
7981
|
-
constants.brailleInput,
|
|
7982
|
-
constants.review_container,
|
|
7983
|
-
];
|
|
7984
|
-
let pressedL = false;
|
|
7985
|
-
let pressedTimeout = null;
|
|
7986
8054
|
|
|
7987
8055
|
// main BTS controls
|
|
7988
|
-
for (let i = 0; i <
|
|
8056
|
+
for (let i = 0; i < this.allControlElements.length; i++) {
|
|
7989
8057
|
constants.events.push([
|
|
7990
|
-
|
|
8058
|
+
this.allControlElements[i],
|
|
7991
8059
|
'keydown',
|
|
7992
8060
|
function (e) {
|
|
7993
|
-
|
|
7994
|
-
let lastPlayed = '';
|
|
7995
|
-
|
|
7996
|
-
// if we're awaiting an L + X prefix, we don't want to do anything else
|
|
7997
|
-
if (pressedL) {
|
|
8061
|
+
if (constants.pressedL) {
|
|
7998
8062
|
return;
|
|
7999
8063
|
}
|
|
8064
|
+
// if we're awaiting an L + X prefix, we don't want to do anything else
|
|
8000
8065
|
|
|
8001
8066
|
// B: braille mode
|
|
8002
|
-
if (e.key == 'b') {
|
|
8067
|
+
if (e.key == 'b' && !control.pressedL) {
|
|
8003
8068
|
constants.tabMovement = 0;
|
|
8004
8069
|
e.preventDefault();
|
|
8005
8070
|
display.toggleBrailleMode();
|
|
8006
8071
|
}
|
|
8007
8072
|
|
|
8008
8073
|
// T: aria live text output mode
|
|
8009
|
-
if (e.key == 't') {
|
|
8074
|
+
if (e.key == 't' && !control.pressedL) {
|
|
8010
8075
|
display.toggleTextMode();
|
|
8011
8076
|
}
|
|
8012
8077
|
|
|
8013
8078
|
// S: sonification mode
|
|
8014
|
-
if (e.key == 's') {
|
|
8079
|
+
if (e.key == 's' && !control.pressedL) {
|
|
8015
8080
|
display.toggleSonificationMode();
|
|
8016
8081
|
}
|
|
8017
8082
|
|
|
8018
8083
|
// R: review mode
|
|
8019
|
-
if (e.key == 'r' && !e.ctrlKey && !e.shiftKey) {
|
|
8084
|
+
if (e.key == 'r' && !e.ctrlKey && !e.shiftKey && !control.pressedL) {
|
|
8020
8085
|
// r, but let Ctrl and Shift R go through cause I use that to refresh
|
|
8021
8086
|
constants.tabMovement = 0;
|
|
8022
8087
|
e.preventDefault();
|
|
@@ -8027,7 +8092,7 @@ class Control {
|
|
|
8027
8092
|
}
|
|
8028
8093
|
}
|
|
8029
8094
|
|
|
8030
|
-
if (e.key == ' ') {
|
|
8095
|
+
if (e.key == ' ' && !control.pressedL) {
|
|
8031
8096
|
// space 32, replay info but no other changes
|
|
8032
8097
|
|
|
8033
8098
|
// exception: if we just initilized, position might not be in range
|
|
@@ -8070,10 +8135,9 @@ class Control {
|
|
|
8070
8135
|
}
|
|
8071
8136
|
|
|
8072
8137
|
// We want to tab or shift tab past the chart,
|
|
8073
|
-
|
|
8074
|
-
for (let i = 0; i < controlElements.length; i++) {
|
|
8138
|
+
for (let i = 0; i < this.allControlElements.length; i++) {
|
|
8075
8139
|
constants.events.push([
|
|
8076
|
-
|
|
8140
|
+
this.allControlElements[i],
|
|
8077
8141
|
'keydown',
|
|
8078
8142
|
function (e) {
|
|
8079
8143
|
if (e.key == 'Tab') {
|
|
@@ -8087,72 +8151,36 @@ class Control {
|
|
|
8087
8151
|
},
|
|
8088
8152
|
]);
|
|
8089
8153
|
}
|
|
8154
|
+
}
|
|
8090
8155
|
|
|
8091
|
-
|
|
8156
|
+
/**
|
|
8157
|
+
* Sets up event listeners for prefix events.
|
|
8158
|
+
* @returns {void}
|
|
8159
|
+
*/
|
|
8160
|
+
SetPrefixControls() {
|
|
8161
|
+
// prefix events, l + x, where x is a key for the title, axis, etc
|
|
8162
|
+
// we listen for a moment when l is hit for a key to follow
|
|
8092
8163
|
constants.events.push([
|
|
8093
8164
|
document,
|
|
8094
8165
|
'keydown',
|
|
8095
8166
|
function (e) {
|
|
8096
8167
|
// init
|
|
8097
|
-
let
|
|
8168
|
+
let pressedTimeout = null;
|
|
8098
8169
|
|
|
8099
8170
|
// enable / disable prefix mode
|
|
8100
8171
|
if (e.key == 'l') {
|
|
8101
|
-
pressedL = true;
|
|
8172
|
+
control.pressedL = true;
|
|
8102
8173
|
if (pressedTimeout != null) {
|
|
8103
8174
|
clearTimeout(pressedTimeout);
|
|
8104
8175
|
pressedTimeout = null;
|
|
8105
8176
|
}
|
|
8106
8177
|
pressedTimeout = setTimeout(function () {
|
|
8107
|
-
pressedL = false;
|
|
8178
|
+
control.pressedL = false;
|
|
8108
8179
|
}, constants.keypressInterval);
|
|
8109
8180
|
}
|
|
8110
8181
|
|
|
8111
|
-
// ctrl/cmd: stop autoplay
|
|
8112
|
-
if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
8113
|
-
// (ctrl/cmd)+(home/fn+left arrow): first element
|
|
8114
|
-
if (e.key == 'Home') {
|
|
8115
|
-
// chart types
|
|
8116
|
-
if (constants.chartType == 'bar' || constants.chartType == 'hist') {
|
|
8117
|
-
position.x = 0;
|
|
8118
|
-
} else if (constants.chartType == 'box') {
|
|
8119
|
-
position.x = 0;
|
|
8120
|
-
position.y = plot.sections.length - 1;
|
|
8121
|
-
} else if (constants.chartType == 'heat') {
|
|
8122
|
-
position.x = 0;
|
|
8123
|
-
position.y = 0;
|
|
8124
|
-
} else if (constants.chartType == 'point') {
|
|
8125
|
-
position.x = 0;
|
|
8126
|
-
} else if (constants.chartType == 'smooth') {
|
|
8127
|
-
positionL1.x = 0;
|
|
8128
|
-
}
|
|
8129
|
-
|
|
8130
|
-
UpdateAllBraille();
|
|
8131
|
-
}
|
|
8132
|
-
|
|
8133
|
-
// (ctrl/cmd)+(end/fn+right arrow): last element
|
|
8134
|
-
else if (e.key == 'End') {
|
|
8135
|
-
// chart types
|
|
8136
|
-
if (constants.chartType == 'bar' || constants.chartType == 'hist') {
|
|
8137
|
-
position.x = plot.bars.length - 1;
|
|
8138
|
-
} else if (constants.chartType == 'box') {
|
|
8139
|
-
position.x = plot.sections.length - 1;
|
|
8140
|
-
position.y = 0;
|
|
8141
|
-
} else if (constants.chartType == 'heat') {
|
|
8142
|
-
position.x = plot.num_cols - 1;
|
|
8143
|
-
position.y = plot.num_rows - 1;
|
|
8144
|
-
} else if (constants.chartType == 'point') {
|
|
8145
|
-
position.x = plot.y.length - 1;
|
|
8146
|
-
} else if (constants.chartType == 'smooth') {
|
|
8147
|
-
positionL1.x = plot.curvePoints.length - 1;
|
|
8148
|
-
}
|
|
8149
|
-
|
|
8150
|
-
UpdateAllBraille();
|
|
8151
|
-
}
|
|
8152
|
-
}
|
|
8153
|
-
|
|
8154
8182
|
// Prefix mode stuff: L is enabled, look for these keys
|
|
8155
|
-
if (pressedL) {
|
|
8183
|
+
if (control.pressedL) {
|
|
8156
8184
|
if (e.key == 'x') {
|
|
8157
8185
|
// X: x label
|
|
8158
8186
|
let xlabel = '';
|
|
@@ -8175,7 +8203,7 @@ class Control {
|
|
|
8175
8203
|
xlabel = plot.plotLegend.x;
|
|
8176
8204
|
}
|
|
8177
8205
|
display.displayInfo('x label', xlabel);
|
|
8178
|
-
pressedL = false;
|
|
8206
|
+
control.pressedL = false;
|
|
8179
8207
|
} else if (e.key == 'y') {
|
|
8180
8208
|
// Y: y label
|
|
8181
8209
|
let ylabel = '';
|
|
@@ -8199,96 +8227,295 @@ class Control {
|
|
|
8199
8227
|
ylabel = plot.plotLegend.y;
|
|
8200
8228
|
}
|
|
8201
8229
|
display.displayInfo('y label', ylabel);
|
|
8202
|
-
pressedL = false;
|
|
8230
|
+
control.pressedL = false;
|
|
8203
8231
|
} else if (e.key == 't') {
|
|
8204
8232
|
// T: title
|
|
8205
8233
|
display.displayInfo('title', plot.title);
|
|
8206
|
-
pressedL = false;
|
|
8234
|
+
control.pressedL = false;
|
|
8207
8235
|
} else if (e.key == 's') {
|
|
8208
8236
|
// subtitle
|
|
8209
8237
|
display.displayInfo('subtitle', plot.subtitle);
|
|
8210
|
-
pressedL = false;
|
|
8238
|
+
control.pressedL = false;
|
|
8211
8239
|
} else if (e.key == 'c') {
|
|
8212
8240
|
// caption
|
|
8213
8241
|
display.displayInfo('caption', plot.caption);
|
|
8214
|
-
pressedL = false;
|
|
8242
|
+
control.pressedL = false;
|
|
8215
8243
|
} else if (e.key == 'f') {
|
|
8216
8244
|
display.displayInfo('fill', plot.fill);
|
|
8217
|
-
pressedL = false;
|
|
8245
|
+
control.pressedL = false;
|
|
8218
8246
|
} else if (e.key != 'l') {
|
|
8219
|
-
pressedL = false;
|
|
8247
|
+
control.pressedL = false;
|
|
8220
8248
|
}
|
|
8221
8249
|
}
|
|
8250
|
+
},
|
|
8251
|
+
]);
|
|
8252
|
+
}
|
|
8222
8253
|
|
|
8223
|
-
|
|
8224
|
-
|
|
8225
|
-
|
|
8226
|
-
|
|
8227
|
-
|
|
8254
|
+
/**
|
|
8255
|
+
* Sets up event listeners for main controls
|
|
8256
|
+
* - Arrow keys: basic motion
|
|
8257
|
+
* - Shift + Arrow keys: Autoplay outward
|
|
8258
|
+
* - Shift + Alt + Arrow keys: Autoplay inward
|
|
8259
|
+
* - Ctrl: Stop autoplay
|
|
8260
|
+
* - Ctrl + Arrow keys: Move to end
|
|
8261
|
+
* - Period: Autoplay speed up
|
|
8262
|
+
* - Comma: Autoplay slow down
|
|
8263
|
+
*
|
|
8264
|
+
* @returns {void}
|
|
8265
|
+
*/
|
|
8266
|
+
SetControls() {
|
|
8267
|
+
constants.events.push([
|
|
8268
|
+
document,
|
|
8269
|
+
'keydown',
|
|
8270
|
+
function (e) {
|
|
8271
|
+
// ctrl/cmd: stop autoplay
|
|
8272
|
+
if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
8273
|
+
// (ctrl/cmd)+(home/fn+left arrow): first element
|
|
8274
|
+
if (e.key == 'Home') {
|
|
8275
|
+
// chart types
|
|
8276
|
+
if (constants.chartType == 'bar' || constants.chartType == 'hist') {
|
|
8277
|
+
position.x = 0;
|
|
8278
|
+
} else if (constants.chartType == 'box') {
|
|
8279
|
+
position.x = 0;
|
|
8280
|
+
position.y = plot.sections.length - 1;
|
|
8281
|
+
} else if (constants.chartType == 'heat') {
|
|
8282
|
+
position.x = 0;
|
|
8283
|
+
position.y = 0;
|
|
8284
|
+
} else if (constants.chartType == 'point') {
|
|
8285
|
+
position.x = 0;
|
|
8286
|
+
} else if (constants.chartType == 'smooth') {
|
|
8287
|
+
positionL1.x = 0;
|
|
8288
|
+
}
|
|
8228
8289
|
|
|
8229
|
-
|
|
8230
|
-
|
|
8231
|
-
|
|
8232
|
-
|
|
8233
|
-
|
|
8234
|
-
|
|
8235
|
-
|
|
8236
|
-
|
|
8237
|
-
|
|
8238
|
-
|
|
8290
|
+
control.UpdateAllBraille();
|
|
8291
|
+
}
|
|
8292
|
+
|
|
8293
|
+
// (ctrl/cmd)+(end/fn+right arrow): last element
|
|
8294
|
+
else if (e.key == 'End') {
|
|
8295
|
+
// chart types
|
|
8296
|
+
if (constants.chartType == 'bar' || constants.chartType == 'hist') {
|
|
8297
|
+
position.x = plot.bars.length - 1;
|
|
8298
|
+
} else if (constants.chartType == 'box') {
|
|
8299
|
+
position.x = plot.sections.length - 1;
|
|
8300
|
+
position.y = 0;
|
|
8301
|
+
} else if (constants.chartType == 'heat') {
|
|
8302
|
+
position.x = plot.num_cols - 1;
|
|
8303
|
+
position.y = plot.num_rows - 1;
|
|
8304
|
+
} else if (constants.chartType == 'point') {
|
|
8305
|
+
position.x = plot.y.length - 1;
|
|
8306
|
+
} else if (constants.chartType == 'smooth') {
|
|
8307
|
+
positionL1.x = plot.curvePoints.length - 1;
|
|
8308
|
+
}
|
|
8309
|
+
|
|
8310
|
+
control.UpdateAllBraille();
|
|
8311
|
+
}
|
|
8312
|
+
}
|
|
8239
8313
|
},
|
|
8240
8314
|
]);
|
|
8241
8315
|
|
|
8316
|
+
// Init a few things
|
|
8317
|
+
let lastPlayed = '';
|
|
8242
8318
|
if ([].concat(singleMaidr.type).includes('bar')) {
|
|
8243
8319
|
window.position = new Position(-1, -1);
|
|
8244
|
-
|
|
8245
|
-
|
|
8246
|
-
|
|
8320
|
+
} else if ([].concat(singleMaidr.type).includes('box')) {
|
|
8321
|
+
// variable initialization
|
|
8322
|
+
constants.plotId = 'geom_boxplot.gTree.78.1';
|
|
8323
|
+
if (constants.plotOrientation == 'vert') {
|
|
8324
|
+
window.position = new Position(0, 6); // always 6
|
|
8325
|
+
} else {
|
|
8326
|
+
window.position = new Position(-1, plot.plotData.length);
|
|
8327
|
+
}
|
|
8328
|
+
if (constants.hasRect) {
|
|
8329
|
+
singleMaidr.rect = new BoxplotRect();
|
|
8330
|
+
}
|
|
8331
|
+
} else if ([].concat(singleMaidr.type).includes('heat')) {
|
|
8332
|
+
// variable initialization
|
|
8333
|
+
constants.plotId = 'geom_rect.rect.2.1';
|
|
8334
|
+
window.position = new Position(-1, -1);
|
|
8247
8335
|
constants.lastx = 0;
|
|
8248
|
-
|
|
8336
|
+
} else if (
|
|
8337
|
+
[].concat(singleMaidr.type).includes('point') ||
|
|
8338
|
+
[].concat(singleMaidr.type).includes('smooth')
|
|
8339
|
+
) {
|
|
8340
|
+
constants.plotId = 'geom_point.points.12.1';
|
|
8341
|
+
window.position = new Position(-1, -1);
|
|
8249
8342
|
|
|
8250
|
-
//
|
|
8343
|
+
constants.lastx = 0; // for scatter point layer autoplay use
|
|
8344
|
+
constants.lastx1 = 0; // for smooth layer autoplay use
|
|
8345
|
+
|
|
8346
|
+
window.positionL1 = new Position(constants.lastx1, constants.lastx1);
|
|
8347
|
+
} else if ([].concat(singleMaidr.type).includes('hist')) {
|
|
8348
|
+
window.position = new Position(-1, -1);
|
|
8349
|
+
} else if (
|
|
8350
|
+
[].concat(singleMaidr.type).includes('stacked_bar') ||
|
|
8351
|
+
[].concat(singleMaidr.type).includes('stacked_normalized_bar') ||
|
|
8352
|
+
[].concat(singleMaidr.type).includes('dodged_bar')
|
|
8353
|
+
) {
|
|
8354
|
+
window.position = new Position(-1, -1);
|
|
8355
|
+
}
|
|
8356
|
+
|
|
8357
|
+
// Cursor routing
|
|
8358
|
+
if ([].concat(singleMaidr.type).includes('box')) {
|
|
8251
8359
|
document.addEventListener('selectionchange', function (e) {
|
|
8252
|
-
|
|
8253
|
-
|
|
8360
|
+
e.preventDefault();
|
|
8361
|
+
if (
|
|
8362
|
+
constants.brailleMode == 'on' &&
|
|
8363
|
+
constants.brailleInput.selectionStart
|
|
8364
|
+
) {
|
|
8365
|
+
let cursorPos = constants.brailleInput.selectionStart;
|
|
8254
8366
|
// we're using braille cursor, update the selection from what was clicked
|
|
8255
|
-
|
|
8256
|
-
if (
|
|
8367
|
+
cursorPos = constants.brailleInput.selectionStart;
|
|
8368
|
+
if (cursorPos < 0) {
|
|
8257
8369
|
pos = 0;
|
|
8258
8370
|
}
|
|
8259
|
-
position
|
|
8260
|
-
|
|
8261
|
-
let
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8371
|
+
// convert braille position to start of whatever section we're in
|
|
8372
|
+
let walk = 0;
|
|
8373
|
+
let posType = '';
|
|
8374
|
+
if (constants.brailleData) {
|
|
8375
|
+
for (let i = 0; i < constants.brailleData.length; i++) {
|
|
8376
|
+
walk += constants.brailleData[i].numChars;
|
|
8377
|
+
if (walk > cursorPos) {
|
|
8378
|
+
if (constants.brailleData[i].type == 'blank') {
|
|
8379
|
+
posType = constants.brailleData[i + 1].type;
|
|
8380
|
+
} else {
|
|
8381
|
+
posType = constants.brailleData[i].type;
|
|
8382
|
+
}
|
|
8383
|
+
break;
|
|
8384
|
+
}
|
|
8385
|
+
}
|
|
8266
8386
|
}
|
|
8267
|
-
|
|
8268
|
-
|
|
8387
|
+
let pos = plot.sections.indexOf(posType);
|
|
8388
|
+
|
|
8389
|
+
if (posType.length > 0) {
|
|
8390
|
+
let xMax = 0;
|
|
8391
|
+
let yMax = 0;
|
|
8392
|
+
if (constants.plotOrientation == 'vert') {
|
|
8393
|
+
position.y = pos;
|
|
8394
|
+
xMax = plot.plotData.length - 1;
|
|
8395
|
+
yMax = plot.sections.length - 1;
|
|
8396
|
+
} else {
|
|
8397
|
+
position.x = pos;
|
|
8398
|
+
xMax = plot.sections.length - 1;
|
|
8399
|
+
yMax = plot.plotData.length - 1;
|
|
8400
|
+
}
|
|
8401
|
+
control.lockPosition(xMax, yMax);
|
|
8402
|
+
let testEnd = true;
|
|
8403
|
+
|
|
8404
|
+
// update display / text / audio
|
|
8405
|
+
if (testEnd) {
|
|
8406
|
+
control.UpdateAll();
|
|
8407
|
+
}
|
|
8408
|
+
if (testEnd) {
|
|
8409
|
+
audio.playEnd();
|
|
8410
|
+
}
|
|
8269
8411
|
}
|
|
8270
|
-
} else {
|
|
8271
|
-
// we're using normal cursor, let the default handle it
|
|
8272
8412
|
}
|
|
8273
8413
|
});
|
|
8414
|
+
} else if ([].concat(singleMaidr.type).includes('heat')) {
|
|
8415
|
+
document.addEventListener('selectionchange', function (e) {
|
|
8416
|
+
if (constants.brailleMode == 'on') {
|
|
8417
|
+
let pos = constants.brailleInput.selectionStart;
|
|
8418
|
+
|
|
8419
|
+
// exception: don't let users click the seperator char
|
|
8420
|
+
let seperatorPositions = constants.brailleInput.value
|
|
8421
|
+
.split('')
|
|
8422
|
+
.reduce((positions, char, index) => {
|
|
8423
|
+
if (char === '⠳') positions.push(index);
|
|
8424
|
+
return positions;
|
|
8425
|
+
}, []);
|
|
8426
|
+
if (seperatorPositions.includes(pos)) {
|
|
8427
|
+
return;
|
|
8428
|
+
}
|
|
8429
|
+
|
|
8430
|
+
// we're using braille cursor, update the selection from what was clicked
|
|
8431
|
+
pos = constants.brailleInput.selectionStart;
|
|
8432
|
+
if (pos < 0) {
|
|
8433
|
+
pos = 0;
|
|
8434
|
+
}
|
|
8435
|
+
|
|
8436
|
+
// actual position is based on num_cols and num_rows and the spacer
|
|
8437
|
+
position.y = Math.floor(pos / (plot.num_cols + 1));
|
|
8438
|
+
position.x = pos % (plot.num_cols + 1);
|
|
8439
|
+
control.lockPosition(plot.num_cols - 1, plot.num_rows - 1);
|
|
8440
|
+
let testEnd = true;
|
|
8441
|
+
|
|
8442
|
+
// update display / text / audio
|
|
8443
|
+
if (testEnd) {
|
|
8444
|
+
control.UpdateAll();
|
|
8445
|
+
}
|
|
8446
|
+
if (testEnd) {
|
|
8447
|
+
audio.playEnd();
|
|
8448
|
+
}
|
|
8449
|
+
} else {
|
|
8450
|
+
// we're using normal cursor, let the default handle it
|
|
8451
|
+
}
|
|
8452
|
+
});
|
|
8453
|
+
} else if (
|
|
8454
|
+
[].concat(singleMaidr.type).includes('bar') ||
|
|
8455
|
+
[].concat(singleMaidr.type).includes('point') ||
|
|
8456
|
+
[].concat(singleMaidr.type).includes('smooth') ||
|
|
8457
|
+
[].concat(singleMaidr.type).includes('hist') ||
|
|
8458
|
+
[].concat(singleMaidr.type).includes('stacked_bar') ||
|
|
8459
|
+
[].concat(singleMaidr.type).includes('stacked_normalized_bar') ||
|
|
8460
|
+
[].concat(singleMaidr.type).includes('dodged_bar')
|
|
8461
|
+
) {
|
|
8462
|
+
document.addEventListener('selectionchange', function (e) {
|
|
8463
|
+
if (constants.brailleMode == 'on') {
|
|
8464
|
+
let pos = constants.brailleInput.selectionStart;
|
|
8465
|
+
// we're using braille cursor, update the selection from what was clicked
|
|
8466
|
+
pos = constants.brailleInput.selectionStart;
|
|
8467
|
+
if (pos < 0) {
|
|
8468
|
+
pos = 0;
|
|
8469
|
+
}
|
|
8470
|
+
position.x = pos;
|
|
8471
|
+
control.lockPosition(); // bar etc is default, no need to supply values
|
|
8472
|
+
let testEnd = true;
|
|
8473
|
+
|
|
8474
|
+
// update display / text / audio
|
|
8475
|
+
if (testEnd) {
|
|
8476
|
+
control.UpdateAll();
|
|
8477
|
+
}
|
|
8478
|
+
if (testEnd) {
|
|
8479
|
+
audio.playEnd();
|
|
8480
|
+
}
|
|
8481
|
+
} else {
|
|
8482
|
+
// we're using normal cursor, let the default handle it
|
|
8483
|
+
}
|
|
8484
|
+
});
|
|
8485
|
+
}
|
|
8486
|
+
|
|
8487
|
+
// TODO control rewrite starts here
|
|
8488
|
+
// plan: generally switch from if chart.type > control, to control > if chart.type
|
|
8489
|
+
// This will standardize and separate controls so we can manage more easily, I hope
|
|
8490
|
+
// It'll also mean we have a single control.UpdateAll / control.UpdateAllBraille / etc
|
|
8491
|
+
//
|
|
8492
|
+
// todo
|
|
8493
|
+
// ! move BTS, prefix, chart init to separate functions
|
|
8494
|
+
// ! move ctrl movement at least to top of SetControls, maybe separate function later
|
|
8495
|
+
// ! move cursor routing at least to top of SetControls, maybe separate function later
|
|
8496
|
+
// reroute control.UpdateAll etc to new class level functions
|
|
8497
|
+
// rearrange nested ifs to start with actual controls (just arrow, ctrl arrow, etc), then if chart.type inside
|
|
8498
|
+
// final routing from nested ifs to class level functions
|
|
8499
|
+
// bugfixes :D
|
|
8500
|
+
|
|
8501
|
+
if ([].concat(singleMaidr.type).includes('bar')) {
|
|
8502
|
+
// control eventlisteners
|
|
8503
|
+
constants.events.push([
|
|
8504
|
+
constants.chart,
|
|
8505
|
+
'keydown',
|
|
8506
|
+
function (e) {
|
|
8507
|
+
let updateInfoThisRound = false; // we only update info and play tones on certain keys
|
|
8508
|
+
let isAtEnd = false;
|
|
8274
8509
|
|
|
8275
|
-
// control eventlisteners
|
|
8276
|
-
constants.events.push([
|
|
8277
|
-
constants.chart,
|
|
8278
|
-
'keydown',
|
|
8279
|
-
function (e) {
|
|
8280
|
-
let updateInfoThisRound = false; // we only update info and play tones on certain keys
|
|
8281
|
-
let isAtEnd = false;
|
|
8282
|
-
|
|
8283
8510
|
if (e.key == 'ArrowRight') {
|
|
8284
8511
|
if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
8285
8512
|
if (e.shiftKey) {
|
|
8286
8513
|
position.x -= 1;
|
|
8287
|
-
Autoplay('right', position.x, plot.plotData.length);
|
|
8514
|
+
control.Autoplay('right', position.x, plot.plotData.length);
|
|
8288
8515
|
} else {
|
|
8289
8516
|
position.x = plot.plotData.length - 1; // go all the way
|
|
8290
8517
|
updateInfoThisRound = true;
|
|
8291
|
-
isAtEnd = lockPosition();
|
|
8518
|
+
isAtEnd = control.lockPosition();
|
|
8292
8519
|
}
|
|
8293
8520
|
} else if (
|
|
8294
8521
|
e.altKey &&
|
|
@@ -8296,11 +8523,11 @@ class Control {
|
|
|
8296
8523
|
position.x != plot.bars.length - 1
|
|
8297
8524
|
) {
|
|
8298
8525
|
constants.lastx = position.x;
|
|
8299
|
-
Autoplay('reverse-right', plot.bars.length, position.x);
|
|
8526
|
+
control.Autoplay('reverse-right', plot.bars.length, position.x);
|
|
8300
8527
|
} else {
|
|
8301
8528
|
position.x += 1;
|
|
8302
8529
|
updateInfoThisRound = true;
|
|
8303
|
-
isAtEnd = lockPosition();
|
|
8530
|
+
isAtEnd = control.lockPosition();
|
|
8304
8531
|
}
|
|
8305
8532
|
} else if (e.key == 'ArrowLeft') {
|
|
8306
8533
|
// var prevLink = document.getElementById('prev'); // what is prev in the html?
|
|
@@ -8309,26 +8536,26 @@ class Control {
|
|
|
8309
8536
|
if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
8310
8537
|
if (e.shiftKey) {
|
|
8311
8538
|
position.x += 1;
|
|
8312
|
-
Autoplay('left', position.x, -1);
|
|
8539
|
+
control.Autoplay('left', position.x, -1);
|
|
8313
8540
|
} else {
|
|
8314
8541
|
position.x = 0; // go all the way
|
|
8315
8542
|
updateInfoThisRound = true;
|
|
8316
|
-
isAtEnd = lockPosition();
|
|
8543
|
+
isAtEnd = control.lockPosition();
|
|
8317
8544
|
}
|
|
8318
8545
|
} else if (e.altKey && e.shiftKey && position.x != 0) {
|
|
8319
8546
|
constants.lastx = position.x;
|
|
8320
|
-
Autoplay('reverse-left', -1, position.x);
|
|
8547
|
+
control.Autoplay('reverse-left', -1, position.x);
|
|
8321
8548
|
} else {
|
|
8322
8549
|
position.x += -1;
|
|
8323
8550
|
updateInfoThisRound = true;
|
|
8324
|
-
isAtEnd = lockPosition();
|
|
8551
|
+
isAtEnd = control.lockPosition();
|
|
8325
8552
|
}
|
|
8326
8553
|
// }
|
|
8327
8554
|
}
|
|
8328
8555
|
|
|
8329
8556
|
// update display / text / audio
|
|
8330
8557
|
if (updateInfoThisRound && !isAtEnd) {
|
|
8331
|
-
UpdateAll();
|
|
8558
|
+
control.UpdateAll();
|
|
8332
8559
|
}
|
|
8333
8560
|
if (isAtEnd) {
|
|
8334
8561
|
audio.playEnd();
|
|
@@ -8350,11 +8577,11 @@ class Control {
|
|
|
8350
8577
|
} else if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
8351
8578
|
if (e.shiftKey) {
|
|
8352
8579
|
position.x -= 1;
|
|
8353
|
-
Autoplay('right', position.x, plot.plotData.length);
|
|
8580
|
+
control.Autoplay('right', position.x, plot.plotData.length);
|
|
8354
8581
|
} else {
|
|
8355
8582
|
position.x = plot.bars.length - 1; // go all the way
|
|
8356
8583
|
updateInfoThisRound = true;
|
|
8357
|
-
isAtEnd = lockPosition();
|
|
8584
|
+
isAtEnd = control.lockPosition();
|
|
8358
8585
|
}
|
|
8359
8586
|
} else if (
|
|
8360
8587
|
e.altKey &&
|
|
@@ -8362,11 +8589,11 @@ class Control {
|
|
|
8362
8589
|
position.x != plot.bars.length - 1
|
|
8363
8590
|
) {
|
|
8364
8591
|
constants.lastx = position.x;
|
|
8365
|
-
Autoplay('reverse-right', plot.bars.length, position.x);
|
|
8592
|
+
control.Autoplay('reverse-right', plot.bars.length, position.x);
|
|
8366
8593
|
} else {
|
|
8367
8594
|
position.x += 1;
|
|
8368
8595
|
updateInfoThisRound = true;
|
|
8369
|
-
isAtEnd = lockPosition();
|
|
8596
|
+
isAtEnd = control.lockPosition();
|
|
8370
8597
|
}
|
|
8371
8598
|
} else if (e.key == 'ArrowLeft') {
|
|
8372
8599
|
// left arrow
|
|
@@ -8374,19 +8601,19 @@ class Control {
|
|
|
8374
8601
|
if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
8375
8602
|
if (e.shiftKey) {
|
|
8376
8603
|
position.x += 1;
|
|
8377
|
-
Autoplay('left', position.x, -1);
|
|
8604
|
+
control.Autoplay('left', position.x, -1);
|
|
8378
8605
|
} else {
|
|
8379
8606
|
position.x = 0; // go all the way
|
|
8380
8607
|
updateInfoThisRound = true;
|
|
8381
|
-
isAtEnd = lockPosition();
|
|
8608
|
+
isAtEnd = control.lockPosition();
|
|
8382
8609
|
}
|
|
8383
8610
|
} else if (e.altKey && e.shiftKey && position.x != 0) {
|
|
8384
8611
|
constants.lastx = position.x;
|
|
8385
|
-
Autoplay('reverse-left', -1, position.x);
|
|
8612
|
+
control.Autoplay('reverse-left', -1, position.x);
|
|
8386
8613
|
} else {
|
|
8387
8614
|
position.x += -1;
|
|
8388
8615
|
updateInfoThisRound = true;
|
|
8389
|
-
isAtEnd = lockPosition();
|
|
8616
|
+
isAtEnd = control.lockPosition();
|
|
8390
8617
|
}
|
|
8391
8618
|
} else if (e.key == 'Tab') {
|
|
8392
8619
|
// do nothing, we handle this in global events
|
|
@@ -8396,7 +8623,7 @@ class Control {
|
|
|
8396
8623
|
|
|
8397
8624
|
// update display / text / audio
|
|
8398
8625
|
if (updateInfoThisRound && !isAtEnd) {
|
|
8399
|
-
UpdateAllBraille();
|
|
8626
|
+
control.UpdateAllBraille();
|
|
8400
8627
|
}
|
|
8401
8628
|
if (isAtEnd) {
|
|
8402
8629
|
audio.playEnd();
|
|
@@ -8404,206 +8631,44 @@ class Control {
|
|
|
8404
8631
|
},
|
|
8405
8632
|
]);
|
|
8406
8633
|
|
|
8407
|
-
let
|
|
8408
|
-
let lastx = 0;
|
|
8409
|
-
for (let i = 0; i < controlElements.length; i++) {
|
|
8634
|
+
for (let i = 0; i < this.controlElements.length; i++) {
|
|
8410
8635
|
constants.events.push([
|
|
8411
|
-
controlElements[i],
|
|
8636
|
+
this.controlElements[i],
|
|
8412
8637
|
'keydown',
|
|
8413
8638
|
function (e) {
|
|
8414
8639
|
// period: speed up
|
|
8415
8640
|
if (e.key == '.') {
|
|
8416
8641
|
constants.SpeedUp();
|
|
8417
|
-
PlayDuringSpeedChange();
|
|
8642
|
+
control.PlayDuringSpeedChange();
|
|
8418
8643
|
display.announceText('Speed up');
|
|
8419
8644
|
}
|
|
8420
8645
|
|
|
8421
8646
|
// comma: speed down
|
|
8422
8647
|
if (e.key == ',') {
|
|
8423
8648
|
constants.SpeedDown();
|
|
8424
|
-
PlayDuringSpeedChange();
|
|
8649
|
+
control.PlayDuringSpeedChange();
|
|
8425
8650
|
display.announceText('Speed down');
|
|
8426
8651
|
}
|
|
8427
8652
|
|
|
8428
8653
|
// /: reset speed
|
|
8429
8654
|
if (e.key == '/') {
|
|
8430
8655
|
constants.SpeedReset();
|
|
8431
|
-
PlayDuringSpeedChange();
|
|
8656
|
+
control.PlayDuringSpeedChange();
|
|
8432
8657
|
display.announceText('Speed reset');
|
|
8433
8658
|
}
|
|
8434
8659
|
},
|
|
8435
8660
|
]);
|
|
8436
8661
|
}
|
|
8437
|
-
function PlayDuringSpeedChange() {
|
|
8438
|
-
if (constants.autoplayId != null) {
|
|
8439
|
-
constants.KillAutoplay();
|
|
8440
|
-
if (lastPlayed == 'reverse-left') {
|
|
8441
|
-
Autoplay('right', position.x, lastx);
|
|
8442
|
-
} else if (lastPlayed == 'reverse-right') {
|
|
8443
|
-
Autoplay('left', position.x, lastx);
|
|
8444
|
-
} else {
|
|
8445
|
-
Autoplay(lastPlayed, position.x, lastx);
|
|
8446
|
-
}
|
|
8447
|
-
}
|
|
8448
|
-
}
|
|
8449
|
-
function lockPosition() {
|
|
8450
|
-
// lock to min / max postions
|
|
8451
|
-
let didLockHappen = false;
|
|
8452
|
-
|
|
8453
|
-
if (position.x < 0) {
|
|
8454
|
-
position.x = 0;
|
|
8455
|
-
didLockHappen = true;
|
|
8456
|
-
if (constants.brailleMode != 'off') {
|
|
8457
|
-
// change selection to match postion as well
|
|
8458
|
-
constants.brailleInput.selectionEnd = 0;
|
|
8459
|
-
}
|
|
8460
|
-
}
|
|
8461
|
-
if (position.x > plot.plotData.length - 1) {
|
|
8462
|
-
position.x = plot.plotData.length - 1;
|
|
8463
|
-
didLockHappen = true;
|
|
8464
|
-
constants.brailleInput.selectionEnd = plot.plotData.length - 1;
|
|
8465
|
-
}
|
|
8466
|
-
|
|
8467
|
-
return didLockHappen;
|
|
8468
|
-
}
|
|
8469
|
-
function UpdateAll() {
|
|
8470
|
-
if (constants.showDisplay) {
|
|
8471
|
-
display.displayValues();
|
|
8472
|
-
}
|
|
8473
|
-
if (constants.showRect && constants.hasRect) {
|
|
8474
|
-
plot.Select();
|
|
8475
|
-
}
|
|
8476
|
-
if (constants.sonifMode != 'off') {
|
|
8477
|
-
plot.PlayTones();
|
|
8478
|
-
}
|
|
8479
|
-
}
|
|
8480
|
-
function UpdateAllAutoplay() {
|
|
8481
|
-
if (constants.showDisplayInAutoplay) {
|
|
8482
|
-
display.displayValues();
|
|
8483
|
-
}
|
|
8484
|
-
if (constants.showRect && constants.hasRect) {
|
|
8485
|
-
plot.Select();
|
|
8486
|
-
}
|
|
8487
|
-
if (constants.sonifMode != 'off') {
|
|
8488
|
-
plot.PlayTones();
|
|
8489
|
-
}
|
|
8490
|
-
|
|
8491
|
-
if (constants.brailleMode != 'off') {
|
|
8492
|
-
display.UpdateBraillePos();
|
|
8493
|
-
}
|
|
8494
|
-
}
|
|
8495
|
-
function UpdateAllBraille() {
|
|
8496
|
-
if (constants.showDisplayInBraille) {
|
|
8497
|
-
display.displayValues();
|
|
8498
|
-
}
|
|
8499
|
-
if (constants.showRect && constants.hasRect) {
|
|
8500
|
-
plot.Select();
|
|
8501
|
-
}
|
|
8502
|
-
if (constants.sonifMode != 'off') {
|
|
8503
|
-
plot.PlayTones();
|
|
8504
|
-
}
|
|
8505
|
-
display.UpdateBraillePos();
|
|
8506
|
-
}
|
|
8507
|
-
function Autoplay(dir, start, end) {
|
|
8508
|
-
lastPlayed = dir;
|
|
8509
|
-
let step = 1; // default right and reverse-left
|
|
8510
|
-
if (dir == 'left' || dir == 'reverse-right') {
|
|
8511
|
-
step = -1;
|
|
8512
|
-
}
|
|
8513
|
-
|
|
8514
|
-
// clear old autoplay if exists
|
|
8515
|
-
if (constants.autoplayId != null) {
|
|
8516
|
-
constants.KillAutoplay();
|
|
8517
|
-
}
|
|
8518
|
-
|
|
8519
|
-
if (dir == 'reverse-right' || dir == 'reverse-left') {
|
|
8520
|
-
position.x = start;
|
|
8521
|
-
}
|
|
8522
|
-
|
|
8523
|
-
constants.autoplayId = setInterval(function () {
|
|
8524
|
-
position.x += step;
|
|
8525
|
-
if (!plot || !plot.plotData) {
|
|
8526
|
-
constants.KillAutoplay();
|
|
8527
|
-
return;
|
|
8528
|
-
}
|
|
8529
|
-
if (position.x < 0 || plot.plotData.length - 1 < position.x) {
|
|
8530
|
-
constants.KillAutoplay();
|
|
8531
|
-
lockPosition();
|
|
8532
|
-
} else if (position.x == end) {
|
|
8533
|
-
constants.KillAutoplay();
|
|
8534
|
-
UpdateAllAutoplay();
|
|
8535
|
-
} else {
|
|
8536
|
-
UpdateAllAutoplay();
|
|
8537
|
-
}
|
|
8538
|
-
}, constants.autoPlayRate);
|
|
8539
|
-
}
|
|
8540
8662
|
} else if ([].concat(singleMaidr.type).includes('box')) {
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
window.plot = new BoxPlot();
|
|
8663
|
+
let xMax = 0;
|
|
8664
|
+
let yMax = 0;
|
|
8544
8665
|
if (constants.plotOrientation == 'vert') {
|
|
8545
|
-
|
|
8666
|
+
xMax = plot.plotData.length - 1;
|
|
8667
|
+
yMax = plot.sections.length - 1;
|
|
8546
8668
|
} else {
|
|
8547
|
-
|
|
8548
|
-
|
|
8549
|
-
let rect;
|
|
8550
|
-
if (constants.hasRect) {
|
|
8551
|
-
rect = new BoxplotRect();
|
|
8669
|
+
xMax = plot.sections.length - 1;
|
|
8670
|
+
yMax = plot.plotData.length - 1;
|
|
8552
8671
|
}
|
|
8553
|
-
let lastPlayed = '';
|
|
8554
|
-
|
|
8555
|
-
// braille cursor routing
|
|
8556
|
-
// bug: still not working. Not really sure what's going on but the tethering is now totally broken
|
|
8557
|
-
// like, it doesn't even seem to be on the right plot
|
|
8558
|
-
document.addEventListener('selectionchange', function (e) {
|
|
8559
|
-
e.preventDefault();
|
|
8560
|
-
if (
|
|
8561
|
-
constants.brailleMode == 'on' &&
|
|
8562
|
-
constants.brailleInput.selectionStart
|
|
8563
|
-
) {
|
|
8564
|
-
let cursorPos = constants.brailleInput.selectionStart;
|
|
8565
|
-
// we're using braille cursor, update the selection from what was clicked
|
|
8566
|
-
cursorPos = constants.brailleInput.selectionStart;
|
|
8567
|
-
if (cursorPos < 0) {
|
|
8568
|
-
pos = 0;
|
|
8569
|
-
}
|
|
8570
|
-
// convert braille position to start of whatever section we're in
|
|
8571
|
-
let walk = 0;
|
|
8572
|
-
let posType = '';
|
|
8573
|
-
if (constants.brailleData) {
|
|
8574
|
-
for (let i = 0; i < constants.brailleData.length; i++) {
|
|
8575
|
-
walk += constants.brailleData[i].numChars;
|
|
8576
|
-
if (walk > cursorPos) {
|
|
8577
|
-
if (constants.brailleData[i].type == 'blank') {
|
|
8578
|
-
posType = constants.brailleData[i + 1].type;
|
|
8579
|
-
} else {
|
|
8580
|
-
posType = constants.brailleData[i].type;
|
|
8581
|
-
}
|
|
8582
|
-
break;
|
|
8583
|
-
}
|
|
8584
|
-
}
|
|
8585
|
-
}
|
|
8586
|
-
let pos = plot.sections.indexOf(posType);
|
|
8587
|
-
|
|
8588
|
-
if (posType.length > 0) {
|
|
8589
|
-
if (constants.plotOrientation == 'vert') {
|
|
8590
|
-
position.y = pos;
|
|
8591
|
-
} else {
|
|
8592
|
-
position.x = pos;
|
|
8593
|
-
}
|
|
8594
|
-
lockPosition();
|
|
8595
|
-
let testEnd = true;
|
|
8596
|
-
|
|
8597
|
-
// update display / text / audio
|
|
8598
|
-
if (testEnd) {
|
|
8599
|
-
UpdateAll();
|
|
8600
|
-
}
|
|
8601
|
-
if (testEnd) {
|
|
8602
|
-
audio.playEnd();
|
|
8603
|
-
}
|
|
8604
|
-
}
|
|
8605
|
-
}
|
|
8606
|
-
});
|
|
8607
8672
|
|
|
8608
8673
|
// control eventlisteners
|
|
8609
8674
|
constants.events.push([
|
|
@@ -8619,20 +8684,28 @@ class Control {
|
|
|
8619
8684
|
if (e.shiftKey) {
|
|
8620
8685
|
// autoplay
|
|
8621
8686
|
if (constants.plotOrientation == 'vert') {
|
|
8622
|
-
Autoplay(
|
|
8687
|
+
control.Autoplay(
|
|
8688
|
+
'right',
|
|
8689
|
+
position.x,
|
|
8690
|
+
plot.plotData.length - 1
|
|
8691
|
+
);
|
|
8623
8692
|
} else {
|
|
8624
|
-
Autoplay(
|
|
8693
|
+
control.Autoplay(
|
|
8694
|
+
'right',
|
|
8695
|
+
position.x,
|
|
8696
|
+
plot.sections.length - 1
|
|
8697
|
+
);
|
|
8625
8698
|
}
|
|
8626
8699
|
} else {
|
|
8627
8700
|
// move to end
|
|
8628
|
-
isAtEnd = lockPosition();
|
|
8701
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
8629
8702
|
if (constants.plotOrientation == 'vert') {
|
|
8630
8703
|
position.x = plot.plotData.length - 1;
|
|
8631
8704
|
} else {
|
|
8632
8705
|
position.x = plot.sections.length - 1;
|
|
8633
8706
|
}
|
|
8634
8707
|
updateInfoThisRound = true;
|
|
8635
|
-
isAtEnd = lockPosition();
|
|
8708
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
8636
8709
|
}
|
|
8637
8710
|
} else if (constants.plotOrientation == 'vert') {
|
|
8638
8711
|
if (
|
|
@@ -8641,7 +8714,11 @@ class Control {
|
|
|
8641
8714
|
plot.sections.length - 1 != position.x
|
|
8642
8715
|
) {
|
|
8643
8716
|
lastY = position.y;
|
|
8644
|
-
Autoplay(
|
|
8717
|
+
control.Autoplay(
|
|
8718
|
+
'reverse-right',
|
|
8719
|
+
plot.plotData.length - 1,
|
|
8720
|
+
position.x
|
|
8721
|
+
);
|
|
8645
8722
|
} else {
|
|
8646
8723
|
// normal movement
|
|
8647
8724
|
if (position.x == -1 && position.y == plot.sections.length) {
|
|
@@ -8649,7 +8726,7 @@ class Control {
|
|
|
8649
8726
|
}
|
|
8650
8727
|
position.x += 1;
|
|
8651
8728
|
updateInfoThisRound = true;
|
|
8652
|
-
isAtEnd = lockPosition();
|
|
8729
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
8653
8730
|
}
|
|
8654
8731
|
} else {
|
|
8655
8732
|
if (
|
|
@@ -8658,14 +8735,18 @@ class Control {
|
|
|
8658
8735
|
plot.sections.length - 1 != position.x
|
|
8659
8736
|
) {
|
|
8660
8737
|
constants.lastx = position.x;
|
|
8661
|
-
Autoplay(
|
|
8738
|
+
control.Autoplay(
|
|
8739
|
+
'reverse-right',
|
|
8740
|
+
plot.sections.length - 1,
|
|
8741
|
+
position.x
|
|
8742
|
+
);
|
|
8662
8743
|
} else {
|
|
8663
8744
|
if (position.x == -1 && position.y == plot.plotData.length) {
|
|
8664
8745
|
position.y -= 1;
|
|
8665
8746
|
}
|
|
8666
8747
|
position.x += 1;
|
|
8667
8748
|
updateInfoThisRound = true;
|
|
8668
|
-
isAtEnd = lockPosition();
|
|
8749
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
8669
8750
|
}
|
|
8670
8751
|
}
|
|
8671
8752
|
constants.navigation = 1;
|
|
@@ -8674,11 +8755,11 @@ class Control {
|
|
|
8674
8755
|
if (e.key == 'ArrowLeft') {
|
|
8675
8756
|
if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
8676
8757
|
if (e.shiftKey) {
|
|
8677
|
-
Autoplay('left', position.x, -1);
|
|
8758
|
+
control.Autoplay('left', position.x, -1);
|
|
8678
8759
|
} else {
|
|
8679
8760
|
position.x = 0;
|
|
8680
8761
|
updateInfoThisRound = true;
|
|
8681
|
-
isAtEnd = lockPosition();
|
|
8762
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
8682
8763
|
}
|
|
8683
8764
|
} else if (e.altKey && e.shiftKey && position.x > 0) {
|
|
8684
8765
|
if (constants.plotOrientation == 'vert') {
|
|
@@ -8686,11 +8767,11 @@ class Control {
|
|
|
8686
8767
|
} else {
|
|
8687
8768
|
constants.lastx = position.x;
|
|
8688
8769
|
}
|
|
8689
|
-
Autoplay('reverse-left', 0, position.x);
|
|
8770
|
+
control.Autoplay('reverse-left', 0, position.x);
|
|
8690
8771
|
} else {
|
|
8691
8772
|
position.x += -1;
|
|
8692
8773
|
updateInfoThisRound = true;
|
|
8693
|
-
isAtEnd = lockPosition();
|
|
8774
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
8694
8775
|
}
|
|
8695
8776
|
constants.navigation = 1;
|
|
8696
8777
|
}
|
|
@@ -8700,9 +8781,9 @@ class Control {
|
|
|
8700
8781
|
if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
8701
8782
|
if (e.shiftKey) {
|
|
8702
8783
|
if (constants.plotOrientation == 'vert') {
|
|
8703
|
-
Autoplay('up', position.y, plot.sections.length);
|
|
8784
|
+
control.Autoplay('up', position.y, plot.sections.length);
|
|
8704
8785
|
} else {
|
|
8705
|
-
Autoplay('up', position.y, plot.plotData.length);
|
|
8786
|
+
control.Autoplay('up', position.y, plot.plotData.length);
|
|
8706
8787
|
}
|
|
8707
8788
|
} else {
|
|
8708
8789
|
if (constants.plotOrientation == 'vert') {
|
|
@@ -8711,7 +8792,7 @@ class Control {
|
|
|
8711
8792
|
position.y = plot.plotData.length - 1;
|
|
8712
8793
|
}
|
|
8713
8794
|
updateInfoThisRound = true;
|
|
8714
|
-
isAtEnd = lockPosition();
|
|
8795
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
8715
8796
|
}
|
|
8716
8797
|
} else if (constants.plotOrientation == 'vert') {
|
|
8717
8798
|
if (
|
|
@@ -8720,11 +8801,15 @@ class Control {
|
|
|
8720
8801
|
position.y != plot.sections.length - 1
|
|
8721
8802
|
) {
|
|
8722
8803
|
lastY = position.y;
|
|
8723
|
-
Autoplay(
|
|
8804
|
+
control.Autoplay(
|
|
8805
|
+
'reverse-up',
|
|
8806
|
+
plot.sections.length - 1,
|
|
8807
|
+
position.y
|
|
8808
|
+
);
|
|
8724
8809
|
} else {
|
|
8725
8810
|
position.y += 1;
|
|
8726
8811
|
updateInfoThisRound = true;
|
|
8727
|
-
isAtEnd = lockPosition();
|
|
8812
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
8728
8813
|
}
|
|
8729
8814
|
} else {
|
|
8730
8815
|
if (
|
|
@@ -8733,11 +8818,15 @@ class Control {
|
|
|
8733
8818
|
position.y != plot.sections.length - 1
|
|
8734
8819
|
) {
|
|
8735
8820
|
constants.lastx = position.x;
|
|
8736
|
-
Autoplay(
|
|
8821
|
+
control.Autoplay(
|
|
8822
|
+
'reverse-up',
|
|
8823
|
+
plot.plotData.length - 1,
|
|
8824
|
+
position.y
|
|
8825
|
+
);
|
|
8737
8826
|
} else {
|
|
8738
8827
|
position.y += 1;
|
|
8739
8828
|
updateInfoThisRound = true;
|
|
8740
|
-
isAtEnd = lockPosition();
|
|
8829
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
8741
8830
|
}
|
|
8742
8831
|
}
|
|
8743
8832
|
constants.navigation = 0;
|
|
@@ -8747,11 +8836,11 @@ class Control {
|
|
|
8747
8836
|
let oldY = position.y;
|
|
8748
8837
|
if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
8749
8838
|
if (e.shiftKey) {
|
|
8750
|
-
Autoplay('down', position.y, -1);
|
|
8839
|
+
control.Autoplay('down', position.y, -1);
|
|
8751
8840
|
} else {
|
|
8752
8841
|
position.y = 0;
|
|
8753
8842
|
updateInfoThisRound = true;
|
|
8754
|
-
isAtEnd = lockPosition();
|
|
8843
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
8755
8844
|
}
|
|
8756
8845
|
} else if (e.altKey && e.shiftKey && position.y != 0) {
|
|
8757
8846
|
if (constants.plotOrientation == 'vert') {
|
|
@@ -8759,7 +8848,7 @@ class Control {
|
|
|
8759
8848
|
} else {
|
|
8760
8849
|
constants.lastx = position.x;
|
|
8761
8850
|
}
|
|
8762
|
-
Autoplay('reverse-down', 0, position.y);
|
|
8851
|
+
control.Autoplay('reverse-down', 0, position.y);
|
|
8763
8852
|
} else {
|
|
8764
8853
|
if (constants.plotOrientation == 'vert') {
|
|
8765
8854
|
if (position.x == -1 && position.y == plot.sections.length) {
|
|
@@ -8772,7 +8861,7 @@ class Control {
|
|
|
8772
8861
|
}
|
|
8773
8862
|
position.y += -1;
|
|
8774
8863
|
updateInfoThisRound = true;
|
|
8775
|
-
isAtEnd = lockPosition();
|
|
8864
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
8776
8865
|
}
|
|
8777
8866
|
//position.x = GetRelativeBoxPosition(oldY, position.y);
|
|
8778
8867
|
constants.navigation = 0;
|
|
@@ -8780,7 +8869,7 @@ class Control {
|
|
|
8780
8869
|
|
|
8781
8870
|
// update display / text / audio
|
|
8782
8871
|
if (updateInfoThisRound && !isAtEnd) {
|
|
8783
|
-
UpdateAll();
|
|
8872
|
+
control.UpdateAll();
|
|
8784
8873
|
}
|
|
8785
8874
|
if (isAtEnd) {
|
|
8786
8875
|
audio.playEnd();
|
|
@@ -8802,9 +8891,13 @@ class Control {
|
|
|
8802
8891
|
if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
8803
8892
|
if (e.shiftKey) {
|
|
8804
8893
|
if (constants.plotOrientation == 'vert') {
|
|
8805
|
-
Autoplay(
|
|
8894
|
+
control.Autoplay(
|
|
8895
|
+
'right',
|
|
8896
|
+
position.x,
|
|
8897
|
+
plot.plotData.length - 1
|
|
8898
|
+
);
|
|
8806
8899
|
} else {
|
|
8807
|
-
Autoplay('right', position.x, plot.sections.length);
|
|
8900
|
+
control.Autoplay('right', position.x, plot.sections.length);
|
|
8808
8901
|
}
|
|
8809
8902
|
} else {
|
|
8810
8903
|
if (constants.plotOrientation == 'vert') {
|
|
@@ -8813,7 +8906,7 @@ class Control {
|
|
|
8813
8906
|
position.x = plot.sections.length - 1;
|
|
8814
8907
|
}
|
|
8815
8908
|
updateInfoThisRound = true;
|
|
8816
|
-
isAtEnd = lockPosition();
|
|
8909
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
8817
8910
|
}
|
|
8818
8911
|
} else if (constants.plotOrientation == 'vert') {
|
|
8819
8912
|
if (
|
|
@@ -8822,7 +8915,11 @@ class Control {
|
|
|
8822
8915
|
plot.plotData.length - 1 != position.x
|
|
8823
8916
|
) {
|
|
8824
8917
|
lastY = position.y;
|
|
8825
|
-
Autoplay(
|
|
8918
|
+
control.Autoplay(
|
|
8919
|
+
'reverse-right',
|
|
8920
|
+
plot.plotData.length - 1,
|
|
8921
|
+
position.x
|
|
8922
|
+
);
|
|
8826
8923
|
} else {
|
|
8827
8924
|
if (
|
|
8828
8925
|
position.x == -1 &&
|
|
@@ -8832,7 +8929,7 @@ class Control {
|
|
|
8832
8929
|
}
|
|
8833
8930
|
position.x += 1;
|
|
8834
8931
|
updateInfoThisRound = true;
|
|
8835
|
-
isAtEnd = lockPosition();
|
|
8932
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
8836
8933
|
}
|
|
8837
8934
|
} else {
|
|
8838
8935
|
if (
|
|
@@ -8841,14 +8938,18 @@ class Control {
|
|
|
8841
8938
|
plot.sections.length - 1 != position.x
|
|
8842
8939
|
) {
|
|
8843
8940
|
constants.lastx = position.x;
|
|
8844
|
-
Autoplay(
|
|
8941
|
+
control.Autoplay(
|
|
8942
|
+
'reverse-right',
|
|
8943
|
+
plot.sections.length - 1,
|
|
8944
|
+
position.x
|
|
8945
|
+
);
|
|
8845
8946
|
} else {
|
|
8846
8947
|
if (position.x == -1 && position.y == plot.plotData.length) {
|
|
8847
8948
|
position.y -= 1;
|
|
8848
8949
|
}
|
|
8849
8950
|
position.x += 1;
|
|
8850
8951
|
updateInfoThisRound = true;
|
|
8851
|
-
isAtEnd = lockPosition();
|
|
8952
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
8852
8953
|
}
|
|
8853
8954
|
}
|
|
8854
8955
|
setBrailleThisRound = true;
|
|
@@ -8858,11 +8959,11 @@ class Control {
|
|
|
8858
8959
|
e.preventDefault();
|
|
8859
8960
|
if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
8860
8961
|
if (e.shiftKey) {
|
|
8861
|
-
Autoplay('left', position.x, -1);
|
|
8962
|
+
control.Autoplay('left', position.x, -1);
|
|
8862
8963
|
} else {
|
|
8863
8964
|
position.x = 0;
|
|
8864
8965
|
updateInfoThisRound = true;
|
|
8865
|
-
isAtEnd = lockPosition();
|
|
8966
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
8866
8967
|
}
|
|
8867
8968
|
} else if (e.altKey && e.shiftKey && position.x > 0) {
|
|
8868
8969
|
if (constants.plotOrientation == 'vert') {
|
|
@@ -8870,11 +8971,11 @@ class Control {
|
|
|
8870
8971
|
} else {
|
|
8871
8972
|
constants.lastx = position.x;
|
|
8872
8973
|
}
|
|
8873
|
-
Autoplay('reverse-left', 0, position.x);
|
|
8974
|
+
control.Autoplay('reverse-left', 0, position.x);
|
|
8874
8975
|
} else {
|
|
8875
8976
|
position.x += -1;
|
|
8876
8977
|
updateInfoThisRound = true;
|
|
8877
|
-
isAtEnd = lockPosition();
|
|
8978
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
8878
8979
|
}
|
|
8879
8980
|
setBrailleThisRound = true;
|
|
8880
8981
|
constants.navigation = 1;
|
|
@@ -8885,9 +8986,9 @@ class Control {
|
|
|
8885
8986
|
if (e.shiftKey) {
|
|
8886
8987
|
if (constants.plotOrientation == 'vert') {
|
|
8887
8988
|
if (position.x < 0) position.x = 0;
|
|
8888
|
-
Autoplay('up', position.y, plot.sections.length);
|
|
8989
|
+
control.Autoplay('up', position.y, plot.sections.length);
|
|
8889
8990
|
} else {
|
|
8890
|
-
Autoplay('up', position.y, plot.plotData.length);
|
|
8991
|
+
control.Autoplay('up', position.y, plot.plotData.length);
|
|
8891
8992
|
}
|
|
8892
8993
|
} else if (constants.plotOrientation == 'vert') {
|
|
8893
8994
|
position.y = plot.sections.length - 1;
|
|
@@ -8903,11 +9004,15 @@ class Control {
|
|
|
8903
9004
|
position.y != plot.sections.length - 1
|
|
8904
9005
|
) {
|
|
8905
9006
|
lasY = position.y;
|
|
8906
|
-
Autoplay(
|
|
9007
|
+
control.Autoplay(
|
|
9008
|
+
'reverse-up',
|
|
9009
|
+
plot.sections.length - 1,
|
|
9010
|
+
position.y
|
|
9011
|
+
);
|
|
8907
9012
|
} else {
|
|
8908
9013
|
position.y += 1;
|
|
8909
9014
|
updateInfoThisRound = true;
|
|
8910
|
-
isAtEnd = lockPosition();
|
|
9015
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
8911
9016
|
}
|
|
8912
9017
|
} else {
|
|
8913
9018
|
if (
|
|
@@ -8916,11 +9021,15 @@ class Control {
|
|
|
8916
9021
|
position.y != plot.plotData.length - 1
|
|
8917
9022
|
) {
|
|
8918
9023
|
constants.lastx = position.x;
|
|
8919
|
-
Autoplay(
|
|
9024
|
+
control.Autoplay(
|
|
9025
|
+
'reverse-up',
|
|
9026
|
+
plot.plotData.length - 1,
|
|
9027
|
+
position.y
|
|
9028
|
+
);
|
|
8920
9029
|
} else {
|
|
8921
9030
|
position.y += 1;
|
|
8922
9031
|
updateInfoThisRound = true;
|
|
8923
|
-
isAtEnd = lockPosition();
|
|
9032
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
8924
9033
|
}
|
|
8925
9034
|
}
|
|
8926
9035
|
if (constants.plotOrientation == 'vert') {
|
|
@@ -8933,11 +9042,11 @@ class Control {
|
|
|
8933
9042
|
let oldY = position.y;
|
|
8934
9043
|
if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
8935
9044
|
if (e.shiftKey) {
|
|
8936
|
-
Autoplay('down', position.y, -1);
|
|
9045
|
+
control.Autoplay('down', position.y, -1);
|
|
8937
9046
|
} else {
|
|
8938
9047
|
position.y = 0;
|
|
8939
9048
|
updateInfoThisRound = true;
|
|
8940
|
-
isAtEnd = lockPosition();
|
|
9049
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
8941
9050
|
}
|
|
8942
9051
|
} else if (e.altKey && e.shiftKey && position.y != 0) {
|
|
8943
9052
|
if (constants.plotOrientation == 'vert') {
|
|
@@ -8945,7 +9054,7 @@ class Control {
|
|
|
8945
9054
|
} else {
|
|
8946
9055
|
constants.lastx = position.x;
|
|
8947
9056
|
}
|
|
8948
|
-
Autoplay('reverse-down', 0, position.y);
|
|
9057
|
+
control.Autoplay('reverse-down', 0, position.y);
|
|
8949
9058
|
} else {
|
|
8950
9059
|
if (constants.plotOrientation == 'vert') {
|
|
8951
9060
|
if (position.x == -1 && position.y == plot.sections.length) {
|
|
@@ -8958,7 +9067,7 @@ class Control {
|
|
|
8958
9067
|
}
|
|
8959
9068
|
position.y += -1;
|
|
8960
9069
|
updateInfoThisRound = true;
|
|
8961
|
-
isAtEnd = lockPosition();
|
|
9070
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
8962
9071
|
}
|
|
8963
9072
|
constants.navigation = 0;
|
|
8964
9073
|
if (constants.plotOrientation == 'vert') {
|
|
@@ -8976,7 +9085,7 @@ class Control {
|
|
|
8976
9085
|
// update audio. todo: add a setting for this later
|
|
8977
9086
|
if (updateInfoThisRound && !isAtEnd) {
|
|
8978
9087
|
if (setBrailleThisRound) display.SetBraille(plot);
|
|
8979
|
-
setTimeout(UpdateAllBraille, 50); // we delay this by just a moment as otherwise the cursor position doesn't get set
|
|
9088
|
+
setTimeout(control.UpdateAllBraille, 50); // we delay this by just a moment as otherwise the cursor position doesn't get set
|
|
8980
9089
|
}
|
|
8981
9090
|
if (isAtEnd) {
|
|
8982
9091
|
audio.playEnd();
|
|
@@ -8984,332 +9093,93 @@ class Control {
|
|
|
8984
9093
|
},
|
|
8985
9094
|
]);
|
|
8986
9095
|
|
|
8987
|
-
let controlElements = [constants.chart, constants.brailleInput];
|
|
8988
9096
|
let lastx = 0;
|
|
8989
|
-
for (let i = 0; i < controlElements.length; i++) {
|
|
9097
|
+
for (let i = 0; i < this.controlElements.length; i++) {
|
|
8990
9098
|
constants.events.push([
|
|
8991
|
-
controlElements[i],
|
|
9099
|
+
this.controlElements[i],
|
|
8992
9100
|
'keydown',
|
|
8993
9101
|
function (e) {
|
|
8994
9102
|
// period: speed up
|
|
8995
9103
|
if (e.key == '.') {
|
|
8996
9104
|
constants.SpeedUp();
|
|
8997
|
-
PlayDuringSpeedChange();
|
|
9105
|
+
control.PlayDuringSpeedChange();
|
|
8998
9106
|
display.announceText('Speed up');
|
|
8999
9107
|
}
|
|
9000
9108
|
|
|
9001
9109
|
// comma: speed down
|
|
9002
9110
|
if (e.key == ',') {
|
|
9003
9111
|
constants.SpeedDown();
|
|
9004
|
-
PlayDuringSpeedChange();
|
|
9112
|
+
control.PlayDuringSpeedChange();
|
|
9005
9113
|
display.announceText('Speed down');
|
|
9006
9114
|
}
|
|
9007
9115
|
|
|
9008
9116
|
// /: reset speed
|
|
9009
9117
|
if (e.key == '/') {
|
|
9010
9118
|
constants.SpeedReset();
|
|
9011
|
-
PlayDuringSpeedChange();
|
|
9119
|
+
control.PlayDuringSpeedChange();
|
|
9012
9120
|
display.announceText('Speed reset');
|
|
9013
9121
|
}
|
|
9014
9122
|
},
|
|
9015
9123
|
]);
|
|
9016
9124
|
}
|
|
9017
|
-
|
|
9018
|
-
|
|
9019
|
-
|
|
9020
|
-
|
|
9021
|
-
|
|
9022
|
-
|
|
9023
|
-
|
|
9024
|
-
|
|
9025
|
-
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
|
|
9029
|
-
|
|
9030
|
-
|
|
9031
|
-
|
|
9032
|
-
|
|
9033
|
-
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
9038
|
-
|
|
9039
|
-
|
|
9040
|
-
|
|
9125
|
+
} else if ([].concat(singleMaidr.type).includes('heat')) {
|
|
9126
|
+
let xMax = plot.num_cols - 1;
|
|
9127
|
+
let yMax = plot.num_rows - 1;
|
|
9128
|
+
// control eventlisteners
|
|
9129
|
+
constants.events.push([
|
|
9130
|
+
constants.chart,
|
|
9131
|
+
'keydown',
|
|
9132
|
+
function (e) {
|
|
9133
|
+
let updateInfoThisRound = false;
|
|
9134
|
+
let isAtEnd = false;
|
|
9135
|
+
|
|
9136
|
+
// right arrow 39
|
|
9137
|
+
if (e.key == 'ArrowRight') {
|
|
9138
|
+
if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
9139
|
+
if (e.shiftKey) {
|
|
9140
|
+
position.x -= 1;
|
|
9141
|
+
control.Autoplay('right', position.x, plot.num_cols);
|
|
9142
|
+
} else {
|
|
9143
|
+
position.x = plot.num_cols - 1;
|
|
9144
|
+
updateInfoThisRound = true;
|
|
9145
|
+
}
|
|
9146
|
+
} else if (
|
|
9147
|
+
e.altKey &&
|
|
9148
|
+
e.shiftKey &&
|
|
9149
|
+
position.x != plot.num_cols - 1
|
|
9150
|
+
) {
|
|
9151
|
+
constants.lastx = position.x;
|
|
9152
|
+
control.Autoplay('reverse-right', plot.num_cols, position.x);
|
|
9041
9153
|
} else {
|
|
9042
|
-
|
|
9154
|
+
if (position.x == -1 && position.y == -1) {
|
|
9155
|
+
position.y += 1;
|
|
9156
|
+
}
|
|
9157
|
+
position.x += 1;
|
|
9158
|
+
updateInfoThisRound = true;
|
|
9159
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
9043
9160
|
}
|
|
9044
|
-
|
|
9045
|
-
|
|
9046
|
-
|
|
9161
|
+
constants.navigation = 1;
|
|
9162
|
+
}
|
|
9163
|
+
|
|
9164
|
+
// left arrow 37
|
|
9165
|
+
if (e.key == 'ArrowLeft') {
|
|
9166
|
+
if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
9167
|
+
if (e.shiftKey) {
|
|
9168
|
+
position.x += 1;
|
|
9169
|
+
control.Autoplay('left', position.x, -1);
|
|
9170
|
+
} else {
|
|
9171
|
+
position.x = 0;
|
|
9172
|
+
updateInfoThisRound = true;
|
|
9173
|
+
}
|
|
9174
|
+
} else if (e.altKey && e.shiftKey && position.x != 0) {
|
|
9175
|
+
constants.lastx = position.x;
|
|
9176
|
+
control.Autoplay('reverse-left', -1, position.x);
|
|
9047
9177
|
} else {
|
|
9048
|
-
|
|
9178
|
+
position.x -= 1;
|
|
9179
|
+
updateInfoThisRound = true;
|
|
9180
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
9049
9181
|
}
|
|
9050
|
-
|
|
9051
|
-
}
|
|
9052
|
-
}
|
|
9053
|
-
|
|
9054
|
-
function UpdateAll() {
|
|
9055
|
-
if (constants.showDisplay) {
|
|
9056
|
-
display.displayValues();
|
|
9057
|
-
}
|
|
9058
|
-
if (constants.showRect && constants.hasRect) {
|
|
9059
|
-
rect.UpdateRect();
|
|
9060
|
-
}
|
|
9061
|
-
if (constants.sonifMode != 'off') {
|
|
9062
|
-
plot.PlayTones();
|
|
9063
|
-
}
|
|
9064
|
-
}
|
|
9065
|
-
function UpdateAllAutoplay() {
|
|
9066
|
-
if (constants.showDisplayInAutoplay) {
|
|
9067
|
-
display.displayValues();
|
|
9068
|
-
}
|
|
9069
|
-
if (constants.showRect && constants.hasRect) {
|
|
9070
|
-
rect.UpdateRect();
|
|
9071
|
-
}
|
|
9072
|
-
if (constants.sonifMode != 'off') {
|
|
9073
|
-
plot.PlayTones();
|
|
9074
|
-
}
|
|
9075
|
-
if (constants.brailleMode != 'off') {
|
|
9076
|
-
display.UpdateBraillePos();
|
|
9077
|
-
}
|
|
9078
|
-
}
|
|
9079
|
-
function UpdateAllBraille() {
|
|
9080
|
-
if (constants.showDisplayInBraille) {
|
|
9081
|
-
display.displayValues();
|
|
9082
|
-
}
|
|
9083
|
-
if (constants.showRect && constants.hasRect) {
|
|
9084
|
-
rect.UpdateRect();
|
|
9085
|
-
}
|
|
9086
|
-
if (constants.sonifMode != 'off') {
|
|
9087
|
-
plot.PlayTones();
|
|
9088
|
-
}
|
|
9089
|
-
display.UpdateBraillePos();
|
|
9090
|
-
}
|
|
9091
|
-
function lockPosition() {
|
|
9092
|
-
// lock to min / max postions
|
|
9093
|
-
let didLockHappen = false;
|
|
9094
|
-
if (position.y < 0) {
|
|
9095
|
-
position.y = 0;
|
|
9096
|
-
didLockHappen = true;
|
|
9097
|
-
}
|
|
9098
|
-
if (position.x < 0) {
|
|
9099
|
-
position.x = 0;
|
|
9100
|
-
didLockHappen = true;
|
|
9101
|
-
}
|
|
9102
|
-
if (constants.plotOrientation == 'vert') {
|
|
9103
|
-
if (position.x > plot.plotData.length - 1) {
|
|
9104
|
-
position.x = plot.plotData.length - 1;
|
|
9105
|
-
didLockHappen = true;
|
|
9106
|
-
}
|
|
9107
|
-
if (position.y > plot.sections.length - 1) {
|
|
9108
|
-
position.y = plot.sections.length - 1;
|
|
9109
|
-
didLockHappen = true;
|
|
9110
|
-
}
|
|
9111
|
-
} else {
|
|
9112
|
-
if (position.y > plot.plotData.length - 1) {
|
|
9113
|
-
position.y = plot.plotData.length - 1;
|
|
9114
|
-
didLockHappen = true;
|
|
9115
|
-
}
|
|
9116
|
-
if (position.x > plot.sections.length - 1) {
|
|
9117
|
-
position.x = plot.sections.length - 1;
|
|
9118
|
-
didLockHappen = true;
|
|
9119
|
-
}
|
|
9120
|
-
}
|
|
9121
|
-
|
|
9122
|
-
return didLockHappen;
|
|
9123
|
-
}
|
|
9124
|
-
|
|
9125
|
-
function Autoplay(dir, start, end) {
|
|
9126
|
-
lastPlayed = dir;
|
|
9127
|
-
let step = 1; // default right / up / reverse-left / reverse-down
|
|
9128
|
-
if (
|
|
9129
|
-
dir == 'left' ||
|
|
9130
|
-
dir == 'down' ||
|
|
9131
|
-
dir == 'reverse-right' ||
|
|
9132
|
-
dir == 'reverse-up'
|
|
9133
|
-
) {
|
|
9134
|
-
step = -1;
|
|
9135
|
-
}
|
|
9136
|
-
|
|
9137
|
-
// clear old autoplay if exists
|
|
9138
|
-
if (constants.autoplayId != null) {
|
|
9139
|
-
constants.KillAutoplay();
|
|
9140
|
-
}
|
|
9141
|
-
|
|
9142
|
-
if (dir == 'reverse-left' || dir == 'reverse-right') {
|
|
9143
|
-
position.x = start;
|
|
9144
|
-
} else if (dir == 'reverse-up' || dir == 'reverse-down') {
|
|
9145
|
-
position.y = start;
|
|
9146
|
-
}
|
|
9147
|
-
|
|
9148
|
-
if (constants.debugLevel > 0) {
|
|
9149
|
-
console.log('starting autoplay', dir, start, end);
|
|
9150
|
-
}
|
|
9151
|
-
|
|
9152
|
-
UpdateAllAutoplay(); // play current tone before we move
|
|
9153
|
-
constants.autoplayId = setInterval(function () {
|
|
9154
|
-
let doneNext = false;
|
|
9155
|
-
if (dir == 'left' || dir == 'right' || dir == 'up' || dir == 'down') {
|
|
9156
|
-
if (
|
|
9157
|
-
(position.x < 1 && dir == 'left') ||
|
|
9158
|
-
(constants.plotOrientation == 'vert' &&
|
|
9159
|
-
dir == 'up' &&
|
|
9160
|
-
position.y > plot.sections.length - 2) ||
|
|
9161
|
-
(constants.plotOrientation == 'horz' &&
|
|
9162
|
-
dir == 'up' &&
|
|
9163
|
-
position.y > plot.plotData.length - 2) ||
|
|
9164
|
-
(constants.plotOrientation == 'horz' &&
|
|
9165
|
-
dir == 'right' &&
|
|
9166
|
-
position.x > plot.sections.length - 2) ||
|
|
9167
|
-
(constants.plotOrientation == 'vert' &&
|
|
9168
|
-
dir == 'right' &&
|
|
9169
|
-
position.x > plot.plotData.length - 2) ||
|
|
9170
|
-
(constants.plotOrientation == 'horz' &&
|
|
9171
|
-
dir == 'down' &&
|
|
9172
|
-
position.y < 1) ||
|
|
9173
|
-
(constants.plotOrientation == 'vert' &&
|
|
9174
|
-
dir == 'down' &&
|
|
9175
|
-
position.y < 1)
|
|
9176
|
-
) {
|
|
9177
|
-
doneNext = true;
|
|
9178
|
-
}
|
|
9179
|
-
} else {
|
|
9180
|
-
if (
|
|
9181
|
-
(dir == 'reverse-left' && position.x >= end) ||
|
|
9182
|
-
(dir == 'reverse-right' && position.x <= end) ||
|
|
9183
|
-
(dir == 'reverse-up' && position.y <= end) ||
|
|
9184
|
-
(dir == 'reverse-down' && position.y >= end)
|
|
9185
|
-
) {
|
|
9186
|
-
doneNext = true;
|
|
9187
|
-
}
|
|
9188
|
-
}
|
|
9189
|
-
|
|
9190
|
-
if (doneNext) {
|
|
9191
|
-
constants.KillAutoplay();
|
|
9192
|
-
} else {
|
|
9193
|
-
if (
|
|
9194
|
-
dir == 'left' ||
|
|
9195
|
-
dir == 'right' ||
|
|
9196
|
-
dir == 'reverse-left' ||
|
|
9197
|
-
dir == 'reverse-right'
|
|
9198
|
-
) {
|
|
9199
|
-
position.x += step;
|
|
9200
|
-
} else {
|
|
9201
|
-
position.y += step;
|
|
9202
|
-
}
|
|
9203
|
-
UpdateAllAutoplay();
|
|
9204
|
-
}
|
|
9205
|
-
if (constants.debugLevel > 5) {
|
|
9206
|
-
console.log('autoplay pos', position);
|
|
9207
|
-
}
|
|
9208
|
-
}, constants.autoPlayRate);
|
|
9209
|
-
}
|
|
9210
|
-
} else if ([].concat(singleMaidr.type).includes('heat')) {
|
|
9211
|
-
// variable initialization
|
|
9212
|
-
constants.plotId = 'geom_rect.rect.2.1';
|
|
9213
|
-
window.position = new Position(-1, -1);
|
|
9214
|
-
window.plot = new HeatMap();
|
|
9215
|
-
let rect = new HeatMapRect();
|
|
9216
|
-
let lastPlayed = '';
|
|
9217
|
-
constants.lastx = 0;
|
|
9218
|
-
|
|
9219
|
-
document.addEventListener('selectionchange', function (e) {
|
|
9220
|
-
if (constants.brailleMode == 'on') {
|
|
9221
|
-
let pos = constants.brailleInput.selectionStart;
|
|
9222
|
-
|
|
9223
|
-
// exception: don't let users click the seperator char
|
|
9224
|
-
let seperatorPositions = constants.brailleInput.value
|
|
9225
|
-
.split('')
|
|
9226
|
-
.reduce((positions, char, index) => {
|
|
9227
|
-
if (char === '⠳') positions.push(index);
|
|
9228
|
-
return positions;
|
|
9229
|
-
}, []);
|
|
9230
|
-
if (seperatorPositions.includes(pos)) {
|
|
9231
|
-
return;
|
|
9232
|
-
}
|
|
9233
|
-
|
|
9234
|
-
// we're using braille cursor, update the selection from what was clicked
|
|
9235
|
-
pos = constants.brailleInput.selectionStart;
|
|
9236
|
-
if (pos < 0) {
|
|
9237
|
-
pos = 0;
|
|
9238
|
-
}
|
|
9239
|
-
|
|
9240
|
-
// actual position is based on num_cols and num_rows and the spacer
|
|
9241
|
-
position.y = Math.floor(pos / (plot.num_cols + 1));
|
|
9242
|
-
position.x = pos % (plot.num_cols + 1);
|
|
9243
|
-
lockPosition();
|
|
9244
|
-
let testEnd = true;
|
|
9245
|
-
|
|
9246
|
-
// update display / text / audio
|
|
9247
|
-
if (testEnd) {
|
|
9248
|
-
UpdateAll();
|
|
9249
|
-
}
|
|
9250
|
-
if (testEnd) {
|
|
9251
|
-
audio.playEnd();
|
|
9252
|
-
}
|
|
9253
|
-
} else {
|
|
9254
|
-
// we're using normal cursor, let the default handle it
|
|
9255
|
-
}
|
|
9256
|
-
});
|
|
9257
|
-
|
|
9258
|
-
// control eventlisteners
|
|
9259
|
-
constants.events.push([
|
|
9260
|
-
constants.chart,
|
|
9261
|
-
'keydown',
|
|
9262
|
-
function (e) {
|
|
9263
|
-
let updateInfoThisRound = false;
|
|
9264
|
-
let isAtEnd = false;
|
|
9265
|
-
|
|
9266
|
-
// right arrow 39
|
|
9267
|
-
if (e.key == 'ArrowRight') {
|
|
9268
|
-
if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
9269
|
-
if (e.shiftKey) {
|
|
9270
|
-
position.x -= 1;
|
|
9271
|
-
Autoplay('right', position.x, plot.num_cols);
|
|
9272
|
-
} else {
|
|
9273
|
-
position.x = plot.num_cols - 1;
|
|
9274
|
-
updateInfoThisRound = true;
|
|
9275
|
-
}
|
|
9276
|
-
} else if (
|
|
9277
|
-
e.altKey &&
|
|
9278
|
-
e.shiftKey &&
|
|
9279
|
-
position.x != plot.num_cols - 1
|
|
9280
|
-
) {
|
|
9281
|
-
constants.lastx = position.x;
|
|
9282
|
-
Autoplay('reverse-right', plot.num_cols, position.x);
|
|
9283
|
-
} else {
|
|
9284
|
-
if (position.x == -1 && position.y == -1) {
|
|
9285
|
-
position.y += 1;
|
|
9286
|
-
}
|
|
9287
|
-
position.x += 1;
|
|
9288
|
-
updateInfoThisRound = true;
|
|
9289
|
-
isAtEnd = lockPosition();
|
|
9290
|
-
}
|
|
9291
|
-
constants.navigation = 1;
|
|
9292
|
-
}
|
|
9293
|
-
|
|
9294
|
-
// left arrow 37
|
|
9295
|
-
if (e.key == 'ArrowLeft') {
|
|
9296
|
-
if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
9297
|
-
if (e.shiftKey) {
|
|
9298
|
-
position.x += 1;
|
|
9299
|
-
Autoplay('left', position.x, -1);
|
|
9300
|
-
} else {
|
|
9301
|
-
position.x = 0;
|
|
9302
|
-
updateInfoThisRound = true;
|
|
9303
|
-
}
|
|
9304
|
-
} else if (e.altKey && e.shiftKey && position.x != 0) {
|
|
9305
|
-
constants.lastx = position.x;
|
|
9306
|
-
Autoplay('reverse-left', -1, position.x);
|
|
9307
|
-
} else {
|
|
9308
|
-
position.x -= 1;
|
|
9309
|
-
updateInfoThisRound = true;
|
|
9310
|
-
isAtEnd = lockPosition();
|
|
9311
|
-
}
|
|
9312
|
-
constants.navigation = 1;
|
|
9182
|
+
constants.navigation = 1;
|
|
9313
9183
|
}
|
|
9314
9184
|
|
|
9315
9185
|
// up arrow 38
|
|
@@ -9317,18 +9187,18 @@ class Control {
|
|
|
9317
9187
|
if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
9318
9188
|
if (e.shiftKey) {
|
|
9319
9189
|
position.y += 1;
|
|
9320
|
-
Autoplay('up', position.y, -1);
|
|
9190
|
+
control.Autoplay('up', position.y, -1);
|
|
9321
9191
|
} else {
|
|
9322
9192
|
position.y = 0;
|
|
9323
9193
|
updateInfoThisRound = true;
|
|
9324
9194
|
}
|
|
9325
9195
|
} else if (e.altKey && e.shiftKey && position.y != 0) {
|
|
9326
9196
|
constants.lastx = position.x;
|
|
9327
|
-
Autoplay('reverse-up', -1, position.y);
|
|
9197
|
+
control.Autoplay('reverse-up', -1, position.y);
|
|
9328
9198
|
} else {
|
|
9329
9199
|
position.y -= 1;
|
|
9330
9200
|
updateInfoThisRound = true;
|
|
9331
|
-
isAtEnd = lockPosition();
|
|
9201
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
9332
9202
|
}
|
|
9333
9203
|
constants.navigation = 0;
|
|
9334
9204
|
}
|
|
@@ -9338,7 +9208,7 @@ class Control {
|
|
|
9338
9208
|
if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
9339
9209
|
if (e.shiftKey) {
|
|
9340
9210
|
position.y -= 1;
|
|
9341
|
-
Autoplay('down', position.y, plot.num_rows);
|
|
9211
|
+
control.Autoplay('down', position.y, plot.num_rows);
|
|
9342
9212
|
} else {
|
|
9343
9213
|
position.y = plot.num_rows - 1;
|
|
9344
9214
|
updateInfoThisRound = true;
|
|
@@ -9349,23 +9219,21 @@ class Control {
|
|
|
9349
9219
|
position.y != plot.num_rows - 1
|
|
9350
9220
|
) {
|
|
9351
9221
|
constants.lastx = position.x;
|
|
9352
|
-
Autoplay('reverse-down', plot.num_rows, position.y);
|
|
9222
|
+
control.Autoplay('reverse-down', plot.num_rows, position.y);
|
|
9353
9223
|
} else {
|
|
9354
9224
|
if (position.x == -1 && position.y == -1) {
|
|
9355
9225
|
position.x += 1;
|
|
9356
9226
|
}
|
|
9357
9227
|
position.y += 1;
|
|
9358
9228
|
updateInfoThisRound = true;
|
|
9359
|
-
isAtEnd = lockPosition();
|
|
9229
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
9360
9230
|
}
|
|
9361
9231
|
constants.navigation = 0;
|
|
9362
9232
|
}
|
|
9363
9233
|
|
|
9364
|
-
console.log('position: ' + position.x + ', ' + position.y);
|
|
9365
|
-
|
|
9366
9234
|
// update text, display, and audio
|
|
9367
9235
|
if (updateInfoThisRound && !isAtEnd) {
|
|
9368
|
-
UpdateAll();
|
|
9236
|
+
control.UpdateAll();
|
|
9369
9237
|
}
|
|
9370
9238
|
if (isAtEnd) {
|
|
9371
9239
|
audio.playEnd();
|
|
@@ -9373,52 +9241,35 @@ class Control {
|
|
|
9373
9241
|
},
|
|
9374
9242
|
]);
|
|
9375
9243
|
|
|
9376
|
-
let
|
|
9377
|
-
let lastx = 0;
|
|
9378
|
-
for (let i = 0; i < controlElements.length; i++) {
|
|
9244
|
+
for (let i = 0; i < this.controlElements.length; i++) {
|
|
9379
9245
|
constants.events.push([
|
|
9380
|
-
controlElements[i],
|
|
9246
|
+
this.controlElements[i],
|
|
9381
9247
|
'keydown',
|
|
9382
9248
|
function (e) {
|
|
9383
9249
|
// period: speed up
|
|
9384
9250
|
if (e.key == '.') {
|
|
9385
9251
|
constants.SpeedUp();
|
|
9386
|
-
PlayDuringSpeedChange();
|
|
9252
|
+
control.PlayDuringSpeedChange();
|
|
9387
9253
|
display.announceText('Speed up');
|
|
9388
9254
|
}
|
|
9389
9255
|
|
|
9390
9256
|
// comma: speed down
|
|
9391
9257
|
if (e.key == ',') {
|
|
9392
9258
|
constants.SpeedDown();
|
|
9393
|
-
PlayDuringSpeedChange();
|
|
9259
|
+
control.PlayDuringSpeedChange();
|
|
9394
9260
|
display.announceText('Speed down');
|
|
9395
9261
|
}
|
|
9396
9262
|
|
|
9397
9263
|
// /: reset speed
|
|
9398
9264
|
if (e.key == '/') {
|
|
9399
9265
|
constants.SpeedReset();
|
|
9400
|
-
PlayDuringSpeedChange();
|
|
9266
|
+
control.PlayDuringSpeedChange();
|
|
9401
9267
|
display.announceText('Speed reset');
|
|
9402
9268
|
}
|
|
9403
9269
|
},
|
|
9404
9270
|
]);
|
|
9405
9271
|
}
|
|
9406
|
-
function PlayDuringSpeedChange() {
|
|
9407
|
-
if (constants.autoplayId != null) {
|
|
9408
|
-
constants.KillAutoplay();
|
|
9409
|
-
if (lastPlayed == 'reverse-left') {
|
|
9410
|
-
Autoplay('right', position.x, lastx);
|
|
9411
|
-
} else if (lastPlayed == 'reverse-right') {
|
|
9412
|
-
Autoplay('left', position.x, lastx);
|
|
9413
|
-
} else if (lastPlayed == 'reverse-up') {
|
|
9414
|
-
Autoplay('down', position.x, lastx);
|
|
9415
|
-
} else if (lastPlayed == 'reverse-down') {
|
|
9416
|
-
Autoplay('up', position.x, lastx);
|
|
9417
|
-
} else {
|
|
9418
|
-
Autoplay(lastPlayed, position.x, lastx);
|
|
9419
|
-
}
|
|
9420
|
-
}
|
|
9421
|
-
}
|
|
9272
|
+
function PlayDuringSpeedChange() {}
|
|
9422
9273
|
|
|
9423
9274
|
constants.events.push([
|
|
9424
9275
|
constants.brailleInput,
|
|
@@ -9446,7 +9297,7 @@ class Control {
|
|
|
9446
9297
|
}
|
|
9447
9298
|
if (e.shiftKey) {
|
|
9448
9299
|
position.x -= 1;
|
|
9449
|
-
Autoplay('right', position.x, plot.num_cols);
|
|
9300
|
+
control.Autoplay('right', position.x, plot.num_cols);
|
|
9450
9301
|
} else {
|
|
9451
9302
|
position.x = plot.num_cols - 1;
|
|
9452
9303
|
updateInfoThisRound = true;
|
|
@@ -9457,14 +9308,14 @@ class Control {
|
|
|
9457
9308
|
position.x != plot.num_cols - 1
|
|
9458
9309
|
) {
|
|
9459
9310
|
constants.lastx = position.x;
|
|
9460
|
-
Autoplay('reverse-right', plot.num_cols, position.x);
|
|
9311
|
+
control.Autoplay('reverse-right', plot.num_cols, position.x);
|
|
9461
9312
|
} else {
|
|
9462
9313
|
if (position.x == -1 && position.y == -1) {
|
|
9463
9314
|
position.y += 1;
|
|
9464
9315
|
}
|
|
9465
9316
|
position.x += 1;
|
|
9466
9317
|
updateInfoThisRound = true;
|
|
9467
|
-
isAtEnd = lockPosition();
|
|
9318
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
9468
9319
|
}
|
|
9469
9320
|
|
|
9470
9321
|
// we need pos to be y*(num_cols+1), (and num_cols+1 because there's a spacer character)
|
|
@@ -9488,18 +9339,18 @@ class Control {
|
|
|
9488
9339
|
if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
9489
9340
|
if (e.shiftKey) {
|
|
9490
9341
|
position.x += 1;
|
|
9491
|
-
Autoplay('left', position.x, -1);
|
|
9342
|
+
control.Autoplay('left', position.x, -1);
|
|
9492
9343
|
} else {
|
|
9493
9344
|
position.x = 0;
|
|
9494
9345
|
updateInfoThisRound = true;
|
|
9495
9346
|
}
|
|
9496
9347
|
} else if (e.altKey && e.shiftKey && position.x != 0) {
|
|
9497
9348
|
constants.lastx = position.x;
|
|
9498
|
-
Autoplay('reverse-left', -1, position.x);
|
|
9349
|
+
control.Autoplay('reverse-left', -1, position.x);
|
|
9499
9350
|
} else {
|
|
9500
9351
|
position.x += -1;
|
|
9501
9352
|
updateInfoThisRound = true;
|
|
9502
|
-
isAtEnd = lockPosition();
|
|
9353
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
9503
9354
|
}
|
|
9504
9355
|
|
|
9505
9356
|
let pos = position.y * (plot.num_cols + 1) + position.x;
|
|
@@ -9520,7 +9371,7 @@ class Control {
|
|
|
9520
9371
|
}
|
|
9521
9372
|
if (e.shiftKey) {
|
|
9522
9373
|
position.y -= 1;
|
|
9523
|
-
Autoplay('down', position.y, plot.num_rows);
|
|
9374
|
+
control.Autoplay('down', position.y, plot.num_rows);
|
|
9524
9375
|
} else {
|
|
9525
9376
|
position.y = plot.num_rows - 1;
|
|
9526
9377
|
updateInfoThisRound = true;
|
|
@@ -9531,14 +9382,14 @@ class Control {
|
|
|
9531
9382
|
position.y != plot.num_rows - 1
|
|
9532
9383
|
) {
|
|
9533
9384
|
constants.lastx = position.x;
|
|
9534
|
-
Autoplay('reverse-down', plot.num_rows, position.y);
|
|
9385
|
+
control.Autoplay('reverse-down', plot.num_rows, position.y);
|
|
9535
9386
|
} else {
|
|
9536
9387
|
if (position.x == -1 && position.y == -1) {
|
|
9537
9388
|
position.x += 1;
|
|
9538
9389
|
}
|
|
9539
9390
|
position.y += 1;
|
|
9540
9391
|
updateInfoThisRound = true;
|
|
9541
|
-
isAtEnd = lockPosition();
|
|
9392
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
9542
9393
|
}
|
|
9543
9394
|
|
|
9544
9395
|
let pos = position.y * (plot.num_cols + 1) + position.x;
|
|
@@ -9555,18 +9406,18 @@ class Control {
|
|
|
9555
9406
|
if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
9556
9407
|
if (e.shiftKey) {
|
|
9557
9408
|
position.y += 1;
|
|
9558
|
-
Autoplay('up', position.y, -1);
|
|
9409
|
+
control.Autoplay('up', position.y, -1);
|
|
9559
9410
|
} else {
|
|
9560
9411
|
position.y = 0;
|
|
9561
9412
|
updateInfoThisRound = true;
|
|
9562
9413
|
}
|
|
9563
9414
|
} else if (e.altKey && e.shiftKey && position.y != 0) {
|
|
9564
9415
|
constants.lastx = position.x;
|
|
9565
|
-
Autoplay('reverse-up', -1, position.y);
|
|
9416
|
+
control.Autoplay('reverse-up', -1, position.y);
|
|
9566
9417
|
} else {
|
|
9567
9418
|
position.y += -1;
|
|
9568
9419
|
updateInfoThisRound = true;
|
|
9569
|
-
isAtEnd = lockPosition();
|
|
9420
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
9570
9421
|
}
|
|
9571
9422
|
|
|
9572
9423
|
let pos = position.y * (plot.num_cols + 1) + position.x;
|
|
@@ -9582,7 +9433,7 @@ class Control {
|
|
|
9582
9433
|
}
|
|
9583
9434
|
|
|
9584
9435
|
if (updateInfoThisRound && !isAtEnd) {
|
|
9585
|
-
UpdateAllBraille();
|
|
9436
|
+
control.UpdateAllBraille();
|
|
9586
9437
|
}
|
|
9587
9438
|
if (isAtEnd) {
|
|
9588
9439
|
audio.playEnd();
|
|
@@ -9590,146 +9441,17 @@ class Control {
|
|
|
9590
9441
|
},
|
|
9591
9442
|
]);
|
|
9592
9443
|
|
|
9593
|
-
function sleep(time) {
|
|
9594
|
-
return new Promise((resolve) => setTimeout(resolve, time));
|
|
9595
|
-
}
|
|
9596
|
-
|
|
9597
|
-
// heat helper functions
|
|
9598
|
-
function lockPosition() {
|
|
9599
|
-
// lock to min / max postions
|
|
9600
|
-
let didLockHappen = false;
|
|
9601
|
-
|
|
9602
|
-
if (position.x < 0) {
|
|
9603
|
-
position.x = 0;
|
|
9604
|
-
didLockHappen = true;
|
|
9605
|
-
}
|
|
9606
|
-
if (position.x > plot.num_cols - 1) {
|
|
9607
|
-
position.x = plot.num_cols - 1;
|
|
9608
|
-
didLockHappen = true;
|
|
9609
|
-
}
|
|
9610
|
-
if (position.y < 0) {
|
|
9611
|
-
position.y = 0;
|
|
9612
|
-
didLockHappen = true;
|
|
9613
|
-
}
|
|
9614
|
-
if (position.y > plot.num_rows - 1) {
|
|
9615
|
-
position.y = plot.num_rows - 1;
|
|
9616
|
-
didLockHappen = true;
|
|
9617
|
-
}
|
|
9618
|
-
|
|
9619
|
-
return didLockHappen;
|
|
9620
|
-
}
|
|
9621
|
-
|
|
9622
|
-
function UpdateAll() {
|
|
9623
|
-
if (constants.showDisplay) {
|
|
9624
|
-
display.displayValues();
|
|
9625
|
-
}
|
|
9626
|
-
if (constants.showRect && constants.hasRect) {
|
|
9627
|
-
rect.UpdateRectDisplay();
|
|
9628
|
-
}
|
|
9629
|
-
if (constants.sonifMode != 'off') {
|
|
9630
|
-
plot.PlayTones();
|
|
9631
|
-
}
|
|
9632
|
-
}
|
|
9633
|
-
function UpdateAllAutoplay() {
|
|
9634
|
-
if (constants.showDisplayInAutoplay) {
|
|
9635
|
-
display.displayValues();
|
|
9636
|
-
}
|
|
9637
|
-
if (constants.showRect && constants.hasRect) {
|
|
9638
|
-
rect.UpdateRectDisplay();
|
|
9639
|
-
}
|
|
9640
|
-
if (constants.sonifMode != 'off') {
|
|
9641
|
-
plot.PlayTones();
|
|
9642
|
-
}
|
|
9643
|
-
if (constants.brailleMode != 'off') {
|
|
9644
|
-
display.UpdateBraillePos();
|
|
9645
|
-
}
|
|
9646
|
-
}
|
|
9647
|
-
function UpdateAllBraille() {
|
|
9648
|
-
if (constants.showDisplayInBraille) {
|
|
9649
|
-
display.displayValues();
|
|
9650
|
-
}
|
|
9651
|
-
if (constants.showRect && constants.hasRect) {
|
|
9652
|
-
rect.UpdateRectDisplay();
|
|
9653
|
-
}
|
|
9654
|
-
if (constants.sonifMode != 'off') {
|
|
9655
|
-
plot.PlayTones();
|
|
9656
|
-
}
|
|
9657
|
-
display.UpdateBraillePos();
|
|
9658
|
-
}
|
|
9659
|
-
|
|
9660
|
-
function Autoplay(dir, start, end) {
|
|
9661
|
-
lastPlayed = dir;
|
|
9662
|
-
let step = 1; // default right, down, reverse-left, and reverse-up
|
|
9663
|
-
if (
|
|
9664
|
-
dir == 'left' ||
|
|
9665
|
-
dir == 'up' ||
|
|
9666
|
-
dir == 'reverse-right' ||
|
|
9667
|
-
dir == 'reverse-down'
|
|
9668
|
-
) {
|
|
9669
|
-
step = -1;
|
|
9670
|
-
}
|
|
9671
|
-
|
|
9672
|
-
// clear old autoplay if exists
|
|
9673
|
-
if (constants.autoplayId != null) {
|
|
9674
|
-
constants.KillAutoplay();
|
|
9675
|
-
}
|
|
9676
|
-
|
|
9677
|
-
if (dir == 'reverse-left' || dir == 'reverse-right') {
|
|
9678
|
-
position.x = start;
|
|
9679
|
-
} else if (dir == 'reverse-up' || dir == 'reverse-down') {
|
|
9680
|
-
position.y = start;
|
|
9681
|
-
}
|
|
9682
|
-
|
|
9683
|
-
constants.autoplayId = setInterval(function () {
|
|
9684
|
-
if (!plot) return;
|
|
9685
|
-
if (
|
|
9686
|
-
dir == 'left' ||
|
|
9687
|
-
dir == 'right' ||
|
|
9688
|
-
dir == 'reverse-left' ||
|
|
9689
|
-
dir == 'reverse-right'
|
|
9690
|
-
) {
|
|
9691
|
-
position.x += step;
|
|
9692
|
-
if (position.x < 0 || plot.num_cols - 1 < position.x) {
|
|
9693
|
-
constants.KillAutoplay();
|
|
9694
|
-
lockPosition();
|
|
9695
|
-
} else if (position.x == end) {
|
|
9696
|
-
constants.KillAutoplay();
|
|
9697
|
-
UpdateAllAutoplay();
|
|
9698
|
-
} else {
|
|
9699
|
-
UpdateAllAutoplay();
|
|
9700
|
-
}
|
|
9701
|
-
} else {
|
|
9702
|
-
// up or down
|
|
9703
|
-
position.y += step;
|
|
9704
|
-
if (position.y < 0 || plot.num_rows - 1 < position.y) {
|
|
9705
|
-
constants.KillAutoplay();
|
|
9706
|
-
lockPosition();
|
|
9707
|
-
} else if (position.y == end) {
|
|
9708
|
-
constants.KillAutoplay();
|
|
9709
|
-
UpdateAllAutoplay();
|
|
9710
|
-
} else {
|
|
9711
|
-
UpdateAllAutoplay();
|
|
9712
|
-
}
|
|
9713
|
-
}
|
|
9714
|
-
}, constants.autoPlayRate);
|
|
9715
|
-
}
|
|
9716
9444
|
} else if (
|
|
9717
9445
|
[].concat(singleMaidr.type).includes('point') ||
|
|
9718
9446
|
[].concat(singleMaidr.type).includes('smooth')
|
|
9719
9447
|
) {
|
|
9720
|
-
|
|
9721
|
-
|
|
9722
|
-
|
|
9723
|
-
|
|
9724
|
-
|
|
9725
|
-
|
|
9726
|
-
|
|
9727
|
-
let lastPlayed = ''; // for autoplay use
|
|
9728
|
-
constants.lastx = 0; // for scatter point layer autoplay use
|
|
9729
|
-
let lastx1 = 0; // for smooth layer autoplay use
|
|
9730
|
-
|
|
9731
|
-
window.positionL1 = new Position(lastx1, lastx1);
|
|
9732
|
-
|
|
9448
|
+
let xMax = 0;
|
|
9449
|
+
let yMax = 0;
|
|
9450
|
+
if (constants.chartType == 'point') {
|
|
9451
|
+
xMax = plot.x.length - 1;
|
|
9452
|
+
} else if (constants.chartType == 'smooth') {
|
|
9453
|
+
xMax = plot.curvePoints.length - 1;
|
|
9454
|
+
}
|
|
9733
9455
|
// control eventlisteners
|
|
9734
9456
|
constants.events.push([
|
|
9735
9457
|
[constants.chart, constants.brailleInput],
|
|
@@ -9745,11 +9467,11 @@ class Control {
|
|
|
9745
9467
|
if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
9746
9468
|
if (e.shiftKey) {
|
|
9747
9469
|
position.x -= 1;
|
|
9748
|
-
Autoplay('right', position.x, plot.x.length);
|
|
9470
|
+
control.Autoplay('right', position.x, plot.x.length);
|
|
9749
9471
|
} else {
|
|
9750
9472
|
position.x = plot.x.length - 1;
|
|
9751
9473
|
updateInfoThisRound = true;
|
|
9752
|
-
isAtEnd = lockPosition();
|
|
9474
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
9753
9475
|
}
|
|
9754
9476
|
} else if (
|
|
9755
9477
|
e.altKey &&
|
|
@@ -9757,11 +9479,11 @@ class Control {
|
|
|
9757
9479
|
position.x != plot.x.length - 1
|
|
9758
9480
|
) {
|
|
9759
9481
|
constants.lastx = position.x;
|
|
9760
|
-
Autoplay('reverse-right', plot.x.length, position.x);
|
|
9482
|
+
control.Autoplay('reverse-right', plot.x.length, position.x);
|
|
9761
9483
|
} else {
|
|
9762
9484
|
position.x += 1;
|
|
9763
9485
|
updateInfoThisRound = true;
|
|
9764
|
-
isAtEnd = lockPosition();
|
|
9486
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
9765
9487
|
}
|
|
9766
9488
|
}
|
|
9767
9489
|
|
|
@@ -9770,24 +9492,24 @@ class Control {
|
|
|
9770
9492
|
if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
9771
9493
|
if (e.shiftKey) {
|
|
9772
9494
|
position.x += 1;
|
|
9773
|
-
Autoplay('left', position.x, -1);
|
|
9495
|
+
control.Autoplay('left', position.x, -1);
|
|
9774
9496
|
} else {
|
|
9775
9497
|
position.x = 0;
|
|
9776
9498
|
updateInfoThisRound = true;
|
|
9777
|
-
isAtEnd = lockPosition();
|
|
9499
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
9778
9500
|
}
|
|
9779
9501
|
} else if (e.altKey && e.shiftKey && position.x != 0) {
|
|
9780
9502
|
constants.lastx = position.x;
|
|
9781
|
-
Autoplay('reverse-left', -1, position.x);
|
|
9503
|
+
control.Autoplay('reverse-left', -1, position.x);
|
|
9782
9504
|
} else {
|
|
9783
9505
|
position.x -= 1;
|
|
9784
9506
|
updateInfoThisRound = true;
|
|
9785
|
-
isAtEnd = lockPosition();
|
|
9507
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
9786
9508
|
}
|
|
9787
9509
|
}
|
|
9788
9510
|
} else if (constants.chartType == 'smooth') {
|
|
9789
9511
|
if (!positionL1.x) {
|
|
9790
|
-
positionL1.x = lastx1;
|
|
9512
|
+
positionL1.x = constants.lastx1;
|
|
9791
9513
|
}
|
|
9792
9514
|
|
|
9793
9515
|
if (e.key == 'ArrowRight' && e.shiftKey) {
|
|
@@ -9795,9 +9517,9 @@ class Control {
|
|
|
9795
9517
|
(constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
9796
9518
|
constants.sonifMode != 'off'
|
|
9797
9519
|
) {
|
|
9798
|
-
PlayLine('right');
|
|
9520
|
+
control.PlayLine('right');
|
|
9799
9521
|
} else if (e.altKey && constants.sonifMode != 'off') {
|
|
9800
|
-
PlayLine('reverse-right');
|
|
9522
|
+
control.PlayLine('reverse-right');
|
|
9801
9523
|
}
|
|
9802
9524
|
}
|
|
9803
9525
|
|
|
@@ -9806,9 +9528,9 @@ class Control {
|
|
|
9806
9528
|
(constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
9807
9529
|
constants.sonifMode != 'off'
|
|
9808
9530
|
) {
|
|
9809
|
-
PlayLine('left');
|
|
9531
|
+
control.PlayLine('left');
|
|
9810
9532
|
} else if (e.altKey && constants.sonifMode != 'off') {
|
|
9811
|
-
PlayLine('reverse-left');
|
|
9533
|
+
control.PlayLine('reverse-left');
|
|
9812
9534
|
}
|
|
9813
9535
|
}
|
|
9814
9536
|
}
|
|
@@ -9819,7 +9541,7 @@ class Control {
|
|
|
9819
9541
|
constants.chartType == 'point' &&
|
|
9820
9542
|
!isAtEnd
|
|
9821
9543
|
) {
|
|
9822
|
-
UpdateAll();
|
|
9544
|
+
control.UpdateAll();
|
|
9823
9545
|
}
|
|
9824
9546
|
if (isAtEnd) {
|
|
9825
9547
|
audio.playEnd();
|
|
@@ -9827,99 +9549,47 @@ class Control {
|
|
|
9827
9549
|
},
|
|
9828
9550
|
]);
|
|
9829
9551
|
|
|
9830
|
-
let controlElements = [constants.chart, constants.brailleInput];
|
|
9831
9552
|
let lastx = 0;
|
|
9832
|
-
for (let i = 0; i < controlElements.length; i++) {
|
|
9553
|
+
for (let i = 0; i < this.controlElements.length; i++) {
|
|
9833
9554
|
constants.events.push([
|
|
9834
|
-
controlElements[i],
|
|
9555
|
+
this.controlElements[i],
|
|
9835
9556
|
'keydown',
|
|
9836
9557
|
function (e) {
|
|
9837
9558
|
// period: speed up
|
|
9838
9559
|
if (e.key == '.') {
|
|
9839
9560
|
constants.SpeedUp();
|
|
9840
|
-
PlayDuringSpeedChange();
|
|
9561
|
+
control.PlayDuringSpeedChange();
|
|
9841
9562
|
display.announceText('Speed up');
|
|
9842
9563
|
}
|
|
9843
9564
|
|
|
9844
9565
|
// comma: speed down
|
|
9845
9566
|
if (e.key == ',') {
|
|
9846
9567
|
constants.SpeedDown();
|
|
9847
|
-
PlayDuringSpeedChange();
|
|
9568
|
+
control.PlayDuringSpeedChange();
|
|
9848
9569
|
display.announceText('Speed down');
|
|
9849
9570
|
}
|
|
9850
9571
|
|
|
9851
9572
|
// /: reset speed
|
|
9852
9573
|
if (e.key == '/') {
|
|
9853
9574
|
constants.SpeedReset();
|
|
9854
|
-
PlayDuringSpeedChange();
|
|
9575
|
+
control.PlayDuringSpeedChange();
|
|
9855
9576
|
display.announceText('Speed reset');
|
|
9856
9577
|
}
|
|
9857
9578
|
},
|
|
9858
9579
|
]);
|
|
9859
9580
|
}
|
|
9860
|
-
function PlayDuringSpeedChange() {
|
|
9861
|
-
if (constants.autoplayId != null) {
|
|
9862
|
-
constants.KillAutoplay();
|
|
9863
|
-
audio.KillSmooth();
|
|
9864
|
-
if (lastPlayed == 'reverse-left') {
|
|
9865
|
-
if (constants.chartType == 'point') {
|
|
9866
|
-
Autoplay('right', position.x, lastx);
|
|
9867
|
-
} else if (constants.chartType == 'smooth') {
|
|
9868
|
-
Autoplay('right', positionL1.x, lastx1);
|
|
9869
|
-
}
|
|
9870
|
-
} else if (lastPlayed == 'reverse-right') {
|
|
9871
|
-
if (constants.chartType == 'point') {
|
|
9872
|
-
Autoplay('left', position.x, lastx);
|
|
9873
|
-
} else if (constants.chartType == 'smooth') {
|
|
9874
|
-
Autoplay('left', positionL1.x, lastx1);
|
|
9875
|
-
}
|
|
9876
|
-
} else {
|
|
9877
|
-
if (constants.chartType == 'point') {
|
|
9878
|
-
Autoplay(lastPlayed, position.x, lastx);
|
|
9879
|
-
} else if (constants.chartType == 'smooth') {
|
|
9880
|
-
Autoplay(lastPlayed, positionL1.x, lastx1);
|
|
9881
|
-
}
|
|
9882
|
-
}
|
|
9883
|
-
}
|
|
9884
|
-
}
|
|
9885
9581
|
|
|
9886
|
-
|
|
9887
|
-
|
|
9888
|
-
|
|
9889
|
-
|
|
9890
|
-
let
|
|
9891
|
-
|
|
9892
|
-
pos = constants.brailleInput.selectionStart;
|
|
9893
|
-
if (pos < 0) {
|
|
9894
|
-
pos = 0;
|
|
9895
|
-
}
|
|
9896
|
-
positionL1.x = pos;
|
|
9897
|
-
lockPosition();
|
|
9898
|
-
let testEnd = true;
|
|
9899
|
-
|
|
9900
|
-
// update display / text / audio
|
|
9901
|
-
if (testEnd) {
|
|
9902
|
-
UpdateAllBraille();
|
|
9903
|
-
}
|
|
9904
|
-
if (testEnd) {
|
|
9905
|
-
audio.playEnd();
|
|
9906
|
-
}
|
|
9907
|
-
} else {
|
|
9908
|
-
// we're using normal cursor, let the default handle it
|
|
9909
|
-
}
|
|
9910
|
-
});
|
|
9911
|
-
|
|
9912
|
-
constants.events.push([
|
|
9913
|
-
constants.brailleInput,
|
|
9914
|
-
'keydown',
|
|
9915
|
-
function (e) {
|
|
9916
|
-
let updateInfoThisRound = false;
|
|
9917
|
-
let isAtEnd = false;
|
|
9582
|
+
constants.events.push([
|
|
9583
|
+
constants.brailleInput,
|
|
9584
|
+
'keydown',
|
|
9585
|
+
function (e) {
|
|
9586
|
+
let updateInfoThisRound = false;
|
|
9587
|
+
let isAtEnd = false;
|
|
9918
9588
|
|
|
9919
9589
|
// @TODO
|
|
9920
9590
|
// only smooth layer can access to braille display
|
|
9921
9591
|
if (constants.chartType == 'smooth') {
|
|
9922
|
-
lockPosition();
|
|
9592
|
+
control.lockPosition(xMax, yMax);
|
|
9923
9593
|
if (e.key == 'ArrowRight') {
|
|
9924
9594
|
// right arrow
|
|
9925
9595
|
e.preventDefault();
|
|
@@ -9932,19 +9602,23 @@ class Control {
|
|
|
9932
9602
|
} else if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
9933
9603
|
if (e.shiftKey) {
|
|
9934
9604
|
positionL1.x -= 1;
|
|
9935
|
-
Autoplay(
|
|
9605
|
+
control.Autoplay(
|
|
9606
|
+
'right',
|
|
9607
|
+
positionL1.x,
|
|
9608
|
+
plot.curvePoints.length
|
|
9609
|
+
);
|
|
9936
9610
|
} else {
|
|
9937
9611
|
positionL1.x = plot.curvePoints.length - 1;
|
|
9938
9612
|
updateInfoThisRound = true;
|
|
9939
|
-
isAtEnd = lockPosition();
|
|
9613
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
9940
9614
|
}
|
|
9941
9615
|
} else if (
|
|
9942
9616
|
e.altKey &&
|
|
9943
9617
|
e.shiftKey &&
|
|
9944
9618
|
positionL1.x != plot.curvePoints.length - 1
|
|
9945
9619
|
) {
|
|
9946
|
-
lastx1 = positionL1.x;
|
|
9947
|
-
Autoplay(
|
|
9620
|
+
constants.lastx1 = positionL1.x;
|
|
9621
|
+
control.Autoplay(
|
|
9948
9622
|
'reverse-right',
|
|
9949
9623
|
plot.curvePoints.length,
|
|
9950
9624
|
positionL1.x
|
|
@@ -9952,7 +9626,7 @@ class Control {
|
|
|
9952
9626
|
} else {
|
|
9953
9627
|
positionL1.x += 1;
|
|
9954
9628
|
updateInfoThisRound = true;
|
|
9955
|
-
isAtEnd = lockPosition();
|
|
9629
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
9956
9630
|
}
|
|
9957
9631
|
} else if (e.key == 'ArrowLeft') {
|
|
9958
9632
|
// left
|
|
@@ -9960,18 +9634,18 @@ class Control {
|
|
|
9960
9634
|
if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
9961
9635
|
if (e.shiftKey) {
|
|
9962
9636
|
positionL1.x += 1;
|
|
9963
|
-
Autoplay('left', positionL1.x, -1);
|
|
9637
|
+
control.Autoplay('left', positionL1.x, -1);
|
|
9964
9638
|
} else {
|
|
9965
9639
|
positionL1.x = 0; // go all the way
|
|
9966
9640
|
updateInfoThisRound = true;
|
|
9967
|
-
isAtEnd = lockPosition();
|
|
9641
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
9968
9642
|
}
|
|
9969
9643
|
} else if (e.altKey && e.shiftKey && positionL1.x != 0) {
|
|
9970
|
-
Autoplay('reverse-left', -1, positionL1.x);
|
|
9644
|
+
control.Autoplay('reverse-left', -1, positionL1.x);
|
|
9971
9645
|
} else {
|
|
9972
9646
|
positionL1.x -= 1;
|
|
9973
9647
|
updateInfoThisRound = true;
|
|
9974
|
-
isAtEnd = lockPosition();
|
|
9648
|
+
isAtEnd = control.lockPosition(xMax, yMax);
|
|
9975
9649
|
}
|
|
9976
9650
|
} else {
|
|
9977
9651
|
e.preventDefault();
|
|
@@ -9982,258 +9656,17 @@ class Control {
|
|
|
9982
9656
|
e.preventDefault();
|
|
9983
9657
|
}
|
|
9984
9658
|
|
|
9985
|
-
lastx1 = positionL1.x;
|
|
9659
|
+
constants.lastx1 = positionL1.x;
|
|
9986
9660
|
|
|
9987
9661
|
if (updateInfoThisRound && !isAtEnd) {
|
|
9988
|
-
UpdateAllBraille();
|
|
9662
|
+
control.UpdateAllBraille();
|
|
9989
9663
|
}
|
|
9990
9664
|
if (isAtEnd) {
|
|
9991
9665
|
audio.playEnd();
|
|
9992
9666
|
}
|
|
9993
9667
|
},
|
|
9994
9668
|
]);
|
|
9995
|
-
|
|
9996
|
-
// helper functions
|
|
9997
|
-
function lockPosition() {
|
|
9998
|
-
// lock to min / max positions
|
|
9999
|
-
let didLockHappen = false;
|
|
10000
|
-
if (constants.chartType == 'point') {
|
|
10001
|
-
if (position.x < 0) {
|
|
10002
|
-
position.x = 0;
|
|
10003
|
-
didLockHappen = true;
|
|
10004
|
-
}
|
|
10005
|
-
if (position.x > plot.x.length - 1) {
|
|
10006
|
-
position.x = plot.x.length - 1;
|
|
10007
|
-
didLockHappen = true;
|
|
10008
|
-
}
|
|
10009
|
-
} else if (constants.chartType == 'smooth') {
|
|
10010
|
-
if (positionL1.x < 0) {
|
|
10011
|
-
positionL1.x = 0;
|
|
10012
|
-
didLockHappen = true;
|
|
10013
|
-
}
|
|
10014
|
-
if (positionL1.x > plot.curvePoints.length - 1) {
|
|
10015
|
-
positionL1.x = plot.curvePoints.length - 1;
|
|
10016
|
-
didLockHappen = true;
|
|
10017
|
-
}
|
|
10018
|
-
}
|
|
10019
|
-
|
|
10020
|
-
return didLockHappen;
|
|
10021
|
-
}
|
|
10022
|
-
|
|
10023
|
-
function UpdateAll() {
|
|
10024
|
-
if (constants.showDisplay) {
|
|
10025
|
-
display.displayValues();
|
|
10026
|
-
}
|
|
10027
|
-
if (layer0Point.hasRect) {
|
|
10028
|
-
layer0Point.UpdatePointDisplay();
|
|
10029
|
-
}
|
|
10030
|
-
if (constants.sonifMode != 'off') {
|
|
10031
|
-
plot.PlayTones();
|
|
10032
|
-
}
|
|
10033
|
-
}
|
|
10034
|
-
|
|
10035
|
-
function UpdateAllAutoplay() {
|
|
10036
|
-
if (constants.showDisplayInAutoplay) {
|
|
10037
|
-
display.displayValues();
|
|
10038
|
-
}
|
|
10039
|
-
if (constants.showRect) {
|
|
10040
|
-
if (constants.chartType == 'point' && layer0Point.hasRect) {
|
|
10041
|
-
layer0Point.UpdatePointDisplay();
|
|
10042
|
-
} else if (constants.chartType == 'smooth' && layer1Point.hasRect) {
|
|
10043
|
-
layer1Point.UpdatePointDisplay();
|
|
10044
|
-
}
|
|
10045
|
-
}
|
|
10046
|
-
if (constants.sonifMode != 'off') {
|
|
10047
|
-
plot.PlayTones();
|
|
10048
|
-
}
|
|
10049
|
-
if (constants.brailleMode != 'off') {
|
|
10050
|
-
display.UpdateBraillePos();
|
|
10051
|
-
}
|
|
10052
|
-
}
|
|
10053
|
-
function UpdateAllBraille() {
|
|
10054
|
-
if (constants.showDisplayInBraille) {
|
|
10055
|
-
display.displayValues();
|
|
10056
|
-
}
|
|
10057
|
-
if (layer1Point.hasRect) {
|
|
10058
|
-
layer1Point.UpdatePointDisplay();
|
|
10059
|
-
}
|
|
10060
|
-
if (constants.sonifMode != 'off') {
|
|
10061
|
-
plot.PlayTones();
|
|
10062
|
-
}
|
|
10063
|
-
display.UpdateBraillePos();
|
|
10064
|
-
}
|
|
10065
|
-
|
|
10066
|
-
function Autoplay(dir, start, end) {
|
|
10067
|
-
lastPlayed = dir;
|
|
10068
|
-
let step = 1; // default right and reverse left
|
|
10069
|
-
if (dir == 'left' || dir == 'reverse-right') {
|
|
10070
|
-
step = -1;
|
|
10071
|
-
}
|
|
10072
|
-
|
|
10073
|
-
// clear old autoplay if exists
|
|
10074
|
-
if (constants.autoplayId) {
|
|
10075
|
-
constants.KillAutoplay();
|
|
10076
|
-
}
|
|
10077
|
-
if (constants.isSmoothAutoplay) {
|
|
10078
|
-
audio.KillSmooth();
|
|
10079
|
-
}
|
|
10080
|
-
|
|
10081
|
-
if (dir == 'reverse-left' || dir == 'reverse-right') {
|
|
10082
|
-
position.x = start;
|
|
10083
|
-
position.L1x = start;
|
|
10084
|
-
}
|
|
10085
|
-
|
|
10086
|
-
if (constants.chartType == 'point') {
|
|
10087
|
-
constants.autoplayId = setInterval(function () {
|
|
10088
|
-
position.x += step;
|
|
10089
|
-
// autoplay for two layers: point layer & smooth layer in braille
|
|
10090
|
-
// plot.numPoints is not available anymore
|
|
10091
|
-
if (position.x < 0 || position.x > plot.y.length - 1) {
|
|
10092
|
-
constants.KillAutoplay();
|
|
10093
|
-
lockPosition();
|
|
10094
|
-
} else if (position.x == end) {
|
|
10095
|
-
constants.KillAutoplay();
|
|
10096
|
-
UpdateAllAutoplay();
|
|
10097
|
-
} else {
|
|
10098
|
-
UpdateAllAutoplay();
|
|
10099
|
-
}
|
|
10100
|
-
}, constants.autoPlayRate);
|
|
10101
|
-
} else if (constants.chartType == 'smooth') {
|
|
10102
|
-
constants.autoplayId = setInterval(function () {
|
|
10103
|
-
positionL1.x += step;
|
|
10104
|
-
// autoplay for two layers: point layer & smooth layer in braille
|
|
10105
|
-
// plot.numPoints is not available anymore
|
|
10106
|
-
if (
|
|
10107
|
-
positionL1.x < 0 ||
|
|
10108
|
-
positionL1.x > plot.curvePoints.length - 1
|
|
10109
|
-
) {
|
|
10110
|
-
constants.KillAutoplay();
|
|
10111
|
-
lockPosition();
|
|
10112
|
-
} else if (positionL1.x == end) {
|
|
10113
|
-
constants.KillAutoplay();
|
|
10114
|
-
UpdateAllAutoplay();
|
|
10115
|
-
} else {
|
|
10116
|
-
UpdateAllAutoplay();
|
|
10117
|
-
}
|
|
10118
|
-
}, constants.autoPlayRate);
|
|
10119
|
-
}
|
|
10120
|
-
}
|
|
10121
|
-
|
|
10122
|
-
function PlayLine(dir) {
|
|
10123
|
-
lastPlayed = dir;
|
|
10124
|
-
|
|
10125
|
-
let freqArr = [];
|
|
10126
|
-
let panningArr = [];
|
|
10127
|
-
let panPoint = audio.SlideBetween(
|
|
10128
|
-
positionL1.x,
|
|
10129
|
-
0,
|
|
10130
|
-
plot.curvePoints.length - 1,
|
|
10131
|
-
-1,
|
|
10132
|
-
1
|
|
10133
|
-
);
|
|
10134
|
-
let x = positionL1.x < 0 ? 0 : positionL1.x;
|
|
10135
|
-
let duration = 0;
|
|
10136
|
-
if (dir == 'right') {
|
|
10137
|
-
for (let i = x; i < plot.curvePoints.length; i++) {
|
|
10138
|
-
freqArr.push(
|
|
10139
|
-
audio.SlideBetween(
|
|
10140
|
-
plot.curvePoints[i],
|
|
10141
|
-
plot.curveMinY,
|
|
10142
|
-
plot.curveMaxY,
|
|
10143
|
-
constants.MIN_FREQUENCY,
|
|
10144
|
-
constants.MAX_FREQUENCY
|
|
10145
|
-
)
|
|
10146
|
-
);
|
|
10147
|
-
}
|
|
10148
|
-
panningArr = [panPoint, 1];
|
|
10149
|
-
duration =
|
|
10150
|
-
(Math.abs(plot.curvePoints.length - x) / plot.curvePoints.length) *
|
|
10151
|
-
3;
|
|
10152
|
-
} else if (dir == 'left') {
|
|
10153
|
-
for (let i = x; i >= 0; i--) {
|
|
10154
|
-
freqArr.push(
|
|
10155
|
-
audio.SlideBetween(
|
|
10156
|
-
plot.curvePoints[i],
|
|
10157
|
-
plot.curveMinY,
|
|
10158
|
-
plot.curveMaxY,
|
|
10159
|
-
constants.MIN_FREQUENCY,
|
|
10160
|
-
constants.MAX_FREQUENCY
|
|
10161
|
-
)
|
|
10162
|
-
);
|
|
10163
|
-
}
|
|
10164
|
-
panningArr = [panPoint, -1];
|
|
10165
|
-
duration = (Math.abs(x) / plot.curvePoints.length) * 3;
|
|
10166
|
-
} else if (dir == 'reverse-right') {
|
|
10167
|
-
for (let i = plot.curvePoints.length - 1; i >= x; i--) {
|
|
10168
|
-
freqArr.push(
|
|
10169
|
-
audio.SlideBetween(
|
|
10170
|
-
plot.curvePoints[i],
|
|
10171
|
-
plot.curveMinY,
|
|
10172
|
-
plot.curveMaxY,
|
|
10173
|
-
constants.MIN_FREQUENCY,
|
|
10174
|
-
constants.MAX_FREQUENCY
|
|
10175
|
-
)
|
|
10176
|
-
);
|
|
10177
|
-
}
|
|
10178
|
-
panningArr = [1, panPoint];
|
|
10179
|
-
duration =
|
|
10180
|
-
(Math.abs(plot.curvePoints.length - x) / plot.curvePoints.length) *
|
|
10181
|
-
3;
|
|
10182
|
-
} else if (dir == 'reverse-left') {
|
|
10183
|
-
for (let i = 0; i <= x; i++) {
|
|
10184
|
-
freqArr.push(
|
|
10185
|
-
audio.SlideBetween(
|
|
10186
|
-
plot.curvePoints[i],
|
|
10187
|
-
plot.curveMinY,
|
|
10188
|
-
plot.curveMaxY,
|
|
10189
|
-
constants.MIN_FREQUENCY,
|
|
10190
|
-
constants.MAX_FREQUENCY
|
|
10191
|
-
)
|
|
10192
|
-
);
|
|
10193
|
-
}
|
|
10194
|
-
panningArr = [-1, panPoint];
|
|
10195
|
-
duration = (Math.abs(x) / plot.curvePoints.length) * 3;
|
|
10196
|
-
}
|
|
10197
|
-
|
|
10198
|
-
if (constants.isSmoothAutoplay) {
|
|
10199
|
-
audio.KillSmooth();
|
|
10200
|
-
}
|
|
10201
|
-
|
|
10202
|
-
// audio.playSmooth(freqArr, 2, panningArr, constants.vol, 'sine');
|
|
10203
|
-
audio.playSmooth(freqArr, duration, panningArr, constants.vol, 'sine');
|
|
10204
|
-
}
|
|
10205
9669
|
} else if ([].concat(singleMaidr.type).includes('hist')) {
|
|
10206
|
-
window.position = new Position(-1, -1);
|
|
10207
|
-
window.plot = new Histogram();
|
|
10208
|
-
|
|
10209
|
-
// global variables
|
|
10210
|
-
let lastPlayed = '';
|
|
10211
|
-
constants.lastx = 0;
|
|
10212
|
-
|
|
10213
|
-
document.addEventListener('selectionchange', function (e) {
|
|
10214
|
-
if (constants.brailleMode == 'on') {
|
|
10215
|
-
let pos = constants.brailleInput.selectionStart;
|
|
10216
|
-
// we're using braille cursor, update the selection from what was clicked
|
|
10217
|
-
pos = constants.brailleInput.selectionStart;
|
|
10218
|
-
if (pos < 0) {
|
|
10219
|
-
pos = 0;
|
|
10220
|
-
}
|
|
10221
|
-
position.x = pos;
|
|
10222
|
-
lockPosition();
|
|
10223
|
-
let testEnd = true;
|
|
10224
|
-
|
|
10225
|
-
// update display / text / audio
|
|
10226
|
-
if (testEnd) {
|
|
10227
|
-
UpdateAll();
|
|
10228
|
-
}
|
|
10229
|
-
if (testEnd) {
|
|
10230
|
-
audio.playEnd();
|
|
10231
|
-
}
|
|
10232
|
-
} else {
|
|
10233
|
-
// we're using normal cursor, let the default handle it
|
|
10234
|
-
}
|
|
10235
|
-
});
|
|
10236
|
-
|
|
10237
9670
|
// control eventlisteners
|
|
10238
9671
|
constants.events.push([
|
|
10239
9672
|
[constants.chart, constants.brailleInput],
|
|
@@ -10252,7 +9685,7 @@ class Control {
|
|
|
10252
9685
|
e.preventDefault();
|
|
10253
9686
|
position.x += 1;
|
|
10254
9687
|
updateInfoThisRound = true;
|
|
10255
|
-
isAtEnd = lockPosition();
|
|
9688
|
+
isAtEnd = control.lockPosition();
|
|
10256
9689
|
} else if (
|
|
10257
9690
|
e.key == 'ArrowRight' &&
|
|
10258
9691
|
(constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
@@ -10261,7 +9694,7 @@ class Control {
|
|
|
10261
9694
|
// ctrl shift right arrow, autoplay right
|
|
10262
9695
|
e.preventDefault();
|
|
10263
9696
|
position.x -= 1;
|
|
10264
|
-
Autoplay('right', position.x, plot.plotData.length);
|
|
9697
|
+
control.Autoplay('right', position.x, plot.plotData.length);
|
|
10265
9698
|
} else if (
|
|
10266
9699
|
e.key == 'ArrowRight' &&
|
|
10267
9700
|
!(constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
@@ -10271,7 +9704,7 @@ class Control {
|
|
|
10271
9704
|
// alt shift right, autoplay from right
|
|
10272
9705
|
e.preventDefault();
|
|
10273
9706
|
constants.lastx = position.x;
|
|
10274
|
-
Autoplay('reverse-right', plot.bars.length, position.x);
|
|
9707
|
+
control.Autoplay('reverse-right', plot.bars.length, position.x);
|
|
10275
9708
|
} else if (
|
|
10276
9709
|
e.key == 'ArrowRight' &&
|
|
10277
9710
|
(constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
@@ -10281,7 +9714,7 @@ class Control {
|
|
|
10281
9714
|
e.preventDefault();
|
|
10282
9715
|
position.x = plot.plotData.length - 1;
|
|
10283
9716
|
updateInfoThisRound = true;
|
|
10284
|
-
isAtEnd = lockPosition();
|
|
9717
|
+
isAtEnd = control.lockPosition();
|
|
10285
9718
|
}
|
|
10286
9719
|
|
|
10287
9720
|
// Left
|
|
@@ -10294,7 +9727,7 @@ class Control {
|
|
|
10294
9727
|
e.preventDefault();
|
|
10295
9728
|
position.x += -1;
|
|
10296
9729
|
updateInfoThisRound = true;
|
|
10297
|
-
isAtEnd = lockPosition();
|
|
9730
|
+
isAtEnd = control.lockPosition();
|
|
10298
9731
|
} else if (
|
|
10299
9732
|
e.key == 'ArrowLeft' &&
|
|
10300
9733
|
(constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
@@ -10303,7 +9736,7 @@ class Control {
|
|
|
10303
9736
|
// ctrl shift left arrow, autoplay left
|
|
10304
9737
|
e.preventDefault();
|
|
10305
9738
|
position.x += 1;
|
|
10306
|
-
Autoplay('left', position.x, -1);
|
|
9739
|
+
control.Autoplay('left', position.x, -1);
|
|
10307
9740
|
} else if (
|
|
10308
9741
|
e.key == 'ArrowLeft' &&
|
|
10309
9742
|
!(constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
@@ -10313,7 +9746,7 @@ class Control {
|
|
|
10313
9746
|
// alt shift left, autoplay from left
|
|
10314
9747
|
e.preventDefault();
|
|
10315
9748
|
constants.lastx = position.x;
|
|
10316
|
-
Autoplay('reverse-left', -1, position.x);
|
|
9749
|
+
control.Autoplay('reverse-left', -1, position.x);
|
|
10317
9750
|
} else if (
|
|
10318
9751
|
e.key == 'ArrowLeft' &&
|
|
10319
9752
|
(constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
@@ -10323,15 +9756,15 @@ class Control {
|
|
|
10323
9756
|
e.preventDefault();
|
|
10324
9757
|
position.x = 0;
|
|
10325
9758
|
updateInfoThisRound = true;
|
|
10326
|
-
isAtEnd = lockPosition();
|
|
9759
|
+
isAtEnd = control.lockPosition();
|
|
10327
9760
|
}
|
|
10328
9761
|
|
|
10329
9762
|
// update display / text / audio
|
|
10330
9763
|
if (updateInfoThisRound && !isAtEnd) {
|
|
10331
9764
|
if (constants.brailleMode == 'off') {
|
|
10332
|
-
UpdateAll();
|
|
9765
|
+
control.UpdateAll();
|
|
10333
9766
|
} else {
|
|
10334
|
-
UpdateAllBraille();
|
|
9767
|
+
control.UpdateAllBraille();
|
|
10335
9768
|
}
|
|
10336
9769
|
}
|
|
10337
9770
|
if (isAtEnd) {
|
|
@@ -10340,18 +9773,17 @@ class Control {
|
|
|
10340
9773
|
},
|
|
10341
9774
|
]);
|
|
10342
9775
|
|
|
10343
|
-
let controlElements = [constants.chart, constants.brailleInput];
|
|
10344
9776
|
let lastx = 0;
|
|
10345
|
-
for (let i = 0; i < controlElements.length; i++) {
|
|
9777
|
+
for (let i = 0; i < this.controlElements.length; i++) {
|
|
10346
9778
|
constants.events.push([
|
|
10347
|
-
controlElements[i],
|
|
9779
|
+
this.controlElements[i],
|
|
10348
9780
|
'keydown',
|
|
10349
9781
|
function (e) {
|
|
10350
9782
|
// period: speed up
|
|
10351
9783
|
if (e.key == '.') {
|
|
10352
9784
|
e.preventDefault();
|
|
10353
9785
|
constants.SpeedUp();
|
|
10354
|
-
PlayDuringSpeedChange();
|
|
9786
|
+
control.PlayDuringSpeedChange();
|
|
10355
9787
|
display.announceText('Speed up');
|
|
10356
9788
|
}
|
|
10357
9789
|
|
|
@@ -10359,7 +9791,7 @@ class Control {
|
|
|
10359
9791
|
if (e.key == ',') {
|
|
10360
9792
|
e.preventDefault();
|
|
10361
9793
|
constants.SpeedDown();
|
|
10362
|
-
PlayDuringSpeedChange();
|
|
9794
|
+
control.PlayDuringSpeedChange();
|
|
10363
9795
|
display.announceText('Speed down');
|
|
10364
9796
|
}
|
|
10365
9797
|
|
|
@@ -10367,149 +9799,18 @@ class Control {
|
|
|
10367
9799
|
if (e.key == '/') {
|
|
10368
9800
|
e.preventDefault();
|
|
10369
9801
|
constants.SpeedReset();
|
|
10370
|
-
PlayDuringSpeedChange();
|
|
9802
|
+
control.PlayDuringSpeedChange();
|
|
10371
9803
|
display.announceText('Speed reset');
|
|
10372
9804
|
}
|
|
10373
9805
|
},
|
|
10374
9806
|
]);
|
|
10375
9807
|
}
|
|
10376
|
-
function PlayDuringSpeedChange() {
|
|
10377
|
-
if (constants.autoplayId != null) {
|
|
10378
|
-
constants.KillAutoplay();
|
|
10379
|
-
if (lastPlayed == 'reverse-left') {
|
|
10380
|
-
Autoplay('right', position.x, lastx);
|
|
10381
|
-
} else if (lastPlayed == 'reverse-right') {
|
|
10382
|
-
Autoplay('left', position.x, lastx);
|
|
10383
|
-
} else {
|
|
10384
|
-
Autoplay(lastPlayed, position.x, lastx);
|
|
10385
|
-
}
|
|
10386
|
-
}
|
|
10387
|
-
}
|
|
10388
|
-
|
|
10389
|
-
// lock to min / max postions
|
|
10390
|
-
function lockPosition() {
|
|
10391
|
-
let didLockHappen = false;
|
|
10392
|
-
|
|
10393
|
-
if (position.x < 0) {
|
|
10394
|
-
position.x = 0;
|
|
10395
|
-
didLockHappen = true;
|
|
10396
|
-
}
|
|
10397
|
-
if (position.x > plot.plotData.length - 1) {
|
|
10398
|
-
position.x = plot.plotData.length - 1;
|
|
10399
|
-
didLockHappen = true;
|
|
10400
|
-
}
|
|
10401
|
-
|
|
10402
|
-
return didLockHappen;
|
|
10403
|
-
}
|
|
10404
|
-
function UpdateAll() {
|
|
10405
|
-
if (constants.showDisplay) {
|
|
10406
|
-
display.displayValues();
|
|
10407
|
-
}
|
|
10408
|
-
if (constants.showRect && constants.hasRect) {
|
|
10409
|
-
plot.Select();
|
|
10410
|
-
}
|
|
10411
|
-
if (constants.sonifMode != 'off') {
|
|
10412
|
-
plot.PlayTones();
|
|
10413
|
-
}
|
|
10414
|
-
}
|
|
10415
|
-
function UpdateAllAutoplay() {
|
|
10416
|
-
if (constants.showDisplayInAutoplay) {
|
|
10417
|
-
display.displayValues();
|
|
10418
|
-
}
|
|
10419
|
-
if (constants.showRect && constants.hasRect) {
|
|
10420
|
-
plot.Select();
|
|
10421
|
-
}
|
|
10422
|
-
if (constants.sonifMode != 'off') {
|
|
10423
|
-
plot.PlayTones();
|
|
10424
|
-
}
|
|
10425
|
-
|
|
10426
|
-
if (constants.brailleMode != 'off') {
|
|
10427
|
-
display.UpdateBraillePos();
|
|
10428
|
-
}
|
|
10429
|
-
}
|
|
10430
|
-
function UpdateAllBraille() {
|
|
10431
|
-
if (constants.showDisplayInBraille) {
|
|
10432
|
-
display.displayValues();
|
|
10433
|
-
}
|
|
10434
|
-
if (constants.showRect && constants.hasRect) {
|
|
10435
|
-
plot.Select();
|
|
10436
|
-
}
|
|
10437
|
-
if (constants.sonifMode != 'off') {
|
|
10438
|
-
plot.PlayTones();
|
|
10439
|
-
}
|
|
10440
|
-
display.UpdateBraillePos();
|
|
10441
|
-
}
|
|
10442
|
-
function Autoplay(dir, start, end) {
|
|
10443
|
-
lastPlayed = dir;
|
|
10444
|
-
let step = 1; // default right and reverse-left
|
|
10445
|
-
if (dir == 'left' || dir == 'reverse-right') {
|
|
10446
|
-
step = -1;
|
|
10447
|
-
}
|
|
10448
|
-
|
|
10449
|
-
// clear old autoplay if exists
|
|
10450
|
-
if (constants.autoplayId != null) {
|
|
10451
|
-
constants.KillAutoplay();
|
|
10452
|
-
}
|
|
10453
9808
|
|
|
10454
|
-
if (dir == 'reverse-right' || dir == 'reverse-left') {
|
|
10455
|
-
position.x = start;
|
|
10456
|
-
}
|
|
10457
|
-
|
|
10458
|
-
constants.autoplayId = setInterval(function () {
|
|
10459
|
-
position.x += step;
|
|
10460
|
-
if (!plot || !plot.plotData) {
|
|
10461
|
-
constants.KillAutoplay();
|
|
10462
|
-
return;
|
|
10463
|
-
}
|
|
10464
|
-
if (position.x < 0 || plot.plotData.length - 1 < position.x) {
|
|
10465
|
-
constants.KillAutoplay();
|
|
10466
|
-
lockPosition();
|
|
10467
|
-
} else if (position.x == end) {
|
|
10468
|
-
constants.KillAutoplay();
|
|
10469
|
-
UpdateAllAutoplay();
|
|
10470
|
-
} else {
|
|
10471
|
-
UpdateAllAutoplay();
|
|
10472
|
-
}
|
|
10473
|
-
}, constants.autoPlayRate);
|
|
10474
|
-
}
|
|
10475
9809
|
} else if (
|
|
10476
9810
|
[].concat(singleMaidr.type).includes('stacked_bar') ||
|
|
10477
9811
|
[].concat(singleMaidr.type).includes('stacked_normalized_bar') ||
|
|
10478
9812
|
[].concat(singleMaidr.type).includes('dodged_bar')
|
|
10479
9813
|
) {
|
|
10480
|
-
window.position = new Position(-1, -1);
|
|
10481
|
-
window.plot = new Segmented();
|
|
10482
|
-
|
|
10483
|
-
// global variables
|
|
10484
|
-
let lastPlayed = '';
|
|
10485
|
-
constants.lastx = 0;
|
|
10486
|
-
|
|
10487
|
-
// todo bug, forgot about all mode
|
|
10488
|
-
// bug: you can click 1 past end (for all chart types). Make sure we're lockign and then resetting the selectionStart
|
|
10489
|
-
document.addEventListener('selectionchange', function (e) {
|
|
10490
|
-
if (constants.brailleMode == 'on') {
|
|
10491
|
-
let pos = constants.brailleInput.selectionStart;
|
|
10492
|
-
// we're using braille cursor, update the selection from what was clicked
|
|
10493
|
-
pos = constants.brailleInput.selectionStart;
|
|
10494
|
-
if (pos < 0) {
|
|
10495
|
-
pos = 0;
|
|
10496
|
-
}
|
|
10497
|
-
position.x = pos;
|
|
10498
|
-
lockPosition();
|
|
10499
|
-
let testEnd = true;
|
|
10500
|
-
|
|
10501
|
-
// update display / text / audio
|
|
10502
|
-
if (testEnd) {
|
|
10503
|
-
UpdateAll();
|
|
10504
|
-
}
|
|
10505
|
-
if (testEnd) {
|
|
10506
|
-
audio.playEnd();
|
|
10507
|
-
}
|
|
10508
|
-
} else {
|
|
10509
|
-
// we're using normal cursor, let the default handle it
|
|
10510
|
-
}
|
|
10511
|
-
});
|
|
10512
|
-
|
|
10513
9814
|
// control eventlisteners
|
|
10514
9815
|
constants.events.push([
|
|
10515
9816
|
[constants.chart, constants.brailleInput],
|
|
@@ -10537,7 +9838,7 @@ class Control {
|
|
|
10537
9838
|
position.x += 1;
|
|
10538
9839
|
updateInfoThisRound = true;
|
|
10539
9840
|
constants.navigation = 1;
|
|
10540
|
-
isAtEnd = lockPosition();
|
|
9841
|
+
isAtEnd = control.lockPosition();
|
|
10541
9842
|
} else if (
|
|
10542
9843
|
e.key == 'ArrowRight' &&
|
|
10543
9844
|
(constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
@@ -10545,7 +9846,7 @@ class Control {
|
|
|
10545
9846
|
) {
|
|
10546
9847
|
// ctrl shift right arrow, autoplay right
|
|
10547
9848
|
position.x -= 1;
|
|
10548
|
-
Autoplay('right', position.x, plot.plotData.length);
|
|
9849
|
+
control.Autoplay('right', position.x, plot.plotData.length);
|
|
10549
9850
|
} else if (
|
|
10550
9851
|
e.key == 'ArrowRight' &&
|
|
10551
9852
|
!(constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
@@ -10554,7 +9855,7 @@ class Control {
|
|
|
10554
9855
|
) {
|
|
10555
9856
|
// alt shift right, autoplay from right
|
|
10556
9857
|
constants.lastx = position.x;
|
|
10557
|
-
Autoplay('reverse-right', plot.plotData.length, position.x);
|
|
9858
|
+
control.Autoplay('reverse-right', plot.plotData.length, position.x);
|
|
10558
9859
|
} else if (
|
|
10559
9860
|
e.key == 'ArrowRight' &&
|
|
10560
9861
|
(constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
@@ -10563,7 +9864,7 @@ class Control {
|
|
|
10563
9864
|
// ctrl right arrow, go to end
|
|
10564
9865
|
position.x = plot.plotData.length - 1;
|
|
10565
9866
|
updateInfoThisRound = true;
|
|
10566
|
-
isAtEnd = lockPosition();
|
|
9867
|
+
isAtEnd = control.lockPosition();
|
|
10567
9868
|
}
|
|
10568
9869
|
|
|
10569
9870
|
// Left
|
|
@@ -10576,7 +9877,7 @@ class Control {
|
|
|
10576
9877
|
position.x += -1;
|
|
10577
9878
|
updateInfoThisRound = true;
|
|
10578
9879
|
constants.navigation = 1;
|
|
10579
|
-
isAtEnd = lockPosition();
|
|
9880
|
+
isAtEnd = control.lockPosition();
|
|
10580
9881
|
} else if (
|
|
10581
9882
|
e.key == 'ArrowLeft' &&
|
|
10582
9883
|
(constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
@@ -10584,7 +9885,7 @@ class Control {
|
|
|
10584
9885
|
) {
|
|
10585
9886
|
// ctrl shift left arrow, autoplay left
|
|
10586
9887
|
position.x += 1;
|
|
10587
|
-
Autoplay('left', position.x, -1);
|
|
9888
|
+
control.Autoplay('left', position.x, -1);
|
|
10588
9889
|
} else if (
|
|
10589
9890
|
e.key == 'ArrowLeft' &&
|
|
10590
9891
|
!(constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
@@ -10593,7 +9894,7 @@ class Control {
|
|
|
10593
9894
|
) {
|
|
10594
9895
|
// alt shift left, autoplay from left
|
|
10595
9896
|
constants.lastx = position.x;
|
|
10596
|
-
Autoplay('reverse-left', -1, position.x);
|
|
9897
|
+
control.Autoplay('reverse-left', -1, position.x);
|
|
10597
9898
|
} else if (
|
|
10598
9899
|
e.key == 'ArrowLeft' &&
|
|
10599
9900
|
(constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
@@ -10602,7 +9903,7 @@ class Control {
|
|
|
10602
9903
|
// ctrl left arrow, go to beginning
|
|
10603
9904
|
position.x = 0;
|
|
10604
9905
|
updateInfoThisRound = true;
|
|
10605
|
-
isAtEnd = lockPosition();
|
|
9906
|
+
isAtEnd = control.lockPosition();
|
|
10606
9907
|
}
|
|
10607
9908
|
|
|
10608
9909
|
// Up
|
|
@@ -10615,14 +9916,14 @@ class Control {
|
|
|
10615
9916
|
position.y += 1;
|
|
10616
9917
|
updateInfoThisRound = true;
|
|
10617
9918
|
constants.navigation = 0;
|
|
10618
|
-
isAtEnd = lockPosition();
|
|
9919
|
+
isAtEnd = control.lockPosition();
|
|
10619
9920
|
} else if (
|
|
10620
9921
|
e.key == 'ArrowUp' &&
|
|
10621
9922
|
(constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
10622
9923
|
e.shiftKey
|
|
10623
9924
|
) {
|
|
10624
9925
|
// ctrl shift up arrow, autoplay up
|
|
10625
|
-
Autoplay('up', position.y, plot.plotData[0].length);
|
|
9926
|
+
control.Autoplay('up', position.y, plot.plotData[0].length);
|
|
10626
9927
|
} else if (
|
|
10627
9928
|
e.key == 'ArrowUp' &&
|
|
10628
9929
|
!(constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
@@ -10631,7 +9932,7 @@ class Control {
|
|
|
10631
9932
|
) {
|
|
10632
9933
|
// alt shift up, autoplay from up
|
|
10633
9934
|
constants.lastx = position.x;
|
|
10634
|
-
Autoplay('reverse-up', -1, plot.plotData[0].length);
|
|
9935
|
+
control.Autoplay('reverse-up', -1, plot.plotData[0].length);
|
|
10635
9936
|
} else if (
|
|
10636
9937
|
e.key == 'ArrowUp' &&
|
|
10637
9938
|
(constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
@@ -10652,14 +9953,14 @@ class Control {
|
|
|
10652
9953
|
position.y += -1;
|
|
10653
9954
|
updateInfoThisRound = true;
|
|
10654
9955
|
constants.navigation = 0;
|
|
10655
|
-
isAtEnd = lockPosition();
|
|
9956
|
+
isAtEnd = control.lockPosition();
|
|
10656
9957
|
} else if (
|
|
10657
9958
|
e.key == 'ArrowDown' &&
|
|
10658
9959
|
(constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
10659
9960
|
e.shiftKey
|
|
10660
9961
|
) {
|
|
10661
9962
|
// ctrl shift down arrow, autoplay down
|
|
10662
|
-
Autoplay('down', position.y, -1);
|
|
9963
|
+
control.Autoplay('down', position.y, -1);
|
|
10663
9964
|
} else if (
|
|
10664
9965
|
e.key == 'ArrowDown' &&
|
|
10665
9966
|
!(constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
@@ -10668,7 +9969,7 @@ class Control {
|
|
|
10668
9969
|
) {
|
|
10669
9970
|
// alt shift down, autoplay from down
|
|
10670
9971
|
constants.lastx = position.x;
|
|
10671
|
-
Autoplay('reverse-down', -1, position.y);
|
|
9972
|
+
control.Autoplay('reverse-down', -1, position.y);
|
|
10672
9973
|
} else if (
|
|
10673
9974
|
e.key == 'ArrowDown' &&
|
|
10674
9975
|
(constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
@@ -10680,219 +9981,75 @@ class Control {
|
|
|
10680
9981
|
}
|
|
10681
9982
|
|
|
10682
9983
|
// update display / text / audio
|
|
10683
|
-
if (updateInfoThisRound
|
|
9984
|
+
if (updateInfoThisRound) {
|
|
10684
9985
|
if (constants.brailleMode == 'off') {
|
|
10685
|
-
UpdateAll();
|
|
9986
|
+
control.UpdateAll();
|
|
10686
9987
|
} else {
|
|
10687
|
-
UpdateAllBraille();
|
|
9988
|
+
control.UpdateAllBraille();
|
|
10688
9989
|
}
|
|
10689
9990
|
}
|
|
10690
|
-
if (isAtEnd) {
|
|
10691
|
-
audio.playEnd();
|
|
10692
|
-
}
|
|
10693
9991
|
},
|
|
10694
9992
|
]);
|
|
10695
9993
|
|
|
10696
|
-
let controlElements = [constants.chart, constants.brailleInput];
|
|
10697
9994
|
let lastx = 0;
|
|
10698
|
-
for (let i = 0; i < controlElements.length; i++) {
|
|
9995
|
+
for (let i = 0; i < this.controlElements.length; i++) {
|
|
10699
9996
|
constants.events.push([
|
|
10700
|
-
controlElements[i],
|
|
9997
|
+
this.controlElements[i],
|
|
10701
9998
|
'keydown',
|
|
10702
9999
|
function (e) {
|
|
10703
10000
|
// period: speed up
|
|
10704
10001
|
if (e.key == '.') {
|
|
10705
10002
|
constants.SpeedUp();
|
|
10706
|
-
PlayDuringSpeedChange();
|
|
10003
|
+
control.PlayDuringSpeedChange();
|
|
10707
10004
|
display.announceText('Speed up');
|
|
10708
10005
|
}
|
|
10709
10006
|
|
|
10710
10007
|
// comma: speed down
|
|
10711
10008
|
if (e.key == ',') {
|
|
10712
10009
|
constants.SpeedDown();
|
|
10713
|
-
PlayDuringSpeedChange();
|
|
10010
|
+
control.PlayDuringSpeedChange();
|
|
10714
10011
|
display.announceText('Speed down');
|
|
10715
10012
|
}
|
|
10716
10013
|
|
|
10717
10014
|
// /: reset speed
|
|
10718
10015
|
if (e.key == '/') {
|
|
10719
10016
|
constants.SpeedReset();
|
|
10720
|
-
PlayDuringSpeedChange();
|
|
10017
|
+
control.PlayDuringSpeedChange();
|
|
10721
10018
|
display.announceText('Speed reset');
|
|
10722
10019
|
}
|
|
10723
10020
|
},
|
|
10724
10021
|
]);
|
|
10725
10022
|
}
|
|
10726
|
-
|
|
10727
|
-
|
|
10728
|
-
|
|
10729
|
-
if (lastPlayed == 'reverse-left') {
|
|
10730
|
-
Autoplay('right', position.x, lastx);
|
|
10731
|
-
} else if (lastPlayed == 'reverse-right') {
|
|
10732
|
-
Autoplay('left', position.x, lastx);
|
|
10733
|
-
} else if (lastPlayed == 'reverse-up') {
|
|
10734
|
-
Autoplay('down', position.x, lastx);
|
|
10735
|
-
} else if (lastPlayed == 'reverse-down') {
|
|
10736
|
-
Autoplay('up', position.x, lastx);
|
|
10737
|
-
} else {
|
|
10738
|
-
Autoplay(lastPlayed, position.x, lastx);
|
|
10739
|
-
}
|
|
10740
|
-
}
|
|
10741
|
-
}
|
|
10023
|
+
} else if (singleMaidr.type == 'line') {
|
|
10024
|
+
window.position = new Position(-1, -1);
|
|
10025
|
+
window.plot = new LinePlot();
|
|
10742
10026
|
|
|
10743
|
-
//
|
|
10744
|
-
|
|
10745
|
-
|
|
10027
|
+
// global variables
|
|
10028
|
+
let lastPlayed = '';
|
|
10029
|
+
constants.lastx = 0;
|
|
10746
10030
|
|
|
10747
|
-
|
|
10748
|
-
|
|
10749
|
-
|
|
10750
|
-
|
|
10751
|
-
|
|
10752
|
-
|
|
10753
|
-
|
|
10754
|
-
|
|
10755
|
-
|
|
10756
|
-
position.
|
|
10757
|
-
|
|
10758
|
-
|
|
10759
|
-
if (position.y > plot.fill.length - 1) {
|
|
10760
|
-
position.y = plot.fill.length - 1;
|
|
10761
|
-
didLockHappen = true;
|
|
10762
|
-
}
|
|
10031
|
+
// braille cursor routing
|
|
10032
|
+
document.addEventListener('selectionchange', function (e) {
|
|
10033
|
+
if (constants.brailleMode == 'on') {
|
|
10034
|
+
let pos = constants.brailleInput.selectionStart;
|
|
10035
|
+
// we're using braille cursor, update the selection from what was clicked
|
|
10036
|
+
pos = constants.brailleInput.selectionStart;
|
|
10037
|
+
if (pos < 0) {
|
|
10038
|
+
pos = 0;
|
|
10039
|
+
}
|
|
10040
|
+
position.x = pos;
|
|
10041
|
+
control.lockPosition();
|
|
10042
|
+
let testEnd = true;
|
|
10763
10043
|
|
|
10764
|
-
|
|
10765
|
-
|
|
10766
|
-
|
|
10767
|
-
|
|
10768
|
-
|
|
10769
|
-
|
|
10770
|
-
|
|
10771
|
-
plot.Select();
|
|
10772
|
-
}
|
|
10773
|
-
if (constants.sonifMode != 'off') {
|
|
10774
|
-
plot.PlayTones();
|
|
10775
|
-
}
|
|
10776
|
-
}
|
|
10777
|
-
function UpdateAllAutoplay() {
|
|
10778
|
-
if (constants.showDisplayInAutoplay) {
|
|
10779
|
-
display.displayValues();
|
|
10780
|
-
}
|
|
10781
|
-
if (constants.showRect && constants.hasRect) {
|
|
10782
|
-
plot.Select();
|
|
10783
|
-
}
|
|
10784
|
-
if (constants.sonifMode != 'off') {
|
|
10785
|
-
plot.PlayTones();
|
|
10044
|
+
// update display / text / audio
|
|
10045
|
+
if (testEnd) {
|
|
10046
|
+
control.UpdateAll();
|
|
10047
|
+
}
|
|
10048
|
+
if (testEnd) {
|
|
10049
|
+
audio.playEnd();
|
|
10050
|
+
}
|
|
10786
10051
|
}
|
|
10787
|
-
|
|
10788
|
-
if (constants.brailleMode != 'off') {
|
|
10789
|
-
display.UpdateBraillePos();
|
|
10790
|
-
}
|
|
10791
|
-
}
|
|
10792
|
-
function UpdateAllBraille() {
|
|
10793
|
-
if (constants.showDisplayInBraille) {
|
|
10794
|
-
display.SetBraille();
|
|
10795
|
-
display.displayValues();
|
|
10796
|
-
}
|
|
10797
|
-
if (constants.showRect && constants.hasRect) {
|
|
10798
|
-
plot.Select();
|
|
10799
|
-
}
|
|
10800
|
-
if (constants.sonifMode != 'off') {
|
|
10801
|
-
plot.PlayTones();
|
|
10802
|
-
}
|
|
10803
|
-
|
|
10804
|
-
display.UpdateBraillePos();
|
|
10805
|
-
}
|
|
10806
|
-
function Autoplay(dir, start, end) {
|
|
10807
|
-
lastPlayed = dir;
|
|
10808
|
-
let step = 1; // default right, up, reverse-left, and reverse-down
|
|
10809
|
-
if (
|
|
10810
|
-
dir == 'left' ||
|
|
10811
|
-
dir == 'down' ||
|
|
10812
|
-
dir == 'reverse-right' ||
|
|
10813
|
-
dir == 'reverse-up'
|
|
10814
|
-
) {
|
|
10815
|
-
step = -1;
|
|
10816
|
-
}
|
|
10817
|
-
|
|
10818
|
-
// clear old autoplay if exists
|
|
10819
|
-
if (constants.autoplayId != null) {
|
|
10820
|
-
constants.KillAutoplay();
|
|
10821
|
-
}
|
|
10822
|
-
|
|
10823
|
-
if (dir == 'reverse-left' || dir == 'reverse-right') {
|
|
10824
|
-
position.x = start;
|
|
10825
|
-
} else if (dir == 'reverse-up' || dir == 'reverse-down') {
|
|
10826
|
-
position.y = start;
|
|
10827
|
-
}
|
|
10828
|
-
|
|
10829
|
-
constants.autoplayId = setInterval(function () {
|
|
10830
|
-
if (
|
|
10831
|
-
dir == 'left' ||
|
|
10832
|
-
dir == 'right' ||
|
|
10833
|
-
dir == 'reverse-left' ||
|
|
10834
|
-
dir == 'reverse-right'
|
|
10835
|
-
) {
|
|
10836
|
-
position.x += step;
|
|
10837
|
-
if (!plot || !plot.plotData) {
|
|
10838
|
-
constants.KillAutoplay();
|
|
10839
|
-
return;
|
|
10840
|
-
}
|
|
10841
|
-
if (position.x < 0 || plot.plotData.length - 1 < position.x) {
|
|
10842
|
-
constants.KillAutoplay();
|
|
10843
|
-
lockPosition();
|
|
10844
|
-
} else if (position.x == end) {
|
|
10845
|
-
constants.KillAutoplay();
|
|
10846
|
-
UpdateAllAutoplay();
|
|
10847
|
-
} else {
|
|
10848
|
-
UpdateAllAutoplay();
|
|
10849
|
-
}
|
|
10850
|
-
} else {
|
|
10851
|
-
// up or down
|
|
10852
|
-
position.y += step;
|
|
10853
|
-
if (position.y < 0 || plot.plotData[0].length - 1 < position.y) {
|
|
10854
|
-
constants.KillAutoplay();
|
|
10855
|
-
lockPosition();
|
|
10856
|
-
} else if (position.y == end) {
|
|
10857
|
-
constants.KillAutoplay();
|
|
10858
|
-
UpdateAllAutoplay();
|
|
10859
|
-
} else {
|
|
10860
|
-
UpdateAllAutoplay();
|
|
10861
|
-
}
|
|
10862
|
-
}
|
|
10863
|
-
}, constants.autoPlayRate);
|
|
10864
|
-
}
|
|
10865
|
-
} else if (singleMaidr.type == 'line') {
|
|
10866
|
-
window.position = new Position(-1, -1);
|
|
10867
|
-
window.plot = new LinePlot();
|
|
10868
|
-
let point = new Point();
|
|
10869
|
-
|
|
10870
|
-
// global variables
|
|
10871
|
-
let lastPlayed = '';
|
|
10872
|
-
constants.lastx = 0;
|
|
10873
|
-
|
|
10874
|
-
// braille cursor routing
|
|
10875
|
-
document.addEventListener('selectionchange', function (e) {
|
|
10876
|
-
if (constants.brailleMode == 'on') {
|
|
10877
|
-
let pos = constants.brailleInput.selectionStart;
|
|
10878
|
-
// we're using braille cursor, update the selection from what was clicked
|
|
10879
|
-
pos = constants.brailleInput.selectionStart;
|
|
10880
|
-
if (pos < 0) {
|
|
10881
|
-
pos = 0;
|
|
10882
|
-
}
|
|
10883
|
-
position.x = pos;
|
|
10884
|
-
lockPosition();
|
|
10885
|
-
let testEnd = true;
|
|
10886
|
-
|
|
10887
|
-
// update display / text / audio
|
|
10888
|
-
if (testEnd) {
|
|
10889
|
-
UpdateAll();
|
|
10890
|
-
}
|
|
10891
|
-
if (testEnd) {
|
|
10892
|
-
audio.playEnd();
|
|
10893
|
-
}
|
|
10894
|
-
}
|
|
10895
|
-
});
|
|
10052
|
+
});
|
|
10896
10053
|
|
|
10897
10054
|
// control eventlisteners
|
|
10898
10055
|
constants.events.push([
|
|
@@ -10906,11 +10063,11 @@ class Control {
|
|
|
10906
10063
|
if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
10907
10064
|
if (e.shiftKey) {
|
|
10908
10065
|
position.x -= 1;
|
|
10909
|
-
Autoplay('right', position.x, plot.pointValuesY.length);
|
|
10066
|
+
control.Autoplay('right', position.x, plot.pointValuesY.length);
|
|
10910
10067
|
} else {
|
|
10911
10068
|
position.x = plot.pointValuesY.length - 1; // go all the way
|
|
10912
10069
|
updateInfoThisRound = true;
|
|
10913
|
-
isAtEnd = lockPosition();
|
|
10070
|
+
isAtEnd = control.lockPosition();
|
|
10914
10071
|
}
|
|
10915
10072
|
} else if (
|
|
10916
10073
|
e.altKey &&
|
|
@@ -10918,11 +10075,15 @@ class Control {
|
|
|
10918
10075
|
position.x != plot.pointValuesY.length - 1
|
|
10919
10076
|
) {
|
|
10920
10077
|
constants.lastx = position.x;
|
|
10921
|
-
Autoplay(
|
|
10078
|
+
control.Autoplay(
|
|
10079
|
+
'reverse-right',
|
|
10080
|
+
plot.pointValuesY.length,
|
|
10081
|
+
position.x
|
|
10082
|
+
);
|
|
10922
10083
|
} else {
|
|
10923
10084
|
position.x += 1;
|
|
10924
10085
|
updateInfoThisRound = true;
|
|
10925
|
-
isAtEnd = lockPosition();
|
|
10086
|
+
isAtEnd = control.lockPosition();
|
|
10926
10087
|
}
|
|
10927
10088
|
} else if (e.key == 'ArrowLeft') {
|
|
10928
10089
|
// var prevLink = document.getElementById('prev'); // what is prev in the html?
|
|
@@ -10931,26 +10092,26 @@ class Control {
|
|
|
10931
10092
|
if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
10932
10093
|
if (e.shiftKey) {
|
|
10933
10094
|
position.x += 1;
|
|
10934
|
-
Autoplay('left', position.x, -1);
|
|
10095
|
+
control.Autoplay('left', position.x, -1);
|
|
10935
10096
|
} else {
|
|
10936
10097
|
position.x = 0; // go all the way
|
|
10937
10098
|
updateInfoThisRound = true;
|
|
10938
|
-
isAtEnd = lockPosition();
|
|
10099
|
+
isAtEnd = control.lockPosition();
|
|
10939
10100
|
}
|
|
10940
10101
|
} else if (e.altKey && e.shiftKey && position.x != 0) {
|
|
10941
10102
|
constants.lastx = position.x;
|
|
10942
|
-
Autoplay('reverse-left', -1, position.x);
|
|
10103
|
+
control.Autoplay('reverse-left', -1, position.x);
|
|
10943
10104
|
} else {
|
|
10944
10105
|
position.x += -1;
|
|
10945
10106
|
updateInfoThisRound = true;
|
|
10946
|
-
isAtEnd = lockPosition();
|
|
10107
|
+
isAtEnd = control.lockPosition();
|
|
10947
10108
|
}
|
|
10948
10109
|
// }
|
|
10949
10110
|
}
|
|
10950
10111
|
|
|
10951
10112
|
// update display / text / audio
|
|
10952
10113
|
if (updateInfoThisRound && !isAtEnd) {
|
|
10953
|
-
UpdateAll();
|
|
10114
|
+
control.UpdateAll();
|
|
10954
10115
|
}
|
|
10955
10116
|
if (isAtEnd) {
|
|
10956
10117
|
audio.playEnd();
|
|
@@ -10972,11 +10133,11 @@ class Control {
|
|
|
10972
10133
|
} else if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
10973
10134
|
if (e.shiftKey) {
|
|
10974
10135
|
position.x -= 1;
|
|
10975
|
-
Autoplay('right', position.x, plot.pointValuesY.length);
|
|
10136
|
+
control.Autoplay('right', position.x, plot.pointValuesY.length);
|
|
10976
10137
|
} else {
|
|
10977
10138
|
position.x = plot.pointValuesY.length - 1; // go all the way
|
|
10978
10139
|
updateInfoThisRound = true;
|
|
10979
|
-
isAtEnd = lockPosition();
|
|
10140
|
+
isAtEnd = control.lockPosition();
|
|
10980
10141
|
}
|
|
10981
10142
|
} else if (
|
|
10982
10143
|
e.altKey &&
|
|
@@ -10984,11 +10145,15 @@ class Control {
|
|
|
10984
10145
|
position.x != plot.pointValues.length - 1
|
|
10985
10146
|
) {
|
|
10986
10147
|
constants.lastx = position.x;
|
|
10987
|
-
Autoplay(
|
|
10148
|
+
control.Autoplay(
|
|
10149
|
+
'reverse-right',
|
|
10150
|
+
plot.pointValuesY.length,
|
|
10151
|
+
position.x
|
|
10152
|
+
);
|
|
10988
10153
|
} else {
|
|
10989
10154
|
position.x += 1;
|
|
10990
10155
|
updateInfoThisRound = true;
|
|
10991
|
-
isAtEnd = lockPosition();
|
|
10156
|
+
isAtEnd = control.lockPosition();
|
|
10992
10157
|
}
|
|
10993
10158
|
} else if (e.key == 'ArrowLeft') {
|
|
10994
10159
|
// left arrow
|
|
@@ -10996,19 +10161,19 @@ class Control {
|
|
|
10996
10161
|
if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
10997
10162
|
if (e.shiftKey) {
|
|
10998
10163
|
position.x += 1;
|
|
10999
|
-
Autoplay('left', position.x, -1);
|
|
10164
|
+
control.Autoplay('left', position.x, -1);
|
|
11000
10165
|
} else {
|
|
11001
10166
|
position.x = 0; // go all the way
|
|
11002
10167
|
updateInfoThisRound = true;
|
|
11003
|
-
isAtEnd = lockPosition();
|
|
10168
|
+
isAtEnd = control.lockPosition();
|
|
11004
10169
|
}
|
|
11005
10170
|
} else if (e.altKey && e.shiftKey && position.x != 0) {
|
|
11006
10171
|
constants.lastx = position.x;
|
|
11007
|
-
Autoplay('reverse-left', -1, position.x);
|
|
10172
|
+
control.Autoplay('reverse-left', -1, position.x);
|
|
11008
10173
|
} else {
|
|
11009
10174
|
position.x += -1;
|
|
11010
10175
|
updateInfoThisRound = true;
|
|
11011
|
-
isAtEnd = lockPosition();
|
|
10176
|
+
isAtEnd = control.lockPosition();
|
|
11012
10177
|
}
|
|
11013
10178
|
} else if (e.key == 'Tab') {
|
|
11014
10179
|
// do nothing, we handle this in global events
|
|
@@ -11018,7 +10183,7 @@ class Control {
|
|
|
11018
10183
|
|
|
11019
10184
|
// update display / text / audio
|
|
11020
10185
|
if (updateInfoThisRound && !isAtEnd) {
|
|
11021
|
-
UpdateAllBraille();
|
|
10186
|
+
control.UpdateAllBraille();
|
|
11022
10187
|
}
|
|
11023
10188
|
if (isAtEnd) {
|
|
11024
10189
|
audio.playEnd();
|
|
@@ -11026,367 +10191,743 @@ class Control {
|
|
|
11026
10191
|
},
|
|
11027
10192
|
]);
|
|
11028
10193
|
|
|
11029
|
-
// control eventlisteners
|
|
11030
|
-
// constants.events.push([
|
|
11031
|
-
// [constants.chart, constants.brailleInput],
|
|
11032
|
-
// 'keydown',
|
|
11033
|
-
// function (e) {
|
|
11034
|
-
// let updateInfoThisRound = false; // we only update info and play tones on certain keys
|
|
11035
|
-
// let isAtEnd = false;
|
|
11036
|
-
|
|
11037
|
-
// if (e.key == 'ArrowRight') {
|
|
11038
|
-
// // right arrow
|
|
11039
|
-
// e.preventDefault();
|
|
11040
|
-
// if (e.target.selectionStart > e.target.value.length - 2) {
|
|
11041
|
-
// } else if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
11042
|
-
// if (e.shiftKey) {
|
|
11043
|
-
// position.x -= 1;
|
|
11044
|
-
// Autoplay('right', position.x, plot.pointValuesY.length);
|
|
11045
|
-
// } else {
|
|
11046
|
-
// position.x = plot.pointValuesY.length - 1; // go all the way
|
|
11047
|
-
// updateInfoThisRound = true;
|
|
11048
|
-
// isAtEnd = lockPosition();
|
|
11049
|
-
// }
|
|
11050
|
-
// } else if (
|
|
11051
|
-
// e.altKey &&
|
|
11052
|
-
// e.shiftKey &&
|
|
11053
|
-
// position.x != plot.pointValuesY.length - 1
|
|
11054
|
-
// ) {
|
|
11055
|
-
// constants.lastx = position.x;
|
|
11056
|
-
// Autoplay('reverse-right', plot.pointValuesY.length, position.x);
|
|
11057
|
-
// } else {
|
|
11058
|
-
// position.x += 1;
|
|
11059
|
-
// updateInfoThisRound = true;
|
|
11060
|
-
// isAtEnd = lockPosition();
|
|
11061
|
-
// }
|
|
11062
|
-
// } else if (e.key == 'ArrowLeft') {
|
|
11063
|
-
// // left arrow
|
|
11064
|
-
// e.preventDefault();
|
|
11065
|
-
// if (constants.isMac ? e.metaKey : e.ctrlKey) {
|
|
11066
|
-
// if (e.shiftKey) {
|
|
11067
|
-
// position.x += 1;
|
|
11068
|
-
// Autoplay('left', position.x, -1);
|
|
11069
|
-
// } else {
|
|
11070
|
-
// position.x = 0; // go all the way
|
|
11071
|
-
// updateInfoThisRound = true;
|
|
11072
|
-
// isAtEnd = lockPosition();
|
|
11073
|
-
// }
|
|
11074
|
-
// } else if (e.altKey && e.shiftKey && position.x != 0) {
|
|
11075
|
-
// constants.lastx = position.x;
|
|
11076
|
-
// Autoplay('reverse-left', -1, position.x);
|
|
11077
|
-
// } else {
|
|
11078
|
-
// position.x += -1;
|
|
11079
|
-
// updateInfoThisRound = true;
|
|
11080
|
-
// isAtEnd = lockPosition();
|
|
11081
|
-
// }
|
|
11082
|
-
// } else if (e.key == 'Tab') {
|
|
11083
|
-
// // do nothing, we handle this in global events
|
|
11084
|
-
// } else {
|
|
11085
|
-
// e.preventDefault();
|
|
11086
|
-
// // Right
|
|
11087
|
-
// if (
|
|
11088
|
-
// e.key == 'ArrowRight' &&
|
|
11089
|
-
// !(constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
11090
|
-
// !e.shiftKey
|
|
11091
|
-
// ) {
|
|
11092
|
-
// // just right arrow, move right
|
|
11093
|
-
// position.x += 1;
|
|
11094
|
-
// updateInfoThisRound = true;
|
|
11095
|
-
// isAtEnd = lockPosition();
|
|
11096
|
-
// } else if (
|
|
11097
|
-
// e.key == 'ArrowRight' &&
|
|
11098
|
-
// (constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
11099
|
-
// e.shiftKey
|
|
11100
|
-
// ) {
|
|
11101
|
-
// // ctrl shift right arrow, autoplay right
|
|
11102
|
-
// position.x += -1;
|
|
11103
|
-
// Autoplay('outward_right', position.x, plot.pointValuesY.length);
|
|
11104
|
-
// } else if (
|
|
11105
|
-
// e.key == 'ArrowRight' &&
|
|
11106
|
-
// !(constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
11107
|
-
// e.altKey &&
|
|
11108
|
-
// e.shiftKey &&
|
|
11109
|
-
// position.x != plot.pointValuesY.length - 1
|
|
11110
|
-
// ) {
|
|
11111
|
-
// // alt shift right, autoplay from right
|
|
11112
|
-
// constants.lastx = position.x;
|
|
11113
|
-
// Autoplay('inward_right', plot.pointValues.length, position.x);
|
|
11114
|
-
// } else if (
|
|
11115
|
-
// e.key == 'ArrowRight' &&
|
|
11116
|
-
// (constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
11117
|
-
// !e.shiftKey
|
|
11118
|
-
// ) {
|
|
11119
|
-
// // ctrl right arrow, go to end
|
|
11120
|
-
// position.x = plot.pointValuesY.length - 1; // go all the way
|
|
11121
|
-
// updateInfoThisRound = true;
|
|
11122
|
-
// isAtEnd = lockPosition();
|
|
11123
|
-
// }
|
|
11124
|
-
|
|
11125
|
-
// // Left
|
|
11126
|
-
// if (
|
|
11127
|
-
// e.key == 'ArrowLeft' &&
|
|
11128
|
-
// !(constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
11129
|
-
// !e.shiftKey
|
|
11130
|
-
// ) {
|
|
11131
|
-
// // just left arrow, move left
|
|
11132
|
-
// position.x += -1;
|
|
11133
|
-
// updateInfoThisRound = true;
|
|
11134
|
-
// isAtEnd = lockPosition();
|
|
11135
|
-
// } else if (
|
|
11136
|
-
// e.key == 'ArrowLeft' &&
|
|
11137
|
-
// (constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
11138
|
-
// e.shiftKey
|
|
11139
|
-
// ) {
|
|
11140
|
-
// // ctrl shift left arrow, autoplay left
|
|
11141
|
-
// position.x += 1;
|
|
11142
|
-
// Autoplay('outward_left', position.x, -1);
|
|
11143
|
-
// } else if (
|
|
11144
|
-
// e.key == 'ArrowLeft' &&
|
|
11145
|
-
// !(constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
11146
|
-
// e.altKey &&
|
|
11147
|
-
// e.shiftKey
|
|
11148
|
-
// ) {
|
|
11149
|
-
// // alt shift left, autoplay from left
|
|
11150
|
-
// constants.lastx = position.x;
|
|
11151
|
-
// Autoplay('inward_left', -1, position.x);
|
|
11152
|
-
// } else if (
|
|
11153
|
-
// e.key == 'ArrowLeft' &&
|
|
11154
|
-
// (constants.isMac ? e.metaKey : e.ctrlKey) &&
|
|
11155
|
-
// !e.shiftKey
|
|
11156
|
-
// ) {
|
|
11157
|
-
// // ctrl left arrow, go to beginning
|
|
11158
|
-
// position.x = 0; // go all the way
|
|
11159
|
-
// updateInfoThisRound = true;
|
|
11160
|
-
// isAtEnd = lockPosition();
|
|
11161
|
-
// }
|
|
11162
|
-
|
|
11163
|
-
// // update display / text / audio
|
|
11164
|
-
// if (updateInfoThisRound && !isAtEnd) {
|
|
11165
|
-
// if (constants.brailleMode == 'off') {
|
|
11166
|
-
// UpdateAll();
|
|
11167
|
-
// } else {
|
|
11168
|
-
// UpdateAllBraille();
|
|
11169
|
-
// }
|
|
11170
|
-
// }
|
|
11171
|
-
// if (isAtEnd) {
|
|
11172
|
-
// audio.playEnd();
|
|
11173
|
-
// }
|
|
11174
|
-
// }
|
|
11175
|
-
// },
|
|
11176
|
-
// ]);
|
|
11177
|
-
|
|
11178
|
-
let controlElements = [constants.chart, constants.brailleInput];
|
|
11179
10194
|
let lastx = 0;
|
|
11180
|
-
for (let i = 0; i < controlElements.length; i++) {
|
|
10195
|
+
for (let i = 0; i < this.controlElements.length; i++) {
|
|
11181
10196
|
constants.events.push([
|
|
11182
|
-
controlElements[i],
|
|
10197
|
+
this.controlElements[i],
|
|
11183
10198
|
'keydown',
|
|
11184
10199
|
function (e) {
|
|
11185
10200
|
// period: speed up
|
|
11186
10201
|
if (e.key == '.') {
|
|
11187
10202
|
constants.SpeedUp();
|
|
11188
|
-
PlayDuringSpeedChange();
|
|
10203
|
+
control.PlayDuringSpeedChange();
|
|
11189
10204
|
display.announceText('Speed up');
|
|
11190
10205
|
}
|
|
11191
10206
|
|
|
11192
10207
|
// comma: speed down
|
|
11193
10208
|
if (e.key == ',') {
|
|
11194
10209
|
constants.SpeedDown();
|
|
11195
|
-
PlayDuringSpeedChange();
|
|
10210
|
+
control.PlayDuringSpeedChange();
|
|
11196
10211
|
display.announceText('Speed down');
|
|
11197
10212
|
}
|
|
11198
10213
|
|
|
11199
10214
|
// /: reset speed
|
|
11200
10215
|
if (e.key == '/') {
|
|
11201
10216
|
constants.SpeedReset();
|
|
11202
|
-
PlayDuringSpeedChange();
|
|
10217
|
+
control.PlayDuringSpeedChange();
|
|
11203
10218
|
display.announceText('Speed reset');
|
|
11204
10219
|
}
|
|
11205
10220
|
},
|
|
11206
10221
|
]);
|
|
11207
10222
|
}
|
|
11208
|
-
|
|
11209
|
-
|
|
11210
|
-
|
|
11211
|
-
|
|
11212
|
-
|
|
11213
|
-
|
|
11214
|
-
|
|
11215
|
-
|
|
11216
|
-
|
|
11217
|
-
|
|
10223
|
+
//bookmark
|
|
10224
|
+
// working through moving these functions and consolidating below, got to here
|
|
10225
|
+
}
|
|
10226
|
+
}
|
|
10227
|
+
PlayDuringSpeedChange() {
|
|
10228
|
+
if (constants.autoplayId != null) {
|
|
10229
|
+
constants.KillAutoplay();
|
|
10230
|
+
audio.KillSmooth();
|
|
10231
|
+
if (lastPlayed == 'reverse-left') {
|
|
10232
|
+
if (constants.chartType == 'point') {
|
|
10233
|
+
control.Autoplay('right', position.x, lastx);
|
|
10234
|
+
} else if (constants.chartType == 'smooth') {
|
|
10235
|
+
control.Autoplay('right', positionL1.x, constants.lastx1);
|
|
10236
|
+
} else if (constants.plotOrientation == 'vert') {
|
|
10237
|
+
control.Autoplay('right', position.y, lastY);
|
|
10238
|
+
} else {
|
|
10239
|
+
control.Autoplay('right', position.x, lastx);
|
|
10240
|
+
}
|
|
10241
|
+
} else if (lastPlayed == 'reverse-right') {
|
|
10242
|
+
if (constants.chartType == 'point') {
|
|
10243
|
+
control.Autoplay('left', position.x, lastx);
|
|
10244
|
+
} else if (constants.chartType == 'smooth') {
|
|
10245
|
+
control.Autoplay('left', positionL1.x, constants.lastx1);
|
|
10246
|
+
} else if (constants.plotOrientation == 'vert') {
|
|
10247
|
+
control.Autoplay('left', position.y, lastY);
|
|
10248
|
+
} else {
|
|
10249
|
+
control.Autoplay('left', position.x, lastx);
|
|
10250
|
+
}
|
|
10251
|
+
} else if (lastPlayed == 'reverse-up') {
|
|
10252
|
+
if (constants.plotOrientation == 'vert') {
|
|
10253
|
+
control.Autoplay('down', position.y, lastY);
|
|
10254
|
+
} else {
|
|
10255
|
+
control.Autoplay('down', position.x, lastx);
|
|
10256
|
+
}
|
|
10257
|
+
} else if (lastPlayed == 'reverse-down') {
|
|
10258
|
+
if (constants.plotOrientation == 'vert') {
|
|
10259
|
+
control.Autoplay('up', position.y, lastY);
|
|
10260
|
+
} else {
|
|
10261
|
+
control.Autoplay('up', position.x, lastx);
|
|
10262
|
+
}
|
|
10263
|
+
} else {
|
|
10264
|
+
if (constants.chartType == 'point') {
|
|
10265
|
+
control.Autoplay(lastPlayed, position.x, lastx);
|
|
10266
|
+
} else if (constants.chartType == 'smooth') {
|
|
10267
|
+
control.Autoplay(lastPlayed, positionL1.x, constants.lastx1);
|
|
10268
|
+
} else if (constants.plotOrientation == 'vert') {
|
|
10269
|
+
control.Autoplay(lastPlayed, position.y, lastY);
|
|
10270
|
+
} else {
|
|
10271
|
+
control.Autoplay(lastPlayed, position.x, lastx);
|
|
11218
10272
|
}
|
|
11219
10273
|
}
|
|
10274
|
+
}
|
|
10275
|
+
}
|
|
10276
|
+
lockPosition(xMax, yMax) {
|
|
10277
|
+
let didLockHappen = false;
|
|
10278
|
+
// default values, which works for bar like charts
|
|
10279
|
+
if (
|
|
10280
|
+
control.isUndefinedOrNull(xMax) &&
|
|
10281
|
+
constants.chartType != 'smooth' &&
|
|
10282
|
+
constants.chartType != 'line'
|
|
10283
|
+
) {
|
|
10284
|
+
if (constants.plotOrientation == 'vert') {
|
|
10285
|
+
xMax = 0;
|
|
10286
|
+
yMax = plot.sections.length - 1;
|
|
10287
|
+
} else {
|
|
10288
|
+
xMax = plot.plotData.length - 1;
|
|
10289
|
+
yMax = 0;
|
|
10290
|
+
}
|
|
10291
|
+
}
|
|
11220
10292
|
|
|
11221
|
-
|
|
11222
|
-
|
|
11223
|
-
|
|
11224
|
-
|
|
11225
|
-
|
|
11226
|
-
|
|
11227
|
-
|
|
11228
|
-
|
|
11229
|
-
|
|
11230
|
-
|
|
10293
|
+
// exceptions first:
|
|
10294
|
+
// smooth
|
|
10295
|
+
if (constants.chartType == 'smooth') {
|
|
10296
|
+
if (positionL1.x < 0) {
|
|
10297
|
+
positionL1.x = 0;
|
|
10298
|
+
didLockHappen = true;
|
|
10299
|
+
}
|
|
10300
|
+
if (positionL1.x > plot.curvePoints.length - 1) {
|
|
10301
|
+
positionL1.x = plot.curvePoints.length - 1;
|
|
10302
|
+
didLockHappen = true;
|
|
10303
|
+
}
|
|
10304
|
+
} else if (constants.chartType == 'line') {
|
|
10305
|
+
if (position.x < 0) {
|
|
10306
|
+
position.x = 0;
|
|
10307
|
+
didLockHappen = true;
|
|
10308
|
+
}
|
|
10309
|
+
if (position.x > plot.pointValuesY.length - 1) {
|
|
10310
|
+
position.x = plot.pointValuesY.length - 1;
|
|
10311
|
+
didLockHappen = true;
|
|
10312
|
+
}
|
|
10313
|
+
} else if (
|
|
10314
|
+
constants.chartType == 'stacked_bar' ||
|
|
10315
|
+
constants.chartType == 'stacked_normalized_bar' ||
|
|
10316
|
+
constants.chartType == 'dodged_bar'
|
|
10317
|
+
) {
|
|
10318
|
+
if (position.x < 0) {
|
|
10319
|
+
position.x = 0;
|
|
10320
|
+
didLockHappen = true;
|
|
10321
|
+
} else if (position.x > plot.level.length - 1) {
|
|
10322
|
+
position.x = plot.level.length - 1;
|
|
10323
|
+
didLockHappen = true;
|
|
10324
|
+
}
|
|
10325
|
+
if (position.y < 0) {
|
|
10326
|
+
position.y = 0;
|
|
10327
|
+
didLockHappen = true;
|
|
10328
|
+
} else if (position.y > plot.fill.length - 1) {
|
|
10329
|
+
position.y = plot.fill.length - 1;
|
|
10330
|
+
didLockHappen = true;
|
|
10331
|
+
}
|
|
10332
|
+
} else {
|
|
10333
|
+
// lock to min / max postions
|
|
10334
|
+
let didLockHappen = false;
|
|
10335
|
+
if (position.y < 0) {
|
|
10336
|
+
position.y = 0;
|
|
10337
|
+
didLockHappen = true;
|
|
10338
|
+
if (constants.brailleMode != 'off') {
|
|
10339
|
+
// change selection to match postion as well
|
|
10340
|
+
constants.brailleInput.selectionEnd = 0;
|
|
11231
10341
|
}
|
|
11232
|
-
|
|
11233
|
-
|
|
11234
|
-
|
|
10342
|
+
}
|
|
10343
|
+
if (position.x < 0) {
|
|
10344
|
+
position.x = 0;
|
|
10345
|
+
didLockHappen = true;
|
|
10346
|
+
if (constants.brailleMode != 'off') {
|
|
10347
|
+
// change selection to match postion as well
|
|
10348
|
+
constants.brailleInput.selectionEnd = 0;
|
|
11235
10349
|
}
|
|
11236
|
-
|
|
11237
|
-
return didLockHappen;
|
|
11238
10350
|
}
|
|
11239
|
-
|
|
11240
|
-
|
|
11241
|
-
|
|
10351
|
+
if (position.x > xMax) {
|
|
10352
|
+
position.x = xMax;
|
|
10353
|
+
didLockHappen = true;
|
|
10354
|
+
constants.brailleInput.selectionStart =
|
|
10355
|
+
constants.brailleInput.value.length;
|
|
10356
|
+
}
|
|
10357
|
+
if (position.y > yMax) {
|
|
10358
|
+
position.y = yMax;
|
|
10359
|
+
didLockHappen = true;
|
|
10360
|
+
constants.brailleInput.selectionStart =
|
|
10361
|
+
constants.brailleInput.value.length;
|
|
10362
|
+
}
|
|
10363
|
+
}
|
|
10364
|
+
return didLockHappen;
|
|
10365
|
+
}
|
|
10366
|
+
UpdateAll() {
|
|
10367
|
+
if (constants.showDisplay) {
|
|
10368
|
+
display.displayValues();
|
|
10369
|
+
}
|
|
10370
|
+
if (constants.showRect && constants.hasRect) {
|
|
10371
|
+
if ([].concat(singleMaidr.type).includes('bar')) {
|
|
10372
|
+
plot.Select();
|
|
10373
|
+
} else if ([].concat(singleMaidr.type).includes('box')) {
|
|
10374
|
+
singleMaidr.rect.UpdateRect();
|
|
10375
|
+
} else if ([].concat(singleMaidr.type).includes('heat')) {
|
|
10376
|
+
singleMaidr.rect.UpdateRectDisplay();
|
|
10377
|
+
} else if (
|
|
10378
|
+
[].concat(singleMaidr.type).includes('point') ||
|
|
10379
|
+
[].concat(singleMaidr.type).includes('smooth')
|
|
10380
|
+
) {
|
|
10381
|
+
if (layer0Point.hasRect) {
|
|
10382
|
+
layer0Point.UpdatePointDisplay();
|
|
11242
10383
|
}
|
|
10384
|
+
} else if ([].concat(singleMaidr.type).includes('hist')) {
|
|
11243
10385
|
if (constants.showRect && constants.hasRect) {
|
|
11244
|
-
|
|
10386
|
+
plot.Select();
|
|
11245
10387
|
}
|
|
11246
|
-
|
|
11247
|
-
|
|
10388
|
+
} else if (
|
|
10389
|
+
[].concat(singleMaidr.type).includes('stacked_bar') ||
|
|
10390
|
+
[].concat(singleMaidr.type).includes('stacked_normalized_bar') ||
|
|
10391
|
+
[].concat(singleMaidr.type).includes('dodged_bar')
|
|
10392
|
+
) {
|
|
10393
|
+
if (constants.showRect && constants.hasRect) {
|
|
10394
|
+
plot.Select();
|
|
10395
|
+
}
|
|
10396
|
+
} else if ([].concat(singleMaidr.type).includes('line')) {
|
|
10397
|
+
if (constants.showRect && constants.hasRect) {
|
|
10398
|
+
let point = new Point();
|
|
10399
|
+
point.UpdatePointDisplay();
|
|
11248
10400
|
}
|
|
11249
10401
|
}
|
|
11250
|
-
|
|
11251
|
-
|
|
11252
|
-
|
|
10402
|
+
}
|
|
10403
|
+
if (constants.sonifMode != 'off') {
|
|
10404
|
+
plot.PlayTones();
|
|
10405
|
+
}
|
|
10406
|
+
}
|
|
10407
|
+
UpdateAllAutoPlay() {
|
|
10408
|
+
if (constants.showDisplayInAutoplay) {
|
|
10409
|
+
display.displayValues();
|
|
10410
|
+
}
|
|
10411
|
+
if (constants.showRect && constants.hasRect) {
|
|
10412
|
+
if ([].concat(singleMaidr.type).includes('bar')) {
|
|
10413
|
+
plot.Select();
|
|
10414
|
+
} else if ([].concat(singleMaidr.type).includes('box')) {
|
|
10415
|
+
singleMaidr.rect.UpdateRect();
|
|
10416
|
+
} else if ([].concat(singleMaidr.type).includes('heat')) {
|
|
10417
|
+
singleMaidr.rect.UpdateRectDisplay();
|
|
10418
|
+
} else if (
|
|
10419
|
+
[].concat(singleMaidr.type).includes('point') ||
|
|
10420
|
+
[].concat(singleMaidr.type).includes('smooth')
|
|
10421
|
+
) {
|
|
10422
|
+
if (constants.showRect) {
|
|
10423
|
+
if (constants.chartType == 'point' && layer0Point.hasRect) {
|
|
10424
|
+
layer0Point.UpdatePointDisplay();
|
|
10425
|
+
} else if (constants.chartType == 'smooth' && layer1Point.hasRect) {
|
|
10426
|
+
layer1Point.UpdatePointDisplay();
|
|
10427
|
+
}
|
|
10428
|
+
}
|
|
10429
|
+
} else if ([].concat(singleMaidr.type).includes('hist')) {
|
|
10430
|
+
if (constants.showRect && constants.hasRect) {
|
|
10431
|
+
plot.Select();
|
|
11253
10432
|
}
|
|
10433
|
+
} else if (
|
|
10434
|
+
[].concat(singleMaidr.type).includes('stacked_bar') ||
|
|
10435
|
+
[].concat(singleMaidr.type).includes('stacked_normalized_bar') ||
|
|
10436
|
+
[].concat(singleMaidr.type).includes('dodged_bar')
|
|
10437
|
+
) {
|
|
10438
|
+
if (constants.showRect && constants.hasRect) {
|
|
10439
|
+
plot.Select();
|
|
10440
|
+
}
|
|
10441
|
+
} else if ([].concat(singleMaidr.type).includes('line')) {
|
|
11254
10442
|
if (constants.showRect) {
|
|
10443
|
+
let point = new Point();
|
|
11255
10444
|
point.UpdatePointDisplay();
|
|
11256
10445
|
}
|
|
11257
|
-
|
|
11258
|
-
|
|
11259
|
-
|
|
10446
|
+
}
|
|
10447
|
+
}
|
|
10448
|
+
if (constants.sonifMode != 'off') {
|
|
10449
|
+
plot.PlayTones();
|
|
10450
|
+
}
|
|
11260
10451
|
|
|
11261
|
-
|
|
11262
|
-
|
|
11263
|
-
|
|
10452
|
+
if (constants.brailleMode != 'off') {
|
|
10453
|
+
display.UpdateBraillePos();
|
|
10454
|
+
}
|
|
10455
|
+
}
|
|
10456
|
+
UpdateAllBraille() {
|
|
10457
|
+
if (constants.showDisplayInBraille) {
|
|
10458
|
+
if (
|
|
10459
|
+
[].concat(singleMaidr.type).includes('stacked_bar') ||
|
|
10460
|
+
[].concat(singleMaidr.type).includes('stacked_normalized_bar') ||
|
|
10461
|
+
[].concat(singleMaidr.type).includes('dodged_bar')
|
|
10462
|
+
) {
|
|
10463
|
+
display.SetBraille();
|
|
11264
10464
|
}
|
|
11265
|
-
|
|
11266
|
-
|
|
11267
|
-
|
|
10465
|
+
display.displayValues();
|
|
10466
|
+
}
|
|
10467
|
+
if (constants.showRect && constants.hasRect) {
|
|
10468
|
+
if ([].concat(singleMaidr.type).includes('bar')) {
|
|
10469
|
+
plot.Select();
|
|
10470
|
+
} else if ([].concat(singleMaidr.type).includes('box')) {
|
|
10471
|
+
singleMaidr.rect.UpdateRect();
|
|
10472
|
+
} else if ([].concat(singleMaidr.type).includes('heat')) {
|
|
10473
|
+
singleMaidr.rect.UpdateRectDisplay();
|
|
10474
|
+
} else if (
|
|
10475
|
+
[].concat(singleMaidr.type).includes('point') ||
|
|
10476
|
+
[].concat(singleMaidr.type).includes('smooth')
|
|
10477
|
+
) {
|
|
10478
|
+
if (layer1Point.hasRect) {
|
|
10479
|
+
layer1Point.UpdatePointDisplay();
|
|
10480
|
+
}
|
|
10481
|
+
} else if ([].concat(singleMaidr.type).includes('hist')) {
|
|
10482
|
+
if (constants.showRect && constants.hasRect) {
|
|
10483
|
+
plot.Select();
|
|
10484
|
+
}
|
|
10485
|
+
} else if (
|
|
10486
|
+
[].concat(singleMaidr.type).includes('stacked_bar') ||
|
|
10487
|
+
[].concat(singleMaidr.type).includes('stacked_normalized_bar') ||
|
|
10488
|
+
[].concat(singleMaidr.type).includes('dodged_bar')
|
|
10489
|
+
) {
|
|
10490
|
+
if (constants.showRect && constants.hasRect) {
|
|
10491
|
+
plot.Select();
|
|
11268
10492
|
}
|
|
10493
|
+
} else if ([].concat(singleMaidr.type).includes('line')) {
|
|
11269
10494
|
if (constants.showRect) {
|
|
10495
|
+
let point = new Point();
|
|
11270
10496
|
point.UpdatePointDisplay();
|
|
11271
10497
|
}
|
|
11272
|
-
|
|
11273
|
-
|
|
10498
|
+
}
|
|
10499
|
+
}
|
|
10500
|
+
if (constants.sonifMode != 'off') {
|
|
10501
|
+
plot.PlayTones();
|
|
10502
|
+
}
|
|
10503
|
+
display.UpdateBraillePos();
|
|
10504
|
+
}
|
|
10505
|
+
Autoplay(dir, start, end) {
|
|
10506
|
+
let lastPlayed = dir;
|
|
10507
|
+
if ([].concat(singleMaidr.type).includes('bar')) {
|
|
10508
|
+
let step = 1; // default right and reverse-left
|
|
10509
|
+
if (dir == 'left' || dir == 'reverse-right') {
|
|
10510
|
+
step = -1;
|
|
10511
|
+
}
|
|
10512
|
+
|
|
10513
|
+
// clear old autoplay if exists
|
|
10514
|
+
if (constants.autoplayId != null) {
|
|
10515
|
+
constants.KillAutoplay();
|
|
10516
|
+
}
|
|
10517
|
+
|
|
10518
|
+
if (dir == 'reverse-right' || dir == 'reverse-left') {
|
|
10519
|
+
position.x = start;
|
|
10520
|
+
}
|
|
10521
|
+
|
|
10522
|
+
constants.autoplayId = setInterval(function () {
|
|
10523
|
+
position.x += step;
|
|
10524
|
+
if (position.x < 0 || plot.plotData.length - 1 < position.x) {
|
|
10525
|
+
constants.KillAutoplay();
|
|
10526
|
+
control.lockPosition();
|
|
10527
|
+
} else if (position.x == end) {
|
|
10528
|
+
constants.KillAutoplay();
|
|
10529
|
+
control.UpdateAllAutoPlay();
|
|
10530
|
+
} else {
|
|
10531
|
+
control.UpdateAllAutoPlay();
|
|
11274
10532
|
}
|
|
11275
|
-
|
|
10533
|
+
}, constants.autoPlayRate);
|
|
10534
|
+
} else if ([].concat(singleMaidr.type).includes('box')) {
|
|
10535
|
+
lastPlayed = dir;
|
|
10536
|
+
let step = 1; // default right / up / reverse-left / reverse-down
|
|
10537
|
+
if (
|
|
10538
|
+
dir == 'left' ||
|
|
10539
|
+
dir == 'down' ||
|
|
10540
|
+
dir == 'reverse-right' ||
|
|
10541
|
+
dir == 'reverse-up'
|
|
10542
|
+
) {
|
|
10543
|
+
step = -1;
|
|
10544
|
+
}
|
|
10545
|
+
|
|
10546
|
+
// clear old autoplay if exists
|
|
10547
|
+
if (constants.autoplayId != null) {
|
|
10548
|
+
constants.KillAutoplay();
|
|
10549
|
+
}
|
|
10550
|
+
|
|
10551
|
+
if (dir == 'reverse-left' || dir == 'reverse-right') {
|
|
10552
|
+
position.x = start;
|
|
10553
|
+
} else if (dir == 'reverse-up' || dir == 'reverse-down') {
|
|
10554
|
+
position.y = start;
|
|
11276
10555
|
}
|
|
11277
|
-
|
|
11278
|
-
|
|
11279
|
-
|
|
11280
|
-
|
|
11281
|
-
|
|
10556
|
+
|
|
10557
|
+
if (constants.debugLevel > 0) {
|
|
10558
|
+
console.log('starting autoplay', dir, start, end);
|
|
10559
|
+
}
|
|
10560
|
+
|
|
10561
|
+
control.UpdateAllAutoPlay(); // play current tone before we move
|
|
10562
|
+
constants.autoplayId = setInterval(function () {
|
|
10563
|
+
let doneNext = false;
|
|
10564
|
+
if (dir == 'left' || dir == 'right' || dir == 'up' || dir == 'down') {
|
|
10565
|
+
if (
|
|
10566
|
+
(position.x < 1 && dir == 'left') ||
|
|
10567
|
+
(constants.plotOrientation == 'vert' &&
|
|
10568
|
+
dir == 'up' &&
|
|
10569
|
+
position.y > plot.sections.length - 2) ||
|
|
10570
|
+
(constants.plotOrientation == 'horz' &&
|
|
10571
|
+
dir == 'up' &&
|
|
10572
|
+
position.y > plot.plotData.length - 2) ||
|
|
10573
|
+
(constants.plotOrientation == 'horz' &&
|
|
10574
|
+
dir == 'right' &&
|
|
10575
|
+
position.x > plot.sections.length - 2) ||
|
|
10576
|
+
(constants.plotOrientation == 'vert' &&
|
|
10577
|
+
dir == 'right' &&
|
|
10578
|
+
position.x > plot.plotData.length - 2) ||
|
|
10579
|
+
(constants.plotOrientation == 'horz' &&
|
|
10580
|
+
dir == 'down' &&
|
|
10581
|
+
position.y < 1) ||
|
|
10582
|
+
(constants.plotOrientation == 'vert' &&
|
|
10583
|
+
dir == 'down' &&
|
|
10584
|
+
position.y < 1)
|
|
10585
|
+
) {
|
|
10586
|
+
doneNext = true;
|
|
10587
|
+
}
|
|
10588
|
+
} else {
|
|
10589
|
+
if (
|
|
10590
|
+
(dir == 'reverse-left' && position.x >= end) ||
|
|
10591
|
+
(dir == 'reverse-right' && position.x <= end) ||
|
|
10592
|
+
(dir == 'reverse-up' && position.y <= end) ||
|
|
10593
|
+
(dir == 'reverse-down' && position.y >= end)
|
|
10594
|
+
) {
|
|
10595
|
+
doneNext = true;
|
|
10596
|
+
}
|
|
11282
10597
|
}
|
|
11283
10598
|
|
|
11284
|
-
|
|
11285
|
-
if (constants.autoplayId != null) {
|
|
10599
|
+
if (doneNext) {
|
|
11286
10600
|
constants.KillAutoplay();
|
|
10601
|
+
} else {
|
|
10602
|
+
if (
|
|
10603
|
+
dir == 'left' ||
|
|
10604
|
+
dir == 'right' ||
|
|
10605
|
+
dir == 'reverse-left' ||
|
|
10606
|
+
dir == 'reverse-right'
|
|
10607
|
+
) {
|
|
10608
|
+
position.x += step;
|
|
10609
|
+
} else {
|
|
10610
|
+
position.y += step;
|
|
10611
|
+
}
|
|
10612
|
+
control.UpdateAllAutoPlay();
|
|
11287
10613
|
}
|
|
10614
|
+
if (constants.debugLevel > 5) {
|
|
10615
|
+
console.log('autoplay pos', position);
|
|
10616
|
+
}
|
|
10617
|
+
}, constants.autoPlayRate);
|
|
10618
|
+
} else if ([].concat(singleMaidr.type).includes('heat')) {
|
|
10619
|
+
lastPlayed = dir;
|
|
10620
|
+
let xMax = plot.num_cols - 1;
|
|
10621
|
+
let yMax = plot.num_rows - 1;
|
|
10622
|
+
let step = 1; // default right, down, reverse-left, and reverse-up
|
|
10623
|
+
if (
|
|
10624
|
+
dir == 'left' ||
|
|
10625
|
+
dir == 'up' ||
|
|
10626
|
+
dir == 'reverse-right' ||
|
|
10627
|
+
dir == 'reverse-down'
|
|
10628
|
+
) {
|
|
10629
|
+
step = -1;
|
|
10630
|
+
}
|
|
11288
10631
|
|
|
11289
|
-
|
|
11290
|
-
|
|
10632
|
+
// clear old autoplay if exists
|
|
10633
|
+
if (constants.autoplayId != null) {
|
|
10634
|
+
constants.KillAutoplay();
|
|
10635
|
+
}
|
|
10636
|
+
|
|
10637
|
+
if (dir == 'reverse-left' || dir == 'reverse-right') {
|
|
10638
|
+
position.x = start;
|
|
10639
|
+
} else if (dir == 'reverse-up' || dir == 'reverse-down') {
|
|
10640
|
+
position.y = start;
|
|
10641
|
+
}
|
|
10642
|
+
|
|
10643
|
+
constants.autoplayId = setInterval(function () {
|
|
10644
|
+
if (
|
|
10645
|
+
dir == 'left' ||
|
|
10646
|
+
dir == 'right' ||
|
|
10647
|
+
dir == 'reverse-left' ||
|
|
10648
|
+
dir == 'reverse-right'
|
|
10649
|
+
) {
|
|
10650
|
+
position.x += step;
|
|
10651
|
+
if (position.x < 0 || plot.num_cols - 1 < position.x) {
|
|
10652
|
+
constants.KillAutoplay();
|
|
10653
|
+
control.lockPosition(xMax, yMax);
|
|
10654
|
+
} else if (position.x == end) {
|
|
10655
|
+
constants.KillAutoplay();
|
|
10656
|
+
control.UpdateAllAutoPlay();
|
|
10657
|
+
} else {
|
|
10658
|
+
control.UpdateAllAutoPlay();
|
|
10659
|
+
}
|
|
10660
|
+
} else {
|
|
10661
|
+
// up or down
|
|
10662
|
+
position.y += step;
|
|
10663
|
+
if (position.y < 0 || plot.num_rows - 1 < position.y) {
|
|
10664
|
+
constants.KillAutoplay();
|
|
10665
|
+
control.lockPosition(xMax, yMax);
|
|
10666
|
+
} else if (position.y == end) {
|
|
10667
|
+
constants.KillAutoplay();
|
|
10668
|
+
control.UpdateAllAutoPlay();
|
|
10669
|
+
} else {
|
|
10670
|
+
control.UpdateAllAutoPlay();
|
|
10671
|
+
}
|
|
11291
10672
|
}
|
|
10673
|
+
}, constants.autoPlayRate);
|
|
10674
|
+
} else if (
|
|
10675
|
+
[].concat(singleMaidr.type).includes('point') ||
|
|
10676
|
+
[].concat(singleMaidr.type).includes('smooth')
|
|
10677
|
+
) {
|
|
10678
|
+
lastPlayed = dir;
|
|
10679
|
+
let xMax = 0;
|
|
10680
|
+
let yMax = 0;
|
|
10681
|
+
if (constants.chartType == 'point') {
|
|
10682
|
+
xMax = plot.x.length - 1;
|
|
10683
|
+
} else if (constants.chartType == 'smooth') {
|
|
10684
|
+
xMax = plot.curvePoints.length - 1;
|
|
10685
|
+
}
|
|
10686
|
+
let step = 1; // default right and reverse left
|
|
10687
|
+
if (dir == 'left' || dir == 'reverse-right') {
|
|
10688
|
+
step = -1;
|
|
10689
|
+
}
|
|
11292
10690
|
|
|
10691
|
+
// clear old autoplay if exists
|
|
10692
|
+
if (constants.autoplayId) {
|
|
10693
|
+
constants.KillAutoplay();
|
|
10694
|
+
}
|
|
10695
|
+
if (constants.isSmoothAutoplay) {
|
|
10696
|
+
audio.KillSmooth();
|
|
10697
|
+
}
|
|
10698
|
+
|
|
10699
|
+
if (dir == 'reverse-left' || dir == 'reverse-right') {
|
|
10700
|
+
position.x = start;
|
|
10701
|
+
position.L1x = start;
|
|
10702
|
+
}
|
|
10703
|
+
|
|
10704
|
+
if (constants.chartType == 'point') {
|
|
11293
10705
|
constants.autoplayId = setInterval(function () {
|
|
11294
10706
|
position.x += step;
|
|
11295
|
-
|
|
10707
|
+
// autoplay for two layers: point layer & smooth layer in braille
|
|
10708
|
+
// plot.numPoints is not available anymore
|
|
10709
|
+
if (position.x < 0 || position.x > plot.y.length - 1) {
|
|
11296
10710
|
constants.KillAutoplay();
|
|
11297
|
-
lockPosition();
|
|
10711
|
+
control.lockPosition(xMax, yMax);
|
|
11298
10712
|
} else if (position.x == end) {
|
|
11299
10713
|
constants.KillAutoplay();
|
|
11300
|
-
|
|
10714
|
+
control.UpdateAllAutoPlay();
|
|
11301
10715
|
} else {
|
|
11302
|
-
|
|
10716
|
+
control.UpdateAllAutoPlay();
|
|
11303
10717
|
}
|
|
11304
10718
|
}, constants.autoPlayRate);
|
|
11305
|
-
}
|
|
11306
|
-
|
|
11307
|
-
|
|
11308
|
-
|
|
11309
|
-
|
|
11310
|
-
|
|
11311
|
-
|
|
11312
|
-
|
|
11313
|
-
|
|
11314
|
-
|
|
11315
|
-
|
|
11316
|
-
|
|
11317
|
-
|
|
11318
|
-
let x = positionL1.x < 0 ? 0 : positionL1.x;
|
|
11319
|
-
let duration = 0;
|
|
11320
|
-
if (dir == 'right') {
|
|
11321
|
-
for (let i = x; i < plot.curvePoints.length; i++) {
|
|
11322
|
-
freqArr.push(
|
|
11323
|
-
audio.SlideBetween(
|
|
11324
|
-
plot.curvePoints[i],
|
|
11325
|
-
plot.curveMinY,
|
|
11326
|
-
plot.curveMaxY,
|
|
11327
|
-
constants.MIN_FREQUENCY,
|
|
11328
|
-
constants.MAX_FREQUENCY
|
|
11329
|
-
)
|
|
11330
|
-
);
|
|
11331
|
-
}
|
|
11332
|
-
panningArr = [panPoint, 1];
|
|
11333
|
-
duration =
|
|
11334
|
-
(Math.abs(plot.curvePoints.length - x) / plot.curvePoints.length) *
|
|
11335
|
-
3;
|
|
11336
|
-
} else if (dir == 'left') {
|
|
11337
|
-
for (let i = x; i >= 0; i--) {
|
|
11338
|
-
freqArr.push(
|
|
11339
|
-
audio.SlideBetween(
|
|
11340
|
-
plot.curvePoints[i],
|
|
11341
|
-
plot.curveMinY,
|
|
11342
|
-
plot.curveMaxY,
|
|
11343
|
-
constants.MIN_FREQUENCY,
|
|
11344
|
-
constants.MAX_FREQUENCY
|
|
11345
|
-
)
|
|
11346
|
-
);
|
|
10719
|
+
} else if (constants.chartType == 'smooth') {
|
|
10720
|
+
constants.autoplayId = setInterval(function () {
|
|
10721
|
+
positionL1.x += step;
|
|
10722
|
+
// autoplay for two layers: point layer & smooth layer in braille
|
|
10723
|
+
// plot.numPoints is not available anymore
|
|
10724
|
+
if (positionL1.x < 0 || positionL1.x > plot.curvePoints.length - 1) {
|
|
10725
|
+
constants.KillAutoplay();
|
|
10726
|
+
control.lockPosition(xMax, yMax);
|
|
10727
|
+
} else if (positionL1.x == end) {
|
|
10728
|
+
constants.KillAutoplay();
|
|
10729
|
+
control.UpdateAllAutoPlay();
|
|
10730
|
+
} else {
|
|
10731
|
+
control.UpdateAllAutoPlay();
|
|
11347
10732
|
}
|
|
11348
|
-
|
|
11349
|
-
|
|
11350
|
-
|
|
11351
|
-
|
|
11352
|
-
|
|
11353
|
-
|
|
11354
|
-
|
|
11355
|
-
|
|
11356
|
-
|
|
11357
|
-
|
|
11358
|
-
|
|
11359
|
-
|
|
11360
|
-
|
|
10733
|
+
}, constants.autoPlayRate);
|
|
10734
|
+
}
|
|
10735
|
+
} else if ([].concat(singleMaidr.type).includes('hist')) {
|
|
10736
|
+
lastPlayed = dir;
|
|
10737
|
+
let step = 1; // default right and reverse-left
|
|
10738
|
+
if (dir == 'left' || dir == 'reverse-right') {
|
|
10739
|
+
step = -1;
|
|
10740
|
+
}
|
|
10741
|
+
|
|
10742
|
+
// clear old autoplay if exists
|
|
10743
|
+
if (constants.autoplayId != null) {
|
|
10744
|
+
constants.KillAutoplay();
|
|
10745
|
+
}
|
|
10746
|
+
|
|
10747
|
+
if (dir == 'reverse-right' || dir == 'reverse-left') {
|
|
10748
|
+
position.x = start;
|
|
10749
|
+
}
|
|
10750
|
+
|
|
10751
|
+
constants.autoplayId = setInterval(function () {
|
|
10752
|
+
position.x += step;
|
|
10753
|
+
if (position.x < 0 || plot.plotData.length - 1 < position.x) {
|
|
10754
|
+
constants.KillAutoplay();
|
|
10755
|
+
control.lockPosition();
|
|
10756
|
+
} else if (position.x == end) {
|
|
10757
|
+
constants.KillAutoplay();
|
|
10758
|
+
control.UpdateAllAutoPlay();
|
|
10759
|
+
} else {
|
|
10760
|
+
control.UpdateAllAutoPlay();
|
|
10761
|
+
}
|
|
10762
|
+
}, constants.autoPlayRate);
|
|
10763
|
+
} else if (
|
|
10764
|
+
[].concat(singleMaidr.type).includes('stacked_bar') ||
|
|
10765
|
+
[].concat(singleMaidr.type).includes('stacked_normalized_bar') ||
|
|
10766
|
+
[].concat(singleMaidr.type).includes('dodged_bar')
|
|
10767
|
+
) {
|
|
10768
|
+
lastPlayed = dir;
|
|
10769
|
+
let step = 1; // default right, up, reverse-left, and reverse-down
|
|
10770
|
+
if (
|
|
10771
|
+
dir == 'left' ||
|
|
10772
|
+
dir == 'down' ||
|
|
10773
|
+
dir == 'reverse-right' ||
|
|
10774
|
+
dir == 'reverse-up'
|
|
10775
|
+
) {
|
|
10776
|
+
step = -1;
|
|
10777
|
+
}
|
|
10778
|
+
|
|
10779
|
+
// clear old autoplay if exists
|
|
10780
|
+
if (constants.autoplayId != null) {
|
|
10781
|
+
constants.KillAutoplay();
|
|
10782
|
+
}
|
|
10783
|
+
|
|
10784
|
+
if (dir == 'reverse-left' || dir == 'reverse-right') {
|
|
10785
|
+
position.x = start;
|
|
10786
|
+
} else if (dir == 'reverse-up' || dir == 'reverse-down') {
|
|
10787
|
+
position.y = start;
|
|
10788
|
+
}
|
|
10789
|
+
|
|
10790
|
+
constants.autoplayId = setInterval(function () {
|
|
10791
|
+
if (
|
|
10792
|
+
dir == 'left' ||
|
|
10793
|
+
dir == 'right' ||
|
|
10794
|
+
dir == 'reverse-left' ||
|
|
10795
|
+
dir == 'reverse-right'
|
|
10796
|
+
) {
|
|
10797
|
+
position.x += step;
|
|
10798
|
+
if (position.x < 0 || plot.plotData.length - 1 < position.x) {
|
|
10799
|
+
constants.KillAutoplay();
|
|
10800
|
+
control.lockPosition();
|
|
10801
|
+
} else if (position.x == end) {
|
|
10802
|
+
constants.KillAutoplay();
|
|
10803
|
+
control.UpdateAllAutoPlay();
|
|
10804
|
+
} else {
|
|
10805
|
+
control.UpdateAllAutoPlay();
|
|
11361
10806
|
}
|
|
11362
|
-
|
|
11363
|
-
|
|
11364
|
-
|
|
11365
|
-
|
|
11366
|
-
|
|
11367
|
-
|
|
11368
|
-
|
|
11369
|
-
|
|
11370
|
-
|
|
11371
|
-
|
|
11372
|
-
|
|
11373
|
-
constants.MIN_FREQUENCY,
|
|
11374
|
-
constants.MAX_FREQUENCY
|
|
11375
|
-
)
|
|
11376
|
-
);
|
|
10807
|
+
} else {
|
|
10808
|
+
// up or down
|
|
10809
|
+
position.y += step;
|
|
10810
|
+
if (position.y < 0 || plot.plotData[0].length - 1 < position.y) {
|
|
10811
|
+
constants.KillAutoplay();
|
|
10812
|
+
control.lockPosition();
|
|
10813
|
+
} else if (position.y == end) {
|
|
10814
|
+
constants.KillAutoplay();
|
|
10815
|
+
control.UpdateAllAutoPlay();
|
|
10816
|
+
} else {
|
|
10817
|
+
control.UpdateAllAutoPlay();
|
|
11377
10818
|
}
|
|
11378
|
-
panningArr = [-1, panPoint];
|
|
11379
|
-
duration = (Math.abs(x) / plot.curvePoints.length) * 3;
|
|
11380
10819
|
}
|
|
10820
|
+
}, constants.autoPlayRate);
|
|
10821
|
+
} else if ([].concat(singleMaidr.type).includes('hist')) {
|
|
10822
|
+
lastPlayed = dir;
|
|
10823
|
+
let step = 1; // default right and reverse-left
|
|
10824
|
+
if (dir == 'left' || dir == 'reverse-right') {
|
|
10825
|
+
step = -1;
|
|
10826
|
+
}
|
|
11381
10827
|
|
|
11382
|
-
|
|
11383
|
-
|
|
10828
|
+
// clear old autoplay if exists
|
|
10829
|
+
if (constants.autoplayId != null) {
|
|
10830
|
+
constants.KillAutoplay();
|
|
10831
|
+
}
|
|
10832
|
+
|
|
10833
|
+
if (dir == 'reverse-right' || dir == 'reverse-left') {
|
|
10834
|
+
position.x = start;
|
|
10835
|
+
}
|
|
10836
|
+
|
|
10837
|
+
constants.autoplayId = setInterval(function () {
|
|
10838
|
+
position.x += step;
|
|
10839
|
+
if (position.x < 0 || plot.pointValuesY.length - 1 < position.x) {
|
|
10840
|
+
constants.KillAutoplay();
|
|
10841
|
+
control.lockPosition();
|
|
10842
|
+
} else if (position.x == end) {
|
|
10843
|
+
constants.KillAutoplay();
|
|
10844
|
+
control.UpdateAllAutoPlay();
|
|
10845
|
+
} else {
|
|
10846
|
+
control.UpdateAllAutoPlay();
|
|
11384
10847
|
}
|
|
10848
|
+
}, constants.autoPlayRate);
|
|
10849
|
+
}
|
|
10850
|
+
}
|
|
10851
|
+
PlayLine(dir) {
|
|
10852
|
+
lastPlayed = dir;
|
|
11385
10853
|
|
|
11386
|
-
|
|
11387
|
-
|
|
10854
|
+
let freqArr = [];
|
|
10855
|
+
let panningArr = [];
|
|
10856
|
+
let panPoint = audio.SlideBetween(
|
|
10857
|
+
positionL1.x,
|
|
10858
|
+
0,
|
|
10859
|
+
plot.curvePoints.length - 1,
|
|
10860
|
+
-1,
|
|
10861
|
+
1
|
|
10862
|
+
);
|
|
10863
|
+
let x = positionL1.x < 0 ? 0 : positionL1.x;
|
|
10864
|
+
let duration = 0;
|
|
10865
|
+
if (dir == 'right') {
|
|
10866
|
+
for (let i = x; i < plot.curvePoints.length; i++) {
|
|
10867
|
+
freqArr.push(
|
|
10868
|
+
audio.SlideBetween(
|
|
10869
|
+
plot.curvePoints[i],
|
|
10870
|
+
plot.curveMinY,
|
|
10871
|
+
plot.curveMaxY,
|
|
10872
|
+
constants.MIN_FREQUENCY,
|
|
10873
|
+
constants.MAX_FREQUENCY
|
|
10874
|
+
)
|
|
10875
|
+
);
|
|
11388
10876
|
}
|
|
10877
|
+
panningArr = [panPoint, 1];
|
|
10878
|
+
duration =
|
|
10879
|
+
(Math.abs(plot.curvePoints.length - x) / plot.curvePoints.length) * 3;
|
|
10880
|
+
} else if (dir == 'left') {
|
|
10881
|
+
for (let i = x; i >= 0; i--) {
|
|
10882
|
+
freqArr.push(
|
|
10883
|
+
audio.SlideBetween(
|
|
10884
|
+
plot.curvePoints[i],
|
|
10885
|
+
plot.curveMinY,
|
|
10886
|
+
plot.curveMaxY,
|
|
10887
|
+
constants.MIN_FREQUENCY,
|
|
10888
|
+
constants.MAX_FREQUENCY
|
|
10889
|
+
)
|
|
10890
|
+
);
|
|
10891
|
+
}
|
|
10892
|
+
panningArr = [panPoint, -1];
|
|
10893
|
+
duration = (Math.abs(x) / plot.curvePoints.length) * 3;
|
|
10894
|
+
} else if (dir == 'reverse-right') {
|
|
10895
|
+
for (let i = plot.curvePoints.length - 1; i >= x; i--) {
|
|
10896
|
+
freqArr.push(
|
|
10897
|
+
audio.SlideBetween(
|
|
10898
|
+
plot.curvePoints[i],
|
|
10899
|
+
plot.curveMinY,
|
|
10900
|
+
plot.curveMaxY,
|
|
10901
|
+
constants.MIN_FREQUENCY,
|
|
10902
|
+
constants.MAX_FREQUENCY
|
|
10903
|
+
)
|
|
10904
|
+
);
|
|
10905
|
+
}
|
|
10906
|
+
panningArr = [1, panPoint];
|
|
10907
|
+
duration =
|
|
10908
|
+
(Math.abs(plot.curvePoints.length - x) / plot.curvePoints.length) * 3;
|
|
10909
|
+
} else if (dir == 'reverse-left') {
|
|
10910
|
+
for (let i = 0; i <= x; i++) {
|
|
10911
|
+
freqArr.push(
|
|
10912
|
+
audio.SlideBetween(
|
|
10913
|
+
plot.curvePoints[i],
|
|
10914
|
+
plot.curveMinY,
|
|
10915
|
+
plot.curveMaxY,
|
|
10916
|
+
constants.MIN_FREQUENCY,
|
|
10917
|
+
constants.MAX_FREQUENCY
|
|
10918
|
+
)
|
|
10919
|
+
);
|
|
10920
|
+
}
|
|
10921
|
+
panningArr = [-1, panPoint];
|
|
10922
|
+
duration = (Math.abs(x) / plot.curvePoints.length) * 3;
|
|
11389
10923
|
}
|
|
10924
|
+
|
|
10925
|
+
if (constants.isSmoothAutoplay) {
|
|
10926
|
+
audio.KillSmooth();
|
|
10927
|
+
}
|
|
10928
|
+
|
|
10929
|
+
// audio.playSmooth(freqArr, 2, panningArr, constants.vol, 'sine');
|
|
10930
|
+
audio.playSmooth(freqArr, duration, panningArr, constants.vol, 'sine');
|
|
11390
10931
|
}
|
|
11391
10932
|
|
|
11392
10933
|
/**
|
|
@@ -11394,7 +10935,7 @@ class Control {
|
|
|
11394
10935
|
* @param {string} nextprev - Determines whether to get the next or previous focusable element. Defaults to 'next'.
|
|
11395
10936
|
* @returns {HTMLElement|null} - The next or previous focusable element, or null if it does not exist.
|
|
11396
10937
|
*/
|
|
11397
|
-
GetNextPrevFocusable(
|
|
10938
|
+
GetNextPrevFocusable() {
|
|
11398
10939
|
// store all focusable elements for future tabbing away from chart
|
|
11399
10940
|
let focusableSelectors =
|
|
11400
10941
|
'a[href], button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
@@ -11421,6 +10962,19 @@ class Control {
|
|
|
11421
10962
|
|
|
11422
10963
|
// now we get next / prev based on chartIndex. If DNE, return null
|
|
11423
10964
|
}
|
|
10965
|
+
/**
|
|
10966
|
+
* Checks if the given item is undefined or null.
|
|
10967
|
+
* @param {*} item - The item to check.
|
|
10968
|
+
* @returns {boolean} - Returns true if the item is undefined or null, else false.
|
|
10969
|
+
*/
|
|
10970
|
+
// todo: this is duplicated in Tracker. Consolidate both somewhere sensible
|
|
10971
|
+
isUndefinedOrNull(item) {
|
|
10972
|
+
try {
|
|
10973
|
+
return item === undefined || item === null;
|
|
10974
|
+
} catch {
|
|
10975
|
+
return true;
|
|
10976
|
+
}
|
|
10977
|
+
}
|
|
11424
10978
|
}
|
|
11425
10979
|
|
|
11426
10980
|
// events and init functions
|