Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

control.html fixes #92

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions html/control.html
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,10 @@ <h1>Release</h1>

<script>
document.addEventListener('DOMContentLoaded', function (event) {
var streamURL = 'stream';
var snapshotURL = 'snapshot';
var webrtcURL = 'webrtc';
const streamURL = 'stream';
const snapshotURL = 'snapshot';
const webrtcURL = 'webrtc';
const baseURL = '';

const header = document.getElementById('logo')
const settings = document.getElementById('sidebar')
Expand Down Expand Up @@ -539,7 +540,7 @@ <h1>Release</h1>
key = encodeURIComponent(key);
value = encodeURIComponent(value);

return fetch(`option?device=${device}&key=${key}&value=${value}`, {
return fetch(`${baseURL}option?device=${device}&key=${key}&value=${value}`, {
method: 'POST'
}).then(function (response) {
return response
Expand All @@ -554,7 +555,7 @@ <h1>Release</h1>
}

const createDeviceOption = (device, key, option) => {
const id_key = `${device}_${key}`;
const id_key = `${device.name}_${key}`;
const groupEl = insertControl("div");
groupEl.className = "input-group";

Expand Down Expand Up @@ -603,7 +604,7 @@ <h1>Release</h1>
selectEl.add(optionEl);
}

for (var value in option.menu) {
for (let value in option.menu) {
const optionEl = document.createElement("option");
optionEl.value = value;
optionEl.text = option.menu[value];
Expand Down Expand Up @@ -695,24 +696,24 @@ <h1>Release</h1>
}

const createControls = (state) => {
for (var device of state.devices) {
for (let device of state.devices) {
const heading = insertControl("h1");
heading.textContent = device.name;

for (var key in device.options) {
for (let key in device.options) {
createDeviceOption(device, key, device.options[key]);
}
}
};

var rtcPeerConfig = {
const rtcPeerConfig = {
sdpSemantics: 'unified-plan'
};

rtcPeerConnection = new RTCPeerConnection(rtcPeerConfig);
let rtcPeerConnection = new RTCPeerConnection(rtcPeerConfig);

// read initial values
fetch(`status`)
fetch(`${baseURL}status`)
.then(function (response) {
return response.json()
})
Expand Down Expand Up @@ -757,7 +758,7 @@ <h1>Release</h1>
{ urls: ['stun:stun.l.google.com:19302'] }
];

fetch(webrtcURL, {
fetch(baseURL + webrtcURL, {
body: JSON.stringify({type: 'request', iceServers: iceServers}),
headers: {'Content-Type': 'application/json'},
method: 'POST'
Expand All @@ -780,7 +781,7 @@ <h1>Release</h1>
});
rtcPeerConnection.addEventListener("icecandidate", function(e) {
if (e.candidate) {
return fetch(webrtcURL, {
return fetch(baseURL + webrtcURL, {
body: JSON.stringify({
type: 'remote_candidate',
id: rtcPeerConnection.remote_pc_id,
Expand All @@ -800,9 +801,9 @@ <h1>Release</h1>
}).then(function(answer) {
return rtcPeerConnection.setLocalDescription(answer);
}).then(function(answer) {
var offer = rtcPeerConnection.localDescription;
const offer = rtcPeerConnection.localDescription;

return fetch(webrtcURL, {
return fetch(baseURL + webrtcURL, {
body: JSON.stringify({
type: offer.type,
id: rtcPeerConnection.remote_pc_id,
Expand Down