Created
September 29, 2015 13:41
-
-
Save doivosevic/8d2de0c20d726cdc0423 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getProjectsTasksTicketsJobTypesLoccosEvents() { | |
console.log("getProjectsTasksTicketsJobTypesLoccosEvents"); | |
var executionCounterGet = -1; | |
function nextGet() { | |
if (executionCounterGet >= executionOrderGet.length - 1) return; | |
executionCounterGet++; | |
executionOrderGet[executionCounterGet](); | |
return; | |
} | |
function getAllXfromCalendarApi() { | |
var itemName = itemNameList[executionCounterGet]; | |
var path = 'http://localhost:48484/api/Calendar/get' + itemName; | |
$.get(path, function (data) { | |
if (itemName == 'events') eventsCallback(data); | |
else defaultCallback(data); | |
}); | |
} | |
function defaultCallback(data) { | |
itemName = itemNameList[executionCounterGet]; | |
window[itemName] = {}; | |
data.forEach(function (item) { window[itemName][item.Id] = item; }); | |
nextGet(); | |
} | |
function eventsCallback(data) { | |
window.events = data; | |
// POPULATION OF THE CALENDAR WITH THE EVENTS FROM THE DATABASE | |
/// ADD ALL EVENT DATA WHICH IS REQUIRED FOR NORMAL CALENDAR FUNCTIONALITY | |
for (var i = 0; i < events.length; ++i) { | |
var startTime = moment(events[i].StartTime); | |
var endTime = moment(events[i].EndTime); | |
if (startTime.minute() != 0 && startTime.minute() != 15 && startTime.minute() != 30 && startTime.minute() != 45 | |
|| endTime.minute() != 0 && endTime.minute() != 15 && endTime.minute() != 30 && endTime.minute() != 45 | |
|| startTime.second() != 0 || endTime.second() != 0) { | |
console.log("Invalid event from service"); | |
console.log(events[i]); | |
//deleteEventInDbWithoutPopup(events[i]); | |
continue; | |
} | |
events[i].title = "Event: " + events[i].IdEvent; | |
events[i].start = events[i].StartTime; | |
events[i].end = events[i].EndTime; | |
events[i].id = events[i].IdEvent; | |
} | |
next(); | |
} | |
var itemNameList = ['projects', 'tasks', 'tickets', 'jobtypes', 'loccos', 'events']; | |
var executionOrderGet = [ | |
getAllXfromCalendarApi, | |
getAllXfromCalendarApi, | |
getAllXfromCalendarApi, | |
getAllXfromCalendarApi, | |
getAllXfromCalendarApi, | |
getAllXfromCalendarApi, | |
next | |
]; | |
nextGet(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment