I came across this code snippet on a website and I'm curious about its function and purpose. While I'm familiar with PHP, HTML, CSS, and JavaScript, I haven't had the chance to learn JQUERY and AJAX yet. Specifically, I'm interested in understanding how the colors array is populated - is it random or does it follow a specific pattern?
$('#onehour_next').css('backgroundColor', colors[(hours == 23 ? 0 : hours+1)]);
function doStuff()
{
current = new Date();
hours = current.getHours();
minutes = 59 - current.getMinutes();
seconds = 59 - current.getSeconds();
onehour.innerHTML = prettyTime(0, minutes, seconds);
if (colors.length === 0 || current.getSeconds() === 0)
init();
$('#onehour').css('backgroundColor', colors[hours]);
$('#onehour_next').css('backgroundColor', colors[(hours == 23 ? 0 : hours+1)]);
setTimeout(doStuff, 1000);
}