<commit_before>{% extends "maposmatic/base.html" %}

{% comment %}
 coding: utf-8

 maposmatic, the web front-end of the MapOSMatic city map generation system
 Copyright (C) 2009  <NAME>
 Copyright (C) 2009  <NAME>
 Copyright (C) 2009  <NAME>
 Copyright (C) 2009  <NAME>
 Copyright (C) 2009  <NAME>
 Copyright (C) 2009  <NAME>

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU Affero General Public License as
 published by the Free Software Foundation, either version 3 of the
 License, or any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU Affero General Public License for more details.

 You should have received a copy of the GNU Affero General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
{% endcomment %}
{% load i18n %}

{% block extralink %}
<script type="text/javascript" src="/smedia/jquery.js"></script>
{{ form.media }}
{% endblock %}

{% block extrajs %}
String.prototype.startsWith = function(str) { return this.indexOf(str) === 0; }

function area_selection_mode_switch(mode)
{
  var arr = document.getElementById('mapform').getElementsByTagName('tr');
  for (i=0; i < arr.length; i++) {
    if (arr[i].className.startsWith('byadmin')) {
      arr[i].style.display = 'none';
      if (mode == 'admin-mode')
        arr[i].style.display = 'table-row';
    }
    if (arr[i].className.startsWith('bybbox')) {
      arr[i].style.display = 'none';
      if (mode == 'bbox-mode')
        arr[i].style.display = 'table-row';
    }
  }

  if (mode == 'bbox-mode') {
    /* re-activate form */
    toggle_form_validation("true");
    reset_osmid_field();
    if (map == null) init();
  }
  else
  {
    /* de-activate form */
    toggle_form_validation("false");
    /* and empty list of previous Nominatim results */
    $("#result_nominatim_search").empty();
    $("#id_administrative_city").attr("value", "");
  }
}

function reset_osmid_field()
{
    $("#id_administrative_osmid").attr("value", "");
}

function pageinit()
{
  document.getElementById('id_mode_0').setAttribute('onclick',
    "area_selection_mode_switch('admin-mode')");
  document.getElementById('id_mode_1').setAttribute('onclick',
    "area_selection_mode_switch('bbox-mode')");

  if (document.getElementById('id_mode_1').checked)
    area_selection_mode_switch('bbox-mode');
  else
    area_selection_mode_switch('admin-mode');

  $('#id_administrative_city').keypress(function (e)
					{
					  /* disable autoposting (keypress on return(13))
					   *  doing a search instead */
					  if (e.which == 13)
					  {
					    validate_city_search();
					    return false;
					  }
					});
}

var elemFound = 0 ;

function toggle_form_validation(enableForm)
{

  if (enableForm == "true")
    {
       $("#id-go-next-btn").removeAttr("disabled");
       $("#id-go-next-btn").attr("class", "btn-enabled");
       $("#id-go-next-btn").attr("title", "{% trans "Generate" %}");
       $("#id-go-next-btn").attr("src", "/smedia/Go-next.png");
    }
  else
    {
       $("#id-go-next-btn").attr("disabled", "true");
       $("#id-go-next-btn").attr("class", "btn-disabled");
       $("#id-go-next-btn").attr("title", "{% trans "Please fill in the form before trying to proceed" %}");
       $("#id-go-next-btn").attr("src", "/smedia/Go-next-disabled.png");
    }
}

function validate_city_search()
{

  toggle_form_validation('false');
  languages_show_all();
  $("#result_nominatim_search").empty();
  $("#result_nominatim_search").append("<li><img src=\"/smedia/loading.gif\" alt=\"Loading\" /></li>");

  var searchPat = $("#id_administrative_city").attr("value") ;

  elemFound = 0;

  $.getJSON("/nominatim/" + searchPat,
            function(data){
              $("#result_nominatim_search").empty();


              $.each(data, function(i,item){
		if (typeof item.ocitysmap_params == "undefined")
		{
		  $("#result_nominatim_search").append("<li><img src=\"/smedia/icon_alert.png\" "+
 	          "alt=\"Work In Progress\" title=\"{% trans "This place cannot be rendered by MapOSMatic, administrative boundary missing. Please contribute !" %}\" />"+
		    "&nbsp;<label class=\"place_unavailable\""
		    + ">" +item.display_name + "</label></li>");
                }
		else
                {
                  $("#result_nominatim_search").append("<li><input onchange=\"javascript:update_hidden(this,'"
		     +item.display_name+"'); languages_select('" + item.country_code + "');\" type=\"radio\" name=\"administrative_tmp_osmid\" value=\""
		     +item.ocitysmap_params['id']+"\" id=\"rd"+item.ocitysmap_params['id']+"\"/><label for=\"rd"+
		     item.ocitysmap_params['id']+"\">" +item.display_name+"</label></li>");
		  elemFound = elemFound + 1;
                }
	      });

	      if (elemFound == 0)
              {
	 	 toggle_form_validation("false");
	         $("#result_nominatim_search").empty();
                 $("#result_nominatim_search").append("<li><b>{% trans 'No results found.' %}</b></li>");
              }
	    });
}

function languages_select(country)
{
  var nonhidden = null;
  $('#id_map_language').find('option').each(function() {
   var ischoosen = $(this).val().match(".._" + country.toUpperCase() + "\..*");
   if (ischoosen == null) {
     $(this).hide();
   }
   else {
     $(this).show();
     if (nonhidden == null)
        nonhidden = $(this);
   }
   });

   nonhidden.attr('selected', 'selected');
}

function languages_show_all()
{
  $('#id_map_language').find('option').each(function() {
    $(this).show();
  });
}

function update_hidden(obj, nloc)
{
  toggle_form_validation("true");<commit_msg>Match language 'C' in all cases<commit_after>{% extends "maposmatic/base.html" %}

{% comment %}
 coding: utf-8

 maposmatic, the web front-end of the MapOSMatic city map generation system
 Copyright (C) 2009  <NAME>
 Copyright (C) 2009  <NAME>
 Copyright (C) 2009  <NAME>
 Copyright (C) 2009  <NAME>
 Copyright (C) 2009  <NAME>
 Copyright (C) 2009  <NAME>

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU Affero General Public License as
 published by the Free Software Foundation, either version 3 of the
 License, or any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU Affero General Public License for more details.

 You should have received a copy of the GNU Affero General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
{% endcomment %}
{% load i18n %}

{% block extralink %}
<script type="text/javascript" src="/smedia/jquery.js"></script>
{{ form.media }}
{% endblock %}

{% block extrajs %}
String.prototype.startsWith = function(str) { return this.indexOf(str) === 0; }

function area_selection_mode_switch(mode)
{
  var arr = document.getElementById('mapform').getElementsByTagName('tr');
  for (i=0; i < arr.length; i++) {
    if (arr[i].className.startsWith('byadmin')) {
      arr[i].style.display = 'none';
      if (mode == 'admin-mode')
        arr[i].style.display = 'table-row';
    }
    if (arr[i].className.startsWith('bybbox')) {
      arr[i].style.display = 'none';
      if (mode == 'bbox-mode')
        arr[i].style.display = 'table-row';
    }
  }

  if (mode == 'bbox-mode') {
    /* re-activate form */
    toggle_form_validation("true");
    reset_osmid_field();
    if (map == null) init();
  }
  else
  {
    /* de-activate form */
    toggle_form_validation("false");
    /* and empty list of previous Nominatim results */
    $("#result_nominatim_search").empty();
    $("#id_administrative_city").attr("value", "");
  }
}

function reset_osmid_field()
{
    $("#id_administrative_osmid").attr("value", "");
}

function pageinit()
{
  document.getElementById('id_mode_0').setAttribute('onclick',
    "area_selection_mode_switch('admin-mode')");
  document.getElementById('id_mode_1').setAttribute('onclick',
    "area_selection_mode_switch('bbox-mode')");

  if (document.getElementById('id_mode_1').checked)
    area_selection_mode_switch('bbox-mode');
  else
    area_selection_mode_switch('admin-mode');

  $('#id_administrative_city').keypress(function (e)
					{
					  /* disable autoposting (keypress on return(13))
					   *  doing a search instead */
					  if (e.which == 13)
					  {
					    validate_city_search();
					    return false;
					  }
					});
}

var elemFound = 0 ;

function toggle_form_validation(enableForm)
{

  if (enableForm == "true")
    {
       $("#id-go-next-btn").removeAttr("disabled");
       $("#id-go-next-btn").attr("class", "btn-enabled");
       $("#id-go-next-btn").attr("title", "{% trans "Generate" %}");
       $("#id-go-next-btn").attr("src", "/smedia/Go-next.png");
    }
  else
    {
       $("#id-go-next-btn").attr("disabled", "true");
       $("#id-go-next-btn").attr("class", "btn-disabled");
       $("#id-go-next-btn").attr("title", "{% trans "Please fill in the form before trying to proceed" %}");
       $("#id-go-next-btn").attr("src", "/smedia/Go-next-disabled.png");
    }
}

function validate_city_search()
{

  toggle_form_validation('false');
  languages_show_all();
  $("#result_nominatim_search").empty();
  $("#result_nominatim_search").append("<li><img src=\"/smedia/loading.gif\" alt=\"Loading\" /></li>");

  var searchPat = $("#id_administrative_city").attr("value") ;

  elemFound = 0;

  $.getJSON("/nominatim/" + searchPat,
            function(data){
              $("#result_nominatim_search").empty();


              $.each(data, function(i,item){
		if (typeof item.ocitysmap_params == "undefined")
		{
		  $("#result_nominatim_search").append("<li><img src=\"/smedia/icon_alert.png\" "+
 	          "alt=\"Work In Progress\" title=\"{% trans "This place cannot be rendered by MapOSMatic, administrative boundary missing. Please contribute !" %}\" />"+
		    "&nbsp;<label class=\"place_unavailable\""
		    + ">" +item.display_name + "</label></li>");
                }
		else
                {
                  $("#result_nominatim_search").append("<li><input onchange=\"javascript:update_hidden(this,'"
		     +item.display_name+"'); languages_select('" + item.country_code + "');\" type=\"radio\" name=\"administrative_tmp_osmid\" value=\""
		     +item.ocitysmap_params['id']+"\" id=\"rd"+item.ocitysmap_params['id']+"\"/><label for=\"rd"+
		     item.ocitysmap_params['id']+"\">" +item.display_name+"</label></li>");
		  elemFound = elemFound + 1;
                }
	      });

	      if (elemFound == 0)
              {
	 	 toggle_form_validation("false");
	         $("#result_nominatim_search").empty();
                 $("#result_nominatim_search").append("<li><b>{% trans 'No results found.' %}</b></li>");
              }
	    });
}

function languages_select(country)
{
  var nonhidden = null;
  $('#id_map_language').find('option').each(function() {
   var ischoosen = $(this).val().match(".._" + country.toUpperCase() + "\..*") != null || $(this).val() == 'C';
   if (! ischoosen) {
     $(this).hide();
   }
   else {
     $(this).show();
     if (nonhidden == null)
        nonhidden = $(this);
   }
   });

   nonhidden.attr('selected', 'selected');
}

function languages_show_all()
{
  $('#id_map_language').find('option').each(function() {
    $(this).show();
  });
}

function update_hidden(obj, nloc)
{
  toggle_form_validation("true");
{'fraction_non_alphanumeric': 0.18439167096885217, 'fraction_numerical': 0.007055584236792291, 'mean_word_length': 3.3144023756495917, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '348392', 'n_tokens_mistral': 3902, 'n_tokens_neox': 3671, 'n_words': 768}