Implemented time jump (same effect with both buttons

This commit is contained in:
l_samenv
2024-08-12 13:17:00 +02:00
parent 81d9d233a8
commit 58d44dd4d7

View File

@ -193,19 +193,6 @@ function strFormat(val, significant_digits=13) {
return evalue; return evalue;
} }
let dummyCallback = function(){
console.log("Dummy callback called");
}
function dummyJumpCallback(dateTimestampMs, timeValueMs, mode){
console.log("Date is : ");
console.log(dateTimestampMs);
console.log("Time is : ");
console.log(timeValueMs);
console.log("Mode is :");
console.log(mode);
}
// Defining keys for global controls // Defining keys for global controls
let xyKey = "xy-control"; let xyKey = "xy-control";
@ -243,7 +230,7 @@ let globalIndicators = (function (){
function loadIndicators(panel){ function loadIndicators(panel){
let leftDate = Date.now() - 30*60*1000; let leftDate = Date.now() - 30*60*1000;
let datesIndicator = new DateIndicator(leftDate, () => {graphs.gotoNow();}, dummyJumpCallback); let datesIndicator = new DateIndicator(leftDate, graphs.gotoNow, graphs.jumpToDate);
panel.appendChild(datesIndicator); panel.appendChild(datesIndicator);
datesIndicator.style.marginLeft = "auto"; datesIndicator.style.marginLeft = "auto";
@ -815,6 +802,14 @@ let graphs = (function (){
function setResolution(timeDelta){ function setResolution(timeDelta){
resolution = Math.ceil((timeDelta / container.getBoundingClientRect().width)/1000) resolution = Math.ceil((timeDelta / container.getBoundingClientRect().width)/1000)
} }
function jumpToDate(dateTimestampMs, timeValueMs, mode){
let msLeftTimestamp = dateTimestampMs + timeValueMs;
let msRightTimestamp = msLeftTimestamp + 24*60*60*1000;
if (liveMode && msRightTimestamp < lastTime) setLiveMode(false);
setMinMax(msLeftTimestamp, msRightTimestamp);
updateAuto();
}
function shiftOlder(){ function shiftOlder(){
@ -1265,6 +1260,7 @@ let graphs = (function (){
zoomIn: zoomIn, zoomIn: zoomIn,
shiftOlder: shiftOlder, shiftOlder: shiftOlder,
shiftNewer: shiftNewer, shiftNewer: shiftNewer,
jumpToDate: jumpToDate,
} }
})(); })();