Fix comment event listener
This commit is contained in:
parent
2a4b252a9d
commit
23ccaea2ff
3 changed files with 175 additions and 169 deletions
|
@ -69,9 +69,10 @@ function get_playlist(plid, retries) {
|
||||||
xhr.send();
|
xhr.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (video_data.plid) {
|
window.addEventListener('load', function (e) {
|
||||||
|
if (video_data.plid) {
|
||||||
get_playlist(video_data.plid);
|
get_playlist(video_data.plid);
|
||||||
} else if (video_data.video_series) {
|
} else if (video_data.video_series) {
|
||||||
player.on('ended', function () {
|
player.on('ended', function () {
|
||||||
var url = new URL('https://example.com/embed/' + video_data.video_series.shift());
|
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);
|
location.assign(url.pathname + url.search);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
|
@ -151,6 +151,7 @@ player.vttThumbnails({
|
||||||
|
|
||||||
// Enable annotations
|
// Enable annotations
|
||||||
if (!video_data.params.listen && video_data.params.annotations) {
|
if (!video_data.params.listen && video_data.params.annotations) {
|
||||||
|
window.addEventListener('load', function (e) {
|
||||||
var video_container = document.getElementById('player');
|
var video_container = document.getElementById('player');
|
||||||
let xhr = new XMLHttpRequest();
|
let xhr = new XMLHttpRequest();
|
||||||
xhr.responseType = 'text';
|
xhr.responseType = 'text';
|
||||||
|
@ -190,6 +191,7 @@ if (!video_data.params.listen && video_data.params.annotations) {
|
||||||
});
|
});
|
||||||
|
|
||||||
xhr.send();
|
xhr.send();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function increase_volume(delta) {
|
function increase_volume(delta) {
|
||||||
|
@ -234,25 +236,25 @@ function toggle_play() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const toggle_captions = (function() {
|
const toggle_captions = (function () {
|
||||||
let toggledTrack = null;
|
let toggledTrack = null;
|
||||||
const onChange = function(e) {
|
const onChange = function (e) {
|
||||||
toggledTrack = null;
|
toggledTrack = null;
|
||||||
};
|
};
|
||||||
const bindChange = function(onOrOff) {
|
const bindChange = function (onOrOff) {
|
||||||
player.textTracks()[onOrOff]('change', onChange);
|
player.textTracks()[onOrOff]('change', onChange);
|
||||||
};
|
};
|
||||||
// Wrapper function to ignore our own emitted events and only listen
|
// Wrapper function to ignore our own emitted events and only listen
|
||||||
// to events emitted by Video.js on click on the captions menu items.
|
// 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');
|
bindChange('off');
|
||||||
track.mode = mode;
|
track.mode = mode;
|
||||||
window.setTimeout(function() {
|
window.setTimeout(function () {
|
||||||
bindChange('on');
|
bindChange('on');
|
||||||
}, 0);
|
}, 0);
|
||||||
};
|
};
|
||||||
bindChange('on');
|
bindChange('on');
|
||||||
return function() {
|
return function () {
|
||||||
if (toggledTrack !== null) {
|
if (toggledTrack !== null) {
|
||||||
if (toggledTrack.mode !== 'showing') {
|
if (toggledTrack.mode !== 'showing') {
|
||||||
setMode(toggledTrack, '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
|
// 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
|
// https://github.com/ctd1500/videojs-hotkeys/blob/bb4a158b2e214ccab87c2e7b95f42bc45c6bfd87/videojs.hotkeys.js#L292-L328
|
||||||
(function() {
|
(function () {
|
||||||
const volumeStep = 0.05;
|
const volumeStep = 0.05;
|
||||||
const enableVolumeScroll = true;
|
const enableVolumeScroll = true;
|
||||||
const enableHoverScroll = true;
|
const enableHoverScroll = true;
|
||||||
|
@ -432,8 +434,8 @@ window.addEventListener('keydown', e => {
|
||||||
var volumeHover = false;
|
var volumeHover = false;
|
||||||
var volumeSelector = pEl.querySelector('.vjs-volume-menu-button') || pEl.querySelector('.vjs-volume-panel');
|
var volumeSelector = pEl.querySelector('.vjs-volume-menu-button') || pEl.querySelector('.vjs-volume-panel');
|
||||||
if (volumeSelector != null) {
|
if (volumeSelector != null) {
|
||||||
volumeSelector.onmouseover = function() { volumeHover = true; };
|
volumeSelector.onmouseover = function () { volumeHover = true; };
|
||||||
volumeSelector.onmouseout = function() { volumeHover = false; };
|
volumeSelector.onmouseout = function () { volumeHover = false; };
|
||||||
}
|
}
|
||||||
|
|
||||||
var mouseScroll = function mouseScroll(event) {
|
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);
|
get_playlist(video_data.plid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (video_data.params.comments[0] === 'youtube') {
|
if (video_data.params.comments[0] === 'youtube') {
|
||||||
get_youtube_comments();
|
get_youtube_comments();
|
||||||
} else if (video_data.params.comments[0] === 'reddit') {
|
} else if (video_data.params.comments[0] === 'reddit') {
|
||||||
get_reddit_comments();
|
get_reddit_comments();
|
||||||
} else if (video_data.params.comments[1] === 'youtube') {
|
} else if (video_data.params.comments[1] === 'youtube') {
|
||||||
get_youtube_comments();
|
get_youtube_comments();
|
||||||
} else if (video_data.params.comments[1] === 'reddit') {
|
} else if (video_data.params.comments[1] === 'reddit') {
|
||||||
get_reddit_comments();
|
get_reddit_comments();
|
||||||
} else {
|
} else {
|
||||||
comments = document.getElementById('comments');
|
comments = document.getElementById('comments');
|
||||||
comments.innerHTML = '';
|
comments.innerHTML = '';
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue