<commit_before>'use strict';

angular.module('pumprApp')
  .directive('searchBar', ['$interval', '$location', 'search', function ($interval, $location, search) {
    return {
      templateUrl: 'app/directives/searchBar/searchBar.html',
      restrict: 'E',
      transclude: true,
      scope: {
        view: '@'
      },
      link: function (scope) {


        (function rotatePlaceholder (){
          var count = 0,
              options = ['Search by Project Name...', 'Search by Project id...', 'Search by Development Plan Id...', 'Search by Address...', 'Search by Street...', 'Search by Facility Id'];
          $interval(function(){
            count = count > 4 ? 0 : count;
            scope.placeholder = options[count];
            count++;
          }, 3000);
        })();
        // rotatePlaceholder();
        scope.autoFillProjects = function (typed) {
          //Turns on the map resulsts table
          scope.searchStatus = false;
          scope.projectDocs = false;
          scope.projectError = false;
          //Uses the Project Search Servies
          scope.projects = [];

          //Testing search factroy
          scope.newProject = search.all(typed);
           return scope.newProject
            .then(function(res){

              if (Array.isArray(res)){
                  var filtered = _.flatten(res);

              }

              if (Array.isArray(filtered) && res.length === 0){
                scope.projects.push('Sorry Project Not Found...');
                return scope.projects;
              }
              else{

                  var unique = _.uniq(filtered);

                  var results = _(unique)
                          .groupBy('group')
                          .map(function (g) {
                            g[0].firstInGroup = true;  // the first item in each group
                            return g;
                          })
                          .flatten()
                          .value();



                        return results;
              }

            })
            .catch(function(err){
              scope.projectError = true;
            });

          //Adds the project to the recently searched cook
          scope.myrecent = scope.projects;
        };
        //Function handles the selection
        scope.searchControl = function (typed){
          if (typed === 'Sorry Project Not Found...'){
            return;
          }
          console.log(scope.view);
          switch(scope.view){
            case 'main':
              $location.url('/project/' + typed.name.split(':')[2]);
            break;
            case 'addDoc':<commit_msg>Added conditions for new redirects<commit_after>'use strict';

angular.module('pumprApp')
  .directive('searchBar', ['$interval', '$location', 'search', function ($interval, $location, search) {
    return {
      templateUrl: 'app/directives/searchBar/searchBar.html',
      restrict: 'E',
      transclude: true,
      scope: {
        view: '@'
      },
      link: function (scope) {


        (function rotatePlaceholder (){
          var count = 0,
              options = ['Search by Project Name...', 'Search by Project id...', 'Search by Development Plan Id...', 'Search by Address...', 'Search by Street...', 'Search by Facility Id'];
          $interval(function(){
            count = count > 4 ? 0 : count;
            scope.placeholder = options[count];
            count++;
          }, 3000);
        })();
        // rotatePlaceholder();
        scope.autoFillProjects = function (typed) {
          //Turns on the map resulsts table
          scope.searchStatus = false;
          scope.projectDocs = false;
          scope.projectError = false;
          //Uses the Project Search Servies
          scope.projects = [];

          //Testing search factroy
          scope.newProject = search.all(typed);
           return scope.newProject
            .then(function(res){

              if (Array.isArray(res)){
                  var filtered = _.flatten(res);

              }

              if (Array.isArray(filtered) && res.length === 0){
                scope.projects.push('Sorry Project Not Found...');
                return scope.projects;
              }
              else{

                  var unique = _.uniq(filtered);

                  var results = _(unique)
                          .groupBy('group')
                          .map(function (g) {
                            g[0].firstInGroup = true;  // the first item in each group
                            return g;
                          })
                          .flatten()
                          .value();



                        return results;
              }

            })
            .catch(function(err){
              scope.projectError = true;
            });

          //Adds the project to the recently searched cook
          scope.myrecent = scope.projects;
        };
        //Function handles the selection
        scope.searchControl = function (typed){
          if (typed === 'Sorry Project Not Found...'){
            return;
          }
          console.log(typed);
          switch(scope.view){
            case 'main':
              if (typed.group === 'project'){
                $location.url('/project/' + typed.name.split(':')[2]);
              }
              else if (typed.group === 'address'){
                alert('Address:', typed.location)
              }
              else if (typed.group === 'facilityid'){
                alert('FACLITYID:', typed.location.x)
              }
            break;
            case 'addDoc':
{'fraction_non_alphanumeric': 0.12297849653456548, 'fraction_numerical': 0.003554291807357384, 'mean_word_length': 1.3075030750307504, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2398958', 'n_tokens_mistral': 1426, 'n_tokens_neox': 1360, 'n_words': 352}