Update index.html
Browse files- index.html +82 -106
index.html
CHANGED
|
@@ -1,144 +1,120 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
-
<html lang="
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
<style>
|
| 9 |
-
/* Langkah 1: Atur halaman utama agar tidak bisa di-scroll dan ukurannya pas */
|
| 10 |
html, body {
|
| 11 |
margin: 0;
|
| 12 |
padding: 0;
|
| 13 |
width: 100%;
|
| 14 |
height: 100%;
|
| 15 |
-
overflow: hidden; /* PENTING! Mencegah scrollbar di halaman utama */
|
| 16 |
-
font-family: sans-serif;
|
| 17 |
-
}
|
| 18 |
-
|
| 19 |
-
/* Langkah 2: Paksa iframe untuk mengisi ruang yang sudah kita siapkan */
|
| 20 |
-
iframe {
|
| 21 |
-
width: 100%;
|
| 22 |
-
height: 100%; /* Mengisi 100% tinggi dari body */
|
| 23 |
-
border: none;
|
| 24 |
-
display: block;
|
| 25 |
}
|
| 26 |
-
|
| 27 |
-
/* Gaya untuk layar loading (sudah bagus) */
|
| 28 |
#loading {
|
| 29 |
position: fixed;
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
| 32 |
display: flex;
|
| 33 |
justify-content: center;
|
| 34 |
align-items: center;
|
| 35 |
-
|
| 36 |
-
font-size: 1.2em;
|
| 37 |
-
color: #333;
|
| 38 |
z-index: 1000;
|
| 39 |
-
transition: opacity 0.5s ease;
|
| 40 |
}
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
|
|
|
| 44 |
}
|
| 45 |
</style>
|
| 46 |
</head>
|
| 47 |
<body>
|
| 48 |
-
<div id="loading">
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
<!-- Iframe dengan izin yang benar untuk menghilangkan error di console -->
|
| 53 |
-
<iframe
|
| 54 |
-
id="chat-frame"
|
| 55 |
-
title="AI Chatbot Assistant"
|
| 56 |
-
allow="clipboard-write; autoplay; fullscreen">
|
| 57 |
-
</iframe>
|
| 58 |
|
| 59 |
<script>
|
| 60 |
-
(
|
| 61 |
-
|
| 62 |
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
const TIMEOUT_MS = 4000;
|
| 69 |
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
const
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
}
|
|
|
|
| 77 |
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
return performance.now() - startTime;
|
| 85 |
-
} catch (error) {
|
| 86 |
-
return Infinity;
|
| 87 |
-
} finally {
|
| 88 |
-
clearTimeout(timeoutId);
|
| 89 |
-
}
|
| 90 |
-
}
|
| 91 |
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
.filter(result => result.speed !== Infinity)
|
| 97 |
-
.sort((a, b) => a.speed - b.speed);
|
| 98 |
-
|
| 99 |
-
return reachableServers.length > 0 ? reachableServers[0].url : null;
|
| 100 |
-
}
|
| 101 |
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
sessionStorage.setItem(storageKey, chosenUrl);
|
| 112 |
-
} else {
|
| 113 |
-
throw new Error("Tidak dapat terhubung ke server manapun.");
|
| 114 |
-
}
|
| 115 |
-
}
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
finalUrl.searchParams.set('cb', Date.now());
|
| 121 |
-
iframe.src = finalUrl.toString();
|
| 122 |
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
};
|
| 126 |
-
|
| 127 |
-
iframe.onerror = () => {
|
| 128 |
-
console.error(`Gagal memuat iframe dari: ${iframe.src}`);
|
| 129 |
-
sessionStorage.removeItem(storageKey);
|
| 130 |
-
updateLoadingText("Koneksi gagal, mencoba server cadangan...");
|
| 131 |
-
setTimeout(loadChatApp, 1000);
|
| 132 |
-
};
|
| 133 |
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
-
|
| 141 |
-
|
| 142 |
</script>
|
| 143 |
</body>
|
| 144 |
-
</html>
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>llamameta/glm4.5-free-unlimited-chatbot</title>
|
| 7 |
+
|
| 8 |
+
<!-- Meta tags untuk mencegah caching halaman HTML -->
|
| 9 |
+
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
|
| 10 |
+
<meta http-equiv="Pragma" content="no-cache">
|
| 11 |
+
<meta http-equiv="Expires" content="0">
|
| 12 |
|
| 13 |
<style>
|
|
|
|
| 14 |
html, body {
|
| 15 |
margin: 0;
|
| 16 |
padding: 0;
|
| 17 |
width: 100%;
|
| 18 |
height: 100%;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
}
|
|
|
|
|
|
|
| 20 |
#loading {
|
| 21 |
position: fixed;
|
| 22 |
+
top: 0;
|
| 23 |
+
left: 0;
|
| 24 |
+
width: 100%;
|
| 25 |
+
height: 100%;
|
| 26 |
+
background: rgba(255, 255, 255, 0.8);
|
| 27 |
display: flex;
|
| 28 |
justify-content: center;
|
| 29 |
align-items: center;
|
| 30 |
+
font-size: 24px;
|
|
|
|
|
|
|
| 31 |
z-index: 1000;
|
|
|
|
| 32 |
}
|
| 33 |
+
iframe {
|
| 34 |
+
width: 100%;
|
| 35 |
+
height: 100vh;
|
| 36 |
+
border: none;
|
| 37 |
}
|
| 38 |
</style>
|
| 39 |
</head>
|
| 40 |
<body>
|
| 41 |
+
<div id="loading">Please wait Memilih server optimal...</div>
|
| 42 |
+
<iframe id="streamlit-frame" allow="clipboard-write; clipboard-read"
|
| 43 |
+
sandbox="allow-scripts allow-same-origin allow-forms allow-popups allow-modals"
|
| 44 |
+
style="width: 100%; height: 100%; border: none;"></iframe>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
<script>
|
| 47 |
+
// Ganti ini dengan versi baru setiap kali Anda update link SERVERS (misalnya "v2", "v3", dll.)
|
| 48 |
+
const VERSION = "v1"; // Ubah ini ke nilai baru untuk memaksa update (contoh: "v2" saat link berubah)
|
| 49 |
|
| 50 |
+
// Array server dengan link baru Anda (ganti sesuai kebutuhan)
|
| 51 |
+
const SERVERS = [
|
| 52 |
+
"https://glm45.balianone.workers.dev/?embed=true", // Ganti dengan link baru
|
| 53 |
+
"https://glm45.balianone.workers.dev/?embed=true" // Ganti dengan link baru
|
| 54 |
+
];
|
|
|
|
| 55 |
|
| 56 |
+
// Fungsi untuk mengecek kecepatan respons server (sama seperti sebelumnya, tapi tambah timeout)
|
| 57 |
+
async function checkServerSpeed(url) {
|
| 58 |
+
const start = performance.now();
|
| 59 |
+
try {
|
| 60 |
+
const response = await Promise.race([
|
| 61 |
+
fetch(url, { method: 'HEAD', mode: 'no-cors' }),
|
| 62 |
+
new Promise((_, reject) => setTimeout(() => reject(new Error('Timeout')), 5000)) // Timeout 5 detik
|
| 63 |
+
]);
|
| 64 |
+
const end = performance.now();
|
| 65 |
+
return end - start;
|
| 66 |
+
} catch (error) {
|
| 67 |
+
console.error(`Error checking ${url}:`, error);
|
| 68 |
+
return Infinity;
|
| 69 |
}
|
| 70 |
+
}
|
| 71 |
|
| 72 |
+
// Fungsi untuk memilih server berdasarkan kecepatan respons
|
| 73 |
+
async function chooseServer() {
|
| 74 |
+
const speeds = await Promise.all(SERVERS.map(checkServerSpeed));
|
| 75 |
+
const fastestIndex = speeds.indexOf(Math.min(...speeds));
|
| 76 |
+
return SERVERS[fastestIndex];
|
| 77 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
+
// Fungsi untuk memuat Streamlit
|
| 80 |
+
async function loadStreamlit() {
|
| 81 |
+
const loadingElement = document.getElementById('loading');
|
| 82 |
+
const iframe = document.getElementById('streamlit-frame');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
+
// Gunakan key sessionStorage dengan VERSION untuk cache busting
|
| 85 |
+
const storageKey = `streamlitUrl_${VERSION}`;
|
| 86 |
+
let chosenUrl = sessionStorage.getItem(storageKey);
|
| 87 |
|
| 88 |
+
if (!chosenUrl) {
|
| 89 |
+
// Jika belum ada atau version berubah, pilih server baru dan simpan
|
| 90 |
+
chosenUrl = await chooseServer();
|
| 91 |
+
sessionStorage.setItem(storageKey, chosenUrl);
|
| 92 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
+
// Tambahkan cache busting ke URL iframe (timestamp unik)
|
| 95 |
+
const cacheBuster = new Date().getTime(); // Timestamp untuk memaksa no-cache
|
| 96 |
+
const iframeSrc = `${chosenUrl}&cb=${cacheBuster}`; // Append ?cb=timestamp jika URL sudah punya query
|
|
|
|
|
|
|
| 97 |
|
| 98 |
+
// Set src iframe
|
| 99 |
+
iframe.src = iframeSrc;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
+
// Event onload untuk sembunyikan loading
|
| 102 |
+
iframe.onload = () => {
|
| 103 |
+
loadingElement.style.display = 'none';
|
| 104 |
+
};
|
| 105 |
+
|
| 106 |
+
// Fallback: Jika iframe gagal load (misalnya URL lama invalid), pilih ulang
|
| 107 |
+
iframe.onerror = async () => {
|
| 108 |
+
console.warn('Iframe load failed, rechoosing server...');
|
| 109 |
+
sessionStorage.removeItem(storageKey); // Hapus storage lama
|
| 110 |
+
chosenUrl = await chooseServer();
|
| 111 |
+
sessionStorage.setItem(storageKey, chosenUrl);
|
| 112 |
+
iframe.src = `${chosenUrl}&cb=${new Date().getTime()}`;
|
| 113 |
+
};
|
| 114 |
+
}
|
| 115 |
|
| 116 |
+
// Jalankan loadStreamlit saat halaman dimuat
|
| 117 |
+
window.onload = loadStreamlit;
|
| 118 |
</script>
|
| 119 |
</body>
|
| 120 |
+
</html>
|