fix time presetting algorithm
This commit is contained in:
@@ -126,8 +126,9 @@ let createMasterFilterFrame=()=>{
|
||||
}
|
||||
|
||||
me.timeChanged=(newTime)=>{
|
||||
if (_filterContext.selectedTime!==newTime){
|
||||
if ((_filterContext.selectedTime!==newTime) || (_filterContext.theDateOfTime!==_filterContext.theDate)) {
|
||||
_filterContext.selectedTime=newTime;
|
||||
_filterContext.theDateOfTime=_filterContext.theDate;
|
||||
$("#tbSelectedTime").text(newTime);
|
||||
console.log("Time changed", newTime);
|
||||
}
|
||||
@@ -158,22 +159,26 @@ let createMasterFilterFrame=()=>{
|
||||
let lbTime=$("#lbTime");
|
||||
lbTime.empty();
|
||||
allTimes = availableTimes;
|
||||
let presetTime=undefined;
|
||||
for (let i=0;i<allTimes.length;i++){
|
||||
theTime=allTimes[i].Time;
|
||||
if (_filterContext.selectedTime !== undefined) {
|
||||
if (_filterContext.selectedTime.substring(0,4) === theTime.substring(0,4)){
|
||||
me.timeChanged(theTime);
|
||||
if (presetTime===undefined) { // emergency fallback, if nothing else fits fall back to first time seen.
|
||||
presetTime = theTime;
|
||||
}
|
||||
if (_filterContext.selectedTime !== undefined) { // try to stay at the same time
|
||||
if (_filterContext.selectedTime.substring(0,4) >= theTime.substring(0,4)){
|
||||
presetTime = theTime;
|
||||
}
|
||||
} else {
|
||||
if (i==4) {
|
||||
if (i==4) { // this is usually upon open - initializing the selected time...
|
||||
// select the 4th time in the day... that's usually around 9:30
|
||||
me.timeChanged(theTime);
|
||||
presetTime = theTime;
|
||||
}
|
||||
}
|
||||
//lbTime.append($(`<option ${selectedFlag}>${theTime}</option>`))
|
||||
lbTime.append($(`<button onclick="myMasterFilter.timeChanged('${theTime}');" class="dropdown-item" type="button">${theTime.substring(0,5)}</button>`))
|
||||
|
||||
}
|
||||
me.timeChanged(presetTime);
|
||||
$("#lbTime").change();
|
||||
$("#spinner-time").hide();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user