1915| }); 1916| 1917| // ── Detect Environment ── 1918| const IS_GITHUB_PAGES = window.location.hostname.includes('github.io'); 1919| const BACKEND_HOST = '116.203.180.240'; 1920| const BACKEND_PORT = '8000'; 1921| // When served from HTTPS (GitHub Pages), the browser blocks mixed-content HTTP requests. 1922| // For full production use, set up a proper domain with SSL cert on the backend. 1923| // For now: GitHub Pages redirects to the live backend directly. 1924| const API_BASE = IS_GITHUB_PAGES 1925| ? 'http://' + BACKEND_HOST + ':' + BACKEND_PORT + '/api' 1926| : '/api'; 1927| const APP_URL = '//' + BACKEND_HOST + ':' + BACKEND_PORT; 1928| 1929| // ── Analysis handler ── 1930| const form = document.getElementById('analyze-form'); 1931| const urlInput = document.getElementById('url-input'); 1932| const resultsSection = document.getElementById('results'); 1933| const loadingSection = document.getElementById('loading'); 1934| const resultsContent = document.getElementById('results-content'); 1935| const errorSection = document.getElementById('error'); 1936| const errorMessage = document.getElementById('error-message'); 1937| 1938| form.addEventListener('submit', function(e) { 1939| e.preventDefault(); 1940| // On GitHub Pages, redirect to the live backend directly 1941| if (IS_GITHUB_PAGES) { 1942| window.location.href = 'http://' + BACKEND_HOST + ':' + BACKEND_PORT + '/?url=' + encodeURIComponent(urlInput.value); 1943| return; 1944| } 1945|