<commit_before>
function searchFavorites (query){
    var feedback = [];
    var resultList = JSON.parse(localStorage.getItem("results"));
    if(resultList == null){
    	return feedback;
    }else{
    _.each(resultList, function(x){
        if(x.name.search(query) > -1 || x.tag.search(query) > -1 || x.notes.search(query) > -1){
            feedback.push(x);
        }
    });
    }
    return feedback;
}

function getFavoriteCategories(){
    var feedback = [];
    var resultList = JSON.parse(localStorage.getItem("results"));
    //returns the list of lists (of categories); 
    _.each(resultList, function(x){
       feedback.push(x.categories);
    }
 );
    var answer = []; //a temp variable used in getBroadCategories which will be filled which a business's category hierachy
    var cats = [];   //a list of 'answer' lists; each element in cats is a list containing the hierachy for each business

    _.each(feedback, function(innerCat){
        cats.push(getBroadCategories(answer, innerCat, categories));
        answer =[];
    });
    return cats;
}
//this function needs testing

function getBroadCategories(answers, innerCat, globalCategories){
    for(var ky in globalCategories){
        if(typeof globalCategories == 'object'){
            answers.push(globalCategories);
            getBroadCategories(answers, globalCategories[ky]);
        }else if(typeof globalCategories == 'string'){
            if(globalCategories == innerCat){
                 return answers; //return the list which contains the hierachy of categories for this business 
                 //first element in the list is the inner most category and the last element is the broad category
            }//else, the category of the item is not this one.
        }
        answers = [];  //clear the array and look at the next category in the global list
    }    
}

function getFavoritesWithinCategory (query){
    var feedback = [];
    var resultList = JSON.parse(localStorage.getItem("results"));

   _.each(resultList, function(x){
        if(x.categories == query){
            feedback.push(x);
        }
    });
    return feedback;
}

function addBusinessToFavorite (business){

    var resultList = JSON.parse(localStorage.getItem("results"));
    if(resultList == null){
   // 	alert("in here!");
    	resultList = [];   	
    	
    }
   resultList.push(business);
   localStorage.setItem("results", JSON.stringify(resultList));
}

function deleteBusinessFromStorage(business){
    var resultList = JSON.parse(localStorage.getItem("results"));
    removeA(resultList, business);
    localStorage.setItem("results", JSON.stringify(resultList));
}

function removeA(arr) {
    var what, a = arguments, L = a.length, ax;
    while (L > 1 && arr.length) {
        what = a[--L];
        while ((ax= arr.indexOf(what)) !== -1) {
            arr.splice(ax, 1);
        }
    }
    return arr;
}

function saveBookmark(business, tags, notes){<commit_msg>removed alerts from retrieve-storage<commit_after>
function searchFavorites (query){
    var feedback = [];
    var resultList = JSON.parse(localStorage.getItem("results"));
    if(resultList == null){
    	return feedback;
    }else{
    _.each(resultList, function(x){
        if(x.name.search(query) > -1 || x.tags.search(query) > -1 || x.notes.search(query) > -1){
            feedback.push(x);
        }
    });
    }
    return feedback;
}

function getFavoriteCategories(){
    var feedback = [];
    var resultList = JSON.parse(localStorage.getItem("results"));
    //returns the list of lists (of categories); 
    _.each(resultList, function(x){
       feedback.push(x.categories);
    }
 );
    var answer = []; //a temp variable used in getBroadCategories which will be filled which a business's category hierachy
    var cats = [];   //a list of 'answer' lists; each element in cats is a list containing the hierachy for each business

    _.each(feedback, function(innerCat){
        cats.push(getBroadCategories(answer, innerCat, categories));
        answer =[];
    });
    return cats;
}
//this function needs testing

function getBroadCategories(answers, innerCat, globalCategories){
    for(var ky in globalCategories){
        if(typeof globalCategories == 'object'){
            answers.push(globalCategories);
            getBroadCategories(answers, globalCategories[ky]);
        }else if(typeof globalCategories == 'string'){
            if(globalCategories == innerCat){
                 return answers; //return the list which contains the hierachy of categories for this business 
                 //first element in the list is the inner most category and the last element is the broad category
            }//else, the category of the item is not this one.
        }
        answers = [];  //clear the array and look at the next category in the global list
    }    
}

function getFavoritesWithinCategory (query){
    var feedback = [];
    var resultList = JSON.parse(localStorage.getItem("results"));

   _.each(resultList, function(x){
        if(x.categories == query){
            feedback.push(x);
        }
    });
    return feedback;
}

function addBusinessToFavorite (business){

    var resultList = JSON.parse(localStorage.getItem("results"));
    if(resultList == null){
    	resultList = [];   	
    	
    }
   resultList.push(business);
   localStorage.setItem("results", JSON.stringify(resultList));
}

function deleteBusinessFromStorage(business){
    var resultList = JSON.parse(localStorage.getItem("results"));
    removeA(resultList, business);
    localStorage.setItem("results", JSON.stringify(resultList));
}

function removeA(arr) {
    var what, a = arguments, L = a.length, ax;
    while (L > 1 && arr.length) {
        what = a[--L];
        while ((ax= arr.indexOf(what)) !== -1) {
            arr.splice(ax, 1);
        }
    }
    return arr;
}

function saveBookmark(business, tags, notes){
{'fraction_non_alphanumeric': 0.12305348679756263, 'fraction_numerical': 0.002031144211238998, 'mean_word_length': 2.842002600780234, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '213387', 'n_tokens_mistral': 1673, 'n_tokens_neox': 1628, 'n_words': 464}