mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-22 11:50:14 +00:00
chore: don't need to load script.js anymore
This commit is contained in:
parent
42ff29c13d
commit
4e4db8f0ae
@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
function sortChange(sortValue) {
|
function sortChange(sortValue) {
|
||||||
var payload = JSON.stringify({'sort_order': sortValue});
|
var payload = JSON.stringify({ sort_order: sortValue });
|
||||||
sendPost(payload);
|
sendPost(payload);
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
location.reload();
|
location.reload();
|
||||||
@ -22,11 +21,11 @@ function updateVideoWatchStatus(input1, videoCurrentWatchStatus) {
|
|||||||
|
|
||||||
if (videoCurrentWatchStatus == "watched") {
|
if (videoCurrentWatchStatus == "watched") {
|
||||||
var watchStatusIndicator = createWatchStatusIndicator(videoId, "unwatched");
|
var watchStatusIndicator = createWatchStatusIndicator(videoId, "unwatched");
|
||||||
var payload = JSON.stringify({'un_watched': videoId});
|
var payload = JSON.stringify({ un_watched: videoId });
|
||||||
sendPost(payload);
|
sendPost(payload);
|
||||||
} else if (videoCurrentWatchStatus == "unwatched") {
|
} else if (videoCurrentWatchStatus == "unwatched") {
|
||||||
var watchStatusIndicator = createWatchStatusIndicator(videoId, "watched");
|
var watchStatusIndicator = createWatchStatusIndicator(videoId, "watched");
|
||||||
var payload = JSON.stringify({'watched': videoId});
|
var payload = JSON.stringify({ watched: videoId });
|
||||||
sendPost(payload);
|
sendPost(payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +70,7 @@ function removeProgressBar(videoId) {
|
|||||||
|
|
||||||
function isWatchedButton(button) {
|
function isWatchedButton(button) {
|
||||||
youtube_id = button.getAttribute("data-id");
|
youtube_id = button.getAttribute("data-id");
|
||||||
var payload = JSON.stringify({'watched': youtube_id});
|
var payload = JSON.stringify({ watched: youtube_id });
|
||||||
button.remove();
|
button.remove();
|
||||||
sendPost(payload);
|
sendPost(payload);
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
@ -95,17 +94,17 @@ function isWatchedButton(button) {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
function unsubscribe(id_unsub) {
|
function unsubscribe(id_unsub) {
|
||||||
var payload = JSON.stringify({'unsubscribe': id_unsub});
|
var payload = JSON.stringify({ unsubscribe: id_unsub });
|
||||||
sendPost(payload);
|
sendPost(payload);
|
||||||
var message = document.createElement('span');
|
var message = document.createElement("span");
|
||||||
message.innerText = "You are unsubscribed.";
|
message.innerText = "You are unsubscribed.";
|
||||||
document.getElementById(id_unsub).replaceWith(message);
|
document.getElementById(id_unsub).replaceWith(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
function subscribe(id_sub) {
|
function subscribe(id_sub) {
|
||||||
var payload = JSON.stringify({'subscribe': id_sub});
|
var payload = JSON.stringify({ subscribe: id_sub });
|
||||||
sendPost(payload);
|
sendPost(payload);
|
||||||
var message = document.createElement('span');
|
var message = document.createElement("span");
|
||||||
message.innerText = "You are subscribed.";
|
message.innerText = "You are subscribed.";
|
||||||
document.getElementById(id_sub).replaceWith(message);
|
document.getElementById(id_sub).replaceWith(message);
|
||||||
}
|
}
|
||||||
@ -113,7 +112,7 @@ function subscribe(id_sub) {
|
|||||||
function changeView(image) {
|
function changeView(image) {
|
||||||
var sourcePage = image.getAttribute("data-origin");
|
var sourcePage = image.getAttribute("data-origin");
|
||||||
var newView = image.getAttribute("data-value");
|
var newView = image.getAttribute("data-value");
|
||||||
var payload = JSON.stringify({'change_view': sourcePage + ":" + newView});
|
var payload = JSON.stringify({ change_view: sourcePage + ":" + newView });
|
||||||
sendPost(payload);
|
sendPost(payload);
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
location.reload();
|
location.reload();
|
||||||
@ -138,8 +137,8 @@ function toggleCheckbox(checkbox) {
|
|||||||
|
|
||||||
// download page buttons
|
// download page buttons
|
||||||
function rescanPending() {
|
function rescanPending() {
|
||||||
var payload = JSON.stringify({'rescan_pending': true});
|
var payload = JSON.stringify({ rescan_pending: true });
|
||||||
animate('rescan-icon', 'rotate-img');
|
animate("rescan-icon", "rotate-img");
|
||||||
sendPost(payload);
|
sendPost(payload);
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
checkMessages();
|
checkMessages();
|
||||||
@ -147,8 +146,8 @@ function rescanPending() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function dlPending() {
|
function dlPending() {
|
||||||
var payload = JSON.stringify({'dl_pending': true});
|
var payload = JSON.stringify({ dl_pending: true });
|
||||||
animate('download-icon', 'bounce-img');
|
animate("download-icon", "bounce-img");
|
||||||
sendPost(payload);
|
sendPost(payload);
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
checkMessages();
|
checkMessages();
|
||||||
@ -156,15 +155,15 @@ function dlPending() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function toIgnore(button) {
|
function toIgnore(button) {
|
||||||
var youtube_id = button.getAttribute('data-id');
|
var youtube_id = button.getAttribute("data-id");
|
||||||
var payload = JSON.stringify({'ignore': youtube_id});
|
var payload = JSON.stringify({ ignore: youtube_id });
|
||||||
sendPost(payload);
|
sendPost(payload);
|
||||||
document.getElementById('dl-' + youtube_id).remove();
|
document.getElementById("dl-" + youtube_id).remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
function downloadNow(button) {
|
function downloadNow(button) {
|
||||||
var youtube_id = button.getAttribute('data-id');
|
var youtube_id = button.getAttribute("data-id");
|
||||||
var payload = JSON.stringify({'dlnow': youtube_id});
|
var payload = JSON.stringify({ dlnow: youtube_id });
|
||||||
sendPost(payload);
|
sendPost(payload);
|
||||||
document.getElementById(youtube_id).remove();
|
document.getElementById(youtube_id).remove();
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
@ -173,15 +172,15 @@ function downloadNow(button) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function forgetIgnore(button) {
|
function forgetIgnore(button) {
|
||||||
var youtube_id = button.getAttribute('data-id');
|
var youtube_id = button.getAttribute("data-id");
|
||||||
var payload = JSON.stringify({'forgetIgnore': youtube_id});
|
var payload = JSON.stringify({ forgetIgnore: youtube_id });
|
||||||
sendPost(payload);
|
sendPost(payload);
|
||||||
document.getElementById("dl-" + youtube_id).remove();
|
document.getElementById("dl-" + youtube_id).remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
function addSingle(button) {
|
function addSingle(button) {
|
||||||
var youtube_id = button.getAttribute('data-id');
|
var youtube_id = button.getAttribute("data-id");
|
||||||
var payload = JSON.stringify({'addSingle': youtube_id});
|
var payload = JSON.stringify({ addSingle: youtube_id });
|
||||||
sendPost(payload);
|
sendPost(payload);
|
||||||
document.getElementById("dl-" + youtube_id).remove();
|
document.getElementById("dl-" + youtube_id).remove();
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
@ -190,8 +189,8 @@ function addSingle(button) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function deleteQueue(button) {
|
function deleteQueue(button) {
|
||||||
var to_delete = button.getAttribute('data-id');
|
var to_delete = button.getAttribute("data-id");
|
||||||
var payload = JSON.stringify({'deleteQueue': to_delete});
|
var payload = JSON.stringify({ deleteQueue: to_delete });
|
||||||
sendPost(payload);
|
sendPost(payload);
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
location.reload();
|
location.reload();
|
||||||
@ -200,76 +199,76 @@ function deleteQueue(button) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function stopQueue() {
|
function stopQueue() {
|
||||||
var payload = JSON.stringify({'queue': 'stop'});
|
var payload = JSON.stringify({ queue: "stop" });
|
||||||
sendPost(payload);
|
sendPost(payload);
|
||||||
document.getElementById('stop-icon').remove();
|
document.getElementById("stop-icon").remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
function killQueue() {
|
function killQueue() {
|
||||||
var payload = JSON.stringify({'queue': 'kill'});
|
var payload = JSON.stringify({ queue: "kill" });
|
||||||
sendPost(payload);
|
sendPost(payload);
|
||||||
document.getElementById('kill-icon').remove();
|
document.getElementById("kill-icon").remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
// settings page buttons
|
// settings page buttons
|
||||||
function manualImport() {
|
function manualImport() {
|
||||||
var payload = JSON.stringify({'manual-import': true});
|
var payload = JSON.stringify({ "manual-import": true });
|
||||||
sendPost(payload);
|
sendPost(payload);
|
||||||
// clear button
|
// clear button
|
||||||
var message = document.createElement('p');
|
var message = document.createElement("p");
|
||||||
message.innerText = 'processing import';
|
message.innerText = "processing import";
|
||||||
var toReplace = document.getElementById('manual-import');
|
var toReplace = document.getElementById("manual-import");
|
||||||
toReplace.innerHTML = '';
|
toReplace.innerHTML = "";
|
||||||
toReplace.appendChild(message);
|
toReplace.appendChild(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
function reEmbed() {
|
function reEmbed() {
|
||||||
var payload = JSON.stringify({'re-embed': true});
|
var payload = JSON.stringify({ "re-embed": true });
|
||||||
sendPost(payload);
|
sendPost(payload);
|
||||||
// clear button
|
// clear button
|
||||||
var message = document.createElement('p');
|
var message = document.createElement("p");
|
||||||
message.innerText = 'processing thumbnails';
|
message.innerText = "processing thumbnails";
|
||||||
var toReplace = document.getElementById('re-embed');
|
var toReplace = document.getElementById("re-embed");
|
||||||
toReplace.innerHTML = '';
|
toReplace.innerHTML = "";
|
||||||
toReplace.appendChild(message);
|
toReplace.appendChild(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
function dbBackup() {
|
function dbBackup() {
|
||||||
var payload = JSON.stringify({'db-backup': true});
|
var payload = JSON.stringify({ "db-backup": true });
|
||||||
sendPost(payload);
|
sendPost(payload);
|
||||||
// clear button
|
// clear button
|
||||||
var message = document.createElement('p');
|
var message = document.createElement("p");
|
||||||
message.innerText = 'backing up archive';
|
message.innerText = "backing up archive";
|
||||||
var toReplace = document.getElementById('db-backup');
|
var toReplace = document.getElementById("db-backup");
|
||||||
toReplace.innerHTML = '';
|
toReplace.innerHTML = "";
|
||||||
toReplace.appendChild(message);
|
toReplace.appendChild(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
function dbRestore(button) {
|
function dbRestore(button) {
|
||||||
var fileName = button.getAttribute("data-id");
|
var fileName = button.getAttribute("data-id");
|
||||||
var payload = JSON.stringify({'db-restore': fileName});
|
var payload = JSON.stringify({ "db-restore": fileName });
|
||||||
sendPost(payload);
|
sendPost(payload);
|
||||||
// clear backup row
|
// clear backup row
|
||||||
var message = document.createElement('p');
|
var message = document.createElement("p");
|
||||||
message.innerText = 'restoring from backup';
|
message.innerText = "restoring from backup";
|
||||||
var toReplace = document.getElementById(fileName);
|
var toReplace = document.getElementById(fileName);
|
||||||
toReplace.innerHTML = '';
|
toReplace.innerHTML = "";
|
||||||
toReplace.appendChild(message);
|
toReplace.appendChild(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fsRescan() {
|
function fsRescan() {
|
||||||
var payload = JSON.stringify({'fs-rescan': true});
|
var payload = JSON.stringify({ "fs-rescan": true });
|
||||||
sendPost(payload);
|
sendPost(payload);
|
||||||
// clear button
|
// clear button
|
||||||
var message = document.createElement('p');
|
var message = document.createElement("p");
|
||||||
message.innerText = 'File system scan in progress';
|
message.innerText = "File system scan in progress";
|
||||||
var toReplace = document.getElementById('fs-rescan');
|
var toReplace = document.getElementById("fs-rescan");
|
||||||
toReplace.innerHTML = '';
|
toReplace.innerHTML = "";
|
||||||
toReplace.appendChild(message);
|
toReplace.appendChild(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetToken() {
|
function resetToken() {
|
||||||
var payload = JSON.stringify({'reset-token': true});
|
var payload = JSON.stringify({ "reset-token": true });
|
||||||
sendPost(payload);
|
sendPost(payload);
|
||||||
var message = document.createElement("p");
|
var message = document.createElement("p");
|
||||||
message.innerText = "Token revoked";
|
message.innerText = "Token revoked";
|
||||||
@ -279,7 +278,7 @@ function resetToken() {
|
|||||||
// delete from file system
|
// delete from file system
|
||||||
function deleteConfirm() {
|
function deleteConfirm() {
|
||||||
to_show = document.getElementById("delete-button");
|
to_show = document.getElementById("delete-button");
|
||||||
document.getElementById("delete-item").style.display = 'none';
|
document.getElementById("delete-item").style.display = "none";
|
||||||
to_show.style.display = "block";
|
to_show.style.display = "block";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,8 +310,8 @@ function deletePlaylist(button) {
|
|||||||
var payload = JSON.stringify({
|
var payload = JSON.stringify({
|
||||||
"delete-playlist": {
|
"delete-playlist": {
|
||||||
"playlist-id": playlist_id,
|
"playlist-id": playlist_id,
|
||||||
"playlist-action": playlist_action
|
"playlist-action": playlist_action,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
sendPost(payload);
|
sendPost(payload);
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
@ -322,22 +321,22 @@ function deletePlaylist(button) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cancelDelete() {
|
function cancelDelete() {
|
||||||
document.getElementById("delete-button").style.display = 'none';
|
document.getElementById("delete-button").style.display = "none";
|
||||||
document.getElementById("delete-item").style.display = 'block';
|
document.getElementById("delete-item").style.display = "block";
|
||||||
}
|
}
|
||||||
|
|
||||||
// player
|
// player
|
||||||
function createPlayer(button) {
|
function createPlayer(button) {
|
||||||
var videoId = button.getAttribute('data-id');
|
var videoId = button.getAttribute("data-id");
|
||||||
var videoData = getVideoData(videoId);
|
var videoData = getVideoData(videoId);
|
||||||
var videoProgress = getVideoProgress(videoId).position;
|
var videoProgress = getVideoProgress(videoId).position;
|
||||||
var videoName = videoData.data.title;
|
var videoName = videoData.data.title;
|
||||||
|
|
||||||
var videoTag = createVideoTag(videoData, videoProgress);
|
var videoTag = createVideoTag(videoData, videoProgress);
|
||||||
|
|
||||||
var playlist = '';
|
var playlist = "";
|
||||||
var videoPlaylists = videoData.data.playlist; // Array of playlists the video is in
|
var videoPlaylists = videoData.data.playlist; // Array of playlists the video is in
|
||||||
if (typeof(videoPlaylists) != 'undefined') {
|
if (typeof videoPlaylists != "undefined") {
|
||||||
var subbedPlaylists = getSubbedPlaylists(videoPlaylists); // Array of playlist the video is in that are subscribed
|
var subbedPlaylists = getSubbedPlaylists(videoPlaylists); // Array of playlist the video is in that are subscribed
|
||||||
if (subbedPlaylists.length != 0) {
|
if (subbedPlaylists.length != 0) {
|
||||||
var playlistData = getPlaylistData(subbedPlaylists[0]); // Playlist data for first subscribed playlist
|
var playlistData = getPlaylistData(subbedPlaylists[0]); // Playlist data for first subscribed playlist
|
||||||
@ -356,7 +355,7 @@ function createPlayer(button) {
|
|||||||
// document.getElementById(videoId).outerHTML = ''; // Remove watch indicator from video info
|
// document.getElementById(videoId).outerHTML = ''; // Remove watch indicator from video info
|
||||||
|
|
||||||
// If cast integration is enabled create cast button
|
// If cast integration is enabled create cast button
|
||||||
var castButton = '';
|
var castButton = "";
|
||||||
if (videoData.config.application.enable_cast) {
|
if (videoData.config.application.enable_cast) {
|
||||||
var castButton = `<google-cast-launcher id="castbutton"></google-cast-launcher>`;
|
var castButton = `<google-cast-launcher id="castbutton"></google-cast-launcher>`;
|
||||||
}
|
}
|
||||||
@ -368,13 +367,15 @@ function createPlayer(button) {
|
|||||||
var watchStatusIndicator = createWatchStatusIndicator(videoId, "unwatched");
|
var watchStatusIndicator = createWatchStatusIndicator(videoId, "unwatched");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var playerStats = `<div class="thumb-icon player-stats"><img src="/static/img/icon-eye.svg" alt="views icon"><span>${videoViews}</span>`;
|
var playerStats = `<div class="thumb-icon player-stats"><img src="/static/img/icon-eye.svg" alt="views icon"><span>${videoViews}</span>`;
|
||||||
if (videoData.data.stats.like_count) {
|
if (videoData.data.stats.like_count) {
|
||||||
var likes = formatNumbers(videoData.data.stats.like_count);
|
var likes = formatNumbers(videoData.data.stats.like_count);
|
||||||
playerStats += `<span>|</span><img src="/static/img/icon-thumb.svg" alt="thumbs-up"><span>${likes}</span>`;
|
playerStats += `<span>|</span><img src="/static/img/icon-thumb.svg" alt="thumbs-up"><span>${likes}</span>`;
|
||||||
}
|
}
|
||||||
if (videoData.data.stats.dislike_count && videoData.config.downloads.integrate_ryd) {
|
if (
|
||||||
|
videoData.data.stats.dislike_count &&
|
||||||
|
videoData.config.downloads.integrate_ryd
|
||||||
|
) {
|
||||||
var dislikes = formatNumbers(videoData.data.stats.dislike_count);
|
var dislikes = formatNumbers(videoData.data.stats.dislike_count);
|
||||||
playerStats += `<span>|</span><img class="dislike" src="/static/img/icon-thumb.svg" alt="thumbs-down"><span>${dislikes}</span>`;
|
playerStats += `<span>|</span><img class="dislike" src="/static/img/icon-thumb.svg" alt="thumbs-down"><span>${dislikes}</span>`;
|
||||||
}
|
}
|
||||||
@ -412,9 +413,12 @@ function createVideoTag(videoData, videoProgress) {
|
|||||||
var videoId = videoData.data.youtube_id;
|
var videoId = videoData.data.youtube_id;
|
||||||
var videoUrl = videoData.data.media_url;
|
var videoUrl = videoData.data.media_url;
|
||||||
var videoThumbUrl = videoData.data.vid_thumb_url;
|
var videoThumbUrl = videoData.data.vid_thumb_url;
|
||||||
var subtitles = '';
|
var subtitles = "";
|
||||||
var videoSubtitles = videoData.data.subtitles; // Array of subtitles
|
var videoSubtitles = videoData.data.subtitles; // Array of subtitles
|
||||||
if (typeof(videoSubtitles) != 'undefined' && videoData.config.downloads.subtitle) {
|
if (
|
||||||
|
typeof videoSubtitles != "undefined" &&
|
||||||
|
videoData.config.downloads.subtitle
|
||||||
|
) {
|
||||||
for (var i = 0; i < videoSubtitles.length; i++) {
|
for (var i = 0; i < videoSubtitles.length; i++) {
|
||||||
let label = videoSubtitles[i].name;
|
let label = videoSubtitles[i].name;
|
||||||
if (videoSubtitles[i].source == "auto") {
|
if (videoSubtitles[i].source == "auto") {
|
||||||
@ -476,7 +480,10 @@ function getVideoPlayerWatchStatus() {
|
|||||||
|
|
||||||
var watchButtons = document.getElementsByClassName("watch-button");
|
var watchButtons = document.getElementsByClassName("watch-button");
|
||||||
for (let i = 0; i < watchButtons.length; i++) {
|
for (let i = 0; i < watchButtons.length; i++) {
|
||||||
if (watchButtons[i].getAttribute("data-id") == videoId && watchButtons[i].getAttribute("data-status") == "watched") {
|
if (
|
||||||
|
watchButtons[i].getAttribute("data-id") == videoId &&
|
||||||
|
watchButtons[i].getAttribute("data-status") == "watched"
|
||||||
|
) {
|
||||||
watched = true;
|
watched = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -488,9 +495,11 @@ function onVideoProgress() {
|
|||||||
var videoId = getVideoPlayerVideoId();
|
var videoId = getVideoPlayerVideoId();
|
||||||
var currentTime = getVideoPlayerCurrentTime();
|
var currentTime = getVideoPlayerCurrentTime();
|
||||||
var duration = getVideoPlayerDuration();
|
var duration = getVideoPlayerDuration();
|
||||||
if ((currentTime % 10).toFixed(1) <= 0.2) { // Check progress every 10 seconds or else progress is checked a few times a second
|
if ((currentTime % 10).toFixed(1) <= 0.2) {
|
||||||
|
// Check progress every 10 seconds or else progress is checked a few times a second
|
||||||
postVideoProgress(videoId, currentTime);
|
postVideoProgress(videoId, currentTime);
|
||||||
if (!getVideoPlayerWatchStatus()) { // Check if video is already marked as watched
|
if (!getVideoPlayerWatchStatus()) {
|
||||||
|
// Check if video is already marked as watched
|
||||||
if (watchedThreshold(currentTime, duration)) {
|
if (watchedThreshold(currentTime, duration)) {
|
||||||
updateVideoWatchStatus(videoId, "unwatched");
|
updateVideoWatchStatus(videoId, "unwatched");
|
||||||
}
|
}
|
||||||
@ -501,19 +510,24 @@ function onVideoProgress() {
|
|||||||
// Runs on video end, marks video as watched
|
// Runs on video end, marks video as watched
|
||||||
function onVideoEnded() {
|
function onVideoEnded() {
|
||||||
var videoId = getVideoPlayerVideoId();
|
var videoId = getVideoPlayerVideoId();
|
||||||
if (!getVideoPlayerWatchStatus()) { // Check if video is already marked as watched
|
if (!getVideoPlayerWatchStatus()) {
|
||||||
|
// Check if video is already marked as watched
|
||||||
updateVideoWatchStatus(videoId, "unwatched");
|
updateVideoWatchStatus(videoId, "unwatched");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function watchedThreshold(currentTime, duration) {
|
function watchedThreshold(currentTime, duration) {
|
||||||
var watched = false;
|
var watched = false;
|
||||||
if (duration <= 1800){ // If video is less than 30 min
|
if (duration <= 1800) {
|
||||||
if ((currentTime / duration) >= 0.90) { // Mark as watched at 90%
|
// If video is less than 30 min
|
||||||
|
if (currentTime / duration >= 0.9) {
|
||||||
|
// Mark as watched at 90%
|
||||||
var watched = true;
|
var watched = true;
|
||||||
}
|
}
|
||||||
} else { // If video is more than 30 min
|
} else {
|
||||||
if (currentTime >= (duration - 120)) { // Mark as watched if there is two minutes left
|
// If video is more than 30 min
|
||||||
|
if (currentTime >= duration - 120) {
|
||||||
|
// Mark as watched if there is two minutes left
|
||||||
var watched = true;
|
var watched = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -531,11 +545,14 @@ function onVideoPause() {
|
|||||||
function formatNumbers(number) {
|
function formatNumbers(number) {
|
||||||
var numberUnformatted = parseFloat(number);
|
var numberUnformatted = parseFloat(number);
|
||||||
if (numberUnformatted > 999999999) {
|
if (numberUnformatted > 999999999) {
|
||||||
var numberFormatted = (numberUnformatted / 1000000000).toFixed(1).toString() + "B";
|
var numberFormatted =
|
||||||
|
(numberUnformatted / 1000000000).toFixed(1).toString() + "B";
|
||||||
} else if (numberUnformatted > 999999) {
|
} else if (numberUnformatted > 999999) {
|
||||||
var numberFormatted = (numberUnformatted / 1000000).toFixed(1).toString() + "M";
|
var numberFormatted =
|
||||||
|
(numberUnformatted / 1000000).toFixed(1).toString() + "M";
|
||||||
} else if (numberUnformatted > 999) {
|
} else if (numberUnformatted > 999) {
|
||||||
var numberFormatted = (numberUnformatted / 1000).toFixed(1).toString() + "K";
|
var numberFormatted =
|
||||||
|
(numberUnformatted / 1000).toFixed(1).toString() + "K";
|
||||||
} else {
|
} else {
|
||||||
var numberFormatted = numberUnformatted;
|
var numberFormatted = numberUnformatted;
|
||||||
}
|
}
|
||||||
@ -585,9 +602,9 @@ function getSubbedPlaylists(videoPlaylists) {
|
|||||||
function postVideoProgress(videoId, videoProgress) {
|
function postVideoProgress(videoId, videoProgress) {
|
||||||
var apiEndpoint = "/api/video/" + videoId + "/progress/";
|
var apiEndpoint = "/api/video/" + videoId + "/progress/";
|
||||||
var duartion = getVideoPlayerDuration();
|
var duartion = getVideoPlayerDuration();
|
||||||
if (!isNaN(videoProgress) && duartion != 'undefined') {
|
if (!isNaN(videoProgress) && duartion != "undefined") {
|
||||||
var data = {
|
var data = {
|
||||||
"position": videoProgress
|
position: videoProgress,
|
||||||
};
|
};
|
||||||
if (videoProgress == 0) {
|
if (videoProgress == 0) {
|
||||||
apiRequest(apiEndpoint, "DELETE");
|
apiRequest(apiEndpoint, "DELETE");
|
||||||
@ -622,7 +639,7 @@ function removePlayer() {
|
|||||||
var videoId = getVideoPlayerVideoId();
|
var videoId = getVideoPlayerVideoId();
|
||||||
postVideoProgress(videoId, currentTime);
|
postVideoProgress(videoId, currentTime);
|
||||||
setProgressBar(videoId, currentTime, duration);
|
setProgressBar(videoId, currentTime, duration);
|
||||||
var playerElement = document.getElementById('player');
|
var playerElement = document.getElementById("player");
|
||||||
if (playerElement.hasChildNodes()) {
|
if (playerElement.hasChildNodes()) {
|
||||||
var youtubeId = playerElement.childNodes[1].getAttribute("data-id");
|
var youtubeId = playerElement.childNodes[1].getAttribute("data-id");
|
||||||
var playedStatus = document.createDocumentFragment();
|
var playedStatus = document.createDocumentFragment();
|
||||||
@ -630,9 +647,9 @@ function removePlayer() {
|
|||||||
if (playedBox) {
|
if (playedBox) {
|
||||||
playedStatus.appendChild(playedBox);
|
playedStatus.appendChild(playedBox);
|
||||||
}
|
}
|
||||||
playerElement.innerHTML = '';
|
playerElement.innerHTML = "";
|
||||||
// append played status
|
// append played status
|
||||||
var videoInfo = document.getElementById('video-info-' + youtubeId);
|
var videoInfo = document.getElementById("video-info-" + youtubeId);
|
||||||
videoInfo.insertBefore(playedStatus, videoInfo.firstChild);
|
videoInfo.insertBefore(playedStatus, videoInfo.firstChild);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -652,14 +669,12 @@ function setProgressBar(videoId, currentTime, duration) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// progressBar = document.getElementById("progress-" + videoId);
|
// progressBar = document.getElementById("progress-" + videoId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// multi search form
|
// multi search form
|
||||||
function searchMulti(query) {
|
function searchMulti(query) {
|
||||||
if (query.length > 1) {
|
if (query.length > 1) {
|
||||||
var payload = JSON.stringify({'multi_search': query});
|
var payload = JSON.stringify({ multi_search: query });
|
||||||
var http = new XMLHttpRequest();
|
var http = new XMLHttpRequest();
|
||||||
http.onreadystatechange = function () {
|
http.onreadystatechange = function () {
|
||||||
if (http.readyState === 4) {
|
if (http.readyState === 4) {
|
||||||
@ -712,7 +727,6 @@ function populateMultiSearchResults(allResults) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function createVideo(video, viewStyle) {
|
function createVideo(video, viewStyle) {
|
||||||
// create video item div from template
|
// create video item div from template
|
||||||
const videoId = video.youtube_id;
|
const videoId = video.youtube_id;
|
||||||
@ -725,7 +739,7 @@ function createVideo(video, viewStyle) {
|
|||||||
var watchStatusIndicator = createWatchStatusIndicator(videoId, "watched");
|
var watchStatusIndicator = createWatchStatusIndicator(videoId, "watched");
|
||||||
} else {
|
} else {
|
||||||
var watchStatusIndicator = createWatchStatusIndicator(videoId, "unwatched");
|
var watchStatusIndicator = createWatchStatusIndicator(videoId, "unwatched");
|
||||||
};
|
}
|
||||||
const channelId = video.channel.channel_id;
|
const channelId = video.channel.channel_id;
|
||||||
const channelName = video.channel.channel_name;
|
const channelName = video.channel.channel_name;
|
||||||
// build markup
|
// build markup
|
||||||
@ -757,7 +771,6 @@ function createVideo(video, viewStyle) {
|
|||||||
return videoDiv;
|
return videoDiv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function createChannel(channel, viewStyle) {
|
function createChannel(channel, viewStyle) {
|
||||||
// create channel item div from template
|
// create channel item div from template
|
||||||
const channelId = channel.channel_id;
|
const channelId = channel.channel_id;
|
||||||
@ -833,7 +846,6 @@ function createPlaylist(playlist, viewStyle) {
|
|||||||
return playlistDiv;
|
return playlistDiv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// generic
|
// generic
|
||||||
function sendPost(payload) {
|
function sendPost(payload) {
|
||||||
var http = new XMLHttpRequest();
|
var http = new XMLHttpRequest();
|
||||||
@ -843,7 +855,6 @@ function sendPost(payload) {
|
|||||||
http.send(payload);
|
http.send(payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getCookie(c_name) {
|
function getCookie(c_name) {
|
||||||
if (document.cookie.length > 0) {
|
if (document.cookie.length > 0) {
|
||||||
c_start = document.cookie.indexOf(c_name + "=");
|
c_start = document.cookie.indexOf(c_name + "=");
|
||||||
@ -857,30 +868,29 @@ function getCookie(c_name) {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// animations
|
// animations
|
||||||
function textReveal() {
|
function textReveal() {
|
||||||
var textBox = document.getElementById('text-reveal');
|
var textBox = document.getElementById("text-reveal");
|
||||||
var button = document.getElementById('text-reveal-button');
|
var button = document.getElementById("text-reveal-button");
|
||||||
var textBoxHeight = textBox.style.height;
|
var textBoxHeight = textBox.style.height;
|
||||||
if (textBoxHeight === 'unset') {
|
if (textBoxHeight === "unset") {
|
||||||
textBox.style.height = '0px';
|
textBox.style.height = "0px";
|
||||||
button.innerText = 'Show';
|
button.innerText = "Show";
|
||||||
} else {
|
} else {
|
||||||
textBox.style.height = 'unset';
|
textBox.style.height = "unset";
|
||||||
button.innerText = 'Hide';
|
button.innerText = "Hide";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showForm() {
|
function showForm() {
|
||||||
var formElement = document.getElementById('hidden-form');
|
var formElement = document.getElementById("hidden-form");
|
||||||
var displayStyle = formElement.style.display;
|
var displayStyle = formElement.style.display;
|
||||||
if (displayStyle === "") {
|
if (displayStyle === "") {
|
||||||
formElement.style.display = 'block';
|
formElement.style.display = "block";
|
||||||
} else {
|
} else {
|
||||||
formElement.style.display = "";
|
formElement.style.display = "";
|
||||||
}
|
}
|
||||||
animate('animate-icon', 'pulse-img');
|
animate("animate-icon", "pulse-img");
|
||||||
}
|
}
|
||||||
|
|
||||||
function showOverwrite() {
|
function showOverwrite() {
|
||||||
@ -888,7 +898,7 @@ function showOverwrite() {
|
|||||||
if (overwriteDiv.classList.contains("hidden-overwrite")) {
|
if (overwriteDiv.classList.contains("hidden-overwrite")) {
|
||||||
overwriteDiv.classList.remove("hidden-overwrite");
|
overwriteDiv.classList.remove("hidden-overwrite");
|
||||||
} else {
|
} else {
|
||||||
overwriteDiv.classList.add("hidden-overwrite")
|
overwriteDiv.classList.add("hidden-overwrite");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,11 +28,6 @@ function MyApp({ Component, pageProps: { session, ...pageProps } }: AppProps) {
|
|||||||
strategy="lazyOnload"
|
strategy="lazyOnload"
|
||||||
src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"
|
src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"
|
||||||
/> */}
|
/> */}
|
||||||
<Script
|
|
||||||
onError={(e) => console.log(`Error loading script.js: ${e}`)}
|
|
||||||
strategy="lazyOnload"
|
|
||||||
src="/js/script.js"
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/** TODO: Detect casting before loading this? */}
|
{/** TODO: Detect casting before loading this? */}
|
||||||
{/* <ClientOnlyScript strategy="lazyOnload" src="/js/cast-videos.js" /> */}
|
{/* <ClientOnlyScript strategy="lazyOnload" src="/js/cast-videos.js" /> */}
|
||||||
|
Loading…
Reference in New Issue
Block a user