<commit_before>function initList(){
  
  $('.collapsible').collapsible({
      accordion : false // A setting that changes the collapsible behavior to expandable instead of the default accordion style
    });
  
  // create a firebase reference to the root
  var ref = new Firebase('https://publicdata-parking.firebaseio.com');

  var data

  // read data from the location san_francisco/garages, only once
  ref.child('san_francisco/garages').once('value', function(snapshot){
    data = snapshot.val()
    console.log('data is loaded', data)

    // filter the data
    var garages = _.filter(data, function(d){
      // keep only those values (d) that has "open_spaces" as a field
      return _.has(d, 'open_spaces')
    })

    console.log('garages is processed', garages);
    
    displayGarages(garages)
  })
}
function displayGarages(garages){
  $('#garages').empty();
  
  // lodash _.forEach https://lodash.com/docs#forEach
  _.forEach(garages, function(val, key){
    $('#garages').append(generateListItem(val))
  })
}

function generateListItem(val){
  
  var listItem = '<li>'
  listItem += '<div class="collapsible-header"><i class="material-icons">place</i>'
  
  //Add header Here
  listItem += val['friendlyName'];
  
  listItem += '</div>'
  
  listItem += createSubListItem("Open Spaces: " + val['open_spaces'])
  
  listItem += createSubListItem("Total Spaces: " + val['total_spaces'])
   
  listItem += createSubListItem("Percentage Open: " + Math.floor(100*val['open_spaces'] / val['total_spaces']) + "%")
    
  var hours = val['hours']
  
  listItem += getHours(hours)
  
  listItem += getCosts(val['rates'])
  return listItem
}

function createSubListItem(str){
  var item = '<div class="collapsible-body"><p>'
  item += str;
  item += '</p></div>';
  return item;
}

function getHours(hours){
  var listItem = "";
  
  var time = ((hours) ? hours['time'] : false)
  
  if( hours.constructor == Array){
      listItem += '<div class="collapsible-body"><p>Hours of Operation: '
      
      hours.forEach(function(entry){
        listItem += '<p>'+entry['BEG'] + " to " + entry['END']+ " " + entry['FROM'] ;
        
        if( entry['TO']){
          listItem += " thru " + entry['TO']
        }
        
        listItem += "</p>"
      })
      
      
      listItem += '</div>';
  }
  else{
    listItem += createSubListItem("Hours of Operation: " + hours['BEG'] + " " + hours['FROM'])
  }
  return listItem
}

function createSubListItem(str){
  var item = '<div class="collapsible-body"><p>'
  item += str;
  item += '</p></div>';
  return item;
}

function getCosts(costs){
  var listItem = "";
  
  console.log("costs: ", costs)
  //var time = ((hours) ? costs['time'] : false)
  
  if( costs == Array){
      listItem += '<div class="collapsible-body"><p>Pricing: '
      
      costs.forEach(function(entry){
        listItem += '<p>'+costs['BEG'] + ((entry['END'] != null)? " to " + entry['END']: "")+ " is $" + entry['RATE'] + " " + entry['RQ'];
        
      
        listItem += "</p>"
      })
      
      
      listItem += '</div>';
  }
  else{
    listItem += createSubListItem("Pricing: " + costs['BEG'] + " " + costs['FROM'] + " is $" + costs['RATE'] + " " + costs['RQ'] )<commit_msg>Minor changes, now displays information correctly for times<commit_after>function initList(){

  $('.collapsible').collapsible({
      accordion : false // A setting that changes the collapsible behavior to expandable instead of the default accordion style
    });

  // create a firebase reference to the root
  var ref = new Firebase('https://publicdata-parking.firebaseio.com');

  var data

  // read data from the location san_francisco/garages, only once
  ref.child('san_francisco/garages').once('value', function(snapshot){
    data = snapshot.val()
    // console.log('data is loaded', data)

    // filter the data
    var garages = _.filter(data, function(d){
      // keep only those values (d) that has "open_spaces" as a field
      return _.has(d, 'open_spaces')
    })

    // console.log('garages is processed', garages);

    displayGarages(garages)
  })
}
function displayGarages(garages){
  $('#garages').empty();

  // lodash _.forEach https://lodash.com/docs#forEach
  _.forEach(garages, function(val, key){
    $('#garages').append(generateListItem(val))
  })
}

function generateListItem(val){

  var listItem = '<li>'
  listItem += '<div class="collapsible-header"><i class="material-icons">place</i>'

  //Add header Here
  listItem += val['friendlyName'];

  listItem += '</div>'

  listItem += createSubListItem("Open Spaces: " + val['open_spaces'])

  listItem += createSubListItem("Total Spaces: " + val['total_spaces'])

  listItem += createSubListItem("Percentage Open: " + Math.floor(100*val['open_spaces'] / val['total_spaces']) + "%")

  var hours = val['hours']

  listItem += getHours(hours)

  listItem += getCosts(val['rates'])
  return listItem
}

function createSubListItem(str){
  var item = '<div class="collapsible-body"><p>'
  item += str;
  item += '</p></div>';
  return item;
}

function getHours(hours){
  var listItem = "";

  var time = ((hours) ? hours['time'] : false)

  if( hours.constructor == Array){
      listItem += '<div class="collapsible-body"><p>Hours of Operation: '

      hours.forEach(function(entry){
        listItem += '<p>'+entry['BEG'] + " to " + entry['END']+ " " + entry['FROM'] ;

        if( entry['TO']){
          listItem += " thru " + entry['TO']
        }

        listItem += "</p>"
      })


      listItem += '</div>';
  }
  else{
    listItem += createSubListItem("Hours of Operation: " + hours['BEG'] + " " + hours['FROM'])
  }
  return listItem
}

function createSubListItem(str){
  var item = '<div class="collapsible-body"><p>'
  item += str;
  item += '</p></div>';
  return item;
}

function getCosts(costs){
  var listItem = "";

  // console.log("costs: ", costs)
  //var time = ((hours) ? costs['time'] : false)
  console.log(costs);
  if( costs.constructor == Array){
      listItem += '<div class="collapsible-body"><p>Costs: '

      costs.forEach(function(entry){
        if (entry['BEG'] !== undefined) {
          listItem += '<p>'+entry['BEG'] + " to " + entry['END'] + " Cost: $" + entry['RATE'] + " per " + entry['RQ'];
          listItem += "</p>"
        }
      })


      listItem += '</div>';
  } else{
    if (costs['BEG'] === undefined){
    return listItem
    }

    listItem += createSubListItem("Costs: " + costs['BEG'] + " " + costs['FROM'])
{'fraction_non_alphanumeric': 0.18428351309707242, 'fraction_numerical': 0.0009244992295839754, 'mean_word_length': 3.1662387676508343, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, 'https://': 4, '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': '4529477', 'n_tokens_mistral': 2161, 'n_tokens_neox': 2096, 'n_words': 466}