I have a surprisingly simple cap frequnecy cookie for a jQuery slide. I am not using the jQuery cookie plugin which doesn’t have a shorter unit than one day anyways.
I have tried everything my limited JS skills allow but get errors and even worse a disruption of my slide function. My working oneDay cookie slide toggle function
$(document).ready(function() {
initSlideboxes();
function initSlideboxes()
{
if(!document.cookie.match("slidedToday")){
var oneDay = new Date();
oneDay.setDate(oneDay.getDate()+1);
document.cookie="slidedToday=true;path=/;expires="+oneDay.toGMTString();
$('#slidebar').slideDown(1000);
setTimeout(function() {$('#slidebar').slideUp(10);}, 5000);
}
$('#slidebartrigger').click(function(){$
('#slidebar').slideToggle(); });
};
});
A JS programmer suggested I try the following but it didn’t work because I can’t figure out what to put in place of oneDay
if(!document.cookie.match("slidedToday")){
var currentDate = new Date();
var startDate = new Date( currentDate.getYear(), currentDate.getMonth(), currentDate.getDate(), currentDate.getHours()+1, currentDate.getMinutes(), currentDate.getSeconds());
document.cookie="slidedToday=true;path=/;expires="+oneHour.toGMTString();
Error is oneHour is undefined, I tried a couple different things like 3600 but I get syntax errors or “,” expected but I don’t have the math head ability to understand what I should try next. The fact that oneDay works makes me wonder what is in http://code.jquery.com/jquery-latest.pack.js that knows what oneDay is.