File size: 11,061 Bytes
70d9328
e6a1cba
 
70d9328
 
 
 
 
 
 
 
 
 
 
 
cd16904
70d9328
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e6a1cba
 
70d9328
 
e6a1cba
 
cd16904
70d9328
e6a1cba
 
70d9328
 
3ffb85a
 
70d9328
 
3ffb85a
 
70d9328
 
3ffb85a
 
70d9328
 
3ffb85a
 
70d9328
 
3ffb85a
 
70d9328
 
3ffb85a
 
70d9328
 
3ffb85a
 
70d9328
 
3ffb85a
 
70d9328
 
e6a1cba
 
70d9328
 
e6a1cba
 
70d9328
 
3ffb85a
77bbeba
 
3ffb85a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e6a1cba
3ffb85a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382

const DATA = [
  {
    "name": "فهد سعيد بن جمعان الزهراني",
    "url": "https://stat2025-map.static.hf.space/TG/01.html"
  },
  {
    "name": "عبدالملك عبدالرحمن بن محمد العصيل",
    "url": "https://stat2025-map.static.hf.space/TG/02.html"
  },
  {
    "name": "نايف محمد علي زين",
    "url": "https://stat2025-map.static.hf.space/TG/03.html"
  },
  {
    "name": "احمد يحي على هزازي",
    "url": "https://stat2025-map.static.hf.space/TG/04.html"
  },
  {
    "name": "مصعب عبداللطيف محمد الجعفري",
    "url": "https://stat2025-map.static.hf.space/TG/05.html"
  },
  {
    "name": "تالا إبراهيم الوطبان",
    "url": "https://stat2025-map.static.hf.space/TG/06.html"
  },
  {
    "name": "مهدي محمد آل اسماعيل",
    "url": "https://stat2025-map.static.hf.space/TG/07.html"
  },
  {
    "name": "فاطمه راشد يوسف العزمان",
    "url": "https://stat2025-map.static.hf.space/TG/08.html"
  },
  {
    "name": "أروى عبدالله سعد العقيل",
    "url": "https://stat2025-map.static.hf.space/TG/09.html"
  },
  {
    "name": "ساره عيسى بن عباس المطوع",
    "url": "https://stat2025-map.static.hf.space/TG/10.html"
  },
  {
    "name": "اثير جعفر سالم الزهراني",
    "url": "https://stat2025-map.static.hf.space/TG/11.html"
  },
  {
    "name": "ديما علي هادي حكمي",
    "url": "https://stat2025-map.static.hf.space/TG/12.html"
  },
  {
    "name": "مريم محمد عبدالله الدوسري",
    "url": "https://stat2025-map.static.hf.space/TG/13.html"
  },
  {
    "name": "العنود محمد بن عبدالله",
    "url": "https://stat2025-map.static.hf.space/TG/14.html"
  },
  {
    "name": "ساره راشد عبدالله المديني",
    "url": "https://stat2025-map.static.hf.space/TG/15.html"
  },
  {
    "name": "سعد خالد عيد المسيليم",
    "url": "https://stat2025-map.static.hf.space/TG/16.html"
  },
  {
    "name": "منى خلف نحيطر العنزي",
    "url": "https://stat2025-map.static.hf.space/TG/17.html"
  },
  {
    "name": "عبدالمحسن احمد بن صالح الغامدي",
    "url": "https://stat2025-map.static.hf.space/TG/18.html"
  },
  {
    "name": "جواهر معيض بن علي الزهراني",
    "url": "https://stat2025-map.static.hf.space/TG/19.html"
  },
  {
    "name": "ريم مساعد بن عثمان",
    "url": "https://stat2025-map.static.hf.space/TG/20.html"
  },
  {
    "name": "فاطمة سعد مبارك القحطاني",
    "url": "https://stat2025-map.static.hf.space/TG/21.html"
  },
  {
    "name": "لطيفه عبداللطيف بن سعد الدوسري",
    "url": "https://stat2025-map.static.hf.space/TG/22.html"
  },
  {
    "name": "أحمد جابر بن احمد الشهري",
    "url": "https://stat2025-map.static.hf.space/TG/23.html"
  },
  {
    "name": "عبدالله محمد السحيباني",
    "url": "https://stat2025-map.static.hf.space/TG/24.html"
  },
  {
    "name": "ريم جعفر ال مسعود",
    "url": "https://stat2025-map.static.hf.space/TG/25.html"
  },
  {
    "name": "روان سامي سالم الصيالى",
    "url": "https://stat2025-map.static.hf.space/TG/26.html"
  },
  {
    "name": "مريم خالد احمد السليمان",
    "url": "https://stat2025-map.static.hf.space/TG/27.html"
  },
  {
    "name": "بنين الحجي",
    "url": "https://stat2025-map.static.hf.space/TG/28.html"
  },
  {
    "name": "روابي محمد حمد الزبيران",
    "url": "https://stat2025-map.static.hf.space/TG/29.html"
  },
  {
    "name": "غدير عبدالعزيز بن سعد القاسم",
    "url": "https://stat2025-map.static.hf.space/TG/30.html"
  },
  {
    "name": "فاطمة نعمة سلمان الهاشم",
    "url": "https://stat2025-map.static.hf.space/TG/31.html"
  },
  {
    "name": "مليكه علي عبدالله الهميلي",
    "url": "https://stat2025-map.static.hf.space/TG/32.html"
  },
  {
    "name": "فاطمه شهيد بن حسن التركي",
    "url": "https://stat2025-map.static.hf.space/TG/33.html"
  },
  {
    "name": "زينب جعفر ال ربح",
    "url": "https://stat2025-map.static.hf.space/TG/34.html"
  },
  {
    "name": "طاهرة حسن بن احمد",
    "url": "https://stat2025-map.static.hf.space/TG/35.html"
  },
  {
    "name": "ماجد سلطان الشمري",
    "url": "https://stat2025-map.static.hf.space/TG/36.html"
  },
  {
    "name": "ايناس الشريف",
    "url": "https://stat2025-map.static.hf.space/TG/37.html"
  },
  {
    "name": "مريم علي بن عبدالله",
    "url": "https://stat2025-map.static.hf.space/TG/38.html"
  },
  {
    "name": "ابعاد احمد عفات الشمري",
    "url": "https://stat2025-map.static.hf.space/TG/39.html"
  },
  {
    "name": "عبدالله فواز الشمري",
    "url": "https://stat2025-map.static.hf.space/TG/40.html"
  },
  {
    "name": "نوف سعد بن ابراهيم",
    "url": "https://stat2025-map.static.hf.space/TG/41.html"
  },
  {
    "name": "حسن عبدالهادي بن حسين الحواج",
    "url": "https://stat2025-map.static.hf.space/TG/42.html"
  },
  {
    "name": "مشاعل محمد حمد المري",
    "url": "https://stat2025-map.static.hf.space/TG/43.html"
  },
  {
    "name": "عبدالهادي حسين بن ابراهيم",
    "url": "https://stat2025-map.static.hf.space/TG/44.html"
  },
  {
    "name": "مي محمد مبارك الدوسري",
    "url": "https://stat2025-map.static.hf.space/TG/45.html"
  },
  {
    "name": "هياء احمد حمد العواد",
    "url": "https://stat2025-map.static.hf.space/TG/46.html"
  },
  {
    "name": "محمد محمود عبداللطيف العبدالعظيم",
    "url": "https://stat2025-map.static.hf.space/TG/47.html"
  },
  {
    "name": "عبدالعزيز محمد حمود المطيري",
    "url": "https://stat2025-map.static.hf.space/TG/48.html"
  },
  {
    "name": "عبدالله علي خلف الجدعان",
    "url": "https://stat2025-map.static.hf.space/TG/49.html"
  },
  {
    "name": "فاطمة هزاع الحربي",
    "url": "https://stat2025-map.static.hf.space/TG/50.html"
  }
]



function normalizeArabic(s) {
  if (!s) return "";
  return String(s)
    .trim()
    .toLowerCase()
    .replace(/[\u064B-\u065F\u0670\u06D6-\u06ED]/g, "")
    .replace(/\u0640/g, "")
    .replace(/[إأآٱ]/g, "ا")
    .replace(/ى/g, "ي")
    .replace(/ة/g, "ه")
    .replace(/^ال\s+/g, "")
    .replace(/\s+/g, " ");
}

function escapeHtml(str) {
  return String(str)
    .replaceAll("&", "&")
    .replaceAll("<", "&lt;")
    .replaceAll(">", "&gt;")
    .replaceAll('"', "&quot;")
    .replaceAll("'", "&#039;");
}

function highlightMatch(name, rawQuery) {
  if (!rawQuery) return escapeHtml(name);
  const tokens = rawQuery.trim().split(/\s+/).filter(Boolean);
  if (!tokens.length) return escapeHtml(name);

  const t = tokens[0];
  const idx = name.indexOf(t);
  if (idx === -1) return escapeHtml(name);

  const before = escapeHtml(name.slice(0, idx));
  const mid = escapeHtml(name.slice(idx, idx + t.length));
  const after = escapeHtml(name.slice(idx + t.length));
  return `${before}<mark>${mid}</mark>${after}`;
}

const elQ = document.getElementById("q");
const elResults = document.getElementById("results");
const elCount = document.getElementById("countPill");
const elTotal = document.getElementById("totalChip");
const toast = document.getElementById("toast");
const toastText = document.getElementById("toastText");

elTotal.innerHTML = `إجمالي: <b>${DATA.length}</b>`;

function showToast(msg = "تم نسخ الرابط") {
  toastText.textContent = msg;
  toast.classList.add("show");
  clearTimeout(window.__toastT);
  window.__toastT = setTimeout(() => toast.classList.remove("show"), 1200);
}

async function copyLink(url) {
  try {
    await navigator.clipboard.writeText(url);
    showToast();
  } catch (e) {
    const ta = document.createElement("textarea");
    ta.value = url;
    document.body.appendChild(ta);
    ta.select();
    document.execCommand("copy");
    document.body.removeChild(ta);
    showToast();
  }
}

function renderResults(list, rawQuery) {
  elResults.innerHTML = "";

  if (!list.length) {
    elCount.textContent = "النتائج: 0";
    elResults.innerHTML = `<div class="empty">لا توجد نتائج</div>`;
    return;
  }

  elCount.textContent = `النتائج: ${list.length}`;
  const frag = document.createDocumentFragment();

  list.forEach(item => {
    const row = document.createElement("div");
    row.className = "result";

    const nm = document.createElement("div");
    nm.className = "name";
    nm.innerHTML = highlightMatch(item.name, rawQuery);

    const actions = document.createElement("div");
    actions.className = "actions";

    const open = document.createElement("a");
    open.className = "openBtn";
    open.href = item.url;
    open.target = "_blank";
    open.rel = "noopener";
    open.innerHTML = `فتح <span aria-hidden="true">↗</span>`;

    const copy = document.createElement("button");
    copy.className = "copyBtn";
    copy.type = "button";
    copy.innerHTML = `نسخ <span aria-hidden="true">⧉</span>`;
    copy.addEventListener("click", () => copyLink(item.url));

    actions.appendChild(open);
    actions.appendChild(copy);

    row.appendChild(nm);
    row.appendChild(actions);

    frag.appendChild(row);
  });

  elResults.appendChild(frag);
}

function doSearch() {
  const raw = (elQ.value || "").trim();
  const q = normalizeArabic(raw);

  if (!q) {
    elCount.textContent = "النتائج: 0";
    elResults.innerHTML = "";
    return;
  }

  const tokens = q.split(" ").filter(Boolean);

  const matched = DATA.filter(d => {
    const nameNorm = normalizeArabic(d.name);
    return tokens.every(t => nameNorm.includes(t));
  });

  matched.sort((a, b) => {
    const al = (a.name || "").length;
    const bl = (b.name || "").length;
    if (al !== bl) return al - bl;
    return (a.name || "").localeCompare(b.name || "", "ar");
  });

  renderResults(matched, raw);
}

document.getElementById("btnSearch").addEventListener("click", doSearch);
document.getElementById("btnClear").addEventListener("click", () => {
  elQ.value = "";
  elQ.focus();
  elResults.innerHTML = "";
  elCount.textContent = "النتائج: 0";
});

let t = null;
elQ.addEventListener("input", () => {
  clearTimeout(t);
  t = setTimeout(doSearch, 140);
});

elQ.addEventListener("keydown", (e) => {
  if (e.key === "Enter") doSearch();
});

// حفظ آخر بحث
try {
  const last = localStorage.getItem("maps_last_query");
  if (last) {
    elQ.value = last;
    doSearch();
  }
  elQ.addEventListener("input", () => {
    localStorage.setItem("maps_last_query", elQ.value || "");
  });
} catch(_){}

elCount.textContent = "النتائج: 0";