I've recently been going through some of the code used through my site, one of them being a "News Slider" which shows some of the latest news articles. The code is using javascript at the moment, however I would like to know how the best way would be of converting it to jquery.
The code is as follows:
var PromoSlideShow = function () {
var b = [];
var f = 0;
var e = false;
var a = false;
var d = function (g) {
if (!e && !a && f != g) {
a = true;
Effect.Fade(b[f], {
duration: 0.8,
from: 1,
to: 0
});
f = g;
if (f >= b.length || f <= -1) {
f = 0
}
Effect.Appear(b[f], {
duration: 0.8,
from: 0,
to: 1,
afterFinish: function () {
a = false
}
});
c(f)
}
};
var c = function (g) {
$$("#promo-bullets a").each(function (h) {
h.removeClassName("active")
});
$$("#promo-bullets a")[g].addClassName("active")
};
return {
init: function () {
b = $$("#promo-box .promo-container");
if (b.length < 2) {
return
}
if ($("promo-bullets")) {
$("promo-bullets").insert('<a href="#" class="active">0</a>');
for (var g = 1; g < b.length; g++) {
$("promo-bullets").insert('<a href="#">' + g + "</a>")
}
$$("#promo-bullets a").each(function (i) {
i.observe("click", function (j) {
Event.stop(j);
e = false;
d(parseInt(j.target.innerHTML, 10));
e = true
})
})
}
var h = 6000;
setInterval(function () {
d(f + 1)
}, h)
}
}
}();
Thanks in advance! :)