-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtry-it-yourself.html
More file actions
339 lines (322 loc) · 13.3 KB
/
try-it-yourself.html
File metadata and controls
339 lines (322 loc) · 13.3 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Try It Yourself - ImageKit Video Player</title>
<link rel="stylesheet" href="/src/style.css" />
<style>
.form-container {
background: white;
padding: 2rem;
border-radius: 8px;
margin-bottom: 2rem;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.form-group {
margin-bottom: 1.5rem;
}
.form-group label {
display: block;
margin-bottom: 0.5rem;
font-weight: 500;
color: #1a202c;
}
.form-group input[type="text"],
.form-group input[type="url"] {
width: 100%;
padding: 0.75rem;
border: 1px solid #cbd5e0;
border-radius: 4px;
font-size: 1rem;
box-sizing: border-box;
}
.form-group input[type="text"]:focus,
.form-group input[type="url"]:focus {
outline: none;
border-color: #3182ce;
box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}
.checkbox-group {
display: flex;
flex-direction: column;
gap: 0.75rem;
}
.checkbox-item {
display: flex;
align-items: center;
gap: 0.5rem;
}
.checkbox-item input[type="checkbox"] {
width: 18px;
height: 18px;
cursor: pointer;
}
.checkbox-item label {
margin: 0;
cursor: pointer;
font-weight: normal;
}
.submit-button {
background-color: #3182ce;
color: white;
padding: 0.75rem 2rem;
border: none;
border-radius: 4px;
font-size: 1rem;
font-weight: 500;
cursor: pointer;
transition: background-color 0.2s;
}
.submit-button:hover {
background-color: #2c5aa0;
}
.submit-button:active {
background-color: #1e3f73;
}
.player-container {
margin: 2rem 0;
}
.sub-options {
margin-left: 2rem;
margin-top: 0.5rem;
padding-left: 1rem;
border-left: 2px solid #e2e8f0;
}
.sub-options .form-group {
margin-bottom: 1rem;
}
.sub-options input[type="number"] {
width: 100px;
padding: 0.5rem;
border: 1px solid #cbd5e0;
border-radius: 4px;
font-size: 0.9rem;
}
.sub-options input[type="text"] {
width: 100%;
padding: 0.5rem;
border: 1px solid #cbd5e0;
border-radius: 4px;
font-size: 0.9rem;
}
.sub-options label {
font-size: 0.9rem;
font-weight: normal;
}
.sub-options .help-text {
font-size: 0.85rem;
color: #718096;
margin-top: 0.25rem;
}
.code-block {
max-width: 100%;
word-wrap: break-word;
overflow-wrap: break-word;
}
.code-block pre {
white-space: pre-wrap;
word-wrap: break-word;
overflow-wrap: break-word;
}
.code-block code {
white-space: pre-wrap;
word-wrap: break-word;
overflow-wrap: break-word;
display: block;
}
.translation-lang-item {
display: flex;
gap: 0.5rem;
margin-bottom: 0.5rem;
align-items: flex-start;
}
.translation-lang-item input[type="text"] {
flex: 1;
}
.translation-lang-item .lang-code-input {
width: 100px;
}
.translation-lang-item .remove-button {
background-color: #e53e3e;
color: white;
border: none;
padding: 0.5rem 0.75rem;
border-radius: 4px;
cursor: pointer;
font-size: 0.9rem;
white-space: nowrap;
}
.translation-lang-item .remove-button:hover {
background-color: #c53030;
}
.add-button {
background-color: #48bb78;
color: white;
border: none;
padding: 0.5rem 1rem;
border-radius: 4px;
cursor: pointer;
font-size: 0.9rem;
}
.add-button:hover {
background-color: #38a169;
}
.help-text a {
color: #3182ce;
text-decoration: none;
}
.help-text a:hover {
text-decoration: underline;
}
.help-text code {
background-color: #f7fafc;
padding: 0.125rem 0.25rem;
border-radius: 3px;
font-family: 'Courier New', monospace;
font-size: 0.9em;
color: #2d3748;
}
</style>
</head>
<body>
<div class="container">
<a href="../" class="back-link">← Back to examples</a>
<h1>Try It Yourself</h1>
<p>Configure your video player with custom settings and see the code generated in real-time.</p>
<div class="form-container">
<form id="player-form">
<div class="form-group">
<label for="imagekit-id">ImageKit ID</label>
<input type="text" id="imagekit-id" name="imagekit-id" placeholder="Enter your ImageKit ID" />
</div>
<div class="form-group">
<label for="src-url">Source URL</label>
<input type="url" id="src-url" name="src-url" placeholder="Enter video source URL" />
</div>
<div class="form-group">
<label for="transformation">Transformation (JSON, optional)</label>
<input type="text" id="transformation" name="transformation" placeholder='[{"width": 800, "height": 600}]' />
<div class="help-text">JSON array of transformation objects. Example: <code>[{"width": 800, "height": 600}]</code></div>
</div>
<div class="form-group">
<div class="checkbox-item">
<input type="checkbox" id="enable-signer" name="enable-signer" />
<label for="enable-signer">Enable Signer Function</label>
</div>
<div id="signer-options" class="sub-options" style="display: none;">
<div class="form-group">
<label for="signer-url">Signer Function URL</label>
<input type="url" id="signer-url" name="signer-url" placeholder="https://your-api.com/sign?url=" />
<div class="help-text">URL endpoint that accepts a URL parameter and returns a signed URL</div>
</div>
</div>
</div>
<div class="form-group">
<label>Features</label>
<div class="checkbox-group">
<div class="checkbox-item">
<input type="checkbox" id="subtitles" name="features" value="subtitles" />
<label for="subtitles">Subtitles (Auto-generate)</label>
</div>
<div id="subtitles-options" class="sub-options" style="display: none;">
<div class="form-group">
<label for="max-chars">Max Chars (optional)</label>
<input type="number" id="max-chars" name="max-chars" min="1" placeholder="e.g., 60" />
<div class="help-text">Maximum number of characters that can appear on a subtitle frame</div>
</div>
<div class="checkbox-item">
<input type="checkbox" id="word-highlight" name="word-highlight" />
<label for="word-highlight">Word Highlight</label>
</div>
</div>
<div class="checkbox-item">
<input type="checkbox" id="translation" name="features" value="translation" />
<label for="translation">Translation</label>
</div>
<div id="translation-options" class="sub-options" style="display: none;">
<div class="form-group">
<label>Translation Languages</label>
<div class="help-text" style="margin-bottom: 0.5rem;">
<a href="https://cloud.google.com/translate/docs/languages" target="_blank" rel="noopener noreferrer">View Google language codes →</a>
</div>
<div id="translation-langs-list"></div>
<button type="button" id="add-translation-lang" class="add-button" style="margin-top: 0.5rem;">+ Add Language</button>
</div>
</div>
<div class="checkbox-item">
<input type="checkbox" id="chapters" name="features" value="chapters" />
<label for="chapters">Chapters</label>
</div>
<div class="checkbox-item">
<input type="checkbox" id="seek-thumbnails" name="features" value="seek-thumbnails" />
<label for="seek-thumbnails">Seek Thumbnails</label>
</div>
<div class="checkbox-item">
<input type="checkbox" id="analytics" name="features" value="analytics" />
<label for="analytics">Analytics</label>
</div>
</div>
</div>
<button type="submit" class="submit-button">Update Player</button>
</form>
</div>
<div class="player-container">
<video id="player" class="video-js" controls preload="auto" width="960" height="540"></video>
</div>
<h2>Generated Code</h2>
<div class="code-block">
<pre><code id="code-display" class="language-javascript"></code></pre>
</div>
</div>
<script type="module" src="/src/try-it-yourself.ts"></script>
<script>
// Show/hide sub-options based on checkbox state
document.getElementById('subtitles')?.addEventListener('change', function() {
const subOptions = document.getElementById('subtitles-options');
if (subOptions) {
subOptions.style.display = this.checked ? 'block' : 'none';
}
});
document.getElementById('translation')?.addEventListener('change', function() {
const subOptions = document.getElementById('translation-options');
if (subOptions) {
subOptions.style.display = this.checked ? 'block' : 'none';
}
});
document.getElementById('enable-signer')?.addEventListener('change', function() {
const subOptions = document.getElementById('signer-options');
if (subOptions) {
subOptions.style.display = this.checked ? 'block' : 'none';
}
});
// Handle addable translation languages list
const translationLangsList = document.getElementById('translation-langs-list');
const addTranslationLangBtn = document.getElementById('add-translation-lang');
function addTranslationLangItem(label = '', langCode = '') {
const item = document.createElement('div');
item.className = 'translation-lang-item';
item.innerHTML = `
<input type="text" class="lang-code-input" placeholder="Code (required, e.g., fr)" value="${langCode}" />
<input type="text" class="translation-label-input" placeholder="Label (optional, e.g., French)" value="${label}" />
<button type="button" class="remove-button">Remove</button>
`;
const removeBtn = item.querySelector('.remove-button');
removeBtn?.addEventListener('click', () => {
item.remove();
});
translationLangsList?.appendChild(item);
}
addTranslationLangBtn?.addEventListener('click', () => {
addTranslationLangItem();
});
// Initialize with one empty item when translation options are shown
document.getElementById('translation')?.addEventListener('change', function() {
const subOptions = document.getElementById('translation-options');
if (subOptions && this.checked && translationLangsList && translationLangsList.children.length === 0) {
addTranslationLangItem();
}
});
</script>
</body>
</html>