@cryptotaxi247 / netdata-1 / commits / 2f9429c15

added url query options to allow sharing specific timeframes

Costa Tsaousis (ktsaou) committed Apr 10, 2016 at 05:56 UTC 2f9429c15e7d8b5e390c249eb9e83baa60a42045
1 file changed +22
web/index.html
+22
@@ -1781,6 +1781,21 @@ function notifyForUpdate(force) {
1781
1782 // ----------------------------------------------------------------------------
1783
1784 +function getUrlParameter(sParam) {
1785 + var sPageURL = decodeURIComponent(window.location.search.substring(1)),
1786 + sURLVariables = sPageURL.split('&'),
1787 + sParameterName,
1788 + i;
1789 +
1790 + for (i = 0; i < sURLVariables.length; i++) {
1791 + sParameterName = sURLVariables[i].split('=');
1792 +
1793 + if (sParameterName[0] === sParam) {
1794 + return sParameterName[1] === undefined ? true : sParameterName[1];
1795 + }
1796 + }
1797 +}
1798 +
1799 function finalizePage() {
1800 // resize all charts - without starting the background thread
1801 // this has to be done while NETDATA is paused
@@ -1788,6 +1803,13 @@ function finalizePage() {
1803 // the Dom elements are initially zero-sized
1804 NETDATA.parseDom();
1805
1806 + var before = 0, after = 0;
1807 + after = getUrlParameter('force_after_ms');
1808 + before = getUrlParameter('force_before_ms');
1809 +
1810 + if(before > 0 && after > 0)
1811 + NETDATA.globalPanAndZoom.setMaster(NETDATA.options.targets[0], after, before);
1812 +
1813 // let it run (update the charts)
1814 NETDATA.unpause();
1815