Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
156 lines (135 loc) · 5.55 KB
/
Copy pathscript.js
File metadata and controls
156 lines (135 loc) · 5.55 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
155
156
// --- 1. LOGIKA LOGIN & LOGOUT ---
const loginForm = document.getElementById('auth-login');
if (loginForm) {
loginForm.addEventListener('submit', function(e) {
e.preventDefault();
const user = document.getElementById('login-username').value;
const pass = document.getElementById('login-password').value;
if (user === 'aterkia' && pass === 'asv123') {
localStorage.setItem('role', 'admin');
window.location.href = 'admin.html';
} else {
localStorage.setItem('role', 'user');
localStorage.setItem('username', user);
window.location.href = 'user.html';
}
});
}
function logout() {
localStorage.removeItem('role');
localStorage.removeItem('username');
window.location.href = 'index.html'; // Pastikan file ini namanya index.html
}
// --- 2. SINKRONISASI GLOBAL (Nama & Warna) ---
function syncSettings() {
const savedName = localStorage.getItem("globalShipName") || "Aterolas";
const savedColor = localStorage.getItem("globalThemeColor") || "#0c53ec";
document.querySelectorAll(".logo").forEach(el => {
const isAdmin = el.querySelector('.logo-admin');
el.innerHTML = `${savedName} ${isAdmin ? '<span class="logo-admin">Admin</span>' : ''}`;
});
document.querySelectorAll(".c1-box").forEach(el => {
el.style.backgroundColor = savedColor;
});
}
// --- 3. ADMIN PANEL (Draggable & Global Edit) ---
const adminPanel = document.getElementById("adminPanel");
const adminHeader = document.getElementById("adminPanelHeader");
if (adminHeader && adminPanel) {
let isDragging = false, offset = [0, 0];
adminHeader.onmousedown = (e) => {
isDragging = true;
offset = [adminPanel.offsetLeft - e.clientX, adminPanel.offsetTop - e.clientY];
};
document.onmousemove = (e) => {
if (!isDragging) return;
adminPanel.style.left = (e.clientX + offset[0]) + "px";
adminPanel.style.top = (e.clientY + offset[1]) + "px";
adminPanel.style.right = 'auto';
};
document.onmouseup = () => isDragging = false;
}
function toggleMinimize() {
const panel = document.getElementById("adminPanel");
const btn = document.querySelector(".min-btn");
panel.classList.toggle("minimized");
// Ubah icon tombolnya
if (panel.classList.contains("minimized")) {
btn.innerHTML = "⚙️"; // Icon gear saat kecil
} else {
btn.innerHTML = "-";
}
}
function applyGlobalSettings() {
const name = document.getElementById("editShipName").value;
const color = document.getElementById("editThemeColor").value;
if (name) localStorage.setItem("globalShipName", name);
localStorage.setItem("globalThemeColor", color);
syncSettings();
alert("Pengaturan Berhasil Diterapkan!");
}
// --- 4. INTERAKSI CONTENT-1 & 2 KE MIDDLE ---
function updateMiddle(title, value) {
const display = document.getElementById("display-content");
if(display) {
display.innerHTML = `
<h2 style="color: #0c53ec; margin-bottom:10px;">${title}</h2>
<div style="font-size: 3rem; font-weight: bold;">${value}</div>
<p style="color: #666; margin-top:10px;">Status: <span style="color:green">Aktif</span></p>
`;
}
}
document.querySelectorAll('.c1-box').forEach(box => {
box.onclick = () => {
const title = box.querySelector('span').innerText;
updateMiddle(title, (Math.random() * 50).toFixed(2));
};
});
// --- 5. OTOMATISASI CONTENT-2 (STREAMING STATUS) ---
function autoShowStreaming() {
const labels = ["Maps", "Trajectory", "Computer Vision", "Photo"];
const boxes = document.querySelectorAll('.c2-box');
boxes.forEach((box, index) => {
// Cek jika label belum ada, baru tambahkan
if (!box.querySelector('.streaming-label')) {
const labelDiv = document.createElement('div');
labelDiv.className = 'streaming-label';
labelDiv.innerHTML = `${labels[index]}: <span style="color:#00ff00">ACTIVE</span>`;
box.appendChild(labelDiv);
}
});
// Ubah indicator status jadi Online
const statusPill = document.getElementById('status-indicator');
if (statusPill) {
statusPill.className = 'status-pill online';
statusPill.innerText = 'Connected';
}
}
// Tambahkan autoShowStreaming ke dalam window.onload
window.onload = () => {
syncSettings();
autoShowStreaming(); // Langsung muncul saat buka halaman
};
// --- Perbaikan applyGlobalSettings agar tetap sinkron ---
function applyGlobalSettings() {
const name = document.getElementById("editShipName").value;
const color = document.getElementById("editThemeColor").value;
if (name) localStorage.setItem("globalShipName", name);
localStorage.setItem("globalThemeColor", color);
syncSettings();
// Opsional: Langsung sembunyikan panel setelah apply
toggleMinimize();
alert("Pengaturan Berhasil Diterapkan!");
}
// --- 6. MODAL GAMBAR ---
const modal = document.getElementById("imageModal");
const shipTrigger = document.getElementById("shipTrigger");
if (shipTrigger) {
shipTrigger.onclick = () => {
modal.style.display = "flex";
document.getElementById("imgFull").src = shipTrigger.src;
};
}
const closeModal = document.querySelector(".close-modal");
if(closeModal) closeModal.onclick = () => modal.style.display = "none";
window.onload = syncSettings;