File size: 4,216 Bytes
cb1d881 3263fad cb1d881 3263fad 8e718ca 34f4060 3263fad 34f4060 74b825c 34f4060 74b825c 34f4060 74b825c 3263fad cb1d881 b37fa6d 34f4060 72a44c3 74b825c 34f4060 3263fad e3c6def 34f4060 72401eb 8e718ca 3aa736e 34f4060 3263fad 34f4060 72a44c3 34f4060 72a44c3 74b825c b0caa54 4ad647c 74b825c 72a44c3 74b825c 72a44c3 34f4060 7bd7645 34f4060 72a44c3 b0caa54 74b825c 34f4060 4ad647c 72a44c3 d8ed607 34f4060 72a44c3 34f4060 74b825c 34f4060 b0caa54 3263fad 72401eb 34f4060 72401eb 3263fad cb1d881 | 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 | <!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SurfGO - النتائج</title>
<link href="https://fonts.googleapis.com/css2?family=Tajawal:wght@400;700&display=swap" rel="stylesheet">
<style>
body { font-family: 'Tajawal', sans-serif; background: #fff; color: #202124; margin: 0; padding: 20px; }
.header { display: flex; align-items: center; gap: 15px; margin-bottom: 20px; border-bottom: 1px solid #eee; padding-bottom: 15px; }
.logo { color: #4285f4; font-weight: 800; font-size: 24px; text-decoration: none; }
.search-box { flex-grow: 1; padding: 10px 15px; border-radius: 24px; border: 1px solid #dfe1e5; outline: none; font-family: 'Tajawal', sans-serif; font-size: 16px;}
.result { margin-bottom: 25px; max-width: 650px; }
.result a { color: #1a0dab; text-decoration: none; font-size: 18px; }
.result a:hover { text-decoration: underline; }
.result p { font-size: 14px; color: #4d5156; margin-top: 5px; line-height: 1.5; }
#loader { color: #70757a; font-style: italic; text-align: center; margin-top: 50px; }
.error { color: #d93025; background: #fce8e6; padding: 15px; border-radius: 8px; display: none; line-height: 1.6; }
</style>
</head>
<body>
<div class="header">
<a href="index.html" class="logo">SurfGO</a>
<input type="text" id="q-input" class="search-box">
</div>
<div id="loader">جاري جلب النتائج...</div>
<div id="error" class="error"></div>
<div id="results-area"></div>
<script>
const PROXY_URL = "https://script.google.com/macros/s/AKfycbyt59U3VKEQf6EVk6xe8S_1UietjUWNgjfZtJJy10fMxnBFPQL6SZY2B0BaAunHwkqF/exec";
const SEARXNG_URL = "https://searxng-anesnt-dev.apps.rm1.0a51.p1.openshiftapps.com/search";
const query = new URLSearchParams(window.location.search).get('q');
if (query) {
document.getElementById('q-input').value = query;
fetchResults(query);
}
async function fetchResults(q) {
const area = document.getElementById('results-area');
const loader = document.getElementById('loader');
const errorDiv = document.getElementById('error');
const targetSearch = `${SEARXNG_URL}?q=${encodeURIComponent(q)}&format=json&language=ar`;
const finalUrl = `${PROXY_URL}?url=${encodeURIComponent(targetSearch)}`;
try {
const response = await fetch(finalUrl);
const text = await response.text();
// فحص إذا كان السيرفر أرجع صفحة ويب بدلاً من البيانات
if (text.trim().startsWith("<")) {
console.error("الرد المستلم ليس JSON:", text);
throw new Error("تعذر جلب البيانات. الرجاء التأكد من أن سيرفر SearXNG على OpenShift قيد التشغيل ولم يتوقف، أو أن جوجل يرفض تمرير الطلب.");
}
const data = JSON.parse(text);
loader.style.display = 'none';
if (!data.results || data.results.length === 0) {
area.innerHTML = "<p>لا توجد نتائج بحث لهذه الكلمة.</p>";
return;
}
area.innerHTML = "";
data.results.forEach(item => {
area.innerHTML += `
<div class="result">
<a href="${item.url}" target="_blank">${item.title}</a>
<p>${item.content || ''}</p>
</div>`;
});
} catch (err) {
loader.style.display = 'none';
errorDiv.style.display = 'block';
errorDiv.innerHTML = `<b>حدث خطأ أثناء الاتصال:</b><br>${err.message}`;
console.error(err);
}
}
document.getElementById('q-input').addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
window.location.href = `results.html?q=${encodeURIComponent(e.target.value)}`;
}
});
</script>
</body>
</html> |