koesan commited on
Commit
04d0e70
·
verified ·
1 Parent(s): c5be01b

Upload 2 files

Browse files
Files changed (2) hide show
  1. static/scripts.js +216 -0
  2. static/styles.css +231 -0
static/scripts.js ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ document.addEventListener("DOMContentLoaded", function () {
2
+ const form = document.getElementById('process-form');
3
+ const loadingOverlay = document.getElementById('loading-overlay');
4
+ const downloadSection = document.getElementById('download-section');
5
+ const downloadLink = document.getElementById('download-link');
6
+ const fileInput = document.getElementById('images');
7
+ const fileError = document.getElementById('file-error');
8
+ const videoError = document.getElementById('video-error');
9
+ const operationSelect = document.getElementById('operation');
10
+ const operationError = document.getElementById('operation-error');
11
+ const languageError = document.getElementById('language-error');
12
+ const sourceLang = document.getElementById("source-lang");
13
+ const targetLang = document.getElementById("target-lang");
14
+ const languageSelection = document.getElementById("language-selection");
15
+ const dubbingOptions = document.getElementById("dubbing-options");
16
+ const dubbingType = document.getElementById("dubbing-type");
17
+ const dubbingLanguage = document.getElementById("dubbing-language");
18
+ const srtFileInput = document.getElementById("srt-file");
19
+ const videoFileInput = document.getElementById("video-file");
20
+ const fileLabel = document.getElementById("file-label");
21
+ const srtFileLabel = document.querySelector('label[for="srt-file"]');
22
+ const videoFileLabel = document.querySelector('label[for="video-file"]');
23
+
24
+ languageSelection.style.display = "none";
25
+ dubbingOptions.style.display = "none";
26
+
27
+ operationSelect.addEventListener('change', function () {
28
+ let selectedOperation = operationSelect.value;
29
+ resetFormFields();
30
+
31
+ if (selectedOperation === "translate" || selectedOperation === "both") {
32
+ languageSelection.style.display = "flex";
33
+ fileLabel.innerText = "Upload File (Max 5 images)";
34
+ fileInput.setAttribute("accept", "image/*");
35
+ fileInput.setAttribute("multiple", "multiple");
36
+ fileInput.style.display = "block";
37
+ fileLabel.style.display = "block";
38
+ sourceLang.required = true;
39
+ targetLang.required = true;
40
+ fileInput.required = true;
41
+ } else if (selectedOperation === "subtitle") {
42
+ languageSelection.style.display = "flex";
43
+ fileLabel.innerText = "Upload File (Max 1 video)";
44
+ fileInput.setAttribute("accept", "video/*");
45
+ fileInput.removeAttribute("multiple");
46
+ fileInput.style.display = "block";
47
+ fileLabel.style.display = "block";
48
+ sourceLang.required = true;
49
+ targetLang.required = true;
50
+ fileInput.required = true;
51
+ } else if (selectedOperation === "dubbing") {
52
+ dubbingOptions.style.display = "flex";
53
+ fileLabel.style.display = "none";
54
+ fileInput.style.display = "none";
55
+ dubbingType.required = true;
56
+ } else {
57
+ fileLabel.innerText = "Upload File (Max 5 images)";
58
+ fileInput.setAttribute("accept", "image/*");
59
+ fileInput.setAttribute("multiple", "multiple");
60
+ fileInput.style.display = "block";
61
+ fileLabel.style.display = "block";
62
+ fileInput.required = true;
63
+ }
64
+ });
65
+
66
+ dubbingType.addEventListener('change', function () {
67
+ if (dubbingType.value === "manual") {
68
+ dubbingLanguage.style.display = "flex";
69
+ srtFileInput.style.display = "block";
70
+ videoFileInput.style.display = "block";
71
+ srtFileLabel.style.display = "block";
72
+ videoFileLabel.style.display = "block";
73
+ videoFileInput.required = true;
74
+ srtFileInput.required = true;
75
+ document.getElementById('dubbing-lang').required = true;
76
+ } else {
77
+ dubbingLanguage.style.display = "none";
78
+ srtFileInput.style.display = "none";
79
+ videoFileInput.style.display = "none";
80
+ srtFileLabel.style.display = "none";
81
+ videoFileLabel.style.display = "none";
82
+ videoFileInput.required = false;
83
+ srtFileInput.required = false;
84
+ document.getElementById('dubbing-lang').required = false;
85
+ }
86
+ });
87
+
88
+ fileInput.addEventListener('change', function () {
89
+ const files = fileInput.files;
90
+ const selectedOperation = operationSelect.value;
91
+ let hasVideo = false;
92
+ let hasImage = false;
93
+
94
+ for (const file of files) {
95
+ if (file.type.startsWith('video/')) {
96
+ hasVideo = true;
97
+ } else if (file.type.startsWith('image/')) {
98
+ hasImage = true;
99
+ }
100
+ }
101
+
102
+ if ((selectedOperation === 'subtitle') && !hasVideo) {
103
+ videoError.style.display = 'block';
104
+ fileInput.value = '';
105
+ } else {
106
+ videoError.style.display = 'none';
107
+ }
108
+
109
+ if (files.length > 5 && !hasVideo) {
110
+ fileError.style.display = 'block';
111
+ fileInput.value = '';
112
+ } else {
113
+ fileError.style.display = 'none';
114
+ }
115
+ });
116
+
117
+ form.addEventListener('submit', async (e) => {
118
+ e.preventDefault();
119
+
120
+ if (!validateForm()) {
121
+ return;
122
+ }
123
+
124
+ loadingOverlay.style.display = 'flex';
125
+ const formData = new FormData(form);
126
+
127
+ try {
128
+ const response = await fetch('/process', {
129
+ method: 'POST',
130
+ body: formData,
131
+ });
132
+ const data = await response.json();
133
+ if (data.status === 'ready') {
134
+ downloadLink.href = data.download_url;
135
+ downloadSection.style.display = 'block';
136
+ form.style.display = 'none';
137
+ }
138
+ } catch (error) {
139
+ console.error('Error:', error);
140
+ } finally {
141
+ loadingOverlay.style.display = 'none';
142
+ }
143
+ });
144
+
145
+ function validateForm() {
146
+ let isValid = true;
147
+ let operation = operationSelect.value;
148
+ let sourceLangValue = sourceLang.value;
149
+ let targetLangValue = targetLang.value;
150
+
151
+ if (!operation) {
152
+ operationError.innerText = "Please select an operation.";
153
+ operationError.style.display = "block";
154
+ isValid = false;
155
+ } else {
156
+ operationError.style.display = "none";
157
+ }
158
+
159
+ if ((operation === "translate" || operation === "both" || operation === "subtitle") &&
160
+ (!sourceLangValue || !targetLangValue)) {
161
+ languageError.innerText = "Both language fields must be selected.";
162
+ languageError.style.display = "block";
163
+ isValid = false;
164
+ } else if (sourceLangValue === targetLangValue && (operation === "translate" || operation === "both")) {
165
+ languageError.innerText = "Source and Target languages cannot be the same.";
166
+ languageError.style.display = "block";
167
+ isValid = false;
168
+ } else {
169
+ languageError.style.display = "none";
170
+ }
171
+
172
+ return isValid;
173
+ }
174
+
175
+ function resetFormFields() {
176
+ languageSelection.style.display = "none";
177
+ dubbingOptions.style.display = "none";
178
+ dubbingLanguage.style.display = "none";
179
+ srtFileInput.style.display = "none";
180
+ videoFileInput.style.display = "none";
181
+ srtFileLabel.style.display = "none";
182
+ videoFileLabel.style.display = "none";
183
+ fileInput.style.display = "none";
184
+ fileLabel.style.display = "none";
185
+ fileInput.value = '';
186
+ sourceLang.value = '';
187
+ targetLang.value = '';
188
+ dubbingType.value = '';
189
+ document.getElementById('dubbing-lang').value = '';
190
+ sourceLang.required = false;
191
+ targetLang.required = false;
192
+ fileInput.required = false;
193
+ dubbingType.required = false;
194
+ videoFileInput.required = false;
195
+ srtFileInput.required = false;
196
+ document.getElementById('dubbing-lang').required = false;
197
+ }
198
+ });
199
+
200
+ // Define resetForm outside of the DOMContentLoaded event listener
201
+ function resetForm() {
202
+ window.location.reload();
203
+ }
204
+
205
+ function purchase() {
206
+ document.getElementById('purchase-modal').style.display = 'flex';
207
+ }
208
+
209
+ function closePurchaseModal() {
210
+ document.getElementById('purchase-modal').style.display = 'none';
211
+ }
212
+
213
+ function confirmPurchase() {
214
+ alert("Satın alma işlemi başarıyla tamamlandı!");
215
+ closePurchaseModal();
216
+ }
static/styles.css ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ body {
2
+ font-family: 'Arial', sans-serif;
3
+ margin: 0;
4
+ padding: 0;
5
+ background: url('/static/wallpaper.jpg') no-repeat center center fixed;
6
+ background-size: cover;
7
+ color: #ffffff;
8
+ min-height: 100vh;
9
+ display: flex;
10
+ justify-content: center;
11
+ align-items: center;
12
+ flex-direction: column;
13
+ }
14
+ .menu {
15
+ position: absolute;
16
+ top: 10px;
17
+ left: 10px;
18
+ background-color: #000000;
19
+ padding: 10px;
20
+ border-radius: 5px;
21
+ cursor: pointer;
22
+ color: white;
23
+ text-align: center;
24
+ width: 70px;
25
+ height: 20px;
26
+ }
27
+ .menu-options {
28
+ display: none;
29
+ position: absolute;
30
+ top: 40px;
31
+ left: 0px;
32
+ background-color: rgba(0, 0, 0, 0.9);
33
+ padding: 5px;
34
+ border-radius: 5px;
35
+ width: 80px;
36
+ max-height: 300px;
37
+ overflow-y: auto;
38
+ }
39
+ .menu:hover .menu-options {
40
+ display: block;
41
+ }
42
+ .menu-options button {
43
+ display: block;
44
+ background: none;
45
+ border: none;
46
+ color: white;
47
+ padding: 5px;
48
+ cursor: pointer;
49
+ width: 100%;
50
+ text-align: left;
51
+ }
52
+ .modal {
53
+ display: none;
54
+ position: fixed;
55
+ top: 0;
56
+ left: 0;
57
+ width: 100%;
58
+ height: 100%;
59
+ background-color: rgba(0, 0, 0, 0.8);
60
+ justify-content: center;
61
+ align-items: center;
62
+ }
63
+
64
+ .modal-content {
65
+ display: flex;
66
+ flex-direction: column;
67
+ justify-content: center;
68
+ align-items: center;
69
+ background-color: rgba(0, 0, 0, 0.8);
70
+ padding: 20px;
71
+ border-radius: 10px;
72
+ width: 300px;
73
+ text-align: center;
74
+ }
75
+
76
+ .modal-content input {
77
+ width: 93%;
78
+ padding: 10px;
79
+ margin: 10px 0;
80
+ border-radius: 5px;
81
+ border: none;
82
+ background-color: #1e1e1e;
83
+ color: white;
84
+ }
85
+
86
+ .modal-content button {
87
+ background-color: #eb142a;
88
+ color: white;
89
+ border: none;
90
+ padding: 15px;
91
+ width: 250px;
92
+ height: 45px;
93
+ border-radius: 5px;
94
+ cursor: pointer;
95
+ }
96
+
97
+ .modal-content button:hover {
98
+ background-color: #c01022;
99
+ }
100
+
101
+ .close-btn {
102
+ background-color: #eb142a;
103
+ margin-top: 10px;
104
+ }
105
+
106
+ .close-btn:hover {
107
+ background-color: #c01022;
108
+ }
109
+
110
+ .product-container {
111
+ display: flex;
112
+ justify-content: space-between;
113
+ margin-top: 20px;
114
+ }
115
+
116
+ .product {
117
+ display: flex;
118
+ flex-direction: column;
119
+ justify-content: center;
120
+ align-items: center;
121
+ background-color: rgba(0, 0, 0, 0.8);
122
+ padding: 15px;
123
+ border-radius: 5px;
124
+ width: 30%;
125
+ text-align: center;
126
+ }
127
+
128
+ .product h3 {
129
+ margin-bottom: 10px;
130
+ }
131
+
132
+ .product p {
133
+ margin-bottom: 15px;
134
+ }
135
+
136
+ .product button {
137
+ background-color: #eb142a;
138
+ color: white;
139
+ border: none;
140
+ padding: 15px;
141
+ width: 250px;
142
+ height: 50px;
143
+ border-radius: 5px;
144
+ cursor: pointer;
145
+ }
146
+
147
+ .product button:hover {
148
+ background-color: #c01022;
149
+ }
150
+
151
+ main {
152
+ background-color: rgba(0, 0, 0, 0.8);
153
+ padding: 20px;
154
+ max-width: 600px;
155
+ margin: auto;
156
+ border-radius: 10px;
157
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
158
+ text-align: center;
159
+ }
160
+ header h1 {
161
+ font-size: 2em;
162
+ color: #eb142a;
163
+ }
164
+ label, select, input[type="file"], button {
165
+ display: block;
166
+ width: 100%;
167
+ margin: 10px 0;
168
+ font-size: 1rem;
169
+ }
170
+ select, input[type="file"] {
171
+ padding: 10px;
172
+ border: none;
173
+ border-radius: 5px;
174
+ background-color: #1e1e1e;
175
+ color: #ffffff;
176
+ }
177
+ button, #download-link, #reset-button {
178
+ padding: 12px;
179
+ border: none;
180
+ border-radius: 5px;
181
+ background-color: #eb142a;
182
+ color: #ffffff;
183
+ font-size: 1rem;
184
+ cursor: pointer;
185
+ text-decoration: none;
186
+ text-align: center;
187
+ width: 100%;
188
+ margin-top: 10px;
189
+ }
190
+ button:hover, #download-link:hover, #reset-button:hover {
191
+ background-color: #c01022;
192
+ }
193
+ #download-link {
194
+ background-color: #28a745;
195
+ }
196
+ #download-link:hover {
197
+ background-color: #218838;
198
+ }
199
+ #loading-overlay {
200
+ position: fixed;
201
+ top: 0;
202
+ left: 0;
203
+ width: 100%;
204
+ height: 100%;
205
+ background-color: rgba(0, 0, 0, 0.8);
206
+ display: none;
207
+ justify-content: center;
208
+ align-items: center;
209
+ z-index: 9999;
210
+ }
211
+ #loading-overlay .spinner {
212
+ width: 50px;
213
+ height: 50px;
214
+ border: 6px solid rgba(255, 255, 255, 0.3);
215
+ border-top: 6px solid #ffffff;
216
+ border-radius: 50%;
217
+ animation: spin 1s linear infinite;
218
+ }
219
+ @keyframes spin {
220
+ 0% { transform: rotate(0deg); }
221
+ 100% { transform: rotate(360deg); }
222
+ }
223
+ @media (max-width: 768px) {
224
+ main {
225
+ margin: 20px;
226
+ padding: 15px;
227
+ }
228
+ header h1 {
229
+ font-size: 1.5em;
230
+ }
231
+ }