diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2ccbe46 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/node_modules/ diff --git a/assets/index.html b/assets/index.html new file mode 100644 index 0000000..7f4a23a --- /dev/null +++ b/assets/index.html @@ -0,0 +1,14 @@ + +
+
Dash Price
+
+ + +
+
+ diff --git a/assets/scripts/app.js b/assets/scripts/app.js new file mode 100644 index 0000000..ce8bde3 --- /dev/null +++ b/assets/scripts/app.js @@ -0,0 +1,32 @@ +(function () { + "use strict"; + window.JSON || document.write('<\/scr' + 'ipt>'); + + function fetchJSONFile(path, callback) { + var httpRequest = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); + httpRequest.onreadystatechange = function () { + if (httpRequest.readyState === 4) { + if (httpRequest.status === 200) { + var data = JSON.parse(httpRequest.responseText); + if (callback) { callback(data); } + } + } + }; + httpRequest.open('GET', path); + httpRequest.send(); + } + + // 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/assets/styles/styles.css b/assets/styles/styles.css new file mode 100644 index 0000000..cda233e --- /dev/null +++ b/assets/styles/styles.css @@ -0,0 +1,54 @@ +/* Micro reset so global styles don't interfere */ +.dash-ticker, +.dash-ticker *, +.dash-ticker *:before, +.dash-ticker *:after { + box-sizing: inherit; + vertical-align: baseline; + font-weight: inherit; + font-family: inherit; + font-style: inherit; + font-size: 100%; + border: 0 none; + outline: 0; + padding: 0; + margin: 0; +} + +.dash-ticker { + display: block; + max-width: 20em; + margin: 0.5em auto; + border-radius: 0.5em; + background-color: rgba(0,0,0,0.125); + box-sizing: border-box; + color: inherit; + padding: 0.5em; +} + +.dash-ticker .dash-ticker--title { + text-align: center; + font-size: 1.5em; + padding-bottom: 0.125em; + border-bottom: 1px solid rgba(0,0,0,0.5); + margin-bottom: 0.25em; +} + +#dash-ticker--price-container { + font-size: 2em; + text-align: center; +} + +#dash-ticker--price-container > input { + position: fixed; + right: -200px; +} + +#dash-ticker--price-container > input + label { + display: none; + cursor: pointer; +} + +#dash-ticker--price-container > input:checked + label { + display: block; +} diff --git a/Dash-price-ticker.html b/dist/index.html similarity index 99% rename from Dash-price-ticker.html rename to dist/index.html index 95c9fc1..ed5bfea 100644 --- a/Dash-price-ticker.html +++ b/dist/index.html @@ -79,7 +79,7 @@ } }; httpRequest.open('GET', path); - httpRequest.send(); + httpRequest.send(); } // this requests the file and executes a callback with the parsed result once it is available diff --git a/package.json b/package.json new file mode 100644 index 0000000..83e0983 --- /dev/null +++ b/package.json @@ -0,0 +1,22 @@ +{ + "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" + } +}