Opera8 commited on
Commit
a20d9f6
·
verified ·
1 Parent(s): 30f6720

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +154 -17
index.html CHANGED
@@ -20,6 +20,8 @@
20
  --accent-glow: rgba(74, 108, 250, 0.2);
21
  --success-color: #38A169;
22
  --danger-color: #e53e3e;
 
 
23
  --radius-card: 20px;
24
  --radius-btn: 14px;
25
  }
@@ -62,7 +64,22 @@
62
  background: linear-gradient(90deg, #2d3748, #4A6CFA);
63
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
64
  }
65
- .subtitle { font-size: 0.9rem; color: var(--text-secondary); margin-top: 5px; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
  .card {
68
  background: var(--panel-bg);
@@ -138,11 +155,16 @@
138
 
139
  /* پلیر و متن */
140
  .player-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; padding-bottom: 15px; border-bottom: 1px solid var(--panel-border); }
141
- #mainDownloadLink {
 
 
142
  background-color: rgba(74, 108, 250, 0.1); color: var(--accent-primary); text-decoration: none; font-size: 0.9rem;
143
- font-weight: 700; padding: 8px 16px; border-radius: 10px; transition: 0.2s; display: none;
144
  }
145
- #mainDownloadLink:hover { background-color: rgba(74, 108, 250, 0.2); }
 
 
 
146
  .audio-item { margin-bottom: 10px; }
147
  audio { width: 100%; height: 45px; border-radius: 20px; margin-top: 5px; }
148
  .lyrics-container {
@@ -160,7 +182,7 @@
160
  .bar:nth-child(4) { animation-delay: 0.3s; height: 50%; }
161
  @keyframes jump { 0%, 100% { height: 20%; } 50% { height: 100%; } }
162
 
163
- /* --- استایل‌های جدید تاریخچه و حذف --- */
164
  #historySection { margin-top: 30px; width: 100%; }
165
  .history-title { font-size: 1.2rem; font-weight: 800; color: var(--text-primary); margin-bottom: 15px; display: flex; align-items: center; gap: 10px; }
166
  .history-list { display: grid; gap: 12px; }
@@ -174,9 +196,8 @@
174
  .h-details h4 { margin: 0; font-size: 1rem; color: var(--text-primary); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
175
  .h-details span { font-size: 0.8rem; color: var(--text-secondary); }
176
 
177
- /* دکمه حذف در سمت چپ */
178
  .h-delete {
179
- position: absolute; left: 15px; /* سمت چپ فیزیکی */
180
  background: #fee2e2; color: var(--danger-color);
181
  width: 38px; height: 38px; border-radius: 50%;
182
  display: flex; align-items: center; justify-content: center;
@@ -186,7 +207,7 @@
186
  .history-card:hover .h-delete { opacity: 1; transform: scale(1); }
187
  .h-delete:hover { background: var(--danger-color); color: white; transform: scale(1.1); }
188
 
189
- /* مودال حذف */
190
  .modal-overlay {
191
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
192
  background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(8px);
@@ -212,7 +233,24 @@
212
  .btn-confirm { background: var(--danger-color); color: white; box-shadow: 0 5px 15px rgba(229, 62, 62, 0.3); }
213
  .btn-confirm:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(229, 62, 62, 0.4); }
214
 
215
- /* نمایش مودال */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
  .modal-overlay.open { display: flex; opacity: 1; }
217
  .modal-overlay.open .modal-box { transform: scale(1); }
218
  </style>
@@ -226,7 +264,8 @@
226
  <svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18V5l12-2v13"></path><circle cx="6" cy="18" r="3"></circle><circle cx="18" cy="16" r="3"></circle></svg>
227
  </div>
228
  <h1>استودیو موزیک آلفا</h1>
229
- <p class="subtitle">ساخت آهنگ حرفه‌ای با هوش مصنوعی</p>
 
230
  </header>
231
 
232
  <div id="step1" class="card">
@@ -258,7 +297,7 @@
258
  <div id="finalResult" class="card" style="display:none;">
259
  <div class="player-header">
260
  <div id="resultHeaderText" style="font-weight: 700; display: flex; align-items: center; gap: 5px;"></div>
261
- <a id="mainDownloadLink" href="#" target="_blank" download>دانلود آهنگ 📥</a>
262
  </div>
263
  <div id="playerWrapper"></div>
264
  <div class="form-label" style="margin-top: 20px; justify-content: center; color: #718096;">متن آهنگ</div>
@@ -290,10 +329,28 @@
290
  </div>
291
  </div>
292
 
 
 
 
 
 
 
 
 
 
 
 
 
 
293
  <script>
294
  const ACE_SPACE_URL = "https://ace-step-ace-step-v1-5.hf.space/";
 
 
 
 
295
  let db;
296
- let songToDeleteId = null; // برای نگهداری شناسه آهنگی که قرار است حذف شود
 
297
 
298
  // المان‌ها
299
  const ideaInput = document.getElementById('ideaInput');
@@ -304,10 +361,12 @@
304
  const finalResult = document.getElementById('finalResult');
305
  const playerWrapper = document.getElementById('playerWrapper');
306
  const finalLyricsBox = document.getElementById('finalLyricsBox');
307
- const mainDownloadLink = document.getElementById('mainDownloadLink');
308
  const historyList = document.getElementById('historyList');
309
  const historySection = document.getElementById('historySection');
310
  const deleteModal = document.getElementById('deleteConfirmModal');
 
 
311
 
312
  const getVal = (id) => document.getElementById(id).value;
313
  const getNum = (id) => Number(document.getElementById(id).value);
@@ -322,6 +381,76 @@
322
  });
323
  }
324
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
325
  // --- مدیریت دیتابیس ---
326
  function initDB() {
327
  const request = indexedDB.open("alphaMusicDB", 1);
@@ -332,6 +461,7 @@
332
 
333
  async function saveToHistory(idea, lyrics, audioUrl) {
334
  try {
 
335
  const response = await fetch(audioUrl);
336
  const audioBlob = await response.blob();
337
  const newItem = {
@@ -415,6 +545,9 @@
415
  deleteModal.addEventListener('click', (e) => {
416
  if (e.target === deleteModal) closeDeleteModal();
417
  });
 
 
 
418
 
419
  function openHistoryItem(item) {
420
  step1.style.display = 'none';
@@ -425,8 +558,10 @@
425
  headerText.innerHTML = `<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path><polyline points="22 4 12 14.01 9 11.01"></polyline></svg> آهنگ آرشیو شده`;
426
  headerText.style.color = 'var(--accent-primary)';
427
 
428
- mainDownloadLink.href = audioURL;
429
- mainDownloadLink.style.display = 'inline-block';
 
 
430
  playerWrapper.innerHTML = `<audio controls autoplay src="${audioURL}"></audio>`;
431
  finalLyricsBox.innerHTML = formatLyrics(item.lyrics);
432
 
@@ -498,8 +633,10 @@
498
  hasResult = true;
499
 
500
  if (processedUrls.size === 1) {
501
- mainDownloadLink.href = fullUrl;
502
- mainDownloadLink.style.display = 'inline-block';
 
 
503
  saveToHistory(idea, lyrics, fullUrl);
504
  }
505
  playerWrapper.innerHTML += `<div class="audio-item"><audio controls autoplay src="${fullUrl}"></audio></div>`;
 
20
  --accent-glow: rgba(74, 108, 250, 0.2);
21
  --success-color: #38A169;
22
  --danger-color: #e53e3e;
23
+ --premium-gold: #FFC107;
24
+ --premium-gradient: linear-gradient(135deg, #FFC107 0%, #FF9800 100%);
25
  --radius-card: 20px;
26
  --radius-btn: 14px;
27
  }
 
64
  background: linear-gradient(90deg, #2d3748, #4A6CFA);
65
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
66
  }
67
+ .subtitle { font-size: 0.9rem; color: var(--text-secondary); margin-top: 5px; margin-bottom: 10px; }
68
+
69
+ /* استایل بج وضعیت اشتراک */
70
+ .status-badge {
71
+ display: inline-block; padding: 6px 16px; border-radius: 20px;
72
+ font-size: 0.85rem; font-weight: 700; margin-top: 5px;
73
+ letter-spacing: 0.5px; opacity: 0; transform: translateY(-5px);
74
+ transition: all 0.5s ease;
75
+ }
76
+ .status-badge.visible { opacity: 1; transform: translateY(0); }
77
+ .badge-free { background: #E2E8F0; color: #64748b; }
78
+ .badge-premium {
79
+ background: var(--premium-gradient); color: #fff;
80
+ box-shadow: 0 4px 15px rgba(255, 193, 7, 0.4);
81
+ text-shadow: 0 1px 2px rgba(0,0,0,0.1);
82
+ }
83
 
84
  .card {
85
  background: var(--panel-bg);
 
155
 
156
  /* پلیر و متن */
157
  .player-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; padding-bottom: 15px; border-bottom: 1px solid var(--panel-border); }
158
+
159
+ /* استایل دکمه دانلود */
160
+ .download-btn-style {
161
  background-color: rgba(74, 108, 250, 0.1); color: var(--accent-primary); text-decoration: none; font-size: 0.9rem;
162
+ font-weight: 700; padding: 8px 16px; border-radius: 10px; transition: 0.2s; display: inline-flex; align-items: center; gap: 5px; cursor: pointer; border: none;
163
  }
164
+ .download-btn-style:hover { background-color: rgba(74, 108, 250, 0.2); }
165
+ .download-btn-style.locked { background-color: #f1f5f9; color: #94a3b8; }
166
+ .download-btn-style.locked:hover { background-color: #e2e8f0; }
167
+
168
  .audio-item { margin-bottom: 10px; }
169
  audio { width: 100%; height: 45px; border-radius: 20px; margin-top: 5px; }
170
  .lyrics-container {
 
182
  .bar:nth-child(4) { animation-delay: 0.3s; height: 50%; }
183
  @keyframes jump { 0%, 100% { height: 20%; } 50% { height: 100%; } }
184
 
185
+ /* --- استایل‌های تاریخچه و حذف --- */
186
  #historySection { margin-top: 30px; width: 100%; }
187
  .history-title { font-size: 1.2rem; font-weight: 800; color: var(--text-primary); margin-bottom: 15px; display: flex; align-items: center; gap: 10px; }
188
  .history-list { display: grid; gap: 12px; }
 
196
  .h-details h4 { margin: 0; font-size: 1rem; color: var(--text-primary); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
197
  .h-details span { font-size: 0.8rem; color: var(--text-secondary); }
198
 
 
199
  .h-delete {
200
+ position: absolute; left: 15px;
201
  background: #fee2e2; color: var(--danger-color);
202
  width: 38px; height: 38px; border-radius: 50%;
203
  display: flex; align-items: center; justify-content: center;
 
207
  .history-card:hover .h-delete { opacity: 1; transform: scale(1); }
208
  .h-delete:hover { background: var(--danger-color); color: white; transform: scale(1.1); }
209
 
210
+ /* مودال‌ها */
211
  .modal-overlay {
212
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
213
  background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(8px);
 
233
  .btn-confirm { background: var(--danger-color); color: white; box-shadow: 0 5px 15px rgba(229, 62, 62, 0.3); }
234
  .btn-confirm:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(229, 62, 62, 0.4); }
235
 
236
+ /* مودال ارتقا */
237
+ @keyframes pulse-gold { 0% { box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.7); } 70% { box-shadow: 0 0 0 15px rgba(255, 193, 7, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 193, 7, 0); } }
238
+ .upgrade-icon {
239
+ width: 70px; height: 70px;
240
+ background: var(--premium-gradient);
241
+ border-radius: 50%; color: white; margin: 0 auto 20px;
242
+ display: flex; align-items: center; justify-content: center;
243
+ font-size: 2rem; animation: pulse-gold 2s infinite;
244
+ }
245
+ .btn-upgrade {
246
+ background: var(--premium-gradient); color: #333;
247
+ box-shadow: 0 5px 15px rgba(255, 193, 7, 0.3);
248
+ }
249
+ .btn-upgrade:hover {
250
+ transform: translateY(-2px);
251
+ box-shadow: 0 8px 25px rgba(255, 193, 7, 0.5);
252
+ }
253
+
254
  .modal-overlay.open { display: flex; opacity: 1; }
255
  .modal-overlay.open .modal-box { transform: scale(1); }
256
  </style>
 
264
  <svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18V5l12-2v13"></path><circle cx="6" cy="18" r="3"></circle><circle cx="18" cy="16" r="3"></circle></svg>
265
  </div>
266
  <h1>استودیو موزیک آلفا</h1>
267
+ <p class="subtitle">ساخت آهنگ حرفه‌ای با هوش مصنوعی</p>
268
+ <div id="statusBadge" class="status-badge">نسخه رایگان</div>
269
  </header>
270
 
271
  <div id="step1" class="card">
 
297
  <div id="finalResult" class="card" style="display:none;">
298
  <div class="player-header">
299
  <div id="resultHeaderText" style="font-weight: 700; display: flex; align-items: center; gap: 5px;"></div>
300
+ <button id="mainDownloadBtn" class="download-btn-style">دانلود آهنگ 📥</button>
301
  </div>
302
  <div id="playerWrapper"></div>
303
  <div class="form-label" style="margin-top: 20px; justify-content: center; color: #718096;">متن آهنگ</div>
 
329
  </div>
330
  </div>
331
 
332
+ <!-- مودال ارتقا به نسخه کامل -->
333
+ <div class="modal-overlay" id="upgradeModal">
334
+ <div class="modal-box">
335
+ <div class="upgrade-icon">👑</div>
336
+ <h3 style="font-weight: 800; color: #333;">دانلود مخصوص اعضای ویژه</h3>
337
+ <p style="margin-bottom: 25px; line-height: 1.6;">برای دانلود آهنگ‌های ساخته شده با کیفیت اصلی و بدون محدودیت، لطفا حساب کاربری خود را به نسخه نامحدود ارتقا دهید.</p>
338
+ <div class="modal-actions" style="flex-direction: column;">
339
+ <button class="btn-modal btn-upgrade" id="btnGoPremium">⭐️ ارتقا به نسخه کامل</button>
340
+ <button class="btn-modal btn-cancel" onclick="closeUpgradeModal()" style="width: 100%;">فعلاً نه</button>
341
+ </div>
342
+ </div>
343
+ </div>
344
+
345
  <script>
346
  const ACE_SPACE_URL = "https://ace-step-ace-step-v1-5.hf.space/";
347
+ // مشخصات نسخه پولی
348
+ const PREMIUM_PAGE_ID = '1149636';
349
+ const PREMIUM_URL = '#/nav/online/news/getSingle/1149636/eyJpdiI6InZSVUdlLzBlR0FzOHZJdXFZeWhER0E9PSIsInZhbHVlIjoiWFhqRXBLc29vSFpHdk9nYmRjZGVuWHRHRHVSZHRlTG1BUENLaE5mNXBNVVRGWFg3ZWN0djJ5K1dIY1RqTHJGaCIsIm1hYyI6IjIzYzFlZTMwYmVmMTdkYjQ0YTQ4YWMxNmFhN2RmNWQ2OTU0MjI0ZWVlZGI3ZjJjMjhkNmQxNjM4MDFlZTIxNmUiLCJ0YWciOiIifQ==/20934991';
350
+
351
  let db;
352
+ let songToDeleteId = null;
353
+ let userSubscriptionStatus = 'free'; // پیش‌فرض رایگان
354
 
355
  // المان‌ها
356
  const ideaInput = document.getElementById('ideaInput');
 
361
  const finalResult = document.getElementById('finalResult');
362
  const playerWrapper = document.getElementById('playerWrapper');
363
  const finalLyricsBox = document.getElementById('finalLyricsBox');
364
+ const mainDownloadBtn = document.getElementById('mainDownloadBtn');
365
  const historyList = document.getElementById('historyList');
366
  const historySection = document.getElementById('historySection');
367
  const deleteModal = document.getElementById('deleteConfirmModal');
368
+ const upgradeModal = document.getElementById('upgradeModal');
369
+ const statusBadge = document.getElementById('statusBadge');
370
 
371
  const getVal = (id) => document.getElementById(id).value;
372
  const getNum = (id) => Number(document.getElementById(id).value);
 
381
  });
382
  }
383
 
384
+ // --- مدیریت اشتراک و ارتباط با آیفریم مادر ---
385
+ function isUserPaid(userObject) {
386
+ return userObject && userObject.isLogin && userObject.accessible_pages &&
387
+ (userObject.accessible_pages.includes(PREMIUM_PAGE_ID) ||
388
+ userObject.accessible_pages.includes(parseInt(PREMIUM_PAGE_ID)));
389
+ }
390
+
391
+ function updateSubscriptionUI(status) {
392
+ if (status === 'paid') {
393
+ statusBadge.textContent = 'نسخه نامحدود';
394
+ statusBadge.className = 'status-badge visible badge-premium';
395
+ mainDownloadBtn.classList.remove('locked');
396
+ } else {
397
+ statusBadge.textContent = 'نسخه رایگان';
398
+ statusBadge.className = 'status-badge visible badge-free';
399
+ // در حالت رایگان آیکون قفل به دکمه دانلود (اختیاری) اضافه نمی‌کنیم تا کاربر کلیک کند و مودال ببیند
400
+ }
401
+ }
402
+
403
+ // شنونده پیام از آیفریم مادر
404
+ window.addEventListener('message', (event) => {
405
+ if (event.data && event.data.type === 'USER_STATUS_RESPONSE') {
406
+ try {
407
+ const userObject = JSON.parse(event.data.payload);
408
+ userSubscriptionStatus = isUserPaid(userObject) ? 'paid' : 'free';
409
+ } catch (e) {
410
+ userSubscriptionStatus = 'free';
411
+ }
412
+ updateSubscriptionUI(userSubscriptionStatus);
413
+ }
414
+ });
415
+
416
+ // درخواست وضعیت کاربر در شروع برنامه
417
+ parent.postMessage({ type: 'REQUEST_USER_STATUS' }, '*');
418
+
419
+ // مدیریت کلیک دکمه دانلود (تابع امنیتی)
420
+ function handleSecureDownload(url, e) {
421
+ if (e) e.preventDefault();
422
+
423
+ if (userSubscriptionStatus === 'free') {
424
+ upgradeModal.classList.add('open');
425
+ } else {
426
+ // ارسال درخواست دانلود به آیفریم مادر
427
+ parent.postMessage({
428
+ type: 'INITIATE_DOWNLOAD_FROM_URL',
429
+ payload: { audioUrl: url }
430
+ }, '*');
431
+
432
+ // تغییر موقت متن دکمه برای فیدبک
433
+ const btn = e ? e.target.closest('button') : null;
434
+ if(btn) {
435
+ const originalText = btn.innerHTML;
436
+ btn.innerHTML = 'در حال ارسال... ⏳';
437
+ setTimeout(() => { btn.innerHTML = originalText; }, 2000);
438
+ }
439
+ }
440
+ }
441
+
442
+ // دکمه ارتقا در مودال
443
+ document.getElementById('btnGoPremium').addEventListener('click', () => {
444
+ parent.postMessage({
445
+ type: 'NAVIGATE_TO_PREMIUM',
446
+ payload: { url: PREMIUM_URL }
447
+ }, '*');
448
+ });
449
+
450
+ function closeUpgradeModal() {
451
+ upgradeModal.classList.remove('open');
452
+ }
453
+
454
  // --- مدیریت دیتابیس ---
455
  function initDB() {
456
  const request = indexedDB.open("alphaMusicDB", 1);
 
461
 
462
  async function saveToHistory(idea, lyrics, audioUrl) {
463
  try {
464
+ // برای ذخیره در DB باید فایل را فچ کنیم
465
  const response = await fetch(audioUrl);
466
  const audioBlob = await response.blob();
467
  const newItem = {
 
545
  deleteModal.addEventListener('click', (e) => {
546
  if (e.target === deleteModal) closeDeleteModal();
547
  });
548
+ upgradeModal.addEventListener('click', (e) => {
549
+ if (e.target === upgradeModal) closeUpgradeModal();
550
+ });
551
 
552
  function openHistoryItem(item) {
553
  step1.style.display = 'none';
 
558
  headerText.innerHTML = `<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path><polyline points="22 4 12 14.01 9 11.01"></polyline></svg> آهنگ آرشیو شده`;
559
  headerText.style.color = 'var(--accent-primary)';
560
 
561
+ // تنظیم دکمه دانلود
562
+ mainDownloadBtn.style.display = 'inline-flex';
563
+ mainDownloadBtn.onclick = (e) => handleSecureDownload(audioURL, e);
564
+
565
  playerWrapper.innerHTML = `<audio controls autoplay src="${audioURL}"></audio>`;
566
  finalLyricsBox.innerHTML = formatLyrics(item.lyrics);
567
 
 
633
  hasResult = true;
634
 
635
  if (processedUrls.size === 1) {
636
+ // تنظیم دکمه دانلود اصلی
637
+ mainDownloadBtn.style.display = 'inline-flex';
638
+ mainDownloadBtn.onclick = (e) => handleSecureDownload(fullUrl, e);
639
+
640
  saveToHistory(idea, lyrics, fullUrl);
641
  }
642
  playerWrapper.innerHTML += `<div class="audio-item"><audio controls autoplay src="${fullUrl}"></audio></div>`;