<commit_before># Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
jQuery ->
  geocoder = new google.maps.Geocoder()

  default_latlng = new google.maps.LatLng 43.66365, -79.377594

  if document.getElementById("global_map") != null
    global_map = new google.maps.Map document.getElementById("global_map"),
      center: default_latlng,
      zoom: 12,
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      scrollwheel: false

    incidentBounds = new google.maps.LatLngBounds()
    markers = {}

    plotMapCallback = (incidents_json) ->
      for incident in incidents_json
        vLatLng = new google.maps.LatLng incident.latitude, incident.longitude
        markers[incident.id] = new google.maps.Marker
          map: global_map,
          position: vLatLng,
          title: incident.to_s
        incidentBounds.extend vLatLng
        google.maps.event.addListener markers[incident.id], 'click', ->
          window.location.href = incident.url

      global_map.setCenter incidentBounds.getCenter()
      global_map.fitBounds incidentBounds

    jQuery.get '/incidents.json', plotMapCallback, 'json'

  if document.getElementById("preview_map") != null
    preview_map = new google.maps.Map document.getElementById("preview_map"),
      center: default_latlng,
      zoom: 13,
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      streetViewControl: false,
      mapTypeControl: false,
      scrollwheel: false

    preview_marker = new google.maps.Marker
      map: preview_map,
      position: default_latlng,
      visible: false

    window.geocodeAddressAndRenderPreview = ->
      addr = $('#incident_location').val()
      return if addr.length == 0
      $('#preview_map_updating').fadeIn()
      geocoder.geocode {'address': addr}, (results, status) ->
        if status == google.maps.GeocoderStatus.OK
          preview_map.setCenter results[0].geometry.location
          preview_map.setZoom 13<commit_msg>Wrap marker listener loop in closure. Fixes #41;<commit_after># Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
jQuery ->
  geocoder = new google.maps.Geocoder()

  default_latlng = new google.maps.LatLng 43.66365, -79.377594

  if document.getElementById("global_map") != null
    global_map = new google.maps.Map document.getElementById("global_map"),
      center: default_latlng,
      zoom: 12,
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      scrollwheel: false

    incidentBounds = new google.maps.LatLngBounds()
    markers = {}

    plotMapCallback = (incidents_json) ->
      for incident in incidents_json
        do (incident) ->
          vLatLng = new google.maps.LatLng incident.latitude, incident.longitude
          markers[incident.id] = new google.maps.Marker
            map: global_map,
            position: vLatLng,
            title: incident.to_s
          incidentBounds.extend vLatLng
          google.maps.event.addListener markers[incident.id], 'click', ->
            window.location.href = incident.url

      global_map.setCenter incidentBounds.getCenter()
      global_map.fitBounds incidentBounds

    jQuery.get '/incidents.json', plotMapCallback, 'json'

  if document.getElementById("preview_map") != null
    preview_map = new google.maps.Map document.getElementById("preview_map"),
      center: default_latlng,
      zoom: 13,
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      streetViewControl: false,
      mapTypeControl: false,
      scrollwheel: false

    preview_marker = new google.maps.Marker
      map: preview_map,
      position: default_latlng,
      visible: false

    window.geocodeAddressAndRenderPreview = ->
      addr = $('#incident_location').val()
      return if addr.length == 0
      $('#preview_map_updating').fadeIn()
      geocoder.geocode {'address': addr}, (results, status) ->
        if status == google.maps.GeocoderStatus.OK
          preview_map.setCenter results[0].geometry.location
          preview_map.setZoom 13
{'fraction_non_alphanumeric': 0.0976470588235294, 'fraction_numerical': 0.011294117647058824, 'mean_word_length': 3.0601719197707737, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, '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': '5200238', 'n_tokens_mistral': 1269, 'n_tokens_neox': 1218, 'n_words': 290}