Skip to content

Commit 372fd2b

Browse files
authored
Update terminal-verification.html
1 parent ab22ef8 commit 372fd2b

1 file changed

Lines changed: 24 additions & 92 deletions

File tree

terminal-verification.html

Lines changed: 24 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,112 +1550,44 @@
15501550
}
15511551

15521552
//📌 sistem butang closed keybord
1553-
// Auto-attach event listener
1554-
// SIMPLE VERSION - Pasti bekerja
1555-
// Auto-attach event listener untuk Close Terminal Button
1553+
// SIMPLE MOBILE VERSION
15561554
document.addEventListener('DOMContentLoaded', function() {
1557-
console.log('🔧 Initializing Terminal Close Button...');
15581555

1556+
// 1. Close button
15591557
const closeBtn = document.querySelector('.terminal-close-btn');
1560-
15611558
if (closeBtn) {
1562-
console.log('✅ Close button found, attaching event listener');
1563-
1564-
// Method 1: Add event listener
1565-
closeBtn.addEventListener('click', function(e) {
1566-
console.log('🖱️ Close button clicked');
1567-
e.preventDefault();
1568-
e.stopPropagation();
1569-
closeTerminal();
1570-
});
1571-
1572-
// Method 2: Juga attach onclick sebagai backup
1573-
closeBtn.onclick = function(e) {
1574-
console.log('🖱️ Close button onclick triggered');
1575-
e.preventDefault();
1576-
e.stopPropagation();
1577-
closeTerminal();
1578-
};
1579-
1580-
// Tambah title/tooltip
1581-
closeBtn.title = "Close and return to Azura AI menu";
1582-
1583-
} else {
1584-
console.warn('⚠️ Close button not found! Check HTML class name');
1585-
console.log('Looking for: .terminal-close-btn');
1586-
console.log('Available buttons:', document.querySelectorAll('button'));
1559+
closeBtn.onclick = closeTerminal;
15871560
}
15881561

1589-
// ESC key untuk close (optional)
1590-
document.addEventListener('keydown', function(e) {
1591-
if (e.key === 'Escape' || e.key === 'Esc' || e.keyCode === 27) {
1592-
console.log('⌨️ ESC key pressed - closing terminal');
1562+
// 2. Android Back Button Handler
1563+
// Push state untuk track
1564+
history.pushState({page: 'terminal'}, '');
1565+
1566+
// Handle back button
1567+
window.onpopstate = function(event) {
1568+
// Ketika user tekan back button hardware
1569+
console.log('Back button pressed on mobile');
1570+
1571+
// Tanya confirmation (optional)
1572+
if (confirm('Return to Azura AI?')) {
15931573
closeTerminal();
1574+
} else {
1575+
// Block back navigation jika user cancel
1576+
history.pushState({page: 'terminal'}, '');
15941577
}
1595-
});
1578+
};
15961579

1597-
// Debug info
1598-
console.log('🔗 Current page:', window.location.href);
1599-
console.log('🎯 Return URL will be: index.html?menu=open');
1580+
// 3. Prevent accidental back
1581+
window.onbeforeunload = function() {
1582+
return 'Are you sure you want to leave?';
1583+
};
16001584
});
16011585

1602-
// Function closeTerminal dengan debugging
16031586
function closeTerminal() {
1604-
console.log('🚀 closeTerminal() function executing...');
1605-
1606-
// Dapatkan button untuk feedback visual
1607-
const btn = document.querySelector('.terminal-close-btn');
1608-
let originalHTML = '';
1609-
1610-
if (btn) {
1611-
originalHTML = btn.innerHTML;
1612-
btn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Closing...';
1613-
btn.disabled = true;
1614-
btn.style.opacity = '0.7';
1615-
console.log('🌀 Showing loading state on button');
1616-
}
1617-
1618-
// Add timestamp untuk avoid cache
1619-
const timestamp = Date.now();
1620-
const returnUrl = `index.html?menu=open&from=terminal&t=${timestamp}`;
1621-
1622-
console.log('🔗 Redirecting to:', returnUrl);
1623-
console.log('⏳ Wait 500ms for loading effect...');
1624-
1625-
// Redirect dengan sedikit delay untuk loading effect
1626-
setTimeout(() => {
1627-
console.log('🎯 Performing redirect now');
1628-
1629-
// Option 1: Standard redirect (akan bekerja)
1630-
window.location.href = returnUrl;
1631-
1632-
// Option 2: Force redirect (backup)
1633-
// window.location.replace(returnUrl);
1634-
1635-
// Option 3: Jika masih tak berfungsi, alert untuk debug
1636-
setTimeout(() => {
1637-
console.warn('⚠️ Redirect seems delayed or blocked');
1638-
if (window.location.href.includes('terminal-verification')) {
1639-
console.log('⚠️ Still on terminal page, trying force reload');
1640-
window.location.href = returnUrl;
1641-
}
1642-
}, 1000);
1643-
1644-
}, 500);
1587+
// Use replace() supaya terminal tak ada dalam history
1588+
window.location.replace('index.html?menu=open');
16451589
}
16461590

1647-
// Juga expose function ke global scope sebagai backup
1648-
window.closeTerminal = closeTerminal;
1649-
1650-
// Optional: Auto-test bila page load
1651-
setTimeout(() => {
1652-
const closeBtn = document.querySelector('.terminal-close-btn');
1653-
if (closeBtn) {
1654-
console.log('✅ Terminal close button is ready');
1655-
console.log('👉 Click me or press ESC to return to Azura AI');
1656-
}
1657-
}, 1000);
1658-
16591591
</script>
16601592
</body>
16611593
</html>

0 commit comments

Comments
 (0)