if (!need4Decimals) var need4Decimals = []; if (!Array.prototype.indexOf) { Array.prototype.indexOf = function(obj, start) { for (var i = (start || 0), j = this.length; i < j; i++) { if (this[i] === obj) { return i; } } return -1; }; } var pushFilter = function (data) { data.price = push.util.formatNum(data.price, 2, '', ',', '.'); data.performance = push.util.formatNum(data.performance, 2, true, ',', '.'); data.performance_pct = push.util.formatNum(data.performance_pct, 2, true, ',', '.'); //data.performance_pct = push.util.formatNum(data.performance_pct, 2, true, ',', '.'); //Fecha var dato = data.date_price; var dateDiv = dato.split(' '); var date = dateDiv[0].split('-'); var time = dateDiv[1].split(':'); var fecha = new Date(date[0], (date[1] - 1), date[2], time[0], time[1], time[2]); var ano = fecha.getFullYear(); var mes = ((fecha.getMonth()+1) < 10) ? '0'+(fecha.getMonth()+1) : fecha.getMonth()+1; var dia = (fecha.getDate() < 10) ? '0'+fecha.getDate() : fecha.getDate(); var hora = fecha.getHours() + push.time.gmt; hora = (hora < 10) ? '0'+hora : hora; var minuto = (fecha.getMinutes() < 10) ? '0'+fecha.getMinutes() : fecha.getMinutes(); var segundo = (fecha.getSeconds() < 10) ? '0'+fecha.getSeconds() : fecha.getSeconds(); var totalFecha = dia+'/'+mes+'/'+ano+' '+hora+':'+minuto+':'+segundo; $('#timeUltimaActu').html(hora+':'+minuto+':'+segundo); $('#dateUltimaActu').html(dia+'/'+mes+'/'+ano); return data; }; var pushNormalFilter = function (data) { var _decimal = 2; var _money = Math.floor(data.total_money) / 1000000; data.total_money = push.util.formatNum(_money, 2, false, ',', '.'); data.price = push.util.formatNum(data.price, _decimal, '', ',', '.'); data.high = push.util.formatNum(data.high, _decimal, '', ',', '.'); data.low = push.util.formatNum(data.low, _decimal, '', ',', '.'); data.performance = push.util.formatNum(data.performance, _decimal, true, ',', '.'); data.performance_pct = push.util.formatNum(data.performance_pct, _decimal, true, ',', '.'); return data; }; var pushNormalFilterconstituents = function (data) { var _decimal = 2; var _money = Math.floor(data.total_money) / 1000000; data.total_money = push.util.formatNum(_money, 2, false, ',', '.'); data.price = push.util.formatNum(data.price, _decimal, '', ',', '.'); data.high = push.util.formatNum(data.high, _decimal, '', ',', '.'); data.low = push.util.formatNum(data.low, _decimal, '', ',', '.'); data.performance = push.util.formatNum(data.performance, _decimal, true, ',', '.'); data.performance_pct = push.util.formatNum(data.performance_pct, _decimal, true, ',', '.')+'%'; //Fecha var dato = data.date_price; var dateDiv = dato.split(' '); var date = dateDiv[0].split('-'); var time = dateDiv[1].split(':'); var fecha = new Date(date[0], (date[1] - 1), date[2], time[0], time[1], time[2]); var ano = fecha.getFullYear(); var mes = ((fecha.getMonth()+1) < 10) ? '0'+(fecha.getMonth()+1) : fecha.getMonth()+1; var dia = (fecha.getDate() < 10) ? '0'+fecha.getDate() : fecha.getDate(); var hora = fecha.getHours() + push.time.gmt; hora = (hora < 10) ? '0'+hora : hora; var minuto = (fecha.getMinutes() < 10) ? '0'+fecha.getMinutes() : fecha.getMinutes(); var segundo = (fecha.getSeconds() < 10) ? '0'+fecha.getSeconds() : fecha.getSeconds(); var totalFecha = dia+'/'+mes+'/'+ano+' '+hora+':'+minuto+':'+segundo; $('#timeUltimaActuMap_' + parseInt(data.id_notation)).html(hora+':'+minuto); $('#dateUltimaActuMap_' + parseInt(data.id_notation)).html(dia+'/'+mes+'/'+ano); return data; }; var pushFilterCurrencies = function (data) { var _decimal = 2; if (data.id_notation == 2 || data.id_notation == 210 || data.id_notation == 231){ data.price = push.util.formatNum(data.price, _decimal, '', ',', '.'); data.performance = push.util.formatNum(data.performance, _decimal, true, ',', '.'); data.performance_pct = push.util.formatNum(data.performance_pct, _decimal, true, ',', '.'); }else{ data.price = push.util.formatNum(data.price, 4, '', ',', '.'); data.performance = push.util.formatNum(data.performance, 2, true, ',', '.'); data.performance_pct = push.util.formatNum(data.performance_pct, 2, true, ',', '.'); } // if (fourthDecimals.indexOf( parseInt(data.id_notation, 10) ) != -1) // _decimal = 4; // data.price = push.util.formatNum(data.price, _decimal, '', ',', '.'); // if (_decimal == 4) // _decimal = 3; // data.performance = push.util.formatNum(data.performance, 2, true, ',', '.'); // data.performance_pct = push.util.formatNum(data.performance_pct, 2, true, ',', '.') + '%'; return data; }; var pushFilterCommodities = function (data) { var _decimal = 4; if (data.id_notation == 980 || data.id_notation == 981 || data.id_notation == 213 || data.id_notation == 214 || data.id_notation == 222){ _decimal = 2 } data.price = push.util.formatNum(data.price, _decimal, '', ',', '.'); data.performance = push.util.formatNum(data.performance, 2, true, ',', '.'); data.performance_pct = push.util.formatNum(data.performance_pct, 2, true, ',', '.'); return data; }; var pushFilterChart = function (data) { var _decimal = 2; var _decimalPct = 2; var _money = Math.floor(data.total_money) / 1000000; data.total_money = push.util.formatNum(_money, 2, false, ',', '.'); if (need4Decimals.indexOf( parseInt(data.id_notation, 10) ) != -1) { _decimal = 4; _decimalPct = 4; } if (!isNaN(data.price) && data.price > 1000000) data.price = push.util.formatNum(data.price, 0, '', '', '.'); else data.price = push.util.formatNum(data.price, _decimal, '', ',', '.'); var _class = 'gray'; if (data.performance_pct > 0.0) _class = 'green'; else if (data.performance_pct < 0.0) _class = 'red'; if (!isNaN(data.price) && data.performance > 9999) data.performance = push.util.formatNum(data.performance, 0, true, ',', '.'); else data.performance = push.util.formatNum(data.performance, _decimal, true, ',', '.'); data.performance_pct = push.util.formatNum(data.performance_pct, 2, true, ',', '.') + '%'; $('#imageHeadChart').attr('class', _class); //Fecha var dato = data.date_price; var dateDiv = dato.split(' '); var date = dateDiv[0].split('-'); var time = dateDiv[1].split(':'); var fecha = new Date(date[0], (date[1] - 1), date[2], time[0], time[1], time[2]); var ano = fecha.getFullYear(); var mes = ((fecha.getMonth()+1) < 10) ? '0'+(fecha.getMonth()+1) : fecha.getMonth()+1; var dia = (fecha.getDate() < 10) ? '0'+fecha.getDate() : fecha.getDate(); var hora = fecha.getHours() + push.time.gmt; hora = (hora < 10) ? '0'+hora : hora; var minuto = (fecha.getMinutes() < 10) ? '0'+fecha.getMinutes() : fecha.getMinutes(); var segundo = (fecha.getSeconds() < 10) ? '0'+fecha.getSeconds() : fecha.getSeconds(); var totalFecha = dia+'/'+mes+'/'+ano+' '+hora+':'+minuto+':'+segundo; $('#timeUltimaActu').html(hora+':'+minuto); $('#dateUltimaActu').html(dia+'/'+mes+'/'+ano); return data; }; var pushFilterChartCurr = function (data) { var _decimal = 2; var _money = Math.floor(data.total_money) / 1000000; data.total_money = push.util.formatNum(_money, 2, false, ',', '.'); if (need4Decimals.indexOf( parseInt(data.id_notation, 10) ) != -1) _decimal = 4; if (!isNaN(data.price) && data.price > 1000000) data.price = push.util.formatNum(data.price, 0, '', '', '.'); else data.price = push.util.formatNum(data.price, _decimal, '', ',', '.'); var _class = 'gray'; if (data.performance_pct > 0.0) _class = 'green'; else if (data.performance_pct < 0.0) _class = 'red'; if (!isNaN(data.price) && data.performance > 9999) data.performance = push.util.formatNum(data.performance, 0, true, ',', '.'); else data.performance = push.util.formatNum(data.performance, _decimal, true, ',', '.'); data.performance_pct = push.util.formatNum(data.performance_pct, _decimal, true, ',', '.') + '%'; $('#imageHeadChart').attr('class', _class); return data; }; var pushFilterStockChart = function (data) { var _decimal = 2; if (fourthDecimals.indexOf( parseInt(data.id_notation, 10) ) != -1) _decimal = 4; if (!isNaN(data.price) && data.price > 1000000) data.price = push.util.formatNum(data.price, 0, '', '', '.'); else{ if (_inFondoList.indexOf( parseInt(data.id_notation, 10) ) != -1) data.price = push.util.formatNum(data.price, _decimal, '', ',', '.'); else data.price = push.util.formatNum(data.price, _decimal, '', ',', '.'); } var _class = 'arrOff'; if (data.performance_pct > 0.0) _class = 'arrGreen'; else if (data.performance_pct < 0.0) _class = 'arrRed'; if (_decimal == 4) _decimal = 3; if (!isNaN(data.price) && data.performance > 9999) data.performance = push.util.formatNum(data.performance, 0, true, ',', '.'); else data.performance = push.util.formatNum(data.performance, _decimal, true, ',', '.'); data.performance_pct = push.util.formatNum(data.performance_pct, _decimal, true, ',', '.') + '%'; data.bid = push.util.formatNum(data.bid, _decimal, '', ',', '.'); data.volume_bid = push.util.formatNum(data.volume_bid, _decimal, '', ',', '.'); data.ask = push.util.formatNum(data.ask, _decimal, '', ',', '.'); data.volume_ask = push.util.formatNum(data.volume_ask, _decimal, '', ',', '.'); data.max = push.util.formatNum(data.max, _decimal, '', ',', '.'); data.min = push.util.formatNum(data.min, _decimal, '', ',', '.'); $('#stockArrow').attr('class', _class); var _dateBeauty = data.dateFormat_price.split('/'); var _timeBeauty = data.timeFormat_price.split(':'); $('#lastTimeDetail').children()[0].innerHTML = _dateBeauty[0] + ' / ' + _dateBeauty[1] + ' / ' + _dateBeauty[2]; $('#lastTimeDetail').children()[1].innerHTML = _timeBeauty[0] + ':' + _timeBeauty[1]; return data; }; push.template.setFormat('performance_pct', function(dato){ return push.util.formatNum(dato, 2, true, ',', '.'); }); push.template.setFormat('price', function(dato){ return push.util.formatNum(dato, 2, '', ',', '.'); }); push.template.setFormat('total_money', function(dato){ return push.util.formatNum((dato/1000000), 2, '', ',', '.'); }); push.template.setFormat('shortName', function(dato){ if (dato.length > 15) dato = dato.substring(0,15) + '..'; return dato; });