@refinitiv-ui/efx-grid 6.0.91 → 6.0.93
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/lib/column-dragging/es6/ColumnDragging.d.ts +1 -1
- package/lib/column-dragging/es6/ColumnDragging.js +144 -34
- package/lib/core/dist/core.js +2410 -2621
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/data/ColumnStats.js +14 -14
- package/lib/core/es6/data/DataCache.js +118 -118
- package/lib/core/es6/data/DataTable.d.ts +3 -1
- package/lib/core/es6/data/DataTable.js +208 -190
- package/lib/core/es6/data/DataView.d.ts +1 -1
- package/lib/core/es6/data/DataView.js +291 -291
- package/lib/core/es6/data/Segment.js +79 -79
- package/lib/core/es6/data/SegmentCollection.js +81 -81
- package/lib/core/es6/data/WrappedView.js +41 -41
- package/lib/core/es6/grid/Core.js +635 -635
- package/lib/core/es6/grid/ILayoutGrid.js +1 -1
- package/lib/core/es6/grid/LayoutGrid.js +183 -183
- package/lib/core/es6/grid/VirtualizedLayoutGrid.js +91 -91
- package/lib/core/es6/grid/components/Cell.js +29 -29
- package/lib/core/es6/grid/components/CellFloatingPanel.js +11 -11
- package/lib/core/es6/grid/components/CellSpan.js +7 -7
- package/lib/core/es6/grid/components/CellSpans.js +36 -34
- package/lib/core/es6/grid/components/Column.js +40 -40
- package/lib/core/es6/grid/components/ElementWrapper.js +17 -17
- package/lib/core/es6/grid/components/HScrollbar.js +31 -31
- package/lib/core/es6/grid/components/Scrollbar.js +77 -77
- package/lib/core/es6/grid/components/StretchedCells.js +49 -49
- package/lib/core/es6/grid/components/VScrollbar.js +11 -11
- package/lib/core/es6/grid/components/VirtualItems.js +3 -3
- package/lib/core/es6/grid/event/EventDispatcher.js +9 -9
- package/lib/core/es6/grid/event/EventListeners.js +4 -4
- package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +186 -186
- package/lib/core/es6/grid/util/Conflator.js +4 -4
- package/lib/core/es6/grid/util/Reverter.js +1 -1
- package/lib/core/es6/grid/util/SectionSettings.js +20 -20
- package/lib/core/es6/grid/util/SelectionList.js +23 -23
- package/lib/core/es6/grid/util/TrackLayout.js +74 -74
- package/lib/core/es6/grid/util/Virtualizer.js +15 -15
- package/lib/core/es6/grid/util/util.js +20 -20
- package/lib/core/es6/index.d.ts +0 -2
- package/lib/core/es6/index.js +0 -3
- package/lib/filter-dialog/lib/filter-dialog.js +1 -0
- package/lib/grid/index.js +1 -1
- package/lib/rt-grid/dist/rt-grid.js +193 -70
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/Grid.js +46 -30
- package/lib/rt-grid/es6/RowDefinition.d.ts +2 -1
- package/lib/rt-grid/es6/RowDefinition.js +74 -16
- package/lib/tr-grid-cell-selection/es6/CellSelection.js +56 -1
- package/lib/tr-grid-checkbox/es6/Checkbox.js +268 -268
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.d.ts +3 -2
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +60 -32
- package/lib/tr-grid-column-stack/es6/ColumnStack.js +279 -279
- package/lib/tr-grid-conditional-coloring/es6/ConditionalColoring.js +227 -207
- package/lib/tr-grid-in-cell-editing/es6/InCellEditing.js +11 -11
- package/lib/tr-grid-row-dragging/es6/RowDragging.d.ts +1 -2
- package/lib/tr-grid-row-dragging/es6/RowDragging.js +120 -121
- package/lib/tr-grid-util/es6/CellPainter.js +94 -104
- package/lib/tr-grid-util/es6/Conflator.js +4 -4
- package/lib/tr-grid-util/es6/CoralItems.js +6 -6
- package/lib/tr-grid-util/es6/DateTime.js +41 -41
- package/lib/tr-grid-util/es6/Deferred.js +5 -5
- package/lib/tr-grid-util/es6/Delay.d.ts +3 -3
- package/lib/tr-grid-util/es6/Delay.js +14 -3
- package/lib/tr-grid-util/es6/Dom.js +26 -26
- package/lib/tr-grid-util/es6/DragUI.js +17 -17
- package/lib/tr-grid-util/es6/ElementObserver.js +12 -12
- package/lib/tr-grid-util/es6/ElementWrapper.js +2 -2
- package/lib/tr-grid-util/es6/ElfDate.js +4 -4
- package/lib/tr-grid-util/es6/ElfUtil.js +37 -37
- package/lib/tr-grid-util/es6/EventDispatcher.js +12 -12
- package/lib/tr-grid-util/es6/ExpanderIcon.js +6 -6
- package/lib/tr-grid-util/es6/ExpressionParser.js +43 -43
- package/lib/tr-grid-util/es6/Ext.js +6 -6
- package/lib/tr-grid-util/es6/FieldFormatter.js +17 -17
- package/lib/tr-grid-util/es6/FilterBuilder.js +57 -58
- package/lib/tr-grid-util/es6/FilterOperators.d.ts +12 -1
- package/lib/tr-grid-util/es6/FilterOperators.js +13 -2
- package/lib/tr-grid-util/es6/GridPlugin.js +86 -87
- package/lib/tr-grid-util/es6/GroupDefinitions.js +90 -90
- package/lib/tr-grid-util/es6/Icon.js +4 -4
- package/lib/tr-grid-util/es6/MouseDownTrait.js +6 -6
- package/lib/tr-grid-util/es6/MultiTableManager.js +71 -80
- package/lib/tr-grid-util/es6/NumberFormatter.js +23 -23
- package/lib/tr-grid-util/es6/PercentBar.js +17 -17
- package/lib/tr-grid-util/es6/Perf.js +5 -5
- package/lib/tr-grid-util/es6/Popup.js +42 -42
- package/lib/tr-grid-util/es6/RangeBar.js +5 -5
- package/lib/tr-grid-util/es6/RequestQueue.js +5 -5
- package/lib/tr-grid-util/es6/RowPainter.js +23 -23
- package/lib/tr-grid-util/es6/SubTable.js +94 -94
- package/lib/tr-grid-util/es6/Table.js +51 -51
- package/lib/tr-grid-util/es6/TextHighlighter.js +52 -52
- package/lib/tr-grid-util/es6/TickCodes.js +2 -2
- package/lib/tr-grid-util/es6/Timer.js +2 -2
- package/lib/tr-grid-util/es6/TouchProxy.js +7 -7
- package/lib/tr-grid-util/es6/Util.js +50 -50
- package/lib/tr-grid-util/es6/formula/ADCService.js +2 -2
- package/lib/tr-grid-util/es6/formula/ADCSubscription.js +19 -19
- package/lib/tr-grid-util/es6/formula/AdFinService.js +2 -2
- package/lib/tr-grid-util/es6/formula/AdFinSubscription.js +19 -19
- package/lib/tr-grid-util/es6/formula/Engine.js +56 -56
- package/lib/tr-grid-util/es6/formula/Formula.js +62 -62
- package/lib/tr-grid-util/es6/formula/IntervalSubscription.js +3 -3
- package/lib/tr-grid-util/es6/formula/Realtime.js +15 -15
- package/lib/tr-grid-util/es6/formula/RealtimeService.js +15 -15
- package/lib/tr-grid-util/es6/formula/TSIService.js +2 -2
- package/lib/tr-grid-util/es6/formula/TSISubscription.js +104 -104
- package/lib/tr-grid-util/es6/formula/VariableToken.js +20 -20
- package/lib/tr-grid-util/es6/formula/functions/AdFin.js +10 -10
- package/lib/tr-grid-util/es6/formula/functions/Excel.js +1 -1
- package/lib/tr-grid-util/es6/formula/functions/Info.js +2 -2
- package/lib/tr-grid-util/es6/formula/functions/Internal.js +5 -5
- package/lib/tr-grid-util/es6/formula/functions/Logic.js +5 -5
- package/lib/tr-grid-util/es6/formula/functions/Math.js +46 -46
- package/lib/tr-grid-util/es6/formula/functions/Statistics.js +27 -27
- package/lib/tr-grid-util/es6/formula/functions/Text.js +19 -19
- package/lib/tr-grid-util/es6/index.js +1 -1
- package/lib/tr-grid-util/es6/jet/Adc.js +36 -36
- package/lib/tr-grid-util/es6/jet/CollectionDict.js +11 -11
- package/lib/tr-grid-util/es6/jet/DataGenerator.js +95 -95
- package/lib/tr-grid-util/es6/jet/DataSet.js +1 -1
- package/lib/tr-grid-util/es6/jet/MockArchive.js +5 -5
- package/lib/tr-grid-util/es6/jet/MockJET.js +1 -1
- package/lib/tr-grid-util/es6/jet/MockQuotes.js +13 -13
- package/lib/tr-grid-util/es6/jet/MockQuotes2.js +100 -100
- package/lib/tr-grid-util/es6/jet/MockRTK.js +4 -4
- package/lib/tr-grid-util/es6/jet/MockUtil.js +2 -2
- package/lib/tr-grid-util/es6/jet/index.js +1 -1
- package/lib/tr-grid-util/es6/jet/mockDataAPI.js +15 -15
- package/lib/tr-grid-util/es6/locale/translation-de.js +1 -1
- package/lib/tr-grid-util/es6/locale/translation-en.js +1 -1
- package/lib/tr-grid-util/es6/locale/translation-ja.js +1 -1
- package/lib/tr-grid-util/es6/locale/translation-zh-hant.js +1 -1
- package/lib/tr-grid-util/es6/locale/translation-zh.js +1 -1
- package/lib/tr-grid-util/es6/locale/translation.js +1 -1
- package/lib/types/es6/ColumnDragging.d.ts +1 -1
- package/lib/types/es6/ColumnGrouping.d.ts +3 -1
- package/lib/types/es6/Core/data/DataTable.d.ts +4 -0
- package/lib/types/es6/Core/data/DataView.d.ts +2 -0
- package/lib/types/es6/Core/data/SegmentCollection.d.ts +2 -0
- package/lib/types/es6/Core/index.d.ts +0 -2
- package/lib/types/es6/RealtimeGrid/RowDefinition.d.ts +2 -1
- package/lib/types/es6/RowDragging.d.ts +1 -2
- package/lib/versions.json +12 -12
- package/package.json +1 -1
- package/lib/core/es6/grid/util/ElementFrameWork.d.ts +0 -18
- package/lib/core/es6/grid/util/ElementFrameWork.js +0 -227
- package/lib/core/es6/grid/util/HttpRequest.d.ts +0 -53
- package/lib/core/es6/grid/util/HttpRequest.js +0 -371
- package/lib/core/es6/grid/util/PercentBar.d.ts +0 -43
- package/lib/core/es6/grid/util/PercentBar.js +0 -390
- package/lib/core/es6/grid/util/PercentBarRenderer.d.ts +0 -41
- package/lib/core/es6/grid/util/PercentBarRenderer.js +0 -316
- package/lib/core/es6/grid/util/RangeBar.d.ts +0 -25
- package/lib/core/es6/grid/util/RangeBar.js +0 -255
- package/lib/types/es6/Core/grid/util/ElementFrameWork.d.ts +0 -18
- package/lib/types/es6/Core/grid/util/HttpRequest.d.ts +0 -53
- package/lib/types/es6/Core/grid/util/PercentBar.d.ts +0 -43
- package/lib/types/es6/Core/grid/util/PercentBarRenderer.d.ts +0 -41
- package/lib/types/es6/Core/grid/util/RangeBar.d.ts +0 -25
|
@@ -25,7 +25,7 @@ import DataSet from "./DataSet.js";
|
|
|
25
25
|
* @param {number=} seed
|
|
26
26
|
* @return {number}
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
let _generateId = function(fInfo, seed) {
|
|
29
29
|
if(seed == null) {
|
|
30
30
|
seed = fInfo._id != null ? fInfo._id : -1;
|
|
31
31
|
fInfo._id = ++seed;
|
|
@@ -37,19 +37,19 @@ var _generateId = function(fInfo, seed) {
|
|
|
37
37
|
* @param {number=} seed
|
|
38
38
|
* @return {Date}
|
|
39
39
|
*/
|
|
40
|
-
|
|
40
|
+
let _generateDate1 = function(fInfo, seed) {
|
|
41
41
|
if(seed == null) {
|
|
42
42
|
return randDate(6e11, 16e11, seed);
|
|
43
43
|
}
|
|
44
44
|
return new Date(1e12 + 1e9 * seed);
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
let POW10 = [1, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10];
|
|
48
48
|
|
|
49
49
|
/** @type {Object.<string, DataGenerator~DataOptions>}
|
|
50
50
|
* @private
|
|
51
51
|
*/
|
|
52
|
-
|
|
52
|
+
let _fieldInfo = {
|
|
53
53
|
"X_RIC_NAME": {type: "string"},
|
|
54
54
|
"CF_NAME": {type: "string", prefix: true, suffix: " Name"},
|
|
55
55
|
"CF_LAST": {type: "number", min: 0.01, max: 1000, prec: 2},
|
|
@@ -113,7 +113,7 @@ var _fieldInfo = {
|
|
|
113
113
|
* @param {string} field
|
|
114
114
|
* @return {!Object}
|
|
115
115
|
*/
|
|
116
|
-
|
|
116
|
+
let getFieldInfo = function(field) {
|
|
117
117
|
return _fieldInfo[field] || {};
|
|
118
118
|
};
|
|
119
119
|
|
|
@@ -121,9 +121,9 @@ var getFieldInfo = function(field) {
|
|
|
121
121
|
* @param {string} field
|
|
122
122
|
* @param {DataGenerator~FieldInformation|Function} options
|
|
123
123
|
*/
|
|
124
|
-
|
|
124
|
+
let addFieldInfo = function(field, options) {
|
|
125
125
|
if(field) {
|
|
126
|
-
|
|
126
|
+
let opt = options;
|
|
127
127
|
if(typeof options === "function") {
|
|
128
128
|
opt = {
|
|
129
129
|
type: "function",
|
|
@@ -139,8 +139,8 @@ var addFieldInfo = function(field, options) {
|
|
|
139
139
|
* @param {number} seed
|
|
140
140
|
* @return {number}
|
|
141
141
|
*/
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
let pseudoRandNumber = function(seed) {
|
|
143
|
+
let rand = Math.sin(seed * 113) * 10000;
|
|
144
144
|
rand *= rand;
|
|
145
145
|
return rand - (rand | 0);
|
|
146
146
|
};
|
|
@@ -149,7 +149,7 @@ var pseudoRandNumber = function(seed) {
|
|
|
149
149
|
* @param {*=} seed
|
|
150
150
|
* @return {number}
|
|
151
151
|
*/
|
|
152
|
-
|
|
152
|
+
let _getRandomNumber = function(seed) {
|
|
153
153
|
return (typeof seed === "number") ? pseudoRandNumber(seed) : Math.random();
|
|
154
154
|
};
|
|
155
155
|
|
|
@@ -161,13 +161,13 @@ var _getRandomNumber = function(seed) {
|
|
|
161
161
|
* @param {number=} seed
|
|
162
162
|
* @return {number}
|
|
163
163
|
*/
|
|
164
|
-
|
|
164
|
+
let randNumber = function(min, max, prec, seed) {
|
|
165
165
|
if(!min) { min = 0; }
|
|
166
166
|
if(max == null) { max = 100; }
|
|
167
|
-
|
|
167
|
+
let v = (max - min) * _getRandomNumber(seed) + min;
|
|
168
168
|
|
|
169
169
|
if(prec > 0) {
|
|
170
|
-
|
|
170
|
+
let pow = POW10[prec];
|
|
171
171
|
return Math.floor(v * pow) / pow;
|
|
172
172
|
} else if(prec != null) {
|
|
173
173
|
return Math.floor(v);
|
|
@@ -183,7 +183,7 @@ var randNumber = function(min, max, prec, seed) {
|
|
|
183
183
|
* @param {number=} seed
|
|
184
184
|
* @return {number}
|
|
185
185
|
*/
|
|
186
|
-
|
|
186
|
+
let randInt = function(min, max, seed) {
|
|
187
187
|
return randNumber(min, max + 1, 0, seed);
|
|
188
188
|
};
|
|
189
189
|
|
|
@@ -194,7 +194,7 @@ var randInt = function(min, max, seed) {
|
|
|
194
194
|
* @param {number=} seed
|
|
195
195
|
* @return {number}
|
|
196
196
|
*/
|
|
197
|
-
|
|
197
|
+
let randBetween = function(min, max, seed) {
|
|
198
198
|
return randNumber(min, max, 0, seed);
|
|
199
199
|
};
|
|
200
200
|
|
|
@@ -206,7 +206,7 @@ var randBetween = function(min, max, seed) {
|
|
|
206
206
|
* @param {number=} seed
|
|
207
207
|
* @return {number}
|
|
208
208
|
*/
|
|
209
|
-
|
|
209
|
+
let randIndex = function(max, seed) {
|
|
210
210
|
return randBetween(0, max, seed);
|
|
211
211
|
};
|
|
212
212
|
|
|
@@ -214,7 +214,7 @@ var randIndex = function(max, seed) {
|
|
|
214
214
|
* @param {number=} seed
|
|
215
215
|
* @return {boolean}
|
|
216
216
|
*/
|
|
217
|
-
|
|
217
|
+
let randBoolean = function(seed) {
|
|
218
218
|
return randInt(0, 1, seed) === 0;
|
|
219
219
|
};
|
|
220
220
|
|
|
@@ -224,9 +224,9 @@ var randBoolean = function(seed) {
|
|
|
224
224
|
* @param {number=} seed
|
|
225
225
|
* @return {*}
|
|
226
226
|
*/
|
|
227
|
-
|
|
227
|
+
let randMember = function(set, seed) {
|
|
228
228
|
if(set) {
|
|
229
|
-
|
|
229
|
+
let index = randIndex(set.length, seed);
|
|
230
230
|
return set[index];
|
|
231
231
|
}
|
|
232
232
|
return String.fromCharCode(randInt(65, 90, seed));
|
|
@@ -238,7 +238,7 @@ var randMember = function(set, seed) {
|
|
|
238
238
|
* @param {number=} seed
|
|
239
239
|
* @return {Date}
|
|
240
240
|
*/
|
|
241
|
-
|
|
241
|
+
let randDate = function(min, max, seed) {
|
|
242
242
|
min = min || (Date.now() - 63072000000); //2 years back from now
|
|
243
243
|
if(min instanceof Date) {
|
|
244
244
|
min = min.getTime();
|
|
@@ -249,7 +249,7 @@ var randDate = function(min, max, seed) {
|
|
|
249
249
|
max = max.getTime();
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
|
|
252
|
+
let ts = randInt(0, (max - min) / 1000, seed);
|
|
253
253
|
return new Date(min + (ts * 1000));
|
|
254
254
|
};
|
|
255
255
|
|
|
@@ -259,15 +259,15 @@ var randDate = function(min, max, seed) {
|
|
|
259
259
|
* @param {number=} seed
|
|
260
260
|
* @return {string}
|
|
261
261
|
*/
|
|
262
|
-
|
|
263
|
-
|
|
262
|
+
let randString = function(min, max, seed) {
|
|
263
|
+
let wordCount = (min < max) ? randBetween(min, max, seed) : min;
|
|
264
264
|
|
|
265
|
-
|
|
266
|
-
for(
|
|
265
|
+
let ary = new Array(wordCount);
|
|
266
|
+
for(let i = 0; i < wordCount; ++i) {
|
|
267
267
|
if(seed != null) {
|
|
268
268
|
seed *= 1.17 * (i + 1);
|
|
269
269
|
}
|
|
270
|
-
|
|
270
|
+
let idx = randIndex(DataSet.words.length, seed);
|
|
271
271
|
ary[i] = DataSet.words[idx];
|
|
272
272
|
}
|
|
273
273
|
return ary.join(" ");
|
|
@@ -280,7 +280,7 @@ var randString = function(min, max, seed) {
|
|
|
280
280
|
* @param {Array.<string|number>=} fields Keys to be mapped on the output records.
|
|
281
281
|
* @return {Array.<Object>} records
|
|
282
282
|
*/
|
|
283
|
-
|
|
283
|
+
let toRecords = function(data2D, fields) {
|
|
284
284
|
if(!Array.isArray(data2D)) {
|
|
285
285
|
return null;
|
|
286
286
|
}
|
|
@@ -291,16 +291,16 @@ var toRecords = function(data2D, fields) {
|
|
|
291
291
|
fields = [];
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
for(
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
for(
|
|
301
|
-
|
|
294
|
+
let len = data2D.length;
|
|
295
|
+
let records = new Array(len);
|
|
296
|
+
for(let i = 0; i < len; ++i) {
|
|
297
|
+
let record = records[i] = {};
|
|
298
|
+
let columns = data2D[i];
|
|
299
|
+
let jLen = columns ? (columns.length || 0) : 0;
|
|
300
|
+
for(let j = 0; j < jLen; ++j) {
|
|
301
|
+
let value = columns[j];
|
|
302
302
|
if(value !== undefined) { // eslint-disable-line
|
|
303
|
-
|
|
303
|
+
let key = fields[j];
|
|
304
304
|
if(!key && key !== 0) {
|
|
305
305
|
key = j + "";
|
|
306
306
|
}
|
|
@@ -314,7 +314,7 @@ var toRecords = function(data2D, fields) {
|
|
|
314
314
|
/** @public
|
|
315
315
|
* @return {number}
|
|
316
316
|
*/
|
|
317
|
-
|
|
317
|
+
let getSeed = function() {
|
|
318
318
|
return DataGenerator.seed;
|
|
319
319
|
};
|
|
320
320
|
|
|
@@ -324,8 +324,8 @@ var getSeed = function() {
|
|
|
324
324
|
* @param {DataGenerator~DataOptions=} options
|
|
325
325
|
* @return {!Array.<Array>} 2D Array of data
|
|
326
326
|
*/
|
|
327
|
-
|
|
328
|
-
|
|
327
|
+
let generate = function(fields, options) {
|
|
328
|
+
let result = _generate2DArray(fields, options, DataGenerator.seed);
|
|
329
329
|
DataGenerator.seed = result.seed;
|
|
330
330
|
|
|
331
331
|
return result.data;
|
|
@@ -338,11 +338,11 @@ var generate = function(fields, options) {
|
|
|
338
338
|
* @param {number=} seed
|
|
339
339
|
* @return {!Object} Object with the given fields as its keys
|
|
340
340
|
*/
|
|
341
|
-
|
|
341
|
+
let generateRecord = function(fields, options, seed) {
|
|
342
342
|
if(!Array.isArray(fields)) {
|
|
343
343
|
fields = [fields + ""];
|
|
344
344
|
}
|
|
345
|
-
|
|
345
|
+
let config = {};
|
|
346
346
|
if(options != null) {
|
|
347
347
|
if(typeof options === "number") {
|
|
348
348
|
seed = options;
|
|
@@ -351,10 +351,10 @@ var generateRecord = function(fields, options, seed) {
|
|
|
351
351
|
}
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
for(
|
|
357
|
-
|
|
354
|
+
let fieldCount = fields.length;
|
|
355
|
+
let record = {};
|
|
356
|
+
for(let i = 0; i < fieldCount; ++i) {
|
|
357
|
+
let field = fields[i];
|
|
358
358
|
record[field] = _generateFieldData(field, config, seed).value;
|
|
359
359
|
}
|
|
360
360
|
return record;
|
|
@@ -365,17 +365,17 @@ var generateRecord = function(fields, options, seed) {
|
|
|
365
365
|
* @param {(number|DataGenerator~DataOptions)=} options Configuration object or number of rows
|
|
366
366
|
* @return {!Array.<Object>} Array of object with the given fields as its keys
|
|
367
367
|
*/
|
|
368
|
-
|
|
369
|
-
|
|
368
|
+
let generateRecords = function(fields, options) {
|
|
369
|
+
let result = _generate2DArray(fields, options, DataGenerator.seed);
|
|
370
370
|
DataGenerator.seed = result.seed;
|
|
371
371
|
fields = result.fields;
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
for(
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
for(
|
|
378
|
-
|
|
372
|
+
let fieldCount = fields.length;
|
|
373
|
+
let records = result.data;
|
|
374
|
+
for(let i = records.length; --i >= 0;) {
|
|
375
|
+
let ary = records[i];
|
|
376
|
+
let record = {};
|
|
377
|
+
for(let j = 0; j < fieldCount; ++j) {
|
|
378
|
+
let field = fields[j];
|
|
379
379
|
record[field] = ary[j];
|
|
380
380
|
}
|
|
381
381
|
records[i] = record;
|
|
@@ -390,11 +390,11 @@ var generateRecords = function(fields, options) {
|
|
|
390
390
|
* @param {number=} seed
|
|
391
391
|
* @return {!Object} Object with value, formattedValue and other properties
|
|
392
392
|
*/
|
|
393
|
-
|
|
394
|
-
|
|
393
|
+
let generateQuoteData = function(field, options, seed) {
|
|
394
|
+
let fInfo = _generateFieldData(field, options, seed);
|
|
395
395
|
|
|
396
396
|
//formatting
|
|
397
|
-
|
|
397
|
+
let fmtValue = fInfo.value + "";
|
|
398
398
|
if(fInfo.prefix){
|
|
399
399
|
if(typeof fInfo.prefix == "string") {
|
|
400
400
|
fmtValue = fInfo.prefix + fmtValue;
|
|
@@ -419,9 +419,9 @@ var generateQuoteData = function(field, options, seed) {
|
|
|
419
419
|
* @param {number=} seed Default seed for randomization
|
|
420
420
|
* @return {!Object}
|
|
421
421
|
*/
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
422
|
+
let _generate2DArray = function(fields, options, seed) {
|
|
423
|
+
let config = {};
|
|
424
|
+
let numRows = 0;
|
|
425
425
|
if(options) {
|
|
426
426
|
if(typeof options === "number") {
|
|
427
427
|
numRows = config.numRows = options;
|
|
@@ -445,14 +445,14 @@ var _generate2DArray = function(fields, options, seed) {
|
|
|
445
445
|
} else if(!Array.isArray(fields)) {
|
|
446
446
|
fields = [fields + ""];
|
|
447
447
|
}
|
|
448
|
-
|
|
448
|
+
let fieldCount = fields.length;
|
|
449
449
|
|
|
450
|
-
|
|
451
|
-
for(
|
|
452
|
-
|
|
450
|
+
let dataRows = [];
|
|
451
|
+
for(let i = 0; i < numRows; ++i) {
|
|
452
|
+
let row = [];
|
|
453
453
|
// Same field in a single record must be produced to the same value
|
|
454
|
-
for(
|
|
455
|
-
|
|
454
|
+
for(let j = 0; j < fieldCount; ++j) {
|
|
455
|
+
let field = fields[j];
|
|
456
456
|
row.push(_generateFieldData(field, options, seed).value);
|
|
457
457
|
}
|
|
458
458
|
if(seed != null) {
|
|
@@ -472,9 +472,9 @@ var _generate2DArray = function(fields, options, seed) {
|
|
|
472
472
|
* @param {string} str
|
|
473
473
|
* @return {number}
|
|
474
474
|
*/
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
475
|
+
let _hash = function(str) {
|
|
476
|
+
let sum = 0;
|
|
477
|
+
let i = str ? str.length : 0;
|
|
478
478
|
while(--i >= 0) {
|
|
479
479
|
sum += str.charCodeAt(i) * (i + 0.9879);
|
|
480
480
|
}
|
|
@@ -486,8 +486,8 @@ var _hash = function(str) {
|
|
|
486
486
|
* @param {number=} seed
|
|
487
487
|
* @return {!Object} Object with value and other properties
|
|
488
488
|
*/
|
|
489
|
-
|
|
490
|
-
|
|
489
|
+
let _generateFieldData = function(field, options, seed) {
|
|
490
|
+
let fInfo = getFieldInfo(field);
|
|
491
491
|
if(!fInfo.type) {
|
|
492
492
|
fInfo.type = "number";
|
|
493
493
|
addFieldInfo(field, fInfo);
|
|
@@ -503,9 +503,9 @@ var _generateFieldData = function(field, options, seed) {
|
|
|
503
503
|
seed += fInfo.hash; // Make each field unique for the same seed
|
|
504
504
|
}
|
|
505
505
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
506
|
+
let min = fInfo.min != null ? fInfo.min : 100; // WARNING: Default values are non-standard values
|
|
507
|
+
let max = fInfo.max != null ? fInfo.max : 10000;
|
|
508
|
+
let value;
|
|
509
509
|
|
|
510
510
|
if(fInfo.type === "string") {
|
|
511
511
|
if(fInfo.min != null || fInfo.max != null) {
|
|
@@ -522,7 +522,7 @@ var _generateFieldData = function(field, options, seed) {
|
|
|
522
522
|
} else if(fInfo.type === "date") {
|
|
523
523
|
value = randDate(min, max, seed);
|
|
524
524
|
} else if(fInfo.type === "isoDate") {
|
|
525
|
-
|
|
525
|
+
let date = randDate(min, max, seed);
|
|
526
526
|
value = date.toISOString().slice(0, 10);
|
|
527
527
|
} else if(fInfo.type === "isoDateObject") {
|
|
528
528
|
value = randDate(min, max, seed);
|
|
@@ -533,7 +533,7 @@ var _generateFieldData = function(field, options, seed) {
|
|
|
533
533
|
fInfo.field = field;
|
|
534
534
|
value = fInfo.generate(fInfo, seed);
|
|
535
535
|
} else { // Default is number for all unknown type
|
|
536
|
-
|
|
536
|
+
let prec = fInfo.prec != null ? fInfo.prec : 0;
|
|
537
537
|
value = randNumber(min, max, prec, seed);
|
|
538
538
|
}
|
|
539
539
|
fInfo.value = value;
|
|
@@ -544,7 +544,7 @@ var _generateFieldData = function(field, options, seed) {
|
|
|
544
544
|
/** @constructor
|
|
545
545
|
* @param {number=} seed
|
|
546
546
|
*/
|
|
547
|
-
|
|
547
|
+
let DataGenerator = function(seed) {
|
|
548
548
|
this._seed = seed != null ? seed : null;
|
|
549
549
|
};
|
|
550
550
|
|
|
@@ -560,7 +560,7 @@ DataGenerator.prototype._seed = null;
|
|
|
560
560
|
* @return {!Array.<Array>} 2D Array of data
|
|
561
561
|
*/
|
|
562
562
|
DataGenerator.prototype.generate = function(fields, options) {
|
|
563
|
-
|
|
563
|
+
let result = _generate2DArray(fields, options, this._seed);
|
|
564
564
|
this._seed = result.seed;
|
|
565
565
|
|
|
566
566
|
return result.data;
|
|
@@ -572,16 +572,16 @@ DataGenerator.prototype.generate = function(fields, options) {
|
|
|
572
572
|
* @return {!Array.<Object>} Array of data object
|
|
573
573
|
*/
|
|
574
574
|
DataGenerator.prototype.generateRecords = function(fields, options) {
|
|
575
|
-
|
|
575
|
+
let result = _generate2DArray(fields, options, this._seed);
|
|
576
576
|
this._seed = result.seed;
|
|
577
577
|
fields = result.fields;
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
for(
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
for(
|
|
584
|
-
|
|
578
|
+
let fieldCount = fields.length;
|
|
579
|
+
let records = result.data;
|
|
580
|
+
for(let i = records.length; --i >= 0;) {
|
|
581
|
+
let ary = records[i];
|
|
582
|
+
let record = {};
|
|
583
|
+
for(let j = 0; j < fieldCount; ++j) {
|
|
584
|
+
let field = fields[j];
|
|
585
585
|
record[field] = ary[j];
|
|
586
586
|
}
|
|
587
587
|
records[i] = record;
|
|
@@ -595,7 +595,7 @@ DataGenerator.prototype.generateRecords = function(fields, options) {
|
|
|
595
595
|
* @return {!Object} Object with value, formattedValue and other properties
|
|
596
596
|
*/
|
|
597
597
|
DataGenerator.prototype.generateQuoteData = function(field, options) {
|
|
598
|
-
|
|
598
|
+
let fInfo = generateQuoteData(field, options, this._seed);
|
|
599
599
|
if(this._seed != null) {
|
|
600
600
|
++this._seed;
|
|
601
601
|
}
|
|
@@ -624,7 +624,7 @@ DataGenerator.prototype.setSeed = function(seed) {
|
|
|
624
624
|
* @return {number}
|
|
625
625
|
*/
|
|
626
626
|
DataGenerator.prototype.randBetween = function(min, max) {
|
|
627
|
-
|
|
627
|
+
let result = randBetween(min, max, this._seed);
|
|
628
628
|
if(this._seed != null) {
|
|
629
629
|
++this._seed;
|
|
630
630
|
}
|
|
@@ -637,7 +637,7 @@ DataGenerator.prototype.randBetween = function(min, max) {
|
|
|
637
637
|
* @return {number}
|
|
638
638
|
*/
|
|
639
639
|
DataGenerator.prototype.randInt = function(min, max) {
|
|
640
|
-
|
|
640
|
+
let result = randInt(min, max, this._seed);
|
|
641
641
|
if(this._seed != null) {
|
|
642
642
|
++this._seed;
|
|
643
643
|
}
|
|
@@ -649,7 +649,7 @@ DataGenerator.prototype.randInt = function(min, max) {
|
|
|
649
649
|
* @return {number}
|
|
650
650
|
*/
|
|
651
651
|
DataGenerator.prototype.randIndex = function(max) {
|
|
652
|
-
|
|
652
|
+
let result = randIndex(max, this._seed);
|
|
653
653
|
if(this._seed != null) {
|
|
654
654
|
++this._seed;
|
|
655
655
|
}
|
|
@@ -663,7 +663,7 @@ DataGenerator.prototype.randIndex = function(max) {
|
|
|
663
663
|
* @return {number}
|
|
664
664
|
*/
|
|
665
665
|
DataGenerator.prototype.randNumber = function(min, max, prec) {
|
|
666
|
-
|
|
666
|
+
let result = randNumber(min, max, prec, this._seed);
|
|
667
667
|
if(this._seed != null) {
|
|
668
668
|
++this._seed;
|
|
669
669
|
}
|
|
@@ -674,7 +674,7 @@ DataGenerator.prototype.randNumber = function(min, max, prec) {
|
|
|
674
674
|
* @return {boolean}
|
|
675
675
|
*/
|
|
676
676
|
DataGenerator.prototype.randBoolean = function() {
|
|
677
|
-
|
|
677
|
+
let result = randBoolean(this._seed);
|
|
678
678
|
if(this._seed != null) {
|
|
679
679
|
++this._seed;
|
|
680
680
|
}
|
|
@@ -686,7 +686,7 @@ DataGenerator.prototype.randBoolean = function() {
|
|
|
686
686
|
* @return {*}
|
|
687
687
|
*/
|
|
688
688
|
DataGenerator.prototype.randMember = function(set) {
|
|
689
|
-
|
|
689
|
+
let result = randMember(set, this._seed);
|
|
690
690
|
if(this._seed != null) {
|
|
691
691
|
++this._seed;
|
|
692
692
|
}
|
|
@@ -699,7 +699,7 @@ DataGenerator.prototype.randMember = function(set) {
|
|
|
699
699
|
* @return {Date}
|
|
700
700
|
*/
|
|
701
701
|
DataGenerator.prototype.randDate = function(min, max) {
|
|
702
|
-
|
|
702
|
+
let result = randDate(min, max, this._seed);
|
|
703
703
|
if(this._seed != null) {
|
|
704
704
|
++this._seed;
|
|
705
705
|
}
|
|
@@ -712,7 +712,7 @@ DataGenerator.prototype.randDate = function(min, max) {
|
|
|
712
712
|
* @return {string}
|
|
713
713
|
*/
|
|
714
714
|
DataGenerator.prototype.randString = function(min, max) {
|
|
715
|
-
|
|
715
|
+
let result = randString(min, max, this._seed);
|
|
716
716
|
if(this._seed != null) {
|
|
717
717
|
++this._seed;
|
|
718
718
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @constructor */
|
|
2
|
-
|
|
2
|
+
let MockArchive = function() {
|
|
3
3
|
this._data = {};
|
|
4
4
|
};
|
|
5
5
|
/** @type {!Object}
|
|
@@ -23,7 +23,7 @@ MockArchive.prototype.put = function(key, val) {
|
|
|
23
23
|
* @return {*}
|
|
24
24
|
*/
|
|
25
25
|
MockArchive.prototype.get = function(key) {
|
|
26
|
-
|
|
26
|
+
let val = this._data[key];
|
|
27
27
|
return (val != null) ? val : "";
|
|
28
28
|
};
|
|
29
29
|
|
|
@@ -41,10 +41,10 @@ MockArchive.prototype.save = function() {
|
|
|
41
41
|
* @return {!Array}
|
|
42
42
|
*/
|
|
43
43
|
MockArchive.prototype.filter = function(func) {
|
|
44
|
-
|
|
44
|
+
let out_ary = [];
|
|
45
45
|
if(func) {
|
|
46
|
-
for(
|
|
47
|
-
|
|
46
|
+
for(let key in this._data) {
|
|
47
|
+
let val = this._data[key];
|
|
48
48
|
if(func(val)) {
|
|
49
49
|
out_ary.push(val);
|
|
50
50
|
}
|
|
@@ -6,7 +6,7 @@ import {mockDataAPI} from "./mockDataAPI.js";
|
|
|
6
6
|
/** @constructor
|
|
7
7
|
* @param {Object=} options
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
let MockJET = function(options) {
|
|
10
10
|
this["Quotes"] = new MockQuotes();
|
|
11
11
|
this["Quotes2"] = new MockQuotes2();
|
|
12
12
|
this["Archive"] = new MockArchive();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { randIndex, generateQuoteData } from "./DataGenerator.js";
|
|
2
2
|
|
|
3
3
|
/** @constructor */
|
|
4
|
-
|
|
4
|
+
let MockQuotes = function() {
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
/** @public
|
|
@@ -16,7 +16,7 @@ MockQuotes.prototype.create = function(opt_id) {
|
|
|
16
16
|
/** @constructor
|
|
17
17
|
* @param {string=} opt_id
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
let MockSubscription = function(opt_id) {
|
|
20
20
|
this._onRowUpdated = this._onRowUpdated.bind(this);
|
|
21
21
|
|
|
22
22
|
this._fieldMap = {};
|
|
@@ -73,7 +73,7 @@ MockSubscription._runningId = 0;
|
|
|
73
73
|
* @return {MockSubscription}
|
|
74
74
|
*/
|
|
75
75
|
MockSubscription.prototype.formattedFields = function(fields) {
|
|
76
|
-
for(
|
|
76
|
+
for(let i = fields.length; --i >= 0;){
|
|
77
77
|
this._fieldMap[fields[i]] = true;
|
|
78
78
|
}
|
|
79
79
|
return this;
|
|
@@ -83,7 +83,7 @@ MockSubscription.prototype.formattedFields = function(fields) {
|
|
|
83
83
|
* @return {MockSubscription}
|
|
84
84
|
*/
|
|
85
85
|
MockSubscription.prototype.rawFields = function(fields) {
|
|
86
|
-
for(
|
|
86
|
+
for(let i = fields.length; --i >= 0;){
|
|
87
87
|
this._fieldMap[fields[i]] = true;
|
|
88
88
|
}
|
|
89
89
|
return this;
|
|
@@ -155,13 +155,13 @@ MockSubscription.prototype._onRowUpdated = function() {
|
|
|
155
155
|
return;
|
|
156
156
|
}
|
|
157
157
|
//TODO: random which fields to be updated
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
let len = this._rics ? this._rics.length : 0;
|
|
159
|
+
let ric;
|
|
160
160
|
if(len === 1) {
|
|
161
161
|
ric = this._rics[0];
|
|
162
162
|
this._updateHandler(this, ric, this._getUpdateData(ric));
|
|
163
163
|
} else {
|
|
164
|
-
for(
|
|
164
|
+
for(let i = 0; i < len; ++i) {
|
|
165
165
|
if(!randIndex(3)) {
|
|
166
166
|
ric = this._rics[i];
|
|
167
167
|
this._updateHandler(this, ric, this._getUpdateData(ric));
|
|
@@ -178,12 +178,12 @@ MockSubscription.prototype._onRowUpdated = function() {
|
|
|
178
178
|
* @return {Object}
|
|
179
179
|
*/
|
|
180
180
|
MockSubscription.prototype._getUpdateData = function(ric) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
for(
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
181
|
+
let data = {"id": this["id"]};
|
|
182
|
+
let options = {"text": ric};
|
|
183
|
+
for(let field in this._fieldMap) {
|
|
184
|
+
let fInfo = generateQuoteData(field, options);
|
|
185
|
+
let v = fInfo.value;
|
|
186
|
+
let fv = fInfo.formattedValue;
|
|
187
187
|
if(fInfo.changeOnly) {
|
|
188
188
|
if(this._prevData[field] === v) {
|
|
189
189
|
continue;
|