-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
867 lines (733 loc) · 35.1 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
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
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Vidyard Custom Link Generator</title>
<link href="https://fonts.googleapis.com/css?family=Roboto:400,500&display=swap" rel="stylesheet">
<link rel="icon" href="https://www.vidyard.com/wp-content/uploads/fbrfg/favicon-32x32.png" sizes="32x32" type="image/png">
<link rel="icon" href="https://www.vidyard.com/wp-content/uploads/fbrfg/favicon-16x16.png" sizes="16x16" type="image/png">
<link rel="icon" href="https://www.vidyard.com/wp-content/uploads/fbrfg/favicon-48x48.png" sizes="48x48" type="image/png">
<link rel="icon" href="https://www.vidyard.com/wp-content/uploads/fbrfg/favicon-96x96.png" sizes="96x96" type="image/png">
<link rel="icon" href="https://www.vidyard.com/wp-content/uploads/fbrfg/favicon-144x144.png" sizes="144x144" type="image/png">
<link rel="icon" href="https://www.vidyard.com/wp-content/uploads/fbrfg/favicon-192x192.png" sizes="192x192" type="image/png">
<link rel="icon" href="https://www.vidyard.com/wp-content/uploads/fbrfg/favicon-256x256.png" sizes="256x256" type="image/png">
<link rel="icon" href="https://www.vidyard.com/wp-content/uploads/fbrfg/favicon-384x384.png" sizes="384x384" type="image/png">
<link rel="icon" href="https://www.vidyard.com/wp-content/uploads/fbrfg/favicon-512x512.png" sizes="512x512" type="image/png">
<link rel="apple-touch-icon" sizes="180x180" href="https://www.vidyard.com/wp-content/uploads/fbrfg/apple-touch-icon.png">
<link rel="shortcut icon" href="https://www.vidyard.com/wp-content/uploads/fbrfg/favicon.ico">
<style>
body {
font-family: 'Roboto', sans-serif;
background-color: #EEEEEE;
padding: 0;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.card {
width: 80%;
max-width: 960px;
margin: auto;
background: white;
padding: 40px;
border-radius: 8px;
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
}
.material-input {
position: relative;
padding-top: 20px;
margin-bottom: 20px;
flex-grow: 1;
}
.material-input input,
.material-input select {
border: none;
border-bottom: 2px solid #9E9E9E;
font-size: 18px;
width: 100%;
padding: 10px 5px;
outline: none;
background: transparent;
font-size: 16px;
}
.material-input label {
position: absolute;
top: 0;
left: 5px;
font-size: 18px;
color: #000000;
transition: all 0.2s ease;
pointer-events: none;
}
.material-input input:focus + label,
.material-input input:not(:placeholder-shown) + label,
.material-input select:focus + label {
top: 0px;
font-size: 16px;
color: #3F51B5;
}
.material-input input:focus,
.material-input select:focus {
border-bottom: 2px solid #3F51B5;
}
button {
padding: 15px 30px;
margin-top: 10px;
font-size: 16px;
border: none;
cursor: pointer;
transition: background-color 0.3s ease;
outline: none;
color: #fff;
background-color: #3F51B5;
text-transform: uppercase;
border-radius: 40px; /* Increase this value for more rounded corners */
}
button:hover {
background-color: #303F9F;
}
button:active {
background-color: #283593;
}
.button-container {
display: flex;
gap: 10px;
margin-bottom: 20px;
}
#outputArea {
width: 100%;
height: 200px;
margin-top: 20px;
padding: 15px;
border: 1px solid #BDBDBD;
border-radius: 4px;
font-family: 'Roboto', sans-serif;
font-size: 16px;
background-color: #FAFAFA;
color: #212121;
}
.checkbox-container {
display: flex;
flex-wrap: wrap;
justify-content: start;
gap: 20px; /* Adds space between the checkboxes */
margin-bottom: 20px; /* Space below the checkbox container */
}
.checkbox-field {
display: flex;
align-items: center;
}
.color-picker-button {
background-color: #FFFFFF;
border: 2px solid #9E9E9E;
border-radius: 4px;
cursor: pointer;
height: 36px;
width: 100px;
margin-right: 10px;
font-size: 14px;
line-height: 32px;
text-align: center;
display: inline-block;
vertical-align: middle;
}
.color-picker-button:not(.no-color) {
color: #FFFFFF;
}
.color-picker-button:focus,
.color-picker-button:active {
outline: none;
border-color: #3F51B5;
}
.hidden-color-input {
display: none;
}
.color-input-wrapper {
display: flex;
align-items: center;
margin-bottom: 20px;
}
.color-label {
margin-right: 10px;
font-size: 18px;
}
.color-input {
height: 36px;
border: 2px solid #9E9E9E;
border-radius: 4px;
background-color: #FFFFFF; /* White background to blend with the page */
width: 100px;
padding: 0;
-webkit-appearance: none;
outline: none;
opacity: 0; /* Make the input invisible */
position: absolute; /* Position it out of the normal flow */
z-index: -1; /* Place it behind other elements */
}
.color-input-label {
display: inline-block;
cursor: pointer;
height: 36px;
line-height: 36px;
border: 2px solid #9E9E9E;
border-radius: 4px;
background-color: #EEEEEE; /* Match the background color */
width: 100px;
text-align: center;
color: black; /* Initial text color */
}
.color-input-wrapper {
position: relative; /* Context for absolute positioning */
display: flex;
align-items: center;
margin-bottom: 20px;
}
.color-label {
margin-right: 10px;
font-size: 18px;
}
.dropdown-container {
display: flex;
justify-content: space-between;
gap: 10px; /* Adjust the gap size to your preference */
}
.color-picker-container {
display: flex;
justify-content: start; /* Align to the start of the container */
gap: 10px; /* Space between the color pickers */
}
.color-input-wrapper {
flex-basis: 50%; /* Each color picker takes up half the width */
}
.color-label {
margin-right: 10px;
font-size: 18px;
white-space: nowrap; /* Prevent the label from wrapping */
}
.color-input {
width: calc(100% - 10px); /* Adjust width accounting for the margin */
cursor: pointer;
border: 2px solid #9E9E9E;
border-radius: 4px;
height: 36px;
}
.dimensions-container {
display: flex;
justify-content: start; /* Align to the start of the container */
gap: 10px; /* Space between the width and height inputs */
}
.material-input {
flex-basis: 100%; /* Each input takes up half the width */
max-width: 100%; /* Prevent the input from exceeding half the container's width */
}
/* Adjust the width of the input fields within the .material-input div */
.material-input input {
width: calc(100% - 50px); /* Subtracting the padding and borders if any */
}
.header {
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
margin-bottom: 30px; /* Adjust as needed */
}
.vidyard-logo {
height: 50px; /* Adjust as needed */
width: auto; /* Adjust if you have a specific width in mind */
}
/* Style for the heading */
.header h1 {
font-size: 36px;
color: #3F51B5; /* You can use Vidyard's brand color here */
margin: 0; /* Removes default margin */
padding: 0; /* Removes default padding */
font-weight: normal; /* Adjust as needed */
}
.checkbox-field {
position: relative;
display: flex;
align-items: center;
gap: 10px;
}
.checkbox-field input {
position: relative;
}
.checkbox-field {
position: relative;
/* Other styles */
}
.tooltip {
visibility: hidden;
width: 180px;
background-color: darkmagenta;
color: white;
text-align: center;
border-radius: 20px;
padding: 15px 0;
position: absolute;
z-index: 1;
bottom: 100%;
left: 50%;
margin-left: -90px; /* Use half of the width value */
opacity: 0.5;
transition: opacity 0.3s;
}
.checkbox-field:hover .tooltip {
visibility: visible;
opacity: 1;
}
.color-input-wrapper:hover .tooltip {
visibility: visible;
opacity: 1;
}
.material-input:hover .tooltip {
visibility: visible;
opacity: 1;
}
#openPreviewBtn {
background-color: limegreen;
}
#previewSharingPageBtn {
background-color: limegreen;
}
#copyToClipboard {
background-color: limegreen;
}
</style>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-KMQPDDDQWS"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-KMQPDDDQWS');
</script>
</head>
<body>
<div class="card">
<div class="header">
<img src="https://www.productboard.com/wp-content/uploads/2020/06/vidyard.png" alt="Vidyard Logo" class="vidyard-logo">
<h1>Vidyard Custom Link Generator</h1>
</div>
<div class="material-input">
<input type="text" id="vidyardLink" placeholder=" " required>
<label>Paste Vidyard Sharing Page URL Here</label>
</div>
<div class="dimensions-container">
<div class="material-input">
<input type="number" id="width" placeholder="Width (e.g., 1280)" min="0">
<label>Width</label>
<span class="tooltip">Overrides the width of the player.</span>
</div>
<div class="material-input">
<input type="number" id="height" placeholder="Height (e.g., 720)" min="0">
<label>Height</label>
<span class="tooltip">Overrides the height of the player.</span>
</div>
</div>
<div class="checkbox-container">
<h3>Standard Controls</h3>
<div class="checkbox-field">
<input type="checkbox" id="autoplay">
<label for="autoplay">Autoplay</label>
<span class="tooltip">Automatically start the video when the page loads.</span>
</div>
<div class="checkbox-field">
<input type="checkbox" id="hidden_controls">
<label for="hidden_controls">Hide Player Controls</label>
<span class="tooltip">Hides the player controls from viewers.</span>
</div>
<div class="checkbox-field">
<input type="checkbox" id="viral_sharing">
<label for="viral_sharing">Viral Sharing</label>
<span class="tooltip">Removes the social network sharing button from the player.</span>
</div>
<div class="checkbox-field">
<input type="checkbox" id="playlist_always_open">
<label for="playlist_always_open">Playlist Always Open</label>
<span class="tooltip">Forces the playlist to always display.</span>
</div>
<div class="checkbox-field">
<input type="checkbox" id="loop">
<label for="loop">Loop</label>
<span class="tooltip">Replays the current video upon completion.</span>
</div>
<div class="color-picker-container">
<div class="color-input-wrapper">
<label class="color-label">Player Color:</label>
<label for="color" class="color-input-label">Choose Color</label>
<input type="color" id="color" class="color-input" onchange="colorChanged('color')">
<span class="tooltip">Select a color for player control bar</span>
</div>
<div class="color-input-wrapper">
<label class="color-label">Play Button Color:</label>
<label for="play_button_color" class="color-input-label">Choose Color</label>
<input type="color" id="play_button_color" class="color-input" onchange="colorChanged('play_button_color')">
<span class="tooltip">Select a color for play button in thumbnail</span>
</div>
</div>
</div>
<div class="checkbox-container">
<!-- Advanced Controls -->
<h3>Advanced Controls</h3>
<div class="checkbox-field">
<input type="checkbox" id="disable_ctas">
<label for="disable_ctas">Disable CTAs</label>
<span class="tooltip">Prevents Events from loading when the player loads.</span>
</div>
<div class="checkbox-field">
<input type="checkbox" id="disable_analytics">
<label for="disable_analytics">Disable Analytics</label>
<span class="tooltip">Disables collection of viewer data by the player.</span>
</div>
<div class="checkbox-field">
<input type="checkbox" id="muted">
<label for="muted">Muted</label>
<span class="tooltip">Mutes the player.</span>
</div>
<div class="checkbox-field">
<input type="checkbox" id="hide_playlist">
<label for="hide_playlist">Hide Playlist</label>
<span class="tooltip">Removes the playlist icon; playlist cannot be accessed.</span>
</div>
</div>
<div class="dropdown-container">
<div class="material-input">
<select id="preload">
<option value="">Select Preload Option</option>
<option value="none">None</option>
<option value="metadata">Metadata</option>
<option value="auto">Auto</option>
</select>
<label>Preload</label>
<span class="tooltip">none - indicates that video files should not begin to download prior to playback.<br><br>
metadata - indicates that a small amount of information is downloaded that prepares the video for playback (e.g. video length).<br><br>
auto - indicates that the video file can begin to download prior to playback.</span>
</div>
<div class="material-input">
<select id="quality">
<option value="">Select Quality</option>
<option value="360p">360p</option>
<option value="480p">480p</option>
<option value="720p">720p</option>
<option value="1080p">1080p</option>
</select>
<label>Quality</label>
<span class="tooltip">Force the viewer to stream at the given resolution. The viewer will still have the ability to change to a higher or lower resolution using the player controls. The player will also still use intelligent resolution selection to automatically lower the resolution in the case of extended buffering.</span>
</div>
<div class="material-input">
<select id="speed">
<option value="">Select Speed</option>
<option value="2">2x</option>
<option value="1.5">1.5x</option>
<option value="1.25">1.25x</option>
<option value="1">Normal</option>
<option value="0.5">0.5x</option>
</select>
<label>Speed</label>
<span class="tooltip">Sets the speed of playback.</span>
</div>
</div>
<div class="button-container">
<button onclick="generateEmbedCode()">Generate Inline Embed</button>
<button onclick="generateLightboxEmbedCode()">Generate Lightbox Embed</button>
<button onclick="generateIframeEmbedCode()">Generate iFrame Embed</button>
<button onclick="generateSharingPageURL()">Generate Sharing Page URL</button>
<button id="copyToClipboard" onclick="copyToClipboard()">Copy to Clipboard </button>
<button id="openPreviewBtn" onclick="openCodePenPreview()" style="display: none;">Open CodePen Preview</button>
<button id="previewSharingPageBtn" onclick="previewSharingPage()" style="display: none;">Preview Sharing Page</button>
</div>
<textarea id="outputArea" readonly></textarea>
</div>
<script>
function trackEvent(eventName) {
gtag('event', eventName, {
'event_category': 'Button Click',
'event_label': eventName
});
}
function generateSharingPageURL() {
const vidyardLink = document.getElementById('vidyardLink').value.trim();
if (!vidyardLink.trim()) {
alert('The sharing page URL is empty. Please generate it first.');
return;
}
const autoplay = document.getElementById('autoplay').checked ? 'autoplay=1' : '';
const previewSharingPageBtn = document.getElementById('previewSharingPageBtn');
previewSharingPageBtn.style.display = 'inline-block';
const openPreviewBtn = document.getElementById('openPreviewBtn');
openPreviewBtn.style.display = 'none';
const disable_ctas = document.getElementById('disable_ctas').checked ? 'disable_ctas=1' : '';
const hidden_controls = document.getElementById('hidden_controls').checked ? 'hidden_controls=1' : '';
const viral_sharing = document.getElementById('viral_sharing').checked ? 'viral_sharing=0' : '';
let color = document.getElementById('color').value;
let play_button_color = document.getElementById('play_button_color').value;
color = (color && color !== '#000000') ? `color=${color.replace('#', '')}` : '';
play_button_color = (play_button_color && play_button_color !== '#000000') ? `play_button_color=${play_button_color.replace('#', '')}` : '';
const preload = document.getElementById('preload').value ? `preload=${document.getElementById('preload').value}` : '';
const playlist_always_open = document.getElementById('playlist_always_open').checked ? 'playlist_always_open=1' : '';
// Add new checkbox values
const loop = document.getElementById('loop').checked ? 'loop=1' : '';
const disable_analytics = document.getElementById('disable_analytics').checked ? 'disable_analytics=1' : '';
const muted = document.getElementById('muted').checked ? 'muted=1' : '';
const hide_playlist = document.getElementById('hide_playlist').checked ? 'hide_playlist=1' : '';
// Add new select values
const quality = document.getElementById('quality').value ? `quality=${document.getElementById('quality').value}` : '';
const speed = document.getElementById('speed').value ? `speed=${document.getElementById('speed').value}` : '';
// Create an array of parameters and filter out empty values
let paramsArray = [
autoplay, disable_ctas, hidden_controls, viral_sharing,
color, play_button_color, preload, playlist_always_open,
loop, disable_analytics, muted, hide_playlist, quality, speed
].filter(param => param);
// Construct the query parameters string
let queryParams = '';
paramsArray.forEach((param, index) => {
queryParams += (index === 0 ? '' : '&') + param;
});
// Determine if vidyardLink already contains query parameters
const separator = vidyardLink.includes('?') && !vidyardLink.endsWith('?') ? '&' : '';
const sharingPageURL = vidyardLink + (queryParams ? separator + queryParams : '');
document.getElementById('outputArea').value = sharingPageURL;
}
function generateEmbedCode() {
const vidyardLink = document.getElementById('vidyardLink').value.trim();
if (!vidyardLink.trim()) {
alert('The sharing page URL is empty. Please generate it first.');
return;
}
// Split the URL at '?' and take the first part, then extract the uuid
const uuid = vidyardLink.split('?')[0].split('/').pop();
const openPreviewBtn = document.getElementById('openPreviewBtn');
openPreviewBtn.style.display = 'inline-block';
const previewSharingPageBtn = document.getElementById('previewSharingPageBtn');
previewSharingPageBtn.style.display = 'none';
const widthValue = document.getElementById('width').value;
const heightValue = document.getElementById('height').value;
const widthAttr = widthValue ? `data-width="${widthValue}"` : '';
const heightAttr = heightValue ? `data-height="${heightValue}"` : '';
let style = 'style="width: 100%; margin: auto; display: block;';
if (widthValue) {
style += ` max-width: ${widthValue}px;`;
}
if (heightValue) {
style += ` max-height: ${heightValue}px;`;
}
style += '"'; // Closing the style attribute
const autoplay = document.getElementById('autoplay').checked ? 'data-autoplay="1"' : '';
const disable_ctas = document.getElementById('disable_ctas').checked ? 'data-disable_ctas="1"' : '';
const hidden_controls = document.getElementById('hidden_controls').checked ? 'data-hidden_controls="1"' : '';
const viral_sharing = document.getElementById('viral_sharing').checked ? 'data-viral_sharing="0"' : '';
let color = document.getElementById('color').value;
let play_button_color = document.getElementById('play_button_color').value;
color = (color && color !== '#000000') ? `data-color="${color.replace('#', '')}"` : '';
play_button_color = (play_button_color && play_button_color !== '#000000') ? `data-play_button_color="${play_button_color.replace('#', '')}"` : '';
const preload = document.getElementById('preload').value ? `data-preload="${document.getElementById('preload').value}"` : '';
const playlist_always_open = document.getElementById('playlist_always_open').checked ? 'data-playlist_always_open="1"' : '';
const loop = document.getElementById('loop').checked ? 'data-loop="1"' : '';
const disable_analytics = document.getElementById('disable_analytics').checked ? 'data-disable_analytics="1"' : '';
const muted = document.getElementById('muted').checked ? 'data-muted="1"' : '';
const hide_playlist = document.getElementById('hide_playlist').checked ? 'data-hide_playlist="1"' : '';
// Add data- prefixed for the new select values
const quality = document.getElementById('quality').value ? `data-quality="${document.getElementById('quality').value}"` : '';
const speed = document.getElementById('speed').value ? `data-speed="${document.getElementById('speed').value}"` : '';
// Combine all data attributes
const dataAttributes = [
autoplay, disable_ctas, hidden_controls, viral_sharing,
color, play_button_color, preload, playlist_always_open,
loop, disable_analytics, muted, hide_playlist, quality, speed,
widthAttr, heightAttr
].filter(attr => attr).map(attr => `\n ${attr}`).join('');
// Construct the embed code with additional parameters
const embedCode = `<!-- The script tag should live in the head of your page if at all possible -->
<script type="text/javascript" async src="https://play.vidyard.com/embed/v4.js"><\/script>
<!-- Put this wherever you would like your player to appear -->
<img
${style}
class="vidyard-player-embed"
src="https://play.vidyard.com/${uuid}.jpg"
data-uuid="${uuid}"
data-v="4"
data-type="inline"
${dataAttributes}
/>
`;
document.getElementById('outputArea').value = embedCode;
}
function generateLightboxEmbedCode() {
const vidyardLink = document.getElementById('vidyardLink').value.trim();
if (!vidyardLink.trim()) {
alert('The sharing page URL is empty. Please generate it first.');
return;
}
// Split the URL at '?' and take the first part, then extract the uuid
const uuid = vidyardLink.split('?')[0].split('/').pop();
const openPreviewBtn = document.getElementById('openPreviewBtn');
openPreviewBtn.style.display = 'inline-block';
const previewSharingPageBtn = document.getElementById('previewSharingPageBtn');
previewSharingPageBtn.style.display = 'none';
const widthValue = document.getElementById('width').value;
const heightValue = document.getElementById('height').value;
const widthAttr = widthValue ? `data-width="${widthValue}"` : '';
const heightAttr = heightValue ? `data-height="${heightValue}"` : '';
let style = 'style="width: 100%; margin: auto; display: block;';
if (widthValue) {
style += ` max-width: ${widthValue}px;`;
}
if (heightValue) {
style += ` max-height: ${heightValue}px;`;
}
style += '"'; // Closing the style attribute
const autoplay = document.getElementById('autoplay').checked ? 'data-autoplay="1"' : '';
const disable_ctas = document.getElementById('disable_ctas').checked ? 'data-disable_ctas="1"' : '';
const hidden_controls = document.getElementById('hidden_controls').checked ? 'data-hidden_controls="1"' : '';
const viral_sharing = document.getElementById('viral_sharing').checked ? 'data-viral_sharing="0"' : '';
let color = document.getElementById('color').value;
let play_button_color = document.getElementById('play_button_color').value;
color = (color && color !== '#000000') ? `data-color="${color.replace('#', '')}"` : '';
play_button_color = (play_button_color && play_button_color !== '#000000') ? `data-play_button_color="${play_button_color.replace('#', '')}"` : '';
const preload = document.getElementById('preload').value ? `data-preload="${document.getElementById('preload').value}"` : '';
const playlist_always_open = document.getElementById('playlist_always_open').checked ? 'data-playlist_always_open="1"' : '';
const loop = document.getElementById('loop').checked ? 'data-loop="1"' : '';
const disable_analytics = document.getElementById('disable_analytics').checked ? 'data-disable_analytics="1"' : '';
const muted = document.getElementById('muted').checked ? 'data-muted="1"' : '';
const hide_playlist = document.getElementById('hide_playlist').checked ? 'data-hide_playlist="1"' : '';
// Add data- prefixed for the new select values
const quality = document.getElementById('quality').value ? `data-quality="${document.getElementById('quality').value}"` : '';
const speed = document.getElementById('speed').value ? `data-speed="${document.getElementById('speed').value}"` : '';
// Combine all data attributes
const dataAttributes = [
autoplay, disable_ctas, hidden_controls, viral_sharing,
color, play_button_color, preload, playlist_always_open,
loop, disable_analytics, muted, hide_playlist, quality, speed, widthAttr, heightAttr
]
.filter(attr => attr)
.map(attr => `\n ${attr}`)
.join('');
// Construct the embed code with additional parameters
const embedCode = `<!-- The script tag should live in the head of your page if at all possible -->
<script type="text/javascript" async src="https://play.vidyard.com/embed/v4.js"><\/script>
<!-- Put this wherever you would like your player to appear -->
<img
${style}
class="vidyard-player-embed"
src="https://play.vidyard.com/${uuid}.jpg"
data-uuid="${uuid}"
data-v="4"
data-type="lightbox"
${dataAttributes}
/>
`;
document.getElementById('outputArea').value = embedCode;
}
function generateIframeEmbedCode() {
const vidyardLink = document.getElementById('vidyardLink').value.trim();
if (!vidyardLink.trim()) {
alert('The sharing page URL is empty. Please generate it first.');
return;
}
const uuid = vidyardLink.split('?')[0].split('/').pop();
const openPreviewBtn = document.getElementById('openPreviewBtn');
openPreviewBtn.style.display = 'inline-block';
const previewSharingPageBtn = document.getElementById('previewSharingPageBtn');
previewSharingPageBtn.style.display = 'none';
// Attributes
const autoplay = document.getElementById('autoplay').checked ? 'autoplay=1' : '';
const disable_ctas = document.getElementById('disable_ctas').checked ? 'disable_ctas=1' : '';
const hidden_controls = document.getElementById('hidden_controls').checked ? 'hidden_controls=1' : '';
const viral_sharing = document.getElementById('viral_sharing').checked ? 'viral_sharing=0' : '';
const loop = document.getElementById('loop').checked ? 'loop=1' : '';
const disable_analytics = document.getElementById('disable_analytics').checked ? 'disable_analytics=1' : '';
const muted = document.getElementById('muted').checked ? 'muted=1' : '';
const hide_playlist = document.getElementById('hide_playlist').checked ? 'hide_playlist=1' : '';
const preload = document.getElementById('preload').value ? `preload=${document.getElementById('preload').value}` : '';
const playlist_always_open = document.getElementById('playlist_always_open').checked ? 'playlist_always_open=1' : '';
const quality = document.getElementById('quality').value ? `quality=${document.getElementById('quality').value}` : '';
const speed = document.getElementById('speed').value ? `speed=${document.getElementById('speed').value}` : '';
// Combine all query parameters
const queryParameters = [
autoplay, disable_ctas, hidden_controls, viral_sharing, loop, disable_analytics,
muted, hide_playlist, preload, playlist_always_open, quality, speed
].filter(param => param).join('&');
// Constructing iframe src URL
const iframeSrc = `//play.vidyard.com/${uuid}.html?${queryParameters}`;
const width = document.getElementById('width').value || '1280'; // Default width
const height = document.getElementById('height').value || '720'; // Default height
// Construct the embed code with additional parameters
const iframeEmbedCode = `<iframe class="vidyard_iframe" title="Vidyard Video Player" src="${iframeSrc}" width="${width}" height="${height}" scrolling="no" frameborder="0" allowtransparency="true" allowfullscreen></iframe>`;
document.getElementById('outputArea').value = iframeEmbedCode;
}
function previewSharingPage() {
const sharingPageURL = document.getElementById('outputArea').value; // Get the generated URL
if (!sharingPageURL.trim()) {
alert('The sharing page URL is empty. Please generate it first.');
return;
}
// Open the URL in a new tab
window.open(sharingPageURL, '_blank');
}
function colorChanged(inputId) {
const colorInput = document.getElementById(inputId);
const color = colorInput.value;
const colorLabel = document.querySelector(`label[for="${inputId}"]`);
// Update the button's (label's) background to the selected color
colorLabel.style.backgroundColor = color;
colorLabel.textContent = color; // Optionally show the hex color code as text
colorLabel.style.color = getContrastYIQ(color);
// If you have a color preview element, update its background too
// const colorPreview = document.getElementById(inputId + '-preview');
// if (colorPreview) {
// colorPreview.style.backgroundColor = color;
// }
}
function getContrastYIQ(hexcolor) {
hexcolor = hexcolor.replace("#", "");
const r = parseInt(hexcolor.substr(0, 2), 16);
const g = parseInt(hexcolor.substr(2, 2), 16);
const b = parseInt(hexcolor.substr(4, 2), 16);
const yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000;
return (yiq >= 128) ? 'black' : 'white';
}
function copyToClipboard() {
const clipArea = document.getElementById('outputArea');
const cpipAreatrim = clipArea.value
if (!cpipAreatrim.trim()) {
alert('Nothing to copy');
return;
}
clipArea.select();
document.execCommand('copy');
alert('Copied to clipboard!');
}
function openCodePenPreview() {
const embedCodeTextArea = document.getElementById('outputArea');
const embedCode = embedCodeTextArea.value;
if (!embedCode.trim()) {
alert('Please generate the embed code first.');
return;
}
const codepenFormData = {
title: 'CodePen Preview',
html: embedCode,
};
const codepenForm = document.createElement('form');
codepenForm.action = 'https://codepen.io/pen/define/';
codepenForm.method = 'POST';
codepenForm.target = '_blank';
codepenForm.style.display = 'none';
const dataInput = document.createElement('input');
dataInput.type = 'hidden';
dataInput.name = 'data';
dataInput.value = JSON.stringify(codepenFormData);
codepenForm.appendChild(dataInput);
document.body.appendChild(codepenForm);
codepenForm.submit();
document.body.removeChild(codepenForm);
}
</script>
</body>
</html>