Update index.html
Browse files- index.html +13 -7
index.html
CHANGED
|
@@ -434,11 +434,11 @@
|
|
| 434 |
resultsEl.appendChild(grid);
|
| 435 |
};
|
| 436 |
|
| 437 |
-
// دمج مصفوفت
|
| 438 |
-
const mergeResults = (
|
| 439 |
const seen = new Set();
|
| 440 |
const merged = [];
|
| 441 |
-
|
| 442 |
if (r.url && !seen.has(r.url)) {
|
| 443 |
seen.add(r.url);
|
| 444 |
merged.push(r);
|
|
@@ -455,6 +455,7 @@
|
|
| 455 |
|
| 456 |
try {
|
| 457 |
if (tab === 'all') {
|
|
|
|
| 458 |
const [imagesData, videosData] = await Promise.all([fetchCategory('images'), fetchCategory('videos')]);
|
| 459 |
const suggestions = imagesData.suggestions || videosData.suggestions || [];
|
| 460 |
if (suggestions.length) renderSuggestions(suggestions);
|
|
@@ -469,12 +470,17 @@
|
|
| 469 |
const divider = document.createElement('hr'); divider.className = 'web-divider'; resultsEl.appendChild(divider);
|
| 470 |
}
|
| 471 |
|
| 472 |
-
//
|
| 473 |
-
const [generalData, newsData] = await Promise.all([
|
| 474 |
fetchCategory('general'),
|
| 475 |
-
fetchCategory('news')
|
|
|
|
| 476 |
]);
|
| 477 |
-
const webResults = mergeResults(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 478 |
loadingEl.style.display = 'none';
|
| 479 |
|
| 480 |
if (webResults.length) {
|
|
|
|
| 434 |
resultsEl.appendChild(grid);
|
| 435 |
};
|
| 436 |
|
| 437 |
+
// دمج مصفوفات مع منع التكرار
|
| 438 |
+
const mergeResults = (...arrays) => {
|
| 439 |
const seen = new Set();
|
| 440 |
const merged = [];
|
| 441 |
+
arrays.flat().forEach(r => {
|
| 442 |
if (r.url && !seen.has(r.url)) {
|
| 443 |
seen.add(r.url);
|
| 444 |
merged.push(r);
|
|
|
|
| 455 |
|
| 456 |
try {
|
| 457 |
if (tab === 'all') {
|
| 458 |
+
// 1. الصور والفيديوهات أولاً
|
| 459 |
const [imagesData, videosData] = await Promise.all([fetchCategory('images'), fetchCategory('videos')]);
|
| 460 |
const suggestions = imagesData.suggestions || videosData.suggestions || [];
|
| 461 |
if (suggestions.length) renderSuggestions(suggestions);
|
|
|
|
| 470 |
const divider = document.createElement('hr'); divider.className = 'web-divider'; resultsEl.appendChild(divider);
|
| 471 |
}
|
| 472 |
|
| 473 |
+
// 2. جلب 3 فئات للويب ودمجها
|
| 474 |
+
const [generalData, newsData, webData] = await Promise.all([
|
| 475 |
fetchCategory('general'),
|
| 476 |
+
fetchCategory('news'),
|
| 477 |
+
fetchCategory('web') // فئة إضافية إن وجدت
|
| 478 |
]);
|
| 479 |
+
const webResults = mergeResults(
|
| 480 |
+
generalData.results || [],
|
| 481 |
+
newsData.results || [],
|
| 482 |
+
webData.results || []
|
| 483 |
+
);
|
| 484 |
loadingEl.style.display = 'none';
|
| 485 |
|
| 486 |
if (webResults.length) {
|