|
|
@ -946,6 +946,11 @@ async function sendVideoData(newState, overrideChanges) {
|
|
|
|
submissionResponseElem.classList.value = ["submission-response-pending"];
|
|
|
|
submissionResponseElem.classList.value = ["submission-response-pending"];
|
|
|
|
submissionResponseElem.innerText = "Submitting video...";
|
|
|
|
submissionResponseElem.innerText = "Submitting video...";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function submissionError(message) {
|
|
|
|
|
|
|
|
submissionResponseElem.innerText = message;
|
|
|
|
|
|
|
|
submissionResponseElem.classList.value = ["submission-response-error"];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const rangesData = [];
|
|
|
|
const rangesData = [];
|
|
|
|
const transitions = [];
|
|
|
|
const transitions = [];
|
|
|
|
let chaptersData = [];
|
|
|
|
let chaptersData = [];
|
|
|
@ -965,7 +970,7 @@ async function sendVideoData(newState, overrideChanges) {
|
|
|
|
// Note that !(x > 0) is not equivalent to (x <= 0) due to NaN.
|
|
|
|
// Note that !(x > 0) is not equivalent to (x <= 0) due to NaN.
|
|
|
|
const transitionDuration = Number(transitionDurationStr);
|
|
|
|
const transitionDuration = Number(transitionDurationStr);
|
|
|
|
if ( !(transitionDuration > 0) ) {
|
|
|
|
if ( !(transitionDuration > 0) ) {
|
|
|
|
addError(`Couldn't submit edits: Invalid transition duration: "${transitionDurationStr}"`);
|
|
|
|
submissionError(`Couldn't submit edits: Invalid transition duration: "${transitionDurationStr}"`);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
transitions.push([transitionType, transitionDuration])
|
|
|
|
transitions.push([transitionType, transitionDuration])
|
|
|
@ -984,7 +989,6 @@ async function sendVideoData(newState, overrideChanges) {
|
|
|
|
const rangeEndSubmit = wubloaderTimeFromVideoPlayerTime(rangeEndPlayer);
|
|
|
|
const rangeEndSubmit = wubloaderTimeFromVideoPlayerTime(rangeEndPlayer);
|
|
|
|
|
|
|
|
|
|
|
|
if (edited && (!rangeStartSubmit || !rangeEndSubmit)) {
|
|
|
|
if (edited && (!rangeStartSubmit || !rangeEndSubmit)) {
|
|
|
|
submissionResponseElem.classList.value = ["submission-response-error"];
|
|
|
|
|
|
|
|
let errorMessage;
|
|
|
|
let errorMessage;
|
|
|
|
if (!rangeStartSubmit && !rangeEndSubmit) {
|
|
|
|
if (!rangeStartSubmit && !rangeEndSubmit) {
|
|
|
|
errorMessage = `The range endpoints "${rangeStartSubmit}" and "${rangeEndSubmit}" are not valid.`;
|
|
|
|
errorMessage = `The range endpoints "${rangeStartSubmit}" and "${rangeEndSubmit}" are not valid.`;
|
|
|
@ -993,14 +997,12 @@ async function sendVideoData(newState, overrideChanges) {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
errorMessage = `The range endpoint "${rangeEndSubmit}" is not valid.`;
|
|
|
|
errorMessage = `The range endpoint "${rangeEndSubmit}" is not valid.`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
submissionResponseElem.innerText = errorMessage;
|
|
|
|
submissionError(errorMessage);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (edited && rangeEndPlayer < rangeStartPlayer) {
|
|
|
|
if (edited && rangeEndPlayer < rangeStartPlayer) {
|
|
|
|
submissionResponseElem.innerText =
|
|
|
|
submissionError("One or more ranges has an end time prior to its start time.");
|
|
|
|
"One or more ranges has an end time prior to its start time.";
|
|
|
|
|
|
|
|
submissionResponseElem.classList.value = ["submission-response-error"];
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1024,15 +1026,13 @@ async function sendVideoData(newState, overrideChanges) {
|
|
|
|
const startFieldTime = videoPlayerTimeFromVideoHumanTime(startField.value);
|
|
|
|
const startFieldTime = videoPlayerTimeFromVideoHumanTime(startField.value);
|
|
|
|
if (startFieldTime === null) {
|
|
|
|
if (startFieldTime === null) {
|
|
|
|
if (edited) {
|
|
|
|
if (edited) {
|
|
|
|
submissionResponseElem.innerText = `Unable to parse chapter start time: ${startField.value}`;
|
|
|
|
submissionError(`Unable to parse chapter start time: ${startField.value}`);
|
|
|
|
submissionResponseElem.classList.value = ["submission-response-error"];
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (startFieldTime < rangeStartPlayer || startFieldTime > rangeEndPlayer) {
|
|
|
|
if (startFieldTime < rangeStartPlayer || startFieldTime > rangeEndPlayer) {
|
|
|
|
submissionResponseElem.innerText = `The chapter at "${startField.value}" is outside its containing time range.`;
|
|
|
|
submissionError(`The chapter at "${startField.value}" is outside its containing time range.`);
|
|
|
|
submissionResponseElem.classList.value = ["submission-response-error"];
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const chapterStartTime = rangeStartInFinalVideo + startFieldTime - rangeStartPlayer;
|
|
|
|
const chapterStartTime = rangeStartInFinalVideo + startFieldTime - rangeStartPlayer;
|
|
|
@ -1051,9 +1051,7 @@ async function sendVideoData(newState, overrideChanges) {
|
|
|
|
enableChaptersElem.checked &&
|
|
|
|
enableChaptersElem.checked &&
|
|
|
|
rangeContainer.getElementsByClassName("range-definition-chapter-marker-start").length > 0
|
|
|
|
rangeContainer.getElementsByClassName("range-definition-chapter-marker-start").length > 0
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
submissionResponseElem.classList.value = ["submission-response-error"];
|
|
|
|
submissionError("Chapter markers can't be saved for ranges without valid endpoints.");
|
|
|
|
submissionResponseElem.innerText =
|
|
|
|
|
|
|
|
"Chapter markers can't be saved for ranges without valid endpoints.";
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1069,16 +1067,13 @@ async function sendVideoData(newState, overrideChanges) {
|
|
|
|
|
|
|
|
|
|
|
|
if (chaptersData.length > 0) {
|
|
|
|
if (chaptersData.length > 0) {
|
|
|
|
if (chaptersData[0].start !== 0) {
|
|
|
|
if (chaptersData[0].start !== 0) {
|
|
|
|
submissionResponseElem.innerText =
|
|
|
|
submissionError("The first chapter must start at the beginning of the video");
|
|
|
|
"The first chapter must start at the beginning of the video";
|
|
|
|
|
|
|
|
submissionResponseElem.classList.value = ["submission-response-error"];
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let lastChapterStart = 0;
|
|
|
|
let lastChapterStart = 0;
|
|
|
|
for (let chapterIndex = 1; chapterIndex < chaptersData.length; chapterIndex++) {
|
|
|
|
for (let chapterIndex = 1; chapterIndex < chaptersData.length; chapterIndex++) {
|
|
|
|
if (edited && chaptersData[chapterIndex].start - lastChapterStart < 10) {
|
|
|
|
if (edited && chaptersData[chapterIndex].start - lastChapterStart < 10) {
|
|
|
|
submissionResponseElem.innerText = "Chapters must be at least 10 seconds apart";
|
|
|
|
submissionError("Chapters must be at least 10 seconds apart");
|
|
|
|
submissionResponseElem.classList.value = ["submission-response-error"];
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lastChapterStart = chaptersData[chapterIndex].start;
|
|
|
|
lastChapterStart = chaptersData[chapterIndex].start;
|
|
|
@ -1102,8 +1097,7 @@ async function sendVideoData(newState, overrideChanges) {
|
|
|
|
document.getElementById("video-info-thumbnail-time").value,
|
|
|
|
document.getElementById("video-info-thumbnail-time").value,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
if (thumbnailTime === null) {
|
|
|
|
if (thumbnailTime === null) {
|
|
|
|
submissionResponseElem.innerText = "The thumbnail time is invalid";
|
|
|
|
submissionError("The thumbnail time is invalid");
|
|
|
|
submissionResponseElem.classList.value = ["submission-response-error"];
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1114,9 +1108,7 @@ async function sendVideoData(newState, overrideChanges) {
|
|
|
|
const fileInput = document.getElementById("video-info-thumbnail-custom");
|
|
|
|
const fileInput = document.getElementById("video-info-thumbnail-custom");
|
|
|
|
if (fileInput.files.length === 0) {
|
|
|
|
if (fileInput.files.length === 0) {
|
|
|
|
if (!videoInfo.thumbnail_image) {
|
|
|
|
if (!videoInfo.thumbnail_image) {
|
|
|
|
submissionResponseElem.innerText =
|
|
|
|
submissionError("A thumbnail file was not provided for the custom thumbnail");
|
|
|
|
"A thumbnail file was not provided for the custom thumbnail";
|
|
|
|
|
|
|
|
submissionResponseElem.classList.value = ["submission-response-error"];
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
thumbnailImage = videoInfo.thumbnail_image;
|
|
|
|
thumbnailImage = videoInfo.thumbnail_image;
|
|
|
@ -1134,14 +1126,11 @@ async function sendVideoData(newState, overrideChanges) {
|
|
|
|
await loadPromise;
|
|
|
|
await loadPromise;
|
|
|
|
const fileLoadData = fileReader.result;
|
|
|
|
const fileLoadData = fileReader.result;
|
|
|
|
if (fileLoadData.error) {
|
|
|
|
if (fileLoadData.error) {
|
|
|
|
submissionResponseElem.innerText = `An error (${fileLoadData.error.name}) occurred loading the custom thumbnail: ${fileLoadData.error.message}`;
|
|
|
|
submissionError(`An error (${fileLoadData.error.name}) occurred loading the custom thumbnail: ${fileLoadData.error.message}`);
|
|
|
|
submissionResponseElem.classList.value = ["submission-response-error"];
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fileLoadData.substring(0, 22) !== "data:image/png;base64,") {
|
|
|
|
if (fileLoadData.substring(0, 22) !== "data:image/png;base64,") {
|
|
|
|
submissionResponseElem.innerHTML =
|
|
|
|
submissionError("An error occurred converting the uploaded image to base64.");
|
|
|
|
"An error occurred converting the uploaded image to base64.";
|
|
|
|
|
|
|
|
submissionResponseElem.classList.value = ["submission-response-error"];
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
thumbnailImage = fileLoadData.substring(22);
|
|
|
|
thumbnailImage = fileLoadData.substring(22);
|
|
|
|