-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Web view improvements (update interval, settings) #286
Changes from 6 commits
bcb3be2
de08e92
1a58be0
45bc439
d2aaf68
94b5f42
30cd953
1b026fa
654c6ab
b5567c5
d1b4516
4e087cb
61081dd
24da4cd
ded06c3
2e6cac4
b97ab45
5234536
a644a86
65fadef
851c30e
d18500e
42294a3
f98a4ab
d8fb51e
52b6830
b930c92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,12 @@ | |
|
||
var localFile, reader; | ||
|
||
var Hour = new Timespan("Hour",1/24); | ||
var Day = new Timespan("Day",1); | ||
var Week = new Timespan("Week",7); | ||
var Month = new Timespan("Month",30); | ||
var timespans = [Month, Week, Day, Hour]; | ||
var Hour = new Timespan("Hour", 1/24); | ||
var Day = new Timespan("Day", 1); | ||
var Week = new Timespan("Week", 7); | ||
var Month = new Timespan("Month", 30); | ||
var Year = new Timespan("Year", 365); | ||
var timespans = [Year, Month, Week, Day, Hour]; | ||
var summaryCoinRate, summaryCoin; | ||
var earningsOutputCoinRate, earningsOutputCoin; | ||
var outputCurrencyDisplayMode = 'all' | ||
|
@@ -69,6 +70,7 @@ function updateRawValues(rawData){ | |
table.innerHTML = ""; | ||
var currencies = Object.keys(rawData); | ||
var totalBTCEarnings = {}; | ||
var totalCoinsOverall = 0; | ||
for (var keyIndex = 0; keyIndex < currencies.length; ++keyIndex) | ||
{ | ||
var currency = currencies[keyIndex]; | ||
|
@@ -78,6 +80,7 @@ function updateRawValues(rawData){ | |
var totalCoins = parseFloat(rawData[currency]['totalCoins']); | ||
var maxToLend = parseFloat(rawData[currency]['maxToLend']); | ||
var highestBidBTC = parseFloat(rawData[currency]['highestBid']); | ||
|
||
if (currency == 'BTC') { | ||
// no bids for BTC provided by poloniex | ||
// this is added so BTC can be handled like other coins for conversions | ||
|
@@ -181,11 +184,20 @@ function updateRawValues(rawData){ | |
} | ||
} | ||
} | ||
totalCoinsOverall += earningsOutputCoinRate * maxToLend * highestBidBTC; | ||
} | ||
|
||
// add headers | ||
var thead = table.createTHead(); | ||
|
||
// total | ||
var total_row = thead.insertRow(0); | ||
var total_cell = total_row.appendChild(document.createElement("th")); | ||
total_cell.innerHTML = "Total holdings"; | ||
total_cell = total_row.appendChild(document.createElement("th")); | ||
total_cell.setAttribute("colspan", 2); | ||
total_cell.innerHTML = prettyFloat(totalCoinsOverall, 2) + " USD"; | ||
|
||
// show account summary | ||
if (currencies.length > 1 || summaryCoin != earningsOutputCoin) { | ||
earnings = ''; | ||
|
@@ -214,18 +226,18 @@ function handleLocalFile(file) { | |
function loadData() { | ||
if (localFile) { | ||
reader.readAsText(localFile, 'utf-8'); | ||
setTimeout('loadData()',30000) | ||
setTimeout('loadData()', 10000) | ||
} else { | ||
// expect the botlog.json to be in the same folder on the webserver | ||
var file = 'botlog.json'; | ||
$.getJSON(file, function (data) { | ||
updateJson(data); | ||
// reload every 30sec | ||
setTimeout('loadData()',30000) | ||
setTimeout('loadData()', 10000) | ||
}).fail( function(d, textStatus, error) { | ||
$('#status').text("getJSON failed, status: " + textStatus + ", error: "+error); | ||
// retry after 60sec | ||
setTimeout('loadData()',60000) | ||
setTimeout('loadData()', 60000) | ||
});; | ||
} | ||
} | ||
|
@@ -246,6 +258,8 @@ function Timespan(name, multiplier) { | |
} | ||
if (currency == "BTC") { | ||
return displayUnit.formatValue(earnings) + " <span class=" + currencyClass + ">" + displayUnit.name + "</span> / " + name + "<br/>" | ||
} else if (currency == "USD" || currency == "USDT") { | ||
return printFloat(earnings, 2) + " <span class=" + currencyClass + ">" + currency + "</span> / "+ name + "<br/>"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest we just use prettyFloat(earnings,2) instead of trying to guess which currency is a Fiat one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i.e. I use EUR. ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would change behavior for quite a few coins, I think we want to see Satoshi level resolution most of the times? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What other currencies should we add here? Some currencies may need special printing, in this case for USD it makes sense. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, the other currencies in this function use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ckcollab "EUR" for example and actually any currency supported by https://blockchain.info/api/exchange_rates_api I'm thinking about using the prettyFloat as it will provide an accuracy of 2 decimals for any coin and I think that should be good enough, no? or should we make the accuracy configurable? I'm open for suggestions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: I also add EUR, but maintain consistency with the surrounding code. Then in a separate PR we decide how to handle this particular problem. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agreed. |
||
} else { | ||
return printFloat(earnings, 8) + " <span class=" + currencyClass + ">" + currency + "</span> / "+ name + "<br/>"; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
USD? I guess it should be earningsOutputCoin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're doing this in another PR I'll pull this stuff