-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
624 lines (531 loc) · 24.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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
151
152
153
154
155
156
157
158
159
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Debt Tracker with Persistent Login</title>
<link rel="icon" type="image/png" href="fav.png">
<style>
/* Update success popup positioning */
.success-popup {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: rgba(129, 199, 132, 0.9);
color: #121212;
padding: 15px 20px;
border-radius: 12px;
font-weight: bold;
z-index: 2001;
display: none;
opacity: 0;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
backdrop-filter: blur(5px);
text-align: center;
width: 320px;
transition: opacity 0.3s ease-in-out;
}
/* All other styles remain exactly the same */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #121212;
font-family: Arial, sans-serif;
color: #ffffff;
}
.loading-screen {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #121212;
display: flex;
justify-content: center;
align-items: center;
z-index: 2000;
}
.loading-spinner {
width: 50px;
height: 50px;
border: 5px solid #333;
border-top: 5px solid #90caf9;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.container {
background: rgba(33, 33, 33, 0.9);
padding: 30px;
width: 320px;
border-radius: 15px;
box-shadow: 0px 10px 30px rgba(0, 0, 0, 0.7);
display: none;
}
.login-popup {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: rgba(48, 48, 48, 0.9);
padding: 20px;
width: 300px;
border-radius: 15px;
box-shadow: 0px 10px 30px rgba(0, 0, 0, 0.7);
text-align: center;
display: none;
}
.login-popup h2 {
color: #90caf9;
margin-bottom: 20px;
}
.login-popup input {
width: 80%;
padding: 10px;
margin: 10px 0;
border-radius: 5px;
border: none;
}
.login-popup button {
background-color: #90caf9;
color: #121212;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
font-weight: bold;
margin-top: 10px;
}
.agreement-text {
margin-top: 15px;
font-size: 12px;
color: #ffffff;
text-align: center;
}
.agreement-link {
color: #90caf9;
text-decoration: underline;
cursor: pointer;
}
.agreement-popup {
display: none;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: rgba(48, 48, 48, 0.95);
padding: 30px;
width: 80%;
max-width: 600px;
max-height: 80vh;
border-radius: 15px;
box-shadow: 0px 10px 30px rgba(0, 0, 0, 0.7);
overflow-y: auto;
z-index: 1000;
}
.agreement-popup h2 {
color: #90caf9;
margin-bottom: 20px;
}
.agreement-popup p {
margin-bottom: 15px;
line-height: 1.6;
}
.close-button {
position: absolute;
top: 15px;
right: 15px;
background: none;
border: none;
color: #ffffff;
font-size: 24px;
cursor: pointer;
}
.overlay {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.7);
z-index: 999;
}
.total {
font-size: 26px;
font-weight: bold;
color: #90caf9;
text-align: center;
margin-bottom: 20px;
}
.transactions {
display: flex;
flex-direction: column;
gap: 12px;
}
.transaction {
display: flex;
justify-content: space-between;
padding: 12px;
border-radius: 10px;
background: rgba(48, 48, 48, 0.8);
box-shadow: 0px 4px 15px rgba(0, 0, 0, 0.5);
transition: transform 0.2s;
}
.transaction.debt div:first-child {
color: #e57373;
font-weight: bold;
}
.transaction.payment div:first-child {
color: #81c784;
font-weight: bold;
}
.show-button {
background-color: #90caf9;
color: #121212;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
font-weight: bold;
text-align: center;
margin-top: 15px;
}
.logout-button {
background-color: #e57373;
color: #ffffff;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
font-weight: bold;
margin-top: 15px;
}
.maintenance-banner {
position: fixed;
top: 20px;
left: 50%;
transform: translateX(-50%);
width: 320px;
background-color: rgba(255, 223, 0, 0.7);
color: #121212;
text-align: center;
padding: 15px 20px;
font-weight: bold;
z-index: 2001;
display: none;
cursor: pointer;
border-radius: 12px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
backdrop-filter: blur(5px);
transition: transform 0.2s ease;
}
.maintenance-banner:hover {
transform: translateX(-50%) scale(1.02);
}
.agreement-text {
margin-top: 15px;
font-size: 12px;
color: #ffffff;
text-align: center;
}
.agreement-link {
color: #90caf9;
text-decoration: underline;
cursor: pointer;
}
</style>
</head>
<body>
<!-- Success Popup -->
<div id="success-popup" class="success-popup">
Password reset email sent successfully!
</div>
<!-- Rest of the HTML remains exactly the same -->
<!-- Maintenance Banner -->
<div id="maintenance-banner" class="maintenance-banner">
Site under maintenance
</div>
<!-- Loading Screen -->
<div id="loading-screen" class="loading-screen">
<div class="loading-spinner"></div>
</div>
<!-- Login Popup -->
<div id="login-popup" class="login-popup">
<h2>Login</h2>
<form id="login-form">
<input type="email" id="email" placeholder="Email" autocomplete="username" required />
<input type="password" id="password" placeholder="Password" autocomplete="current-password" required />
<button type="button" id="loginButton">Login</button>
<button type="button" id="googleLoginButton">Login with Google</button>
<button type="button" id="forgotPasswordButton" class="forgot-password">Forgot Password?</button>
</form>
<div id="login-error" style="color: red; margin-top: 10px;"></div>
<div class="agreement-text">
By using the service, you accept our<br>
<span class="agreement-link" onclick="showAgreement()">User Agreement</span>
</div>
</div>
<!-- User Agreement Popup -->
<div id="agreement-popup" class="agreement-popup">
<button class="close-button" onclick="hideAgreement()">×</button>
<h2>User Agreement</h2>
<div id="agreement-content" style="white-space: pre-line">
A magyar verzióhoz görgessen
User Agreement for debts.matee.xyz
This agreement applies to the use of debts.matee.xyz. By using the website, users agree to the terms and conditions outlined below and acknowledge the purpose and operation of the system.
Technical Requirements
To use debts.matee.xyz, your browser must support JavaScript. Please ensure JavaScript is enabled for the best experience on the website.
Positive Balance
If a user has a positive balance, it means that Máté Kovács owes them money. The system keeps track of the amount and the date of the transaction. However, if the user wishes to reclaim their money, they must contact Máté Kovács personally or via email at hello@matee.xyz. The website serves only as a platform for tracking amounts and does not handle requests for repayment automatically.
Negative Balance
If a user has a negative balance, it means they owe money to Máté Kovács. In this case, the user is obligated to repay the debt within thirty (30) days. Failure to do so may result in a loss of trust and may affect future financial interactions.
Additionally, on the 12th of each month, an extra 5% of the outstanding balance will be added to the total owed amount. This penalty applies automatically and continues to accrue until the debt is fully repaid. Users can view the details of their debt, including the amount, date, and accrued penalties, on debts.matee.xyz.
Transaction Details
The system records and displays the amount and date of transactions. If a user wants to know additional details, such as the purpose of a transaction, they must contact Máté Kovács at hello@matee.xyz. This is the only way to request further information.
Account Information
Login information for debts.matee.xyz is securely encrypted and stored in Google Firebase. Users can update their email address or password by visiting accounts.matee.xyz, logging in, and selecting the relevant options. Note that if the user changes their email address, they will no longer be able to log in using Google, as it is tied to the previous email address.
General Provisions
Users acknowledge that debts.matee.xyz is solely a personal tracking tool for Máté Kovács and is not a legal or official financial tool. By using the website, users agree to adhere to the terms outlined in this agreement and respect the obligations associated with their balances.
By using debts.matee.xyz, users confirm that they understand and accept this user agreement.
Felhasználói Megállapodás a debts.matee.xyz Weboldalhoz
Ez a megállapodás a debts.matee.xyz weboldal használatára vonatkozik. A weboldal használatával a felhasználó elfogadja az alábbi feltételeket, és kijelenti, hogy megérti a rendszer célját és működését.
Technikai Követelmények
A debts.matee.xyz használatához a böngészőnek támogatnia kell a JavaScriptet. Kérjük, hogy engedélyezze a JavaScriptet a weboldal zökkenőmentes használatához.
Pozitív Egyenleg
Amennyiben a felhasználó pozitív egyenleggel rendelkezik, az azt jelenti, hogy Kovács Máté tartozik neki pénzzel. A rendszer automatikusan nyilvántartja az összeget és a tranzakció dátumát. Amennyiben a felhasználó szeretné visszakapni a pénzét, személyesen vagy e-mailben kell felvennie a kapcsolatot Kovács Mátéval a hello@matee.xyz címen. A weboldal kizárólag az adatok nyilvántartására szolgál, és nem kezeli automatikusan a visszafizetési kéréseket.
Negatív Egyenleg
Amennyiben a felhasználó negatív egyenleggel rendelkezik, az azt jelenti, hogy pénzzel tartozik Kovács Máténak. Ebben az esetben a felhasználó köteles a tartozását harminc (30) napon belül visszafizetni. A határidő elmulasztása bizalomvesztést eredményezhet, és negatívan befolyásolhatja a jövőbeni pénzügyi kapcsolatokat.
Továbbá, minden hónap 12-én a fennálló tartozásra 5%-os pótdíj kerül felszámításra. Ez a büntetés automatikusan hozzáadódik a teljes tartozáshoz, és addig halmozódik, amíg az adósság teljes egészében ki nem egyenlítésre kerül. A felhasználók a debts.matee.xyz oldalon megtekinthetik tartozásuk részleteit, beleértve az összeget, a tranzakció dátumát és a felhalmozott pótdíjakat.
Tranzakciók Részletei
A rendszer rögzíti és megjeleníti a tranzakciók összegét és dátumát. Amennyiben a felhasználó további részletekre, például a tranzakció céljára kíváncsi, kapcsolatba kell lépnie Kovács Mátéval a hello@matee.xyz e-mail címen. Ez az egyetlen módja annak, hogy további információhoz jusson.
Fiókadatok Kezelése
A debts.matee.xyz oldalon tárolt bejelentkezési adatok szigorúan titkosítva vannak, és a Google Firebase rendszerében kerülnek tárolásra. A felhasználók módosíthatják e-mail címüket vagy jelszavukat a accounts.matee.xyz oldalon, ahol bejelentkezés után kiválaszthatják a megfelelő lehetőségeket. Fontos megjegyezni, hogy ha a felhasználó megváltoztatja e-mail címét, akkor nem fog tudni bejelentkezni Google-fiókjával, mivel az a korábbi e-mail címhez van társítva.
Általános Rendelkezések
A felhasználó tudomásul veszi, hogy a debts.matee.xyz kizárólag Kovács Máté személyes pénzügyeinek nyomon követésére szolgál, és nem minősül hivatalos vagy jogi eszköznek. A weboldal használatával a felhasználó elfogadja a jelen megállapodásban foglaltakat, és tiszteletben tartja az egyenlegeivel kapcsolatos kötelezettségeit.
A debts.matee.xyz használatával a felhasználó kijelenti, hogy megértette és elfogadta a jelen felhasználói megállapodást. </div>
</div>
<!-- Overlay -->
<div id="overlay" class="overlay" onclick="hideAgreement()"></div>
<!-- Main Container (hidden until login) -->
<div class="container" id="main-container">
<div id="total-debt" class="total">Loading...</div>
<div id="transaction-list" class="transactions"></div>
<button id="toggle-transactions-button" class="show-button">Show All</button>
<!-- Logout Button -->
<button id="logout-button" class="logout-button">Log Out</button>
</div>
<script type="module">
// JavaScript code remains exactly the same
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.0.0/firebase-app.js";
import { getAuth, signInWithEmailAndPassword, signInWithPopup, GoogleAuthProvider, onAuthStateChanged, signOut, sendPasswordResetEmail } from "https://www.gstatic.com/firebasejs/9.0.0/firebase-auth.js";
import { getFirestore, collection, getDocs } from "https://www.gstatic.com/firebasejs/9.0.0/firebase-firestore.js";
import { getDatabase, ref, onValue } from "https://www.gstatic.com/firebasejs/9.0.0/firebase-database.js";
const firebaseConfig = {
apiKey: "AIzaSyDl6hnUPdneEuC9emWbELvYoplR8vWhEsA",
authDomain: "debts-92f72.firebaseapp.com",
projectId: "debts-92f72",
storageBucket: "debts-92f72.appspot.com",
messagingSenderId: "904817355212",
appId: "1:904817355212:web:fd6837ba25f57d0ec6d569",
databaseURL: "https://debts-92f72-default-rtdb.europe-west1.firebasedatabase.app"
};
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
const auth = getAuth(app);
const rtdb = getDatabase(app);
// Check maintenance status
const maintenanceRef = ref(rtdb, 'maintenance');
const banner = document.getElementById('maintenance-banner');
let currentMaintenanceValue = 0;
onValue(maintenanceRef, (snapshot) => {
currentMaintenanceValue = snapshot.val();
if (currentMaintenanceValue === 1 && !isAgreementVisible()) {
banner.style.display = 'block';
} else {
banner.style.display = 'none';
}
});
// Add click handler to hide banner
banner.addEventListener('click', () => {
banner.style.display = 'none';
});
// Handle forgot password with improved success popup
document.getElementById("forgotPasswordButton").addEventListener("click", async () => {
const email = document.getElementById("email").value;
const loginError = document.getElementById("login-error");
const successPopup = document.getElementById("success-popup");
if (!email) {
loginError.innerText = "Please enter your email address.";
return;
}
try {
// Show loading screen while sending email
document.getElementById("loading-screen").style.display = "flex";
await sendPasswordResetEmail(auth, email);
// Hide loading screen
document.getElementById("loading-screen").style.display = "none";
// Clear any previous error
loginError.innerText = "";
// Show success popup with fade in
successPopup.style.display = 'block';
// Force a reflow to ensure the transition works
successPopup.offsetHeight;
successPopup.style.opacity = '1';
document.getElementById("password").value = "";
// Hide the popup after 3 seconds with a fade effect
setTimeout(() => {
successPopup.style.opacity = '0';
setTimeout(() => {
successPopup.style.display = 'none';
}, 300); // Wait for the fade out transition
}, 6000);
} catch (error) {
// Hide loading screen
document.getElementById("loading-screen").style.display = "none";
console.error("Password reset error:", error);
loginError.innerText = "Error sending reset email. Please check your email address.";
}
});
// Handle persistent login
onAuthStateChanged(auth, (user) => {
if (user) {
document.getElementById("loading-screen").style.display = "none";
document.getElementById("login-popup").style.display = "none";
document.getElementById("main-container").style.display = "block";
loadTransactions(user.uid);
} else {
document.getElementById("loading-screen").style.display = "none";
document.getElementById("login-popup").style.display = "block";
document.getElementById("main-container").style.display = "none";
}
});
// Handle email login
document.getElementById("loginButton").addEventListener("click", login);
// Handle Google login
document.getElementById("googleLoginButton").addEventListener("click", loginWithGoogle);
// Handle logout
document.getElementById("logout-button").addEventListener("click", logout);
async function login() {
const email = document.getElementById("email").value;
const password = document.getElementById("password").value;
const loginError = document.getElementById("login-error");
try {
const userCredential = await signInWithEmailAndPassword(auth, email, password);
const user = userCredential.user;
document.getElementById("login-popup").style.display = "none";
document.getElementById("main-container").style.display = "block";
loadTransactions(user.uid);
} catch (error) {
console.error("Login error:", error);
loginError.innerText = "Invalid email or password.";
}
}
async function loginWithGoogle() {
const provider = new GoogleAuthProvider();
try {
const result = await signInWithPopup(auth, provider);
const user = result.user;
document.getElementById("login-popup").style.display = "none";
document.getElementById("main-container").style.display = "block";
loadTransactions(user.uid);
} catch (error) {
console.error("Google Login error:", error);
}
}
async function logout() {
try {
await signOut(auth);
document.getElementById("login-popup").style.display = "block";
document.getElementById("main-container").style.display = "none";
} catch (error) {
console.error("Logout error:", error);
}
}
const TRANSACTION_LIMIT = 5;
let allTransactions = [];
let toggleButton = document.getElementById("toggle-transactions-button");
async function loadTransactions(uid) {
const transactionsRef = collection(db, uid);
try {
const transactionSnapshot = await getDocs(transactionsRef);
let totalDebt = 0;
allTransactions = [];
transactionSnapshot.forEach((doc) => {
const data = doc.data();
const type = data.type.replace(/^"|"$/g, '');
const date = data.date.replace(/^"|"$/g, '');
const amount = Number(data.amount);
allTransactions.push({ ...data, type, date });
if (type === "debt") {
totalDebt -= amount;
} else if (type === "payment") {
totalDebt += amount;
}
});
document.getElementById("total-debt").innerText = `${totalDebt.toFixed(0)} Ft`;
// Remove existing event listener if it exists
toggleButton.removeEventListener('click', toggleTransactions);
// Add new event listener
toggleButton.addEventListener('click', toggleTransactions);
// Display first few transactions
displayTransactions(TRANSACTION_LIMIT);
toggleButton.innerText = "Show All";
} catch (error) {
console.error("Error loading transactions:", error);
}
}
function toggleTransactions() {
if (toggleButton.innerText === "Show All") {
displayTransactions(allTransactions.length);
toggleButton.innerText = "Show Less";
} else {
displayTransactions(TRANSACTION_LIMIT);
toggleButton.innerText = "Show All";
}
}
function displayTransactions(limit) {
const transactions = allTransactions.slice(0, limit);
const transactionList = document.getElementById("transaction-list");
transactionList.innerHTML = ""; // Clear existing transactions
transactions.forEach(transaction => {
const transactionElement = document.createElement("div");
transactionElement.className = `transaction ${transaction.type}`;
transactionElement.innerHTML = `
<div>${transaction.type === "debt" ? '-' : '+'} ${transaction.amount} Ft</div>
<div>${transaction.date}</div>
`;
transactionList.appendChild(transactionElement);
});
}
// Make functions available globally
window.showAgreement = function() {
document.getElementById('agreement-popup').style.display = 'block';
document.getElementById('overlay').style.display = 'block';
banner.style.display = 'none';
};
window.hideAgreement = function() {
document.getElementById('agreement-popup').style.display = 'none';
document.getElementById('overlay').style.display = 'none';
// Check current maintenance value
if (currentMaintenanceValue === 1) {
banner.style.display = 'block';
}
};
function isAgreementVisible() {
return document.getElementById('agreement-popup').style.display === 'block';
}
</script>
</body>
</html>