I have a tweeter feed. The feed shows a small div
with some animation, first it checks if the div
display
property its :none
if so, it toggles the visibility and writes some info from a a json file. But, If its display: block
it hides the 'div'.
Now I want to change the 'delay' value for 'setInterval' using the 'if' 'else' inside the function. But I can't get to change it?
$(document).ready(function() {
$.ajaxSetup({ cache: false });
var delay = 2000;
setInterval(function() {
var isVisible = $('#container').css("display") == "none";
if(isVisible) {
delay = 10000;
$("#container").toggle( "clip", "slow" );
$.getJSON('data.json', function (data) {
document.getElementById("user").innerHTML = "<h1>@"
+ data.user.screen_name + "</h1>";
});
}
else {
delay = 1000;
$("#container").toggle( "clip", "slow" );
}
}, delay );
});
Thanks!