-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
321 lines (306 loc) · 11.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ACSE Animation Changer</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
transition: background-color 0.3s, color 0.3s;
background-color: #181818;
color: #f1f1f1;
}
.dark-mode {
background-color: #181818;
color: #f1f1f1;
}
.video-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
}
.video-item {
border: 1px solid #444;
padding: 10px;
border-radius: 8px;
background-color: #333;
transition: background-color 0.3s, border-color 0.3s;
}
.video-item h2 {
font-size: 16px;
margin: 0 0 10px;
}
.video-item p {
margin: 5px 0;
}
.video-item video {
width: 100%;
height: auto;
margin-bottom: 10px;
}
.video-item button {
display: block;
width: 100%;
padding: 10px;
background-color: #007bff;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
margin-top: 5px;
}
.video-item button:hover {
background-color: #0056b3;
}
.tab {
overflow: hidden;
border: 1px solid #444;
background-color: #333;
transition: background-color 0.3s, border-color 0.3s;
}
.tab button {
background-color: inherit;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 14px 16px;
transition: 0.3s;
color: #f1f1f1;
}
.tab button:hover {
background-color: #444;
}
.tab button.active {
background-color: #555;
}
.tabcontent {
display: none;
padding: 6px 12px;
border: 1px solid #444;
border-top: none;
transition: background-color 0.3s, border-color 0.3s;
background-color: #333;
}
.sort-options, .search-bar {
margin-bottom: 20px;
}
.pagination {
display: flex;
justify-content: center;
margin-top: 20px;
}
.pagination button {
padding: 10px 20px;
margin: 0 5px;
background-color: #007bff;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}
.pagination button:hover {
background-color: #0056b3;
}
.quit-button {
position: absolute;
top: 10px;
right: 10px;
padding: 10px 20px;
background-color: #ff4d4d;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
.quit-button:hover {
background-color: #d11a1a;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: block;
margin-bottom: 5px;
}
.form-group input {
width: 100%;
padding: 8px;
box-sizing: border-box;
}
</style>
</head>
<body class="dark-mode">
<h1>ACSE Animation Changer</h1>
<button class="quit-button" onclick="quitProgram()">Quit</button>
<div class="tab">
<button class="tablinks" onclick="openTab(event, 'Download')">Download Videos</button>
<button class="tablinks" onclick="openTab(event, 'Manage')">Manage Videos</button>
</div>
<div id="Download" class="tabcontent">
<h2>Available Videos from SteamDeckRepo</h2>
<div class="search-bar">
<label for="search">Search:</label>
<input type="text" id="search" onkeypress="searchKeyPress(event)">
</div>
<div class="sort-options">
<label for="sort">Sort by:</label>
<select id="sort" onchange="changeSort()">
<option value="downloads-desc">Most Downloaded</option>
<option value="trending">Trending</option>
<option value="likes-desc">Most Liked</option>
<option value="created_at-desc">Uploaded (Newest)</option>
<option value="created_at-asc">Uploaded (Oldest)</option>
<option value="random">Random</option>
</select>
</div>
<div id="external-video-list" class="video-grid"></div>
<div class="pagination">
<button id="prevPage" onclick="changePage(-1)" style="display: none;">Previous</button>
<button id="nextPage" onclick="changePage(1)" style="display: none;">Next</button>
</div>
</div>
<div id="Manage" class="tabcontent">
<h2>Downloaded Videos</h2>
<div class="form-group">
<label for="replacePath">Replace Path:</label>
<input type="text" id="replacePath" placeholder="Specify the path to replace or leave empty to auto-detect">
</div>
<div id="video-list" class="video-grid">
{% for video in videos %}
<div class="video-item" id="{{ video }}-item">
<h2>{{ video.replace('.webm', '') }}</h2>
<video controls>
<source src="{{ url_for('preview', filename=video) }}" type="video/webm">
Your browser does not support the video tag.
</video>
<button onclick="replaceVideo('{{ video }}')">Replace</button>
<button onclick="deleteVideo('{{ video }}')">Delete</button>
</div>
{% endfor %}
</div>
</div>
<script>
let currentPage = 1;
let totalPages = 1;
function openTab(evt, tabName) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(tabName).style.display = "block";
evt.currentTarget.className += " active";
}
function searchKeyPress(event) {
if (event.key === "Enter") {
console.log("Search triggered");
currentPage = 1;
fetchExternalVideos();
}
}
function changeSort() {
console.log("Sort changed");
currentPage = 1;
fetchExternalVideos();
}
async function fetchExternalVideos() {
const sortOption = document.getElementById('sort').value;
const searchQuery = document.getElementById('search').value;
console.log(`Fetching videos with sort: ${sortOption}, search: ${searchQuery}, page: ${currentPage}`);
const response = await fetch(`/fetch_videos?page=${currentPage}&sort=${sortOption}&search=${searchQuery}`);
const { posts, links, meta } = await response.json();
const videoListDiv = document.getElementById('external-video-list');
videoListDiv.innerHTML = '';
posts.forEach(video => {
const videoItem = document.createElement('div');
videoItem.className = 'video-item';
videoItem.innerHTML = `
<h2>${video.title}</h2>
<p>Author: ${video.user.steam_name}</p>
<p>Downloads: ${video.downloads}</p>
<p>Uploaded: ${new Date(video.created_at).toLocaleDateString()}</p>
<video controls>
<source src="${video.video}" type="video/webm">
Your browser does not support the video tag.
</video>
<button onclick="downloadVideo('${video.video}', '${video.title}')">Download</button>
`;
videoListDiv.appendChild(videoItem);
});
// Show "Next" button only if there are 12 posts
document.getElementById('nextPage').style.display = posts.length === 12 ? 'inline' : 'none';
document.getElementById('prevPage').style.display = currentPage > 1 ? 'inline' : 'none';
}
async function downloadVideo(url, title) {
console.log(`Downloading video: ${title} from ${url}`);
const response = await fetch('/download_video', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ url, title })
});
const data = await response.json();
alert(data.message);
location.reload();
}
async function replaceVideo(filename) {
console.log(`Replacing video: ${filename}`);
const replacePath = document.getElementById('replacePath').value;
const response = await fetch('/convert_replace', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ filename, replacePath })
});
const data = await response.json();
alert(data.message);
}
async function deleteVideo(filename) {
console.log(`Deleting video: ${filename}`);
const response = await fetch('/delete_video', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ filename })
});
const data = await response.json();
alert(data.message);
document.getElementById(`${filename}-item`).style.display = 'none';
}
function changePage(direction) {
currentPage += direction;
if (currentPage < 1) currentPage = 1;
console.log(`Changing to page: ${currentPage}`);
fetchExternalVideos();
}
function quitProgram() {
fetch('/shutdown', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
}).then(() => {
window.close();
});
}
document.addEventListener('DOMContentLoaded', () => {
fetchExternalVideos();
document.querySelector('.tablinks').click();
document.getElementById('sort').value = 'downloads-desc'; // Default to Most Downloaded
changeSort();
});
</script>
</body>
</html>