Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +252 -258
templates/index.html
CHANGED
|
@@ -1,258 +1,252 @@
|
|
| 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>Gold Price Prediction System</title>
|
| 7 |
-
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
| 8 |
-
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
| 9 |
-
<style>
|
| 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 |
-
</div>
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
<
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
<
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
<div class="
|
| 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 |
-
<div
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
<footer
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
<td>
|
| 230 |
-
<td
|
| 231 |
-
|
| 232 |
-
${prediction.
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
function formatNumber(num) {
|
| 254 |
-
return new Intl.NumberFormat('id-ID').format(num);
|
| 255 |
-
}
|
| 256 |
-
</script>
|
| 257 |
-
</body>
|
| 258 |
-
</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>Gold Price Prediction System</title>
|
| 7 |
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" />
|
| 8 |
+
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet" />
|
| 9 |
+
<style>
|
| 10 |
+
.gradient-bg {
|
| 11 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 12 |
+
color: white;
|
| 13 |
+
}
|
| 14 |
+
.gold-accent {
|
| 15 |
+
color: #ffd700;
|
| 16 |
+
}
|
| 17 |
+
.prediction-card {
|
| 18 |
+
border: none;
|
| 19 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
| 20 |
+
transition: transform 0.3s ease;
|
| 21 |
+
}
|
| 22 |
+
.prediction-card:hover {
|
| 23 |
+
transform: translateY(-5px);
|
| 24 |
+
}
|
| 25 |
+
.price-up {
|
| 26 |
+
color: #28a745;
|
| 27 |
+
}
|
| 28 |
+
.price-down {
|
| 29 |
+
color: #dc3545;
|
| 30 |
+
}
|
| 31 |
+
.loading-spinner {
|
| 32 |
+
display: none;
|
| 33 |
+
}
|
| 34 |
+
.navbar-brand {
|
| 35 |
+
font-weight: bold;
|
| 36 |
+
}
|
| 37 |
+
.hero-section {
|
| 38 |
+
background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)),
|
| 39 |
+
url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 300"><defs><linearGradient id="grad" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" style="stop-color:%23FFD700;stop-opacity:0.3" /><stop offset="100%" style="stop-color:%23FFA500;stop-opacity:0.1" /></linearGradient></defs><rect width="1000" height="300" fill="url(%23grad)"/></svg>');
|
| 40 |
+
color: white;
|
| 41 |
+
padding: 100px 0;
|
| 42 |
+
}
|
| 43 |
+
</style>
|
| 44 |
+
</head>
|
| 45 |
+
<body>
|
| 46 |
+
<!-- Navigation -->
|
| 47 |
+
<nav class="navbar navbar-expand-lg navbar-dark gradient-bg">
|
| 48 |
+
<div class="container">
|
| 49 |
+
<a class="navbar-brand" href="#">
|
| 50 |
+
<i class="fas fa-coins gold-accent"></i>
|
| 51 |
+
Gold Price Predictor
|
| 52 |
+
</a>
|
| 53 |
+
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
|
| 54 |
+
<span class="navbar-toggler-icon"></span>
|
| 55 |
+
</button>
|
| 56 |
+
<div class="collapse navbar-collapse" id="navbarNav">
|
| 57 |
+
<ul class="navbar-nav ms-auto">
|
| 58 |
+
<li class="nav-item">
|
| 59 |
+
<a class="nav-link active" href="/">Home</a>
|
| 60 |
+
</li>
|
| 61 |
+
<li class="nav-item">
|
| 62 |
+
<a class="nav-link" href="/data-analysis">Data Analysis</a>
|
| 63 |
+
</li>
|
| 64 |
+
</ul>
|
| 65 |
+
</div>
|
| 66 |
+
</div>
|
| 67 |
+
</nav>
|
| 68 |
+
|
| 69 |
+
<!-- Hero Section -->
|
| 70 |
+
<section class="hero-section text-center">
|
| 71 |
+
<div class="container">
|
| 72 |
+
<h1 class="display-4 mb-4">
|
| 73 |
+
<i class="fas fa-chart-line gold-accent"></i>
|
| 74 |
+
Prediksi Harga Emas 7 Hari Kedepan
|
| 75 |
+
</h1>
|
| 76 |
+
<p class="lead mb-5">Sistem prediksi harga emas menggunakan Machine Learning dengan Linear Regression</p>
|
| 77 |
+
<button class="btn btn-warning btn-lg" onclick="predictGoldPrice()"><i class="fas fa-magic"></i> Prediksi Sekarang</button>
|
| 78 |
+
</div>
|
| 79 |
+
</section>
|
| 80 |
+
|
| 81 |
+
<!-- Main Content -->
|
| 82 |
+
<div class="container my-5">
|
| 83 |
+
<!-- Loading Spinner -->
|
| 84 |
+
<div class="text-center loading-spinner" id="loadingSpinner">
|
| 85 |
+
<div class="spinner-border text-warning" role="status" style="width: 3rem; height: 3rem">
|
| 86 |
+
<span class="visually-hidden">Loading...</span>
|
| 87 |
+
</div>
|
| 88 |
+
<p class="mt-3">Menganalisis data dan membuat prediksi...</p>
|
| 89 |
+
</div>
|
| 90 |
+
|
| 91 |
+
<!-- Results Section -->
|
| 92 |
+
<div id="resultsSection" style="display: none">
|
| 93 |
+
<!-- Current Prices -->
|
| 94 |
+
<div class="row mb-4">
|
| 95 |
+
<div class="col-md-6">
|
| 96 |
+
<div class="card prediction-card text-center">
|
| 97 |
+
<div class="card-body">
|
| 98 |
+
<h5 class="card-title"><i class="fas fa-clock"></i> Harga Saat Ini</h5>
|
| 99 |
+
<div id="currentPrices"></div>
|
| 100 |
+
</div>
|
| 101 |
+
</div>
|
| 102 |
+
</div>
|
| 103 |
+
<div class="col-md-6">
|
| 104 |
+
<div class="card prediction-card text-center">
|
| 105 |
+
<div class="card-body">
|
| 106 |
+
<h5 class="card-title"><i class="fas fa-trending-up"></i> Perkiraan Perubahan Total</h5>
|
| 107 |
+
<div id="totalChanges"></div>
|
| 108 |
+
</div>
|
| 109 |
+
</div>
|
| 110 |
+
</div>
|
| 111 |
+
</div> <!-- Prediction Chart -->
|
| 112 |
+
<div class="card prediction-card mb-4">
|
| 113 |
+
<div class="card-header">
|
| 114 |
+
<h5 class="mb-0"><i class="fas fa-chart-area"></i> Grafik Prediksi Harga Emas</h5>
|
| 115 |
+
</div>
|
| 116 |
+
<div class="card-body">
|
| 117 |
+
<div id="predictionChart"></div>
|
| 118 |
+
</div>
|
| 119 |
+
</div>
|
| 120 |
+
|
| 121 |
+
<!-- Predictions Table -->
|
| 122 |
+
<div class="card prediction-card">
|
| 123 |
+
<div class="card-header">
|
| 124 |
+
<h5 class="mb-0"><i class="fas fa-table"></i> Prediksi Harga 7 Hari Kedepan</h5>
|
| 125 |
+
</div>
|
| 126 |
+
<div class="card-body">
|
| 127 |
+
<div class="table-responsive">
|
| 128 |
+
<table class="table table-striped table-hover">
|
| 129 |
+
<thead class="table-dark">
|
| 130 |
+
<tr>
|
| 131 |
+
<th>Tanggal</th>
|
| 132 |
+
<th>Harga Tutup (IDR)</th>
|
| 133 |
+
<th>Perubahan Tutup (%)</th>
|
| 134 |
+
<th>Harga Buka (IDR)</th>
|
| 135 |
+
<th>Perubahan Buka (%)</th>
|
| 136 |
+
</tr>
|
| 137 |
+
</thead>
|
| 138 |
+
<tbody id="predictionsTable"></tbody>
|
| 139 |
+
</table>
|
| 140 |
+
</div>
|
| 141 |
+
</div>
|
| 142 |
+
</div>
|
| 143 |
+
</div>
|
| 144 |
+
|
| 145 |
+
<!-- Error Section -->
|
| 146 |
+
<div id="errorSection" style="display: none">
|
| 147 |
+
<div class="alert alert-danger text-center" role="alert">
|
| 148 |
+
<i class="fas fa-exclamation-triangle"></i>
|
| 149 |
+
<span id="errorMessage"></span>
|
| 150 |
+
</div>
|
| 151 |
+
</div>
|
| 152 |
+
</div>
|
| 153 |
+
|
| 154 |
+
<!-- Footer -->
|
| 155 |
+
<footer class="gradient-bg text-center py-4 mt-5">
|
| 156 |
+
<div class="container">
|
| 157 |
+
<p class="mb-0">© 2025 Kelompok 4 - Sistem Prediksi Harga Emas. Powered by Machine Learning.</p>
|
| 158 |
+
</div>
|
| 159 |
+
</footer>
|
| 160 |
+
|
| 161 |
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|
| 162 |
+
<script>
|
| 163 |
+
function predictGoldPrice() {
|
| 164 |
+
// Show loading spinner
|
| 165 |
+
document.getElementById("loadingSpinner").style.display = "block";
|
| 166 |
+
document.getElementById("resultsSection").style.display = "none";
|
| 167 |
+
document.getElementById("errorSection").style.display = "none";
|
| 168 |
+
|
| 169 |
+
// Make API call
|
| 170 |
+
fetch("/predict", {
|
| 171 |
+
method: "POST",
|
| 172 |
+
headers: {
|
| 173 |
+
"Content-Type": "application/json",
|
| 174 |
+
},
|
| 175 |
+
})
|
| 176 |
+
.then((response) => response.json())
|
| 177 |
+
.then((data) => {
|
| 178 |
+
document.getElementById("loadingSpinner").style.display = "none";
|
| 179 |
+
|
| 180 |
+
if (data.success) {
|
| 181 |
+
displayResults(data);
|
| 182 |
+
} else {
|
| 183 |
+
displayError(data.error || "Unknown error occurred");
|
| 184 |
+
}
|
| 185 |
+
})
|
| 186 |
+
.catch((error) => {
|
| 187 |
+
document.getElementById("loadingSpinner").style.display = "none";
|
| 188 |
+
displayError("Network error: " + error.message);
|
| 189 |
+
});
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
function displayResults(data) {
|
| 193 |
+
// Display current prices
|
| 194 |
+
const currentPricesHtml = `
|
| 195 |
+
<p class="mb-1"><strong>Harga Tutup:</strong> <span class="gold-accent">IDR ${data.current_prices.close.toLocaleString()}</span></p>
|
| 196 |
+
<p class="mb-0"><strong>Harga Buka:</strong> <span class="gold-accent">IDR ${data.current_prices.open.toLocaleString()}</span></p>
|
| 197 |
+
`;
|
| 198 |
+
document.getElementById("currentPrices").innerHTML = currentPricesHtml;
|
| 199 |
+
|
| 200 |
+
// Display total changes
|
| 201 |
+
const totalChangesHtml = `
|
| 202 |
+
<p class="mb-1"><strong>Tutup:</strong>
|
| 203 |
+
<span class="${data.total_changes.close >= 0 ? "price-up" : "price-down"}">
|
| 204 |
+
${data.total_changes.close >= 0 ? "+" : ""}${data.total_changes.close}%
|
| 205 |
+
<i class="fas fa-arrow-${data.total_changes.close >= 0 ? "up" : "down"}"></i>
|
| 206 |
+
</span>
|
| 207 |
+
</p>
|
| 208 |
+
<p class="mb-0"><strong>Buka:</strong>
|
| 209 |
+
<span class="${data.total_changes.open >= 0 ? "price-up" : "price-down"}">
|
| 210 |
+
${data.total_changes.open >= 0 ? "+" : ""}${data.total_changes.open}%
|
| 211 |
+
<i class="fas fa-arrow-${data.total_changes.open >= 0 ? "up" : "down"}"></i>
|
| 212 |
+
</span>
|
| 213 |
+
</p>
|
| 214 |
+
`;
|
| 215 |
+
document.getElementById("totalChanges").innerHTML = totalChangesHtml; // Display chart
|
| 216 |
+
document.getElementById("predictionChart").innerHTML = data.chart_html;
|
| 217 |
+
|
| 218 |
+
// Display predictions table
|
| 219 |
+
let tableHtml = "";
|
| 220 |
+
data.predictions.forEach((prediction) => {
|
| 221 |
+
tableHtml += `
|
| 222 |
+
<tr>
|
| 223 |
+
<td><strong>${prediction.date}</strong></td>
|
| 224 |
+
<td>IDR ${prediction.close_price.toLocaleString()}</td>
|
| 225 |
+
<td class="${prediction.close_change >= 0 ? "price-up" : "price-down"}">
|
| 226 |
+
${prediction.close_change >= 0 ? "+" : ""}${prediction.close_change}%
|
| 227 |
+
<i class="fas fa-arrow-${prediction.close_change >= 0 ? "up" : "down"}"></i>
|
| 228 |
+
</td>
|
| 229 |
+
<td>IDR ${prediction.open_price.toLocaleString()}</td>
|
| 230 |
+
<td class="${prediction.open_change >= 0 ? "price-up" : "price-down"}">
|
| 231 |
+
${prediction.open_change >= 0 ? "+" : ""}${prediction.open_change}%
|
| 232 |
+
<i class="fas fa-arrow-${prediction.open_change >= 0 ? "up" : "down"}"></i>
|
| 233 |
+
</td>
|
| 234 |
+
</tr>
|
| 235 |
+
`;
|
| 236 |
+
});
|
| 237 |
+
document.getElementById("predictionsTable").innerHTML = tableHtml;
|
| 238 |
+
|
| 239 |
+
document.getElementById("resultsSection").style.display = "block";
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
function displayError(errorMessage) {
|
| 243 |
+
document.getElementById("errorMessage").textContent = errorMessage;
|
| 244 |
+
document.getElementById("errorSection").style.display = "block";
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
function formatNumber(num) {
|
| 248 |
+
return new Intl.NumberFormat("id-ID").format(num);
|
| 249 |
+
}
|
| 250 |
+
</script>
|
| 251 |
+
</body>
|
| 252 |
+
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|