AnesKAM commited on
Commit
72a44c3
·
verified ·
1 Parent(s): 3263fad

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +186 -57
index.html CHANGED
@@ -3,87 +3,216 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>نتائج البحث - SurfGO</title>
 
 
7
  <style>
8
- body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #f8f9fa; margin: 0; padding: 20px; }
9
- .container { max-width: 800px; margin: auto; }
10
- .search-info { margin-bottom: 20px; color: #555; font-size: 0.9em; }
11
- .result-item { background: white; padding: 15px; border-radius: 8px; margin-bottom: 15px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
12
- .result-item a { color: #1a0dab; text-decoration: none; font-size: 1.2em; }
13
- .result-item a:hover { text-decoration: underline; }
14
- .result-item .url { color: #006621; font-size: 0.85em; display: block; margin-top: 2px; word-break: break-all; }
15
- .result-item .content { color: #4d5156; margin-top: 8px; line-height: 1.4; }
16
- .loading { text-align: center; padding: 50px; font-weight: bold; color: #007bff; }
17
- .error { color: red; text-align: center; padding: 20px; }
18
- .no-results { text-align: center; padding: 20px; color: #777; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </style>
20
  </head>
21
  <body>
22
 
 
 
 
 
 
 
 
23
  <div class="container">
24
- <h2 id="query-title">جاري البحث عن...</h2>
25
- <div id="results-container">
26
- <div class="loading">انتظر قليلاً، جاري جلب النتائج من سيرفر OpenShift...</div>
 
 
 
 
 
 
 
 
 
 
27
  </div>
28
  </div>
29
 
30
  <script>
31
- // 1. استخراج كلمة البحث من الرابط (URL Parameters)
32
  const urlParams = new URLSearchParams(window.location.search);
33
  const query = urlParams.get('q');
34
- const category = urlParams.get('categories') || 'general';
35
-
36
- if (query) {
37
- document.getElementById('query-title').innerText = `نتائج البحث عن: ${query}`;
38
- fetchResults(query, category);
39
- } else {
40
- document.getElementById('results-container').innerHTML = '<div class="error">لم يتم إدخال كلمة بحث!</div>';
41
  }
42
 
43
- async function fetchResults(query, cat) {
44
- const resultsContainer = document.getElementById('results-container');
45
-
46
- // رابط سيرفرك الأصلي
47
- const targetUrl = `https://searxng-anesnt-dev.apps.rm1.0a51.p1.openshiftapps.com/search?q=${encodeURIComponent(query)}&format=json&categories=${cat}&language=ar&safesearch=1`;
48
-
49
- // استخدام بروكسي AllOrigins لتجاوز CORS
50
- const proxyUrl = `https://api.allorigins.win/get?url=${encodeURIComponent(targetUrl)}`;
 
 
 
 
51
 
52
  try {
53
  const response = await fetch(proxyUrl);
54
- if (!response.ok) throw new Error("فشل في الاتصال بالبروكسي");
55
 
56
  const data = await response.json();
57
- // تحويل البيانات من نص إلى JSON
58
- const searchData = JSON.parse(data.contents);
59
-
60
- resultsContainer.innerHTML = ''; // تنظيف شاشة التحميل
61
-
62
- if (searchData.results && searchData.results.length > 0) {
63
- searchData.results.forEach(item => {
64
- const resultHtml = `
65
- <div class="result-item">
66
- <a href="${item.url}" target="_blank">${item.title}</a>
67
- <span class="url">${item.url}</span>
68
- <div class="content">${item.content || 'لا يوجد وصف متاح.'}</div>
69
- </div>
70
- `;
71
- resultsContainer.innerHTML += resultHtml;
72
- });
73
- } else {
74
- resultsContainer.innerHTML = '<div class="no-results">لم نجد أي نتائج لهذه الكلمة.</div>';
75
  }
76
 
 
 
 
 
 
 
 
 
 
 
 
77
  } catch (error) {
78
- console.error("Error:", error);
79
- resultsContainer.innerHTML = `
80
- <div class="error">
81
- حدث خطأ أثناء جلب البيانات.<br>
82
- تأكد أن سيرفر OpenShift يعمل أو جرب لاحقاً.<br>
83
- <small>${error.message}</small>
84
- </div>`;
85
  }
86
  }
 
 
 
87
  </script>
88
 
89
  </body>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>نتائج بحث SurfGO</title>
7
+ <!-- استيراد خط Tajawal من جوجل -->
8
+ <link href="https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700&display=swap" rel="stylesheet">
9
  <style>
10
+ :root {
11
+ --primary-color: #4285f4;
12
+ --bg-color: #f8f9fa;
13
+ --card-bg: #ffffff;
14
+ --text-main: #202124;
15
+ --text-muted: #4d5156;
16
+ --link-color: #1a0dab;
17
+ --url-color: #006621;
18
+ }
19
+
20
+ body {
21
+ font-family: 'Tajawal', sans-serif;
22
+ background-color: var(--bg-color);
23
+ color: var(--text-main);
24
+ margin: 0;
25
+ padding: 0;
26
+ line-height: 1.6;
27
+ }
28
+
29
+ /* رأس الصفحة */
30
+ header {
31
+ background: var(--card-bg);
32
+ padding: 20px;
33
+ box-shadow: 0 1px 6px rgba(32,33,36,0.1);
34
+ position: sticky;
35
+ top: 0;
36
+ z-index: 1000;
37
+ }
38
+
39
+ .header-content {
40
+ max-width: 1000px;
41
+ margin: 0 auto;
42
+ display: flex;
43
+ align-items: center;
44
+ gap: 20px;
45
+ }
46
+
47
+ .logo {
48
+ font-size: 24px;
49
+ font-weight: 700;
50
+ color: var(--primary-color);
51
+ text-decoration: none;
52
+ }
53
+
54
+ /* حاوية النتائج */
55
+ .container {
56
+ max-width: 800px;
57
+ margin: 30px auto;
58
+ padding: 0 20px;
59
+ }
60
+
61
+ .stats {
62
+ font-size: 14px;
63
+ color: var(--text-muted);
64
+ margin-bottom: 20px;
65
+ }
66
+
67
+ /* تصميم بطاقة النتيجة */
68
+ .result-card {
69
+ background: var(--card-bg);
70
+ padding: 18px;
71
+ border-radius: 12px;
72
+ margin-bottom: 20px;
73
+ transition: transform 0.2s, box-shadow 0.2s;
74
+ border: 1px solid transparent;
75
+ }
76
+
77
+ .result-card:hover {
78
+ transform: translateY(-2px);
79
+ box-shadow: 0 4px 12px rgba(0,0,0,0.08);
80
+ border-color: #e0e0e0;
81
+ }
82
+
83
+ .result-card a {
84
+ text-decoration: none;
85
+ color: var(--link-color);
86
+ font-size: 1.25rem;
87
+ font-weight: 500;
88
+ display: block;
89
+ margin-bottom: 4px;
90
+ }
91
+
92
+ .result-card a:hover {
93
+ text-decoration: underline;
94
+ }
95
+
96
+ .result-card .cite {
97
+ font-size: 13px;
98
+ color: var(--url-color);
99
+ margin-bottom: 10px;
100
+ display: block;
101
+ white-space: nowrap;
102
+ overflow: hidden;
103
+ text-overflow: ellipsis;
104
+ }
105
+
106
+ .result-card .snippet {
107
+ font-size: 15px;
108
+ color: var(--text-muted);
109
+ }
110
+
111
+ /* أنيميشن التحميل */
112
+ .shimmer {
113
+ height: 100px;
114
+ background: linear-gradient(90deg, #eff1f3 25%, #e2e2e2 50%, #eff1f3 75%);
115
+ background-size: 400% 100%;
116
+ animation: loading 1.5s infinite;
117
+ border-radius: 12px;
118
+ margin-bottom: 20px;
119
+ }
120
+
121
+ @keyframes loading {
122
+ 0% { background-position: 100% 0; }
123
+ 100% { background-position: 0% 0; }
124
+ }
125
+
126
+ #error-msg {
127
+ display: none;
128
+ text-align: center;
129
+ color: #d93025;
130
+ padding: 40px;
131
+ }
132
  </style>
133
  </head>
134
  <body>
135
 
136
+ <header>
137
+ <div class="header-content">
138
+ <a href="index.html" class="logo">SurfGO</a>
139
+ <div id="search-box-mini"></div>
140
+ </div>
141
+ </header>
142
+
143
  <div class="container">
144
+ <div id="stats" class="stats">جاري البحث عن أفضل النتائج...</div>
145
+
146
+ <div id="loader">
147
+ <div class="shimmer"></div>
148
+ <div class="shimmer"></div>
149
+ <div class="shimmer"></div>
150
+ </div>
151
+
152
+ <div id="results-list"></div>
153
+
154
+ <div id="error-msg">
155
+ <h3>عذراً، حدث خطأ!</h3>
156
+ <p>تأكد من أن سيرفر OpenShift الخاص بك يعمل أو جرب مرة أخرى.</p>
157
  </div>
158
  </div>
159
 
160
  <script>
 
161
  const urlParams = new URLSearchParams(window.location.search);
162
  const query = urlParams.get('q');
163
+
164
+ if (!query) {
165
+ window.location.href = 'index.html';
 
 
 
 
166
  }
167
 
168
+ async function getSearchData() {
169
+ const resultsList = document.getElementById('results-list');
170
+ const loader = document.getElementById('loader');
171
+ const stats = document.getElementById('stats');
172
+ const errorMsg = document.getElementById('error-msg');
173
+
174
+ // الرابط الخاص بك
175
+ const apiBase = "https://searxng-anesnt-dev.apps.rm1.0a51.p1.openshiftapps.com/search";
176
+ const fullUrl = `${apiBase}?q=${encodeURIComponent(query)}&format=json&language=ar`;
177
+
178
+ // البروكسي لحل مشكلة CORS
179
+ const proxyUrl = `https://api.allorigins.win/get?url=${encodeURIComponent(fullUrl)}`;
180
 
181
  try {
182
  const response = await fetch(proxyUrl);
183
+ if (!response.ok) throw new Error('Network Error');
184
 
185
  const data = await response.json();
186
+ const jsonResults = JSON.parse(data.contents);
187
+
188
+ loader.style.display = 'none';
189
+ stats.innerText = `تم العثور على حوالي ${jsonResults.results.length} نتيجة لـ "${query}"`;
190
+
191
+ if (jsonResults.results.length === 0) {
192
+ resultsList.innerHTML = "<p>لا توجد نتائج، حاول بكلمات أخرى.</p>";
193
+ return;
 
 
 
 
 
 
 
 
 
 
194
  }
195
 
196
+ jsonResults.results.forEach(item => {
197
+ const card = `
198
+ <div class="result-card">
199
+ <cite class="cite">${item.url}</cite>
200
+ <a href="${item.url}" target="_blank">${item.title}</a>
201
+ <div class="snippet">${item.content || 'لا يوجد وصف متاح لهذا الرابط.'}</div>
202
+ </div>
203
+ `;
204
+ resultsList.innerHTML += card;
205
+ });
206
+
207
  } catch (error) {
208
+ console.error(error);
209
+ loader.style.display = 'none';
210
+ errorMsg.style.display = 'block';
 
 
 
 
211
  }
212
  }
213
+
214
+ // انطلاق البحث
215
+ getSearchData();
216
  </script>
217
 
218
  </body>