<commit_before>function buildRating(val) {
  var htmlBuilder = "";
  for (var i = 1; i <= 5; i++) {
    var img_src = "imgs/star_empty.png";
    if (val >= i) {
      img_src = "imgs/star_fill.png";
    }
    htmlBuilder += "<img class='filter-rating-star' src='" + img_src + "'>";
  }
  return htmlBuilder;
}
function initializeDetails(){
    var sessObj = getSessionObject();
    var charityDetails = getCharityDetails(); 
    var detailsCharity = sessObj["detailsCharity"];

    // Get Charity Name and Image
    var imageDiv = document.getElementById("charity-image");
    imageDiv.innerHTML = "";

    var imageView = document.createElement("img");
    imageDiv.appendChild(imageView);
    imageView.className = "charity-image";
    imageView.src = charityDetails[detailsCharity]["photoUrl"];
    console.log(imageView.src);

    var nameDiv = document.getElementById("charity-name");
    nameDiv.innerHTML = "<h3>" + charityDetails[detailsCharity]["name"] +"<h3>";

    var addCharityButton = document.getElementById("addCharityButton");
    if (sessObj["savedCharities"].indexOf(sessObj["detailsCharity"]) > -1){
        addCharityButton.innerHTML = "Remove Charity";
    } else {
        addCharityButton.innerHTML = "Add Charity";
    }

    addCharityButton.addEventListener("click", function(elem){
        return function(){
            var sessObj = getSessionObject();
            if (elem.innerHTML == "Add Charity"){
                sessObj["savedCharities"].push(sessObj["detailsCharity"]);
                sessObj["allocationAmounts"][charityDetails[detailsCharity]["name"]] = 0
                elem.innerHTML = "Remove Charity";
                elem.className = "added"
            }else{
                var removeIndex = sessObj["savedCharities"].indexOf(sessObj["detailsCharity"]);
                sessObj["savedCharities"].splice(removeIndex, 1);
                alloc = sessObj["allocationAmounts"][charityDetails[detailsCharity]];
                sessObj["percentAllocated"] -= alloc;
                delete sessObj["allocationAmounts"][charityDetails[detailsCharity]];
                elem.innerHTML = "Add Charity";
                elem.className = "unadded"
            }
            setSessionObject(sessObj);
        };
    }(addCharityButton));
}
function initNavMenu(){
   var aboutNavButton = document.getElementById("aboutNavButton");
   var impactNavButton = document.getElementById("impactNavButton");
   var financialsNavButton = document.getElementById("financialsNavButton");
   var leadershipNavButton = document.getElementById("leadershipNavButton");

  aboutNavButton.addEventListener("click", function(){
    toggleSideSelection("aboutNavButton");
    showAboutView();
  });
  impactNavButton.addEventListener("click", function(){
    toggleSideSelection("impactNavButton");
    showImpactView();
  });
  financialsNavButton.addEventListener("click", function(){
    toggleSideSelection("financialsNavButton");
    showFinancialsView();
  });
  leadershipNavButton.addEventListener("click", function(){
    toggleSideSelection("leadershipNavButton");
    showLeadershipView();
  });
   // Functionality for add to charities button

   // initialize at about page
   toggleSideSelection("aboutNavButton");
   showAboutView();
}

function toggleSideSelection(elemId){
  var selected = document.getElementsByClassName("side-nav-elem-selected");
  for (var i=0; i < selected.length; i++){
    selected[i].className = "row side-nav-elem"
  }
  var selectElem = document.getElementById(elemId);
  selectElem.className = "row side-nav-elem side-nav-elem-selected";
}

function showAboutView(){
  var sessObj = getSessionObject();
  var charityId = sessObj["detailsCharity"];
  var charityDetails = getCharityDetails();
  var charityDetail = charityDetails[charityId];

  var contentView = document.getElementById("mainContentView");
  contentView.innerHTML = "";

  var glanceHeader = document.createElement("h2");
  glanceHeader.innerHTML = "At a Glance";
  contentView.appendChild(glanceHeader);

  var glanceRow = document.createElement("div");
  glanceRow.className = "row about-data";
  contentView.appendChild(glanceRow);
  var leftSide = document.createElement("div");
  leftSide.className = "col-md-6";
  //leftSide.innerHTML += "<h4>Rating: " + charityDetail["rating"] + "</h4>";
  leftSide.innerHTML += "<h4>Rating: </h4>" + buildRating(charityDetails[result_indeces[i]].rating);
  leftSide.innerHTML += "<h4>Org Type: " + charityDetail["orgType"] + "</h4>";
  leftSide.innerHTML += "<h4>Founded: " + charityDetail["founded"] + "</h4>";
  leftSide.innerHTML += "<h4>Headquarters: " + charityDetail["headquarters"] + "</h4>";
<commit_msg>using stars for quick facts on details page<commit_after>function buildRating(val) {
  var htmlBuilder = "";
  for (var i = 1; i <= 5; i++) {
    var img_src = "imgs/star_empty.png";
    if (val >= i) {
      img_src = "imgs/star_fill.png";
    }
    htmlBuilder += "<img class='filter-rating-star' src='" + img_src + "'>";
  }
  return htmlBuilder;
}
function initializeDetails(){
    var sessObj = getSessionObject();
    var charityDetails = getCharityDetails(); 
    var detailsCharity = sessObj["detailsCharity"];

    // Get Charity Name and Image
    var imageDiv = document.getElementById("charity-image");
    imageDiv.innerHTML = "";

    var imageView = document.createElement("img");
    imageDiv.appendChild(imageView);
    imageView.className = "charity-image";
    imageView.src = charityDetails[detailsCharity]["photoUrl"];
    console.log(imageView.src);

    var nameDiv = document.getElementById("charity-name");
    nameDiv.innerHTML = "<h3>" + charityDetails[detailsCharity]["name"] +"<h3>";

    var addCharityButton = document.getElementById("addCharityButton");
    if (sessObj["savedCharities"].indexOf(sessObj["detailsCharity"]) > -1){
        addCharityButton.innerHTML = "Remove Charity";
    } else {
        addCharityButton.innerHTML = "Add Charity";
    }

    addCharityButton.addEventListener("click", function(elem){
        return function(){
            var sessObj = getSessionObject();
            if (elem.innerHTML == "Add Charity"){
                sessObj["savedCharities"].push(sessObj["detailsCharity"]);
                sessObj["allocationAmounts"][charityDetails[detailsCharity]["name"]] = 0
                elem.innerHTML = "Remove Charity";
                elem.className = "added"
            }else{
                var removeIndex = sessObj["savedCharities"].indexOf(sessObj["detailsCharity"]);
                sessObj["savedCharities"].splice(removeIndex, 1);
                alloc = sessObj["allocationAmounts"][charityDetails[detailsCharity]];
                sessObj["percentAllocated"] -= alloc;
                delete sessObj["allocationAmounts"][charityDetails[detailsCharity]];
                elem.innerHTML = "Add Charity";
                elem.className = "unadded"
            }
            setSessionObject(sessObj);
        };
    }(addCharityButton));
}
function initNavMenu(){
   var aboutNavButton = document.getElementById("aboutNavButton");
   var impactNavButton = document.getElementById("impactNavButton");
   var financialsNavButton = document.getElementById("financialsNavButton");
   var leadershipNavButton = document.getElementById("leadershipNavButton");

  aboutNavButton.addEventListener("click", function(){
    toggleSideSelection("aboutNavButton");
    showAboutView();
  });
  impactNavButton.addEventListener("click", function(){
    toggleSideSelection("impactNavButton");
    showImpactView();
  });
  financialsNavButton.addEventListener("click", function(){
    toggleSideSelection("financialsNavButton");
    showFinancialsView();
  });
  leadershipNavButton.addEventListener("click", function(){
    toggleSideSelection("leadershipNavButton");
    showLeadershipView();
  });
   // Functionality for add to charities button

   // initialize at about page
   toggleSideSelection("aboutNavButton");
   showAboutView();
}

function toggleSideSelection(elemId){
  var selected = document.getElementsByClassName("side-nav-elem-selected");
  for (var i=0; i < selected.length; i++){
    selected[i].className = "row side-nav-elem"
  }
  var selectElem = document.getElementById(elemId);
  selectElem.className = "row side-nav-elem side-nav-elem-selected";
}

function showAboutView(){
  var sessObj = getSessionObject();
  var charityId = sessObj["detailsCharity"];
  var charityDetails = getCharityDetails();
  var charityDetail = charityDetails[charityId];

  var contentView = document.getElementById("mainContentView");
  contentView.innerHTML = "";

  var glanceHeader = document.createElement("h2");
  glanceHeader.innerHTML = "At a Glance";
  contentView.appendChild(glanceHeader);

  var glanceRow = document.createElement("div");
  glanceRow.className = "row about-data";
  contentView.appendChild(glanceRow);
  var leftSide = document.createElement("div");
  leftSide.className = "col-md-6";
  //leftSide.innerHTML += "<h4>Rating: " + charityDetail["rating"] + "</h4>";
  leftSide.innerHTML += "<h4>Rating: </h4>" + buildRating(charityDetail["rating"]);
  leftSide.innerHTML += "<h4>Org Type: " + charityDetail["orgType"] + "</h4>";
  leftSide.innerHTML += "<h4>Founded: " + charityDetail["founded"] + "</h4>";
  leftSide.innerHTML += "<h4>Headquarters: " + charityDetail["headquarters"] + "</h4>";

{'fraction_non_alphanumeric': 0.14148629917901695, 'fraction_numerical': 0.004264846998613925, 'mean_word_length': 4.002666666666666, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, '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': '4065653', 'n_tokens_mistral': 2683, 'n_tokens_neox': 2594, 'n_words': 477}