Alhosiny commited on
Commit
bbf57f9
·
verified ·
1 Parent(s): 177e802

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +27 -14
index.html CHANGED
@@ -7,10 +7,9 @@
7
  <link href="https://fonts.googleapis.com/css2?family=Cairo:wght@600;700&display=swap" rel="stylesheet">
8
 
9
  <style>
10
- /* إعدادات أساسية لضبط المقاسات على الجوال */
11
  * {
12
  box-sizing: border-box;
13
- -webkit-tap-highlight-color: transparent; /* إخفاء مربع التحديد الأزرق عند اللمس في الجوال */
14
  }
15
 
16
  body {
@@ -27,7 +26,7 @@
27
 
28
  .container {
29
  width: 100%;
30
- max-width: 400px; /* مقاس مثالي لشاشات الهواتف */
31
  background: white;
32
  padding: 30px 20px;
33
  border-radius: 24px;
@@ -84,7 +83,7 @@
84
  }
85
 
86
  button:active {
87
- transform: scale(0.96); /* تأثير تفاعلي عند الضغط بالاصبع */
88
  box-shadow: 0 2px 5px rgba(44, 62, 80, 0.2);
89
  }
90
 
@@ -95,14 +94,22 @@
95
  box-shadow: 0 4px 10px rgba(39, 174, 96, 0.2);
96
  }
97
 
98
- /* الكانفاس (الصورة المدمجة) */
99
  canvas {
 
 
 
 
 
100
  width: 100%;
101
  height: auto;
102
  margin-top: 25px;
103
  border-radius: 16px;
104
  box-shadow: 0 8px 16px rgba(0,0,0,0.1);
105
- display: none;
 
 
 
106
  }
107
 
108
  .hint {
@@ -125,6 +132,8 @@
125
 
126
  <canvas id="myCanvas"></canvas>
127
 
 
 
128
  <button id="downloadBtn" onclick="downloadImage()">تحميل الصورة</button>
129
  <p id="downloadHint" class="hint">ملاحظة: إذا لم يعمل زر التحميل، اضغط مطولاً على الصورة واختر "حفظ الصورة".</p>
130
  </div>
@@ -150,38 +159,42 @@
150
  return;
151
  }
152
 
 
153
  ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
154
-
155
  ctx.font = "bold 80px 'Cairo'";
156
  ctx.fillStyle = "#000000";
157
  ctx.textAlign = "center";
158
-
159
  const xPosition = canvas.width / 2;
160
  const yPosition = canvas.height - 350;
161
-
162
  ctx.fillText(name, xPosition, yPosition);
163
 
164
- canvas.style.display = "block";
 
 
 
 
 
165
  document.getElementById('downloadBtn').style.display = "block";
166
  document.getElementById('downloadHint').style.display = "block";
167
 
168
- // تمرير الشاشة تلقائياً للأسفل لرؤية الصورة وزر التحميل على الجوال
169
  setTimeout(() => {
170
  window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' });
171
  }, 100);
172
  }
173
 
174
  function downloadImage() {
 
175
  try {
176
- const dataUrl = canvas.toDataURL("image/png");
177
  const link = document.createElement('a');
178
  link.download = 'ramadan-mubarak.png';
179
- link.href = dataUrl;
180
  document.body.appendChild(link);
181
  link.click();
182
  document.body.removeChild(link);
183
  } catch (error) {
184
- alert("عذراً، متصفحك يمنع التحميل المباشر لحماية الأمان. يرجى الضغط مطولاً على الصورة واختيار 'حفظ الصورة'.");
185
  }
186
  }
187
  </script>
 
7
  <link href="https://fonts.googleapis.com/css2?family=Cairo:wght@600;700&display=swap" rel="stylesheet">
8
 
9
  <style>
 
10
  * {
11
  box-sizing: border-box;
12
+ -webkit-tap-highlight-color: transparent;
13
  }
14
 
15
  body {
 
26
 
27
  .container {
28
  width: 100%;
29
+ max-width: 400px;
30
  background: white;
31
  padding: 30px 20px;
32
  border-radius: 24px;
 
83
  }
84
 
85
  button:active {
86
+ transform: scale(0.96);
87
  box-shadow: 0 2px 5px rgba(44, 62, 80, 0.2);
88
  }
89
 
 
94
  box-shadow: 0 4px 10px rgba(39, 174, 96, 0.2);
95
  }
96
 
97
+ /* الكانفاس أصبح مخفياً دائماً، نحن نستخدمه للرسم فقط وليس للعرض */
98
  canvas {
99
+ display: none !important;
100
+ }
101
+
102
+ /* هذا هو عنصر الصورة الحقيقية الذي سيتم عرضه للمستخدم */
103
+ #finalImage {
104
  width: 100%;
105
  height: auto;
106
  margin-top: 25px;
107
  border-radius: 16px;
108
  box-shadow: 0 8px 16px rgba(0,0,0,0.1);
109
+ display: none; /* مخفي حتى تكتمل الصورة */
110
+ /* تحسينات اللمس للجوال */
111
+ -webkit-user-select: none;
112
+ user-select: none;
113
  }
114
 
115
  .hint {
 
132
 
133
  <canvas id="myCanvas"></canvas>
134
 
135
+ <img id="finalImage" alt="تهنئة رمضان لأسرة العصيل">
136
+
137
  <button id="downloadBtn" onclick="downloadImage()">تحميل الصورة</button>
138
  <p id="downloadHint" class="hint">ملاحظة: إذا لم يعمل زر التحميل، اضغط مطولاً على الصورة واختر "حفظ الصورة".</p>
139
  </div>
 
159
  return;
160
  }
161
 
162
+ // 1. الرسم على الكانفاس المخفي
163
  ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
 
164
  ctx.font = "bold 80px 'Cairo'";
165
  ctx.fillStyle = "#000000";
166
  ctx.textAlign = "center";
 
167
  const xPosition = canvas.width / 2;
168
  const yPosition = canvas.height - 350;
 
169
  ctx.fillText(name, xPosition, yPosition);
170
 
171
+ // 2. تحويل الرسمة إلى صورة حقيقية وعرضها (هذا هو الحل لمشكلة التعليق!)
172
+ const finalImage = document.getElementById('finalImage');
173
+ finalImage.src = canvas.toDataURL("image/png");
174
+ finalImage.style.display = "block";
175
+
176
+ // إظهار الأزرار
177
  document.getElementById('downloadBtn').style.display = "block";
178
  document.getElementById('downloadHint').style.display = "block";
179
 
180
+ // التمرير للأسفل
181
  setTimeout(() => {
182
  window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' });
183
  }, 100);
184
  }
185
 
186
  function downloadImage() {
187
+ // الآن نأخذ رابط التحميل من الصورة الحقيقية
188
  try {
189
+ const finalImgSrc = document.getElementById('finalImage').src;
190
  const link = document.createElement('a');
191
  link.download = 'ramadan-mubarak.png';
192
+ link.href = finalImgSrc;
193
  document.body.appendChild(link);
194
  link.click();
195
  document.body.removeChild(link);
196
  } catch (error) {
197
+ alert("عذراً، متصفحك يمنع التحميل المباشر. يرجى الضغط مطولاً على الصورة واختيار 'حفظ الصورة'.");
198
  }
199
  }
200
  </script>