@millistream/millistream-widgets 1.0.29 → 1.0.31

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.
@@ -2962,7 +2962,7 @@ function Milli_Chart(settings) {
2962
2962
  // Compare functions
2963
2963
  _this.removeAllCompares = function() {
2964
2964
  if (_this.instruments.length == 1) return;
2965
- for (var i = 0; i < 3; i++)
2965
+ for (var i = 1; i < 3; i++)
2966
2966
  _this.instruments[i] = { insref: 0 };
2967
2967
  };
2968
2968
 
@@ -3477,7 +3477,10 @@ function Milli_OptionsList(settings) {
3477
3477
  custom_columns: {},
3478
3478
  sortorder: 'asc',
3479
3479
  strikedateHeader: true,
3480
- hidePuts: false
3480
+ hidePuts: false,
3481
+ mirror_custom_columns: true,
3482
+ header_on_strike: true
3483
+
3481
3484
  };
3482
3485
  MillistreamWidgetApi_AssignObject(MillistreamWidgetSettings, _this.settings);
3483
3486
 
@@ -3493,8 +3496,8 @@ function Milli_OptionsList(settings) {
3493
3496
  let m_strikes = [];
3494
3497
  let m_strikedates = [];
3495
3498
  let m_strikepricedecimals = 2;
3496
- let m_strikeprices = [];
3497
-
3499
+ let m_strikeprices = [];
3500
+
3498
3501
  let m_lang_en = {
3499
3502
  askprice: 'Ask',
3500
3503
  bidprice: 'Bid',
@@ -3708,6 +3711,7 @@ function Milli_OptionsList(settings) {
3708
3711
  let pos = 0;
3709
3712
  let newinsrefs = [];
3710
3713
  let s, h1, h2, i;
3714
+ let firstHeader = true;
3711
3715
  for (i = 0; i < m_strikes.length; i++) {
3712
3716
  if (m_strikes[i].strikedate != strikedate) {
3713
3717
  if (_this.settings.strikedateHeader) {
@@ -3724,8 +3728,14 @@ function Milli_OptionsList(settings) {
3724
3728
  }
3725
3729
  } else {
3726
3730
  if (_this.settings.strikedateHeader) {
3727
- h1.style.display = 'table-row';
3728
- h2.style.display = 'table-row';
3731
+ if(firstHeader || _this.settings.header_on_strike == true) {
3732
+ firstHeader = false;
3733
+ h1.style.display = 'table-row';
3734
+ h2.style.display = 'table-row';
3735
+ } else {
3736
+ h1.style.display = 'none';
3737
+ h2.style.display = 'none';
3738
+ }
3729
3739
  }
3730
3740
  for (s = pos; s < i; s++) {
3731
3741
  m_strikes[s].row.style.display = 'table-row';
@@ -3754,8 +3764,11 @@ function Milli_OptionsList(settings) {
3754
3764
  continue;
3755
3765
  } else {
3756
3766
  if (_this.settings.strikedateHeader) {
3757
- h1.style.display = 'table-row';
3758
- h2.style.display = 'table-row';
3767
+ if(firstHeader || _this.settings.header_on_strike == true) { // new
3768
+ firstHeader = false;
3769
+ h1.style.display = 'table-row';
3770
+ h2.style.display = 'table-row';
3771
+ }
3759
3772
  }
3760
3773
  }
3761
3774
  m_strikes[s].row.style.display = 'table-row';
@@ -3817,7 +3830,7 @@ function Milli_OptionsList(settings) {
3817
3830
  let display = '';
3818
3831
  let tr, th;
3819
3832
  if (_this.settings.strikedateHeader) {
3820
- tr = MillistreamWidgetApi_addElement(_this, 'tr', null, tbody);
3833
+ tr = MillistreamWidgetApi_addElement(_this, 'tr', "millistream-optionslist-header-strikedate", tbody);
3821
3834
  tr.setAttribute('data-strikedate', m_strikedates[s].strikedate);
3822
3835
  if (_this.settings.strikedatefilter.length != 0 && _this.settings.strikedatefilter.indexOf(m_strikedates[s].strikedate) == -1) {
3823
3836
  tr.style.display = 'none';
@@ -3901,20 +3914,40 @@ function Milli_OptionsList(settings) {
3901
3914
  info = MillistreamWidgetApi_getColumnInfo(_this, _this.settings.fields[i]);
3902
3915
  MillistreamWidgetApi_addElement(_this, 'th', 'millistream-optionslist-table-th millistream-' + info[1] + ' millistream-' + _this.settings.fields[i], tr, null, info[3]);
3903
3916
  }
3904
- for (cpos in _this.settings.custom_columns) {
3905
- if (cpos == i + 1) {
3917
+ let keys = Object.keys(_this.settings.custom_columns);
3918
+ for(let s = 0; s < keys.length; s++) {
3919
+ if(keys[s] == i + 1) {
3920
+ let cpos;
3921
+ if(_this.settings.mirror_custom_columns == false) cpos = keys[keys.length - s-1];
3922
+ else cpos = keys[s];
3906
3923
  MillistreamWidgetApi_addElement(_this, 'th', 'millistream-optionslist-table-th', tr, null, _this.settings.custom_columns[cpos].name);
3907
3924
  added_columns++;
3908
3925
  }
3909
3926
  }
3927
+ /*for (cpos in _this.settings.custom_columns) {
3928
+ if (cpos == i + 1) {
3929
+ MillistreamWidgetApi_addElement(_this, 'th', 'millistream-optionslist-table-th', tr, null, _this.settings.custom_columns[cpos].name);
3930
+ added_columns++;
3931
+ }
3932
+ }*/
3910
3933
  added_columns++;
3911
3934
  }
3912
- for (cpos in _this.settings.custom_columns) {
3913
- if (cpos == i + 1) {
3935
+ let keys = Object.keys(_this.settings.custom_columns);
3936
+ for(let s = 0; s < keys.length; s++) {
3937
+ if(keys[s] == i + 1) {
3938
+ let cpos;
3939
+ if(_this.settings.mirror_custom_columns == false) cpos = keys[keys.length - s-1];
3940
+ else cpos = keys[s];
3914
3941
  MillistreamWidgetApi_addElement(_this, 'th', 'millistream-optionslist-table-th', tr, null, _this.settings.custom_columns[cpos].name);
3915
3942
  added_columns++;
3916
3943
  }
3917
3944
  }
3945
+ /*for (cpos in _this.settings.custom_columns) {
3946
+ if (cpos == i + 1) {
3947
+ MillistreamWidgetApi_addElement(_this, 'th', 'millistream-optionslist-table-th', tr, null, _this.settings.custom_columns[cpos].name);
3948
+ added_columns++;
3949
+ }
3950
+ }*/
3918
3951
  }
3919
3952
  let numcalls = 0;
3920
3953
  let numputs = 0;
@@ -4018,8 +4051,12 @@ function Milli_OptionsList(settings) {
4018
4051
  };
4019
4052
  m_cellMap.set(cellMap.insref + ':' + info[0], cellMap);
4020
4053
  }
4021
- for (cpos in _this.settings.custom_columns) {
4022
- if (cpos == x + 1) {
4054
+ let keys = Object.keys(_this.settings.custom_columns);
4055
+ for(let s = 0; s < keys.length; s++) {
4056
+ if(keys[s] == x + 1) {
4057
+ let cpos;
4058
+ if(_this.settings.mirror_custom_columns == false) cpos = keys[keys.length - s-1];
4059
+ else cpos = keys[s];
4023
4060
  td = MillistreamWidgetApi_addTableCell2(_this, null, 'millistream-optionslist-put-cell', otr);
4024
4061
  if (m_strikes[i].puts && (typeof _this.settings.custom_columns[cpos].condition !== 'function' || _this.settings.custom_columns[cpos].condition(m_strikes[i].puts))) {
4025
4062
  if (_this.settings.custom_columns[cpos].instruments && -1 != _this.settings.custom_columns[cpos].instruments.indexOf(m_strikes[i].insref)) {
@@ -4029,11 +4066,15 @@ function Milli_OptionsList(settings) {
4029
4066
  }
4030
4067
  }
4031
4068
  added_columns++;
4032
- }
4069
+ }
4033
4070
  }
4034
4071
  }
4035
- for (cpos in _this.settings.custom_columns) {
4036
- if (cpos == x + 1) {
4072
+ let keys = Object.keys(_this.settings.custom_columns);
4073
+ for(let s = 0; s < keys.length; s++) {
4074
+ if(keys[s] == x + 1) {
4075
+ let cpos;
4076
+ if(_this.settings.mirror_custom_columns == false) cpos = keys[keys.length - s-1];
4077
+ else cpos = keys[s];
4037
4078
  td = MillistreamWidgetApi_addTableCell2(_this, null, 'millistream-optionslist-put-cell', otr);
4038
4079
  if (m_strikes[i].puts && (typeof _this.settings.custom_columns[cpos].condition !== 'function' || _this.settings.custom_columns[cpos].condition(m_strikes[i].puts))) {
4039
4080
  if (_this.settings.custom_columns[cpos].instruments && -1 != _this.settings.custom_columns[cpos].instruments.indexOf(m_strikes[i].insref)) {
@@ -4043,14 +4084,13 @@ function Milli_OptionsList(settings) {
4043
4084
  }
4044
4085
  }
4045
4086
  added_columns++;
4046
- }
4087
+ }
4047
4088
  }
4048
4089
  }
4049
4090
  } else break;
4050
4091
  }
4051
4092
  if (_this.settings.strikedateHeader) {
4052
4093
  callheader.innerHTML = _this.get_lang_text('calls') + ' · ' + m_strikedates[s].strikedate + ' ' + (m_strikedates[s].expirationtype == '2' ? _this.get_lang_text('weeklytype') : ' ') + ' · ' + m_strikedates[s].dte + ' ' + _this.get_lang_text('dte') + ' · ' + numcalls + ' strikes';
4053
- console.log(callheader.innerHTML);
4054
4094
  callheader.colSpan = _this.settings.fields.length + 1 + Object.keys(_this.settings.custom_columns).length;
4055
4095
  putheader.innerHTML = _this.get_lang_text('puts') + ' · ' + m_strikedates[s].strikedate + ' ' + (m_strikedates[s].expirationtype == '2' ? _this.get_lang_text('weeklytype') : ' ') + ' · ' + m_strikedates[s].dte + ' ' + _this.get_lang_text('dte') + ' · ' + numputs + ' strikes';
4056
4096
  putheader.colSpan = _this.settings.fields.length + Object.keys(_this.settings.custom_columns).length;
@@ -4062,6 +4102,18 @@ function Milli_OptionsList(settings) {
4062
4102
  if (_this.settings.onreadyCallback) _this.settings.onreadyCallback();
4063
4103
  }
4064
4104
 
4105
+ function getXhrJson(url) {
4106
+ var req = new XMLHttpRequest();
4107
+ req.onload = function() {
4108
+ buildlist(JSON.parse(this.responseText));
4109
+ };
4110
+ req.open("GET", url, true);
4111
+ req.onerror = function(error) {
4112
+ console.log('Fetch data error', error);
4113
+ };
4114
+ req.send();
4115
+ }
4116
+
4065
4117
 
4066
4118
  _this.drawWidget = function() {
4067
4119
 
@@ -4078,9 +4130,13 @@ function Milli_OptionsList(settings) {
4078
4130
  m_cellMap = new Map();
4079
4131
 
4080
4132
  let url = MillistreamWidgetApi_buildQuery(_this, 'optionslist');
4081
- millistream_data_api.fetch(url, function(data) {
4082
- buildlist(data);
4083
- });
4133
+ if (_this.settings.xhr) {
4134
+ getXhrJson(url);
4135
+ } else {
4136
+ millistream_data_api.fetch(url, function(data) {
4137
+ buildlist(data);
4138
+ });
4139
+ }
4084
4140
  };
4085
4141
  if (this.settings.autodraw == true) this.drawWidget();
4086
4142
 
@@ -4427,7 +4483,12 @@ function MillistreamWidgetApi_buildQuery(widget, type) {
4427
4483
  if (typeof widget.settings.xhr !== 'undefined' && widget.settings.xhr == true) {
4428
4484
  url += '&xhr=1';
4429
4485
  }
4430
- console.log(url);
4486
+ if (typeof widget.settings.blacklists !== 'undefined' && widget.settings.blacklist != 0) {
4487
+ url += '&blacklist=1';
4488
+ }
4489
+ if (typeof widget.settings.tradecode === 'number') {
4490
+ url += '&tradecode=' + widget.settings.tradecode;
4491
+ }
4431
4492
  return url;
4432
4493
  }
4433
4494
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@millistream/millistream-widgets",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "description": "Millistream widgets node package",
5
5
  "main": "millistream-widgets.js",
6
6
  "scripts": {