diff --git a/src/common/rivetsExtra.es6 b/src/common/rivetsExtra.es6 index 1e17043177..4b0a0ec18c 100644 --- a/src/common/rivetsExtra.es6 +++ b/src/common/rivetsExtra.es6 @@ -7,6 +7,8 @@ import 'jquery-sparkline'; import 'chosen'; import 'color-picker'; +const hasValue = value => value === 0 ? true : Boolean(value); + /* Rivets js does not allow manually observing properties from javascript, Use "rv.bind().observe('path.to.object', callback)" to subscribe */ rivets._.View.prototype.observe = function (keypath, callback) { @@ -24,7 +26,7 @@ rivets._.View.prototype.observe = function (keypath, callback) { /* rivets formatter to translate strings to 18n */ rv.formatters['i18n'] = (value) => { - if(typeof value === 'string') return value.i18n(); + if (typeof value === 'string') return value.i18n(); return value; }; rv.formatters['sanitize'] = (value) => value.replace(/("|'|\&|\(|\)|\<|\>)/g, ''); @@ -36,7 +38,7 @@ rv.formatters['prop'] = (value, prop) => { rv.formatters['one-of'] = (...args) => { const value = args[0]; for (let i = 1; i < args.length ; ++i) - if(args[i] === value) + if (args[i] === value) return true; return false; } @@ -60,10 +62,12 @@ rv.formatters['and-not'] = (vlaue, other) => vlaue && !other; rv.formatters['gt'] = (vlaue, other) => vlaue > other; /* rivets formatter for < operator */ rv.formatters['lt'] = (vlaue, other) => vlaue < other; +/* rivets formatter to check if a variable has value */ +rv.formatters['has-value'] = hasValue; /* localise price format*/ -rv.formatters['format-price'] = (value, currency) => (value) ? formatPrice(value, currency) : undefined; +rv.formatters['format-price'] = (value, currency) => hasValue(value) ? formatPrice(value, currency) : undefined; /* comma added format*/ -rv.formatters['add-comma'] = (value, decimal_points) => (value) ? addComma(value, decimal_points) : undefined; +rv.formatters['add-comma'] = (value, decimal_points) => value ? addComma(value, decimal_points) : undefined; /* rivets formater to capitalize string */ rv.formatters.capitalize = { read: (value) => _.capitalize(value), @@ -71,7 +75,7 @@ rv.formatters.capitalize = { }; /* call toFixed on a fload number */ rv.formatters['to-fixed'] = (value, digits) => { - if(!$.isNumeric(value) || !$.isNumeric(digits)){ + if (!$.isNumeric(value) || !$.isNumeric(digits)){ return; } return (value * 1).toFixed(digits || 2); @@ -109,7 +113,7 @@ rv.formatters.currency = (value, currency) => { 'PYG': '₲', /* Paraguayan Guarani */ 'THB': '฿', /* Thai Baht */ 'UAH': '₴', /* Ukrainian Hryvnia */ 'VND': '₫', /* Vietnamese Dong */ }; - if(value) + if (value) return (currency_symbols[currency] || currency) + value; return value; } @@ -126,7 +130,7 @@ rv.formatters['moment'] = (epoch, format) => { } /* human readable difference of two epoch values */ rv.formatters['moment-humanize'] = (from_epoch, till_epoch) => { - if(!from_epoch || !till_epoch) { + if (!from_epoch || !till_epoch) { return undefined; } @@ -151,7 +155,7 @@ rv.formatters['bold-last-character'] = (str) => { } /* formatter to calcualte the percent of a value of another value */ rv.formatters['percent-of'] = (changed, original) => { - if(!changed || !original) return undefined; + if (!(changed != null) || !original) return undefined; const percentage_of_amount = (100*(changed - original)/original).toFixed(2); if (percentage_of_amount > 0) { return `+${percentage_of_amount}%`; @@ -191,7 +195,7 @@ rv.binders.selectmenu = { routine: (el, value) => { el = $(el); el.val(value); - if(el.find("option[value='" + value + "']").length > 0) + if (el.find("option[value='" + value + "']").length > 0) el.selectmenu('refresh'); } }; @@ -219,7 +223,7 @@ rv.binders['is-valid-number'] = { /* bindar for jqueyr ui selectmenu options */ rv.binders['dom-*'] = function (el, value) { const method = this.args[0]; - if(value) + if (value) setTimeout(() => el[method](), 0); }; @@ -238,9 +242,9 @@ rv.binders.selectrefresh = { priority: 99, routine: (el,array_or_value) => { el = $(el); - if(typeof array_or_value === 'string') { + if (typeof array_or_value === 'string') { el.val(array_or_value); - if(el.find("option[value='" + array_or_value+ "']").length === 0) + if (el.find("option[value='" + array_or_value+ "']").length === 0) return; } el.selectmenu('refresh'); @@ -275,7 +279,7 @@ rv.binders.chosendisable = (el, value) => { const inputElement = chosenContainer.find('.chosen-choices input'); const chosenDrop = chosenContainer.find('.chosen-drop'); const chosenDisableElement = chosenContainer.find('.webtrader-chosen-disable'); - if(value) { + if (value) { inputElement.attr('disabled', value); chosenDrop.hide(); chosenDisableElement.addClass('chosen-disable'); @@ -343,7 +347,7 @@ rv.binders['input-enter'] = { publishes: false, routine: (el, callback) => { $(el).keyup(function(event){ - if(event.keyCode == 13){ + if (event.keyCode == 13){ callback(el); } }); @@ -460,7 +464,7 @@ rv.binders.datepicker = { closeText: 'Done'.i18n(), currentText: 'Today'.i18n() }; - if(model.yearRange) + if (model.yearRange) options.yearRange = model.yearRange; else { options.maxDate = model.maxDate || null; @@ -535,7 +539,7 @@ rv.binders['jq-class'] = { /* rv binder to active click event on another button when Enter key is pressed */ rv.binders['input-default-btn'] = (el, jquery_selector) => { $(el).keyup((event) => { - if(event.keyCode == 13) { + if (event.keyCode == 13) { $(jquery_selector).click(); } }); @@ -577,7 +581,7 @@ rv.binders['visible'] = (el, value) => { }; /* binder to add or remove disabled attribute */ rv.binders.disabled = (el,value) => { - if(value) $(el).attr('disabled', 'disabled'); + if (value) $(el).attr('disabled', 'disabled'); else $(el).removeAttr('disabled'); } @@ -689,10 +693,10 @@ rv.binders['indicative-color'] = (el, value) => { const red = '#d71818'; const green = '#02920e'; const black = 'black'; - if(!$.isNumeric(value)) { + if (!$.isNumeric(value)) { $(el).css({color: black}); } - else if(perv !== value*1) { + else if (perv !== value*1) { $(el).css({color: perv < value*1 ? green : red}); } el._perv_indicative_color = value; @@ -706,7 +710,7 @@ const component_twoway_bind = (self, data, keypathes) => { const keypath = keypathes[i]; const key = _.last(keypath.split('.')); const observer = self.observers[key]; - if(observer) { + if (observer) { observer.options.adapters['.'].observe(observer.target, _.last(observer.keypath.split('.')), () => { const updated = observer.target[_.last(observer.keypath.split('.'))]; data[key] = updated; diff --git a/src/common/util.js b/src/common/util.js index 6490976733..3e437abcaf 100755 --- a/src/common/util.js +++ b/src/common/util.js @@ -131,6 +131,21 @@ function addComma(num, decimal_points, is_crypto) { }); }; +function getSymbolPipValue(symbol) { + var active_symbols = local_storage.get('active_symbols'); + var pip_value = 4; + var selected_symbol = active_symbols.find(function(item) { + return item.symbol === symbol; + }); + + if (selected_symbol) { + var symbol_pip = selected_symbol.pip.toString(); + pip_value = symbol_pip.substring(symbol_pip.indexOf(".") + 1).length; + } + + return pip_value; +}; + function sortAlphaNum(property) { "use strict"; var reA = /[^a-zA-Z]/g; diff --git a/src/statement/statement.es6 b/src/statement/statement.es6 index c9560ce194..fb192e28d0 100644 --- a/src/statement/statement.es6 +++ b/src/statement/statement.es6 @@ -30,6 +30,7 @@ export const init = ($menuLink) => { let loading = false; let is_specific_date_shown = false; /* is data for a specific date is shown */ +let scroll_end_reached = false; const refreshTable = (yyy_mm_dd) => { const processing_msg = $('#' + table.attr('id') + '_processing').css('top','200px').show(); @@ -79,6 +80,7 @@ const refreshTable = (yyy_mm_dd) => { table.api().rows.add(rows); table.api().draw(); loading = false; + if (data.statement.count === 0) scroll_end_reached = true; processing_msg.hide(); }; @@ -97,6 +99,7 @@ const refreshTable = (yyy_mm_dd) => { } const initStatement = () => { + scroll_end_reached = false; statement = windows.createBlankWindow($('
'), { title: 'Statement'.i18n(), dialogClass: 'statement', @@ -173,7 +176,7 @@ const initStatement = () => { innerHeight = statement.innerHeight(), scrollHeight = statement[0].scrollHeight, postion = (scrollTop + innerHeight) / scrollHeight; - if(postion > 0.75 && !loading && !is_specific_date_shown){ + if(postion > 0.75 && !loading && !is_specific_date_shown && !scroll_end_reached){ refreshTable({clear:false}); } }); diff --git a/src/trade/tradeDialog.es6 b/src/trade/tradeDialog.es6 index 137055478c..698ba1398a 100644 --- a/src/trade/tradeDialog.es6 +++ b/src/trade/tradeDialog.es6 @@ -399,7 +399,7 @@ function init_state(available,root, dialog, symbol, contracts_for_spot) { multiplier: "0", error: '', loading: true, /* the proposal request state */ - + pip: getSymbolPipValue(symbol.symbol), /* computed properties */ netprofit_: function () { const {contract_type} = state.category_displays.selected; diff --git a/src/trade/tradeDialog.html b/src/trade/tradeDialog.html index bde19edfea..bccca0ada7 100644 --- a/src/trade/tradeDialog.html +++ b/src/trade/tradeDialog.html @@ -15,7 +15,7 @@ rv-show='template.visible'>Entry Spot
Current Spot
- +Exit Spot
- +Close
- +Multiplier
@@ -95,7 +95,7 @@Final Price
Entry Spot
Exit spotExit Spot
+ rv-text="proposal_open_contract.exit_tick | add-comma proposal_open_contract.pip | or '-'" + rv-class-dotted-underline="proposal_open_contract.exit_tick | add-comma proposal_open_contract.pip">Current Level