-
Notifications
You must be signed in to change notification settings - Fork 0
/
mhzchoice_ultrawide.js
41 lines (31 loc) · 1.14 KB
/
mhzchoice_ultrawide.js
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
var video, controlBar, fullscreenButton, resolutionsButton;
var ultrawideButton;
var findElements = function () {
video = document.querySelector('#video_html5_api');
controlBar = document.querySelectorAll('.vjs-control-bar')[2];
if (controlBar) {
fullscreenButton = controlBar.querySelector('.vjs-fullscreen-control');
resolutionsButton = controlBar.querySelector('.vjs-resolutions-button');
}
return !!(video && controlBar && fullscreenButton && resolutionsButton);
};
var toggleUltrawide = function () {
video.classList.toggle('ultrawide');
ultrawideButton.classList.toggle('pushed');
};
var run = function () {
if (findElements()) {
ultrawideButton = document.createElement('div');
ultrawideButton.classList.add('vjs-control');
ultrawideButton.classList.add('vjs-button');
ultrawideButton.classList.add('ultrawide');
ultrawideButton.title = 'Ultrawide';
ultrawideButton.addEventListener('click', toggleUltrawide);
controlBar.appendChild(fullscreenButton);
controlBar.appendChild(ultrawideButton);
controlBar.appendChild(resolutionsButton);
} else {
setTimeout(run, 100);
}
};
run();