Repository navigation
Expand file tree
/
Copy pathnews.html
More file actions
220 lines (193 loc) · 5.18 KB
/
Copy pathnews.html
File metadata and controls
220 lines (193 loc) · 5.18 KB
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
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>اخبار - برای ایران</title>
<link href="src/tailwind.min.css" rel="stylesheet">
<link href="src/font-face.css" rel="stylesheet">
<link href="src/main-style.css" rel="stylesheet">
<style>
@font-face {
font-family: 'Vazir';
src: url('src/Vazir-Bold.woff2') format('woff2');
}
body {
font-family: 'Vazir', sans-serif;
background-color: #f9f9f9;
padding: 1rem;
}
.news-item {
padding: 1rem;
border-bottom: 1px solid #ddd;
display: flex;
flex-direction: column;
background: #fff;
border-radius: 0.75rem;
margin-bottom: 1rem;
box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.news-item.important .blinker {
width: 10px;
height: 10px;
background-color: red;
border-radius: 50%;
margin-left: 0.5rem;
animation: blink 1s infinite;
display: inline-block;
}
.news-title {
display: flex;
align-items: center;
font-weight: bold;
font-size: 1.1rem;
color: #1e3a8a;
}
.news-time {
font-size: 0.9rem;
color: #666;
margin-top: 0.25rem;
direction: ltr;
text-align: left;
}
@keyframes blink {
0%, 100% { opacity: 1; }
50% { opacity: 0; }
}
/* Header and Footer Styles */
.min-h-screen {
min-height: 100vh;
}
.bg-blue-900 {
background-color: #1e3a8a;
}
.bg-blue-600 {
background-color: rgba(30, 58, 138, 0.9);
}
.backdrop-blur-sm {
backdrop-filter: blur(10px);
}
.text-white {
color: #ffffff;
}
.shadow-md {
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}
.z-10 {
z-index: 10;
}
/* Container for header, main, and footer */
.container {
max-width: 1200px;
margin-left: auto;
margin-right: auto;
padding-left: 1rem;
padding-right: 1rem;
}
/* Flex utilities */
.flex {
display: flex;
}
.flex-1 {
flex: 1;
}
/* Overflow utilities */
.overflow-hidden {
overflow: hidden;
}
.overflow-y-auto {
overflow-y: auto;
}
/* Margin utilities */
.mt-20 {
margin-top: 5rem;
}
.mb-20 {
margin-bottom: 5rem;
}
/* Padding utilities */
.px-6 {
padding-left: 1.5rem;
padding-right: 1.5rem;
}
.py-4 {
padding-top: 1rem;
padding-bottom: 1rem;
}
/* Text utilities */
.text-center {
text-align: center;
}
.text-sm {
font-size: 0.875rem;
}
/* Link utilities */
.hover\:text-blue-200:hover {
color: #bfdbfe;
}
/* Transition utilities */
.transition {
transition: all 0.3s ease;
}
@media (max-width: 600px) {
.news-item {
padding: 0.7rem;
font-size: 0.95rem;
}
.news-title {
font-size: 1rem;
}
.news-time {
font-size: 0.85rem;
}
main {
margin-top: 60px !important;
margin-bottom: 60px !important;
padding: 0.2rem 0;
}
}
</style>
</head>
<body class="min-h-screen text-gray-800 flex flex-col">
<header id="main-header"></header>
<main class="container mx-auto px-6 py-20 flex-1 overflow-y-auto main-spacing">
<h1 class="text-center my-4">📢 آخرین اخبار</h1>
<div id="news-container"></div>
<div class="text-center mt-8">
<a href="index.html" class="inline-block bg-blue-600 text-white px-6 py-2 rounded-lg btn hover:bg-blue-700">بازگشت به صفحه اصلی</a>
</div>
</main>
<footer id="main-footer"></footer>
<script src="src/common-header-footer.js"></script>
<script>
fetch('json/news.json')
.then(response => response.json())
.then(newsList => {
newsList.sort((a, b) => new Date(b.datetime) - new Date(a.datetime));
const container = document.getElementById('news-container');
newsList.forEach(news => {
const div = document.createElement('div');
div.className = 'news-item' + (news.important ? ' important' : '');
const dateObj = new Date(news.datetime);
const faTime = new Intl.DateTimeFormat('fa-IR-u-ca-persian', {
dateStyle: 'medium',
timeStyle: 'short'
}).format(dateObj);
div.innerHTML = `
<div class="news-title">
${news.important ? '<span class="blinker"></span>' : ''}
${news.title}
</div>
<div class="news-time">${faTime}</div>
${news.text ? `<div class='mt-2 text-gray-700'>${news.text}</div>` : ''}
${news.source ? `<div class='mt-2 text-xs text-gray-500'>منبع: ${news.source}</div>` : ''}
`;
container.appendChild(div);
});
})
.catch(error => {
document.getElementById('news-container').innerHTML = '<p>خطا در بارگذاری خبرها</p>';
});
</script>
</body>
</html>