Update index.html
Browse files- index.html +78 -165
index.html
CHANGED
@@ -54,27 +54,21 @@
|
|
54 |
border-radius: 3px;
|
55 |
font-weight: bold;
|
56 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
/* ================================
|
59 |
-
تنسيق عرض
|
60 |
================================= */
|
61 |
-
.
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
}
|
66 |
-
.line-item {
|
67 |
-
display: flex;
|
68 |
-
align-items: flex-start;
|
69 |
-
margin-bottom: 0.5rem;
|
70 |
-
}
|
71 |
-
.line-number {
|
72 |
-
width: 30px;
|
73 |
-
font-weight: bold;
|
74 |
-
color: #4B5563;
|
75 |
-
flex-shrink: 0;
|
76 |
}
|
77 |
-
.line-text { flex: 1; }
|
78 |
|
79 |
/* ================================
|
80 |
تحسين تنسيق البطاقات والعناصر
|
@@ -188,15 +182,15 @@
|
|
188 |
<i class="fas fa-search text-green-600 ml-2"></i> نتائج التحليل والمقارنة
|
189 |
</h2>
|
190 |
<div id="errorsList" class="space-y-3 mb-6"></div>
|
191 |
-
<div class="result-section
|
192 |
-
<!-- عرض النص المصدر بعد التحديد
|
193 |
<div>
|
194 |
<h4 class="text-lg font-bold text-gray-700 mb-3 flex items-center">
|
195 |
<i class="fas fa-file-alt text-indigo-600 ml-2"></i> النص المصدر (مع التعليم)
|
196 |
</h4>
|
197 |
<div id="sourceTextReview" class="bg-indigo-50 rounded-xl p-6 min-h-[200px] border-2 border-indigo-100 text-comparison"></div>
|
198 |
</div>
|
199 |
-
<!-- عرض النص الهدف بعد التحديد
|
200 |
<div>
|
201 |
<h4 class="text-lg font-bold text-gray-700 mb-3 flex items-center">
|
202 |
<i class="fas fa-file-alt text-pink-600 ml-2"></i> النص الهدف (مع التعليم)
|
@@ -214,29 +208,13 @@
|
|
214 |
<div id="explanationText" class="text-lg text-gray-700"></div>
|
215 |
</div>
|
216 |
|
217 |
-
<!-- زر إعادة المراجعة -->
|
218 |
<button id="reviewAgainBtn" class="w-full bg-gray-600 hover:bg-gray-700 text-white font-bold py-3 px-6 rounded-xl transition-all transform hover:scale-105 focus:ring-gray-200 text-xl shadow-lg hover:shadow-xl mb-8">
|
219 |
<div class="flex items-center justify-center">
|
220 |
<i class="fas fa-redo ml-2"></i> إعادة المراجعة
|
221 |
</div>
|
222 |
</button>
|
223 |
|
224 |
-
<!-- قسم إعادة المراجعة: قائمة منسدلة لتحديد نوع المراجعة -->
|
225 |
-
<div id="reviewAgainSection" class="hidden bg-white rounded-2xl shadow-lg p-8 border border-gray-100 hover:shadow-xl transition-all animate-scale mb-8 card-hover">
|
226 |
-
<h2 class="text-2xl font-bold mb-6 text-gray-800 border-b pb-3 flex items-center">
|
227 |
-
<i class="fas fa-redo text-blue-600 ml-2"></i> إعادة المراجعة - اختيار النوع
|
228 |
-
</h2>
|
229 |
-
<div class="flex items-center space-x-4">
|
230 |
-
<select id="reviewType" class="px-4 py-2 border rounded-xl focus:outline-none">
|
231 |
-
<option value="all">جميع الاختلافات</option>
|
232 |
-
<option value="number">مراجعة رقمية فقط</option>
|
233 |
-
<option value="meaning">مراجعة المعنى فقط</option>
|
234 |
-
<option value="missing">مراجعة النص المفقود فقط</option>
|
235 |
-
</select>
|
236 |
-
<button id="confirmReviewBtn" class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-xl">تنفيذ إعادة المراجعة</button>
|
237 |
-
</div>
|
238 |
-
</div>
|
239 |
-
|
240 |
</main>
|
241 |
</div>
|
242 |
|
@@ -253,21 +231,25 @@
|
|
253 |
const API_URL = 'https://api.deepseek.com/chat/completions';
|
254 |
const API_KEY = 'sk-15606736ed9e4aea8b7cc11a195d2b01';
|
255 |
|
256 |
-
|
257 |
-
مهمتك مقارنة النص المصدر والنص الهدف بدقة عالية
|
258 |
-
|
259 |
-
•
|
260 |
-
•
|
261 |
-
• اختلافات
|
262 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
|
264 |
-
اختلافات الأرقام باستخدام <الرقم_في_المصدر> → <الرقم_في_الهدف>.
|
265 |
-
النصوص المفقودة كما هي بين علامتي __.
|
266 |
-
اختلافات المعنى باستخدام [MEANING] مع الحفاظ على التعليم.
|
267 |
النص المصدر:
|
268 |
-
{source}
|
|
|
269 |
النص الهدف:
|
270 |
-
{target}
|
271 |
|
272 |
// دوال مساعدة للتعامل مع النصوص
|
273 |
function countWords(text) {
|
@@ -276,10 +258,12 @@
|
|
276 |
function escapeRegExp(string) {
|
277 |
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
278 |
}
|
279 |
-
|
280 |
-
|
|
|
281 |
}
|
282 |
-
|
|
|
283 |
const index = text.indexOf(substring);
|
284 |
if (index === -1) return "غير محدد";
|
285 |
return text.substring(0, index).split("\n").length;
|
@@ -309,6 +293,16 @@
|
|
309 |
highlightedText = highlightedText.replace(phraseRegex, replacement);
|
310 |
}
|
311 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
312 |
// اختلافات المعنى
|
313 |
const meaningRegex = /\[MEANING\](.*?)\[\/MEANING\]/g;
|
314 |
while ((match = meaningRegex.exec(analysisOutput)) !== null) {
|
@@ -322,74 +316,44 @@
|
|
322 |
return highlightedText;
|
323 |
}
|
324 |
|
325 |
-
// تطبيق التمييز بحسب نوع المراجعة
|
326 |
-
function applyHighlightsByType(originalText, analysisOutput, reviewType) {
|
327 |
-
let highlightedText = originalText;
|
328 |
-
if (reviewType === 'meaning') {
|
329 |
-
const meaningRegex = /\[MEANING\](.*?)\[\/MEANING\]/g;
|
330 |
-
let match;
|
331 |
-
while ((match = meaningRegex.exec(analysisOutput)) !== null) {
|
332 |
-
const phrase = match[1].trim();
|
333 |
-
if (phrase) {
|
334 |
-
const replacement = `<span class="highlight-meaning">${phrase}</span>`;
|
335 |
-
const phraseRegex = new RegExp(escapeRegExp(phrase), 'g');
|
336 |
-
highlightedText = highlightedText.replace(phraseRegex, replacement);
|
337 |
-
}
|
338 |
-
}
|
339 |
-
} else if (reviewType === 'number') {
|
340 |
-
const numberRegex = /<([^<>]+)>/g;
|
341 |
-
let match;
|
342 |
-
while ((match = numberRegex.exec(analysisOutput)) !== null) {
|
343 |
-
const phrase = match[1].trim();
|
344 |
-
if (phrase) {
|
345 |
-
const replacement = `<span class="highlight-number">${phrase}</span>`;
|
346 |
-
const phraseRegex = new RegExp(escapeRegExp(phrase), 'g');
|
347 |
-
highlightedText = highlightedText.replace(phraseRegex, replacement);
|
348 |
-
}
|
349 |
-
}
|
350 |
-
} else if (reviewType === 'missing') {
|
351 |
-
const missingRegex = /__(.*?)__/g;
|
352 |
-
let match;
|
353 |
-
while ((match = missingRegex.exec(analysisOutput)) !== null) {
|
354 |
-
const phrase = match[1].trim();
|
355 |
-
if (phrase) {
|
356 |
-
const replacement = `<span class="highlight-missing">__${phrase}__</span>`;
|
357 |
-
const phraseRegex = new RegExp(escapeRegExp(phrase), 'g');
|
358 |
-
highlightedText = highlightedText.replace(phraseRegex, replacement);
|
359 |
-
}
|
360 |
-
}
|
361 |
-
} else {
|
362 |
-
highlightedText = applyHighlights(originalText, analysisOutput);
|
363 |
-
}
|
364 |
-
return highlightedText;
|
365 |
-
}
|
366 |
-
|
367 |
// توليد الشرح التفصيلي
|
368 |
function generateExplanation(sourceText, analysisOutput) {
|
369 |
let steps = [];
|
|
|
370 |
const missingRegex = /__(.*?)__/g;
|
371 |
let match;
|
372 |
while ((match = missingRegex.exec(analysisOutput)) !== null) {
|
373 |
const phrase = match[1].trim();
|
374 |
if (phrase) {
|
375 |
-
const
|
376 |
-
steps.push(`<li><strong
|
377 |
}
|
378 |
}
|
|
|
379 |
const numberRegex = /<([^<>]+)>/g;
|
380 |
while ((match = numberRegex.exec(analysisOutput)) !== null) {
|
381 |
const phrase = match[1].trim();
|
382 |
if (phrase) {
|
383 |
-
const
|
384 |
-
steps.push(`<li><strong
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
385 |
}
|
386 |
}
|
|
|
387 |
const meaningRegex = /\[MEANING\](.*?)\[\/MEANING\]/g;
|
388 |
while ((match = meaningRegex.exec(analysisOutput)) !== null) {
|
389 |
const phrase = match[1].trim();
|
390 |
if (phrase) {
|
391 |
-
const
|
392 |
-
steps.push(`<li><strong
|
393 |
}
|
394 |
}
|
395 |
if (steps.length === 0) {
|
@@ -398,48 +362,6 @@
|
|
398 |
return `<ol class="list-decimal ml-6 space-y-2">${steps.join('')}</ol>`;
|
399 |
}
|
400 |
|
401 |
-
// توليد الشرح بحسب نوع إعادة المراجعة
|
402 |
-
function generateExplanationByType(sourceText, analysisOutput, reviewType) {
|
403 |
-
let steps = [];
|
404 |
-
if (reviewType === 'meaning') {
|
405 |
-
const meaningRegex = /\[MEANING\](.*?)\[\/MEANING\]/g;
|
406 |
-
let match;
|
407 |
-
while ((match = meaningRegex.exec(analysisOutput)) !== null) {
|
408 |
-
const phrase = match[1].trim();
|
409 |
-
if (phrase) {
|
410 |
-
const lineNum = getLineNumber(sourceText, phrase);
|
411 |
-
steps.push(`<li><strong>مراجعة المعنى:</strong> في السطر ${lineNum}، التعبير "<span class="highlight-meaning">${phrase}</span>" يختلف. تحقق من الدقة.</li>`);
|
412 |
-
}
|
413 |
-
}
|
414 |
-
} else if (reviewType === 'number') {
|
415 |
-
const numberRegex = /<([^<>]+)>/g;
|
416 |
-
let match;
|
417 |
-
while ((match = numberRegex.exec(analysisOutput)) !== null) {
|
418 |
-
const phrase = match[1].trim();
|
419 |
-
if (phrase) {
|
420 |
-
const lineNum = getLineNumber(sourceText, phrase);
|
421 |
-
steps.push(`<li><strong>مراجعة رقمية:</strong> في السطر ${lineNum}، الرقم "<span class="highlight-number">${phrase}</span>" لا يتطابق. يرجى المراجعة.</li>`);
|
422 |
-
}
|
423 |
-
}
|
424 |
-
} else if (reviewType === 'missing') {
|
425 |
-
const missingRegex = /__(.*?)__/g;
|
426 |
-
let match;
|
427 |
-
while ((match = missingRegex.exec(analysisOutput)) !== null) {
|
428 |
-
const phrase = match[1].trim();
|
429 |
-
if (phrase) {
|
430 |
-
const lineNum = getLineNumber(sourceText, phrase);
|
431 |
-
steps.push(`<li><strong>مراجعة النص المفقود:</strong> في السطر ${lineNum}، النص "<span class="highlight-missing">__${phrase}__</span>" مفقود أو مختلف. يرجى المراجعة.</li>`);
|
432 |
-
}
|
433 |
-
}
|
434 |
-
} else {
|
435 |
-
return generateExplanation(sourceText, analysisOutput);
|
436 |
-
}
|
437 |
-
if (steps.length === 0) {
|
438 |
-
return `<p>لا توجد اختلافات من النوع المحدد.</p>`;
|
439 |
-
}
|
440 |
-
return `<ol class="list-decimal ml-6 space-y-2">${steps.join('')}</ol>`;
|
441 |
-
}
|
442 |
-
|
443 |
// دالة معالجة الملفات (PDF و DOCX)
|
444 |
async function processFile(file) {
|
445 |
let text = "";
|
@@ -587,26 +509,28 @@
|
|
587 |
checkDiv.className = "p-4 rounded-xl bg-green-50 text-green-700 flex items-center";
|
588 |
checkDiv.innerHTML = `<i class="fas fa-check-circle ml-2 text-lg"></i> <span class="text-lg">النصوص متطابقة تماماً</span>`;
|
589 |
document.getElementById('errorsList').appendChild(checkDiv);
|
590 |
-
document.getElementById('sourceTextReview').innerHTML =
|
591 |
-
document.getElementById('targetTextReview').innerHTML =
|
592 |
document.getElementById('explanationText').innerHTML = `<p>النصوص متطابقة ولا يوجد اختلاف يجب الإشارة إليه.</p>`;
|
593 |
} else {
|
594 |
const sourceHighlighted = applyHighlights(sourceText, analysisOutput);
|
595 |
const targetHighlighted = applyHighlights(targetText, analysisOutput);
|
596 |
-
document.getElementById('sourceTextReview').innerHTML =
|
597 |
-
document.getElementById('targetTextReview').innerHTML =
|
598 |
const explanationHTML = generateExplanation(sourceText, analysisOutput);
|
599 |
document.getElementById('explanationText').innerHTML = explanationHTML;
|
600 |
|
601 |
const numDiffCount = (analysisOutput.match(/<([^<>]+)>/g) || []).length;
|
602 |
const missingDiffCount = (analysisOutput.match(/__(.*?)__/g) || []).length;
|
|
|
603 |
const meaningDiffCount = (analysisOutput.match(/\[MEANING\](.*?)\[\/MEANING\]/g) || []).length;
|
604 |
-
if (numDiffCount > 0 || missingDiffCount > 0 || meaningDiffCount > 0) {
|
605 |
const summaryDiv = document.createElement('div');
|
606 |
summaryDiv.className = "p-4 rounded-xl bg-yellow-50 text-gray-800";
|
607 |
let summaryText = '<div class="font-bold mb-2">ملخص الاختلافات:</div><ul class="list-disc mr-6 space-y-1">';
|
608 |
if (numDiffCount > 0) summaryText += `<li>اختلاف في الأرقام: ${numDiffCount}</li>`;
|
609 |
if (missingDiffCount > 0) summaryText += `<li>النصوص المفقودة: ${missingDiffCount}</li>`;
|
|
|
610 |
if (meaningDiffCount > 0) summaryText += `<li>اختلاف في المعنى: ${meaningDiffCount}</li>`;
|
611 |
summaryText += '</ul>';
|
612 |
summaryDiv.innerHTML = summaryText;
|
@@ -619,26 +543,15 @@
|
|
619 |
}
|
620 |
});
|
621 |
|
622 |
-
// زر إعادة
|
623 |
document.getElementById('reviewAgainBtn').addEventListener('click', () => {
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
document.getElementById('
|
628 |
-
|
629 |
-
|
630 |
-
// تنفيذ إعادة المراجعة بناءً على النوع المحدد
|
631 |
-
document.getElementById('confirmReviewBtn').addEventListener('click', () => {
|
632 |
-
const reviewType = document.getElementById('reviewType').value;
|
633 |
-
const explanationHTML = generateExplanationByType(storedSourceText, storedAnalysisOutput, reviewType);
|
634 |
document.getElementById('explanationText').innerHTML = explanationHTML;
|
635 |
-
const sourceHighlighted = applyHighlightsByType(storedSourceText, storedAnalysisOutput, reviewType);
|
636 |
-
const targetHighlighted = applyHighlightsByType(storedTargetText, storedAnalysisOutput, reviewType);
|
637 |
-
document.getElementById('sourceTextReview').innerHTML = splitIntoLines(sourceHighlighted);
|
638 |
-
document.getElementById('targetTextReview').innerHTML = splitIntoLines(targetHighlighted);
|
639 |
-
document.getElementById('reviewAgainSection').classList.add('hidden');
|
640 |
-
document.getElementById('resultSection').classList.remove('hidden');
|
641 |
-
document.getElementById('explanationBox').classList.remove('hidden');
|
642 |
});
|
643 |
</script>
|
644 |
</body>
|
|
|
54 |
border-radius: 3px;
|
55 |
font-weight: bold;
|
56 |
}
|
57 |
+
.highlight-date {
|
58 |
+
background-color: #C6F6D5;
|
59 |
+
padding: 0 4px;
|
60 |
+
border-radius: 3px;
|
61 |
+
font-weight: bold;
|
62 |
+
}
|
63 |
|
64 |
/* ================================
|
65 |
+
تنسيق عرض الفقرات في المعاينة
|
66 |
================================= */
|
67 |
+
.paragraph-view p {
|
68 |
+
margin-bottom: 1rem;
|
69 |
+
padding: 0.5rem;
|
70 |
+
border-bottom: 1px solid #e2e8f0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
}
|
|
|
72 |
|
73 |
/* ================================
|
74 |
تحسين تنسيق البطاقات والعناصر
|
|
|
182 |
<i class="fas fa-search text-green-600 ml-2"></i> نتائج التحليل والمقارنة
|
183 |
</h2>
|
184 |
<div id="errorsList" class="space-y-3 mb-6"></div>
|
185 |
+
<div class="result-section paragraph-view">
|
186 |
+
<!-- عرض النص المصدر بعد التحديد على شكل فقرات -->
|
187 |
<div>
|
188 |
<h4 class="text-lg font-bold text-gray-700 mb-3 flex items-center">
|
189 |
<i class="fas fa-file-alt text-indigo-600 ml-2"></i> النص المصدر (مع التعليم)
|
190 |
</h4>
|
191 |
<div id="sourceTextReview" class="bg-indigo-50 rounded-xl p-6 min-h-[200px] border-2 border-indigo-100 text-comparison"></div>
|
192 |
</div>
|
193 |
+
<!-- عرض النص الهدف بعد التحديد على شكل فقرات -->
|
194 |
<div>
|
195 |
<h4 class="text-lg font-bold text-gray-700 mb-3 flex items-center">
|
196 |
<i class="fas fa-file-alt text-pink-600 ml-2"></i> النص الهدف (مع التعليم)
|
|
|
208 |
<div id="explanationText" class="text-lg text-gray-700"></div>
|
209 |
</div>
|
210 |
|
211 |
+
<!-- زر إعادة المراجعة (بدون تحديد نوع) -->
|
212 |
<button id="reviewAgainBtn" class="w-full bg-gray-600 hover:bg-gray-700 text-white font-bold py-3 px-6 rounded-xl transition-all transform hover:scale-105 focus:ring-gray-200 text-xl shadow-lg hover:shadow-xl mb-8">
|
213 |
<div class="flex items-center justify-center">
|
214 |
<i class="fas fa-redo ml-2"></i> إعادة المراجعة
|
215 |
</div>
|
216 |
</button>
|
217 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
</main>
|
219 |
</div>
|
220 |
|
|
|
231 |
const API_URL = 'https://api.deepseek.com/chat/completions';
|
232 |
const API_KEY = 'sk-15606736ed9e4aea8b7cc11a195d2b01';
|
233 |
|
234 |
+
// تحديث البرومبت ليتضمن مراجعة الفروقات ��التركيز على النصوص المفقودة، الأرقام والتواريخ
|
235 |
+
const ANALYSIS_PROMPT = `أنت خبير لغوي متخصص في مراجعة الترجمة التقنية. مهمتك مقارنة النص المصدر والنص الهدف بدقة عالية والبحث عن الفروقات بينهما.
|
236 |
+
النصوص مليئة بالأخطاء والنواقص، لذا قم بالتركيز على:
|
237 |
+
• النصوص المفقودة (حافظ على علامات __ و __).
|
238 |
+
• الاختلافات الرقمية (حافظ على علامات < و >).
|
239 |
+
• اختلافات التواريخ (حافظ على علامات [DATE] و [/DATE]).
|
240 |
+
• اختلافات المعنى (إن وُجد) مع الحفاظ على علامات [MEANING] و [/MEANING].
|
241 |
+
|
242 |
+
اعتمد النص المصدر كأساس للمقارنة، وحدد الفروقات كما يلي:
|
243 |
+
1. اختلافات الأرقام باستخدام <الرقم_في_المصدر> → <الرقم_في_الهدف>.
|
244 |
+
2. النصوص المفقودة كما هي بين علامتي __.
|
245 |
+
3. اختلافات التواريخ باستخدام [DATE] مع الحفاظ على التعليم.
|
246 |
+
4. اختلافات المعنى باستخدام [MEANING] مع الحفاظ على التعليم (إن وُجد).
|
247 |
|
|
|
|
|
|
|
248 |
النص المصدر:
|
249 |
+
{source}
|
250 |
+
|
251 |
النص الهدف:
|
252 |
+
{target}`;
|
253 |
|
254 |
// دوال مساعدة للتعامل مع النصوص
|
255 |
function countWords(text) {
|
|
|
258 |
function escapeRegExp(string) {
|
259 |
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
260 |
}
|
261 |
+
// تقسيم النص إلى فقرات وعرض كل فقرة داخل وسم <p>
|
262 |
+
function splitIntoParagraphs(text) {
|
263 |
+
return text.split(/\n+/).map(para => `<p>${para.trim()}</p>`).join('');
|
264 |
}
|
265 |
+
// الحصول على رقم الفقرة لظهور عبارة معينة
|
266 |
+
function getParagraphNumber(text, substring) {
|
267 |
const index = text.indexOf(substring);
|
268 |
if (index === -1) return "غير محدد";
|
269 |
return text.substring(0, index).split("\n").length;
|
|
|
293 |
highlightedText = highlightedText.replace(phraseRegex, replacement);
|
294 |
}
|
295 |
}
|
296 |
+
// اختلافات التواريخ
|
297 |
+
const dateRegex = /\[DATE\](.*?)\[\/DATE\]/g;
|
298 |
+
while ((match = dateRegex.exec(analysisOutput)) !== null) {
|
299 |
+
const phrase = match[1].trim();
|
300 |
+
if (phrase) {
|
301 |
+
const replacement = `<span class="highlight-date">${phrase}</span>`;
|
302 |
+
const phraseRegex = new RegExp(escapeRegExp(phrase), 'g');
|
303 |
+
highlightedText = highlightedText.replace(phraseRegex, replacement);
|
304 |
+
}
|
305 |
+
}
|
306 |
// اختلافات المعنى
|
307 |
const meaningRegex = /\[MEANING\](.*?)\[\/MEANING\]/g;
|
308 |
while ((match = meaningRegex.exec(analysisOutput)) !== null) {
|
|
|
316 |
return highlightedText;
|
317 |
}
|
318 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
319 |
// توليد الشرح التفصيلي
|
320 |
function generateExplanation(sourceText, analysisOutput) {
|
321 |
let steps = [];
|
322 |
+
// مراجعة النصوص المفقودة
|
323 |
const missingRegex = /__(.*?)__/g;
|
324 |
let match;
|
325 |
while ((match = missingRegex.exec(analysisOutput)) !== null) {
|
326 |
const phrase = match[1].trim();
|
327 |
if (phrase) {
|
328 |
+
const paraNum = getParagraphNumber(sourceText, phrase);
|
329 |
+
steps.push(`<li><strong>مراجعة النص المفقود:</strong> في الفقرة ${paraNum}، النص "<span class="highlight-missing">__${phrase}__</span>" مفقود أو مختلف. يرجى المراجعة.</li>`);
|
330 |
}
|
331 |
}
|
332 |
+
// مراجعة الأرقام
|
333 |
const numberRegex = /<([^<>]+)>/g;
|
334 |
while ((match = numberRegex.exec(analysisOutput)) !== null) {
|
335 |
const phrase = match[1].trim();
|
336 |
if (phrase) {
|
337 |
+
const paraNum = getParagraphNumber(sourceText, phrase);
|
338 |
+
steps.push(`<li><strong>مراجعة الأرقام:</strong> في الفقرة ${paraNum}، الرقم "<span class="highlight-number">${phrase}</span>" لا يتطابق. يرجى المراجعة.</li>`);
|
339 |
+
}
|
340 |
+
}
|
341 |
+
// مراجعة التواريخ
|
342 |
+
const dateRegex = /\[DATE\](.*?)\[\/DATE\]/g;
|
343 |
+
while ((match = dateRegex.exec(analysisOutput)) !== null) {
|
344 |
+
const phrase = match[1].trim();
|
345 |
+
if (phrase) {
|
346 |
+
const paraNum = getParagraphNumber(sourceText, phrase);
|
347 |
+
steps.push(`<li><strong>مراجعة التواريخ:</strong> في الفقرة ${paraNum}، التاريخ "<span class="highlight-date">${phrase}</span>" غير مطابق. يرجى المراجعة.</li>`);
|
348 |
}
|
349 |
}
|
350 |
+
// مراجعة اختلافات المعنى
|
351 |
const meaningRegex = /\[MEANING\](.*?)\[\/MEANING\]/g;
|
352 |
while ((match = meaningRegex.exec(analysisOutput)) !== null) {
|
353 |
const phrase = match[1].trim();
|
354 |
if (phrase) {
|
355 |
+
const paraNum = getParagraphNumber(sourceText, phrase);
|
356 |
+
steps.push(`<li><strong>مراجعة المعنى:</strong> في الفقرة ${paraNum}، التعبير "<span class="highlight-meaning">${phrase}</span>" يختلف. تحقق من الدقة.</li>`);
|
357 |
}
|
358 |
}
|
359 |
if (steps.length === 0) {
|
|
|
362 |
return `<ol class="list-decimal ml-6 space-y-2">${steps.join('')}</ol>`;
|
363 |
}
|
364 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
365 |
// دالة معالجة الملفات (PDF و DOCX)
|
366 |
async function processFile(file) {
|
367 |
let text = "";
|
|
|
509 |
checkDiv.className = "p-4 rounded-xl bg-green-50 text-green-700 flex items-center";
|
510 |
checkDiv.innerHTML = `<i class="fas fa-check-circle ml-2 text-lg"></i> <span class="text-lg">النصوص متطابقة تماماً</span>`;
|
511 |
document.getElementById('errorsList').appendChild(checkDiv);
|
512 |
+
document.getElementById('sourceTextReview').innerHTML = splitIntoParagraphs(sourceText);
|
513 |
+
document.getElementById('targetTextReview').innerHTML = splitIntoParagraphs(targetText);
|
514 |
document.getElementById('explanationText').innerHTML = `<p>النصوص متطابقة ولا يوجد اختلاف يجب الإشارة إليه.</p>`;
|
515 |
} else {
|
516 |
const sourceHighlighted = applyHighlights(sourceText, analysisOutput);
|
517 |
const targetHighlighted = applyHighlights(targetText, analysisOutput);
|
518 |
+
document.getElementById('sourceTextReview').innerHTML = splitIntoParagraphs(sourceHighlighted);
|
519 |
+
document.getElementById('targetTextReview').innerHTML = splitIntoParagraphs(targetHighlighted);
|
520 |
const explanationHTML = generateExplanation(sourceText, analysisOutput);
|
521 |
document.getElementById('explanationText').innerHTML = explanationHTML;
|
522 |
|
523 |
const numDiffCount = (analysisOutput.match(/<([^<>]+)>/g) || []).length;
|
524 |
const missingDiffCount = (analysisOutput.match(/__(.*?)__/g) || []).length;
|
525 |
+
const dateDiffCount = (analysisOutput.match(/\[DATE\](.*?)\[\/DATE\]/g) || []).length;
|
526 |
const meaningDiffCount = (analysisOutput.match(/\[MEANING\](.*?)\[\/MEANING\]/g) || []).length;
|
527 |
+
if (numDiffCount > 0 || missingDiffCount > 0 || dateDiffCount > 0 || meaningDiffCount > 0) {
|
528 |
const summaryDiv = document.createElement('div');
|
529 |
summaryDiv.className = "p-4 rounded-xl bg-yellow-50 text-gray-800";
|
530 |
let summaryText = '<div class="font-bold mb-2">ملخص الاختلافات:</div><ul class="list-disc mr-6 space-y-1">';
|
531 |
if (numDiffCount > 0) summaryText += `<li>اختلاف في الأرقام: ${numDiffCount}</li>`;
|
532 |
if (missingDiffCount > 0) summaryText += `<li>النصوص المفقودة: ${missingDiffCount}</li>`;
|
533 |
+
if (dateDiffCount > 0) summaryText += `<li>اختلاف في التواريخ: ${dateDiffCount}</li>`;
|
534 |
if (meaningDiffCount > 0) summaryText += `<li>اختلاف في المعنى: ${meaningDiffCount}</li>`;
|
535 |
summaryText += '</ul>';
|
536 |
summaryDiv.innerHTML = summaryText;
|
|
|
543 |
}
|
544 |
});
|
545 |
|
546 |
+
// زر إعادة المراجعة (بدون اختيار نوع) يعيد تطبيق النتائج المُخزنة
|
547 |
document.getElementById('reviewAgainBtn').addEventListener('click', () => {
|
548 |
+
// إعادة عرض النتائج باستخدام البيانات المخزنة
|
549 |
+
const sourceHighlighted = applyHighlights(storedSourceText, storedAnalysisOutput);
|
550 |
+
const targetHighlighted = applyHighlights(storedTargetText, storedAnalysisOutput);
|
551 |
+
document.getElementById('sourceTextReview').innerHTML = splitIntoParagraphs(sourceHighlighted);
|
552 |
+
document.getElementById('targetTextReview').innerHTML = splitIntoParagraphs(targetHighlighted);
|
553 |
+
const explanationHTML = generateExplanation(storedSourceText, storedAnalysisOutput);
|
|
|
|
|
|
|
|
|
554 |
document.getElementById('explanationText').innerHTML = explanationHTML;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
555 |
});
|
556 |
</script>
|
557 |
</body>
|