From d268f3077fcbc3b231d89dc31a4dc394458b2da7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D9=81=D8=A7=D8=B7=D9=85=D9=87=20=D8=AA=D9=82=DB=8C=20?=
=?UTF-8?q?=D9=BE=D9=88=D8=B1?= <20+f.taghipour@noreply.localhost>
Date: Tue, 10 Nov 2026 09:25:55 +0000
Subject: [PATCH] Update index.html
---
index.html | 47 ++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 40 insertions(+), 7 deletions(-)
diff --git a/index.html b/index.html
index cf17a59..347356d 100644
--- a/index.html
+++ b/index.html
@@ -1,3 +1,4 @@
+
@@ -96,7 +97,7 @@
color: #888;
}
- @media(max-width: 600px) {
+ @media (max-width: 600px) {
.container {
padding: 20px;
}
@@ -122,6 +123,7 @@
type="text"
id="searchInput"
placeholder="نام سند یا شناسه مانند DOC-S300-015 را وارد کنید..."
+ disabled
>
در حال بارگذاری اسناد...
@@ -139,6 +141,21 @@ const results = document.getElementById("results");
const status = document.getElementById("status");
+// یکسانسازی حروف و اعداد برای جستوجو
+function normalize(value) {
+ return String(value ?? "")
+ .trim()
+ .toLowerCase()
+ .replace(/[۰-۹]/g, digit =>
+ "۰۱۲۳۴۵۶۷۸۹".indexOf(digit)
+ )
+ .replace(/[٠-٩]/g, digit =>
+ "٠١٢٣٤٥٦٧٨٩".indexOf(digit)
+ )
+ .replace(/ي/g, "ی")
+ .replace(/ك/g, "ک");
+}
+
// خواندن صحیح اطلاعات CSV
function parseCSV(text) {
@@ -162,8 +179,13 @@ function parseCSV(text) {
row.push(field);
field = "";
}
- else if ((char === "\n" || char === "\r") && !insideQuotes) {
- if (char === "\r" && text[i + 1] === "\n") i++;
+ else if (
+ (char === "\n" || char === "\r") &&
+ !insideQuotes
+ ) {
+ if (char === "\r" && text[i + 1] === "\n") {
+ i++;
+ }
row.push(field);
@@ -188,6 +210,7 @@ function parseCSV(text) {
return rows;
}
+
// دریافت فایل CSV
async function loadDocuments() {
try {
@@ -219,6 +242,7 @@ async function loadDocuments() {
}
}
+
// جستوجوی اسناد
function searchDocuments() {
const query = normalize(searchInput.value);
@@ -231,10 +255,14 @@ function searchDocuments() {
return;
}
- const matches = documents.filter(doc =>
- normalize(doc.title).includes(query) ||
- normalize(doc.id).includes(query)
- );
+ const matches = documents.filter(doc => {
+ const titleWords = normalize(doc.title)
+ .split(/[\s\-_]+/);
+
+ const id = normalize(doc.id);
+
+ return titleWords.includes(query) || id === query;
+ });
status.textContent =
`${matches.length} نتیجه پیدا شد.`;
@@ -245,6 +273,7 @@ function searchDocuments() {
return;
}
+ // نمایش نتایج
matches.forEach(doc => {
const item = document.createElement("div");
item.className = "result";
@@ -275,13 +304,17 @@ function searchDocuments() {
idInfo.append(idLabel, idValue);
item.append(title, rowInfo, idInfo);
+
results.appendChild(item);
});
}
+
// جستوجوی لحظهای
searchInput.addEventListener("input", searchDocuments);
+
+// شروع بارگذاری
loadDocuments();