diff --git a/tugas-spbu/index.html b/tugas-spbu/index.html
index f0db3a6..19628e3 100644
--- a/tugas-spbu/index.html
+++ b/tugas-spbu/index.html
@@ -90,6 +90,20 @@ function promptApiKey() {
}
}
+function updateBukaVisibility() {
+ const selectEl = document.querySelector('#modal-fields select[name="jenis"]');
+ const container = document.getElementById('buka-24-jam-container');
+ if (selectEl && container) {
+ if (selectEl.value === 'rumah') {
+ container.style.display = 'none';
+ const checkbox = container.querySelector('input[name="buka_24_jam"]');
+ if (checkbox) checkbox.checked = false;
+ } else {
+ container.style.display = 'block';
+ }
+ }
+}
+
function handleApiResponse(res, callback) {
if (res.status === 401) {
alert('Akses Ditolak: API Key tidak valid atau kosong.');
@@ -150,10 +164,18 @@ map.on(L.Draw.Event.CREATED, function (e) {
-
+
`, handleModalSubmit);
+
+ // Setup dynamic visibility for 24 hours checkbox
+ const selectEl = document.querySelector('#modal-fields select[name="jenis"]');
+ if (selectEl) {
+ selectEl.addEventListener('change', updateBukaVisibility);
+ updateBukaVisibility();
+ }
+
// try to reverse-geocode and prefill the alamat field
reverseGeocode(ll.lat, ll.lng).then(addr=>{
try{ const f = document.querySelector('#modal-fields input[name="alamat"]'); if(f && addr) f.value = addr; }catch(e){}
@@ -548,7 +570,7 @@ function edit(id,nama,telp,buka,alamat,jenis){
-
+
`, function(values){
fetch('src/api/update_lokasi.php',{
@@ -556,8 +578,15 @@ function edit(id,nama,telp,buka,alamat,jenis){
body:JSON.stringify({id:id,nama:values.nama, jenis: values.jenis || 'rumah', no_telp:values.no_telp||'',buka_24_jam:values.buka_24_jam?1:0, alamat: values.alamat || ''})
}).then(res => handleApiResponse(res, loadData));
});
- // set current jenis selection after modal fields inserted
- setTimeout(()=>{ const sel=document.querySelector('#modal-fields select[name="jenis"]'); if(sel) sel.value = (jenis||'rumah'); },0);
+ // set current jenis selection after modal fields inserted and setup listener
+ setTimeout(()=>{
+ const sel=document.querySelector('#modal-fields select[name="jenis"]');
+ if(sel) {
+ sel.value = (jenis||'rumah');
+ sel.addEventListener('change', updateBukaVisibility);
+ updateBukaVisibility();
+ }
+ },0);
}
function editJalan(id,nama,status,panjang){