<commit_before>var map;
var geocoder;
var marker = null;
var userid = "";
/*
 * handle the fact that the browser do not support geolocation
 */
function handleNoGeolocation(errorFlag) {
	var content;
    if (errorFlag) {
    	 content = 'Error: The Geolocation service failed.';
    } else {
    	content = 'Error: Your browser doesn\'t support geolocation.';
    }
    console.log(content);
    var options = {
      map: map,
      position: new google.maps.LatLng(10, 0),
      content: content
    };

    /*var infowindow = new google.maps.InfoWindow(options);*/
    map.setCenter(options.position);
}

/*
 * create the map
 */
function initialize() {
	geocoder = new google.maps.Geocoder();

    var mapOptions = {
      center: new google.maps.LatLng(10, 0),
      zoom: 5,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById("map"),
        mapOptions);
   locate();
   
   google.maps.event.addListener(map, 'click', function(event) {
	    addMarker(event.latLng);
	  });

}

//Add a marker to the map and push to the array.
function addMarker(location) {
	if(marker == null)
	{
		marker = new google.maps.Marker({
		    position: location,
		    map: map
		});
	}
	else
		marker.setPosition(location);
}


function locate()
{
	// Try HTML5 geolocation
   if(navigator.geolocation) 
    {
      navigator.geolocation.getCurrentPosition(function(position) 
    		  {
		        var pos = new google.maps.LatLng(position.coords.latitude,
		                                         position.coords.longitude);
		        
		        map.setCenter(pos);
		      }, function() {
		        handleNoGeolocation(true);
		      });
    } 
    else 
    {
      // Browser doesn't support Geolocation
      handleNoGeolocation(false);
      
    }
}

function codeAddress() {
	  var address = document.getElementById('address').value;
	  geocoder.geocode( { 'address': address}, function(results, status) {
	    if (status == google.maps.GeocoderStatus.OK) {
	      map.setCenter(results[0].geometry.location);
	      marker = new google.maps.Marker({
	          map: map,
	          position: results[0].geometry.location
	      });

	    } else {
	      alert('Geocode was not successful for the following reason: ' + status);
	    }
	  });
	  map.setZoom(8);
}

google.maps.event.addDomListener(window, 'load', initialize);

/**
 * to have a nice file input which look like boostrap
 */
$(document)
.on('change', '.btn-file :file', function() {
    var input = $(this),
        numFiles = input.get(0).files ? input.get(0).files.length : 1,
        value = input.val(),
        label = value.replace(/\\/g, '/').replace(/.*\//, '');
    //input.trigger('fileselect', [numFiles, label]);
    $("#showfile").val(label);
});

$(document).ready(function(){
	checkRadioChange();
	$("#gothere").click(function(){codeAddress(); $("#locatetome").attr('checked', false);});
	$("#locatetome").click(function(){
		if($(this).is(":checked"))
			locate();
	});
	$("#submit").click(function(){
		checkAndSend();
	});
	$("#error").hide();
	userid = $("#userid").val();
});

/*
 * check the data to be correct then send the data
 */
function checkAndSend()
{
	$("#error").hide();
	if(marker == null)
		error("You must provide a location for your media! Please click on the map where you want to add your media");
	else if(!$("#picture").val() && !$("#showfile").val() && !$("#video").val())
		error("You must provide a media content! A picture via url, via upload or a youtube link");
	else
	{
		var urlpicture = $("#picture").val();
		var go = true;
		//if the user want to upload a picture
		if($("#showfile").val() && !$("#video").val())
		{
			var file = $(".btn-file :file").prop("files")[0];
	        name = file.name;
	        size = file.size;
	        type = file.type;
	        
	        if(file.size > 5000000) {
	            error("File is to big it have to be under 5MO");
	            go = false;<commit_msg>hotfix<commit_after>var map;
var geocoder;
var marker = null;
var userid = "";
/*
 * handle the fact that the browser do not support geolocation
 */
function handleNoGeolocation(errorFlag) {
	var content;
    if (errorFlag) {
    	 content = 'Error: The Geolocation service failed.';
    } else {
    	content = 'Error: Your browser doesn\'t support geolocation.';
    }
    console.log(content);
    var options = {
      map: map,
      position: new google.maps.LatLng(10, 0),
      content: content
    };

    /*var infowindow = new google.maps.InfoWindow(options);*/
    map.setCenter(options.position);
}

/*
 * create the map
 */
function initialize() {
	geocoder = new google.maps.Geocoder();

    var mapOptions = {
      center: new google.maps.LatLng(10, 0),
      zoom: 5,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById("map"),
        mapOptions);
   locate();
   
   google.maps.event.addListener(map, 'click', function(event) {
	    addMarker(event.latLng);
	  });

}

//Add a marker to the map and push to the array.
function addMarker(location) {
	if(marker == null)
	{
		marker = new google.maps.Marker({
		    position: location,
		    map: map
		});
	}
	else
		marker.setPosition(location);
}


function locate()
{
	// Try HTML5 geolocation
   if(navigator.geolocation) 
    {
      navigator.geolocation.getCurrentPosition(function(position) 
    		  {
		        var pos = new google.maps.LatLng(position.coords.latitude,
		                                         position.coords.longitude);
		        
		        map.setCenter(pos);
		      }, function() {
		        handleNoGeolocation(true);
		      });
    } 
    else 
    {
      // Browser doesn't support Geolocation
      handleNoGeolocation(false);
      
    }
}

function codeAddress() {
	  var address = document.getElementById('address').value;
	  geocoder.geocode( { 'address': address}, function(results, status) {
	    if (status == google.maps.GeocoderStatus.OK) {
	      map.setCenter(results[0].geometry.location);
	      marker = new google.maps.Marker({
	          map: map,
	          position: results[0].geometry.location
	      });

	    } else {
	      alert('Geocode was not successful for the following reason: ' + status);
	    }
	  });
	  map.setZoom(8);
}

google.maps.event.addDomListener(window, 'load', initialize);

/**
 * to have a nice file input which look like boostrap
 */
$(document)
.on('change', '.btn-file :file', function() {
    var input = $(this),
        numFiles = input.get(0).files ? input.get(0).files.length : 1,
        value = input.val(),
        label = value.replace(/\\/g, '/').replace(/.*\//, '');
    //input.trigger('fileselect', [numFiles, label]);
    $("#showfile").val(label);
});

$(document).ready(function(){
	checkRadioChange();
	$("#gothere").click(function(){codeAddress(); $("#locatetome").attr('checked', false);});
	$("#locatetome").click(function(){
		if($(this).is(":checked"))
			locate();
	});
	$("#submit").click(function(){
		checkAndSend();
	});
	$("#error").hide();
	userid = $("#userid").text();
});

/*
 * check the data to be correct then send the data
 */
function checkAndSend()
{
	$("#error").hide();
	if(marker == null)
		error("You must provide a location for your media! Please click on the map where you want to add your media");
	else if(!$("#picture").val() && !$("#showfile").val() && !$("#video").val())
		error("You must provide a media content! A picture via url, via upload or a youtube link");
	else
	{
		var urlpicture = $("#picture").val();
		var go = true;
		//if the user want to upload a picture
		if($("#showfile").val() && !$("#video").val())
		{
			var file = $(".btn-file :file").prop("files")[0];
	        name = file.name;
	        size = file.size;
	        type = file.type;
	        
	        if(file.size > 5000000) {
	            error("File is to big it have to be under 5MO");
	            go = false;
{'fraction_non_alphanumeric': 0.1654876200101061, 'fraction_numerical': 0.005811015664477008, 'mean_word_length': 2.711673699015471, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3346511', 'n_tokens_mistral': 2606, 'n_tokens_neox': 2460, 'n_words': 603}