code.js

angular.module('homepage', ['ngStorage', 'ui.router', 'templates']);
angular.module('templates', []);

angular.module('homepage').
config(function($httpProvider) {
    var interceptor = function($q, $location, $localStorage) {
        function success(response) {
            response.headers = response.headers || {};
            if ($localStorage.token) {
                response.headers.Authorization = 'Bearer ' + $localStorage.token;
            }
            return response;
        }

        function error(response) {
            if (response.status === 401 || response.status === 403) {
                $location.path('/#/login');
            }
            return $q.reject(response);
        }

        return function(promise) {
            return promise.then(success, error);
        };
    };
    $httpProvider.interceptors.push(interceptor);
}).
run(function($http, $localStorage, $rootScope, Authentication, MobileType, Server) {
    function setMobileType() {
        $rootScope.isMobile = MobileType.any();
    }

    // TODO load local storage templates on load
    function initializeLocalStorage() {
        if(!($localStorage.templates && $localStorage.templates.length)) {
            $localStorage.templates = [];
        }
        else {
            Server.ibsubmit({ 'templates': $localStorage.templates})
            .success(function (result) {
                console.log(result);
                if(result.success) {
                    $localStorage.templates = [];
                }
            });
        }
    }

    function initializeDefaults() {
        // Set the token as header for your requests!
        $http.defaults.headers.common['X-Auth-Token'] = $localStorage.token;
    }

    function initializeAuthentication() {
        $rootScope.userDtls = Authentication.getUser();
        $rootScope.isAuthenticated = Authentication.isAuthenticated();
    }

    function initialize() {
        setMobileType();
        initializeDefaults();
        initializeLocalStorage();
        initializeAuthentication();
    }

    initialize();
    window.addEventListener("orientationchange", setMobileType, false);
    window.addEventListener("resize", setMobileType, false);
});

angular.module('homepage').
controller('DownloadController', function ($anchorScroll, $scope, $state, DataStoreSrvc, DownloadFile, Server) {
    $anchorScroll();

	var inputs = DataStoreSrvc.getInputData();

	$scope.selectedFileType = 'DOCX';

	$scope.selectFileType = function (type) {
		$scope.selectedFileType = type;
	};

    $scope.onBack = function () {
        $state.transitionTo('inputextras');
    };

	$scope.onEdit = function () {
		$state.transitionTo('inputbasic');
	};

	$scope.downloadCV = function () {
        var data = { 'type': $scope.selectedFileType, 'inputs': inputs };
        var callback = null;
		if($scope.selectedFileType === 'RTF') {
            Server.downloadRtf(data).then(function (result) {
                DownloadFile.getPlainText('file.rtf', result.data.content);
            });
        }
        else {
            Server.downloadDocx(data).then(function (result) {
                var fullname = inputs.profile.fullname ? inputs.profile.fullname : 'file';
                DownloadFile.getDocxFile(fullname + '.docx', result.data);
            });
        }

	};

    $scope.print = function () {
        $state.transitionTo('print');
    };

});

angular.module('homepage').
controller('InputBasicController', function ($anchorScroll, $localStorage, $scope, $state, DataStoreSrvc) {
	$anchorScroll();

	$scope.inputs = DataStoreSrvc.getInputData();

    $scope.onReset = function () {
        // Discard the local storage saved data
        // Reload the page from last saved server data
    };

    $scope.onNext = function () {
		$localStorage.inputs = JSON.stringify($scope.inputs);
        // Submit new data to server
        console.log($scope.inputs);
		$state.transitionTo('inputexperience');
    };
});

angular.module('homepage').
controller('InputExperienceController', function ($anchorScroll, $localStorage, $scope, $state, DataStoreSrvc) {
	$anchorScroll();

	$scope.inputs = DataStoreSrvc.getInputData();

    $scope.onBack = function () {
		$localStorage.inputs = JSON.stringify($scope.inputs);
        $state.transitionTo('inputbasic');
    };

    $scope.onNext = function () {
		$localStorage.inputs = JSON.stringify($scope.inputs);
        // Submit new data to server
        console.log($scope.inputs);
		$state.transitionTo('inputextras');
    };
});

angular.module('homepage').
controller('InputExtrasController', function ($anchorScroll, $localStorage, $scope, $state, DataStoreSrvc, Server) {
	$anchorScroll();

	$scope.inputs = DataStoreSrvc.getInputData();

    $scope.onBack = function () {
		$localStorage.inputs = JSON.stringify($scope.inputs);
        $state.transitionTo('inputexperience');
    };

    $scope.onSubmit = function () {
		$localStorage.inputs = JSON.stringify($scope.inputs);
        // Submit new data to server
        console.log($scope.inputs);
		Server.saveResumeData($scope.inputs);
		$state.transitionTo('download');
    };
});

angular.module('homepage').
controller('PrintController', function ($anchorScroll, $scope, $state, $timeout, $window, DataStoreSrvc) {
	$anchorScroll();

	$scope.inputs = DataStoreSrvc.getInputData();

	$scope.onBack = function () {
        $state.transitionTo('download');
    };

	$scope.print = function () {
        $timeout(function () {
        	$window.print();
        });
    };
});

angular.module('homepage').
// ARRAY filters
filter('reverse', function() {
	return function(items) {
		return items.slice().reverse();
	};
}).
filter('arr2str', function() {
	return function(items) {
		var string = '';
		for(var index in items) {
			var item = items[index];
			if (index !== "0") string += ', ';
			if (item !== undefined && item.length !== 0 && item !== '') {
				string += item;
			}
		}
		return string;
	};
}).
filter('arraysum', function() {
	return function(items, attribute) {
		var sum = 0;
		for(var index in items) {
			var item = items[index];
			if (item !== undefined && item[attribute.name] !== undefined) {
				var value = parseInt(item[attribute.name]);
				if(typeof value  === "number") {
					sum += value;
				}
			}
		}
		return sum;
	};
}).
filter('filterByValue', function () {
	/**
	 * Returns items by type and excludes if type is EXCL
	 * name: Name of the attribute whose value is to be compared
	 * type: INCL/INCLUDE or EXCL/EXCLUDE value whose value matches
	 * value: value of the attribute
	 * { name: String, type: String, value: String}
	 */
	 return function (items, typeinfo) {
	 	var filtered = [];
	 	for (var index in items) {
	 		var item = items[index];
	 		if(typeinfo.type == 'INCL' || typeinfo.type == 'INCLUDE') {
	 			if(item[typeinfo.name] === typeinfo.value) {
	 				filtered.push(items[index]);
	 			}
	 		}
	 		// Default type is 'EXCL' or 'EXCLUDE'
	 		else {
	 			if(item[typeinfo.name] !== typeinfo.value) {
	 				filtered.push(items[index]);
	 			}
	 		}
	 	}
	 	return filtered;
	};
}).
filter('filterByIndex', function () {
	/**
	 * Returns items by type and excludes if exclude is set to 'true'
	 * { exclude: Boolean, index: Number }
	 */
	 return function (items, indexinfo) {
	 	var filtered = [];
	 	// Exclude item at index mentioned from the returned list
	 	for (var index in items) {
	 		if(indexinfo.exclude === true) {
		 		if(index != indexinfo.index) {
		 			filtered.push(items[index]);
		 		}
		 	}
		 	else {
		 		if (index === indexinfo.index) {
		 			filtered.push(items[index]);
		 		}
		 	}
	 	}

	 	return filtered;
	};
});

angular.module('homepage').
filter('doubledigit', [function() {
	return function (number) {
		if(number < 10) {
			return '0' + number;
		}
		else {
			return number;
		}
	};
}]);

angular.module('homepage').
filter('companytext', function() {
	return function(company) {
        var result = '';
        if(company.companyName) {
            result += company.companyName + ' | ';
        }

        if(company.startDate && company.endDate) {
            result += company.startDate + ' to ' + company.endDate;
        }
        return result;
	};
});

angular.module('homepage').
filter('codeconvert', function(CodeConvertSrvc) {
	return function (code) {
		var value = CodeConvertSrvc.getValue(code);
		if(value === '') {
			return code;
		}
		else {
			return value;
		}
	};
});

angular.module('homepage').
// DATE filters
filter('datediff', function() {
	/**
	 * Get the difference of dates
	 * @param  {Object} attribute {'0': Date, '1': Date, type: 'String'}
	 * @return {Number}           Difference of date in hours/days
	 */
	return function(input, date1, date2) {
		var text = '';
		var suffix = '';
		var timestamp0 = new Date(date1).getTime();
		var timestamp1 = new Date(date2).getTime();
		var difference = Math.abs(timestamp0 - timestamp1) / 1000;
		
		if (difference < 60) {
			text = difference + ' sec';
		}
		else if (difference < 60*60) {
			difference = Math.floor(difference/60);
			text = difference + 'min'; 
		}
		else if (difference < 24*60*60) {
			difference = Math.floor(difference/(60*60));
			text = difference + ' hour';
		}

		suffix = difference == 1 ? '' : 's';

		return text + suffix;
	};
});
angular.module('homepage').
filter('educationtext', function() {
	return function(education) {
        var result = '';
        if(education.educationTitle) {
            result += education.educationTitle;
        }

        if(education.studiedFrom) {
            result += ' | ' + education.studiedFrom;
        }

        if(education.startDate && education.endDate) {
            result += ' | ' + education.startDate + ' to ' + education.endDate;
        }

		if(education.specialization) {
            result += ' | ' + education.specialization;
        }

		if(education.score) {
            result += ' | ' + education.score;
        }
        return result;
	};
});

angular.module('homepage').
filter('projecttext', function() {
	return function(project) {
        var result = '';
        if(project.projectName) {
            result += project.projectName + ' | ';
        }

        if(project.startDate && project.endDate) {
            result += project.startDate + ' to ' + project.endDate;
        }
        return result;
	};
});

angular.module('homepage').
filter('skilltext', function() {
	return function(skill) {
        var result = '';
        if(skill.skillName) {
            result += skill.skillName + ' | ';
        }

        if(skill.versionNo) {
            result += 'Version ' + skill.versionNo + ' | ';
        }

        if(skill.totalExp) {
            result += skill.totalExp;
        }
        return result;
	};
});

angular.module('homepage').
directive('choosemany', function() {
  return {
    link: choosemanyLinker,
    restrict: 'A',
    replace: false
  }

  function choosemanyLinker(scope, element, attribute) {
    var groupname = attribute.choosemany;
    var parentname = attribute.namespace && typeof attribute.namespace == 'string' && attribute.namespace.length > 0 
                      ? '.' + attribute.namespace + ' ' : '';
    var query = parentname + '[choosemany=' + groupname + ']';
    element.bind('click', function() {
      if(this.classList.contains('chosen')) {
        this.classList.remove('chosen');
      }
      else {
        this.classList.add('chosen');
      }
    })
  }
});

angular.module('homepage').
directive('chooseone', function() {
  return {
    link: chosenLinker,
    restrict: 'A',
    replace: false
  }

  function chosenLinker(scope, element, attribute) {
    var groupname = attribute.chooseone;
    var parentname = attribute.namespace && typeof attribute.namespace == 'string' && attribute.namespace.length > 0 
                      ? '.' + attribute.namespace + ' ' : '';
    var query = parentname + '[chooseone=' + groupname + ']';
    element.bind('click', function() {
      var elements = document.querySelectorAll(query);
      for (var i = 0; i < elements.length; i++) {
        var item = elements[i];
        item.classList.remove('chosen');
      }
      this.classList.add('chosen');
    })
  }
});

angular.module('homepage').
directive('choosetoggle', function() {
  return {
    link: chosenLinker,
    restrict: 'A',
    replace: false
  }

  function chosenLinker(scope, element, attribute) {
    element.bind('click', function() {
        this.classList.toggle('chosen');
    })
  }
});

angular.module('homepage').
directive("contenteditable", function() {
  return {
    restrict: "A",
    require: "ngModel",
    link: function(scope, element, attrs, ngModel) {
      function read() {
        ngModel.$setViewValue(element.html() || "<br>");
      }

      ngModel.$render = function() {
        element.html(ngModel.$viewValue || "<br>");
      };

      element.bind("blur keyup change", function() {
        scope.$apply(read);
      });
    }
  };
});

angular.module('homepage').
/**
 * On action modifies an property on scope.
 * It takes the following parameters:
 *   onAction attribute - (following values seper)
 *     type: type of action,
 *     item: item name on scope,
 *     value: value that is to be set for the item
 *   scopeObj attribute - the variable,
 *   on which the items needs to be modified.
 */
 directive('onAction', function (StringUtility, $timeout) {
 	return {
 		restrict: 'A',
 		link: onActionLinkerFn,
 		scope: {
 			onAction: '=',
 			isVisible: '=scopeObj'
 		}
 	}
 	
 	function onActionLinkerFn(scope, element, attribute) {
            var parts = StringUtility.getPartsOfString(scope.onAction);
            parts = convertPartToArray(parts);
            parts = checkValues(parts);

            var events = parts[0];
            for(var index in events) {
                  var eventtype = events[index];
                  if(eventtype.toLowerCase() == 'KEYUP'.toLowerCase()) {
                        element.bind('keyup', function(event) {
                              setAttributes(event, scope, parts);
                        });
                  }

                  if(eventtype.toLowerCase() == 'CLICK'.toLowerCase()) {
                        element.bind('click', function(event) {
                              setAttributes(event, scope, parts);   
                        });
                  }
            }
      }

      function setAttributes(event, scope, parts) {
            event.stopPropagation();

            var attributes = parts[1];
            var values = parts[2];

            for(var index in attributes) {
                  var attribute = attributes[index].trim();
                  // convert value to boolean from string if string contains 'true' or 'false' value
                  var value = StringUtility.stringToBoolean(values[index].trim());
                  scope.isVisible[attribute] = value;
            }

            $timeout(function () {
                  scope.$apply();
            })
      }

      /* Expand from one value to multiple if needed */
      function checkValues(parts) {
            var attributes = parts[1];
            var values = parts[2];

            if(attributes.length != values.length) {
                  var value = values[0];
                  var values = [];
                  for(var index in attributes) {
                        values.push(value);
                  }
                  parts[2] = values;
            }

            return parts;
      }

      /* Extract items from string and convert to array */
      /**
       * @return parts
       * parts[1]: attributes
       * parts[2]: values
       */
      function convertPartToArray(parts) {
            for(var index in parts) {
                  var part = parts[index];
                  if(typeof part == 'string') {
                        // convert string to array
                        parts[index] = [part.trim()];
                  }
            }
            return parts;
      }
});
angular.module('homepage').
/**
 * On action modifies an property on scope.
 * It takes the following parameters:
 *   onActionToggle attribute - (following values seper)
 *     type: type of action,
 *     item: item name on scope,
 *     value: value that is to be set for the item
 *   scopeObj attribute - the variable,
 *   on which the items needs to be modified.
 */
 directive('onActionToggle', function (StringUtility, $timeout) {
 	return {
 		restrict: 'A',
 		link: onActionToggleLinkerFn,
 		scope: {
 			onActionToggle: '=',
 			isVisible: '=scopeObj'
 		}
 	}
 	
 	function onActionToggleLinkerFn(scope, element, attribute) {
            var parts = StringUtility.getPartsOfString(scope.onActionToggle);
            parts = convertPartToArray(parts);
            parts = checkValues(parts);

            setDefaultValues(scope, parts);

            var events = parts[0];
            for(var index in events) {
                  var eventtype = events[index];
                  if(eventtype.toLowerCase() == 'KEYUP'.toLowerCase()) {
                        element.bind('keyup', function(event) {
                              setAttributes(event, scope, parts);
                        });
                  }

                  if(eventtype.toLowerCase() == 'CLICK'.toLowerCase()) {
                        element.bind('click', function(event) {
                              setAttributes(event, scope, parts);   
                        });
                  }
            }
      }

      function setDefaultValues(scope, parts) {
            var attributes = parts[1];
            var values = parts[2];

            for(var index in attributes) {
                  var attribute = attributes[index].trim();
                  // convert value to boolean from string if string contains 'true' or 'false' value
                  var value = StringUtility.stringToBoolean(values[index].trim());
                  scope.isVisible[attribute] = value;
            }

            $timeout(function () {
                  scope.$apply();
            });
      }

      function setAttributes(event, scope, parts) {
            event.stopPropagation();

            var attributes = parts[1];
            var values = parts[2];

            for(var index in attributes) {
                  var attribute = attributes[index].trim();
                  scope.isVisible[attribute] = !scope.isVisible[attribute];
            }

            $timeout(function () {
                  scope.$apply();
            });
      }

      /* Expand from one value to multiple if needed */
      function checkValues(parts) {
            var attributes = parts[1];
            var values = parts[2];

            if(attributes.length != values.length) {
                  var value = values[0];
                  var values = [];
                  for(var index in attributes) {
                        values.push(value);
                  }
                  parts[2] = values;
            }

            return parts;
      }

      /* Extract items from string and convert to array */
      /**
       * @return parts
       * parts[1]: attributes
       * parts[2]: values
       */
       function convertPartToArray(parts) {
            for(var index in parts) {
                  var part = parts[index];
                  if(typeof part == 'string') {
                        // convert string to array
                        parts[index] = [part.trim()];
                  }
            }
            return parts;
      }
});
angular.module('homepage').
/**
 * @param 'main' CSS Selector for element whose height is to be set on other elements
 * @param 'others' Array of CSS Selector of elements whose height is to be set
 * @param 'offset' Any variance required from the height being set to the element
 */
 directive('setequalheight', function($timeout) {
  return {
    link: setequalheightLinker,
    restrict: 'A',
    replace: false
  }

  function setequalheightLinker(scope, element, attribute) {
    window.addEventListener("orientationchange", setHeight, false);
    window.addEventListener("resize", setHeight, false);

    setHeight();

    function setHeight() {
      $timeout(function () {
        scope.$apply(function(){
          var params = JSON.parse(attribute.setequalheight);
          var mainElement = element[0].querySelector(params.main);
          var mainElementHeight = mainElement.offsetHeight;
          for(var i=0; i<params.others.length; i++) {
            var otherElement, offset;
            if(params.others[i]=="") {
              otherElement= element[0];
            }
            else {
              otherElement= element[0].querySelector(params.others[i]);
            }
            if(otherElement && otherElement != null) {
              offset = params.offset && params.offset[i] ? params.offset[i] : 0;
              otherElement.style.height = (mainElementHeight - offset) + 'px';
            }
          }
        });
      });
    }
  }
});

angular.module("templates").run(["$templateCache", function($templateCache) {$templateCache.put("components/common-components/autocomplete/autocomplete.html","<div class=\"autocomplete\">\n  <input class=\"inputtext\" type=\"text\" ng-model=\"enteredtext\" ng-keyup=\"filterItems()\"/>\n  <div class=\"choices\" ng-show=\"isVisible.suggestions\">\n    <div class=\"choice\" ng-repeat=\"choice in filteredChoices\"\n      ng-click=\"selectItem(choice.index)\">{{choice.label}}</div>\n  </div>\n</div>");
$templateCache.put("components/common-components/editor/editor.html","<div class=\"editor\">\n	<div class=\"editorbox\" contenteditable=\"{{isEditable}}\" ng-model=\"note\"\n	ng-paste=\"handlePaste($event)\"><br></div>\n</div>\n");
$templateCache.put("components/common-components/checkbox/checkbox.html","<span class=\"checkbox\">\n    <input type=\"checkbox\" id=\"{{::name}}\" name=\"cc\" ng-model=\"isChecked\"\n        ng-click=\"markCheckboxFn({\'name\':name, \'isChecked\': isChecked})\"/>\n    <label for=\"{{::name}}\">\n        <span class=\"icon\"></span>\n        <span class=\"label-text\">{{::label}}</span>\n    </label>\n</span>\n");
$templateCache.put("components/common-components/list/list.html","<div class=\"list\">\n	<!-- pass only object, not primitive while using isolated scope directives -->\n	<div ng-repeat=\"item in list track by $index\">\n		<!-- need to pass parameters from scope into the directive methods, blank or non scope params are not passed to controller method -->\n		<listitem list=\"list\" is-disabled=\"isDisabled\" itemindex=\"{index: $index}\"\n			set-list=\"setList($index)\"></listitem>\n		<list list=\"item.list\" is-disabled=\"isDisabled\" ng-if=\"item.list != undefined\"><list>\n	</div>\n</div>\n");
$templateCache.put("components/common-components/title/title.html","<div class=\"inputfield title\">\n	<input class=\"input-value\" type=\"text\" ng-model=\"note.title\" placeholder=\"Title\" \n	onfocus=\"this.placeholder = \'\'\" onblur=\"this.placeholder = \'Title\'\">\n</div>");
$templateCache.put("components/content-components/drawer/drawer-menu.html","<div class=\"drawer-menu\" ng-if=\"isMobile\">\n	<div class=\"drawer-icon\">\n		<i class=\"fa fa-bars menu-icon\" aria-hidden=\"true\" ng-click=\"toggleDrawer()\"></i>\n	</div>\n	<div class=\"menu-sidebar\" ng-show=\"isPanelVisible\">\n		<div class=\"menu-item\">\n			<a href=\"/#/home\" ng-click=\"hideDrawer()\">Home</a>\n		</div>\n		<div class=\"menu-item\">\n			<a href=\"/#/comment\" ng-click=\"hideDrawer()\">Feedback</a>\n		</div>\n		<!-- <div class=\"menu-item\">\n			<a href=\"/#/about\" ng-click=\"hideDrawer()\">About Us</a>\n		</div> -->\n		<div class=\"menu-item register\">\n			<a href=\"/#/signup\" ng-click=\"hideDrawer()\">Register</a>\n		</div>\n	</div>\n</div>");
$templateCache.put("components/content-components/footer/footer.html","<div class=\"copyright-wrapper\">\n  <div class=\"copyright text-center\">\n      Contact Us at hello@about-me.co\n  </div>\n</div>\n");
$templateCache.put("components/content-components/header/header-menu.html","<div class=\"header-menu\">\n    <div class=\"item hidden-xs\">\n        <a href=\"/#/comment\">\n            <i class=\"fa fa-comment-o\" aria-hidden=\"true\"></i>\n        </a>\n    </div>\n    <div class=\"item\" ng-hide=\"isAuthenticated\">\n        <a class=\"clickable\" href=\"/#/login\">Login</a>\n    </div>\n    <div class=\"item hidden-very-xs\" ng-hide=\"isAuthenticated\">\n        <a class=\"btn clickable register\" href=\"/#/signup\">Sign Up</a>\n    </div>\n    <div class=\"item\" ng-show=\"isAuthenticated\">\n        <a class=\"btn clickable register\" ng-click=\"logout()\">Log Out</a>\n    </div>\n</div>\n");
$templateCache.put("components/content-components/header/header.html","<div class=\"header-wrapper\">\n    <div class=\"header container\">\n        <div class=\"title\">\n        	<drawer-menu></drawer-menu>\n        	<a class=\"inputbox-link\" ng-click=\"loadDefaultPage()\">ABOUT ME</a>\n        </div>\n        <header-menu></header-menu>\n    </div>\n</div>\n");
$templateCache.put("components/content-components/home/home.html","<div class=\"container\">\n    <div class=\"home col-xs-12 col-sm-12 col-md-12\" ng-init=\"getUser()\">\n        <ng-transclude></ng-transclude>\n    </div>\n</div>\n");
$templateCache.put("components/content-components/input/activity-list.html","<div class=\"activity-list\">\n    <div class=\"activity list-item\" ng-repeat=\"activity in activities track by $index\">\n        <div class=\"inputfield\">\n            <label class=\"input-title\" ng-if=\"$index === 0\">Description</label>\n            <div class=\"description\">\n                <div class=\"index\" ng-if=\"activities.length > 1\">{{$index + 1}}</div>\n                <editor note=\"activity.description\" is-editable=\"true\"></editor>\n            </div>\n        </div>\n    </div>\n    <div class=\"inputfield\">\n        <button ng-click=\"addActivity()\" class=\"btn secondary-btn full-width\" type=\"button\" name=\"button\">Add New</button>\n    </div>\n</div>\n");
$templateCache.put("components/content-components/input/career-objective.html","<div class=\"career-objective\">\n    <div class=\"description\">\n        <div class=\"inputfield\">\n            <label class=\"input-title\">Description</label>\n            <editor note=\"objective.description\" is-editable=\"true\"></editor>\n        </div>\n    </div>\n</div>\n");
$templateCache.put("components/content-components/input/company-list.html","<div class=\"company-list\">\n    <div class=\"company list-item\" ng-repeat=\"company in companies track by $index\">\n        <div class=\"\" ng-show=\"companies.length > 1 || company.projects.length > 0\">\n            <div class=\"index\">{{$index + 1}}</div>\n            <div class=\"underline\"></div>\n        </div>\n        <div class=\"inputfield\">\n            <label class=\"input-title\">Company name</label>\n            <input class=\"input-value\" type=\"text\" ng-model=\"company.companyName\">\n        </div>\n        <div class=\"inputfield\">\n            <label class=\"input-title\">Last Job Title</label>\n            <input class=\"input-value\" type=\"text\" ng-model=\"company.jobTitle\">\n        </div>\n        <div class=\"inputfield\">\n            <div class=\"split-two first\">\n                <label class=\"input-title\">Start Date</label>\n                <input class=\"input-value\" type=\"text\" ng-model=\"company.startDate\">\n                <!-- <input-with-plchldr placeholder=\"DD Month YYYY\"></input-with-plchldr> -->\n            </div>\n            <div class=\"split-two second\">\n                <label class=\"input-title\">End Date</label>\n                <input class=\"input-value\" type=\"text\" ng-model=\"company.endDate\">\n                <!-- <input-with-plchldr placeholder=\"DD Month YYYY\"></input-with-plchldr> -->\n            </div>\n        </div>\n        <projects-list data=\"company.projects\"></projects-list>\n        <div class=\"inputfield\">\n            <button ng-click=\"addProject($index)\" class=\"btn secondary-btn selected full-width\" type=\"button\" name=\"button\">Add Project</button>\n        </div>\n    </div>\n\n    <div class=\"inputfield\">\n        <button ng-click=\"addCompany()\" class=\"btn secondary-btn full-width\" type=\"button\" name=\"button\">Add Company</button>\n    </div>\n</div>\n");
$templateCache.put("components/content-components/input/education-list.html","<div class=\"education-list\">\n    <div class=\"education list-item\" ng-repeat=\"education in educations\">\n        <div class=\"index\" ng-show=\"educations.length > 1\">{{$index + 1}}</div>\n        <div class=\"underline\" ng-show=\"educations.length > 1\"></div>\n        <div class=\"inputfield\">\n            <label class=\"input-title\">Education Title</label>\n            <input class=\"input-value\" type=\"text\" ng-model=\"education.educationTitle\">\n        </div>\n        <div class=\"inputfield\">\n            <label class=\"input-title\">Studied From</label>\n            <input class=\"input-value\" type=\"text\" ng-model=\"education.studiedFrom\">\n        </div>\n        <div class=\"inputfield\">\n            <div class=\"split-two first\">\n                <label class=\"input-title\">Start Date</label>\n                <input class=\"input-value\" type=\"text\" ng-model=\"education.startDate\">\n                <!-- <input-with-plchldr placeholder=\"DD Month YYYY\"></input-with-plchldr> -->\n            </div>\n            <div class=\"split-two second\">\n                <label class=\"input-title\">End Date</label>\n                <input class=\"input-value\" type=\"text\" ng-model=\"education.endDate\">\n                <!-- <input-with-plchldr placeholder=\"DD Month YYYY\"></input-with-plchldr> -->\n            </div>\n        </div>\n        <div class=\"inputfield\">\n            <div class=\"split-two first\">\n                <label class=\"input-title\">Specialization</label>\n                <input class=\"input-value\" type=\"text\" ng-model=\"education.specialization\">\n                <!-- <input-with-plchldr placeholder=\"DD Month YYYY\"></input-with-plchldr> -->\n            </div>\n            <div class=\"split-two second\">\n                <label class=\"input-title\">CPA / Score</label>\n                <input class=\"input-value\" type=\"text\" ng-model=\"education.score\">\n                <!-- <input-with-plchldr placeholder=\"DD Month YYYY\"></input-with-plchldr> -->\n            </div>\n        </div>\n    </div>\n    <div class=\"inputfield\">\n        <button ng-click=\"addEducation()\" class=\"btn secondary-btn full-width\" type=\"button\" name=\"button\">Add New</button>\n    </div>\n</div>\n");
$templateCache.put("components/content-components/input/experience-list.html","<div class=\"experience-list\">\n    <div class=\"experience list-item\" ng-repeat=\"experience in experiences track by $index\">\n        <div class=\"inputfield\">\n            <label class=\"input-title\" ng-if=\"$index === 0\">Description</label>\n            <div class=\"description\">\n                <div class=\"index\" ng-if=\"experiences.length > 1\">{{$index + 1}}</div>\n                <editor note=\"experience.description\" is-editable=\"true\"></editor>\n            </div>\n        </div>\n    </div>\n    <div class=\"inputfield\">\n        <button ng-click=\"addExperience()\" class=\"btn secondary-btn full-width\" type=\"button\" name=\"button\">Add New</button>\n    </div>\n</div>\n");
$templateCache.put("components/content-components/input/interest-info.html","<div class=\"interest-info\">\n    <div class=\"description\">\n        <div class=\"inputfield\">\n            <label class=\"input-title\">Interests / Hobbies</label>\n            <list list=\"interest.hobbies.list\" is-disabled=\"false\"></list>\n        </div>\n        <div class=\"inputfield\">\n            <label class=\"input-title\">Blogs / Websites</label>\n            <list list=\"interest.blogs.list\" is-disabled=\"false\"></list>\n        </div>\n        <div class=\"inputfield\">\n            <label class=\"input-title\">Projects</label>\n            <list list=\"interest.projects.list\" is-disabled=\"false\"></list>\n        </div>\n    </div>\n</div>\n");
$templateCache.put("components/content-components/input/more-details.html","<div class=\"more-details\">\n    <div class=\"description\">\n        <div class=\"inputfield\">\n            <label class=\"input-title\">Languages (Spoken)</label>\n            <input class=\"input-value\" type=\"text\" ng-model=\"detail.languages.spoken\">\n        </div>\n        <div class=\"inputfield\">\n            <label class=\"input-title\">Languages (Read / Write)</label>\n            <input class=\"input-value\" type=\"text\" ng-model=\"detail.languages.readwrite\">\n        </div>\n        <div class=\"inputfield\">\n            <label class=\"input-title\">Email Id</label>\n            <input class=\"input-value\" type=\"text\" ng-model=\"detail.emailId\">\n        </div>\n        <div class=\"inputfield\">\n            <div class=\"split-two first\">\n                <label class=\"input-title\">Contact Number</label>\n                <input class=\"input-value\" type=\"text\" ng-model=\"detail.contactNo\">\n                <!-- <input-with-plchldr placeholder=\"DD Month YYYY\"></input-with-plchldr> -->\n            </div>\n            <div class=\"split-two second\">\n                <label class=\"input-title\">Notice Period <span class=\"emphasis\">(In Months)</span></label>\n                <input class=\"input-value\" type=\"text\" ng-model=\"detail.noticeDuration\">\n                <!-- <input-with-plchldr placeholder=\"DD Month YYYY\"></input-with-plchldr> -->\n            </div>\n        </div>\n        <div class=\"inputfield\">\n            <div class=\"split-two first\">\n                <label class=\"input-title\">Current City</label>\n                <input class=\"input-value\" type=\"text\" ng-model=\"detail.currentCity\">\n                <!-- <input-with-plchldr placeholder=\"DD Month YYYY\"></input-with-plchldr> -->\n            </div>\n            <div class=\"split-two second\">\n                <label class=\"input-title\">Home Town</label>\n                <input class=\"input-value\" type=\"text\" ng-model=\"detail.homeTown\">\n                <!-- <input-with-plchldr placeholder=\"DD Month YYYY\"></input-with-plchldr> -->\n            </div>\n        </div>\n        <div class=\"inputfield\">\n            <div class=\"split-two first\">\n                <label class=\"input-title\">Current CTC <span class=\"emphasis\">(Optional)</span></label>\n                <input class=\"input-value\" type=\"text\" ng-model=\"detail.currentCtc\">\n                <!-- <input-with-plchldr placeholder=\"DD Month YYYY\"></input-with-plchldr> -->\n            </div>\n            <div class=\"split-two second\">\n                <label class=\"input-title\">Expected CTC <span class=\"emphasis\">(Optional)</span></label>\n                <input class=\"input-value\" type=\"text\" ng-model=\"detail.expectedCtc\">\n                <!-- <input-with-plchldr placeholder=\"DD Month YYYY\"></input-with-plchldr> -->\n            </div>\n        </div>\n    </div>\n</div>\n");
$templateCache.put("components/content-components/input/profile-summary.html","<div class=\"profile-summary\">\n    <div class=\"inputfield\">\n        <label class=\"input-title\">Full name</label>\n        <input class=\"input-value\" type=\"text\" ng-model=\"data.fullname\">\n    </div>\n    <div class=\"inputfield\">\n        <label class=\"input-title\">Job Title / Designation</label>\n        <input class=\"input-value\" type=\"text\" ng-model=\"data.designation\">\n    </div>\n    <div class=\"inputfield\">\n        <div class=\"split-two first\">\n            <label class=\"input-title\">Date of Birth</label>\n            <input class=\"input-value\" type=\"text\" ng-model=\"data.dateOfBirth\">\n            <!-- <input-with-plchldr placeholder=\"DD Month YYYY\"></input-with-plchldr> -->\n        </div>\n        <div class=\"split-two second\">\n            <label class=\"input-title\">Gender</label>\n            <input class=\"input-value\" type=\"text\" ng-model=\"data.gender\">\n            <!-- <input-with-plchldr placeholder=\"DD Month YYYY\"></input-with-plchldr> -->\n        </div>\n    </div>\n    <div class=\"inputfield\">\n        <div class=\"split-two first\">\n            <label class=\"input-title\">Total Experience</label>\n            <input class=\"input-value\" type=\"text\" ng-model=\"data.experienceTotal\">\n            <!-- <input-with-plchldr placeholder=\"DD Month YYYY\"></input-with-plchldr> -->\n        </div>\n        <div class=\"split-two second\">\n            <label class=\"input-title\">Relevant Experience</label>\n            <input class=\"input-value\" type=\"text\" ng-model=\"data.experienceRelevant\">\n            <!-- <input-with-plchldr placeholder=\"DD Month YYYY\"></input-with-plchldr> -->\n        </div>\n    </div>\n</div>\n");
$templateCache.put("components/content-components/input/projects-list.html","<div class=\"projects-list\">\n    <div class=\"project\" ng-repeat=\"project in projects track by $index\">\n        <div class=\"\" ng-show=\"projects.length > 0\">\n            <div class=\"index sub-index\">{{$index + 1}}</div>\n            <div class=\"underline\"></div>\n        </div>\n        <div class=\"inputfield\">\n            <label class=\"input-title\">Project name</label>\n            <input class=\"input-value\" type=\"text\" ng-model=\"project.projectName\">\n        </div>\n        <div class=\"inputfield\">\n            <label class=\"input-title\">Job Role</label>\n            <input class=\"input-value\" type=\"text\" ng-model=\"project.jobTitle\">\n        </div>\n        <div class=\"inputfield\">\n            <div class=\"split-two first\">\n                <label class=\"input-title\">Start Date</label>\n                <input class=\"input-value\" type=\"text\" ng-model=\"project.startDate\">\n                <!-- <input-with-plchldr placeholder=\"DD Month YYYY\"></input-with-plchldr> -->\n            </div>\n            <div class=\"split-two second\">\n                <label class=\"input-title\">End Date</label>\n                <input class=\"input-value\" type=\"text\" ng-model=\"project.endDate\">\n                <!-- <input-with-plchldr placeholder=\"DD Month YYYY\"></input-with-plchldr> -->\n            </div>\n        </div>\n        <div class=\"inputfield\">\n            <label class=\"input-title\">Responsibilities</label>\n            <list list=\"project.responsibilities\" is-disabled=\"false\"></list>\n        </div>\n    </div>\n</div>\n");
$templateCache.put("components/content-components/input/skill-list.html","<div class=\"skill-list\">\n    <div class=\"skill list-item\" ng-repeat=\"skill in skills track by $index\">\n        <div class=\"index\" ng-show=\"skills.length > 1\">{{$index + 1}}</div>\n        <div class=\"underline\" ng-show=\"skills.length > 1\"></div>\n        <div class=\"inputfield\">\n            <div class=\"split-two first\">\n                <label class=\"input-title\">Skill Title</label>\n                <input class=\"input-value\" type=\"text\" ng-model=\"skill.skillName\">\n                <!-- <input-with-plchldr placeholder=\"DD Month YYYY\"></input-with-plchldr> -->\n            </div>\n            <div class=\"split-two second\">\n                <label class=\"input-title\">Version Number</label>\n                <input class=\"input-value\" type=\"text\" ng-model=\"skill.versionNo\">\n                <!-- <input-with-plchldr placeholder=\"DD Month YYYY\"></input-with-plchldr> -->\n            </div>\n        </div>\n        <div class=\"inputfield\">\n            <div class=\"split-two first\">\n                <label class=\"input-title\">Total Experience</label>\n                <input class=\"input-value\" type=\"text\" ng-model=\"skill.totalExp\">\n                <!-- <input-with-plchldr placeholder=\"DD Month YYYY\"></input-with-plchldr> -->\n            </div>\n            <div class=\"split-two second\">\n                <label class=\"input-title\">Self Rating (Out of 10)</label>\n                <input class=\"input-value\" type=\"text\" ng-model=\"skill.selfRating\">\n                <!-- <input-with-plchldr placeholder=\"DD Month YYYY\"></input-with-plchldr> -->\n            </div>\n        </div>\n    </div>\n    <div class=\"inputfield\">\n        <button ng-click=\"addSkill()\" class=\"btn secondary-btn full-width\" type=\"button\" name=\"button\">Add New</button>\n    </div>\n</div>\n");
$templateCache.put("components/content-components/login/commentpanel.html","<div class=\"row\">\n    <style>\n        .addcomment {\n            font-weight: normal;\n            text-align: center;\n            text-transform: uppercase;\n        }\n    </style>\n    <div class=\"col-xs-12 col-sm-8 col-sm-offset-2 col-md-10 col-md-offset-1\" ng-controller=\"commentPanelController\">\n        <div class=\"signup-wall\">\n            <form class=\"form-signin\" name=\"registerationForm\">\n                <label class=\"addcomment full-width\" for=\"commentbox\">feeback and suggestions here</label>\n                <textarea required class=\"full-width\" name=\"commentbox\" cols=\"30\" rows=\"10\"\n                    ng-model=\"comment\"></textarea>\n                <button type=\"submit\" class=\"btn btn-lg btn-block btn-register ib-blue-bg\"\n                ng-click=\"registerationForm.$valid && addcomment()\">Submit</button>\n                <span class=\"clearfix\"></span>\n            </form>\n        </div>\n        <div class=\"alert alert-info text-center\" role=\"alert\" ng-show=\"isMessageVisible\">{{::message}}</div>\n    </div>\n</div>\n");
$templateCache.put("components/content-components/login/loginpanel.html","<div class=\"row\">\n    <div class=\"col-xs-12 col-sm-6 col-sm-offset-3 col-md-10 col-md-offset-1\">\n        <div class=\"account-wall\">\n            <div class=\"user text-center\">\n                <i class=\"fa fa-user\" aria-hidden=\"true\" style=\"font-size: 5em;\"></i>\n            </div>\n            <form class=\"form-signin\">\n                <div class=\"inputfield\">\n                    <label class=\"input-title\">User Name</label>\n                    <input type=\"text\" ng-model=\"username\" placeholder=\"\" required autofocus=\"true\">\n                </div>\n                <div class=\"inputfield\">\n                    <label class=\"input-title\">Password</label>\n                    <input type=\"password\" ng-model=\"password\" placeholder=\"\" required>\n                </div>\n                <div class=\"inputfield\">\n                    <button type=\"submit\" class=\"btn secondary-btn full-width\"\n                    ng-click=\"authenticate()\">Sign in</button>\n                </div>\n                <span class=\"clearfix\"></span>\n            </form>\n            <div class=\"form-signin\">\n                <div class=\"signup\">\n                    <p class=\"text-center\">New User</p>\n                    <a href=\"/#/signup\" class=\"text-center new-account\">\n                        <button type=\"submit\" class=\"btn primary-btn full-width\">Sign Up</button>\n                    </a>\n                </div>\n            </div>\n            <div class=\"alert alert-info text-center\" role=\"alert\" ng-show=\"isMessageVisible\">{{message}}</div>\n        </div>\n    </div>\n</div>\n");
$templateCache.put("components/content-components/login/registerpanel.html","<div class=\"row\">\n    <div class=\"col-xs-12 col-sm-6 col-sm-offset-3 col-md-10 col-md-offset-1\">\n        <div class=\"signup-wall\">\n            <div class=\"register\" ng-hide=\"hasInvite\">\n                <h3 class=\"message text-center\">\n                    <span>Get a</span>\n                    <span class=\"empahsis ib-pink-txt\" style=\"padding-left: 5px\">\n                        <i class=\"fa fa-rocket\" aria-hidden=\"true\"></i>\n                        <span>beta</span>\n                    </span>\n                    <span>&nbsp;version invite</span>\n                </h3>\n                <form class=\"form-signin\" name=\"registerationForm\">\n                    <div class=\"inputfield\">\n                        <label class=\"input-title\">Full Name</label>\n                        <input required type=\"text\" ng-model=\"data.fullname\" placeholder=\"\" autofocus=\"{{!hasInvite}}\">\n                    </div>\n                    <div class=\"inputfield\">\n                        <label class=\"input-title\">Email</label>\n                        <input required type=\"email\" ng-model=\"data.email\" placeholder=\"\">\n                    </div>\n                    <button type=\"submit\" class=\"btn btn-lg btn-primary btn-block btn-register\"\n                        ng-click=\"registerationForm.$valid && register() && fbq(\'track\', \'CompleteRegistration\');\">Register</button>\n                    <span class=\"clearfix\"></span>\n                </form>\n            </div>\n            <div class=\"alert alert-info text-center\" role=\"alert\" ng-show=\"isRegisterMessageVisible\">{{message}}</div>\n            <div class=\"invite-code\">\n                <h3 class=\"text-center\">Got invite code?</h3>\n                <form class=\"form-signin\" name=\"inviteForm\">\n                    <div class=\"inputfield\">\n                        <label class=\"input-title\">Invite Code</label>\n                        <input required type=\"text\" ng-model=\"invite.code\" placeholder=\"\" autofocus=\"{{hasInvite}}\">\n                    </div>\n                    <button type=\"submit\" class=\"btn btn-lg btn-success btn-block btn-register\"\n                        ng-click=\"inviteForm.$valid && checkInviteCode() && fbq(\'track\', \'UsedInviteCode\');\">Submit</button>\n                    <span class=\"clearfix\"></span>\n                </form>\n            </div>\n            <div class=\"alert alert-info text-center\" role=\"alert\" ng-show=\"isInviteMessageVisible\">{{message}}</div>\n        </div>\n    </div>\n</div>\n");
$templateCache.put("components/content-components/login/signuppanel.html","<div class=\"row\">\n    <div class=\"col-md-10 col-md-offset-1\">\n        <div class=\"signup-wall\">\n            <form class=\"form-signin\">\n                <div class=\"inputfield\">\n            		<label class=\"input-title\">First Name</label>\n                    <input id=\"firstname\" maxlength=\"15\" required type=\"text\" pattern=\"[A-Za-z]*\"\n                        oninvalid=\"setCustomValidity(\'Please enter only Alphabets\')\" oninput=\"try{setCustomValidity(\'\')}catch(e){}\"\n                        ng-model=\"registrationInfo.firstName\" placeholder=\"\" autofocus=\"true\">\n            	</div>\n                <div class=\"inputfield\">\n                    <label class=\"input-title\">Last Name</label>\n                    <input id=\"lastname\" maxlength=\"15\" required type=\"text\" pattern=\"[A-Za-z]*\"\n                        oninvalid=\"setCustomValidity(\'Please enter only Alphabets\')\" oninput=\"try{setCustomValidity(\'\')}catch(e){}\"\n                        ng-model=\"registrationInfo.lastName\" placeholder=\"\">\n                </div>\n                <div class=\"inputfield\">\n                    <label class=\"input-title\">Username</label>\n                    <input id=\"username\" maxlength=\"15\" required type=\"text\" pattern=\"[A-Za-z0-9]*\"\n                        oninvalid=\"setCustomValidity(\'Special characters not allowed\')\" oninput=\"try{setCustomValidity(\'\')}catch(e){}\"\n                        ng-model=\"registrationInfo.username\" placeholder=\"\">\n                </div>\n                <div class=\"inputfield\">\n                    <label class=\"input-title\">Password</label>\n                    <input required type=\"text\" ng-model=\"registrationInfo.password\" placeholder=\"\" class=\"nomargin\">\n                </div>\n                <div class=\"inputfield\">\n                    <label class=\"input-title\">Email</label>\n                    <input required type=\"email\" ng-model=\"registrationInfo.email\" placeholder=\"\"\n                        oninvalid=\"setCustomValidity(\'Please enter an email address\')\" oninput=\"try{setCustomValidity(\'\')}catch(e){}\">\n                </div>\n                <div class=\"inputfield\">\n                    <button type=\"submit\" class=\"btn secondary-btn full-width\" ng-click=\"registerUser()\">Submit</button>\n                </div>\n                <span class=\"clearfix\"></span>\n            </form>\n            <div class=\"alert alert-info text-center\" role=\"alert\" ng-show=\"isMessageVisible\">{{message}}</div>\n            <div class=\"form-signin\">\n                <div class=\"login\">\n                    <p class=\"text-center\">Already have an account</p>\n                    <a href=\"/#/login\" class=\"text-center new-account\">\n                        <button type=\"submit\" class=\"btn primary-btn full-width\">Sign In</button>\n                    </a>\n                </div>\n            </div>\n        </div>\n    </div>\n</div>\n");
$templateCache.put("components/content-components/preview/preview-resume.html","<div class=\"preview-cv\">\n    <div class=\"person-details\">\n        <h1 class=\"person-name title\">{{inputs.profile.fullname}}</h1>\n        <h3 class=\"sub-title\">{{inputs.profile.designation}} {{inputs.profile.gender ? \' | \' + inputs.profile.gender : \'\'}} {{inputs.profile.experienceTotal ? \' | \' + inputs.profile.experienceTotal + \' experience\' : \'\'}}</h3>\n        <hr>\n    </div>\n    <div class=\"career-objective\">\n        <h2 class=\"title\">Career Objective</h2>\n        <div class=\"objective description\">\n            {{inputs.objective.description}}\n        </div>\n    </div>\n    <div class=\"skills-list\">\n        <h2 class=\"title\">Skills List</h2>\n        <ul class=\"skills\">\n            <li class=\"skill\" ng-repeat=\"skill in inputs.skills.list\">\n                {{ skill | skilltext }}\n            </li>\n        </ul>\n    </div>\n    <div class=\"work-experience\">\n        <h2 class=\"title\">Work Experience</h2>\n        <div class=\"companies\">\n            <div class=\"company\" ng-repeat=\"company in inputs.companies.list\">\n                <div class=\"main-title\">\n                    {{ company | companytext }}\n                </div>\n                <div class=\"projects\">\n                    <div class=\"project\" ng-repeat=\"project in company.projects\">\n                        <div class=\"project-title\">\n                            {{ project | projecttext }}\n                        </div>\n                        <ul class=\"responsibilities\">\n                            <li class=\"responsibility\" ng-repeat=\"responsibility in project.responsibilities\">\n                                {{ responsibility.value }}\n                            </li>\n                        </ul>\n                    </div>\n                </div>\n            </div>\n        </div>\n    </div>\n    <div class=\"educations\">\n        <h2 class=\"title\">Education Summary</h2>\n        <ul class=\"educations\">\n            <li class=\"education\" ng-repeat=\"education in inputs.educations.list\">\n                {{ education | educationtext }}\n            </li>\n        </ul>\n    </div>\n    <div class=\"experiences\">\n        <h2 class=\"title\">Professional Experience</h2>\n        <ul class=\"experiences\">\n            <li class=\"experience\" ng-repeat=\"experience in inputs.experiences.list\">\n                {{ experience.description }}\n            </li>\n        </ul>\n    </div>\n    <div class=\"activities\">\n        <h2 class=\"title\">Accomplishments</h2>\n        <ul class=\"activities\">\n            <li class=\"activity\" ng-repeat=\"activity in inputs.activities.list\">\n                {{ activity.description }}\n            </li>\n        </ul>\n    </div>\n    <div class=\"interest-info\">\n        <h2 class=\"title\">Other Activities</h2>\n        <div class=\"interests\">\n            <div class=\"interest\">\n                <div class=\"main-title\">\n                    Interests / Hobbies\n                </div>\n                <ul class=\"hobbies\">\n                    <li class=\"activity\" ng-repeat=\"activity in inputs.interest.hobbies.list\">\n                        {{ activity.value }}\n                    </li>\n                </ul>\n            </div>\n            <div class=\"interest\">\n                <div class=\"main-title\">\n                    Blogs / Websites\n                </div>\n                <ul class=\"blogs\">\n                    <li class=\"blog\" ng-repeat=\"blog in inputs.interest.blogs.list\">\n                        {{ blog.value }}\n                    </li>\n                </ul>\n            </div>\n            <div class=\"interest\">\n                <div class=\"main-title\">\n                    Projects\n                </div>\n                <ul class=\"projects\">\n                    <li class=\"project\" ng-repeat=\"project in inputs.interest.projects.list\">\n                        {{ project.value }}\n                    </li>\n                </ul>\n            </div>\n        </div>\n    </div>\n</div>\n");}]);
angular.module('homepage').
run(function($rootScope, $state, $timeout, Authentication) {
    $rootScope.isVisible = {
        loading: false
    };
    $rootScope.currentRoute = {
        name: ''
    };
    $rootScope.$on("$stateChangeStart", function(event, toState, toParams, fromState, fromParams) {
        $rootScope.isVisible.loading = true;
        if (toState.name == 'login' && Authentication.isAuthenticated()) {
            // User is authenticated
            $rootScope.currentRoute.name = "inputbasic";
            $state.transitionTo("inputbasic");
            event.preventDefault();
        }
        else if (toState.authenticate && !Authentication.isAuthenticated()) {
            // User isn’t authenticated
            $rootScope.currentRoute.name = "login";
            $state.transitionTo("login");
            event.preventDefault();
        }
        else if (!toState.authenticate) {
            $rootScope.currentRoute.name = toState.name;
        }
    });
    $rootScope.$on("$viewContentLoaded", function () {
        $timeout(function () {
            $rootScope.isVisible.loading = false;
        }, 1000);
    });
}).
config(function($stateProvider, $urlRouterProvider) {
    $urlRouterProvider.otherwise('/start');
    $stateProvider.
        // INDEX STATES  ========================================
        state('start', {
            url: '/start',
            templateUrl: '../../html/partials/partial-index.html',
            authenticate: false
        }).
        // LOGIN ROUTES  ========================================
        state('login', {
            url: '/login',
            templateUrl: '../../html/partials/partial-login.html',
            authenticate: false
        }).
        state('signup', {
            url: '/signup',
            templateUrl: '../../html/partials/partial-signup.html',
            authenticate: false
        }).
        state('register', {
            url: '/register',
            templateUrl: '../../html/partials/partial-register.html',
            authenticate: false
        }).
        // FEATURE ROUTES  ========================================
        state('inputbasic', {
            url: '/input/basic',
            templateUrl: '../../html/partials/partial-input-basic.html',
            authenticate: true,
            controller: 'InputBasicController'
        }).
        state('inputexperience', {
            url: '/input/experience',
            templateUrl: '../../html/partials/partial-input-experience.html',
            authenticate: true,
            controller: 'InputExperienceController'
        }).
        state('inputextras', {
            url: '/input/extras',
            templateUrl: '../../html/partials/partial-input-extras.html',
            authenticate: true,
            controller: 'InputExtrasController'
        }).
        state('download', {
            url: '/download',
            templateUrl: '../../html/partials/partial-download.html',
            authenticate: true,
            controller: 'DownloadController'
        }).
        state('print', {
            url: '/print',
            templateUrl: '../../html/partials/partial-print.html',
            authenticate: true,
            controller: 'PrintController'
        });
});

angular.module('homepage').
factory('Server', function($http) {
    return {
    	// USER
        login   : function(user) {
            return $http.post('/auth/user/login', user);
        },
        logout  : function() {
            return $http.get('/auth/user/logout');
        },
        register: function(data) {
            return $http.post('/auth/user/register', data);
        },
        signup: function(data) {
            return $http.post('/auth/user/signup', data);
        },
        // DOWNLOAD
        downloadDocx: function (data) {
            return $http.post('/api/download/docx', data, {responseType:'arraybuffer'});
        },
        downloadRtf: function (data) {
            return $http.post('/api/download/rtf', data);
        },
        // RESUME
        saveResumeData: function (data) {
            return $http.post('/api/resume/save', data);
        }
    };
});

angular.module('homepage').
factory('DownloadFile', function () {
    function getPlainText(filename, content) {
        var filetype = 'plain/text';
        var hrefContent = 'data:' + filetype + ';charset=utf-8,' + encodeURIComponent(content);
        downloadLink(filename, hrefContent);
    }

    function getDocxFile(filename, content) {
        const docxMimeType = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
        var blob = new Blob([content], {'type': docxMimeType});
        var hrefContent = URL.createObjectURL(blob);

        downloadLink(filename, hrefContent);
    }

    function downloadLink(filename, hrefContent) {
        var element = document.createElement('a');
        element.setAttribute('href', hrefContent);
        element.setAttribute('download', filename);

        element.style.display = 'none';
        document.body.appendChild(element);

        element.click();

        document.body.removeChild(element);
    }

    return {
        getPlainText: getPlainText,
        getDocxFile: getDocxFile
    };
});

angular.module('homepage').
factory('Authentication', function($http, $localStorage, $rootScope) {
    var _user = {};

    function urlBase64Decode(str) {
        var output = str.replace('-', '+').replace('_', '/');
        switch (output.length % 4) {
            case 0:
                break;
            case 2:
                output += '==';
                break;
            case 3:
                output += '=';
                break;
            default:
                throw 'Illegal base64url string!';
        }
        return window.atob(output);
    }

    function getUserFromLocalStorage() {
        var token = $localStorage.token;
        var user = {};
        if (typeof token !== 'undefined') {
            var encoded = token.split('.')[1];
            user = JSON.parse(urlBase64Decode(encoded));
        }
        return user;
    }

    function removeUserFromLocalStorage() {
        delete $localStorage.token;
    }

    function getUser() {
        _user = getUserFromLocalStorage();
        return _user;
    }

    function setUser(token) {
        if(token) {
            $localStorage.token = token;
            $rootScope.userDtls = getUser();
            $rootScope.isAuthenticated = true;
        }
    }

    function removeUser() {
        removeUserFromLocalStorage();
        $rootScope.userDtls = {};
        $rootScope.isAuthenticated = false;
        _user = {};
    }

    function isAuthenticated() {
        return $rootScope.userDtls && $rootScope.userDtls.username !== undefined ? true : false;
    }

    function setHeaders() {
        // Set the token as header for your requests!
        $http.defaults.headers.common['X-Auth-Token'] = $localStorage.token;
    }

    return {
        getUser: getUser,
        setUser: setUser,
        removeUser: removeUser,
        isAuthenticated: isAuthenticated,
        setHeaders: setHeaders
    };
});

angular.module('homepage').
factory('CodeConvertSrvc', function () {
    var codes = {
        // FINANCE
        'PMNT'  : 'Payment',
    };

    function getValue(code) {
        if(codes[code]) {
            return codes[code];
        }
        else {
            return '';
        }
    }

    return {
        getValue: getValue
    };
});

angular.module('homepage').
factory('DataStorage', function () {
    var InputTemplate = {
        "profile": {
            "title": "Profile Summary",
            "fullname": "",
            "designation": "",
            "dateOfBirth": "",
            "experienceTotal": "",
            "experienceRelevant": "",
            "gender": ""
        },
        "companies": {
            "title": "Work Experience",
            "list": [
                {
                    "companyName": "",
                    "jobTitle": "",
                    "startDate": "",
                    "endDate": "",
                    "projects": [
                        
                    ]
                }
            ]
        },
        "educations": {
            "title": "Education Summary",
            "list": [
                {
                    "educationTitle": "",
                    "studiedFrom": "",
                    "startDate": "",
                    "endDate": "",
                    "specialization": "",
                    "score": ""
                }
            ]
        },
        "skills": {
            "title": "Skills List",
            "list": [
                {
                    "skillName": "",
                    "totalExp": "",
                    "versionNo": "",
                    "studiedFrom": "",
                    "selfRating": ""
                }
            ]
        },
        "experiences": {
            "title": "Professional Experience",
            "list": [
                { "description": ""}
            ]
        },
        "activities": {
            "title": "Accomplishments",
            "list":  [
                { "description": "" }
            ]
        },
        "objective": {
            "title": "Career Objective",
            "description": ""
        },
        "detail": {
            "title": "More Details",
            "languages": {
                "spoken": "",
                "readwrite": ""
            },
            "emailId": "",
            "contactNo": "",
            "noticeDuration": "",
            "currentCity": "",
            "homeTown": "",
            "currentCtc": "",
            "expectedCtc": ""
        },
        "interest": {
            "title": "Other Activities",
            "hobbies": {
                "title": "Interests / Hobbies",
                "list": [
                    { "value": "" }
                ]
            },
            "blogs": {
                "title": "Blogs / Websites",
                "list": [
                    { "value": "" }
                ]
            },
            "projects": {
                "title": "Projects",
                "list": [
                    { "value": "" }
                ]
            }
        }
    };

    var InputData = {
        "profile": {
			"title": "Profile Summary",
            "fullname": "Jagdeep Singh Bisht",
            "designation": "Senior Software Engineer",
            "dateOfBirth": "20 Mar 1990",
            "experienceTotal": "7 years",
			"experienceRelevant": "7 years",
            "gender": "Male"
        },
        "companies": {
			"title": "Work Experience",
			"list": [
	            {
	                "companyName": "IBM",
	                "jobTitle": "Trainee Software Engineer",
	                "startDate": "Sept 2011",
	                "endDate": "Mar 2012",
	                "projects": [
	                    {
	                        "projectName": "IBM Cúram Workers Compensation",
	                        "jobTitle": "Trainee Software Engineer",
	                        "startDate": "Sept 2011",
	                        "endDate": "Mar 2012",
							"responsibilities": [
								{ "value": "Working very hard irrespective of task assigned" },
								{ "value": "Smartly led the task to completion" }
							]
	                    },
	                    {
	                        "projectName": "IBM Cúram Child Care",
	                        "jobTitle": "Associate Software Engineer",
	                        "startDate": "Apr 2012",
	                        "endDate": "Aug 2012",
							"responsibilities": [
								{ "value": "Working very hard irrespective of task assigned" },
								{ "value": "Smartly led the task to completion" }
							]
	                    },
	                    {
	                        "projectName": "IBM Cúram Income Support",
	                        "jobTitle": "Software Engineer",
	                        "startDate": "Sept 2012",
	                        "endDate": "Jun 2015",
							"responsibilities": [
								{ "value": "Working very hard irrespective of task assigned" },
								{ "value": "Smartly led the task to completion" }
							]
	                    }
	                ]
	            },
	            {
	                "companyName": "Amadeus",
	                "jobTitle": "Senior Software Engineer",
	                "startDate": "Jun 2015",
	                "endDate": "Aug 2017",
	                "projects": [
	                    {
	                        "projectName": "Air China",
	                        "jobTitle": "UI Developer",
	                        "startDate": "Sept 2011",
	                        "endDate": "Mar 2012",
							"responsibilities": [
								{ "value": "Working very hard irrespective of task assigned" },
								{ "value": "Smartly led the task to completion" }
							]
	                    },
	                    {
	                        "projectName": "IBM Cúram Child Care",
	                        "jobTitle": "UI Developer",
	                        "startDate": "Apr 2012",
	                        "endDate": "Aug 2012",
							"responsibilities": [
								{ "value": "Working very hard irrespective of task assigned" },
								{ "value": "Smartly led the task to completion" }
							]
	                    }
	                ]
	            }
	        ]
		},
        "educations": {
			"title": "Education Summary",
			"list": [
	            {
	                "educationTitle": "B.E",
	                "studiedFrom": "Bangalore Coll. of Engg. & Tech",
	                "startDate": "Aug 2006",
	                "endDate": "Jun 2010",
	                "specialization": "Computer Science",
	                "score": "100"
	            },
	            {
	                "educationTitle": "12th",
	                "studiedFrom": "Kendriya Vidyalaya A.S.C Centre",
	                "startDate": "Apr 2005",
	                "endDate": "Jun 2006",
	                "specialization": "Computer Science",
	                "score": "100"
	            },
	            {
	                "educationTitle": "10th",
	                "studiedFrom": "Kendriya Vidyalaya A.S.C Centre",
	                "startDate": "Apr 2003",
	                "endDate": "Jun 2004",
	                "specialization": "Computer Science",
	                "score": "100"
	            }
	        ]
		},
        "skills": {
			"title": "Skills List",
			"list": [
	            {
	                "skillName": "Java",
	                "totalExp": "2 years",
	                "versionNo": "7",
	                "studiedFrom": "Online",
	                "selfRating": "7"
	            },
	            {
	                "skillName": "Java",
	                "totalExp": "2 years",
	                "versionNo": "7",
	                "studiedFrom": "Online",
	                "selfRating": "7"
	            }
	        ]
		},
        "experiences": {
			"title": "Professional Experience",
			"list": [
	            { "description": "Experience of using javascript OOP" },
	            { "description": "Very highly experienced in killing time"},
	            { "description": "Can play guitar at times"},
	            { "description": "Highly proficient in cooking non-edible items"}
	        ]
		},
        "activities": {
			"title": "Accomplishments",
			"list":  [
	            { "description": "Got Pinkies number" },
	            { "description": "Healed frodo when he was stabbed" }
	        ]
		},
        "objective": {
			"title": "Career Objective",
            "description": "Wanna rock the world with my amazing products and world changing ideas. Great fan of lean principles. Still trying to understand how to best implement the same."
        },
		"detail": {
			"title": "More Details",
			"languages": {
				"spoken": "English, Hindi, Kannada",
				"readwrite": "English, Hindi"
			},
			"emailId": "hello@jsbisht.in",
			"contactNo": "9743012345",
			"noticeDuration": "2 months",
			"currentCity": "Bangalore",
			"homeTown": "Dehradun",
			"currentCtc": "10 Lac INR",
			"expectedCtc": "20 Lac INR"
		},
		"interest": {
			"title": "Other Activities",
			"hobbies": {
				"title": "Hobbies",
				"list": [
					{ "value": "Table Tennis" },
					{ "value": "Running" },
					{ "value": "Badminton" },
					{ "value": "Volleyball" }
				]
			},
			"blogs": {
				"title": "Blogs / Websites",
				"list": [
					{ "value": "jsbisht.in" },
					{ "value": "inputbox.co" }
				]
			},
			"projects": {
				"title": "Projects",
				"list": [
					{ "value": "Creepy Chat" },
					{ "value": "Inputbox" },
					{ "value": "Preaching Mommy" },
					{ "value": "About Me" }
				]
			}
		}
    };

    return {
        'InputTemplate': InputTemplate,
        'InputData': InputData
    }
 });
angular.module('homepage').
factory('DataStoreSrvc', function ($localStorage, DataStorage) {
	/**
	 * Store all the data received till now from the server
	 */
	var DataStore = {
		inputs: {}
	};;

	if($localStorage.inputs) {
		DataStore['inputs'] = JSON.parse($localStorage.inputs);
	}
	else {
		DataStore['inputs'] = DataStorage.InputTemplate;
	}

	function getInputData() {
		return DataStore.inputs;
	}

	return {
		getInputData: getInputData
	};
});

angular.module('homepage').
factory('ReadJsonSrvc', function ($http) {
    function readJson(filename) {
        return $http.get('../../../json/' + filename + '.json');
    }

    return {
        readJson: readJson
    };
});

angular.module('homepage').
factory('Activity', function () {
	function Activity() {
		this.description = null;
	}

	return Activity;
});

angular.module('homepage').
factory('Company', function () {
	function Company() {
		this.companyName = null;
        this.jobTitle = null;
        this.startDate = null;
        this.endDate = null;
        this.projects = [];
	}

	return Company;
});

angular.module('homepage').
// Store templates, location and widget data
factory('Education', function () {
	function Education() {
		this.educationTitle = null;
        this.studiedFrom = null;
        this.startDate = null;
        this.endDate = null;
        this.specialization = null;
		this.score = null;
	}

	return Education;
});

angular.module('homepage').
factory('Experience', function () {
	function Experience() {
		this.description = null;
	}

	return Experience;
});

angular.module('homepage').
factory('Project', function () {
    function Project() {
        this.projectName = null;
        this.jobTitle = null;
        this.startDate = null;
        this.endDate = null;
        this.responsibilities = [{
            value: ''
        }];
    }

    return Project;
});

angular.module('homepage').
factory('Skill', function () {
	function Skill() {
		this.skillName = null;
        this.totalExp = null;
        this.versionNo = null;
        this.studiedFrom = null;
        this.selfRating = null;
	}

	return Skill;
});

angular.module('homepage').
// Store templates, location and widget data
factory('Structs', function ($rootScope, DataStoreSrvc, GlobalDataService, Server) {
	function DateRange() {
		return {
			start: null,
			end: null
		}
	}

	return {
		DateRange: DateRange
	}
});
angular.module('homepage').
factory('ArrayUtility', function() {
    return {
        reassignArray: reassignArray
    };

    /**
     * Reassign new array to original array preserving the original array reference
     */
    function reassignArray(originalArray, newArray) {
    	// Empty original array keeping the original reference
    	originalArray.length = 0;
    	// Add all items of new array to original array
    	// originalArray.concat(newArray);  This doesnt work with object arrays
        for(var index in newArray) {
            var item = newArray[index];
            originalArray.push(item);
        }

    	return originalArray;
    }
});

angular.module('homepage').
factory('DateUtility', function() {
    var monthShort = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];

    return {
        getTimeStr: getTimeStr,
        getDateStr: getDateStr,
        getDateOnly: getDateOnly,
        getDateEnd: getDateEnd,
        getMonthDateRange: getMonthDateRange,
        getGmtTimestamp: getGmtTimestamp,
        newDateSameRef: newDateSameRef,
        compareDateOnly: compareDateOnly,
        isBetweenDates: isBetweenDates
    }

    /**
     * Get time from date as string
     * @param  {Date} date Date object/Timestamp
     * @return {string}      Time as string 'hh:mm:ss am/pm'
     */
    function getTimeStr(date) {
			date = new Date(date) || new Date();
			var hours = date.getHours();
			var minutes = date.getMinutes();
			var seconds = date.getSeconds();
			var ampm = hours >= 12 ? 'pm' : 'am';
			hours = hours % 12;
			hours = hours ? hours : 12; // the hour '0' should be '12'
			minutes = minutes < 10 ? '0' + minutes : minutes;
			seconds = seconds < 10 ? '0' + seconds : seconds;
			var strTime = hours + ':' + minutes + ':' + seconds + ' ' + ampm;
			return strTime;
		}

    /**
     * Get date from date as string
     * @param  {Date} date Date object/Timestamp
     * @return {string}      Date as string 'dd MMM yyyy'
     */
	function getDateStr(date) {
		date = new Date(date) || new Date();
		return date.getDate() + ' ' + monthShort[date.getMonth()] + ' ' + date.getFullYear();
	}

    /**
     * Get date only with time part set to zero
     * @param  {Date} date Date object/Timestamp
     * @return {Date}      Date object
     */
    function getDateOnly(date) {
    	date = new Date(date);
    	return new Date(date.setHours(0,0,0,0));
    }

    /**
     * Get date only with time part set to zero
     * @param  {Date} date Date object/Timestamp
     * @return {Date}      Date object
     */
    function getDateEnd(date) {
        date = new Date(date);
        return new Date(date.setHours(23,59,59,999));
    }

    function getMonthDateRange(date) {
        date = new Date(date);
        var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
        var lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);
        return {
            start: getDateOnly(firstDay),
            end: getDateEnd(lastDay)
        };
    }

    /**
     * Convert timestamp from local timezone to GMT
     * @param  {Date} date Date/Timestamp
     * @return {Number}      Timestamp in GMT
     */
    function getGmtTimestamp(date) {
        if(!date) {
            date = new Date();
        }
        // Timestamp in client time zone
        var timestamp = new Date(date).getTime();
        var offset = new Date().getTimezoneOffset(); // in minutes
        // Convert local time to GMT
        // TODO add or substract based on the offset value
        timestamp = timestamp + (offset * 60 * 1000);
        return timestamp;
    }

    /**
     * Get latest date keeping the refrence of the passed date object
     * @param  {Date} date Date object/Timestamp
     * @return {Date}      Date object
     */
    function newDateSameRef(date) {
        date = new Date(date);
        date.setTime(new Date().getTime());
        return date;
    }

    /**
     * Compare dates without comparing time
     * @param  {Date} date1 Date object/Timestamp
     * @param  {Date} date2 Date object/Timestamp
     * @return {Number}     Difference in dates after setting time to zero
     */
    function compareDateOnly(date1, date2) {
    	date1 = getDateOnly(date1);
    	date2 = getDateOnly(date2);

    	var oneday = 24*60*60*1000; // hours*minutes*seconds*milliseconds
    	var diff   = (date1.getTime() - date1.getTime())/ oneday;

    	return diff;
    }

    /**
     * Check if the given date falls between from and to date
     * @param  {Date}  date            Date to be compared
     * @param  {Date}  fromDate        From Date
     * @param  {Date}  toDate          To Date
     * @param  {Boolean} isFromInclusive Is from date inclusive
     * @param  {Boolean} isToInclusive   Is to date inclusive
     * @return {Boolean}                 [description]
     */
    function isBetweenDates(date, fromDate, toDate, isFromInclusive, isToInclusive) {
        var isWithinRange = false;

        date        = new Date(date);
        fromDate    = getDateOnly(fromDate);
        toDate      = getDateEnd(toDate);

        if(isFromInclusive && isToInclusive) {
            isWithinRange = date >= fromDate && date <= toDate;
        }
        else if(isFromInclusive) {
            isWithinRange = date >= fromDate && date < toDate;
        }
        else if(isToInclusive) {
            isWithinRange = date > fromDate && date <= toDate;
        }
        else {
            isWithinRange = date > fromDate && date < toDate;
        }

        return isWithinRange;
    }

});

angular.module('homepage').
factory('StringUtility', function() {
    return {
        getPartsOfString: getPartsOfString,
        stringToBoolean: stringToBoolean
    }

    /**
     * SPLIT the following string into three parts
     * @param text
     * @returns [part1, part2, part3]
     */
    // TEST INPUTS
    // var text = 'eventType, attributeName, value';
    // var text = '[eventType1, eventType2, ..., eventTypeN], attributeName, value';
    // var text = 'eventType, [attributeName1, attributeName2, ..., attributeNameN], value';
    // var text = 'eventType, attributeName, [value1, value2, ..., valueN]';
    // var text = 'eventType, [attributeName1, attributeName2, ..., attributeNameN], [value1, value2, ..., valueN]';
    // var text = '[eventType1, eventType2, ..., eventTypeN], [attributeName1, attributeName2, ..., attributeNameN], [value1, value2, ..., valueN]';

    function getPartsOfString(text) {
        // if no square bracket found, split by comma
        // else parse each part
        //      find comma separated part or square bracket part
        var parts = [];
        if(text.indexOf('[') > -1) {
            return findPart(parts, text);
        }
        else {
            return parts = text.split(',');
        }
    }
    /**
     * Recursively find parts of strings
     * @param parts, text
     * @return [part1, part2, part3]
     */
    function findPart(parts, text) {
        text = text.trim();
        var indexOfComma = text.indexOf(',');
        var indexOfOpenBracket = text.indexOf('[');

        if(text.length != 0) {
            // if part doesn't contain bracket
            if(text.indexOf('[') == -1) {
                var indexOfPartEnd = indexOfComma > -1 ? indexOfComma : text.trim().length;
                parts.push(text.substring(0, indexOfPartEnd));
                findPart(parts, text.substring(indexOfPartEnd + 1));
            }
            // if part contains bracket
            else if(indexOfComma > indexOfOpenBracket) {
                var indexOfCloseBracket = text.indexOf(']');
                var partStr = text.substring(indexOfOpenBracket + 1, indexOfCloseBracket);
                var partParts = partStr.split(',');
                parts.push(partParts);
                findPart(parts, text.substring(indexOfCloseBracket + 2));
            }
            else if(indexOfComma < indexOfOpenBracket) {
                parts.push(text.substring(0, indexOfComma));
                findPart(parts, text.substring(indexOfComma + 1));
            }
        }

        return parts;
    }

    // convert value to boolean from string if string contains 'true' or 'false' value
    function stringToBoolean(string){
        switch(string.toLowerCase().trim()){
            case "true": case "yes": case "1": return true;
            case "false": case "no": case "0": case null: return false;
        }
        return string;
    }
});

angular.module('homepage').
service('BrowserType', function($window) {
	return function() {
		var userAgent = $window.navigator.userAgent;
		var browsers = {chrome: /chrome/i, safari: /safari/i, firefox: /firefox/i, ie: /internet explorer/i};
		for(var key in browsers) {
			if (browsers[key].test(userAgent)) {
				return key;
			}
		};
		return 'unknown';
	}
}).
service('MobileType', function () {
	return {
		Android: function() {
			return navigator.userAgent.match(/Android/i);
		},
		BlackBerry: function() {
			return navigator.userAgent.match(/BlackBerry/i);
		},
		iOS: function() {
			return navigator.userAgent.match(/iPhone|iPad|iPod/i);
		},
		Opera: function() {
			return navigator.userAgent.match(/Opera Mini/i);
		},
		Windows: function() {
			return navigator.userAgent.match(/IEMobile/i) || navigator.userAgent.match(/WPDesktop/i);
		},
		any: function() {
			// TODO make width as 480
			var isWidthLessThanDesktop = window.innerWidth < 600;
			return (this.Android() || this.BlackBerry() || this.iOS() || this.Opera() || this.Windows() || isWidthLessThanDesktop);
		}
	};
});

angular.module('homepage').
directive('autocomplete', function($timeout) {
    return {
        controller: 'autocompleteController',
        restrict: 'E',
        replace: true,
        scope: {
            choices: '=',
            enteredtext: '=',
            minlength: '=',
            result: '=',
            type: '=',
            onselect: '&'
        },
        templateUrl: 'components/common-components/autocomplete/autocomplete.html'
    };
}).
controller('autocompleteController', function($scope, $timeout) {
    $scope.filteredChoices = [];
    $scope.isVisible = {
        suggestions: false
    };

    $scope.filterItems = function () {
        if($scope.enteredtext && $scope.minlength <= $scope.enteredtext.length) {
            $scope.filteredChoices = querySearch($scope.enteredtext);
            $scope.isVisible.suggestions = $scope.filteredChoices.length > 0 ? true : false;
        }
        else {
            $scope.isVisible.suggestions = false;
        }
    };

    /**
    * Takes one based index to save selected choice object
    */
    $scope.selectItem = function (index) {
        $scope.result = {'chosen': $scope.choices[index - 1], 'type': $scope.type};
        $scope.enteredtext = $scope.result.chosen.label;
        $scope.isVisible.suggestions = false;
        $timeout(function () {
            $scope.$apply();
            if($scope.onselect) {
                $scope.onselect();
            }
        });
    };

    /**
    * Search for states... use $timeout to simulate
    * remote dataservice call.
    */
    function querySearch (query) {
        if(!$scope.choices) return [];
        // returns list of filtered items
        return  query ? $scope.choices.filter( createFilterFor(query) ) : [];
    }

    /**
    * Create filter function for a query string
    */
    function createFilterFor(query) {
        var lowercaseQuery = angular.lowercase(query);

        return function filterFn(item) {
            // Check if the given item matches for the given query
            var label = angular.lowercase(item.label);
            return (label.indexOf(lowercaseQuery) === 0);
        };
    }
});

angular.module('homepage').
directive('checkbox', function () {
    return {
        controller: 'checkboxController',
        restrict: 'E',
        replace: true,
        scope: {
            label: '=',
            name: '=',
            isChecked: '=',
            markCheckboxFn: '&'
        },
        transclude: true,
        templateUrl: 'components/common-components/checkbox/checkbox.html'
    }
}).
controller('checkboxController', function ($scope) {
    // Setting default value for the checkbox
    $scope.checked = $scope.checked ? $scope.checked : false;
});

angular.module('homepage').
directive('editor', function () {
    return {
        controller: 'EditorController',
        restrict: 'E',
        replace: true,
        scope: {
            note: '=',
            isEditable: '='
        },
        transclude: true,
        templateUrl: 'components/common-components/editor/editor.html'
    };
}).
controller('EditorController', function ($scope) {
    $scope.handlePaste = function (event) {
        //event.preventDefault();
        //event.stopPropagation();
        // var plaintext = event.originalEvent.clipboardData.getData('text/plain');
        // document.execCommand('inserttext', false, plaintext);
    };
});

angular.module('homepage').
directive('list', function($compile, $timeout, RecursionHelper) {
    return {
        compile: ListCompile,
        controller: 'ListController',
        link: ListLinker,
        replace: true,
        restrict: 'E',
        scope: {
            list: '=',
            isDisabled: '='
        },
        templateUrl: 'components/common-components/list/list.html'
    };

    function ListLinker(scope, element, attribute) {
        $timeout(function() {});
    }

    function ListCompile(element) {
        // Use the compile function from the RecursionHelper,
        // And return the linking function(s) which it returns
        return RecursionHelper.compile(element);
    }
}).
directive('listitem', function($compile, $timeout) {
    return {
        // attributes are passed into the isolate scope of the directive
        // and manipulated via the controller method passed into the isolate scope
        link: ListItemLinker,
        replace: true,
        restrict: 'E',
        scope: {
            list: '=',
            isDisabled: '=',
            itemindex: '=',
            setList: '&'
        },
        template: '<div class="listitem"><label class="listitem-index">{{itemindex.index + 1}}.</label><input class="input-field" type="text" ' +
            'ng-disabled="isDisabled" ng-model="list[itemindex.index].value"/></div>'
    };

    function ListItemLinker(scope, element, attribute) {
        element.on('keyup', function(event) {
            event.stopPropagation();
            var code = event.keyCode || event.which;
            var itemindex = scope.itemindex.index;
            if(code == 13) {
                scope.setList();
                $timeout(function() {
                    scope.$apply();
                });
            }
        });
    }
}).
controller('ListController', function($scope, ListHelper) {
    var list = [
        {
            value: ''
        }
    ];
    // initialize list only if creating a list
    if($scope.list === undefined) {
        $scope.list = angular.copy(list);
    }
    $scope.setList = function(itemindex) {
        var newitemindex = parseInt(itemindex) + 1;
        var itemvalue = $scope.list[itemindex].value;
        if(itemvalue !== undefined && typeof newitemindex == 'number') {
            var listsize = $scope.list.length;
            var item = {
                value: ''
            };
            var isStartOfList = ListHelper.isCreatingList(itemvalue);
            if(false && isStartOfList) {
                // If last item of the list add one item to list end, before appending list
                $scope.list.push(item);
                $scope.list[itemindex].list = angular.copy(list);
            }
            else {
                if(newitemindex == listsize){
                    $scope.list.push(item);
                }
                else {
                    // Insert item in between the array
                    // insert at new index, remove 0, item to be inserted
                    $scope.list.splice(newitemindex, 0, item);
                }
            }
        }
    };
}).
factory('ListHelper', function() {
    return {
        // Check if line ends with '::'
        isCreatingList: function(line) {
            line = line + '';
            line = line.trim();

            if(line.charAt(line.length - 1) == ':') {
                if(line.charAt(line.length - 2) == ':') {
                    return true;
                }
            }

            return false;
        }
    };
}).
factory('RecursionHelper', function($compile){
    return {
        /**
         * Manually compiles the element, fixing the recursion loop.
         * @param element
         * @param [link] A post-link function, or an object with function(s) registered via pre and post properties.
         * @returns An object containing the linking functions.
         */
        compile: function(element, link){
            // Normalize the link parameter
            if(angular.isFunction(link)){
                link = { post: link };
            }

            // Break the recursion loop by removing the contents
            var contents = element.contents().remove();
            var compiledContents;
            return {
                pre: (link && link.pre) ? link.pre : null,
                /**
                 * Compiles and re-adds the contents
                 */
                post: function(scope, element){
                    // Compile the contents
                    if(!compiledContents){
                        compiledContents = $compile(contents);
                    }
                    // Re-add the compiled contents to the element
                    compiledContents(scope, function(clone){
                        element.append(clone);
                    });

                    // Call the post-linking function, if any
                    if(link && link.post){
                        link.post.apply(null, arguments);
                    }
                }
            };
        }
    };
});

angular.module('homepage').
directive('title', function () {
	return {
		restrict: 'E',
		replace: true,
		scope: {
			// placeholderTitle
			title: '='
		},
		templateUrl: 'components/common-components/title/title.html'
	}
});

angular.module('homepage').
directive('drawerMenu', function () {
	return {
		controller: 'drawerMenuController',
		link: showDrawerLinker,
		restrict: 'E',
		templateUrl: 'components/content-components/drawer/drawer-menu.html'
	}

	function showDrawerLinker(scope, element, attribute) {
		scope.$on('$destroy', function () {
	    	document.querySelector("body").classList.add('noscroll');
	  	});
	}
}).
controller('drawerMenuController', function ($scope) {
	var bodyElement = document.querySelector("body");
	$scope.isPanelVisible = false;
	$scope.showDrawer = function () {
		$scope.isPanelVisible = true;
		bodyElement.classList.add('noscroll');
	};
	$scope.hideDrawer = function () {
		$scope.isPanelVisible = false;
		bodyElement.classList.remove('noscroll');
	};
	$scope.toggleDrawer = function () {
		$scope.isPanelVisible = !$scope.isPanelVisible;
		bodyElement.classList.toggle('noscroll');	
	}
});

angular.module('homepage').
directive('footer', function () {
    return {
        restrict: 'E',
        replace: true,
        transclude: true,
        templateUrl: 'components/content-components/footer/footer.html'
    }
});

angular.module('homepage').
directive('headerMenu', function() {
    return {
        restrict: 'E',
        replace: true,
        transclude: true,
        templateUrl: 'components/content-components/header/header-menu.html',
        controller: 'loginController'
    }
}).
controller('loginController', function($scope, $window, Authentication, Server) {
    $scope.login = function() {
        Server.fblogin().
        success(function(data) {
            console.log(data);
        });
    };
    $scope.logout = function() {
        Server.logout().
        success(function(data) {
            Authentication.removeUser();
            $window.location.href = '/#/';
        });
    };
});
angular.module('homepage').
directive('header', function () {
    return {
    	controller: 'HeaderController',
        restrict: 'E',
        replace: true,
        transclude: true,
        templateUrl: 'components/content-components/header/header.html'
    };
}).
controller('HeaderController', function ($scope, $state, $rootScope, $window, Authentication) {
    $scope.loadDefaultPage = function () {
        if($rootScope.currentRoute.name == "demo") {
            $state.go("start");
        }
        else if($rootScope.isAuthenticated) {
            $window.location.href = '/#/home';
        }
        else {
            $state.go("start");
        }
    };
});

angular.module('homepage').
directive('home', function () {
    return {
        restrict: 'E',
        replace: true,
        transclude: true,
        templateUrl: 'components/content-components/home/home.html'
    }
});
/*.
controller('HomeController', function($scope, $rootScope, Authentication) {
    $scope.getUser = function() {
        $rootScope.userDtls = Authentication.getUser();
        $rootScope.isAuthenticated = Authentication.isAuthenticated();
    }
});*/

angular.module('homepage').
directive('activityList', function() {
    return {
        restrict: 'E',
        replace: true,
        scope: {
            activities: '=data'
        },
        templateUrl: 'components/content-components/input/activity-list.html',
        controller: 'activityListController'
    };
}).
controller('activityListController', function($scope, Activity) {
    if(!$scope.activities || $scope.activities.length === 0) {
        $scope.activities = [];
        $scope.activities[0] = new Activity();
    }

    $scope.addActivity = function () {
        var length = $scope.activities.length;
        $scope.activities[length] = new Activity();
    };
});

angular.module('homepage').
directive('careerObjective', function() {
    return {
        restrict: 'E',
        replace: true,
        scope: {
            objective: '=data'
        },
        templateUrl: 'components/content-components/input/career-objective.html',
        controller: 'careerObjectiveController'
    };
}).
controller('careerObjectiveController', function($scope) {
    
});

angular.module('homepage').
directive('companyList', function() {
    return {
        restrict: 'E',
        replace: true,
        scope: {
            companies: '=data'
        },
        templateUrl: 'components/content-components/input/company-list.html',
        controller: 'companyListController'
    };
}).
controller('companyListController', function($scope, Company, Project) {
    if(!$scope.companies || $scope.companies.length === 0) {
        $scope.companies = [];
        $scope.companies[0] = new Company();
    }

    $scope.addProject = function (index) {
        var length = $scope.companies[index].projects.length;
        $scope.companies[index].projects[length] = new Project();
    };

    $scope.addCompany = function () {
        var length = $scope.companies.length;
        $scope.companies[length] = new Company();
    };
});

angular.module('homepage').
directive('educationList', function() {
    return {
        restrict: 'E',
        replace: true,
        scope: {
            educations: '=data'
        },
        templateUrl: 'components/content-components/input/education-list.html',
        controller: 'educationListController'
    };
}).
controller('educationListController', function($scope, Education) {
    if(!$scope.educations || $scope.educations.length === 0) {
        $scope.educations = [];
        $scope.educations[0] = new Education();
    }

    $scope.addEducation = function () {
        var length = $scope.educations.length;
        $scope.educations[length] = new Education();
    };
});

angular.module('homepage').
directive('experienceList', function() {
    return {
        restrict: 'E',
        replace: true,
        scope: {
            experiences: '=data'
        },
        templateUrl: 'components/content-components/input/experience-list.html',
        controller: 'experienceListController'
    };
}).
controller('experienceListController', function($scope, Experience) {
    if(!$scope.experiences || $scope.experiences.length === 0) {
        $scope.experiences = [];
        $scope.experiences[0] = new Experience();
    }

    $scope.addExperience = function () {
        var length = $scope.experiences.length;
        $scope.experiences[length] = new Experience();
    };
});

angular.module('homepage').
directive('interestInfo', function() {
    return {
        restrict: 'E',
        replace: true,
        scope: {
            interest: '=data'
        },
        templateUrl: 'components/content-components/input/interest-info.html',
        controller: 'interestInfoController'
    };
}).
controller('interestInfoController', function($scope) {
    $scope.interest.list = [
        { 'value': "" }
    ];
});

angular.module('homepage').
directive('moreDetails', function() {
    return {
        restrict: 'E',
        replace: true,
        scope: {
            detail: '=data'
        },
        templateUrl: 'components/content-components/input/more-details.html',
        controller: 'moreDetailsController'
    };
}).
controller('moreDetailsController', function($scope) {
    $scope.detail.language = {
        spoken: '',
        readwrite: ''
    };
});

angular.module('homepage').
directive('profileSummary', function() {
    return {
        restrict: 'E',
        replace: true,
        scope: {
            data: '='
        },
        templateUrl: 'components/content-components/input/profile-summary.html',
        controller: 'profileSummaryController'
    };
}).
controller('profileSummaryController', function($scope) {

});

angular.module('homepage').
directive('projectsList', function() {
    return {
        restrict: 'E',
        replace: true,
        scope: {
            projects: '=data'
        },
        templateUrl: 'components/content-components/input/projects-list.html'
    };
});

angular.module('homepage').
directive('skillList', function() {
    return {
        restrict: 'E',
        replace: true,
        scope: {
            skills: '=data'
        },
        templateUrl: 'components/content-components/input/skill-list.html',
        controller: 'skillListController'
    };
}).
controller('skillListController', function($scope, Skill) {
    if(!$scope.skills || $scope.skills.length === 0) {
        $scope.skills = [];
        $scope.skills[0] = new Skill();
    }

    $scope.addSkill = function () {
        var length = $scope.skills.length;
        $scope.skills[length] = new Skill();
    };
});

angular.module('homepage').
directive('commentpanel', function() {
    return {
    	controller: 'commentPanelController',
        restrict: 'E',
        replace: true,
        transclude: true,
        templateUrl: 'components/content-components/login/commentpanel.html'
    }
}).
controller('commentPanelController', function ($scope, $timeout, Server) {
	$scope.isMessageVisible = false;
	$scope.message = "Comment posted successfully";
	$scope.addcomment = function () {
		Server.addcomment({comment: $scope.comment})
		.success(function (data) {
			$scope.comment = "";
			$scope.isMessageVisible = true;
			$timeout(function () {
				$scope.isMessageVisible = false;
			}, 3000);
		});
	}
});
angular.module('homepage').
directive('loginpanel', function() {
    return {
        controller: 'loginPanelController',
        restrict: 'E',
        replace: true,
        transclude: true,
        templateUrl: 'components/content-components/login/loginpanel.html'
    };
}).
controller('loginPanelController', function($scope, $timeout, $window, Authentication, Server) {
    $scope.isMessageVisible = false;

    $scope.authenticate = function() {
        var user = {
            username: $scope.username,
            password: $scope.password
        };
        Server.login(user).
        success(function(data) {
            console.log(data);
            if(data.token && data.success) {
                Authentication.setUser(data.token);
                Authentication.setHeaders();
                $window.location.href = '/#/home';
            }
            else {
                $scope.message = data.message;
                $scope.isMessageVisible = true;
                $timeout(function () {
                    $scope.isMessageVisible = false;
                }, 3000);
            }
        });
    };
});

angular.module('homepage').
directive('registerpanel', function() {
	return {
		controller: 'registerPanelController',
		restrict: 'E',
		replace: true,
		transclude: true,
		templateUrl: 'components/content-components/login/registerpanel.html'
	};
}).
controller('registerPanelController', function ($location, $scope, $timeout, Server) {
	// FB Pixel: Track when a user expresses interest in your offering
	fbq('track', 'Lead');
	var params = $location.search();
	console.log(params);

	$scope.data = {};
	$scope.invite = { code: ''};
	$scope.isRegisterMessageVisible = false;
	$scope.isInviteMessageVisible = false;

	// Hide registration panel, if param 'hasinvite' set to true
	$scope.hasInvite = params.hasinvite;
	$scope.register = function () {
		console.log($scope.data);
		Server.register($scope.data)
		.success(function (data) {
			console.log(data);
			if(data.success) {

			}
			$scope.data = {};
			$scope.message = data.message;
			$scope.isRegisterMessageVisible = true;
			$timeout(function () {
				$scope.isRegisterMessageVisible = false;
			}, 3000);
		});
	};
	$scope.checkInviteCode = function () {
		Server.checkInvite($scope.invite)
		.success(function (data) {
			console.log(data);
			$scope.invite.code = '';
			if(data.success) {
				$timeout(function () {
					$location.path('/signup');
				}, 2000);
			}
			$scope.message = data.message;
			$scope.isInviteMessageVisible = true;
			$timeout(function () {
				$scope.isInviteMessageVisible = false;
			}, 3000);
		});
	};
});

angular.module('homepage').
directive('signuppanel', function() {
    return {
        restrict: 'E',
        replace: true,
        transclude: true,
        templateUrl: 'components/content-components/login/signuppanel.html',
        controller: 'signupPanelController'
    };
}).
controller('signupPanelController', function($scope, $timeout, $window, Authentication, Server) {
    $scope.isMessageVisible = false;
	$scope.error = {
		email: false,
		username: false
	};

    $scope.registerUser = function() {
        var userData = $scope.registrationInfo;
        console.log(userData);

        if(isValidData(userData)) {
            Server.signup(userData).
            success(function(data) {
                console.log(data);
                $scope.message = data.message;
                if(data.success) {
                    $scope.isMessageVisible = true;
                    $scope.registrationInfo =  {};
                    $timeout(function () {
                        Authentication.setUser(data.token);
                        $window.location.href = '/#/home';
                    }, 3000);
                }
                else {
                    $scope.isMessageVisible = true;
                    $timeout(function () {
                        $scope.isMessageVisible = false;
                    }, 3000);
                }
            });
        }
    };

    function isValidData(data) {
        if(!data) {
            return false;
        }
        var count = 0;
        for(var key in data) {
            if(data.hasOwnProperty(key)) {
                count++;
            }
        }
        // Number of mandatory fields
        if(count === 5) {
            return true;
        }
    }
})

angular.module('homepage').
directive('previewResume', function() {
    return {
        restrict: 'E',
        replace: true,
        templateUrl: 'components/content-components/preview/preview-resume.html',
        controller: 'previewResumeController'
    };
}).
controller('previewResumeController', function($scope, DataStoreSrvc) {
    $scope.inputs = DataStoreSrvc.getInputData();
});