<commit_before>.field-with-notes
  .fields
    = f.input :street_address, as: :string, input_html: { class: 'geo' }
    = f.input :locality, as: :string, input_html: { class: 'geo' }, label: 'Locality (e.g. town or city)'
    = f.input :region, as: :string, input_html: { class: 'geo' }, label: 'Region (e.g. county or province)'
    = f.input :country,  collection: Digitalsocial::EU_COUNTRIES, input_html: { class: 'geo' }
    = f.input :postal_code, as: :string
  .notes
    :markdown
      Please tell us where your organisation is based. If in doubt please use the head office address. We'll automatically try and find you on the map based on the address you enter.


:ruby
  messages_class = @organisation.errors.include?(:lat) || @organisation.errors.include?(:lng) ? 'error' : 'normal'

= content_tag :div, id: 'map-messages-wrapper', class: messages_class do
  #map-messages
    Click to place a pin at the location of your organisation's main office.

#map

#lat-lng
  = f.input :lat
  = f.input :lng

:javascript
  $(function() {

    var defaultCenter = [50,10];
    var defaultZoom = 4;
    var selectedZoom = 16;

    var lat = #{@organisation.lat.present? ? @organisation.lat : 'null'};
    var lng = #{@organisation.lng.present? ? @organisation.lng : 'null'};

    // hide the lat long fields
    $("#lat-lng").hide();

    var map = L.mapbox.map('map', '#{Digitalsocial::MAPBOX_SHOW_MAP_ID}', {scrollWheelZoom: false})
      .setView(defaultCenter,defaultZoom);

    var marker = null;

    // if we've got a lat lng, drop a pin
    if(lat && lng) {
      dropPin(lat, lng);
      map.setZoom(selectedZoom);
      map.panTo(new L.LatLng(lat, lng));
    }

    map.on('click', onMapClick);

    // handle forms changing

    function formFieldChanged() {
      var streetAddress = $('#organisation_presenter_street_address').val();
      var locality = $('#organisation_presenter_locality').val();
      var region = $('#organisation_presenter_region').val();
      var country = $('#organisation_presenter_country').val();

      // if we've got a street address, locality and country, then do the geo coding...
      if(streetAddress.length > 0 &&
          (locality.length > 0) &&
          country.length > 0 ) {
        geoCode(streetAddress, locality, region, country);
      }
    }

    $("input.geo, select.geo").on('change', formFieldChanged);

    function addSectionToGeoQuery(geoQuery, section) {
      if (section.length > 0) {
        if (geoQuery.length > 0) {geoQuery += ', '; }
        geoQuery += section;
      }
      return geoQuery;
    }

    function geoCode(streetAddress, locality, region, country, postalCode) {

      var url = 'http://nominatim.openstreetmap.org/search';

      geoQuery = '';
      geoQuery = addSectionToGeoQuery(geoQuery, streetAddress);
      geoQuery = addSectionToGeoQuery(geoQuery, locality);
      geoQuery = addSectionToGeoQuery(geoQuery, region);
      geoQuery = addSectionToGeoQuery(geoQuery, country);

      url += '?q=' + encodeURIComponent(geoQuery);
      url += '&email=#{Digitalsocial::NOMINATIM_EMAIL}';
      url += '&format=json';
      url += '&limit=1';

      setGeoCodingWorking();

      $.ajax({
        dataType: 'jsonp',
        jsonp: 'json_callback',
        url: url,
        success: function(data, textStatus, jqXHR) {
          if (data && data.length > 0) {
            var result = data[0];<commit_msg>Omit region from location geocode<commit_after>.field-with-notes
  .fields
    = f.input :street_address, as: :string, input_html: { class: 'geo' }
    = f.input :locality, as: :string, input_html: { class: 'geo' }, label: 'Locality (e.g. town or city)'
    = f.input :region, as: :string, input_html: { class: 'geo' }, label: 'Region (e.g. county or province)'
    = f.input :country,  collection: Digitalsocial::EU_COUNTRIES, input_html: { class: 'geo' }
    = f.input :postal_code, as: :string
  .notes
    :markdown
      Please tell us where your organisation is based. If in doubt please use the head office address. We'll automatically try and find you on the map based on the address you enter.


:ruby
  messages_class = @organisation.errors.include?(:lat) || @organisation.errors.include?(:lng) ? 'error' : 'normal'

= content_tag :div, id: 'map-messages-wrapper', class: messages_class do
  #map-messages
    Click to place a pin at the location of your organisation's main office.

#map

#lat-lng
  = f.input :lat
  = f.input :lng

:javascript
  $(function() {

    var defaultCenter = [50,10];
    var defaultZoom = 4;
    var selectedZoom = 16;

    var lat = #{@organisation.lat.present? ? @organisation.lat : 'null'};
    var lng = #{@organisation.lng.present? ? @organisation.lng : 'null'};

    // hide the lat long fields
    $("#lat-lng").hide();

    var map = L.mapbox.map('map', '#{Digitalsocial::MAPBOX_SHOW_MAP_ID}', {scrollWheelZoom: false})
      .setView(defaultCenter,defaultZoom);

    var marker = null;

    // if we've got a lat lng, drop a pin
    if(lat && lng) {
      dropPin(lat, lng);
      map.setZoom(selectedZoom);
      map.panTo(new L.LatLng(lat, lng));
    }

    map.on('click', onMapClick);

    // handle forms changing

    function formFieldChanged() {
      var streetAddress = $('#organisation_presenter_street_address').val();
      var locality = $('#organisation_presenter_locality').val();
      var country = $('#organisation_presenter_country').val();

      // if we've got a street address, locality and country, then do the geo coding...
      if(streetAddress.length > 0 &&
          (locality.length > 0) &&
          country.length > 0 ) {
        geoCode(streetAddress, locality, country);
      }
    }

    $("input.geo, select.geo").on('change', formFieldChanged);

    function addSectionToGeoQuery(geoQuery, section) {
      if (section.length > 0) {
        if (geoQuery.length > 0) {geoQuery += ', '; }
        geoQuery += section;
      }
      return geoQuery;
    }

    function geoCode(streetAddress, locality, country, postalCode) {

      var url = 'http://nominatim.openstreetmap.org/search';

      geoQuery = '';
      geoQuery = addSectionToGeoQuery(geoQuery, streetAddress);
      geoQuery = addSectionToGeoQuery(geoQuery, locality);
      geoQuery = addSectionToGeoQuery(geoQuery, country);

      url += '?q=' + encodeURIComponent(geoQuery);
      url += '&email=#{Digitalsocial::NOMINATIM_EMAIL}';
      url += '&format=json';
      url += '&limit=1';

      setGeoCodingWorking();

      $.ajax({
        dataType: 'jsonp',
        jsonp: 'json_callback',
        url: url,
        success: function(data, textStatus, jqXHR) {
          if (data && data.length > 0) {
            var result = data[0];
{'fraction_non_alphanumeric': 0.14223815927088002, 'fraction_numerical': 0.0044822949350067235, 'mean_word_length': 3.037394451145959, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '1454929', 'n_tokens_mistral': 2228, 'n_tokens_neox': 2118, 'n_words': 549}