Spaces:
Paused
Paused
Update templates/index.html
Browse files- templates/index.html +25 -24
templates/index.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>تست سیستم اعتبار با تایمر</title>
|
| 7 |
<style>
|
| 8 |
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;700&display=swap');
|
| 9 |
body {
|
|
@@ -21,8 +21,7 @@
|
|
| 21 |
padding: 40px;
|
| 22 |
background-color: white;
|
| 23 |
border-radius: 12px;
|
| 24 |
-
box-shadow: 0 4px
|
| 25 |
-
20px rgba(0,0,0,0.1);
|
| 26 |
width: 90%;
|
| 27 |
max-width: 500px;
|
| 28 |
}
|
|
@@ -55,7 +54,6 @@
|
|
| 55 |
.success { color: #28a745; }
|
| 56 |
.error { color: #dc3545; }
|
| 57 |
|
| 58 |
-
/* --- استایلهای جدید برای تایمر --- */
|
| 59 |
@keyframes fadeIn {
|
| 60 |
from { opacity: 0; transform: translateY(10px); }
|
| 61 |
to { opacity: 1; transform: translateY(0); }
|
|
@@ -66,34 +64,34 @@
|
|
| 66 |
}
|
| 67 |
|
| 68 |
#countdown-timer {
|
| 69 |
-
display: none;
|
| 70 |
margin-top: 20px;
|
| 71 |
padding: 15px;
|
| 72 |
-
background-color: #
|
| 73 |
border-radius: 8px;
|
| 74 |
-
border: 1px solid #
|
| 75 |
animation: fadeIn 0.5s ease;
|
| 76 |
}
|
| 77 |
.timer-content {
|
| 78 |
display: flex;
|
| 79 |
align-items: center;
|
| 80 |
justify-content: center;
|
| 81 |
-
gap:
|
| 82 |
}
|
| 83 |
.clock-icon {
|
| 84 |
-
width:
|
| 85 |
-
height:
|
| 86 |
-
animation: spin
|
|
|
|
| 87 |
}
|
| 88 |
#time-left {
|
| 89 |
font-size: 1.2rem;
|
| 90 |
font-weight: 700;
|
| 91 |
-
color: #
|
| 92 |
-
direction: ltr; /* برای نمایش صحیح اعداد */
|
| 93 |
}
|
| 94 |
.timer-text {
|
| 95 |
font-size: 0.9rem;
|
| 96 |
-
color: #
|
| 97 |
}
|
| 98 |
</style>
|
| 99 |
</head>
|
|
@@ -103,12 +101,11 @@
|
|
| 103 |
<button id="action-button">استفاده از یک اعتبار</button>
|
| 104 |
<p id="status">برای شروع روی دکمه کلیک کنید.</p>
|
| 105 |
|
| 106 |
-
<!-- کانتینر جدید برای تایمر شمارش معکوس -->
|
| 107 |
<div id="countdown-timer">
|
| 108 |
<div class="timer-content">
|
| 109 |
-
<svg class="clock-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#
|
| 110 |
<div>
|
| 111 |
-
<div id="time-left">
|
| 112 |
<div class="timer-text">زمان باقیمانده تا دریافت ۵ اعتبار رایگان</div>
|
| 113 |
</div>
|
| 114 |
</div>
|
|
@@ -149,7 +146,7 @@
|
|
| 149 |
if (countdownInterval) clearInterval(countdownInterval);
|
| 150 |
countdownContainer.style.display = 'block';
|
| 151 |
|
| 152 |
-
|
| 153 |
const now = Date.now() / 1000;
|
| 154 |
const timeLeft = Math.max(0, resetTimestamp - now);
|
| 155 |
|
|
@@ -167,13 +164,17 @@
|
|
| 167 |
const minutes = Math.floor((timeLeft % 3600) / 60);
|
| 168 |
const seconds = Math.floor(timeLeft % 60);
|
| 169 |
|
| 170 |
-
let
|
| 171 |
-
if (days > 0)
|
| 172 |
-
|
|
|
|
|
|
|
| 173 |
|
| 174 |
-
timeLeftDisplay.textContent =
|
| 175 |
-
|
| 176 |
-
|
|
|
|
|
|
|
| 177 |
}
|
| 178 |
|
| 179 |
actionButton.addEventListener('click', async () => {
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>تست سیستم اعتبار با تایمر فارسی</title>
|
| 7 |
<style>
|
| 8 |
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;700&display=swap');
|
| 9 |
body {
|
|
|
|
| 21 |
padding: 40px;
|
| 22 |
background-color: white;
|
| 23 |
border-radius: 12px;
|
| 24 |
+
box-shadow: 0 4px 20px rgba(0,0,0,0.1);
|
|
|
|
| 25 |
width: 90%;
|
| 26 |
max-width: 500px;
|
| 27 |
}
|
|
|
|
| 54 |
.success { color: #28a745; }
|
| 55 |
.error { color: #dc3545; }
|
| 56 |
|
|
|
|
| 57 |
@keyframes fadeIn {
|
| 58 |
from { opacity: 0; transform: translateY(10px); }
|
| 59 |
to { opacity: 1; transform: translateY(0); }
|
|
|
|
| 64 |
}
|
| 65 |
|
| 66 |
#countdown-timer {
|
| 67 |
+
display: none;
|
| 68 |
margin-top: 20px;
|
| 69 |
padding: 15px;
|
| 70 |
+
background-color: #fff9e6;
|
| 71 |
border-radius: 8px;
|
| 72 |
+
border: 1px solid #ffeeba;
|
| 73 |
animation: fadeIn 0.5s ease;
|
| 74 |
}
|
| 75 |
.timer-content {
|
| 76 |
display: flex;
|
| 77 |
align-items: center;
|
| 78 |
justify-content: center;
|
| 79 |
+
gap: 12px;
|
| 80 |
}
|
| 81 |
.clock-icon {
|
| 82 |
+
width: 28px;
|
| 83 |
+
height: 28px;
|
| 84 |
+
animation: spin 20s linear infinite;
|
| 85 |
+
flex-shrink: 0;
|
| 86 |
}
|
| 87 |
#time-left {
|
| 88 |
font-size: 1.2rem;
|
| 89 |
font-weight: 700;
|
| 90 |
+
color: #856404;
|
|
|
|
| 91 |
}
|
| 92 |
.timer-text {
|
| 93 |
font-size: 0.9rem;
|
| 94 |
+
color: #856404;
|
| 95 |
}
|
| 96 |
</style>
|
| 97 |
</head>
|
|
|
|
| 101 |
<button id="action-button">استفاده از یک اعتبار</button>
|
| 102 |
<p id="status">برای شروع روی دکمه کلیک کنید.</p>
|
| 103 |
|
|
|
|
| 104 |
<div id="countdown-timer">
|
| 105 |
<div class="timer-content">
|
| 106 |
+
<svg class="clock-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#856404"><path d="M12 2C6.486 2 2 6.486 2 12s4.486 10 10 10 10-4.486 10-10S17.514 2 12 2zm0 18c-4.411 0-8-3.589-8-8s3.589-8 8-8 8 3.589 8 8-3.589 8-8 8z"></path><path d="M13 7h-2v6l5.25 3.15.75-1.23-4.5-2.67z"></path></svg>
|
| 107 |
<div>
|
| 108 |
+
<div id="time-left">...</div>
|
| 109 |
<div class="timer-text">زمان باقیمانده تا دریافت ۵ اعتبار رایگان</div>
|
| 110 |
</div>
|
| 111 |
</div>
|
|
|
|
| 146 |
if (countdownInterval) clearInterval(countdownInterval);
|
| 147 |
countdownContainer.style.display = 'block';
|
| 148 |
|
| 149 |
+
const updateTimer = () => {
|
| 150 |
const now = Date.now() / 1000;
|
| 151 |
const timeLeft = Math.max(0, resetTimestamp - now);
|
| 152 |
|
|
|
|
| 164 |
const minutes = Math.floor((timeLeft % 3600) / 60);
|
| 165 |
const seconds = Math.floor(timeLeft % 60);
|
| 166 |
|
| 167 |
+
let parts = [];
|
| 168 |
+
if (days > 0) parts.push(`${days} روز`);
|
| 169 |
+
if (hours > 0) parts.push(`${hours} ساعت`);
|
| 170 |
+
if (minutes > 0) parts.push(`${minutes} دقیقه`);
|
| 171 |
+
if (seconds > 0) parts.push(`${seconds} ثانیه`);
|
| 172 |
|
| 173 |
+
timeLeftDisplay.textContent = parts.slice(0, 3).join(' و '); // نمایش حداکثر سه بخش
|
| 174 |
+
};
|
| 175 |
+
|
| 176 |
+
updateTimer(); // فراخوانی اولیه
|
| 177 |
+
countdownInterval = setInterval(updateTimer, 1000);
|
| 178 |
}
|
| 179 |
|
| 180 |
actionButton.addEventListener('click', async () => {
|