Fix comment event listener

pull/836/head
Omar Roth 5 years ago
parent 2a4b252a9d
commit 23ccaea2ff
No known key found for this signature in database
GPG Key ID: B8254FB7EC3D37F2

@ -69,9 +69,10 @@ function get_playlist(plid, retries) {
xhr.send();
}
if (video_data.plid) {
window.addEventListener('load', function (e) {
if (video_data.plid) {
get_playlist(video_data.plid);
} else if (video_data.video_series) {
} else if (video_data.video_series) {
player.on('ended', function () {
var url = new URL('https://example.com/embed/' + video_data.video_series.shift());
@ -97,4 +98,5 @@ if (video_data.plid) {
location.assign(url.pathname + url.search);
});
}
}
});

@ -151,6 +151,7 @@ player.vttThumbnails({
// Enable annotations
if (!video_data.params.listen && video_data.params.annotations) {
window.addEventListener('load', function (e) {
var video_container = document.getElementById('player');
let xhr = new XMLHttpRequest();
xhr.responseType = 'text';
@ -190,6 +191,7 @@ if (!video_data.params.listen && video_data.params.annotations) {
});
xhr.send();
});
}
function increase_volume(delta) {
@ -234,25 +236,25 @@ function toggle_play() {
}
}
const toggle_captions = (function() {
const toggle_captions = (function () {
let toggledTrack = null;
const onChange = function(e) {
const onChange = function (e) {
toggledTrack = null;
};
const bindChange = function(onOrOff) {
const bindChange = function (onOrOff) {
player.textTracks()[onOrOff]('change', onChange);
};
// Wrapper function to ignore our own emitted events and only listen
// to events emitted by Video.js on click on the captions menu items.
const setMode = function(track, mode) {
const setMode = function (track, mode) {
bindChange('off');
track.mode = mode;
window.setTimeout(function() {
window.setTimeout(function () {
bindChange('on');
}, 0);
};
bindChange('on');
return function() {
return function () {
if (toggledTrack !== null) {
if (toggledTrack.mode !== 'showing') {
setMode(toggledTrack, 'showing');
@ -422,7 +424,7 @@ window.addEventListener('keydown', e => {
// Add support for controlling the player volume by scrolling over it. Adapted from
// https://github.com/ctd1500/videojs-hotkeys/blob/bb4a158b2e214ccab87c2e7b95f42bc45c6bfd87/videojs.hotkeys.js#L292-L328
(function() {
(function () {
const volumeStep = 0.05;
const enableVolumeScroll = true;
const enableHoverScroll = true;
@ -432,8 +434,8 @@ window.addEventListener('keydown', e => {
var volumeHover = false;
var volumeSelector = pEl.querySelector('.vjs-volume-menu-button') || pEl.querySelector('.vjs-volume-panel');
if (volumeSelector != null) {
volumeSelector.onmouseover = function() { volumeHover = true; };
volumeSelector.onmouseout = function() { volumeHover = false; };
volumeSelector.onmouseover = function () { volumeHover = true; };
volumeSelector.onmouseout = function () { volumeHover = false; };
}
var mouseScroll = function mouseScroll(event) {

@ -439,19 +439,21 @@ if (video_data.play_next) {
});
}
if (video_data.plid) {
window.addEventListener('load', function (e) {
if (video_data.plid) {
get_playlist(video_data.plid);
}
}
if (video_data.params.comments[0] === 'youtube') {
if (video_data.params.comments[0] === 'youtube') {
get_youtube_comments();
} else if (video_data.params.comments[0] === 'reddit') {
} else if (video_data.params.comments[0] === 'reddit') {
get_reddit_comments();
} else if (video_data.params.comments[1] === 'youtube') {
} else if (video_data.params.comments[1] === 'youtube') {
get_youtube_comments();
} else if (video_data.params.comments[1] === 'reddit') {
} else if (video_data.params.comments[1] === 'reddit') {
get_reddit_comments();
} else {
} else {
comments = document.getElementById('comments');
comments.innerHTML = '';
}
}
});

Loading…
Cancel
Save