Amartala commited on
Commit
ad50e1c
·
verified ·
1 Parent(s): 8ea1c7f

<!DOCTYPE html>

Browse files

<html lang="ar">
<head>
<meta charset="UTF-8">
<title>تحليل الوسائط الإعلامية</title>
<style>
body { font-family: Arial; direction: rtl; margin: 20px; }
textarea { width: 100%; }
#result { white-space: pre-wrap; background: #f3f3f3; padding: 10px; margin-top: 20px; }
img { max-width: 300px; display: block; margin-top: 10px; }
</style>
</head>
<body>
<h1>تحليل الوسائط الإعلامية</h1>

<form id="analyzeForm">
<label>نص التحليل:</label><br>
<textarea name="userText" rows="4" placeholder="أدخل نص التحليل هنا"></textarea><br><br>
<label>اختر صورة:</label><br>
<input type="file" name="media" accept="image/*" required><br><br>
<button type="submit">تحليل</button>
</form>

<div id="preview"></div>
<div id="result"></div>

<script>
const AZURE_ENDPOINT = "https://lahja-dev-resource2.openai.azure.com/openai/deployments/Wasm-V1/chat/completions?api-version=2025-01-01-preview";
const AZURE_API_KEY = "E7k8z3ADEUi2DZ1dl9pHlSTeUSoKb3jVjg5zYDAPNHBHKBfXlbTFJQQJ99BJACHYHv6XJ3w3AAAAACOGyF4Z";
const DEPLOYMENT = "Wasm-V1";
const PROMPT_MEDIA_ANALYSIS = """
أنت خبير في تحليل انتشار الوسائط الرقمية (صور / فيديوهات) على الإنترنت.

المطلوب:
قم بتحليل الوسائط المرفقة والنص المصاحب لها لاستخراج وتحليل العناصر التالية:

🔹 1. نوع الوسيط:
- صورة / فيديو / صورة مع نص.
🔹 2. عدد المنشورات التي تتضمن هذا الوسيط أو نسخًا مشابهة منه.
🔹 3. المنصات التي انتشر عليها الوسيط (تويتر، إنستغرام، تيك توك، يوتيوب، فيسبوك...).
🔹 4. مستوى الانتشار:
- محلي (داخل دولة معينة).
- إقليمي.
- عالمي.
🔹 5. نسب التفاعل الإجمالية:
- الإعجابات.
- المشاركات / إعادة النشر.
- التعليقات.
🔹 6. الفترات الزمنية الأبرز في الانتشار (مثل: يوم الذروة، مدة الانتشار).
🔹 7. تحليل دلالي لمحتوى الصورة / الفيديو:
- ما الذي يظهر في الوسيط؟
- الرسالة أو الانطباع العام الذي يقدمه للجمهور.
🔹 8. تقييم موثوقية المصدر واحتمالية التلاعب أو التعديل في الصورة/الفيديو.
🔹 9. إذا كانت هناك صور أو مقاطع مشابهة، فحلل أوجه التشابه وأي أنماط تكرار.

🧾 النص الوصفي أو التحليلي المرفق:
{user_text}

🖼️ الوسائط المرفقة:
(يتم تحليل الصورة أو الفيديو المرفق كجزء من الإدخال)
"""
const form = document.getElementById("analyzeForm");
const previewDiv = document.getElementById("preview");
const resultDiv = document.getElementById("result");

form.addEventListener("submit", async (e) => {
e.preventDefault();
resultDiv.textContent = "جارٍ التحليل...";
previewDiv.innerHTML = "";

const userText = form.userText.value;
const file = form.media.files[0];

if (!file) return alert("اختر صورة");

// عرض المعاينة
const imgPreview = document.createElement("img");
imgPreview.src = URL.createObjectURL(file);
previewDiv.appendChild(imgPreview);

// تحويل الصورة إلى Base64
const reader = new FileReader();
reader.onloadend = async () => {
const base64Image = reader.result;

const chat_prompt = [
{ role: "system", content:PROMPT_MEDIA_ANALYSIS},
{ role: "user", content: `${userText}\nالصورة: ${base64Image}` }
];

try {
const res = await fetch(AZURE_ENDPOINT, {
method: "POST",
headers: {
"Content-Type": "application/json",
"api-key": AZURE_API_KEY
},
body: JSON.stringify({
model: DEPLOYMENT,
messages: chat_prompt,
max_completion_tokens: 1024,
stream: false
})
});

const data = await res.json();
const analysis = data.choices?.[0]?.message?.content || "لم يتم الحصول على نتيجة";
resultDiv.textContent = analysis;

} catch (err) {
resultDiv.textContent = "حدث خطأ: " + err.message;
}
};

reader.readAsDataURL(file);
});
</script>

</body>
</html>

Files changed (1) hide show
  1. index.html +206 -8
index.html CHANGED
@@ -53,9 +53,17 @@
53
 
54
  <!-- Main Card -->
55
  <div class="bg-white rounded-xl shadow-2xl overflow-hidden max-w-4xl mx-auto">
56
- <!-- Upload Section -->
57
- <div class="p-8 border-b border-gray-200">
58
- <div class="flex flex-col md:flex-row gap-8 items-center">
 
 
 
 
 
 
 
 
59
  <div class="flex-1">
60
  <h2 class="text-2xl font-semibold text-gray-800 mb-4">تحميل الصورة للتحليل</h2>
61
  <p class="text-gray-600 mb-6">اسحب وأسقط صورتك هنا أو انقر لتحديد ملف. سيتم تحليل المحتوى باستخدام نماذج الذكاء الاصطناعي المتطورة.</p>
@@ -90,10 +98,9 @@
90
  </div>
91
  </div>
92
  </div>
93
-
94
  <!-- Results Section -->
95
- <div class="p-8">
96
- <h2 class="text-2xl font-semibold text-gray-800 mb-6">نتائج التحليل</h2>
97
 
98
  <div id="loadingIndicator" class="hidden flex flex-col items-center py-12">
99
  <div class="animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-indigo-500 mb-4"></div>
@@ -136,11 +143,175 @@
136
  <footer class="text-center py-8 mt-12 text-gray-500 text-sm">
137
  <p>© 2023 VisionVortex. جميع الحقوق محفوظة.</p>
138
  </footer>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
 
140
  <script>
141
  feather.replace();
142
 
143
- // Initialize Vanta.js background
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  VANTA.GLOBE({
145
  el: "#vanta-bg",
146
  mouseControls: true,
@@ -333,6 +504,33 @@
333
  };
334
  }
335
  }
336
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
337
  </body>
338
  </html>
 
53
 
54
  <!-- Main Card -->
55
  <div class="bg-white rounded-xl shadow-2xl overflow-hidden max-w-4xl mx-auto">
56
+ <!-- Navigation Tabs -->
57
+ <div class="flex justify-center mb-8">
58
+ <div class="inline-flex rounded-lg bg-gray-100 p-1">
59
+ <button id="imageAnalysisTab" class="px-4 py-2 rounded-md font-medium text-indigo-600 bg-white shadow-sm">تحليل الصور</button>
60
+ <button id="mediaAnalysisTab" class="px-4 py-2 rounded-md font-medium text-gray-500">تحليل الوسائط الإعلامية</button>
61
+ </div>
62
+ </div>
63
+
64
+ <!-- Image Analysis Section -->
65
+ <div id="imageAnalysisSection" class="p-8 border-b border-gray-200">
66
+ <div class="flex flex-col md:flex-row gap-8 items-center">
67
  <div class="flex-1">
68
  <h2 class="text-2xl font-semibold text-gray-800 mb-4">تحميل الصورة للتحليل</h2>
69
  <p class="text-gray-600 mb-6">اسحب وأسقط صورتك هنا أو انقر لتحديد ملف. سيتم تحليل المحتوى باستخدام نماذج الذكاء الاصطناعي المتطورة.</p>
 
98
  </div>
99
  </div>
100
  </div>
 
101
  <!-- Results Section -->
102
+ <div id="imageResultsSection" class="p-8">
103
+ <h2 class="text-2xl font-semibold text-gray-800 mb-6">نتائج التحليل</h2>
104
 
105
  <div id="loadingIndicator" class="hidden flex flex-col items-center py-12">
106
  <div class="animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-indigo-500 mb-4"></div>
 
143
  <footer class="text-center py-8 mt-12 text-gray-500 text-sm">
144
  <p>© 2023 VisionVortex. جميع الحقوق محفوظة.</p>
145
  </footer>
146
+ <!-- Media Analysis Section (hidden by default) -->
147
+ <div id="mediaAnalysisSection" class="hidden p-8 border-b border-gray-200">
148
+ <div class="flex flex-col md:flex-row gap-8 items-center">
149
+ <div class="flex-1">
150
+ <h2 class="text-2xl font-semibold text-gray-800 mb-4">تحليل الوسائط الإعلامية</h2>
151
+ <p class="text-gray-600 mb-6">أدخل النص المرافق للوسائط واختر الصورة لتحليل انتشارها وتفاعلاتها</p>
152
+
153
+ <form id="analyzeForm" class="space-y-4">
154
+ <div>
155
+ <label class="block text-gray-700 mb-2">نص التحليل:</label>
156
+ <textarea name="userText" rows="4" class="w-full p-3 border border-gray-300 rounded-lg" placeholder="أدخل نص التحليل هنا"></textarea>
157
+ </div>
158
+
159
+ <div>
160
+ <label class="block text-gray-700 mb-2">اختر صورة:</label>
161
+ <input type="file" name="media" accept="image/*" required class="w-full">
162
+ </div>
163
+
164
+ <button type="submit" class="bg-indigo-600 hover:bg-indigo-700 text-white px-6 py-3 rounded-lg font-medium flex items-center gap-2 transition">
165
+ <i data-feather="search"></i>
166
+ تحليل الوسائط
167
+ </button>
168
+ </form>
169
+ </div>
170
+
171
+ <div class="flex-1">
172
+ <div id="mediaPreview" class="relative bg-gray-100 rounded-lg overflow-hidden aspect-square">
173
+ <div class="flex flex-col items-center justify-center h-full text-gray-400">
174
+ <i data-feather="image" class="w-16 h-16 mb-4"></i>
175
+ <p>ستظهر معاينة الصورة هنا</p>
176
+ </div>
177
+ </div>
178
+ </div>
179
+ </div>
180
+ </div>
181
+
182
+ <!-- Media Results Section -->
183
+ <div id="mediaResultsSection" class="hidden p-8">
184
+ <h2 class="text-2xl font-semibold text-gray-800 mb-6">نتائج تحليل الوسائط</h2>
185
+ <div id="mediaResults" class="prose max-w-none text-gray-600 bg-gray-50 p-6 rounded-xl">
186
+ <p>سيعرض هنا نتائج تحليل الوسائط بعد الانتهاء من المعالجة.</p>
187
+ </div>
188
+ </div>
189
 
190
  <script>
191
  feather.replace();
192
 
193
+ // Tab switching functionality
194
+ const imageAnalysisTab = document.getElementById('imageAnalysisTab');
195
+ const mediaAnalysisTab = document.getElementById('mediaAnalysisTab');
196
+ const imageAnalysisSection = document.getElementById('imageAnalysisSection');
197
+ const imageResultsSection = document.getElementById('imageResultsSection');
198
+ const mediaAnalysisSection = document.getElementById('mediaAnalysisSection');
199
+ const mediaResultsSection = document.getElementById('mediaResultsSection');
200
+
201
+ imageAnalysisTab.addEventListener('click', () => {
202
+ imageAnalysisTab.classList.add('text-indigo-600', 'bg-white', 'shadow-sm');
203
+ imageAnalysisTab.classList.remove('text-gray-500');
204
+ mediaAnalysisTab.classList.remove('text-indigo-600', 'bg-white', 'shadow-sm');
205
+ mediaAnalysisTab.classList.add('text-gray-500');
206
+
207
+ imageAnalysisSection.classList.remove('hidden');
208
+ imageResultsSection.classList.remove('hidden');
209
+ mediaAnalysisSection.classList.add('hidden');
210
+ mediaResultsSection.classList.add('hidden');
211
+ });
212
+
213
+ mediaAnalysisTab.addEventListener('click', () => {
214
+ mediaAnalysisTab.classList.add('text-indigo-600', 'bg-white', 'shadow-sm');
215
+ mediaAnalysisTab.classList.remove('text-gray-500');
216
+ imageAnalysisTab.classList.remove('text-indigo-600', 'bg-white', 'shadow-sm');
217
+ imageAnalysisTab.classList.add('text-gray-500');
218
+
219
+ mediaAnalysisSection.classList.remove('hidden');
220
+ mediaResultsSection.classList.remove('hidden');
221
+ imageAnalysisSection.classList.add('hidden');
222
+ imageResultsSection.classList.add('hidden');
223
+ });
224
+
225
+ // Media Analysis Form
226
+ const analyzeForm = document.getElementById('analyzeForm');
227
+ const mediaPreview = document.getElementById('mediaPreview');
228
+ const mediaResults = document.getElementById('mediaResults');
229
+
230
+ analyzeForm.addEventListener('submit', async (e) => {
231
+ e.preventDefault();
232
+ mediaResults.textContent = "جارٍ التحليل...";
233
+
234
+ const userText = analyzeForm.userText.value;
235
+ const file = analyzeForm.media.files[0];
236
+
237
+ if (!file) return;
238
+
239
+ // Display preview
240
+ mediaPreview.innerHTML = '';
241
+ const imgPreview = document.createElement('img');
242
+ imgPreview.src = URL.createObjectURL(file);
243
+ imgPreview.className = 'absolute inset-0 w-full h-full object-contain';
244
+ mediaPreview.appendChild(imgPreview);
245
+
246
+ // Convert image to Base64
247
+ const reader = new FileReader();
248
+ reader.onloadend = async () => {
249
+ const base64Image = reader.result;
250
+
251
+ try {
252
+ const response = await analyzeMediaContent(userText, base64Image);
253
+ mediaResults.innerHTML = response;
254
+ } catch (err) {
255
+ mediaResults.textContent = "حدث خطأ: " + err.message;
256
+ }
257
+ };
258
+
259
+ reader.readAsDataURL(file);
260
+ });
261
+
262
+ async function analyzeMediaContent(userText, imageData) {
263
+ // Replace with your actual Azure credentials and endpoint
264
+ const AZURE_ENDPOINT = "https://lahja-dev-resource2.openai.azure.com/openai/deployments/Wasm-V1/chat/completions?api-version=2025-01-01-preview";
265
+ const AZURE_API_KEY = "E7k8z3ADEUi2DZ1dl9pHlSTeUSoKb3jVjg5zYDAPNHBHKBfXlbTFJQQJ99BJACHYHv6XJ3w3AAAAACOGyF4Z";
266
+
267
+ const PROMPT = `أنت خبير في تحليل انتشار الوسائط الرقمية (صور / فيديوهات) على الإنترنت.
268
+
269
+ المطلوب:
270
+ قم بتحليل الوسائط المرفقة والنص المصاحب لها لاستخراج وتحليل العناصر التالية:
271
+
272
+ 🔹 1. نوع الوسيط:
273
+ - صورة / فيديو / صورة مع نص.
274
+ 🔹 2. عدد المنشورات التي تتضمن هذا الوسيط أو نسخًا مشابهة منه.
275
+ 🔹 3. المنصات التي انتشر عليها الوسيط (تويتر، إنستغرام، تيك توك، يوتيوب، فيسبوك...).
276
+ 🔹 4. مستوى الانتشار:
277
+ - محلي (داخل دولة معينة).
278
+ - إقليمي.
279
+ - عالمي.
280
+ 🔹 5. نسب التفاعل الإجمالية:
281
+ - الإعجابات.
282
+ - المشاركات / إعادة النشر.
283
+ - التعليقات.
284
+ 🔹 6. الفترات الزمنية الأبرز في الانتشار (مثل: يوم الذروة، مدة الانتشار).
285
+ 🔹 7. تحليل دلالي لمحتوى الصورة / الفيديو:
286
+ - ما الذي يظهر في الوسيط؟
287
+ - الرسالة أو الانطباع العام الذي يقدمه للجمهور.
288
+ 🔹 8. تقييم موثوقية المصدر واحتمالية التلاعب أو التعديل في الصورة/الفيديو.
289
+ 🔹 9. إذا كانت هناك صور أو مقاطع مشابهة، فحلل أوجه التشابه وأي أنماط تكرار.
290
+
291
+ 🧾 النص الوصفي أو التحليلي المرفق:
292
+ ${userText || "لا يوجد نص مرفق"}`;
293
+
294
+ const chat_prompt = [
295
+ { role: "system", content: PROMPT },
296
+ { role: "user", content: `الصورة: ${imageData}` }
297
+ ];
298
+
299
+ const res = await fetch(AZURE_ENDPOINT, {
300
+ method: "POST",
301
+ headers: {
302
+ "Content-Type": "application/json",
303
+ "api-key": AZURE_API_KEY
304
+ },
305
+ body: JSON.stringify({
306
+ messages: chat_prompt,
307
+ max_tokens: 2048
308
+ })
309
+ });
310
+
311
+ const data = await res.json();
312
+ return data.choices?.[0]?.message?.content || "لم يتم الحصول على نتيجة";
313
+ }
314
+ // Initialize Vanta.js background
315
  VANTA.GLOBE({
316
  el: "#vanta-bg",
317
  mouseControls: true,
 
504
  };
505
  }
506
  }
507
+ // Initialize with your actual Azure credentials
508
+ const AZURE_ENDPOINT = "https://your-resource-name.openai.azure.com/openai/deployments/your-deployment-name/chat/completions?api-version=2023-05-15";
509
+ const AZURE_API_KEY = "your-api-key-here";
510
+ const DEPLOYMENT = "your-deployment-name";
511
+
512
+ // Helper function to format API response
513
+ function parseAnalysisResponse(text) {
514
+ try {
515
+ // Try to parse as JSON first
516
+ return JSON.parse(text);
517
+ } catch (e) {
518
+ // Fallback to extracting sections from plain text
519
+ const summaryMatch = text.match(/ملخص:(.*?)(?=الكلمات المفتاحية|$)/s);
520
+ const keywordsMatch = text.match(/الكلمات المفتاحية:(.*?)(?=التقرير التفصيلي|$)/s);
521
+ const reportMatch = text.match(/التقرير التفصيلي:(.*)/s);
522
+
523
+ return {
524
+ summary: summaryMatch ? summaryMatch[1].trim() : "لا يوجد ملخص متاح",
525
+ keywords: keywordsMatch ?
526
+ keywordsMatch[1].trim().split(',').map(k => k.trim()) :
527
+ ["لا يوجد كلمات مفتاحية"],
528
+ detailed_report: reportMatch ?
529
+ `<p>${reportMatch[1].trim().replace(/\n/g, '</p><p>')}</p>` :
530
+ "<p>لا يوجد تقرير متاح</p>"
531
+ };
532
+ }
533
+ }
534
+ </script>
535
  </body>
536
  </html>