var urlTimeline = "/api/1.0/events/future";

function showTimeline(timelineElement) {
    $(timelineElement).empty();
    getFromRest(urlTimeline, function (eventList) {
        eventList.forEach(function (event, index) {
            var date = new Date(event.executeDate);
            var formated_date = date.toLocaleDateString();

            $(timelineElement).append("<li class='" + eventInverted(index) + "'>" +
                "<div class=\"timeline-image\"><h4><br/>" + formated_date + "</h4></div>" +
                "<div class=\"timeline-panel\">" +
                "<div class=\"timeline-heading\">" +
                "<h4>" + event.title + "</h4>" +
                "</div>" +
                "<div class=\"timeline-body\">" +
                "<p class=\"text-muted\">" + event.description + "</p>" +
                "</div>" +
                "</div>" +
                "</li>");
        });
    });
}

function eventInverted(index) {
    return index % 2 == 1 ? "timeline-inverted" : "";
}