Index: branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Scripts/Hubs/CalendarHubber.js
===================================================================
--- branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Scripts/Hubs/CalendarHubber.js	(revision 13795)
+++ branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Scripts/Hubs/CalendarHubber.js	(revision 13805)
@@ -12,20 +12,20 @@
                var hubber = $.connection.calendarHub;
 
-               vm.alertMessage = "No alerts";
-               vm.currentcal = [];
-               $scope.permission = false;
-               vm.selectedEventId = -1;
-               vm.groups = [];
-               vm.clients = [];
+               vm.currentcal = [];//Reference to current calendar (treeview.currentNode.calendar)
+               $scope.permissionview = false;//Show permissions or not
+               $scope.resaddview = false;//Show add resources or not
+               vm.selectedEventId = -1;//Selected downtime (-1 for none)
+               vm.groups = []; //All resource groups
+               vm.clients = []; //All resources 
                vm.init = function () {
-
-                   //  $.connection.hub.logging = true;
-
 
                    var v = document.getElementById("userId").innerHTML;
                    $.connection.hub.qs = { 'userid': v };
+                   //Connection string set to identify the unique session ID for the user
                    $.connection.hub.start().done(function () {
-                       hubber.server.requestInfo();
-                   });
+                       hubber.server.requestInfo();//initial data request
+                   });
+
+                   //Process all initial data needed (heavy load)
                    hubber.client.processData = function (data, users, groups) {
                        vm.data = JSON.parse(data);
@@ -36,4 +36,6 @@
                        $scope.$apply();
                    };
+
+                   //Saving from current graph is done -> refresh it
                    hubber.client.savingCurrentDone = function () {
                        vm.calendarSaver = false;
@@ -41,4 +43,6 @@
                        $scope.$apply();
                    };
+
+                   //Saving all graphs done -> clear everything
                    hubber.client.savingAllDone = function () {
                        vm.calendarSaver = false;
@@ -46,4 +50,6 @@
                        $scope.$apply();
                    };
+
+                   //Dispose toggle refresh for current
                    hubber.client.processDispose = function (disp) {
                        vm.treeview.currentNode.IsDisposable = disp;
@@ -51,4 +57,6 @@
                        $scope.$apply();
                    }
+
+                   //Permissions refresh for specific resource 
                    hubber.client.processPermissions = function (id, perm) {
                        var json = JSON.parse(perm);
@@ -59,4 +67,6 @@
                        $scope.$apply();
                    }
+
+                   //Process downtimes for a resource. Data conversion
                    hubber.client.processDowntime = function (id, down) {
                        var json = JSON.parse(down);
@@ -98,11 +108,101 @@
                    }
 
+                   //Initial function to build the resource tree
+                   $scope.buildTree = function () {
+                       vm.tree = [];
+                       vm.temptree = [];
+                       vm.top = false;
+                       var ungrouped = {
+                           children: [],
+                           Name: 'Ungrouped'
+                       }
+                       for (; vm.data.length > 0;) {
+
+                           if (vm.data[0].ParentResourceId == null && vm.data[0].IsDisposable !== undefined) {
+                               var curr = $scope.seekChildren(vm.data.splice(0, 1)[0]);
+                               vm.clients.push(curr);
+                               ungrouped.children.push(curr);
+                           }
+                           else if (vm.data[0].ParentResourceId == null) {
+                               var curr = $scope.seekChildren(vm.data.splice(0, 1)[0]);
+                               vm.groups.push(curr);
+                               vm.tree.push(curr);
+                           }
+                           else {
+                               var curr = $scope.seekChildren(vm.data.splice(0, 1)[0]);
+                               if (curr.IsDisposable !== undefined)
+                                   vm.clients.push(curr);
+                               else
+                                   vm.groups.push(curr);
+                               vm.temptree.push(curr);
+                           }
+                       }
+                       vm.tree.push(ungrouped);
+
+                   };//End for hubber init
+
+                   //menu navigation
+                   $scope.menuchange = function (i) {
+                       switch (i) {
+                           case 0:
+                               $scope.permissionview = false;
+                               $scope.resaddview = false;
+                               break;
+                           case 1:
+                               $scope.permissionview = true;
+                               $scope.resaddview = false;
+                               break;
+                           case 2:
+                               $scope.permissionview = false;
+                               $scope.resaddview = true;
+                               break;
+                       }
+                   }
+
+                   //Seeks for children, used recursively for building the treeview
+                   $scope.seekChildren = function (current) {
+                       current.calendar = [];
+                       current.children = [];
+                       current.todelete = [];
+                       current.changes = false;
+                       current.collapsed = true;
+                       for (var t = 0; t < vm.temptree.length;) {
+                           if (current.Id == vm.temptree[t].ParentResourceId) {
+                               current.children.push(vm.temptree.splice(t, 1)[0]);
+                           }
+                           else {
+                               t++;
+                           }
+                       }
+                       var childc = current.children.length;//Remembers count of children received from temp tree;
+                       for (var t = 0; t < vm.data.length;) {
+                           if (current.Id == vm.data[t].ParentResourceId) {
+                               if (vm.data[t].IsDisposable !== undefined)
+                                   vm.clients.push(vm.data[t]);
+                               else
+                                   vm.groups.push(vm.data[t]);
+                               current.children.push(vm.data.splice(t, 1)[0]);
+                           }
+                           else {
+                               t++;
+                           }
+                       }
+                       for (var t = childc; t < current.children.length; t++) {
+                           current.children[t] = $scope.seekChildren(current.children[t]);
+                       }
+                       return current;
+                   }
+
+                   //Change to another resource
                    $scope.$watch("treeview.currentNode", function (newValue, oldValue) {
                        $scope.currentcal = [];
+                       $scope.resaddview = false;
                        $(".selected.ng-binding").addClass('loaded');
                        $scope.selectedEventId = -1;
                        
+                       //Check if resource already has downtime data loaded
                        if ($scope.treeview.currentNode != null && $scope.treeview.currentNode.Id != undefined) {
                            if ($scope.treeview.currentNode.calendar.length === 0) {
+                               //Reach out to server to receive resource data
                                hubber.server.requestPermissions(vm.treeview.currentNode.Id);
                                hubber.server.requestDownTime(vm.treeview.currentNode.Id);
@@ -112,12 +212,27 @@
                                $timeout(function () {
                                    refreshPermissions();
+                                   //set previously loaded data
                                    $scope.currentcal = $scope.treeview.currentNode.calendar;
                                }, 0);
 
                            }
-                       }
-
-                   });
-               }
+                           $scope.refreshAdds();
+                       }
+
+                   });
+               }
+
+               //Resets the add resources menu 
+               $scope.refreshAdds = function() {
+                   for (var i = 0; i < $scope.clients.length; i++) {
+                       $scope.clients[i].add = false;
+                       for (var j = 0; j < $scope.treeview.currentNode.children.length; j++) {
+                           if ($scope.clients[i].Id === $scope.treeview.currentNode.children[j].Id)
+                               $scope.clients[i].add = true;
+                       }
+                   }
+               }
+
+               //Resets the permissions menu
                function refreshPermissions() {
                    for (var i = 0; i < $scope.permUsers.length; i++){
@@ -136,4 +251,6 @@
                    }
                }
+
+               //Add resource group show by clearing the tree
                $scope.clearTreeSelect = function () {
                    if (vm.treeview.currentNode != undefined) {
@@ -143,73 +260,12 @@
                    }
                }
-               $scope.buildTree = function () {
-                   vm.tree = [];
-                   vm.temptree = [];
-                   vm.top = false;
-                   var ungrouped = {
-                       children: [],
-                       Name: 'Ungrouped'
-                   }
-                   for (; vm.data.length > 0;) {
-
-                       if (vm.data[0].ParentResourceId == null && vm.data[0].IsDisposable !== undefined) {
-                           var curr = $scope.seekChildren(vm.data.splice(0, 1)[0]);
-                           vm.clients.push(curr);
-                           ungrouped.children.push(curr);
-                       }
-                       else if (vm.data[0].ParentResourceId == null) {
-                           var curr = $scope.seekChildren(vm.data.splice(0, 1)[0]);
-                           vm.groups.push(curr);
-                           vm.tree.push(curr);
-                       }
-                       else {
-                           var curr = $scope.seekChildren(vm.data.splice(0, 1)[0]);
-                           if (curr.IsDisposable !== undefined)
-                               vm.clients.push(curr);
-                           else
-                               vm.groups.push(curr);
-                           vm.temptree.push(curr);
-                       }
-                   }
-                   vm.tree.push(ungrouped);
-
-               };
-
-               $scope.seekChildren = function (current) {
-                   current.calendar = [];
-                   current.children = [];
-                   current.todelete = [];
-                   current.changes = false;
-                   current.collapsed = true;
-                   for (var t = 0; t < vm.temptree.length;) {
-                       if (current.Id == vm.temptree[t].ParentResourceId) {
-                           current.children.push(vm.temptree.splice(t, 1)[0]);
-                       }
-                       else {
-                           t++;
-                       }
-                   }
-                   var childc = current.children.length;//Remembers count of children received from temp tree;
-                   for (var t = 0; t < vm.data.length;) {
-                       if (current.Id == vm.data[t].ParentResourceId) {
-                           if (vm.data[t].IsDisposable !== undefined)
-                               vm.clients.push(vm.data[t]);
-                           else
-                               vm.groups.push(vm.data[t]);
-                           current.children.push(vm.data.splice(t, 1)[0]);
-                       }
-                       else {
-                           t++;
-                       }
-                   }
-                   for (var t = childc; t < current.children.length; t++) {
-                       current.children[t] = $scope.seekChildren(current.children[t]);
-                   }
-                   return current;
-               }
+
+               //Reach out to server to toggle disposable for current calendar
                $scope.toggleDisposable = function () {
                    $scope.calendarDispose = true;
                    hubber.server.toggleDisposable(vm.treeview.currentNode.Id);
                }
+
+               //Pushes permissions to server
                $scope.pushPermissions = function () {
                    var perms = [];
@@ -226,4 +282,6 @@
                    hubber.server.changePermissions(perms, node.Id);
                }
+
+               //Collects all data from a single resource to save to the server
                function collectInfoToSave(node, refresh, last) {
                    var arr = node.calendar.down[0];
@@ -233,4 +291,5 @@
                    for (var i = 0; i < arr.length; i++) {
                        if (arr[i].id === '00000000-0000-0000-0000-000000000000') {
+                           //NEW DOWNTIME
                            var t = arr[i].allDay.toString();
                            toadd.push([
@@ -250,4 +309,5 @@
                        }
                        else if (arr[i].changed === true) {
+                           //EDIT EXISTING DOWNTIME
                            var t = arr[i].allDay.toString();
                            toupd.push([
@@ -269,9 +329,13 @@
                    hubber.server.saveCalendar(node.Id, todel, toadd, toupd, refresh, last);
                }
+
+               //Save current calendar
                $scope.saveCurrentCalendar = function () {
                    vm.calendarSaver = true;
-                   collectInfoToSave(vm.treeview.currentNode, true, false);
+                   collectInfoToSave(vm.treeview.currentNode, true, false);//true for refresh, false for save all
                    //true for refresh, false for showing it's only one calendar saved.
                }
+
+               //Save all changed calendars
                $scope.saveAllCalendars = function () {
 
@@ -289,4 +353,5 @@
                    }).then(function (success) {
                        vm.calendarSaver = true;
+
                        for (var i = 0; i < $scope.allSave.length; i++) {
                            if (i >= $scope.allSave.length - 1)
@@ -299,4 +364,6 @@
 
                }
+
+               //Checks treeview for edits and builds new array containing these (recurse for children)
                function createSaveRequests(node) {
                    if (node.changes === true)
@@ -306,4 +373,6 @@
                    }
                }
+
+               //Clears and refreshes calendar for current resource (delete current changes)
                $scope.clearCurrentCalendar = function () {
 
@@ -319,4 +388,6 @@
 
                }
+
+               //Clears all calendars and refreshes current (Deletes all changes)
                $scope.clearAllCalendars = function () {
                    ngDialog.openConfirm({
@@ -333,4 +404,6 @@
 
                }
+
+               //Function that clears all calendar (separate so dialog is not called when saveAll is finished)
                function clearAllCalendarsFunc() {
                    $(".ng-binding.changed").removeClass('changed');
@@ -347,4 +420,6 @@
                    $(".selected.ng-scope").addClass('loaded');
                }
+
+               //Recurse trough tree view
                function clearCalendarsRecurse(node) {
 
@@ -356,4 +431,6 @@
                    }
                }
+
+               //Delete all downtimes from current resource
                $scope.deleteAllEvents = function () {
                    vm.calendarDeleter = true;
@@ -373,4 +450,6 @@
                    });
                }
+
+               //Delete all past events
                $scope.deleteAllPreviousEvents = function () {
                    vm.calendarDeleter = true;
@@ -395,5 +474,5 @@
                }
 
-
+               //Sets the status of a downtime AND the current resource to changed
                $scope.setChanged = function (id) {
                    if (id != -1) {
@@ -408,5 +487,6 @@
                    $(".selected").addClass('changed');
                }
-               //*Add event by click
+
+               //Adds event by click on empty space
                $scope.calendarClick = function (date, jsEvent, view) {
 
@@ -418,5 +498,5 @@
                    end.setHours(dat.getHours() + 2);
                    vm.treeview.currentNode.calendar.down[0].push({
-                       id: '00000000-0000-0000-0000-000000000000',
+                       id: '00000000-0000-0000-0000-000000000000',//Makes it recognizable as new for the server
                        title: 'Unavailable',
                        start: dat,
@@ -440,4 +520,6 @@
 
                }
+
+               //Finds array index for specific _id
                function checkId(id) {
                    for (var i = 0; i < vm.treeview.currentNode.calendar.down[0].length ; i++) {
@@ -447,13 +529,15 @@
                    return -1;
                }
-               /* alert on eventClick */
+               //Set selected downtime
                $scope.eventClick = function (date, jsEvent, view) {
                    vm.selectedEventId = checkId(date._id);
                };
+               //Sets selected downtime by clicking on the button at bottom on the page, moves to date
                $scope.eventClickBtn = function (id) {
                    vm.selectedEventId = checkId(id);
                    vm.goToDate();
                };
-               /* alert on Drop */
+
+               //Drag and drop downtime
                $scope.dragandDrop = function (event, delta, revertFunc, jsEvent, ui, view) {
                    vm.selectedEventId = checkId(event._id);
@@ -474,5 +558,5 @@
                    vm.treeview.currentNode.calendar.down[0][vm.selectedEventId].end = new Date(event.end);
                };
-               /* alert on Resize */
+               //Resize downtime
                $scope.resizeEvent = function (event, delta, revertFunc, jsEvent, ui, view) {
                    vm.selectedEventId = checkId(event._id);
@@ -482,5 +566,5 @@
                };
 
-               /* remove event */
+               //Removes a downtime from client (existing downtime gets referenced in todelete
                $scope.remove = function (index) {
                    vm.selectedEventId = -1;
@@ -493,4 +577,5 @@
 
                };
+               //Remove trough list view at bottom
                $scope.removeList = function (id) {
                    var index = checkId(id);
@@ -504,5 +589,5 @@
 
                };
-
+               //Check if start is before end AND start is after now (recursion)
                $scope.checkDateStartEnd = function () {
                    if ($scope.currentcal.down[0][vm.selectedEventId].rec.start > $scope.currentcal.down[0][vm.selectedEventId].rec.end ||
@@ -515,5 +600,5 @@
                        $scope.currentcal.down[0][vm.selectedEventId].rec.start = new Date();
                }
-               //pushes all changes to other recurs
+               //pushes all changes to other existing recurs and creates new downtimes where needed
                $scope.pushRecurChanges = function (recid) {
                    ngDialog.openConfirm({
@@ -526,17 +611,22 @@
                        plain: true
                    }).then(function (success) {
+
                        var arr = vm.treeview.currentNode.calendar.down[0];
+                       //Deep copy of downtime for referencing
                        var ob = $.extend(true, {}, arr[vm.selectedEventId]);
-                       for (var i = 0; i < arr.length;) {
+
+                       for (var i = 0; i < arr.length;) {//Go trough downtimes and find all recurrences
                            if (arr[i].rec.recid === recid) {
                                if (new Date(arr[i].start) < new Date(ob.rec.start) ||
                                         new Date(arr[i].end) > new Date(ob.rec.end) ||
                                         !ob.rec.days[new Date(arr[i].start).getDay()]) {
-                                   vm.remove(i);
+                                   //Downtime is out of recurrence boundaries
+                                   //Before start date OR After end date OR Not on right day of the week
+                                   vm.remove(i);//NO I++ -> REMOVE SPLICES ARRAY
                                    vm.selectedEventId = -1;
 
                                }
                                else {
-
+                                   //Edit downtime when it is within the bounds
                                    arr[i].start.setHours(ob.start.getHours(), ob.start.getMinutes());
                                    arr[i].end.setHours(ob.end.getHours(), ob.end.getMinutes());
@@ -551,14 +641,16 @@
                                i++;
                        }
+                       //init for new downtimes. 
                        var start = new Date(ob.rec.start);
-                       start.setHours(2, 0, 0, 0);
+                       start.setHours(2, 0, 0, 0);//Beginning of the day + time conversion +02
                        var end = new Date(ob.rec.end);
-                       end = new Date(end.setHours(24, 0, 0, 0) + 1000 * 3600 * 2);
-
-                       loop1:
+                       end = new Date(end.setHours(24, 0, 0, 0) + 1000 * 3600 * 2);//End of the day + time conversion +02
+
+                       loop1: //Loop start to end with single day increment
                            for (var d = (start.getTime()) ; d < (end.getTime()) ;) {
                                var tog = ob.rec.days[new Date(d).getDay()];
+                               //Check if day of the week is included in recursion
                                if (tog) {
-                                   loop2:
+                                   loop2://Loop checking existing downtime array to see if day is already filled or not
                                        for (var i = 0; i < arr.length; i++) {
 
@@ -567,10 +659,10 @@
                                                if (arr[i].start.getTime() >= d &&
                                                    arr[i].end.getTime() <= dend) {
-                                                   d += (1000 * 3600 * 24);
-                                                   continue loop1;
+                                                   d += (1000 * 3600 * 24);//add day to loop 1
+                                                   continue loop1;//breaks out of loop2 and skips to next day
                                                }
                                            }
                                        }
-
+                                   //Made it here = new event needed: init
                                    var ts = new Date(d);
                                    ts.setHours(new Date(ob.start).getHours(), new Date(ob.start).getMinutes());
@@ -589,9 +681,11 @@
                                }
 
-                               d += (1000 * 3600 * 24);// 1 day
-
-                           }
-                   });
-               }
+                               d += (1000 * 3600 * 24);// adds one day
+
+                           }
+                   });
+               }
+
+               //Delete all bound recurrences
                $scope.deleteAllRecurrences = function (recid) {
                    ngDialog.openConfirm({
@@ -614,8 +708,9 @@
                }
 
+               //Moves calendar to selected date
                $scope.goToDate = function () {
                    $("#resourcecalendar").fullCalendar('gotoDate', vm.currentcal.down[0][vm.selectedEventId].start);
                }
-               /* Render Tooltip */
+               /* Renders Tooltip */
                $scope.eventRender = function (event, element, view) {
                    element.attr({
@@ -625,5 +720,5 @@
                    //$compile(element)($scope);
                };
-               /* config object */
+               //Calendar configuration
                $scope.uiConfig = {
                    calendar: {
@@ -650,12 +745,14 @@
                };
 
+               
+
 
 
            }).filter('disp', function () {
-               return function (input) {
+               return function (input) {//Filter boolean to string
                    return input ? 'Disposable' : 'Not disposable';
                }
            }).directive('animateOnChange', function ($timeout) {
-               return function (scope, element, attr) {
+               return function (scope, element, attr) {//Animation on downtime info to show change
                    scope.$watch(attr.animateOnChange, function (nv, ov) {
 
@@ -665,5 +762,5 @@
                                $timeout(function () {
                                    element.removeClass('changed');
-                               }, 250); // Could be enhanced to take duration as a parameter
+                               }, 250); 
                            }
                            else {
@@ -671,5 +768,5 @@
                                $timeout(function () {
                                    element.removeClass('changedshut');
-                               }, 250); // Could be enhanced to take duration as a parameter
+                               }, 250);
                            }
                        }
Index: branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Scripts/Hubs/UserInfoHubber.js
===================================================================
--- branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Scripts/Hubs/UserInfoHubber.js	(revision 13795)
+++ branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Scripts/Hubs/UserInfoHubber.js	(revision 13805)
@@ -2,5 +2,5 @@
 
 $(function () {
-    $.connection.hub.logging = true;
+    //$.connection.hub.logging = true;
     var v = document.getElementById("userId").innerHTML;
     console.log(v);
@@ -8,5 +8,5 @@
     $.connection.hub.start();
     hubber.client.showNewPass = function (pass) {
-        $("#inppassreset").html("<label class=' control-label' style='text-align:left'>New password: " + pass + "</label>");
+        $("#inppassreset").html("<label class=' control-label' style='text-align:left'>New pass: " + pass + ". An email has been sent to the user containing the new password</label>");
                                       
     };
Index: branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Scripts/Styling/angular.treeview.css
===================================================================
--- branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Scripts/Styling/angular.treeview.css	(revision 13795)
+++ branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Scripts/Styling/angular.treeview.css	(revision 13805)
@@ -61,5 +61,5 @@
 
     div[data-tree-model] li.selected {
-        box-shadow:  2px 3px 5px rgba(0,0,0,0.6), inset 1px 10px 300px 51px rgba(143,201,58,1)!important;
+        box-shadow:  2px 3px 5px rgba(0,0,0,0.6), inset 1px 10px 300px 51px #5cb85c!important;
     }
     div[data-tree-model] span.selected {
