summaryrefslogtreecommitdiff
path: root/web/share
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2021-07-01 09:22:18 +0300
committerDevaev Maxim <[email protected]>2021-07-01 09:22:18 +0300
commit4fe20641da44e25eb394d7ce26776b7ee6ce7c10 (patch)
tree0133c3caddd3b1c1b48af11b7e7c235e21bfeb5f /web/share
parent2995ca4909b171052aebf1497580cc797cb95f19 (diff)
save video mode
Diffstat (limited to 'web/share')
-rw-r--r--web/share/js/kvm/stream.js14
-rw-r--r--web/share/js/tools.js19
2 files changed, 27 insertions, 6 deletions
diff --git a/web/share/js/kvm/stream.js b/web/share/js/kvm/stream.js
index 1596816c..272df998 100644
--- a/web/share/js/kvm/stream.js
+++ b/web/share/js/kvm/stream.js
@@ -459,6 +459,7 @@ export function Streamer() {
__janus_enabled = (enabled && supported && _Janus !== null);
tools.featureSetEnabled($("stream-mode"), __janus_enabled);
tools.info(`Stream: Janus WebRTC state: enabled=${enabled}, supported=${supported}, imported=${!!_Janus}`);
+ tools.radioClickValue("stream-mode-radio", tools.storage.get("stream.mode", "mjpeg"));
self.setState(__state);
};
if (enabled && supported) {
@@ -609,16 +610,17 @@ export function Streamer() {
var __clickModeRadio = function() {
if (_Janus !== null) {
let mode = tools.radioGetValue("stream-mode-radio");
+ tools.storage.set("stream.mode", mode);
if (mode !== __streamer.getMode()) {
setTimeout(() => tools.radioSetValue("stream-mode-radio", mode), 100);
- tools.hiddenSetVisible($("stream-image"), (mode === "mjpeg"));
- tools.hiddenSetVisible($("stream-video"), (mode !== "mjpeg"));
- if (mode === "mjpeg") {
- __streamer.stopStream();
- __streamer = new _MjpegStreamer(__setActive, __setInactive, __setInfo);
- } else { // janus
+ tools.hiddenSetVisible($("stream-image"), (mode !== "janus"));
+ tools.hiddenSetVisible($("stream-video"), (mode === "janus"));
+ if (mode === "janus") {
__streamer.stopStream();
__streamer = new _JanusStreamer(__setActive, __setInactive, __setInfo);
+ } else { // mjpeg
+ __streamer.stopStream();
+ __streamer = new _MjpegStreamer(__setActive, __setInactive, __setInfo);
}
if (wm.isWindowVisible($("stream-window"))) {
__streamer.ensureStream(__state);
diff --git a/web/share/js/tools.js b/web/share/js/tools.js
index 02c6e637..6fcacf45 100644
--- a/web/share/js/tools.js
+++ b/web/share/js/tools.js
@@ -160,6 +160,15 @@ export var tools = new function() {
el.checked = (el.value === value);
}
};
+ this.radioClickValue = function(name, value) {
+ for (let el of $$$(`input[type="radio"][name="${name}"]`)) {
+ if (el.value === value) {
+ el.click();
+ return;
+ }
+ }
+ };
+
this.progressSetValue = function(el, title, percent) {
el.setAttribute("data-label", title);
@@ -242,6 +251,16 @@ export var tools = new function() {
this.info("Browser:", this.browser);
this.https = (location.protocol === "https:");
+
+ this.storage = new function() {
+ return {
+ "get": function(key, default_value) {
+ let value = window.localStorage.getItem(key);
+ return (value !== null ? value : default_value);
+ },
+ "set": (key, value) => window.localStorage.setItem(key, value),
+ };
+ };
};
export var $ = (id) => document.getElementById(id);