mirror of
https://github.com/seigler/Dash-price-widget
synced 2025-07-27 08:06:09 +00:00
update demo to match latest
This commit is contained in:
parent
0a2545f3bd
commit
c180d56f35
2 changed files with 77 additions and 75 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/node_modules/
|
21
index.html
21
index.html
|
@ -15,8 +15,7 @@
|
|||
|
||||
<h1>Dash Price Widget</h1>
|
||||
|
||||
<style type="text/css">
|
||||
/* Micro reset so global styles don't interfere */
|
||||
<style type="text/css">/* Micro reset so global styles don't interfere */
|
||||
|
||||
.dash-ticker,
|
||||
.dash-ticker *,
|
||||
|
@ -87,8 +86,7 @@
|
|||
</label>
|
||||
</div>
|
||||
</form>
|
||||
<script type="application/javascript">
|
||||
(function () {
|
||||
<script type="application/javascript">(function () {
|
||||
"use strict";
|
||||
|
||||
function fetchJSONFile(path, callback) {
|
||||
|
@ -97,9 +95,7 @@
|
|||
if (httpRequest.readyState === 4) {
|
||||
if (httpRequest.status === 200) {
|
||||
var data = JSON.parse(httpRequest.responseText);
|
||||
if (callback) {
|
||||
callback(data);
|
||||
}
|
||||
if (callback) { callback(data); }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -107,10 +103,11 @@
|
|||
httpRequest.send();
|
||||
}
|
||||
|
||||
// this requests the file and executes a callback with the parsed result once it is available
|
||||
function updatePrices() {
|
||||
// this requests the Dash price JSON and executes a callback with the parsed result once it is available
|
||||
fetchJSONFile('https://coinmarketcap-nexuist.rhcloud.com/api/dash/price', function (data) {
|
||||
var keys = Object.keys(data)
|
||||
, currencyListHTML = "";
|
||||
var keys = Object.keys(data),
|
||||
currencyListHTML = "";
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var thisCurrency = keys[i];
|
||||
var nextCurrency = keys[(i < keys.length - 1 ? i + 1 : 0)];
|
||||
|
@ -120,6 +117,10 @@
|
|||
}
|
||||
document.getElementById('dash-ticker--price-container').innerHTML = currencyListHTML;
|
||||
});
|
||||
}
|
||||
|
||||
updatePrices(); // update prices now
|
||||
setInterval(updatePrices, 5 * 60 * 1000); // ...and every five minutes after this
|
||||
})();
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue