-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.html
More file actions
141 lines (129 loc) · 6.46 KB
/
settings.html
File metadata and controls
141 lines (129 loc) · 6.46 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="color-scheme" content="dark">
<meta name="theme-color" content="#050505">
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#050505">
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#050505">
<meta name="description" content="cyroz - Settings previews">
<meta name="keywords" content="cyroz, settings, files, config">
<meta name="author" content="cyroz">
<meta property="og:title" content="cyroz - Settings">
<meta property="og:description" content="Preview settings files">
<meta property="og:type" content="website">
<meta property="og:url" content="https://cyroz1.github.io/settings.html">
<meta property="og:image" content="https://cyroz1.github.io/assets/images/og-preview.png">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://cyroz1.github.io/assets/images/og-preview.png">
<link rel="canonical" href="https://cyroz1.github.io/settings.html">
<title>Settings - cyroz</title>
<link rel="icon" type="image/svg+xml" href="favicon.svg">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="css/base.css">
<link rel="stylesheet" href="css/settings.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="preload" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap"
as="style">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap"
rel="stylesheet">
</head>
<body>
<div class="bg-canvas">
<div class="glow glow-1"></div>
<div class="glow glow-2"></div>
<div class="glow glow-3"></div>
<div class="glow-cursor" id="glowCursor"></div>
</div>
<main class="container">
<header class="hero">
<h1>Settings</h1>
<p>Preview files loaded live from Google Drive</p>
</header>
<div class="settings-grid" id="settingsGrid">
<div class="settings-loading" id="settingsLoading">
<div class="loading-spinner"></div>
<span>Loading settings...</span>
</div>
</div>
<div class="back-wrapper">
<a href="index.html" class="back-button">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<line x1="19" y1="12" x2="5" y2="12" />
<polyline points="12 19 5 12 12 5" />
</svg>
Back to Home
</a>
</div>
</main>
<script>
const CONFIG = {
FOLDER_ID: '1nOATMA-Eh0SJJhRETGKWPvLW1V-F0Idt',
API_KEY: 'AIzaSyCpy-rEO1nopWSSWFuvrWDpelidsV2gpl4',
};
function escapeHtml(value) {
return String(value)
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''');
}
function drivePreviewUrl(fileId) {
return `https://drive.google.com/file/d/${fileId}/preview`;
}
function createSettingCard(file, index) {
const card = document.createElement('div');
card.className = 'settings-card';
card.style.setProperty('--delay', index);
const safeName = escapeHtml(file.name);
const previewSrc = drivePreviewUrl(file.id);
card.innerHTML = `
<h2 class="settings-title">${safeName}</h2>
<div class="settings-preview-wrapper">
<iframe
class="settings-preview"
src="${previewSrc}"
loading="lazy"
title="${safeName} preview"
sandbox="allow-scripts allow-same-origin"
allow="autoplay">
</iframe>
</div>
`;
return card;
}
async function loadSettings() {
const grid = document.getElementById('settingsGrid');
const loading = document.getElementById('settingsLoading');
try {
const apiUrl = `https://www.googleapis.com/drive/v3/files?` +
`q='${CONFIG.FOLDER_ID}'+in+parents+and+trashed=false+and+mimeType!='application/vnd.google-apps.folder'` +
`&key=${CONFIG.API_KEY}` +
`&fields=files(id,name,mimeType,modifiedTime)` +
`&orderBy=modifiedTime+desc&pageSize=100`;
const res = await fetch(apiUrl);
if (!res.ok) throw new Error(`API returned ${res.status}`);
const data = await res.json();
const files = data.files || [];
loading.remove();
if (files.length === 0) {
grid.innerHTML = `<div class="settings-empty"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg><p>No settings files found right now.</p></div>`;
return;
}
const fragment = document.createDocumentFragment();
files.forEach((file, index) => fragment.appendChild(createSettingCard(file, index)));
grid.appendChild(fragment);
} catch (err) {
console.error('Failed to load settings:', err);
loading.innerHTML = `<div class="settings-empty"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/></svg><p>Couldn't load settings. Please try again later.</p></div>`;
}
}
document.addEventListener('DOMContentLoaded', loadSettings);
</script>
<script src="js/cursor.js" defer></script>
</body>
</html>