<commit_before>﻿<!DOCTYPE html>
<html>
<head>
  <script type="text/javascript" src="javascripts/utils/jquery.min.js"></script>
  <script type="text/javascript" src="javascripts/utils/PerfectTime.js"></script>
  <script type="text/javascript" src="javascripts/application.js"></script>
  <script type="text/javascript" src="http://cdn.simplegeo.com/js/1.2/simplegeo.places.min.js"></script>

  <script>
    var bgPage = chrome.extension.getBackgroundPage();

    // Set the body class to the user status (loggedin or loggedout)
    function updateStatus(){
      if( bgPage.oauth.hasToken() ){
        $(document.body).removeClass('loggedout').addClass('loggedin');
      } else {
        $(document.body).removeClass('loggedin').addClass('loggedout');
      }
    }

    $(document).ready(function(){
      // Check the user status when the popup loads
      updateStatus();

      $('#logoutbutton').click(function(){
        bgPage.logout();
        updateStatus();
      });

      $('#loginbutton').click(function(){

        // Autherize via oauth
        bgPage.oauth.authorize(function(){
          updateStatus();
        });
      });
    });

    chrome.tabs.getSelected(null, function(tab) {
      // get the microformats from the current tab
      var hcards      = bgPage.hcards[tab.id];
      var hcalendars  = bgPage.hcalendars[tab.id];
      var hreviews    = bgPage.hreviews[tab.id];
      var hreviewaggs = bgPage.hreviewaggs[tab.id];
      var hrecipes    = bgPage.hrecipes[tab.id];
      var geos        = bgPage.geos[tab.id];

      // let's put these suckers on the page!
      $.each(unique_cards(hcards), function(i, hcard) {
        // What other data should we display?
        var html = $('<li class="hcard" id="hcard-'+i+'">'
                     + '<div class="download">'
                       + (hcard.photo ? '<img src="'+hcard.photo[0]+'" class="photo"> ' : '<img src="images/vcf_48.png">')
                     + '</div>'
                     + '<div class="details">'
                       + '<h1>'
                         + hcard.fn
                         + '<a href="http://growing-flower-18.heroku.com/vcard?query='+ encodeURIComponent(JSON.stringify(hcard)) + '" title="Download" target="_blank" class="vcard">'
                           + '<img src="images/hcard_download.png">'
                         + '</a>'
                         + '<a href="#" class="submithcard" title="Add to Google Contacts">'
                           + '<img src="images/googleIcon.png" alt="Google" />'
                         + '</a>'
                       + '</h1>'
                       + '<ul></ul>'
                     + '</div>'
                   + '</li>');

        // fn is required so only output the vcard if it's "valid"
        if (hcard.fn) {

          // When the Google icon is clicked, the hcard will be added to Google Contacts
          $('.submithcard', html).click(function(){
            bgPage.Export.HCard.google(hcard, function(txt, response){
              if (response.status == 201) {
                $('.submithcard img', html).first().replaceWith('<img src="images/check.png" alt="Added" />');
              } else {
                console.log('FAILED');
              }
            });
            return false;
          });

          $("#hcards").append(html);

          if (hcard.org) {
            $.each(hcard.org, function(index, org) {
              $('#hcard-'+i+' ul').append('<li>'+ org['organization-name'] +'</li>');
            });
          }

          if (hcard.role) {
            $.each(hcard.role, function(index, role) {
              $('#hcard-'+i+' ul').append('<li>'+ role +'</li>');
            });
          }

          if (hcard.nickname) {
            $('#hcard-'+i+' ul').append('<li>Nickname: '+ hcard.nickname[0] +'</li>');
          }

          if (hcard.email) {
            $.each(hcard.email, function(index, email) {
              $('#hcard-'+i+' ul').append('<li><a href="mailto:'+ email['value'] +'">'+ email['value'] +'</li>');
            });
          }

          if (hcard.url) {
            $.each(hcard.url, function(index, url) {
              $('#hcard-'+i+' ul').append('<li><a href="'+ url +'" target="_blank">'+ url + '</a></li>');
            });
          }

          if (hcard.tel) {
            $.each(hcard.tel, function(index, tel) {
              var type = tel.type ? tel.type.toString() + ': ' : '';
              $('#hcard-'+i+' ul').append('<li>'+ type + tel['value'] +'</li>');
            });
          }

          if (hcard.adr) {
            var street = hcard.adr[0]["street-address"] ? hcard.adr[0]["street-address"] : '';
            var locality = hcard.adr[0].locality ? hcard.adr[0].locality : '';
            var region = hcard.adr[0].region ? hcard.adr[0].region : '';
            var country = hcard.adr[0]["country-name"] ? hcard.adr[0]["country-name"] : '';
            var postalCode = hcard.adr[0]["postal-code"] ? hcard.adr[0]["postal-code"] : '';
            var mapString = [street, locality, region, country, postalCode];

            $('#hcard-'+i+' ul').append('<li>'+ street +'<br>'+ locality +', '+ region +' '+ country +' '+ postalCode +'<br><a href="http://maps.google.com/maps?q='+encodeURIComponent(mapString.join(" "))+'" target="_blank" title="View on Google Maps"><img src="http://maps.google.com/maps/api/staticmap?center='+encodeURIComponent(mapString.join(" "))+'&zoom=14&size=100x100&markers=color:green|label:A|'+mapString+'&sensor=false" class="static-map"></a></li>');
          }
        }
      });

      $.each(unique_events(hcalendars), function(j, hcalendar) {
        var hcalHtml = $('<li class="hcalendar" id="hcal-'+j+'">'
                         + '<div class="download">'
                           + '<img src="images/calendargray.png">'
                           + '<span class="dtstart-month">'+ $.fn.strftime($.fn.parseISO(hcalendar.dtstart), '%b') +'</span>'
                           + '<span class="dtstart-day">'+ $.fn.strftime($.fn.parseISO(hcalendar.dtstart), '%d') +'</span>'
                         + '</div>'
                         + '<div class="details">'
                           + '<h1>'
                             + hcalendar.summary
                             + '<a href="http://growing-flower-18.heroku.com/vevent?query='+ encodeURIComponent(JSON.stringify(hcalendar)) + '" title="Download" target="_blank" class="vevent">'
                               + '<img src="images/icon-hcalendar-download.png">'
                             + '</a>'
                             + '<a href="#" class="submitvevent" title="Add to Google Contacts">'
                               + '<img src="images/googleIcon.png" alt="Google" />'
                             + '</a>'
                           + '</h1>'
                           + '<ul>'
                             + '<li class="start">'+ $.fn.strftime($.fn.parseISO(hcalendar.dtstart), '%b %d, %Y at %i:%M%P') +'</li>'
                           + '</ul>'
                         + '</div>'
                       + '</li>');

        $("#hcalendars").append(hcalHtml);

        // Handle submit to Google link
        $('.submitvevent', hcalHtml).click(function(){
          bgPage.Export.HCalendar.google(hcalendar, function(txt, response){
            if (response.status == 201) {
              $('.submitvevent img', hcalHtml).first().replaceWith('<img src="images/check.png" alt="Added" />');
            } else {
              console.log('FAILED');
            }
          });
          return false;
        });

        if (hcalendar.dtend)
          $('#hcal-'+j+' ul .start').append(' — '+ $.fn.strftime($.fn.parseISO(hcalendar.dtend), '%b %d, %Y at %i:%M%P'));

        if (hcalendar.location)
          $('#hcal-'+j+' ul').append('<li><a href="http://maps.google.com/maps?q='+encodeURIComponent(hcalendar.location)+'" target="_blank" title="View on Google Maps">'+hcalendar.location+'</a></li>');
      });

      $.each(hreviews, function(k, hreview) {
        var hreviewHTML = $('<li class="hreview" id="hreview-'+k+'"><div class="download"><img src="images/star.png"></div><div class="details"><h1>' + (hreview.item.fn || hreview.item.url || hreview.item.photo_url) + '</h1><ul></ul></div></li>');

        $("#hreviews").append(hreviewHTML);

        if (hreview.summary)
          $('#hreview-'+k+' ul').append('<li>' + hreview.summary + '</li>');

        if (hreview.description)
          $('#hreview-'+k+' ul').append('<li>'+ hreview.description +'</li>');

        if (hreview.dtreviewed)
          $('#hreview-'+k+' ul').append('<li><strong>Reviewed: </strong>'+ hreview.dtreviewed +'</li>');

        if (hreview.rating)
          $('#hreview-'+k+' ul').append('<li><strong>Rating: </strong>'+ hreview.rating +'</li>');
      });
<commit_msg>Fix location information and link in hcalendar<commit_after>﻿<!DOCTYPE html>
<html>
<head>
  <script type="text/javascript" src="javascripts/utils/jquery.min.js"></script>
  <script type="text/javascript" src="javascripts/utils/PerfectTime.js"></script>
  <script type="text/javascript" src="javascripts/application.js"></script>
  <script type="text/javascript" src="http://cdn.simplegeo.com/js/1.2/simplegeo.places.min.js"></script>

  <script>
    var bgPage = chrome.extension.getBackgroundPage();

    // Set the body class to the user status (loggedin or loggedout)
    function updateStatus(){
      if( bgPage.oauth.hasToken() ){
        $(document.body).removeClass('loggedout').addClass('loggedin');
      } else {
        $(document.body).removeClass('loggedin').addClass('loggedout');
      }
    }

    $(document).ready(function(){
      // Check the user status when the popup loads
      updateStatus();

      $('#logoutbutton').click(function(){
        bgPage.logout();
        updateStatus();
      });

      $('#loginbutton').click(function(){

        // Autherize via oauth
        bgPage.oauth.authorize(function(){
          updateStatus();
        });
      });
    });

    chrome.tabs.getSelected(null, function(tab) {
      // get the microformats from the current tab
      var hcards      = bgPage.hcards[tab.id];
      var hcalendars  = bgPage.hcalendars[tab.id];
      var hreviews    = bgPage.hreviews[tab.id];
      var hreviewaggs = bgPage.hreviewaggs[tab.id];
      var hrecipes    = bgPage.hrecipes[tab.id];
      var geos        = bgPage.geos[tab.id];

      // let's put these suckers on the page!
      $.each(unique_cards(hcards), function(i, hcard) {
        // What other data should we display?
        var html = $('<li class="hcard" id="hcard-'+i+'">'
                     + '<div class="download">'
                       + (hcard.photo ? '<img src="'+hcard.photo[0]+'" class="photo"> ' : '<img src="images/vcf_48.png">')
                     + '</div>'
                     + '<div class="details">'
                       + '<h1>'
                         + hcard.fn
                         + '<a href="http://growing-flower-18.heroku.com/vcard?query='+ encodeURIComponent(JSON.stringify(hcard)) + '" title="Download" target="_blank" class="vcard">'
                           + '<img src="images/hcard_download.png">'
                         + '</a>'
                         + '<a href="#" class="submithcard" title="Add to Google Contacts">'
                           + '<img src="images/googleIcon.png" alt="Google" />'
                         + '</a>'
                       + '</h1>'
                       + '<ul></ul>'
                     + '</div>'
                   + '</li>');

        // fn is required so only output the vcard if it's "valid"
        if (hcard.fn) {

          // When the Google icon is clicked, the hcard will be added to Google Contacts
          $('.submithcard', html).click(function(){
            bgPage.Export.HCard.google(hcard, function(txt, response){
              if (response.status == 201) {
                $('.submithcard img', html).first().replaceWith('<img src="images/check.png" alt="Added" />');
              } else {
                console.log('FAILED');
              }
            });
            return false;
          });

          $("#hcards").append(html);

          if (hcard.org) {
            $.each(hcard.org, function(index, org) {
              $('#hcard-'+i+' ul').append('<li>'+ org['organization-name'] +'</li>');
            });
          }

          if (hcard.role) {
            $.each(hcard.role, function(index, role) {
              $('#hcard-'+i+' ul').append('<li>'+ role +'</li>');
            });
          }

          if (hcard.nickname) {
            $('#hcard-'+i+' ul').append('<li>Nickname: '+ hcard.nickname[0] +'</li>');
          }

          if (hcard.email) {
            $.each(hcard.email, function(index, email) {
              $('#hcard-'+i+' ul').append('<li><a href="mailto:'+ email['value'] +'">'+ email['value'] +'</li>');
            });
          }

          if (hcard.url) {
            $.each(hcard.url, function(index, url) {
              $('#hcard-'+i+' ul').append('<li><a href="'+ url +'" target="_blank">'+ url + '</a></li>');
            });
          }

          if (hcard.tel) {
            $.each(hcard.tel, function(index, tel) {
              var type = tel.type ? tel.type.toString() + ': ' : '';
              $('#hcard-'+i+' ul').append('<li>'+ type + tel['value'] +'</li>');
            });
          }

          if (hcard.adr) {
            var street = hcard.adr[0]["street-address"] ? hcard.adr[0]["street-address"] : '';
            var locality = hcard.adr[0].locality ? hcard.adr[0].locality : '';
            var region = hcard.adr[0].region ? hcard.adr[0].region : '';
            var country = hcard.adr[0]["country-name"] ? hcard.adr[0]["country-name"] : '';
            var postalCode = hcard.adr[0]["postal-code"] ? hcard.adr[0]["postal-code"] : '';
            var mapString = [street, locality, region, country, postalCode];

            $('#hcard-'+i+' ul').append('<li>'+ street +'<br>'+ locality +', '+ region +' '+ country +' '+ postalCode +'<br><a href="http://maps.google.com/maps?q='+encodeURIComponent(mapString.join(" "))+'" target="_blank" title="View on Google Maps"><img src="http://maps.google.com/maps/api/staticmap?center='+encodeURIComponent(mapString.join(" "))+'&zoom=14&size=100x100&markers=color:green|label:A|'+mapString+'&sensor=false" class="static-map"></a></li>');
          }
        }
      });

      $.each(unique_events(hcalendars), function(j, hcalendar) {
        var hcalHtml = $('<li class="hcalendar" id="hcal-'+j+'">'
                         + '<div class="download">'
                           + '<img src="images/calendargray.png">'
                           + '<span class="dtstart-month">'+ $.fn.strftime($.fn.parseISO(hcalendar.dtstart), '%b') +'</span>'
                           + '<span class="dtstart-day">'+ $.fn.strftime($.fn.parseISO(hcalendar.dtstart), '%d') +'</span>'
                         + '</div>'
                         + '<div class="details">'
                           + '<h1>'
                             + hcalendar.summary
                             + '<a href="http://growing-flower-18.heroku.com/vevent?query='+ encodeURIComponent(JSON.stringify(hcalendar)) + '" title="Download" target="_blank" class="vevent">'
                               + '<img src="images/icon-hcalendar-download.png">'
                             + '</a>'
                             + '<a href="#" class="submitvevent" title="Add to Google Contacts">'
                               + '<img src="images/googleIcon.png" alt="Google" />'
                             + '</a>'
                           + '</h1>'
                           + '<ul>'
                             + '<li class="start">'+ $.fn.strftime($.fn.parseISO(hcalendar.dtstart), '%b %d, %Y at %i:%M%P') +'</li>'
                           + '</ul>'
                         + '</div>'
                       + '</li>');

        $("#hcalendars").append(hcalHtml);

        // Handle submit to Google link
        $('.submitvevent', hcalHtml).click(function(){
          bgPage.Export.HCalendar.google(hcalendar, function(txt, response){
            if (response.status == 201) {
              $('.submitvevent img', hcalHtml).first().replaceWith('<img src="images/check.png" alt="Added" />');
            } else {
              console.log('FAILED');
            }
          });
          return false;
        });

        if (hcalendar.dtend)
          $('#hcal-'+j+' ul .start').append(' — '+ $.fn.strftime($.fn.parseISO(hcalendar.dtend), '%b %d, %Y at %i:%M%P'));

        if (hcalendar.location) {
          var location = hcalendar.location.adr[0];
          var street = location["street-address"][0] ? location["street-address"][0] : '';
          var locality = location.locality ? location.locality : '';
          var region = location.region ? location.region : '';
          var country = location["country-name"] ? location["country-name"] : '';
          var postalCode = location["postal-code"] ? location["postal-code"] : '';
          var mapString = [street, locality, region, country, postalCode];
        
          $('#hcal-'+j+' ul').append('<li><a href="http://maps.google.com/maps?q='+encodeURIComponent(mapString)+'" target="_blank" title="View on Google Maps">'+hcalendar.location.fn+'</a></li>');
        }
      });

      $.each(hreviews, function(k, hreview) {
        var hreviewHTML = $('<li class="hreview" id="hreview-'+k+'"><div class="download"><img src="images/star.png"></div><div class="details"><h1>' + (hreview.item.fn || hreview.item.url || hreview.item.photo_url) + '</h1><ul></ul></div></li>');

        $("#hreviews").append(hreviewHTML);

        if (hreview.summary)
          $('#hreview-'+k+' ul').append('<li>' + hreview.summary + '</li>');

        if (hreview.description)
          $('#hreview-'+k+' ul').append('<li>'+ hreview.description +'</li>');

        if (hreview.dtreviewed)
          $('#hreview-'+k+' ul').append('<li><strong>Reviewed: </strong>'+ hreview.dtreviewed +'</li>');

        if (hreview.rating)
          $('#hreview-'+k+' ul').append('<li><strong>Rating: </strong>'+ hreview.rating +'</li>');
      });

{'fraction_non_alphanumeric': 0.20130475302889095, 'fraction_numerical': 0.004550189134367633, 'mean_word_length': 1.9318547090967535, 'pattern_counts': {'":': 0, '<': 211, '<?xml version=': 0, '>': 211, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4455407', 'n_tokens_mistral': 5600, 'n_tokens_neox': 5478, 'n_words': 922}