Opera8 commited on
Commit
3e3025e
·
verified ·
1 Parent(s): de02d2c

Create index.html

Browse files
Files changed (1) hide show
  1. index.html +293 -0
index.html ADDED
@@ -0,0 +1,293 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="fa" dir="rtl">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>دستیار ساخت آهنگ هوشمند</title>
7
+ <link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;700&display=swap" rel="stylesheet">
8
+ <style>
9
+ :root {
10
+ --bg-color: #0f172a;
11
+ --card-bg: #1e293b;
12
+ --primary: #6366f1;
13
+ --primary-hover: #4f46e5;
14
+ --text-main: #f8fafc;
15
+ --text-muted: #94a3b8;
16
+ --border: #334155;
17
+ }
18
+
19
+ body {
20
+ font-family: 'Vazirmatn', sans-serif;
21
+ background-color: var(--bg-color);
22
+ color: var(--text-main);
23
+ margin: 0;
24
+ padding: 20px;
25
+ display: flex;
26
+ justify-content: center;
27
+ min-height: 100vh;
28
+ }
29
+
30
+ .container {
31
+ width: 100%;
32
+ max-width: 900px;
33
+ background: var(--card-bg);
34
+ border-radius: 16px;
35
+ padding: 30px;
36
+ box-shadow: 0 10px 30px rgba(0,0,0,0.3);
37
+ border: 1px solid var(--border);
38
+ }
39
+
40
+ h1 {
41
+ text-align: center;
42
+ color: var(--primary);
43
+ margin-bottom: 10px;
44
+ }
45
+
46
+ p.subtitle {
47
+ text-align: center;
48
+ color: var(--text-muted);
49
+ margin-bottom: 30px;
50
+ }
51
+
52
+ .input-group {
53
+ margin-bottom: 25px;
54
+ }
55
+
56
+ label {
57
+ display: block;
58
+ margin-bottom: 8px;
59
+ font-weight: bold;
60
+ color: var(--text-main);
61
+ }
62
+
63
+ textarea {
64
+ width: 100%;
65
+ padding: 15px;
66
+ border-radius: 12px;
67
+ border: 2px solid var(--border);
68
+ background: #0f172a;
69
+ color: white;
70
+ font-family: 'Vazirmatn', sans-serif;
71
+ font-size: 16px;
72
+ resize: vertical;
73
+ min-height: 100px;
74
+ box-sizing: border-box;
75
+ transition: border-color 0.3s;
76
+ }
77
+
78
+ textarea:focus {
79
+ outline: none;
80
+ border-color: var(--primary);
81
+ }
82
+
83
+ button#generateBtn {
84
+ width: 100%;
85
+ padding: 15px;
86
+ background: var(--primary);
87
+ color: white;
88
+ border: none;
89
+ border-radius: 12px;
90
+ font-size: 18px;
91
+ font-weight: bold;
92
+ cursor: pointer;
93
+ transition: background 0.3s, transform 0.1s;
94
+ display: flex;
95
+ align-items: center;
96
+ justify-content: center;
97
+ gap: 10px;
98
+ }
99
+
100
+ button#generateBtn:hover {
101
+ background: var(--primary-hover);
102
+ }
103
+
104
+ button#generateBtn:active {
105
+ transform: scale(0.98);
106
+ }
107
+
108
+ button:disabled {
109
+ background: var(--border);
110
+ cursor: not-allowed;
111
+ }
112
+
113
+ .results-area {
114
+ display: grid;
115
+ grid-template-columns: 1fr 1fr;
116
+ gap: 20px;
117
+ margin-top: 30px;
118
+ opacity: 0;
119
+ transform: translateY(20px);
120
+ transition: all 0.5s ease;
121
+ }
122
+
123
+ .results-area.visible {
124
+ opacity: 1;
125
+ transform: translateY(0);
126
+ }
127
+
128
+ .result-box {
129
+ background: #0f172a;
130
+ border: 1px solid var(--border);
131
+ border-radius: 12px;
132
+ padding: 15px;
133
+ position: relative;
134
+ }
135
+
136
+ .result-header {
137
+ display: flex;
138
+ justify-content: space-between;
139
+ align-items: center;
140
+ margin-bottom: 10px;
141
+ border-bottom: 1px solid var(--border);
142
+ padding-bottom: 10px;
143
+ }
144
+
145
+ .result-title {
146
+ font-weight: bold;
147
+ color: var(--primary);
148
+ }
149
+
150
+ .copy-btn {
151
+ background: transparent;
152
+ border: 1px solid var(--border);
153
+ color: var(--text-muted);
154
+ padding: 5px 10px;
155
+ border-radius: 6px;
156
+ cursor: pointer;
157
+ font-size: 12px;
158
+ transition: all 0.2s;
159
+ }
160
+
161
+ .copy-btn:hover {
162
+ background: var(--border);
163
+ color: white;
164
+ }
165
+
166
+ .output-text {
167
+ white-space: pre-wrap;
168
+ line-height: 1.8;
169
+ font-size: 14px;
170
+ color: #e2e8f0;
171
+ max-height: 300px;
172
+ overflow-y: auto;
173
+ }
174
+
175
+ /* لودر */
176
+ .loader {
177
+ border: 4px solid rgba(255, 255, 255, 0.1);
178
+ border-left-color: white;
179
+ border-radius: 50%;
180
+ width: 24px;
181
+ height: 24px;
182
+ animation: spin 1s linear infinite;
183
+ display: none;
184
+ }
185
+
186
+ @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
187
+
188
+ @media (max-width: 768px) {
189
+ .results-area {
190
+ grid-template-columns: 1fr;
191
+ }
192
+ }
193
+ </style>
194
+ </head>
195
+ <body>
196
+
197
+ <div class="container">
198
+ <h1>🎵 استودیو هوشمند ترانه و آهنگ</h1>
199
+ <p class="subtitle">ایده خود را بنویسید تا متن شعر (با اعراب دقیق) و پرامپت موسیقی را دریافت کنید.</p>
200
+
201
+ <div class="input-group">
202
+ <label for="userInput">توضیحات آهنگ شما:</label>
203
+ <textarea id="userInput" placeholder="مثال: یک آهنگ سنتی غمگین در مورد پاییز و باران با صدای زن..."></textarea>
204
+ </div>
205
+
206
+ <button id="generateBtn" onclick="generateContent()">
207
+ <span class="btn-text">ساخت ترانه و پرامپت</span>
208
+ <div class="loader"></div>
209
+ </button>
210
+
211
+ <div class="results-area" id="resultsArea">
212
+ <!-- باکس متن شعر -->
213
+ <div class="result-box">
214
+ <div class="result-header">
215
+ <span class="result-title">📜 متن شعر (با اعراب)</span>
216
+ <button class="copy-btn" onclick="copyToClipboard('lyricsOutput')">کپی</button>
217
+ </div>
218
+ <div class="output-text" id="lyricsOutput"></div>
219
+ </div>
220
+
221
+ <!-- باکس پرامپت موزیک -->
222
+ <div class="result-box">
223
+ <div class="result-header">
224
+ <span class="result-title">🎹 پرامپت موسیقی (انگلیسی)</span>
225
+ <button class="copy-btn" onclick="copyToClipboard('promptOutput')">کپی</button>
226
+ </div>
227
+ <div class="output-text" id="promptOutput" style="direction: ltr; text-align: left;"></div>
228
+ </div>
229
+ </div>
230
+ </div>
231
+
232
+ <script>
233
+ async function generateContent() {
234
+ const input = document.getElementById('userInput').value;
235
+ const btn = document.getElementById('generateBtn');
236
+ const loader = document.querySelector('.loader');
237
+ const btnText = document.querySelector('.btn-text');
238
+ const resultsArea = document.getElementById('resultsArea');
239
+
240
+ if (!input.trim()) {
241
+ alert("لطفا توضیحات آهنگ را وارد کنید.");
242
+ return;
243
+ }
244
+
245
+ // UI Loading State
246
+ btn.disabled = true;
247
+ loader.style.display = 'block';
248
+ btnText.style.display = 'none';
249
+ resultsArea.classList.remove('visible');
250
+
251
+ try {
252
+ const response = await fetch('/api/generate', {
253
+ method: 'POST',
254
+ headers: {
255
+ 'Content-Type': 'application/json'
256
+ },
257
+ body: JSON.stringify({ description: input })
258
+ });
259
+
260
+ if (!response.ok) {
261
+ throw new Error('Network response was not ok');
262
+ }
263
+
264
+ const data = await response.json();
265
+
266
+ // Display Results
267
+ document.getElementById('lyricsOutput').innerText = data.lyrics;
268
+ document.getElementById('promptOutput').innerText = data.music_prompt;
269
+
270
+ resultsArea.classList.add('visible');
271
+
272
+ } catch (error) {
273
+ console.error('Error:', error);
274
+ alert("خطایی رخ داد. لطفا کلید API را چک کنید یا دوباره تلاش کنید.");
275
+ } finally {
276
+ // Reset UI
277
+ btn.disabled = false;
278
+ loader.style.display = 'none';
279
+ btnText.style.display = 'block';
280
+ }
281
+ }
282
+
283
+ function copyToClipboard(elementId) {
284
+ const text = document.getElementById(elementId).innerText;
285
+ navigator.clipboard.writeText(text).then(() => {
286
+ alert("کپی شد!");
287
+ }).catch(err => {
288
+ console.error('خطا در کپی:', err);
289
+ });
290
+ }
291
+ </script>
292
+ </body>
293
+ </html>