-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
154 lines (131 loc) · 3.99 KB
/
index.html
File metadata and controls
154 lines (131 loc) · 3.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Skyblock Coins Converter</title>
<style>
/* base font scales with viewport width */
html {
font-size: calc(14px + 0.5vw);
}
body {
font-family: sans-serif;
/* let it expand up to 90% of viewport width, but cap at 600px */
max-width: min(90vw, 600px);
margin: 4rem auto;
padding: 1rem;
text-align: center;
}
h1 {
/* roughly 2.5× the base font */
font-size: 2.5rem;
margin-bottom: 0.5rem;
}
#price,
#coins,
#cookie-cost-display {
/* 1.5× the base font */
font-size: 1.5rem;
margin-top: 1rem;
}
.error {
color: #c00;
}
#converter {
margin-top: 2rem;
}
input[type="input"] {
/* scale width with viewport but not too large */
width: min(12rem, 20vw);
font-size: 1rem;
text-align: right;
}
#cookie-cost-slider {
width: 100%;
margin-top: 0.5rem;
/* make thumb and track easier to drag on big screens */
height: 1.5em;
}
label {
display: block;
margin-top: 1.5rem;
font-size: 1rem;
}
select {
font-size: 1rem;
padding: 0.2em 0.4em;
}
</style>
</head>
<body>
<h1>Skyblock Coins Converter</h1>
<div id="price">Loading Bazaar price…</div>
<div id="converter" hidden>
<label>
Currency:
<select id="currency">
<option value="USD" selected>USD</option>
<option value="EUR">EUR</option>
<option value="GBP">GBP</option>
</select>
</label>
<label for="cookie-cost-slider">
Cookie cost:
<span id="cookie-cost-display">1.00</span>
<span id="currency-symbol">USD</span>
</label>
<input
id="cookie-cost-slider"
type="range"
min="1"
max="10"
step="0.01"
value="1"
/>
<label for="amount">Amount:</label>
<input id="amount" type="input" min="0" value="1" />
<div id="coins"></div>
</div>
<script>
const BAZAAR = 'https://api.hypixel.net/v2/skyblock/bazaar';
async function init() {
const priceEl = document.getElementById('price');
const convEl = document.getElementById('converter');
try {
const res = await fetch(BAZAAR);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json();
const cp = data.products.BOOSTER_COOKIE.quick_status.buyPrice;
priceEl.textContent = `Bazaar buy‑price: ${cp.toLocaleString()} coins`;
convEl.hidden = false;
const currSel = document.getElementById('currency');
const symbol = document.getElementById('currency-symbol');
const slider = document.getElementById('cookie-cost-slider');
const disp = document.getElementById('cookie-cost-display');
const amtIn = document.getElementById('amount');
const coinsEl = document.getElementById('coins');
function update() {
const currency = currSel.value;
symbol.textContent = currency;
const costPerCookie = parseFloat(slider.value);
disp.textContent = costPerCookie.toFixed(2);
const coinsPerUnit = cp / costPerCookie;
const amount = parseFloat(amtIn.value) || 0;
const totalCoins = Math.round(amount * coinsPerUnit);
coinsEl.textContent =
`${totalCoins.toLocaleString()} coins for ` +
`${currency} ${amount.toFixed(2)}`;
}
currSel.addEventListener('change', update);
slider .addEventListener('input', update);
amtIn .addEventListener('input', update);
update();
} catch (err) {
priceEl.innerHTML = `<span class="error">Error: ${err.message}</span>`;
}
}
init();
setInterval(init, 60_000);
</script>
</body>
</html>