refactoring

This commit is contained in:
Devaev Maxim 2021-04-03 10:41:07 +03:00
parent 26cc73ab8a
commit b4b98583d4

View File

@ -33,7 +33,6 @@ export function Streamer() {
/************************************************************************/ /************************************************************************/
var __resolution = {width: 640, height: 480}; var __resolution = {width: 640, height: 480};
var __resolution_str = "640x480";
var __size_factor = 1; var __size_factor = 1;
@ -107,12 +106,9 @@ export function Streamer() {
} }
} }
if ( let resolution_str = __makeStringResolution(state.streamer.source.resolution);
__resolution.width !== state.streamer.source.resolution.width if (__makeStringResolution(__resolution) != resolution_str) {
|| __resolution.height !== state.streamer.source.resolution.height
) {
__resolution = state.streamer.source.resolution; __resolution = state.streamer.source.resolution;
__resolution_str = `${__resolution.width}x${__resolution.height}`;
if ($("stream-auto-resize-switch").checked) { if ($("stream-auto-resize-switch").checked) {
__adjustSizeFactor(); __adjustSizeFactor();
} else { } else {
@ -126,13 +122,13 @@ export function Streamer() {
for (let variant of state.limits.available_resolutions) { for (let variant of state.limits.available_resolutions) {
resolutions_html += `<option value="${variant}">${variant}</option>`; resolutions_html += `<option value="${variant}">${variant}</option>`;
} }
if (!state.limits.available_resolutions.includes(__resolution_str)) { if (!state.limits.available_resolutions.includes(resolution_str)) {
resolutions_html += `<option value="${__resolution_str}">${__resolution_str}</option>`; resolutions_html += `<option value="${resolution_str}">${resolution_str}</option>`;
} }
$("stream-resolution-selector").innerHTML = resolutions_html; $("stream-resolution-selector").innerHTML = resolutions_html;
$("stream-resolution-selector").resolutions = state.limits.available_resolutions; $("stream-resolution-selector").resolutions = state.limits.available_resolutions;
} }
document.querySelector(`#stream-resolution-selector [value="${__resolution_str}"]`).selected = true; document.querySelector(`#stream-resolution-selector [value="${resolution_str}"]`).selected = true;
wm.setElementEnabled($("stream-resolution-selector"), true); wm.setElementEnabled($("stream-resolution-selector"), true);
} }
@ -214,7 +210,7 @@ export function Streamer() {
if (!online) { if (!online) {
title += "no signal / "; title += "no signal / ";
} }
title += __resolution_str; title += __makeStringResolution(__resolution);
if (__client_fps >= 0) { if (__client_fps >= 0) {
title += ` / ${__client_fps} fps`; title += ` / ${__client_fps} fps`;
} }
@ -301,5 +297,9 @@ export function Streamer() {
wm.showWindow($("stream-window"), false); wm.showWindow($("stream-window"), false);
}; };
var __makeStringResolution = function(resolution) {
return `${resolution.width}x${resolution.height}`;
};
__init__(); __init__();
} }