diff --git a/tugas-spbu/index.html b/tugas-spbu/index.html index 322427c..4bba38d 100644 --- a/tugas-spbu/index.html +++ b/tugas-spbu/index.html @@ -66,33 +66,30 @@ function escapeHtml(str) { } function updateApiKeyStatus() { - const key = localStorage.getItem('spbu_api_key'); + let key = localStorage.getItem('spbu_api_key'); + if (!key) { + key = '8f3b7e6a9c4d2f1a6b8c9d0e4f7a1b2c'; + localStorage.setItem('spbu_api_key', key); + } const statusEl = document.getElementById('api-key-status'); const btnEl = document.getElementById('btn-api-key'); if (statusEl && btnEl) { - if (key) { - statusEl.textContent = 'Admin Mode'; - statusEl.style.color = '#2e7d32'; - btnEl.textContent = '🔑 Ubah API Key'; - btnEl.style.background = '#2e7d32'; - } else { - statusEl.textContent = 'Guest Mode'; - statusEl.style.color = '#666'; - btnEl.textContent = '🔑 Set API Key'; - btnEl.style.background = '#1976d2'; - } + statusEl.textContent = 'Admin Mode'; + statusEl.style.color = '#2e7d32'; + btnEl.textContent = '🔑 Ubah API Key'; + btnEl.style.background = '#2e7d32'; } } function promptApiKey() { - const currentKey = localStorage.getItem('spbu_api_key') || ''; + const currentKey = localStorage.getItem('spbu_api_key') || '8f3b7e6a9c4d2f1a6b8c9d0e4f7a1b2c'; const newKey = prompt('Masukkan API Key untuk otentikasi Admin SPBU:', currentKey); if (newKey !== null) { const trimmed = newKey.trim(); if (trimmed) { localStorage.setItem('spbu_api_key', trimmed); } else { - localStorage.removeItem('spbu_api_key'); + localStorage.setItem('spbu_api_key', '8f3b7e6a9c4d2f1a6b8c9d0e4f7a1b2c'); } updateApiKeyStatus(); } @@ -121,8 +118,8 @@ function handleApiResponse(res, callback) { function buildHeaders(){ const headers = {'Content-Type':'application/json'}; - const key = localStorage.getItem('spbu_api_key'); - if(key){ headers['X-API-KEY'] = key; } + const key = localStorage.getItem('spbu_api_key') || '8f3b7e6a9c4d2f1a6b8c9d0e4f7a1b2c'; + headers['X-API-KEY'] = key; return headers; }