mirror of
https://github.com/seigler/Dash-price-widget
synced 2025-07-27 08:06:09 +00:00
set up inlining and minifying
This commit is contained in:
parent
4dd6e2020b
commit
8cf456f7aa
4 changed files with 61 additions and 121 deletions
|
@ -1,6 +1,4 @@
|
||||||
<style>
|
<link rel="stylesheet" type="text/css" href="styles/styles.css" />
|
||||||
@import 'styles/styles.css';
|
|
||||||
</style>
|
|
||||||
<form class="dash-ticker">
|
<form class="dash-ticker">
|
||||||
<div class="dash-ticker--title">Dash Price</div>
|
<div class="dash-ticker--title">Dash Price</div>
|
||||||
<div id="dash-ticker--price-container" title="Click to change currency">
|
<div id="dash-ticker--price-container" title="Click to change currency">
|
||||||
|
@ -11,4 +9,4 @@
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<script src="scripts/app.js"></script>
|
<script type="application/javascript" src="scripts/app.js"></script>
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
(function () {
|
(function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
/*jshint ignore:start*/
|
||||||
window.JSON || document.write('<scr' + 'ipt src="//cdnjs.cloudflare.com/ajax/libs/json3/3.2.4/json3.min.js"><\/scr' + 'ipt>');
|
window.JSON || document.write('<scr' + 'ipt src="//cdnjs.cloudflare.com/ajax/libs/json3/3.2.4/json3.min.js"><\/scr' + 'ipt>');
|
||||||
|
/*jshint ignore:end*/
|
||||||
|
|
||||||
function fetchJSONFile(path, callback) {
|
function fetchJSONFile(path, callback) {
|
||||||
var httpRequest = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
|
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 nextCurrency = keys[(i < keys.length - 1 ? i + 1 : 0)];
|
||||||
var currencyValue = data[keys[i]];
|
var currencyValue = data[keys[i]];
|
||||||
var currencyString = (currencyValue.toPrecision(3).length > currencyValue.toFixed(2) ? currencyValue.toPrecision(3) : currencyValue.toFixed(2));
|
var currencyString = (currencyValue.toPrecision(3).length > currencyValue.toFixed(2) ? currencyValue.toPrecision(3) : currencyValue.toFixed(2));
|
||||||
currencyListHTML += '<input type="radio" name="currency" id="dash-ticker-currencies-' + thisCurrency + '"' + (i == 0 ? ' checked' : '') + ' /><label for="dash-ticker-currencies-' + nextCurrency + '"><span class="dash-ticker--price">' + currencyString + '</span> <span class="dash-ticker--currency">' + thisCurrency.toUpperCase() + '</span></label>';
|
currencyListHTML += '<input type="radio" name="currency" id="dash-ticker-currencies-' + thisCurrency + '"' + (i === 0 ? ' checked' : '') + ' /><label for="dash-ticker-currencies-' + nextCurrency + '"><span class="dash-ticker--price">' + currencyString + '</span> <span class="dash-ticker--currency">' + thisCurrency.toUpperCase() + '</span></label>';
|
||||||
}
|
}
|
||||||
document.getElementById('dash-ticker--price-container').innerHTML = currencyListHTML;
|
document.getElementById('dash-ticker--price-container').innerHTML = currencyListHTML;
|
||||||
});
|
});
|
||||||
|
|
128
dist/index.html
vendored
128
dist/index.html
vendored
|
@ -1,99 +1,35 @@
|
||||||
<style type="text/css">
|
<style type="text/css">.dash-ticker,.dash-ticker *,.dash-ticker :after,.dash-ticker :before{box-sizing:inherit;vertical-align:baseline;font-weight:inherit;font-family:inherit;font-style:inherit;font-size:100%;border:0;outline:0;padding:0;margin:0}.dash-ticker{display:block;max-width:20em;margin:.5em auto;border-radius:.5em;background-color:rgba(0,0,0,.125);box-sizing:border-box;color:inherit;padding:.5em}.dash-ticker .dash-ticker--title{text-align:center;font-size:1.5em;padding-bottom:.125em;border-bottom:1px solid rgba(0,0,0,.5);margin-bottom:.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}</style><form class="dash-ticker"><div class="dash-ticker--title">Dash Price</div><div id="dash-ticker--price-container" title="Click to change currency"><input type="radio" name="currency" id="USD" checked="checked"><label><span class="dash-ticker--price">Loading...</span> <span class="dash-ticker--currency"></span></label></div></form><script type="application/javascript">(function () {
|
||||||
/* Micro reset so global styles don't interfere */
|
"use strict";
|
||||||
.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 {
|
/*jshint ignore:start*/
|
||||||
display: block;
|
window.JSON || document.write('<scr' + 'ipt src="//cdnjs.cloudflare.com/ajax/libs/json3/3.2.4/json3.min.js"><\/scr' + 'ipt>');
|
||||||
max-width: 20em;
|
/*jshint ignore:end*/
|
||||||
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 {
|
function fetchJSONFile(path, callback) {
|
||||||
text-align: center;
|
var httpRequest = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
|
||||||
font-size: 1.5em;
|
httpRequest.onreadystatechange = function () {
|
||||||
padding-bottom: 0.125em;
|
if (httpRequest.readyState === 4) {
|
||||||
border-bottom: 1px solid rgba(0,0,0,0.5);
|
if (httpRequest.status === 200) {
|
||||||
margin-bottom: 0.25em;
|
var data = JSON.parse(httpRequest.responseText);
|
||||||
}
|
if (callback) { callback(data); }
|
||||||
|
}
|
||||||
#dash-ticker--price-container {
|
}
|
||||||
font-size: 2em;
|
};
|
||||||
text-align: center;
|
httpRequest.open('GET', path);
|
||||||
}
|
httpRequest.send();
|
||||||
|
|
||||||
#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;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<form class="dash-ticker">
|
|
||||||
<div class="dash-ticker--title">Dash Price</div>
|
|
||||||
<div id="dash-ticker--price-container" title="Click to change currency">
|
|
||||||
<input type="radio" name="currency" id="USD" checked />
|
|
||||||
<label>
|
|
||||||
<span class="dash-ticker--price">Loading...</span>
|
|
||||||
<span class="dash-ticker--currency"></span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
<script>
|
|
||||||
(function () {
|
|
||||||
window.JSON || document.write('<script src="//cdnjs.cloudflare.com/ajax/libs/json3/3.2.4/json3.min.js"><\/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);
|
|
||||||
var 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 += '<input type="radio" name="currency" id="dash-ticker-currencies-' + thisCurrency + '"' + (i == 0 ? ' checked' : '') + ' /><label for="dash-ticker-currencies-' + nextCurrency + '"><span class="dash-ticker--price">' + currencyString + '</span> <span class="dash-ticker--currency">' + thisCurrency.toUpperCase() + '</span></label>';
|
|
||||||
}
|
}
|
||||||
document.getElementById('dash-ticker--price-container').innerHTML = currencyListHTML;
|
|
||||||
});
|
// 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) {
|
||||||
</script>
|
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 += '<input type="radio" name="currency" id="dash-ticker-currencies-' + thisCurrency + '"' + (i === 0 ? ' checked' : '') + ' /><label for="dash-ticker-currencies-' + nextCurrency + '"><span class="dash-ticker--price">' + currencyString + '</span> <span class="dash-ticker--currency">' + thisCurrency.toUpperCase() + '</span></label>';
|
||||||
|
}
|
||||||
|
document.getElementById('dash-ticker--price-container').innerHTML = currencyListHTML;
|
||||||
|
});
|
||||||
|
})();</script>
|
||||||
|
|
43
package.json
43
package.json
|
@ -1,22 +1,25 @@
|
||||||
{
|
{
|
||||||
"name": "dash-price-ticker"
|
"name": "dash-price-ticker",
|
||||||
, "version": "1.0.0"
|
"version": "1.0.0",
|
||||||
, "description": "Embeddable dash price widget"
|
"description": "Embeddable dash price widget",
|
||||||
, "scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "npm run -s lint",
|
||||||
"lint": "echo '=> linting' && jshint assets/scripts/*.js"
|
"lint": "echo '=> linting' && jshint assets/scripts/*.js",
|
||||||
}
|
"inline": "echo '=> inlining' && inline-assets --cssmin --htmlmin assets/index.html dist/index.html",
|
||||||
, "repository": {
|
"install": "npm run -s lint && npm run -s inline"
|
||||||
"type": "git"
|
},
|
||||||
, "url": "git+https://github.com/seigler/Dash-html-ticker.git"
|
"repository": {
|
||||||
}
|
"type": "git",
|
||||||
, "author": "Joshua Seigler"
|
"url": "git+https://github.com/seigler/Dash-html-ticker.git"
|
||||||
, "license": "ISC"
|
},
|
||||||
, "bugs": {
|
"author": "Joshua Seigler",
|
||||||
"url": "https://github.com/seigler/Dash-html-ticker/issues"
|
"license": "ISC",
|
||||||
}
|
"bugs": {
|
||||||
, "homepage": "https://github.com/seigler/Dash-html-ticker#readme"
|
"url": "https://github.com/seigler/Dash-html-ticker/issues"
|
||||||
, "devDependencies": {
|
},
|
||||||
"jshint": "^2.9.2"
|
"homepage": "https://github.com/seigler/Dash-html-ticker#readme",
|
||||||
}
|
"devDependencies": {
|
||||||
|
"inline-assets": "^1.0.0",
|
||||||
|
"jshint": "^2.9.2"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue