Skip to content

Commit

Permalink
new ep
Browse files Browse the repository at this point in the history
  • Loading branch information
realtux committed Oct 18, 2020
1 parent bdab6b6 commit 05bac0f
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
package-lock.json
20 changes: 20 additions & 0 deletions 120/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const path = require('path');
const { app, BrowserWindow } = require('electron');

require('electron-reload')(__dirname);

app.once('ready', () => {
const window = new BrowserWindow({
width: 400,
height: 300,
webPreferences: {
nodeIntegration: false,
worldSafeExecuteJavaScript: true,
contextIsolation: true,
preload: path.join(__dirname, 'preload.js')
}
});

window.loadFile('index.html');
//window.webContents.openDevTools();
});
6 changes: 6 additions & 0 deletions 120/btc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
setInterval(async () => {
let { data } = await axios
.get('https://api.coindesk.com/v1/bpi/currentprice.json');

document.getElementById('price').innerText = '$' + data.bpi.USD.rate;
}, 2000);
16 changes: 16 additions & 0 deletions 120/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>BTC Price Tracker</title>

<meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />

<link href="style.css" rel="stylesheet" />
<script src="btc.js"></script>
</head>
<body>
<h1 class="title">BTC Price</h1>
<h2 id="price" class="price"></h2>
</body>
</html>
11 changes: 11 additions & 0 deletions 120/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"dependencies": {
"axios": "^0.20.0",
"electron": "10.1.3",
"electron-reload": "1.5.0"
},
"main": "app.js",
"scripts": {
"start": "electron --disable-gpu ."
}
}
3 changes: 3 additions & 0 deletions 120/preload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { contextBridge } = require('electron');

contextBridge.exposeInMainWorld('axios', require('axios'));
17 changes: 17 additions & 0 deletions 120/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
html {
background: #222;
color: #fff;
}

body {
text-align: center;
}

.title {
font-size: 48px;
}

.price {
font-size: 38px;
color: #FCC117;
}

0 comments on commit 05bac0f

Please sign in to comment.