How can I insert tomorrow's day's startTime and endTime into the content message for the setupOrderingNotAvailable function if today's day has an endTime that has expired? Right now the message setupOrderingNotAvailable says "...again tomorrow from 11:00am to 9:00pm" but that is not true for every day; this is where I would like to insert tomorrow's times.
Code
var days = {
'1': {startTime: '4:00 PM', endTime: '8:00 PM'},
'2': {startTime: '11:00 AM', endTime: '9:00 PM'},
'3': {startTime: '11:00 AM', endTime: '9:00 PM'},
'4': {startTime: '11:00 AM', endTime: '4:00 PM'},
'5': {startTime: '11:00 AM', endTime: '10:00 PM'},
'6': {startTime: '12:00 PM', endTime: '10:00 PM'},
'7': {startTime: '12:00 PM', endTime: '8:00 PM'},
};
var curr_day = new Date().getDay();
var curr_time = getval();
var orderIsAvailable = false;
var day = days[curr_day];
//
function setupOrderingAvailable() {
document.querySelector('#alert-success').onclick = function() {
$.sweetModal({
content: '<h2>Online Ordering is Available!</h2>' +
'Please click the button below to begin your online order.' +
'<div class="sweet-modal-buttons"><a href="http://pizzospizzeria.hungerrush.com" target="_blank" class="button greenB">Start Order</a></div>',
// icon: $.sweetModal.ICON_SUCCESS
});
};
}
// Need to make this a function that inserts tomorrows startTime and endTime into message if todays endTime has passed
function setupOrderingNotAvailable() {
document.querySelector('#alert-success').onclick = function() {
$.sweetModal({
content: '<h2>Online Ordering is Not Available</h2>' +
'Online ordering will be available again tomorrow from 11:00am to 9:00pm',
buttons: [{
label: 'Close',
classes: 'redB'
}]
});
};
}
if (day) {
if (get24Hr(curr_time) > get24Hr(day.startTime) && get24Hr(curr_time) < get24Hr(day.endTime)) {
orderingIsAvailable = true;
} else {
document.querySelector('#alert-success').onclick = function() {
$.sweetModal({
content: '<h2>Online Ordering is Not Available</h2>' +
'Online ordering will be available again tomorrow from 11:00am to 9:00pm',
buttons: [{
label: 'Close',
classes: 'redB'
}]
});
}
}
}
if (orderingIsAvailable) {
setupOrderingAvailable();
} else {
setupOrderingNotAvailable();
}
dayand concatenate then into the message. Are you not sure how to combine strings?dayby usingnew Date().getDay(), so tomorrow'sdaywould usenew Date().getDay() + 1, right?