-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditor.html
More file actions
659 lines (590 loc) · 26.7 KB
/
Copy patheditor.html
File metadata and controls
659 lines (590 loc) · 26.7 KB
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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="darkreader-lock">
<meta name="color-scheme" content="dark">
<title>Dailys Editor</title>
<link rel="icon" type="image/svg+xml" href="favicon.svg">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link rel="stylesheet" href="style.css">
<style>
/* --- Editor Specific Overrides & Additions --- */
.editor-toolbar {
display: flex;
gap: 10px;
align-items: center;
}
.btn {
padding: 8px 16px;
border-radius: 6px;
border: none;
font-weight: 600;
cursor: pointer;
font-size: 14px;
transition: var(--transition);
display: flex;
align-items: center;
gap: 8px;
text-decoration: none;
}
.btn-primary {
background: var(--primary);
color: white;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
background: var(--bg-card);
color: var(--text-primary);
border: 1px solid var(--border-color);
}
.btn-secondary:hover { background: var(--bg-card-hover); border-color: var(--text-secondary); }
/* Drag and Drop Visuals */
.draggable-source {
opacity: 0.4;
border: 2px dashed var(--primary);
}
.drag-handle {
cursor: grab;
color: var(--text-secondary);
padding: 5px;
margin-right: 5px;
}
.drag-handle:active { cursor: grabbing; color: var(--primary); }
.category-wrapper {
background: var(--bg-card);
border-radius: 12px;
margin-bottom: 20px;
border: 1px solid var(--border-color);
overflow: hidden;
}
.cat-header-edit {
padding: 15px 20px;
display: flex;
justify-content: space-between;
align-items: center;
background: rgba(255, 255, 255, 0.03);
border-bottom: 1px solid var(--border-color);
}
.cat-title-group {
display: flex;
align-items: center;
gap: 10px;
}
.cat-title-text {
font-size: 18px;
font-weight: 600;
color: var(--text-primary);
}
.cat-desc-text {
font-size: 13px;
color: var(--text-secondary);
margin-left: 10px;
}
.action-group {
display: flex;
gap: 8px;
}
.icon-btn {
background: transparent;
border: none;
color: var(--text-secondary);
cursor: pointer;
padding: 6px;
border-radius: 4px;
transition: var(--transition);
}
.icon-btn:hover { color: var(--primary); background: rgba(255,255,255,0.05); }
.icon-btn.delete:hover { color: #ff4444; }
.game-card {
height: auto;
min-height: 80px;
}
.game-actions {
display: flex;
gap: 5px;
margin-left: 10px;
}
.add-game-area {
padding: 15px 20px;
border-top: 1px solid var(--border-color);
}
.add-game-btn {
width: 100%;
padding: 12px;
background: transparent;
border: 2px dashed var(--border-color);
border-radius: 8px;
color: var(--text-secondary);
cursor: pointer;
transition: var(--transition);
}
.add-game-btn:hover {
border-color: var(--primary);
color: var(--primary);
background: rgba(255, 56, 46, 0.05);
}
.modal-overlay {
position: fixed; top: 0; left: 0; right: 0; bottom: 0;
background: rgba(0,0,0,0.8);
backdrop-filter: blur(5px);
z-index: 2000;
display: none;
justify-content: center;
align-items: center;
opacity: 0;
transition: opacity 0.3s ease;
}
.modal-overlay.active { display: flex; opacity: 1; }
.modal {
background: var(--bg-card);
border: 1px solid var(--border-color);
padding: 30px;
border-radius: 16px;
width: 90%;
max-width: 500px;
box-shadow: 0 20px 50px rgba(0,0,0,0.5);
transform: translateY(20px);
transition: transform 0.3s ease;
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal h2 { margin-bottom: 20px; color: var(--primary); }
.form-group { margin-bottom: 15px; }
.form-label { display: block; color: var(--text-secondary); margin-bottom: 8px; font-size: 14px; }
.form-input {
width: 100%;
padding: 12px 20px;
border-radius: 8px;
border: 2px solid var(--border-color);
background: var(--bg-dark);
color: var(--text-primary);
font-size: 14px;
outline: none;
transition: var(--transition);
}
.form-input:focus { border-color: var(--primary); }
textarea.form-input { resize: vertical; min-height: 80px; }
.modal-footer {
margin-top: 25px;
display: flex;
justify-content: flex-end;
gap: 10px;
}
.export-area {
font-family: monospace;
font-size: 12px;
min-height: 200px;
white-space: pre;
}
.toast {
position: fixed;
bottom: 30px;
right: 30px;
background: var(--bg-card);
border-left: 4px solid var(--success);
padding: 15px 25px;
border-radius: 8px;
box-shadow: 0 5px 15px rgba(0,0,0,0.3);
transform: translateY(100px);
transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
z-index: 3000;
font-weight: 600;
display: flex;
align-items: center;
gap: 10px;
}
.toast.show { transform: translateY(0); }
/* Clean Logo Link Styling */
.logo-link {
text-decoration: none;
display: flex;
align-items: center;
gap: 12px;
}
</style>
</head>
<body>
<header>
<div class="container">
<div class="header-content">
<a href="https://periandevelopment.github.io/Dailys/" class="logo-link">
<div class="logo">
<div class="logo-icon">
<img src="favicon.svg" onerror="this.src='data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0id2hpdGUiPjxwYXRoIGQ9Ik0xMiAyTDIgN2wxMCA1IDEwLTUtMTAtNXptMCA5bDQgMi00IDItNC0ybDQtMnp2N2w0LTJ2LTdsLTQgMnoiLz48L3N2Zz4='" alt="Dailys Icon">
</div>
<h1>Dailys <span style="font-size: 0.6em; color: var(--text-secondary); font-weight: 400;">Editor</span></h1>
</div>
</a>
<div class="editor-toolbar">
<button class="btn btn-secondary" onclick="addNewCategory()">
<i class="fas fa-folder-plus"></i> New Category
</button>
<button class="btn btn-primary" onclick="openExportModal()">
<i class="fas fa-download"></i> Export
</button>
</div>
</div>
</div>
</header>
<div class="container">
<main class="main-content" id="editorContainer">
<div class="empty-state">
<div class="loading"></div>
<p style="margin-top: 15px">Initializing Editor...</p>
</div>
</main>
<footer>
<p>© 2025 <a href="https://periandevelopment.github.io/" target="_blank">PerianDevelopment</a>. Editor Mode.</p>
</footer>
</div>
<div class="modal-overlay" id="categoryModal">
<div class="modal">
<h2 id="catModalTitle">Edit Category</h2>
<input type="hidden" id="catIndex">
<div class="form-group">
<label class="form-label">Category ID (Unique)</label>
<input type="text" class="form-input" id="catId" placeholder="e.g. word-games">
</div>
<div class="form-group">
<label class="form-label">Display Name</label>
<input type="text" class="form-input" id="catName" placeholder="e.g. Word Themed">
</div>
<div class="form-group">
<label class="form-label">FontAwesome Icon Class</label>
<div style="display:flex; gap:10px; align-items:center;">
<input type="text" class="form-input" id="catIcon" placeholder="e.g. fas fa-font">
<i id="catIconPreview" class="fas fa-font" style="font-size:24px; color:var(--primary); width: 30px; text-align:center;"></i>
</div>
</div>
<div class="form-group">
<label class="form-label">Description</label>
<textarea class="form-input" id="catDesc" placeholder="Short description..."></textarea>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" onclick="closeModal('categoryModal')">Cancel</button>
<button class="btn btn-primary" onclick="saveCategory()">Save</button>
</div>
</div>
</div>
<div class="modal-overlay" id="gameModal">
<div class="modal">
<h2 id="gameModalTitle">Edit Daily</h2>
<input type="hidden" id="gameCatIndex">
<input type="hidden" id="gameIndex">
<div class="form-group">
<label class="form-label">Daily ID</label>
<input type="text" class="form-input" id="gameId" placeholder="e.g. wordle">
</div>
<div class="form-group">
<label class="form-label">Name</label>
<input type="text" class="form-input" id="gameName" placeholder="e.g. Wordle">
</div>
<div class="form-group">
<label class="form-label">URL</label>
<input type="url" class="form-input" id="gameUrl" placeholder="https://...">
</div>
<div class="form-group">
<label class="form-label">Favicon URL</label>
<div style="display:flex; gap:10px; align-items:center;">
<input type="url" class="form-input" id="gameFavicon" placeholder="https://...">
<div class="game-favicon" style="margin:0; width:44px; height:44px;">
<img id="gameFaviconPreview" src="" alt="" style="display:none">
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" onclick="closeModal('gameModal')">Cancel</button>
<button class="btn btn-primary" onclick="saveGame()">Save</button>
</div>
</div>
</div>
<div class="modal-overlay" id="importModal">
<div class="modal">
<h2>Load Data</h2>
<div class="form-group">
<label class="form-label">From URL</label>
<div style="display:flex; gap:10px;">
<input type="text" class="form-input" id="importUrl" value="https://periandevelopment.github.io/Dailys/dailys.json">
<button class="btn btn-primary" onclick="loadFromUrlInput()">Fetch</button>
</div>
</div>
<div style="text-align:center; margin: 15px 0; color: var(--text-secondary)">- OR -</div>
<div class="form-group">
<label class="form-label">Paste JSON Content</label>
<textarea class="form-input export-area" id="pasteJson" placeholder='{ "topics": [...] }'></textarea>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" onclick="closeModal('importModal')">Cancel</button>
<button class="btn btn-primary" onclick="processPaste()">Parse JSON</button>
</div>
</div>
</div>
<div class="modal-overlay" id="exportModal">
<div class="modal">
<h2>Export Data</h2>
<p style="color:var(--text-secondary); font-size:14px; margin-bottom:15px;">
Copy the text below or download the file to replace your current <code>dailys.json</code>.
</p>
<textarea class="form-input export-area" id="exportArea" readonly></textarea>
<div class="modal-footer">
<button class="btn btn-secondary" onclick="copyToClipboard()">
<i class="fas fa-copy"></i> Copy
</button>
<button class="btn btn-primary" onclick="downloadFile()">
<i class="fas fa-download"></i> Download .json
</button>
<button class="btn btn-secondary" onclick="closeModal('exportModal')">Close</button>
</div>
</div>
</div>
<div class="toast" id="toast">
<i class="fas fa-check-circle"></i>
<span id="toastMsg">Success</span>
</div>
<script>
let appData = { topics: [] };
const defaultUrl = "https://periandevelopment.github.io/Dailys/dailys.json";
let dragSrcIndex = null;
let dragParentIndex = null;
let dragType = null;
document.addEventListener('DOMContentLoaded', () => {
loadDefault();
document.getElementById('catIcon').addEventListener('input', (e) => {
document.getElementById('catIconPreview').className = e.target.value;
});
document.getElementById('gameFavicon').addEventListener('input', (e) => {
const img = document.getElementById('gameFaviconPreview');
img.src = e.target.value;
img.style.display = e.target.value ? 'block' : 'none';
});
});
async function loadDefault() {
try {
const res = await fetch(defaultUrl);
if(res.ok) {
appData = await res.json();
render();
} else { throw new Error("Status " + res.status); }
} catch (e) {
document.getElementById('editorContainer').innerHTML = `
<div class="empty-state">
<i class="fas fa-exclamation-triangle"></i>
<h2>Load Data to Begin</h2>
<button class="btn btn-primary" style="margin: 20px auto" onclick="openModal('importModal')">Import JSON</button>
</div>`;
}
}
async function loadFromUrlInput() {
const url = document.getElementById('importUrl').value;
try {
const res = await fetch(url);
appData = await res.json();
render();
closeModal('importModal');
showToast("Loaded from URL");
} catch (e) { alert("Failed to load URL."); }
}
function processPaste() {
try {
appData = JSON.parse(document.getElementById('pasteJson').value);
render();
closeModal('importModal');
showToast("JSON Parsed");
} catch (e) { alert("Invalid JSON"); }
}
function render() {
const container = document.getElementById('editorContainer');
container.innerHTML = '';
appData.topics.forEach((topic, tIndex) => {
const catWrapper = document.createElement('div');
catWrapper.className = 'category-wrapper';
catWrapper.setAttribute('draggable', 'true');
catWrapper.addEventListener('dragstart', (e) => {
dragType = 'category';
dragSrcIndex = tIndex;
e.stopPropagation();
});
catWrapper.addEventListener('dragover', (e) => e.preventDefault());
catWrapper.addEventListener('drop', (e) => {
e.stopPropagation();
if(dragType !== 'category') return;
const item = appData.topics.splice(dragSrcIndex, 1)[0];
appData.topics.splice(tIndex, 0, item);
render();
});
catWrapper.innerHTML = `
<div class="cat-header-edit">
<div class="cat-title-group">
<i class="fas fa-grip-vertical drag-handle"></i>
<div class="section-icon"><i class="${topic.icon}"></i></div>
<div>
<div class="cat-title-text">${escapeHtml(topic.name)}</div>
<div class="cat-desc-text">${escapeHtml(topic.description || '')}</div>
</div>
</div>
<div class="action-group">
<button class="icon-btn" onclick="editCategory(${tIndex})"><i class="fas fa-pen"></i></button>
<button class="icon-btn delete" onclick="deleteCategory(${tIndex})"><i class="fas fa-trash"></i></button>
</div>
</div>
<div class="games-grid" style="padding: 20px; margin-bottom: 0;"></div>
<div class="add-game-area">
<button class="add-game-btn" onclick="addGame(${tIndex})">
<i class="fas fa-plus"></i> Add Daily to "${escapeHtml(topic.name)}"
</button>
</div>
`;
const gamesGrid = catWrapper.querySelector('.games-grid');
if (topic.games) {
topic.games.forEach((game, gIndex) => {
const card = document.createElement('div');
card.className = 'game-card';
card.setAttribute('draggable', 'true');
card.addEventListener('dragstart', (e) => {
dragType = 'game';
dragSrcIndex = gIndex;
dragParentIndex = tIndex;
e.stopPropagation();
});
card.addEventListener('dragover', (e) => e.preventDefault());
card.addEventListener('drop', (e) => {
e.stopPropagation();
if(dragType !== 'game' || dragParentIndex !== tIndex) return;
const item = appData.topics[tIndex].games.splice(dragSrcIndex, 1)[0];
appData.topics[tIndex].games.splice(gIndex, 0, item);
render();
});
card.innerHTML = `
<div class="game-content">
<div class="game-info">
<i class="fas fa-grip-vertical drag-handle"></i>
<div class="game-favicon">
<img src="${game.favicon}" onerror="this.style.display='none'">
</div>
<div class="game-title">${escapeHtml(game.name)}</div>
</div>
<div class="game-actions">
<button class="icon-btn" onclick="editGame(${tIndex}, ${gIndex})"><i class="fas fa-pen"></i></button>
<button class="icon-btn delete" onclick="deleteGame(${tIndex}, ${gIndex})"><i class="fas fa-trash"></i></button>
</div>
</div>
`;
gamesGrid.appendChild(card);
});
}
container.appendChild(catWrapper);
});
}
function addNewCategory() {
document.getElementById('catModalTitle').innerText = "New Category";
document.getElementById('catIndex').value = "-1";
document.getElementById('catId').value = "";
document.getElementById('catName').value = "";
document.getElementById('catIcon').value = "fas fa-gamepad";
document.getElementById('catDesc').value = "";
openModal('categoryModal');
}
function editCategory(index) {
const t = appData.topics[index];
document.getElementById('catModalTitle').innerText = "Edit Category";
document.getElementById('catIndex').value = index;
document.getElementById('catId').value = t.id;
document.getElementById('catName').value = t.name;
document.getElementById('catIcon').value = t.icon;
document.getElementById('catDesc').value = t.description;
openModal('categoryModal');
}
function saveCategory() {
const idx = parseInt(document.getElementById('catIndex').value);
const data = {
id: document.getElementById('catId').value,
name: document.getElementById('catName').value,
icon: document.getElementById('catIcon').value,
description: document.getElementById('catDesc').value,
games: idx >= 0 ? (appData.topics[idx].games || []) : []
};
if(idx === -1) appData.topics.push(data);
else appData.topics[idx] = data;
closeModal('categoryModal');
render();
showToast("Category Saved");
}
function deleteCategory(index) {
if(confirm("Delete category?")) { appData.topics.splice(index, 1); render(); }
}
function addGame(catIdx) {
document.getElementById('gameModalTitle').innerText = "New Daily";
document.getElementById('gameCatIndex').value = catIdx;
document.getElementById('gameIndex').value = "-1";
document.getElementById('gameId').value = "";
document.getElementById('gameName').value = "";
document.getElementById('gameUrl').value = "";
document.getElementById('gameFavicon').value = "";
openModal('gameModal');
}
function editGame(catIdx, gameIdx) {
const g = appData.topics[catIdx].games[gameIdx];
document.getElementById('gameModalTitle').innerText = "Edit Daily";
document.getElementById('gameCatIndex').value = catIdx;
document.getElementById('gameIndex').value = gameIdx;
document.getElementById('gameId').value = g.id;
document.getElementById('gameName').value = g.name;
document.getElementById('gameUrl').value = g.url;
document.getElementById('gameFavicon').value = g.favicon;
openModal('gameModal');
}
function saveGame() {
const cIdx = parseInt(document.getElementById('gameCatIndex').value);
const gIdx = parseInt(document.getElementById('gameIndex').value);
const newGame = {
id: document.getElementById('gameId').value,
name: document.getElementById('gameName').value,
url: document.getElementById('gameUrl').value,
favicon: document.getElementById('gameFavicon').value
};
if(!appData.topics[cIdx].games) appData.topics[cIdx].games = [];
if(gIdx === -1) appData.topics[cIdx].games.push(newGame);
else appData.topics[cIdx].games[gIdx] = newGame;
closeModal('gameModal');
render();
showToast("Daily Saved");
}
function deleteGame(cIdx, gIdx) {
if(confirm("Delete daily?")) { appData.topics[cIdx].games.splice(gIdx, 1); render(); }
}
function openExportModal() {
document.getElementById('exportArea').value = JSON.stringify(appData, null, 2);
openModal('exportModal');
}
function copyToClipboard() {
const txt = document.getElementById('exportArea');
txt.select();
document.execCommand('copy');
showToast("Copied!");
}
function downloadFile() {
const dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(appData, null, 2));
const dlNode = document.createElement('a');
dlNode.setAttribute("href", dataStr);
dlNode.setAttribute("download", "dailys.json");
dlNode.click();
}
function openModal(id) { document.getElementById(id).classList.add('active'); }
function closeModal(id) { document.getElementById(id).classList.remove('active'); }
function showToast(msg) {
const t = document.getElementById('toast');
document.getElementById('toastMsg').innerText = msg;
t.classList.add('show');
setTimeout(() => t.classList.remove('show'), 3000);
}
function escapeHtml(text) {
if (!text) return "";
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
}
document.querySelectorAll('.modal-overlay').forEach(el => {
el.addEventListener('click', e => { if(e.target===el) closeModal(el.id); });
});
</script>
</body>
</html>