-
Live latency
Amsterdam → Jito 0.10ms
Rotterdam → Jito 1.60ms
Frankfurt → Jito 0.60ms
@@ -464,53 +443,68 @@
const basePriceEl = document.getElementById('customBasePrice');
const addonPriceEl = document.getElementById('customAddonPrice');
const totalPriceEl = document.getElementById('customTotalPrice');
- const addonsSummaryEl = document.getElementById('custom-addons-summary');
+ const addonSummary = document.getElementById('custom-addons-summary');
const previewBtn = document.getElementById('customPreviewBtn');
const latencyUpdated = document.getElementById('latency-updated');
let offers = [];
let activeOffer = null;
const formatCurrency = (value, symbol = '€') => {
- if (!Number.isFinite(value)) {
- return '—';
- }
+ if (!Number.isFinite(value)) return '—';
return `${symbol}${value.toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 2 })}`;
};
- const renderInstantDeals = (deals) => {
- if (!deals.length) {
- instantDealsBody.innerHTML = '
No inventory available. ';
+ const renderInstantDeals = (rows) => {
+ if (!rows.length) {
+ instantDealsBody.innerHTML = '
No inventory available. ';
return;
}
- instantDealsBody.innerHTML = deals.map((deal) => `
+ instantDealsBody.innerHTML = rows.map((row) => `
- ${deal.cpu}
- ${deal.location}
- ${deal.cores}
- ${deal.memory}
- ${deal.storage}
- ${deal.network}
- ${deal.bandwidth}
- ${formatCurrency(deal.price, deal.currencySymbol)}
- Deploy now
+ ${row.cpu}
+ ${row.location}
+ ${row.cores}
+ ${row.memory}
+ ${row.storage}
+ ${row.network}
+ ${row.bandwidth}
+ ${formatCurrency(row.price, row.currencySymbol)}
+ Deploy now
`).join('');
};
const loadInstantDeals = async () => {
try {
- const res = await fetch('/api/instant-offers', { cache: 'no-cache' });
- const payload = await res.json();
+ const response = await fetch('/api/instant-offers', { cache: 'no-cache' });
+ const payload = await response.json();
renderInstantDeals(payload.offers || []);
} catch (error) {
- console.error('Instant offers fetch failed', error);
+ console.error('Instant offers error', error);
instantDealsBody.innerHTML = '
Unable to load instant inventory. ';
}
};
+ const loadCustomOffers = async () => {
+ try {
+ const response = await fetch('/api/custom-offers', { cache: 'no-cache' });
+ const payload = await response.json();
+ offers = (payload.offers || []).map((offer, idx) => ({
+ ...offer,
+ id: `custom-${idx}`,
+ basePrice: offer.basePrice || offer.price || 0,
+ currencySymbol: offer.currencySymbol || '€',
+ }));
+ } catch (error) {
+ console.error('Custom offers error', error);
+ offers = [];
+ }
+ renderCustomOffers();
+ };
+
const renderCustomOffers = () => {
if (!offers.length) {
- customOffersList.innerHTML = '
No custom offers available right now.
';
+ customOffersList.innerHTML = '
No custom offers available.
';
return;
}
customOffersList.innerHTML = offers.map((offer) => `
@@ -531,10 +525,8 @@
renderCustomOptions(offer);
});
});
- const firstCard = customOffersList.querySelector('.offer-card');
- if (firstCard) {
- firstCard.click();
- }
+ const first = customOffersList.querySelector('.offer-card');
+ if (first) first.click();
};
const renderCustomOptions = (offer) => {
@@ -542,25 +534,25 @@
customOptionsContainer.innerHTML = '
Dropdown data unavailable.
';
return;
}
- const optionsHtml = offer.options.map((option, idx) => {
+ const markup = offer.options.map((option, idx) => {
const selectId = `option-${offer.id}-${idx}`;
- const selects = option.choices.map((choice) => {
- const label = choice.label || choice.rawLabel || 'Option';
+ const selector = option.choices.map((choice) => {
const delta = Number(choice.priceDelta) || 0;
const symbol = choice.priceSymbol || offer.currencySymbol || '€';
const deltaLabel = delta ? ` (${delta > 0 ? '+' : ''}${formatCurrency(delta, symbol)})` : '';
- return `
${label}${deltaLabel} `;
+ const label = choice.label || choice.rawLabel || 'Option';
+ return `
${label}${deltaLabel} `;
}).join('');
return `
${option.label}
- ${selects}
+ ${selector}
`;
}).join('');
- customOptionsContainer.innerHTML = `
${optionsHtml}
`;
+ customOptionsContainer.innerHTML = `
${markup}
`;
customOptionsContainer.querySelectorAll('select').forEach((select) => {
select.addEventListener('change', () => updateCustomTotals(offer));
});
@@ -571,60 +563,41 @@
if (!offer) return;
const selects = customOptionsContainer.querySelectorAll('select');
let addonTotal = 0;
- const detailLines = [];
+ const details = [];
selects.forEach((select) => {
const value = Number(select.value) || 0;
addonTotal += value;
const label = select.dataset.optionLabel || select.getAttribute('data-option-name');
- if (value) {
+ if (value !== 0) {
const symbol = offer.currencySymbol || '€';
- detailLines.push(`${label} (${value > 0 ? '+' : ''}${formatCurrency(value, symbol)})`);
+ details.push(`${label} (${value > 0 ? '+' : ''}${formatCurrency(value, symbol)})`);
}
});
const base = Number(offer.basePrice) || 0;
const total = base + addonTotal;
- const currency = offer.currencySymbol || '€';
- basePriceEl.textContent = formatCurrency(base, currency);
- addonPriceEl.textContent = formatCurrency(addonTotal, currency);
- totalPriceEl.textContent = formatCurrency(total, currency);
- addonsSummaryEl.textContent = detailLines.length ? `Add-ons: ${detailLines.join(', ')}` : 'Add-ons: base configuration';
+ const symbol = offer.currencySymbol || '€';
+ basePriceEl.textContent = formatCurrency(base, symbol);
+ addonPriceEl.textContent = formatCurrency(addonTotal, symbol);
+ totalPriceEl.textContent = formatCurrency(total, symbol);
+ addonSummary.textContent = details.length ? `Add-ons: ${details.join(', ')}` : 'Add-ons: base configuration';
previewBtn.disabled = false;
previewBtn.onclick = () => {
- if (offer.configUrl) {
- window.open(offer.configUrl, '_blank');
- }
+ if (offer.configUrl) window.open(offer.configUrl, '_blank');
};
};
- const loadCustomOffers = async () => {
- try {
- const res = await fetch('/api/custom-offers', { cache: 'no-cache' });
- const payload = await res.json();
- offers = (payload.offers || []).map((offer, idx) => ({
- ...offer,
- id: `custom-${idx}`,
- basePrice: offer.basePrice || offer.price || 0,
- currencySymbol: offer.currencySymbol || '€',
- }));
- } catch (error) {
- console.error('Custom offers load failed', error);
- offers = [];
- }
- renderCustomOffers();
- };
-
const updateLatencies = () => {
- const list = [
+ const routes = [
{ id: 'latency-ams', base: 0.1 },
{ id: 'latency-rtm', base: 1.6 },
{ id: 'latency-fra', base: 0.6 },
{ id: 'latency-lon', base: 0.2 },
{ id: 'latency-nyc', base: 0.9 },
];
- list.forEach((item) => {
- const el = document.getElementById(item.id);
+ routes.forEach((route) => {
+ const el = document.getElementById(route.id);
if (el) {
- const jitter = (item.base + (Math.random() - 0.5) * (item.base * 0.3 + 0.05)).toFixed(2);
+ const jitter = (route.base + (Math.random() - 0.5) * (route.base * 0.3 + 0.05)).toFixed(2);
el.textContent = `${jitter}ms`;
}
});