Unite/Revolution Slider API/Cookie

Home Forums Support Unite/Revolution Slider API/Cookie


Okay so this is kind of complicated – hope you can help.

I’ve got a slideshow that plays when my site loads – the first slide is a 10-second video that my wife insists be on the site even though I’m not a fan. I don’t like it because if you click on a link that’s a new page in the same window, then hit the “back” button, he damn video plays again. It’s only 10 seconds, but it’s irritating. Plus Google “fixed” Chrome so that it won’t autoplay any video with sound…but that’s another discussion.

Figured I’d use cookies and the API to have it check to see if the page had been visited that day and if so, to move on to slide 2, which is just an image.

I have the Javascript for cookies working (using cookies.js from GitHub – https://github.com/madmurphy/cookies.js) I can set and read the cookies and manipulate text and alerts/popups based on whether the cookie is set or not. And I am doing all of the setting/reading *inside* the “Custom Javascript” window of the slider. So I know it’s working from there.

It listens for the slider to load, then checks the cookie value. If the cookie exists, it’s supposed to go to slide 2 – which is the image. If the cookie value is “null” then it plays slide 1 and loads the cookie.

Here is the code:

// listen for when the slider initially loads
revapi20.bind(‘revolution.slide.onloaded’, function() {
console.log(‘Slider Loaded’);
// check cookie
var visited = docCookies.getItem(“visited”);
if (visited == null) {
// cookie is empty
console.log(‘value is null’);
revapi20.revshowslide(1);
console.log(‘SETTING COOKIE’);
docCookies.setItem(“visited”, “affirmative”, 31536e3);
//yes, I know that expire time is a year – It’s that way only for testing. I plan to reduce it to 30 minutes once it’s working
} else {
// cookie has content
revapi20.revshowslide(2);
console.log(‘value is affirmative’);
}
});

What I get is the console content based on the cookies. In other words, on first load, console reports “Slider Loaded” – the cookie is null of course so the console log will report “cookie is null” then “SETTING COOKIE” – and I can see in the developer console that the cookie doesn’t exist – and the first slide plays. Upon refresh, I see “Slider Loaded” then “value is affirmative” and then slide 1 plays. So it’s working through the script, but the API calls are failing.

I even went back and removed all the script down to this:

revapi20.bind(‘revolution.slide.onloaded’, function() {
console.log(‘Slider Loaded’);
revapi20.revkill();
});

Funny thing about that is the slider disappears – you can’t see it – but you can *hear* the audio from the video… None of the other API calls seem to have any effect at all. It won’t pause, or return any other info. I’ve tried it with Jquery enable and disabled – no change in behavior.

I understand I’m probably doing something wrong, but I’m not sure what it is.

Any assistance appreciated.

Thanks!

Tim



Yeah I was afraid you were going to say that 🙂

I was hoping though, LOL

You must be logged in to reply to this topic.