From af9a6a8a6edbe5fcfaf24157994393361083c257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 11 Aug 2014 22:25:09 +0200 Subject: [PATCH] Don't overwrite query string of webcam URI If there's a query already present, just append the timestamp to it with a & in between instead of creating a new query. (cherry picked from commit 51c77be) --- src/octoprint/static/js/app/main.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/octoprint/static/js/app/main.js b/src/octoprint/static/js/app/main.js index 450d1e26..6f297fce 100644 --- a/src/octoprint/static/js/app/main.js +++ b/src/octoprint/static/js/app/main.js @@ -361,7 +361,15 @@ $(function() { var webcamImage = $("#webcam_image"); var currentSrc = webcamImage.attr("src"); if (currentSrc === undefined || currentSrc.trim() == "") { - webcamImage.attr("src", CONFIG_WEBCAM_STREAM + "?" + new Date().getTime()); + var newSrc = CONFIG_WEBCAM_STREAM; + if (CONFIG_WEBCAM_STREAM.lastIndexOf("?") > -1) { + newSrc += "&"; + } else { + newSrc += "?"; + } + newSrc += new Date().getTime(); + + webcamImage.attr("src", newSrc); } } else if (previous.hash == "#control") { // only disable webcam stream if tab is out of focus for more than 5s, otherwise we might cause