From a71002d20c2b229727a93435506eb2578dd431af Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Sat, 26 Oct 2013 18:58:58 +0300 Subject: [PATCH] adapted cache prevention query argument for current snapshot --- doc/todo.txt | 2 -- static/js/main.js | 11 ++++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/todo.txt b/doc/todo.txt index 07de28b..32515b7 100644 --- a/doc/todo.txt +++ b/doc/todo.txt @@ -1,6 +1,4 @@ -> add an autoupdate mechanism --> cache jpegs from remote cameras locally --> cache prevention query arg should be according to the refresh rate -> the camera is not available on page load, it is never shown afterwards - increase the timeout -> click to zoom on cameras -> make camera frames positions configurable diff --git a/static/js/main.js b/static/js/main.js index 2c041ef..ab6e94d 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -1323,8 +1323,13 @@ function refreshCameraFrames() { return; } - function refreshCameraFrame(cameraId, img) { - img.src = '/snapshot/' + cameraId + '/current/?_=' + new Date().getTime(); + function refreshCameraFrame(cameraId, img, fast) { + var timestamp = new Date().getTime(); + if (!fast) { + timestamp /= 500; + } + timestamp = Math.round(timestamp); + img.src = '/snapshot/' + cameraId + '/current/?_=' + timestamp; } var cameraFrames = $('div.page-container').find('div.camera-frame'); @@ -1343,7 +1348,7 @@ function refreshCameraFrames() { } else { var cameraId = this.id.substring(6); - refreshCameraFrame(cameraId, img); + refreshCameraFrame(cameraId, img, count <= 2); /* count <= 2 means at least 5 fps */ this.refreshDivider = 0; } -- 2.39.5