$(document).ready(function() {
$("div.columba").each(function(j) {
var closure = $(this);
$(this).removeClass("hidden");
$(this).find("ul").append("
Loading events...");
var tags = $(this).find("input.tags").val();
$.getJSON("https://pssweb.manchester.ac.uk/includes/php/apps/columba/json_feed_fetcher.php?callback=?", {
"tags": tags,
"limit": 10
}, function(data) {
if (data.outcome == "error") {
$(closure).find("ul").empty().append("ERROR: " + data.message + "");
}
if (data.outcome == "success") {
$(closure).find("ul").empty();
if (data.result.events.length == 0) {
$(closure).find("ul").append("No events at the moment");
} else {
for (var i = 0; i < data.result.events.length; i++) {
$(closure).find("ul").append("");
$(closure).find("ul").children("li:last").children("h5").text(data.result.events[i].title);
$(closure).find("ul").children("li:last").children("div.datetime").addClass("date").text(data.result.events[i].prettytime);
$(closure).find("ul").children("li:last").children("p").text(data.result.events[i].description);
$(closure).find("ul").children("li:last").children("h5").wrapInner("");
$(closure).find("ul").children("li:last").children("h5").children("a").attr("href", "http://events.manchester.ac.uk/event/" + data.result.events[i].id);
if (i > 2) $(closure).find("ul").children("li:last").addClass("post3");
}
$(closure).find("ul").append("");
$(closure).find("li.more").children("h5").children("a").attr("href", data.result.more);
}
}
});
});
});