From 272b0117b6a5ec715d9e999fa772eb91249ba88f Mon Sep 17 00:00:00 2001 From: Joerg Lehmann Date: Sat, 31 Oct 2020 11:11:20 +0100 Subject: [PATCH] change url when changing property --- static/js/graph.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/static/js/graph.js b/static/js/graph.js index 63881b5..32c9ff3 100644 --- a/static/js/graph.js +++ b/static/js/graph.js @@ -7,6 +7,17 @@ $(function() { console.log("XXX: "+start.format()); + function change_property(new_property) { + if (new_property != property) { + property = new_property; + + if (history.pushState) { + var newurl = window.location.href.replace(/property=./,'property='+new_property); + window.history.pushState({path:newurl},'',newurl); + } + } + } + function cb(start, end) { $('#reportrange span').html(start.locale('de').format('D. MMM YYYY') + ' - ' + end.locale('de').format('D. MMM YYYY')); console.log("A new date selection was made: " + start.format() + ' to ' + end.format()); @@ -17,27 +28,27 @@ $(function() { } $('#btn_w').on("click", function() { - property = 'w'; + change_property('w'); drawGraph(deveui, alias, property, s_start, s_end, false); }); $('#btn_t').on("click", function() { - property = 't'; + change_property('t'); drawGraph(deveui, alias, property, s_start, s_end, false); }); $('#btn_h').on("click", function() { - property = 'h'; + change_property('h'); drawGraph(deveui, alias, property, s_start, s_end, false); }); $('#btn_p').on("click", function() { - property = 'p'; + change_property('p'); drawGraph(deveui, alias, property, s_start, s_end, false); }); $('#btn_vp').on("click", function() { - property = 'vp'; + change_property('vp'); drawGraph(deveui, alias, property, s_start, s_end, false); });