JSFiddle - React, Tailwind, and code Playground
by frifox
HTML
<div>Loading...</div>
CSS
html {
font-family: Verdana;
color: #000;
font-size: 12px;
text-align: center;
background: #333;
}
div {
display: inline-block;
padding: 20px 40px;
margin: 40px;
background: #eee;
background: -moz-linear-gradient(top, #eee, #aaa);
background: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#aaa));
border: 1px solid #000;
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
box-shadow: 0 0 20px rgba(0, 0, 0, .5);
-moz-box-shadow: 0 0 20px rgba(0, 0, 0, .5);
-webkit-box-shadow: 0 0 20px rgba(0, 0, 0, .5);
}
h1 {
font-size: 20px;
font-weight: bold;
margin: 0 0 20px 0;
}
p {
font-size: 15px;
}
JavaScript
$.ajaxSetup({cache: false});
setInterval(function () {
$.ajax({
type: 'GET',
url: 'http://www.gw2spidy.com/api/v0.9/json/gem-price',
dataType: 'jsonp',
success: function (json) {
var result = '<h1>' + getISODateTime(new Date()) + '</h1>' +
'<p>400 gems = ' + 4 * json.result.gold_to_gem / 10000 + ' gold</p>' +
'<p>600 gems = ' + 6 * json.result.gold_to_gem / 10000 + ' gold</p>' +
'<p>800 gems = ' + 8 * json.result.gold_to_gem / 10000 + ' gold</p>';
$('div').html(result);
}
});
}, 5000);
function getISODateTime(d) {
var s = function (a, b) {
return (1e15 + a + "").slice(-b)
};
if (typeof d === 'undefined') {
d = new Date();
};
return d.getFullYear() + '-' + s(d.getMonth() + 1, 2) + '-' + s(d.getDate(), 2) + ' ' + s(d.getHours(), 2) + ':' + s(d.getMinutes(), 2) + ':' + s(d.getSeconds(), 2);
};