mjpeg-player: simplified main.js's load function

This commit is contained in:
Trek H 2020-01-28 14:26:06 +10:30
parent 09c254e1f0
commit fd5425659d
1 changed files with 3 additions and 14 deletions

View File

@ -42,10 +42,10 @@ init();
function load() {
let url = document.getElementById('url').value;
if (url == "") {
url = getQuery()
// Get everything following the ? from the browser's URL bar.
url = window.location.search.slice(1);
document.getElementById('url').value = url;
}
if (url[0] == '/') {
} else if (url[0] == '/') {
url = window.location.protocol + '//' + window.location.host + url;
}
if (url == "") {
@ -56,17 +56,6 @@ function load() {
hls.loadSource(url, append);
}
// getQuery gets everything after the question mark from the URL in the browser's URL bar.
function getQuery() {
let regex = new RegExp("\\?(.*)");
let match = regex.exec(window.location.href);
if (match == null) {
return '';
} else {
return decodeURIComponent(match[1].replace(/\+/g, " "));
}
}
// append, on the first call, starts a player worker and passes it a frame rate and the video data,
// on subsequent calls it passes the video data to the player worker.
function append(data) {