<commit_before>
    var create_type = 0;
    var interval = null;


    head(function(){

      $('div.geom_type span').click(function(ev){
        ev.stopPropagation();
        ev.preventDefault();
        if (!$(this).hasClass('selected')) {
          $('div.geom_type span').removeClass('selected');
          $(this).addClass('selected');
        }
      });
      
      $('div.geom_type span a').click(function(ev){
        ev.stopPropagation();
        ev.preventDefault();
        $(this).parent().trigger('click');
      });



      //Create new table
      $('a.new_table').click(function(ev){
         ev.preventDefault();
         ev.stopPropagation();
         resetUploadFile();
         $('div.create_window').show();
         $('div.mamufas').fadeIn();
         bindESC();
       });


      $('div.create_window ul li a').click(function(ev){
        ev.stopPropagation();
        ev.preventDefault();
        if (!$(this).parent().hasClass('selected') && !$(this).parent().hasClass('disabled') && !$(this).parent().is("span")) {
          $('div.create_window ul li').removeClass('selected');
          $(this).parent().addClass('selected');
          (create_type==0)?create_type++:create_type--;
        }
				
				if ($(this).closest('li').index()==1) {
					$('div.create_window span.bottom input').addClass('disabled');
				} else {
					$('div.create_window span.bottom input').removeClass('disabled');
				}
      });
      


      $('span.file input').hover(function(ev){
        $('span.file a').addClass('hover');
        $(document).css('cursor','pointer');
      },function(ev){
        $('span.file a').removeClass('hover');
        $(document).css('cursor','default');
      });

      var uploader = new qq.FileUploader({
        element: document.getElementById('uploader'),
        action: '/upload',
        params: {},
        allowedExtensions: ['csv', 'xls', 'xlsx', 'zip'],
        sizeLimit: 0, // max size
        minSizeLimit: 0, // min size
        debug: false,

        onSubmit: function(id, fileName){
          $('div.create_window ul li:eq(0)').addClass('disabled');
          $('form input[type="submit"]').addClass('disabled');
          $('span.file').addClass('uploading');
        },
        onProgress: function(id, fileName, loaded, total){
          var percentage = loaded / total;
          $('span.progress').width((346*percentage)/1);
        },
        onComplete: function(id, fileName, responseJSON){
          createNewToFinish('',responseJSON.file_uri);
        },
        onCancel: function(id, fileName){},
        showMessage: function(message){
          $('div.select_file p').text(message);
          $('div.select_file p').addClass('error');
        }
      });

      $('form#import_file').submit(function(ev){
        ev.stopPropagation();
        ev.preventDefault();
        if (create_type==0) {
          var geom_type = $('div.geom_type span.selected a').text();
          createNewToFinish(geom_type,'');
        }
      });
    });


    function resetUploadFile() {
      create_type = 0;
      $('div.create_window ul li:eq(0)').removeClass('disabled');
      $('div.create_window ul li').removeClass('selected');
      $('div.create_window ul li:eq(0)').addClass('selected');
      $('div.create_window div.inner_ form').show();
      $('div.create_window div.inner_ form').css('opacity',1);
      $('div.create_window div.inner_').css('border-color','#CCCCCC');
      $('div.create_window a.close_create').removeClass('last');
      $('div.create_window div.inner_').css('height','auto');
      $('div.create_window div.inner_ span.loading').hide();
      $('div.create_window div.inner_ span.loading').css('opacity',0);
      $('form input[type="submit"]').removeClass('disabled');
      $('span.file').removeClass('uploading');
      $('span.file input[type="file"]').attr('value','');
      $('div.select_file p').text('You can import .csv, .xls and .zip files');
      $('div.select_file p').removeClass('error');
      $('span.progress').width(5);
      $('div.create_window ul li:eq(1)').removeClass('finished');
      $('div.create_window').removeClass('georeferencing');
      $('div.create_window div.inner_ span.loading p').html('It\'s not gonna be a lot of time. Just a few seconds, ok?');
      $('div.create_window div.inner_ span.loading h5').html('We are creating your table...');
    }


    function createNewToFinish (type,url) {
      $('div.create_window div.inner_').animate({borderColor:'#FFC209', height:'68px'},500);
      $('div.create_window div.inner_ form').animate({opacity:0},300,function(){
        $('div.create_window div.inner_ span.loading').show();
				$('div.create_window a.close_create').hide();
        $('div.create_window div.inner_ span.loading').animate({opacity:1},200, function(){
          var params = {}
          if (url!='') {
            params = {file:'http://'+window.location.host + url};
          } else {
            params = {the_geom_type:type}
          }
          $.ajax({
            type: "POST",
            url: global_api_url+'tables/',
            data: params,
            headers: {'cartodbclient':true},
            success: function(data, textStatus, XMLHttpRequest) {
              window.location.href = "/tables/"+data.id;
            },
            error: function(e) {
              $('div.create_window div.inner_ span.loading').addClass('error');
              $('div.create_window div.inner_ span.loading p').html('Something weird has occurred when creating your table. Do you want to <a onclick="retryImportTable()">retry</a>?');
              $('div.create_window div.inner_ span.loading h5').text('Ops! There has been an error');
              $('div.create_window div.inner_').height(78);
            }
          });
        });
      });
      setTimeout(function(){$('div.create_window a.close_create').addClass('last');},250);
    }
    
    
    function retryImportTable() {
      $('div.create_window a.close_create').show().removeClass('last');
      $('div.create_window div.inner_').animate({borderColor:'#CCCCCC', height:'254px'},500,function(){
        $('div.create_window div.inner_').css('height','auto');
      });
      $('div.create_window ul li:eq(0)').removeClass('disabled');
      $('form input[type="submit"]').removeClass('disabled');
      $('span.file').removeClass('uploading');
      $('div.create_window div.inner_ span.loading').animate({opacity:0},300,function(){
        $('div.create_window div.inner_ span.loading').hide();
        $('div.create_window div.inner_ span.loading').removeClass('error');
        $('div.create_window div.inner_ span.loading p').html('It\'s not gonna be a lot of time. Just a few seconds, ok?');
        $('div.create_window div.inner_ span.loading h5').html('We are creating your table...');
        $('div.create_window div.inner_ form').show();
        $('div.create_window div.inner_ form').animate({opacity:1},200);
        $('div.select_file p').text('You can import .csv, .xls and .zip files');<commit_msg>new import messages<commit_after>
    var create_type = 0;
    var interval = null;


    head(function(){

      $('div.geom_type span').click(function(ev){
        ev.stopPropagation();
        ev.preventDefault();
        if (!$(this).hasClass('selected')) {
          $('div.geom_type span').removeClass('selected');
          $(this).addClass('selected');
        }
      });
      
      $('div.geom_type span a').click(function(ev){
        ev.stopPropagation();
        ev.preventDefault();
        $(this).parent().trigger('click');
      });



      //Create new table
      $('a.new_table').click(function(ev){
         ev.preventDefault();
         ev.stopPropagation();
         resetUploadFile();
         $('div.create_window').show();
         $('div.mamufas').fadeIn();
         bindESC();
       });


      $('div.create_window ul li a').click(function(ev){
        ev.stopPropagation();
        ev.preventDefault();
        if (!$(this).parent().hasClass('selected') && !$(this).parent().hasClass('disabled') && !$(this).parent().is("span")) {
          $('div.create_window ul li').removeClass('selected');
          $(this).parent().addClass('selected');
          (create_type==0)?create_type++:create_type--;
        }
				
				if ($(this).closest('li').index()==1) {
					$('div.create_window span.bottom input').addClass('disabled');
				} else {
					$('div.create_window span.bottom input').removeClass('disabled');
				}
      });
      


      $('span.file input').hover(function(ev){
        $('span.file a').addClass('hover');
        $(document).css('cursor','pointer');
      },function(ev){
        $('span.file a').removeClass('hover');
        $(document).css('cursor','default');
      });

      var uploader = new qq.FileUploader({
        element: document.getElementById('uploader'),
        action: '/upload',
        params: {},
        allowedExtensions: ['csv', 'xls', 'xlsx', 'zip'],
        sizeLimit: 0, // max size
        minSizeLimit: 0, // min size
        debug: false,

        onSubmit: function(id, fileName){
          $('div.create_window ul li:eq(0)').addClass('disabled');
          $('form input[type="submit"]').addClass('disabled');
          $('span.file').addClass('uploading');
        },
        onProgress: function(id, fileName, loaded, total){
          var percentage = loaded / total;
          $('span.progress').width((346*percentage)/1);
        },
        onComplete: function(id, fileName, responseJSON){
          createNewToFinish('',responseJSON.file_uri);
        },
        onCancel: function(id, fileName){},
        showMessage: function(message){
          $('div.select_file p').text(message);
          $('div.select_file p').addClass('error');
        }
      });

      $('form#import_file').submit(function(ev){
        ev.stopPropagation();
        ev.preventDefault();
        if (create_type==0) {
          var geom_type = $('div.geom_type span.selected a').text();
          createNewToFinish(geom_type,'');
        }
      });
    });


    function resetUploadFile() {
      create_type = 0;
      $('div.create_window ul li:eq(0)').removeClass('disabled');
      $('div.create_window ul li').removeClass('selected');
      $('div.create_window ul li:eq(0)').addClass('selected');
      $('div.create_window div.inner_ form').show();
      $('div.create_window div.inner_ form').css('opacity',1);
      $('div.create_window div.inner_').css('border-color','#CCCCCC');
      $('div.create_window a.close_create').removeClass('last');
      $('div.create_window div.inner_').css('height','auto');
      $('div.create_window div.inner_ span.loading').hide();
      $('div.create_window div.inner_ span.loading').css('opacity',0);
      $('form input[type="submit"]').removeClass('disabled');
      $('span.file').removeClass('uploading');
      $('span.file input[type="file"]').attr('value','');
      $('div.select_file p').text('You can import .csv, .xls and .zip files');
      $('div.select_file p').removeClass('error');
      $('span.progress').width(5);
      $('div.create_window ul li:eq(1)').removeClass('finished');
      $('div.create_window').removeClass('georeferencing');
      $('div.create_window div.inner_ span.loading p').html('It\'s not gonna be a lot of time. Just a few seconds, ok?');
      $('div.create_window div.inner_ span.loading h5').html('We are creating your table...');
    }


    function createNewToFinish (type,url) {
      $('div.create_window div.inner_').animate({borderColor:'#FFC209', height:'68px'},500);
      $('div.create_window div.inner_ form').animate({opacity:0},300,function(){
        $('div.create_window div.inner_ span.loading').show();
				$('div.create_window a.close_create').hide();
        $('div.create_window div.inner_ span.loading').animate({opacity:1},200, function(){
          var params = {}
          if (url!='') {
            params = {file:'http://'+window.location.host + url};
          } else {
            params = {the_geom_type:type}
          }
          $.ajax({
            type: "POST",
            url: global_api_url+'tables/',
            data: params,
            headers: {'cartodbclient':true},
            success: function(data, textStatus, XMLHttpRequest) {
              window.location.href = "/tables/"+data.id;
            },
            error: function(e) {
							var json = $.parseJSON(e.responseText);
              $('div.create_window div.inner_ span.loading').addClass('error');
              $('div.create_window div.inner_ span.loading p').html(json.hint);
              $('div.create_window div.inner_ span.loading h5').text(json.message);
							$('div.create_window a.close_create').show().addClass('last');
              $('div.create_window div.inner_').height(98);
            }
          });
        });
      });
      setTimeout(function(){$('div.create_window a.close_create').addClass('last');},250);
    }
    
    
    function retryImportTable() {
      $('div.create_window a.close_create').show().removeClass('last');
      $('div.create_window div.inner_').animate({borderColor:'#CCCCCC', height:'254px'},500,function(){
        $('div.create_window div.inner_').css('height','auto');
      });
      $('div.create_window ul li:eq(0)').removeClass('disabled');
      $('form input[type="submit"]').removeClass('disabled');
      $('span.file').removeClass('uploading');
      $('div.create_window div.inner_ span.loading').animate({opacity:0},300,function(){
        $('div.create_window div.inner_ span.loading').hide();
        $('div.create_window div.inner_ span.loading').removeClass('error');
        $('div.create_window div.inner_ span.loading p').html('It\'s not gonna be a lot of time. Just a few seconds, ok?');
        $('div.create_window div.inner_ span.loading h5').html('We are creating your table...');
        $('div.create_window div.inner_ form').show();
        $('div.create_window div.inner_ form').animate({opacity:1},200);
        $('div.select_file p').text('You can import .csv, .xls and .zip files');
{'fraction_non_alphanumeric': 0.19452326901248582, 'fraction_numerical': 0.008087400681044268, 'mean_word_length': 2.760202720725527, 'pattern_counts': {'":': 0, '<': 5, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '920623', 'n_tokens_mistral': 4291, 'n_tokens_neox': 4176, 'n_words': 694}