Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
nyakase committed Aug 24, 2020
1 parent 33a779e commit 78aeb7e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
7 changes: 4 additions & 3 deletions src/pages/js/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ if (getItem("usd")) {
setInterval(function() {
balance += 1;
document.getElementById("bal").innerHTML = balance;
document.getElementById("usd").innerHTML = usd;
localStorage.setItem("bal", balance);
}, 1000);
}, 500);

function reset() {
localStorage.setItem("usd", 0);
Expand All @@ -26,8 +27,8 @@ function reset() {
}

function convert() {
usd = balance
balance = 0
usd += Math.floor(balance / 3);
balance = 0;
document.getElementById("usd").innerHTML = usd;
document.getElementById("bal").innerHTML = balance;
localStorage.setItem("usd", usd);
Expand Down
20 changes: 20 additions & 0 deletions src/pages/js/store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
var usd = getItem("usd")

setTimeout(() => {
if (usd > 19) {
document.getElementById("amount").innerHTML = "We have these items in stock:"
document.getElementById("vukkybutton").style.display = ""
} else {
document.getElementById("amount").innerHTML = "We don't have anything in stock! Come back later."
}
}, 1000);

function buy(name, price) {
alert("That feature isn't available right now.")
}

function getItem(name) {
var value = localStorage.getItem(name);
if (value != null && !isNaN(Number(value))) return Number(value);
else return value;
}
4 changes: 2 additions & 2 deletions src/pages/panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<body>
<h1>Hello!</h1>
Right now, you have:<br>
<b><span id="bal">0</span></b> VUK<br>
<b><span id="usd">0</span></b> USD<br><br>
<b><span id="bal">Getting</span></b> VUK<br>
<b><span id="usd">Getting</span></b> USD<br><br>
<button onclick="reset()">Reset!</button>
<button onclick="convert()">Convert to USD!</button>
<button onclick="document.location.href='shop.html'">Go to the shop!</button>
Expand Down
7 changes: 4 additions & 3 deletions src/pages/shop.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
<meta charset="UTF-8">
<title>VukkyShop</title>
<link rel="stylesheet" href="css/panel.css">
<script src="js/panel.js"></script>
<script src="js/store.js"></script>
</head>
<body>
<h1>VukkyShop!</h1>
Welcome! We don't have anything in store right now.<br><br>
<h1>VukkyShop</h1>
Welcome! <span id="amount">We'll check our stock now...</span><br><br>
<button id="vukkybutton" style="display:none;" onclick="buy('Vukky', 20)">Vukky (20 USD)</button><br><br>
<button onclick="document.location.href = 'panel.html'">Go back to the panel</button>
</body>
</html>

0 comments on commit 78aeb7e

Please sign in to comment.