From 63aaf76f0d58105bcfe8eae1a16e63cfc4150110 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 25 Feb 2020 12:13:05 -0500 Subject: [PATCH] handle a 0 value for scale as the scale to fit value --- web/skins/classic/views/js/montage.js | 31 ++++++++++++++++++++------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/web/skins/classic/views/js/montage.js b/web/skins/classic/views/js/montage.js index 68a2acf2c..b88833db0 100644 --- a/web/skins/classic/views/js/montage.js +++ b/web/skins/classic/views/js/montage.js @@ -334,7 +334,7 @@ function changeScale() { Cookie.write('zmMontageScale', scale, {duration: 10*365}); Cookie.write('zmMontageWidth', '', {duration: 10*365}); Cookie.write('zmMontageHeight', '', {duration: 10*365}); - if ( !scale ) { + if ( scale == '' ) { selectLayout('#zmMontageLayout'); return; } @@ -349,8 +349,12 @@ function changeScale() { console.log("Error finding frame for " + monitor.id); continue; } - if ( newWidth ) { - monitor_frame.css('width', newWidth); + if ( scale != '0' ) { + if ( newWidth ) { + monitor_frame.css('width', newWidth); + } + } else { + monitor_frame.css('width', '100%'); } // We don't set the frame height because it has the status bar as well //if ( height ) { @@ -364,13 +368,24 @@ function changeScale() { streamImg.src = ''; //src = src.replace(/rand=\d+/i,'rand='+Math.floor((Math.random() * 1000000) )); - src = src.replace(/scale=[\.\d]+/i, 'scale='+scale); - src = src.replace(/width=[\.\d]+/i, 'width='+newWidth); - src = src.replace(/height=[\.\d]+/i, 'height='+newHeight); + if ( scale != '0' ) { + src = src.replace(/scale=[\.\d]+/i, 'scale='+scale); + src = src.replace(/width=[\.\d]+/i, 'width='+newWidth); + src = src.replace(/height=[\.\d]+/i, 'height='+newHeight); + } else { + src = src.replace(/scale=[\.\d]+/i, 'scale=100'); + src = src.replace(/width=[\.\d]+/i, 'width='+monitorData[i].width); + src = src.replace(/height=[\.\d]+/i, 'height='+monitorData[i].height); + } streamImg.src = src; } - streamImg.style.width = newWidth + "px"; - streamImg.style.height = newHeight + "px"; + if ( scale != '0' ) { + streamImg.style.width = newWidth + "px"; + streamImg.style.height = newHeight + "px"; + } else { + streamImg.style.width = '100%'; + streamImg.style.height = 'auto'; + } } } }