Spaces:
Running
Running
Add 2 files
Browse files- README.md +7 -5
- index.html +471 -19
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: middagsplanlegger
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: gray
|
| 5 |
+
colorTo: gray
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,471 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>Middagsplanlegger</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<style>
|
| 10 |
+
@keyframes shake {
|
| 11 |
+
0%, 100% { transform: translateX(0); }
|
| 12 |
+
10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
|
| 13 |
+
20%, 40%, 60%, 80% { transform: translateX(5px); }
|
| 14 |
+
}
|
| 15 |
+
.shake {
|
| 16 |
+
animation: shake 0.5s;
|
| 17 |
+
}
|
| 18 |
+
.star-rating {
|
| 19 |
+
display: inline-flex;
|
| 20 |
+
direction: rtl;
|
| 21 |
+
}
|
| 22 |
+
.star-rating input {
|
| 23 |
+
display: none;
|
| 24 |
+
}
|
| 25 |
+
.star-rating label {
|
| 26 |
+
color: #d1d5db;
|
| 27 |
+
font-size: 1.5rem;
|
| 28 |
+
padding: 0 0.1rem;
|
| 29 |
+
cursor: pointer;
|
| 30 |
+
}
|
| 31 |
+
.star-rating input:checked ~ label,
|
| 32 |
+
.star-rating label:hover,
|
| 33 |
+
.star-rating label:hover ~ label {
|
| 34 |
+
color: #f59e0b;
|
| 35 |
+
}
|
| 36 |
+
</style>
|
| 37 |
+
</head>
|
| 38 |
+
<body class="bg-gray-100 min-h-screen">
|
| 39 |
+
<!-- Login Page (shown by default) -->
|
| 40 |
+
<div id="loginPage" class="flex items-center justify-center min-h-screen">
|
| 41 |
+
<div class="bg-white rounded-xl shadow-lg p-8 w-full max-w-md">
|
| 42 |
+
<div class="text-center mb-8">
|
| 43 |
+
<i class="fas fa-utensils text-5xl text-green-500 mb-4"></i>
|
| 44 |
+
<h1 class="text-3xl font-bold text-gray-800">Middagsplanlegger</title>
|
| 45 |
+
<p class="text-gray-600 mt-2">Planlegg ukens middager</p>
|
| 46 |
+
</div>
|
| 47 |
+
|
| 48 |
+
<form id="loginForm" class="space-y-6">
|
| 49 |
+
<div>
|
| 50 |
+
<label for="password" class="block text-sm font-medium text-gray-700 mb-1">Tilgangskode</label>
|
| 51 |
+
<div class="relative">
|
| 52 |
+
<input
|
| 53 |
+
type="password"
|
| 54 |
+
id="password"
|
| 55 |
+
name="password"
|
| 56 |
+
required
|
| 57 |
+
class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-green-500 transition"
|
| 58 |
+
placeholder="Skriv inn koden"
|
| 59 |
+
>
|
| 60 |
+
<button
|
| 61 |
+
type="button"
|
| 62 |
+
id="togglePassword"
|
| 63 |
+
class="absolute right-3 top-3 text-gray-400 hover:text-gray-600"
|
| 64 |
+
>
|
| 65 |
+
<i class="fas fa-eye"></i>
|
| 66 |
+
</button>
|
| 67 |
+
</div>
|
| 68 |
+
<p id="errorMessage" class="text-red-500 text-sm mt-2 hidden">
|
| 69 |
+
Feil kode, prøv igjen
|
| 70 |
+
</p>
|
| 71 |
+
</div>
|
| 72 |
+
|
| 73 |
+
<button
|
| 74 |
+
type="submit"
|
| 75 |
+
class="w-full bg-green-500 hover:bg-green-600 text-white font-medium py-3 px-4 rounded-lg transition duration-200 flex items-center justify-center"
|
| 76 |
+
>
|
| 77 |
+
<i class="fas fa-sign-in-alt mr-2"></i> Logg inn
|
| 78 |
+
</button>
|
| 79 |
+
|
| 80 |
+
<div class="text-center text-sm text-gray-500">
|
| 81 |
+
<p>Kontakt administrator for tilgangskode</p>
|
| 82 |
+
</div>
|
| 83 |
+
</form>
|
| 84 |
+
</div>
|
| 85 |
+
</div>
|
| 86 |
+
|
| 87 |
+
<!-- Middagsplanlegger App (hidden by default) -->
|
| 88 |
+
<div id="appPage" class="hidden p-6 max-w-4xl mx-auto">
|
| 89 |
+
<header class="mb-8 text-center">
|
| 90 |
+
<h1 class="text-3xl font-bold text-gray-800 flex items-center justify-center">
|
| 91 |
+
<i class="fas fa-utensils text-green-500 mr-3"></i> Middagsplanlegger
|
| 92 |
+
</h1>
|
| 93 |
+
<p class="text-gray-600 mt-2">Planlegg ukens middager og vurder rettene</p>
|
| 94 |
+
</header>
|
| 95 |
+
|
| 96 |
+
<div class="bg-white rounded-xl shadow-lg p-6 mb-8">
|
| 97 |
+
<h2 class="text-xl font-semibold text-gray-700 mb-4">Ukens middager</h2>
|
| 98 |
+
|
| 99 |
+
<div class="space-y-4">
|
| 100 |
+
<!-- Monday -->
|
| 101 |
+
<div class="flex flex-col sm:flex-row items-start sm:items-center gap-4">
|
| 102 |
+
<label class="w-24 font-medium text-gray-700">Mandag:</label>
|
| 103 |
+
<input type="text" id="monday" class="flex-1 px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-green-500 transition" placeholder="Hva skal vi spise?">
|
| 104 |
+
</div>
|
| 105 |
+
|
| 106 |
+
<!-- Tuesday -->
|
| 107 |
+
<div class="flex flex-col sm:flex-row items-start sm:items-center gap-4">
|
| 108 |
+
<label class="w-24 font-medium text-gray-700">Tirsdag:</label>
|
| 109 |
+
<input type="text" id="tuesday" class="flex-1 px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-green-500 transition" placeholder="Hva skal vi spise?">
|
| 110 |
+
</div>
|
| 111 |
+
|
| 112 |
+
<!-- Wednesday -->
|
| 113 |
+
<div class="flex flex-col sm:flex-row items-start sm:items-center gap-4">
|
| 114 |
+
<label class="w-24 font-medium text-gray-700">Onsdag:</label>
|
| 115 |
+
<input type="text" id="wednesday" class="flex-1 px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-green-500 transition" placeholder="Hva skal vi spise?">
|
| 116 |
+
</div>
|
| 117 |
+
|
| 118 |
+
<!-- Thursday -->
|
| 119 |
+
<div class="flex flex-col sm:flex-row items-start sm:items-center gap-4">
|
| 120 |
+
<label class="w-24 font-medium text-gray-700">Torsdag:</label>
|
| 121 |
+
<input type="text" id="thursday" class="flex-1 px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-green-500 transition" placeholder="Hva skal vi spise?">
|
| 122 |
+
</div>
|
| 123 |
+
|
| 124 |
+
<!-- Friday -->
|
| 125 |
+
<div class="flex flex-col sm:flex-row items-start sm:items-center gap-4">
|
| 126 |
+
<label class="w-24 font-medium text-gray-700">Fredag:</label>
|
| 127 |
+
<input type="text" id="friday" class="flex-1 px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-green-500 transition" placeholder="Hva skal vi spise?">
|
| 128 |
+
</div>
|
| 129 |
+
|
| 130 |
+
<!-- Saturday -->
|
| 131 |
+
<div class="flex flex-col sm:flex-row items-start sm:items-center gap-4">
|
| 132 |
+
<label class="w-24 font-medium text-gray-700">Lørdag:</label>
|
| 133 |
+
<input type="text" id="saturday" class="flex-1 px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-green-500 transition" placeholder="Hva skal vi spise?">
|
| 134 |
+
</div>
|
| 135 |
+
|
| 136 |
+
<!-- Sunday -->
|
| 137 |
+
<div class="flex flex-col sm:flex-row items-start sm:items-center gap-4">
|
| 138 |
+
<label class="w-24 font-medium text-gray-700">Søndag:</label>
|
| 139 |
+
<input type="text" id="sunday" class="flex-1 px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-green-500 transition" placeholder="Hva skal vi spise?">
|
| 140 |
+
</div>
|
| 141 |
+
</div>
|
| 142 |
+
|
| 143 |
+
<div class="mt-6 flex justify-end">
|
| 144 |
+
<button id="saveBtn" class="bg-green-500 hover:bg-green-600 text-white font-medium py-2 px-6 rounded-lg transition duration-200 flex items-center">
|
| 145 |
+
<i class="fas fa-save mr-2"></i> Lagre plan
|
| 146 |
+
</button>
|
| 147 |
+
</div>
|
| 148 |
+
</div>
|
| 149 |
+
|
| 150 |
+
<div class="bg-white rounded-xl shadow-lg p-6 mb-8">
|
| 151 |
+
<h2 class="text-xl font-semibold text-gray-700 mb-4">Denne ukens middager</h2>
|
| 152 |
+
|
| 153 |
+
<div id="dinnersList" class="space-y-6">
|
| 154 |
+
<!-- This will be populated with JavaScript -->
|
| 155 |
+
<p class="text-gray-500 italic">Ingen middager lagt til ennå</p>
|
| 156 |
+
</div>
|
| 157 |
+
|
| 158 |
+
<div id="ratingSummary" class="mt-4 pt-4 border-t border-gray-200 hidden">
|
| 159 |
+
<h3 class="font-medium text-gray-700 mb-2">Gjennomsnittlig vurdering:</h3>
|
| 160 |
+
<div id="averageRating" class="text-yellow-500 text-xl"></div>
|
| 161 |
+
</div>
|
| 162 |
+
</div>
|
| 163 |
+
|
| 164 |
+
<div class="bg-white rounded-xl shadow-lg p-6">
|
| 165 |
+
<h2 class="text-xl font-semibold text-gray-700 mb-4">Inspirasjon</h2>
|
| 166 |
+
|
| 167 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
| 168 |
+
<a href="https://vegetarmat.org//" target="_blank" class="bg-green-50 hover:bg-green-100 p-4 rounded-lg transition flex items-center">
|
| 169 |
+
<i class="fas fa-leaf text-green-500 text-2xl mr-3"></i>
|
| 170 |
+
<div>
|
| 171 |
+
<h3 class="font-medium text-gray-800">Vegetarmat.no</h3>
|
| 172 |
+
<p class="text-sm text-gray-600">Vegetariske oppskrifter</p>
|
| 173 |
+
</div>
|
| 174 |
+
</a>
|
| 175 |
+
|
| 176 |
+
<a href="https://www.godfisk.no/oppskrifter/" target="_blank" class="bg-blue-50 hover:bg-blue-100 p-4 rounded-lg transition flex items-center">
|
| 177 |
+
<i class="fas fa-fish text-blue-500 text-2xl mr-3"></i>
|
| 178 |
+
<div>
|
| 179 |
+
<h3 class="font-medium text-gray-800">Godfisk</h3>
|
| 180 |
+
<p class="text-sm text-gray-600">Pescetariske oppskrifter</p>
|
| 181 |
+
</div>
|
| 182 |
+
</a>
|
| 183 |
+
</div>
|
| 184 |
+
</div>
|
| 185 |
+
</div>
|
| 186 |
+
|
| 187 |
+
<script>
|
| 188 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 189 |
+
const loginForm = document.getElementById('loginForm');
|
| 190 |
+
const passwordInput = document.getElementById('password');
|
| 191 |
+
const togglePassword = document.getElementById('togglePassword');
|
| 192 |
+
const errorMessage = document.getElementById('errorMessage');
|
| 193 |
+
const loginPage = document.getElementById('loginPage');
|
| 194 |
+
const appPage = document.getElementById('appPage');
|
| 195 |
+
const correctPassword = '1555'; // Hardcoded password for demo
|
| 196 |
+
|
| 197 |
+
// Toggle password visibility
|
| 198 |
+
togglePassword.addEventListener('click', function() {
|
| 199 |
+
const type = passwordInput.getAttribute('type') === 'password' ? 'text' : 'password';
|
| 200 |
+
passwordInput.setAttribute('type', type);
|
| 201 |
+
this.innerHTML = type === 'password' ? '<i class="fas fa-eye"></i>' : '<i class="fas fa-eye-slash"></i>';
|
| 202 |
+
});
|
| 203 |
+
|
| 204 |
+
// Form submission
|
| 205 |
+
loginForm.addEventListener('submit', function(e) {
|
| 206 |
+
e.preventDefault();
|
| 207 |
+
|
| 208 |
+
const enteredPassword = passwordInput.value.trim();
|
| 209 |
+
|
| 210 |
+
if (enteredPassword === correctPassword) {
|
| 211 |
+
// Successful login - show the app
|
| 212 |
+
errorMessage.classList.add('hidden');
|
| 213 |
+
passwordInput.classList.remove('border-red-500');
|
| 214 |
+
|
| 215 |
+
// Hide login and show app
|
| 216 |
+
loginPage.classList.add('hidden');
|
| 217 |
+
appPage.classList.remove('hidden');
|
| 218 |
+
|
| 219 |
+
// Load any saved data
|
| 220 |
+
loadSavedData();
|
| 221 |
+
} else {
|
| 222 |
+
// Failed login
|
| 223 |
+
errorMessage.classList.remove('hidden');
|
| 224 |
+
passwordInput.classList.add('border-red-500');
|
| 225 |
+
loginForm.classList.add('shake');
|
| 226 |
+
|
| 227 |
+
// Remove shake class after animation completes
|
| 228 |
+
setTimeout(() => {
|
| 229 |
+
loginForm.classList.remove('shake');
|
| 230 |
+
}, 500);
|
| 231 |
+
|
| 232 |
+
// Focus and select the password field
|
| 233 |
+
passwordInput.focus();
|
| 234 |
+
passwordInput.select();
|
| 235 |
+
}
|
| 236 |
+
});
|
| 237 |
+
|
| 238 |
+
// Clear error when typing
|
| 239 |
+
passwordInput.addEventListener('input', function() {
|
| 240 |
+
errorMessage.classList.add('hidden');
|
| 241 |
+
this.classList.remove('border-red-500');
|
| 242 |
+
});
|
| 243 |
+
|
| 244 |
+
// Save button functionality
|
| 245 |
+
document.getElementById('saveBtn').addEventListener('click', function() {
|
| 246 |
+
saveData();
|
| 247 |
+
updateDinnersList();
|
| 248 |
+
});
|
| 249 |
+
|
| 250 |
+
// Function to save data to localStorage
|
| 251 |
+
function saveData() {
|
| 252 |
+
const weekData = {
|
| 253 |
+
monday: {
|
| 254 |
+
meal: document.getElementById('monday').value,
|
| 255 |
+
rating: 0 // Ratings are now handled separately
|
| 256 |
+
},
|
| 257 |
+
tuesday: {
|
| 258 |
+
meal: document.getElementById('tuesday').value,
|
| 259 |
+
rating: 0
|
| 260 |
+
},
|
| 261 |
+
wednesday: {
|
| 262 |
+
meal: document.getElementById('wednesday').value,
|
| 263 |
+
rating: 0
|
| 264 |
+
},
|
| 265 |
+
thursday: {
|
| 266 |
+
meal: document.getElementById('thursday').value,
|
| 267 |
+
rating: 0
|
| 268 |
+
},
|
| 269 |
+
friday: {
|
| 270 |
+
meal: document.getElementById('friday').value,
|
| 271 |
+
rating: 0
|
| 272 |
+
},
|
| 273 |
+
saturday: {
|
| 274 |
+
meal: document.getElementById('saturday').value,
|
| 275 |
+
rating: 0
|
| 276 |
+
},
|
| 277 |
+
sunday: {
|
| 278 |
+
meal: document.getElementById('sunday').value,
|
| 279 |
+
rating: 0
|
| 280 |
+
}
|
| 281 |
+
};
|
| 282 |
+
|
| 283 |
+
localStorage.setItem('middagsplanlegger', JSON.stringify(weekData));
|
| 284 |
+
|
| 285 |
+
// Show a temporary success message
|
| 286 |
+
const btn = this;
|
| 287 |
+
const originalText = btn.innerHTML;
|
| 288 |
+
btn.innerHTML = '<i class="fas fa-check mr-2"></i> Lagret!';
|
| 289 |
+
btn.classList.remove('bg-green-500');
|
| 290 |
+
btn.classList.add('bg-green-600');
|
| 291 |
+
|
| 292 |
+
setTimeout(() => {
|
| 293 |
+
btn.innerHTML = originalText;
|
| 294 |
+
btn.classList.remove('bg-green-600');
|
| 295 |
+
btn.classList.add('bg-green-500');
|
| 296 |
+
}, 2000);
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
// Function to load saved data from localStorage
|
| 300 |
+
function loadSavedData() {
|
| 301 |
+
const savedData = localStorage.getItem('middagsplanlegger');
|
| 302 |
+
if (savedData) {
|
| 303 |
+
const weekData = JSON.parse(savedData);
|
| 304 |
+
|
| 305 |
+
// Populate the form fields
|
| 306 |
+
document.getElementById('monday').value = weekData.monday.meal || '';
|
| 307 |
+
document.getElementById('tuesday').value = weekData.tuesday.meal || '';
|
| 308 |
+
document.getElementById('wednesday').value = weekData.wednesday.meal || '';
|
| 309 |
+
document.getElementById('thursday').value = weekData.thursday.meal || '';
|
| 310 |
+
document.getElementById('friday').value = weekData.friday.meal || '';
|
| 311 |
+
document.getElementById('saturday').value = weekData.saturday.meal || '';
|
| 312 |
+
document.getElementById('sunday').value = weekData.sunday.meal || '';
|
| 313 |
+
|
| 314 |
+
// Update the dinners list
|
| 315 |
+
updateDinnersList();
|
| 316 |
+
}
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
// Function to update the dinners list display
|
| 320 |
+
function updateDinnersList() {
|
| 321 |
+
const dinnersList = document.getElementById('dinnersList');
|
| 322 |
+
const ratingSummary = document.getElementById('ratingSummary');
|
| 323 |
+
const averageRating = document.getElementById('averageRating');
|
| 324 |
+
const savedData = localStorage.getItem('middagsplanlegger');
|
| 325 |
+
|
| 326 |
+
if (!savedData) {
|
| 327 |
+
dinnersList.innerHTML = '<p class="text-gray-500 italic">Ingen middager lagt til ennå</p>';
|
| 328 |
+
ratingSummary.classList.add('hidden');
|
| 329 |
+
return;
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
const weekData = JSON.parse(savedData);
|
| 333 |
+
let hasMeals = false;
|
| 334 |
+
let html = '';
|
| 335 |
+
let totalRatings = 0;
|
| 336 |
+
let ratedMeals = 0;
|
| 337 |
+
|
| 338 |
+
const days = [
|
| 339 |
+
{ name: 'Mandag', key: 'monday' },
|
| 340 |
+
{ name: 'Tirsdag', key: 'tuesday' },
|
| 341 |
+
{ name: 'Onsdag', key: 'wednesday' },
|
| 342 |
+
{ name: 'Torsdag', key: 'thursday' },
|
| 343 |
+
{ name: 'Fredag', key: 'friday' },
|
| 344 |
+
{ name: 'Lørdag', key: 'saturday' },
|
| 345 |
+
{ name: 'Søndag', key: 'sunday' }
|
| 346 |
+
];
|
| 347 |
+
|
| 348 |
+
days.forEach(day => {
|
| 349 |
+
const mealData = weekData[day.key];
|
| 350 |
+
if (mealData.meal) {
|
| 351 |
+
hasMeals = true;
|
| 352 |
+
|
| 353 |
+
// Create rating HTML for each meal
|
| 354 |
+
let ratingHtml = '';
|
| 355 |
+
if (mealData.rating > 0) {
|
| 356 |
+
ratingHtml = `
|
| 357 |
+
<div class="mt-2">
|
| 358 |
+
<span class="text-yellow-500">
|
| 359 |
+
${'★'.repeat(mealData.rating)}${'☆'.repeat(5 - mealData.rating)}
|
| 360 |
+
</span>
|
| 361 |
+
<span class="text-sm text-gray-500 ml-2">${mealData.rating} av 5</span>
|
| 362 |
+
</div>
|
| 363 |
+
`;
|
| 364 |
+
totalRatings += parseInt(mealData.rating);
|
| 365 |
+
ratedMeals++;
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
html += `
|
| 369 |
+
<div class="border-b border-gray-100 pb-4 last:border-0">
|
| 370 |
+
<div class="flex justify-between items-start">
|
| 371 |
+
<div>
|
| 372 |
+
<p class="font-medium">${day.name}: ${mealData.meal}</p>
|
| 373 |
+
${ratingHtml}
|
| 374 |
+
</div>
|
| 375 |
+
<div class="flex items-center gap-2">
|
| 376 |
+
<div class="star-rating">
|
| 377 |
+
<input type="radio" id="${day.key}-5" name="${day.key}-rating" value="5">
|
| 378 |
+
<label for="${day.key}-5">★</label>
|
| 379 |
+
<input type="radio" id="${day.key}-4" name="${day.key}-rating" value="4">
|
| 380 |
+
<label for="${day.key}-4">★</label>
|
| 381 |
+
<input type="radio" id="${day.key}-3" name="${day.key}-rating" value="3">
|
| 382 |
+
<label for="${day.key}-3">★</label>
|
| 383 |
+
<input type="radio" id="${day.key}-2" name="${day.key}-rating" value="2">
|
| 384 |
+
<label for="${day.key}-2">★</label>
|
| 385 |
+
<input type="radio" id="${day.key}-1" name="${day.key}-rating" value="1">
|
| 386 |
+
<label for="${day.key}-1">★</label>
|
| 387 |
+
</div>
|
| 388 |
+
<button
|
| 389 |
+
onclick="rateMeal('${day.key}')"
|
| 390 |
+
class="bg-blue-500 hover:bg-blue-600 text-white text-sm font-medium py-1 px-3 rounded transition duration-200"
|
| 391 |
+
>
|
| 392 |
+
Rate
|
| 393 |
+
</button>
|
| 394 |
+
</div>
|
| 395 |
+
</div>
|
| 396 |
+
</div>
|
| 397 |
+
`;
|
| 398 |
+
}
|
| 399 |
+
});
|
| 400 |
+
|
| 401 |
+
if (!hasMeals) {
|
| 402 |
+
html = '<p class="text-gray-500 italic">Ingen middager lagt til ennå</p>';
|
| 403 |
+
ratingSummary.classList.add('hidden');
|
| 404 |
+
} else {
|
| 405 |
+
// Calculate and show average rating if there are any rated meals
|
| 406 |
+
if (ratedMeals > 0) {
|
| 407 |
+
const avgRating = (totalRatings / ratedMeals).toFixed(1);
|
| 408 |
+
averageRating.innerHTML = `${avgRating} av 5`;
|
| 409 |
+
|
| 410 |
+
// Create visual stars for average rating
|
| 411 |
+
const fullStars = Math.floor(avgRating);
|
| 412 |
+
const hasHalfStar = (avgRating % 1) >= 0.5;
|
| 413 |
+
let starsHtml = '';
|
| 414 |
+
|
| 415 |
+
for (let i = 0; i < fullStars; i++) {
|
| 416 |
+
starsHtml += '★';
|
| 417 |
+
}
|
| 418 |
+
if (hasHalfStar) {
|
| 419 |
+
starsHtml += '½';
|
| 420 |
+
}
|
| 421 |
+
const emptyStars = 5 - fullStars - (hasHalfStar ? 1 : 0);
|
| 422 |
+
for (let i = 0; i < emptyStars; i++) {
|
| 423 |
+
starsHtml += '☆';
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
averageRating.innerHTML += ` ${starsHtml}`;
|
| 427 |
+
ratingSummary.classList.remove('hidden');
|
| 428 |
+
} else {
|
| 429 |
+
ratingSummary.classList.add('hidden');
|
| 430 |
+
}
|
| 431 |
+
}
|
| 432 |
+
|
| 433 |
+
dinnersList.innerHTML = html;
|
| 434 |
+
}
|
| 435 |
+
|
| 436 |
+
// Add rateMeal function to the window object so it can be called from inline onclick
|
| 437 |
+
window.rateMeal = function(dayKey) {
|
| 438 |
+
const selectedRating = document.querySelector(`input[name="${dayKey}-rating"]:checked`);
|
| 439 |
+
if (!selectedRating) {
|
| 440 |
+
alert('Velg en vurdering først!');
|
| 441 |
+
return;
|
| 442 |
+
}
|
| 443 |
+
|
| 444 |
+
const rating = parseInt(selectedRating.value);
|
| 445 |
+
const savedData = localStorage.getItem('middagsplanlegger');
|
| 446 |
+
if (savedData) {
|
| 447 |
+
const weekData = JSON.parse(savedData);
|
| 448 |
+
weekData[dayKey].rating = rating;
|
| 449 |
+
localStorage.setItem('middagsplanlegger', JSON.stringify(weekData));
|
| 450 |
+
|
| 451 |
+
// Update the display
|
| 452 |
+
updateDinnersList();
|
| 453 |
+
|
| 454 |
+
// Show a temporary success message
|
| 455 |
+
const rateBtn = selectedRating.closest('div').querySelector('button');
|
| 456 |
+
const originalText = rateBtn.innerHTML;
|
| 457 |
+
rateBtn.innerHTML = '<i class="fas fa-check mr-1"></i> Lagret';
|
| 458 |
+
rateBtn.classList.remove('bg-blue-500');
|
| 459 |
+
rateBtn.classList.add('bg-green-500');
|
| 460 |
+
|
| 461 |
+
setTimeout(() => {
|
| 462 |
+
rateBtn.innerHTML = 'Rate';
|
| 463 |
+
rateBtn.classList.remove('bg-green-500');
|
| 464 |
+
rateBtn.classList.add('bg-blue-500');
|
| 465 |
+
}, 2000);
|
| 466 |
+
}
|
| 467 |
+
};
|
| 468 |
+
});
|
| 469 |
+
</script>
|
| 470 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=oyvsar/middagsplanlegger" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 471 |
+
</html>
|