Skip to content

Instantly share code, notes, and snippets.

@TimonVS
Last active June 11, 2017 13:44
Show Gist options
  • Save TimonVS/9fb8d48899884efb4f00c7701851d4a1 to your computer and use it in GitHub Desktop.
Save TimonVS/9fb8d48899884efb4f00c7701851d4a1 to your computer and use it in GitHub Desktop.
Electron workshop - step 2
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Cryptocoin Tracker</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div id="app"></div>
</body>
<script>
// You can also require other files to run in this process
require('./renderer.js')
</script>
</html>
const app = document.getElementById('app')
const getPrices = () => {
return fetch(
'https://min-api.cryptocompare.com/data/pricemulti?fsyms=BTC,ETH,LTC&tsyms=USD,EUR'
).then(res => {
return res.json()
})
}
const update = () => {
getPrices().then(res => {
const html = Object.entries(res)
.map(currency => {
return `<div class="currency-row">
<h2 class="currency-title">${currency[0]}</h2>
€ ${currency[1].EUR}<br />
$ ${currency[1].USD}
</div>`
})
.join('')
app.innerHTML = html
})
}
update()
setInterval(update, 2000)
@import 'https://cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.min.css';
body {
font-family: sans-serif;
}
.currency-row {
width: 100%;
padding: 10px;
}
.currency-row:nth-child(odd) {
background-color: #f0f0f0;
}
.currency-title {
margin: 0;
margin-bottom: 10px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment