Skip to content

Commit

Permalink
Improve handling of fiat/btc value in tables (don't process if no row…
Browse files Browse the repository at this point in the history
…s exist)
  • Loading branch information
nirvana-tikku committed Dec 20, 2017
1 parent b7663fa commit 539af5b
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion enhancer.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,19 @@ Enhancer.enhanceMarketsTable = function enhanceMarketsTable(table){
}
// Volume -> USD
let columns = row.getElementsByTagName('td');
if(columns.length===1){
break;
}
let alreadyInserted = getChildNodeWithClass(row, CONSTANTS.classes.estUsdPrice);
let priceColIdx = alreadyInserted ? 5 : 4;
updateColumn(CONSTANTS.classes.estUsdPrice, row, priceColIdx, Enhancer.getMarketType(columns[0].innerText));
}
}
}
Enhancer.enhanceHistoryTable = function enhanceHistoryOpenTable(type, table, isShortTable){
Enhancer.enhanceHistoryTable = function enhanceHistoryTable(type, table, isShortTable){
if(!table){
return;
}
const rows = table.getElementsByTagName('tr');
if(rows && rows.length > 1){
for(let i=0; i<rows.length; i++){
Expand All @@ -263,6 +269,9 @@ Enhancer.enhanceHistoryTable = function enhanceHistoryOpenTable(type, table, isS
updateHeader(CONSTANTS.classes.estUsdValue+"-"+type, row, totalIdx, (type === 'closed' ? 'Hyp.' : 'Est.') +' USD Value');
continue;
}
if(row.getElementsByTagName("td").length===1){
break;
}
// BTC Value + USD
let alreadyInserted = getChildNodeWithClass(row, CONSTANTS.classes.estUsdValue);
if(alreadyInserted){
Expand Down Expand Up @@ -292,6 +301,9 @@ Enhancer.enhanceBalanceTable = function balanceTable(table){
updateHeader(CONSTANTS.classes.estUsdValue, row, 10, 'Est. USD Value');
continue;
}
if(row.getElementsByTagName("td").length===1){
break;
}
// BTC Value + USD
let alreadyInserted = getChildNodeWithClass(row, CONSTANTS.classes.estUsdValue);
let priceIdx = 7;
Expand Down Expand Up @@ -333,6 +345,9 @@ Enhancer.enhanceOrderTable = function enhanceOrderTable(type, table){
updateHeader('est-price-' + type, row, priceColIdx, title + ' (Est. ' + (isUsdtMarket?'BTC':'USD') + ')');
continue;
}
if(row.getElementsByTagName("td").length===1){
break;
}
let alreadyInserted = getChildNodeWithClass(row, CONSTANTS.classes.estPrice);
let priceIdx = priceColIdx;
if(alreadyInserted){
Expand All @@ -343,6 +358,9 @@ Enhancer.enhanceOrderTable = function enhanceOrderTable(type, table){
}
}
Enhancer.enhanceOpenOrdersTable = function enhanceOpenOrdersTable(table){
if(!table){
return;
}
const rows = table.getElementsByTagName('tr');
if(rows && rows.length > 1){
for(let i=0; i<rows.length; i++){
Expand Down Expand Up @@ -380,6 +398,9 @@ Enhancer.enhanceMarketHistoryTable = function enhanceMarketHistoryTable(table){
updateHeader(CONSTANTS.classes.mktHistoryTotalUsdVal, row, totalIdx, 'TOTAL COST (Est. ' + (isUsdtMarket?'BTC':'USD') + ')');
continue;
}
if(row.getElementsByTagName("td").length===1){
break;
}
let alreadyInserted = getChildNodeWithClass(row, CONSTANTS.classes.mktHistoryUsdPrice);
if(alreadyInserted){
priceIdx += 1;
Expand Down

0 comments on commit 539af5b

Please sign in to comment.