Installation
- Add jQuery
- Add now_open.js
- Initialize
Usage
-
week:
An array with each time of the week to show as open. The key of each value is the time of the week, from 0 (sunday) to 6 (saturday).
The key is followed by an array of the open and close times.
For minutes, use decimals. For example, 6:30 would be 6.5, 22:15 would be 22.25 and so on.
Default: Monday to Friday, 8:30 to 17:00
-
excludes:
Is an array of hollydays or other specific dates of the year to exclude, each one in the form of [month, year].
The month is an integer from 1 to 12.
Default: none
-
callback:
The callback function is called with two parameters:
the original element the function was called from,
and the current open/close status as a boolean.
Default: none
var myWeek = [
{'1':[8.5,20]},
{'2':[8.5,20]},
{'3':[8.5,20]},
{'4':[8.5,20]},
{'5':[8.5,20]},
{'6':[10,20]}
];
var myExcludes = [
[1,1],
[1,6]
];
// Initialize plugin
var autocomplete1 = $('#open_div').now_open({
week: myWeek,
excludes: myExcludes,
callback: myCallback
});
// Callback
function myCallback(element, isOpen){
if(isOpen){
element.text('We are open... call us!');
} else {
element.text('We are not open');
}
}
More options
-
latency:
Yo may want to keep checking for the open status. For that, pass the interval of minutes as a integer.
Default: 1
-
currentDate:
You also may want to force a date instead of using the actual current time, mostly for testing purposes. Pass any valid date format.
Default: false
var autocomplete1 = $('#open_div').now_open({
week: myWeek,
excludes: myExcludes,
callback: myCallback,
latency: false,
currentDate: "January 1, 2017 11:00:00" // New year, close
});
var autocomplete1 = $('#open_div').now_open({
week: myWeek,
excludes: myExcludes,
callback: myCallback,
latency: 1,
currentDate: "January 8, 2017 11:00:00" // Monday, open
});