<commit_before><script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAATfHumDbW3OmRByfquHd3SRTRERdeAiwZ9EeJWta3L_JZVS0bOBRQeZgr4K0xyVKzUdnnuFl8X9PX0w&sensor=false"
        type="text/javascript"></script>
<script>
var maps_key = "<KEY>";

function xhr_geocode(address) {
  var xhr = new XMLHttpRequest();
  xhr.onreadystatechange = function() {
    if (xhr.readyState == 4 && xhr.status == 200) {
      console.log(xhr.responseText);
      var parsed = JSON.parse(xhr.responseText);
      console.dir(parsed);
      var point = parsed.Placemark[0].Point.coordinates;
      var latlng = point[1] + "," + point[0];
      window.open("http://maps.google.com/staticmap?center=" + latlng +
                  "&markers=" + latlng + "&zoom=14" +
                  "&size=512x512&sensor=false&key=" + maps_key,
                  "mappy_popup",
                  "width=512,height=512");
    } else {
      console.log("xhr: " + xhr.readyState);
    }
  };
  var url = 
      "http://maps.google.com/maps/geo?output=json&oe=utf8&sensor=false&key=" + 
      maps_key + "&q=" + address;
  console.log(url);
  xhr.open("GET", url);
  xhr.send(null);
}

function gclient_geocode(address) {
  var geocoder = new GClientGeocoder();
  geocoder.getLatLng(address, function(point) {
    if (!point) {
      console.log(address + " not found");
    } else {
      var latlng = point.toUrlValue();
      var url = "http://maps.google.com/staticmap?center=" + latlng +
                "&markers=" + latlng + "&zoom=14" +
                "&size=512x512&sensor=false&key=" + maps_key;
      //window.open(url, "mappy_popup", "width=512,height=512");
      document.body.style.width = "512px";
      setTimeout(chrome.toolstrip.expand, 100, 512, url);
    }
  });
}

function map() {
  chrome.tabs.getSelected(null, function(tab) {
    var port = chrome.tabs.connect(tab.id);
    if (!port) {
      console.log("no port");
    } else {
      port.onMessage.addListener(function(data) {
        var address = data.values[0];
        //xhr_geocode(address);
        gclient_geocode(address);
      });
      port.postMessage({message: "hello tab: " + tab.id});
      console.log("sent message");
    }
  });
};
</script>
<div class="toolstrip-button" onclick="map()">
<span>Mappy</span>
</div><commit_msg>fix mappy to use new API changes TBR=rafaelw BUG=none TEST=use mappy extension<commit_after><script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAATfHumDbW3OmRByfquHd3SRTRERdeAiwZ9EeJWta3L_JZVS0bOBRQeZgr4K0xyVKzUdnnuFl8X9PX0w&sensor=false"
        type="text/javascript"></script>
<script>
var maps_key = "<KEY>";

function gclient_geocode(address) {
  var geocoder = new GClientGeocoder();
  geocoder.getLatLng(address, function(point) {
    if (!point) {
      console.log(address + " not found");
    } else {
      var latlng = point.toUrlValue();
      var url = "http://maps.google.com/staticmap?center=" + latlng +
                "&markers=" + latlng + "&zoom=14" +
                "&size=512x512&sensor=false&key=" + maps_key;
      document.body.style.width = "512px";
      setTimeout(chrome.toolstrip.expand, 100, {height:512, url:url});
    }
  });
}

function map() {
  chrome.tabs.getSelected(null, function(tab) {
    var port = chrome.tabs.connect(tab.id);
    if (!port) {
      console.log("no port");
    } else {
      port.onMessage.addListener(function(data) {
        var address = data.values[0];
        gclient_geocode(address);
      });
      port.postMessage({message: "hello tab: " + tab.id});
    }
  });
};
</script>
<div class="toolstrip-button" onclick="map()">
<span>Mappy</span>
</div>
{'fraction_non_alphanumeric': 0.16767454645409566, 'fraction_numerical': 0.023639362286970864, 'mean_word_length': 3.158857142857143, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '4152626', 'n_tokens_mistral': 1388, 'n_tokens_neox': 1326, 'n_words': 195}