function acceptTerms() {
// Show loading state
document.querySelector('.buttons').style.display = 'none';
document.querySelector('.loading').style.display = 'block';
// Get the realm name from the URL if it was passed
const urlParams = new URLSearchParams(window.location.search);
const realm = urlParams.get('realm') || 'test-mobile';
// Use the same hostname as the current page to support Android emulator (10.0.2.2)
const keycloakHost = window.location.hostname;
const keycloakPort = 8080;
// Redirect to the complete-onboarding endpoint
// The mobile app will intercept this URL
window.location.href = `http://${keycloakHost}:${keycloakPort}/realms/${realm}/complete-onboarding`;
}
function declineTerms() {
// In production, this might redirect to your app's cancel flow
// For testing, we'll just show an alert and redirect to a cancel page
if (confirm('Are you sure you want to decline? You will not be able to complete registration.')) {
// Redirect to app cancel URL (mobile app should handle this)
window.location.href = 'myapp://oauth/cancel';
// Fallback for testing in browser
setTimeout(() => {
window.location.href = 'error.html?reason=declined';
}, 1000);
}
}
// Log page load for debugging
console.log('Preview page loaded');
console.log('Current URL:', window.location.href);
// Check if we have realm parameter
const urlParams = new URLSearchParams(window.location.search);
console.log('Realm:', urlParams.get('realm') || 'test-mobile (default)');