youssefreda9 commited on
Commit
565d2f9
·
1 Parent(s): 6a06042

fix: Correct toast types (warning/error) + analyze API error toast + cleanup

Browse files
Files changed (2) hide show
  1. src/index.html +6 -6
  2. src/js/editor.js +1 -0
src/index.html CHANGED
@@ -1226,7 +1226,7 @@
1226
  let _dialectResult = '';
1227
  async function convertDialect() {
1228
  var input = document.getElementById('dialect-input').value.trim();
1229
- if (!input) { if (typeof showToast === 'function') showToast('الرجاء كتابة نص أولاً'); return; }
1230
 
1231
  var resultCard = document.getElementById('dialect-result-card');
1232
  var resultDiv = document.getElementById('dialect-result');
@@ -1309,7 +1309,7 @@
1309
  const sel = window.getSelection();
1310
  const text = sel ? sel.toString().trim() : '';
1311
  if (!text) {
1312
- if (typeof showToast === 'function') showToast('علّم على النص القرآني أولاً');
1313
  return;
1314
  }
1315
  // Save selection range before modal steals focus
@@ -1500,25 +1500,25 @@
1500
 
1501
  function applyQuranText() {
1502
  if (!_quranVerseClean || !_quranCurrentQuery) {
1503
- if (typeof showToast === 'function') showToast('لا يوجد نص للتطبيق');
1504
  return;
1505
  }
1506
  if (_replaceInEditor(_quranVerseClean, _quranRef)) {
1507
  if (typeof showToast === 'function') showToast('✓ تم تطبيق النص القرآني المدقق');
1508
  } else {
1509
- if (typeof showToast === 'function') showToast('لم يتم العثور على النص الأصلي');
1510
  }
1511
  }
1512
 
1513
  function applyQuranTranslation() {
1514
  if (!_quranTransClean || !_quranCurrentQuery) {
1515
- if (typeof showToast === 'function') showToast('لا يوجد ترجمة للتطبيق');
1516
  return;
1517
  }
1518
  if (_replaceInEditor(_quranTransClean, _quranTransRef)) {
1519
  if (typeof showToast === 'function') showToast('✓ تم تطبيق الترجمة');
1520
  } else {
1521
- if (typeof showToast === 'function') showToast('لم يتم العثور على النص الأصلي');
1522
  }
1523
  }
1524
 
 
1226
  let _dialectResult = '';
1227
  async function convertDialect() {
1228
  var input = document.getElementById('dialect-input').value.trim();
1229
+ if (!input) { if (typeof showToast === 'function') showToast('الرجاء كتابة نص أولاً', 'warning'); return; }
1230
 
1231
  var resultCard = document.getElementById('dialect-result-card');
1232
  var resultDiv = document.getElementById('dialect-result');
 
1309
  const sel = window.getSelection();
1310
  const text = sel ? sel.toString().trim() : '';
1311
  if (!text) {
1312
+ if (typeof showToast === 'function') showToast('علّم على النص القرآني أولاً', 'warning');
1313
  return;
1314
  }
1315
  // Save selection range before modal steals focus
 
1500
 
1501
  function applyQuranText() {
1502
  if (!_quranVerseClean || !_quranCurrentQuery) {
1503
+ if (typeof showToast === 'function') showToast('لا يوجد نص للتطبيق', 'warning');
1504
  return;
1505
  }
1506
  if (_replaceInEditor(_quranVerseClean, _quranRef)) {
1507
  if (typeof showToast === 'function') showToast('✓ تم تطبيق النص القرآني المدقق');
1508
  } else {
1509
+ if (typeof showToast === 'function') showToast('لم يتم العثور على النص الأصلي', 'error');
1510
  }
1511
  }
1512
 
1513
  function applyQuranTranslation() {
1514
  if (!_quranTransClean || !_quranCurrentQuery) {
1515
+ if (typeof showToast === 'function') showToast('لا يوجد ترجمة للتطبيق', 'warning');
1516
  return;
1517
  }
1518
  if (_replaceInEditor(_quranTransClean, _quranTransRef)) {
1519
  if (typeof showToast === 'function') showToast('✓ تم تطبيق الترجمة');
1520
  } else {
1521
+ if (typeof showToast === 'function') showToast('لم يتم العثور على النص الأصلي', 'error');
1522
  }
1523
  }
1524
 
src/js/editor.js CHANGED
@@ -323,6 +323,7 @@ async function analyzeText() {
323
  if (error.name === 'AbortError') return;
324
  console.error('Analysis error:', error);
325
  renderWithoutSuggestions(text);
 
326
  } finally {
327
  setAnalyzingState(false);
328
  }
 
323
  if (error.name === 'AbortError') return;
324
  console.error('Analysis error:', error);
325
  renderWithoutSuggestions(text);
326
+ if (typeof showToast === 'function') showToast('\u062a\u0639\u0630\u0651\u0631 \u0627\u0644\u062a\u062d\u0644\u064a\u0644 \u2014 \u062a\u062d\u0642\u0642 \u0645\u0646 \u0627\u0644\u0627\u062a\u0635\u0627\u0644', 'error');
327
  } finally {
328
  setAnalyzingState(false);
329
  }