Misc little changes, fix up the date and time handling, auto select latest date if no date selected. add Vega

This commit is contained in:
Joe Tretter
2020-04-25 20:56:09 -05:00
parent b5f71423b3
commit 17d89d34e3
3 changed files with 47 additions and 17 deletions

View File

@@ -10,7 +10,7 @@ let createMasterFilterFrame=()=>{
<div id='datePicker'></div>
<div class="dropdown" id="grpSymbol">
<button class="btn btn-secondary dropdown-toggle ddMnuBtn" type="button" id="ddMnuBtnSymbol" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<button class="btn btn-primary dropdown-toggle ddMnuBtn" type="button" id="ddMnuBtnSymbol" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Symbol
</button>
<div class="dropdown-menu" aria-labelledby="ddMnuBtnSymbol" id='lbSymbol'>
@@ -19,7 +19,7 @@ let createMasterFilterFrame=()=>{
</div>
<div class="dropdown" id="grpTime">
<button class="btn btn-secondary dropdown-toggle ddMnuBtn" type="button" id="ddMnuBtnTime" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<button class="btn btn-primary dropdown-toggle ddMnuBtn" type="button" id="ddMnuBtnTime" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Time
</button>
<div class="dropdown-menu" aria-labelledby="ddMnuBtnTime" id='lbTime'>
@@ -76,6 +76,7 @@ let symbolChanged=(newSymbol)=>{
filterContext.theSymbol=newSymbol
document.title=getCurrentSymbol();
$("#tbSymbol").text(getCurrentSymbol());
getAvailDatesForSymbol(getCurrentSymbol()).done(_=>{
$("#datePicker").datepicker('destroy');
$("#datePicker").datepicker({beforeShowDay:beforeShowDay})
@@ -86,7 +87,15 @@ let symbolChanged=(newSymbol)=>{
showTimesForDay(filterContext.theDate);
}
});
$("#datePicker").datepicker('setDate',new Date(filterContext.theDate));
if (filterContext.theDate === undefined) {
console.log("no date in contest, setting date to the last in chain.");
filterContext.theDate=filterContext.availableDates[filterContext.availableDates.length-1].Date;
}
currentTZDate = new Date(Date.parse("2020-04-23") + new Date().getTimezoneOffset()*60000);
console.log("setting datepicker date to ", filterContext.theDate, currentTZDate);
$("#datePicker").datepicker('setDate',currentTZDate);
});
}
@@ -95,8 +104,9 @@ let timeChanged=(newTime)=>{
filterContext.selectedTime=newTime;
$("#tbSelectedTime").text(newTime);
console.log("Time changed", newTime);
requestOptionChain();
}
requestOptionChain();
}
let requestOptionChain=()=>{
@@ -121,13 +131,18 @@ let showTimesForDay=()=>{
allTimes = availableTimes;
for (let i=0;i<allTimes.length;i++){
theTime=allTimes[i].Time;
let selectedFlag="";
if (i==4) {
// select the 4th time in the day... that's usually around 9:30
timeChanged(theTime);
}
if (filterContext.selectedTime !== undefined) {
if (filterContext.selectedTime.substring(0,4) === theTime.substring(0,4)){
timeChanged(theTime);
}
} else {
if (i==4) {
// select the 4th time in the day... that's usually around 9:30
timeChanged(theTime);
}
}
//lbTime.append($(`<option ${selectedFlag}>${theTime}</option>`))
lbTime.append($(`<button onclick="timeChanged('${theTime}');" class="dropdown-item" type="button">${theTime}</button>`))
lbTime.append($(`<button onclick="timeChanged('${theTime}');" class="dropdown-item" type="button">${theTime.substring(0,5)}</button>`))
}
$("#lbTime").change();