diff --git a/assets/index.html b/assets/index.html index 7f4a23a..0b7e281 100644 --- a/assets/index.html +++ b/assets/index.html @@ -1,6 +1,4 @@ - +
Dash Price
@@ -11,4 +9,4 @@
- + diff --git a/assets/scripts/app.js b/assets/scripts/app.js index ce8bde3..3a3b9a2 100644 --- a/assets/scripts/app.js +++ b/assets/scripts/app.js @@ -1,6 +1,9 @@ (function () { "use strict"; + +/*jshint ignore:start*/ window.JSON || document.write('<\/scr' + 'ipt>'); +/*jshint ignore:end*/ function fetchJSONFile(path, callback) { var httpRequest = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); @@ -25,7 +28,7 @@ var nextCurrency = keys[(i < keys.length - 1 ? i + 1 : 0)]; var currencyValue = data[keys[i]]; var currencyString = (currencyValue.toPrecision(3).length > currencyValue.toFixed(2) ? currencyValue.toPrecision(3) : currencyValue.toFixed(2)); - currencyListHTML += ''; + currencyListHTML += ''; } document.getElementById('dash-ticker--price-container').innerHTML = currencyListHTML; }); diff --git a/dist/index.html b/dist/index.html index ed5bfea..000936b 100644 --- a/dist/index.html +++ b/dist/index.html @@ -1,99 +1,35 @@ -
Dash Price
+ + // this requests the file 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 = ""; + for (var i = 0; i < keys.length; i++) { + var thisCurrency = keys[i]; + var nextCurrency = keys[(i < keys.length - 1 ? i + 1 : 0)]; + var currencyValue = data[keys[i]]; + var currencyString = (currencyValue.toPrecision(3).length > currencyValue.toFixed(2) ? currencyValue.toPrecision(3) : currencyValue.toFixed(2)); + currencyListHTML += ''; + } + document.getElementById('dash-ticker--price-container').innerHTML = currencyListHTML; + }); +})(); diff --git a/package.json b/package.json index 83e0983..f66c25f 100644 --- a/package.json +++ b/package.json @@ -1,22 +1,25 @@ { - "name": "dash-price-ticker" - , "version": "1.0.0" - , "description": "Embeddable dash price widget" - , "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "lint": "echo '=> linting' && jshint assets/scripts/*.js" - } - , "repository": { - "type": "git" - , "url": "git+https://github.com/seigler/Dash-html-ticker.git" - } - , "author": "Joshua Seigler" - , "license": "ISC" - , "bugs": { - "url": "https://github.com/seigler/Dash-html-ticker/issues" - } - , "homepage": "https://github.com/seigler/Dash-html-ticker#readme" - , "devDependencies": { - "jshint": "^2.9.2" - } + "name": "dash-price-ticker", + "version": "1.0.0", + "description": "Embeddable dash price widget", + "scripts": { + "test": "npm run -s lint", + "lint": "echo '=> linting' && jshint assets/scripts/*.js", + "inline": "echo '=> inlining' && inline-assets --cssmin --htmlmin assets/index.html dist/index.html", + "install": "npm run -s lint && npm run -s inline" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/seigler/Dash-html-ticker.git" + }, + "author": "Joshua Seigler", + "license": "ISC", + "bugs": { + "url": "https://github.com/seigler/Dash-html-ticker/issues" + }, + "homepage": "https://github.com/seigler/Dash-html-ticker#readme", + "devDependencies": { + "inline-assets": "^1.0.0", + "jshint": "^2.9.2" + } }