<commit_before>$(document).ready(function(){
  $("#imageup").submit(function(event){
    event.preventDefault();
    $.ajax( {
      url: '/api/image/new',
      type: 'POST',
      data: new FormData( this ),
      processData: false,
      contentType: false,
      success: function(data){
        if(data.success){
          $(".alerts").append("<div class=\"alert-box success\" data-alert>Image successfully uploaded! <a style='color:#fff' href=/i/"+data.name+"><i class='fa fa-external-link'></i>[Image link]</a><a class=\"close\">&times;</a></div>");
          $("#imageup")[0].reset();
        $(document).foundation('alert','reflow');
        } else {
          $(".alerts").append("<div class=\"alert-box alert\" data-alert>Failed upload<a class=\"close\">&times;</a></div>");
        $(document).foundation('alert','reflow');
        }
      }
    });
  });
  $("#remoteimageup").submit(function(event){
    event.preventDefault();
	  $.post( "/api/image/remote", $( this ).serialize(), function(data){
        if(data.success){
          $(".alerts").append("<div class=\"alert-box success\" data-alert>Image successfully uploaded! <a style='color:#fff' href=/i/"+data.name+"><i class='fa fa-external-link'></i>[Image link]</a><a class=\"close\">&times;</a></div>");
          $("#remoteimageup")[0].reset();
        $(document).foundation('alert','reflow');
        } else {
          $(".alerts").append("<div class=\"alert-box alert\" data-alert>Failed upload<a class=\"close\">&times;</a></div>");
        $(document).foundation('alert','reflow');
        }
	  });
  });  

  $("#fileup").submit(function(event){
    event.preventDefault();
    $.ajax( {
      url: '/api/file/new',
      type: 'POST',
      data: new FormData( this ),
      processData: false,
      contentType: false,
      success: function(data){
        if(data.success){
          $(".alerts").append("<div class=\"alert-box success\" data-alert>File successfully uploaded! <a style='color:#fff' href=/d/"+data.name+"><i class='fa fa-external-link'></i>[File link]</a><a class=\"close\">&times;</a></div>");
          $("#fileup")[0].reset();
          $(document).foundation('alert','reflow');
        } else {
          $(".alerts").append("<div class=\"alert-box alert\" data-alert>Failed upload<a class=\"close\">&times;</a></div>");
          $(document).foundation('alert','reflow');
        }
      }
    });
  });
  $("#remotefileup").submit(function(event){
    event.preventDefault();
    $.post( "/api/file/remote", $( this ).serialize(), function(data){
        if(data.success){
          $(".alerts").append("<div class=\"alert-box success\" data-alert>File successfully uploaded! <a style='color:#fff' href=/d/"+data.name+"><i class='fa fa-external-link'></i>[File link]</a><a class=\"close\">&times;</a></div>");
          $("#remotefileup")[0].reset();
        $(document).foundation('alert','reflow');
        } else {
          $(".alerts").append("<div class=\"alert-box alert\" data-alert>Failed upload<a class=\"close\">&times;</a></div>");
        $(document).foundation('alert','reflow');
        }
    });
  }); 

  $("#shorturl").submit(function(event){
    event.preventDefault();  
    console.log( $( this ).serialize() ); 
    $.post( "/api/shorten/new", $( this ).serialize(), function(data){
        if(data.success){
          $(".alerts").append("<div class=\"alert-box success\" data-alert>Link successfully shortened! <a style='color:#fff' href="+data.name+"><i class='fa fa-external-link'></i>[Short URL]</a><a class=\"close\">&times;</a></div>");
          $("#shorturl")[0].reset();
        $(document).foundation('alert','reflow');
        } else {
          $(".alerts").append("<div class=\"alert-box alert\" data-alert>Failed to shorten URL<a class=\"close\">&times;</a></div>");
        $(document).foundation('alert','reflow');
        }
      });
  }); 

  $("#shorturl2").submit(function(event){
    event.preventDefault();  
    console.log( $( this ).serialize() ); 
    $.post( "/api/shorten/new", $( this ).serialize(), function(data){
        if(data.success){
          $(".alerts").append("<div class=\"alert-box success\" data-alert>Link successfully shortened! <a style='color:#fff' href="+data.name+"><i class='fa fa-external-link'></i>[Short URL]</a><a class=\"close\">&times;</a></div>");
          $("#shorturl")[0].reset();
        $(document).foundation('alert','reflow');
        } else {
          $(".alerts").append("<div class=\"alert-box alert\" data-alert>Failed to shorten URL<a class=\"close\">&times;</a></div>");
        $(document).foundation('alert','reflow');
        }
      });
  });   

  $("a.delete").click(function(event){
    event.preventDefault();
    var link = $( this ).attr("href");
    //console.log( link );
    $.get( link, function(data){
        if(data.success){
          $(".alerts").append("<div class=\"alert-box success\" data-alert>Successfully deleted "+data.name+"!<a class=\"close\">&times;</a></div>");
        $(document).foundation('alert','reflow');
        } else {
          $(".alerts").append("<div class=\"alert-box alert\" data-alert>Failed to delete<a class=\"close\">&times;</a></div>");
        $(document).foundation('alert','reflow');
        }
    });    
  });

  $("#login").submit(function(event){
    event.preventDefault();   
    $.post( "login", $( this ).serialize(), function(data){
      if(data.success){
        $(location).attr('href', data.name);
        //$(".alerts").append("<div class=\"alert-box success\" data-alert>Successful login<a class=\"close\">&times;</a></div>");
        //$("#login-form").remove();
        //$(document).foundation('alert','reflow');
      } else {
        $(".alerts").append("<div class=\"alert-box alert\" data-alert>Failed login<a class=\"close\">&times;</a></div>");<commit_msg>Delete function now pops up a modal<commit_after>$(document).ready(function(){
  $("#imageup").submit(function(event){
    event.preventDefault();
    $.ajax( {
      url: '/api/image/new',
      type: 'POST',
      data: new FormData( this ),
      processData: false,
      contentType: false,
      success: function(data){
        if(data.success){
          $(".alerts").append("<div class=\"alert-box success\" data-alert>Image successfully uploaded! <a style='color:#fff' href=/i/"+data.name+"><i class='fa fa-external-link'></i>[Image link]</a><a class=\"close\">&times;</a></div>");
          $("#imageup")[0].reset();
        $(document).foundation('alert','reflow');
        } else {
          $(".alerts").append("<div class=\"alert-box alert\" data-alert>Failed upload<a class=\"close\">&times;</a></div>");
        $(document).foundation('alert','reflow');
        }
      }
    });
  });
  $("#remoteimageup").submit(function(event){
    event.preventDefault();
	  $.post( "/api/image/remote", $( this ).serialize(), function(data){
        if(data.success){
          $(".alerts").append("<div class=\"alert-box success\" data-alert>Image successfully uploaded! <a style='color:#fff' href=/i/"+data.name+"><i class='fa fa-external-link'></i>[Image link]</a><a class=\"close\">&times;</a></div>");
          $("#remoteimageup")[0].reset();
        $(document).foundation('alert','reflow');
        } else {
          $(".alerts").append("<div class=\"alert-box alert\" data-alert>Failed upload<a class=\"close\">&times;</a></div>");
        $(document).foundation('alert','reflow');
        }
	  });
  });  

  $("#fileup").submit(function(event){
    event.preventDefault();
    $.ajax( {
      url: '/api/file/new',
      type: 'POST',
      data: new FormData( this ),
      processData: false,
      contentType: false,
      success: function(data){
        if(data.success){
          $(".alerts").append("<div class=\"alert-box success\" data-alert>File successfully uploaded! <a style='color:#fff' href=/d/"+data.name+"><i class='fa fa-external-link'></i>[File link]</a><a class=\"close\">&times;</a></div>");
          $("#fileup")[0].reset();
          $(document).foundation('alert','reflow');
        } else {
          $(".alerts").append("<div class=\"alert-box alert\" data-alert>Failed upload<a class=\"close\">&times;</a></div>");
          $(document).foundation('alert','reflow');
        }
      }
    });
  });
  $("#remotefileup").submit(function(event){
    event.preventDefault();
    $.post( "/api/file/remote", $( this ).serialize(), function(data){
        if(data.success){
          $(".alerts").append("<div class=\"alert-box success\" data-alert>File successfully uploaded! <a style='color:#fff' href=/d/"+data.name+"><i class='fa fa-external-link'></i>[File link]</a><a class=\"close\">&times;</a></div>");
          $("#remotefileup")[0].reset();
        $(document).foundation('alert','reflow');
        } else {
          $(".alerts").append("<div class=\"alert-box alert\" data-alert>Failed upload<a class=\"close\">&times;</a></div>");
        $(document).foundation('alert','reflow');
        }
    });
  }); 

  $("#shorturl").submit(function(event){
    event.preventDefault();  
    console.log( $( this ).serialize() ); 
    $.post( "/api/shorten/new", $( this ).serialize(), function(data){
        if(data.success){
          $(".alerts").append("<div class=\"alert-box success\" data-alert>Link successfully shortened! <a style='color:#fff' href="+data.name+"><i class='fa fa-external-link'></i>[Short URL]</a><a class=\"close\">&times;</a></div>");
          $("#shorturl")[0].reset();
        $(document).foundation('alert','reflow');
        } else {
          $(".alerts").append("<div class=\"alert-box alert\" data-alert>Failed to shorten URL<a class=\"close\">&times;</a></div>");
        $(document).foundation('alert','reflow');
        }
      });
  }); 

  $("#shorturl2").submit(function(event){
    event.preventDefault();  
    console.log( $( this ).serialize() ); 
    $.post( "/api/shorten/new", $( this ).serialize(), function(data){
        if(data.success){
          $(".alerts").append("<div class=\"alert-box success\" data-alert>Link successfully shortened! <a style='color:#fff' href="+data.name+"><i class='fa fa-external-link'></i>[Short URL]</a><a class=\"close\">&times;</a></div>");
          $("#shorturl")[0].reset();
        $(document).foundation('alert','reflow');
        } else {
          $(".alerts").append("<div class=\"alert-box alert\" data-alert>Failed to shorten URL<a class=\"close\">&times;</a></div>");
        $(document).foundation('alert','reflow');
        }
      });
  });   

  $("a.delete").click(function(event){
    event.preventDefault();
    var link = $( this ).attr("href");
    //console.log( link );
    $.get( link, function(data){
        if(data.success){
          //<div class=\"alert-box success\" data-alert>Successfully deleted "+data.name+"!<a class=\"close\">&times;</a></div>");
          //$(document).foundation('alert','reflow');
            $(".alerts").append("<div id=\"alertModal\" class=\"reveal-modal\" data-reveal aria-labelledby=\"modalTitle\" aria-hidden=\"true\" role=\"dialog\">\
	           <h2 id=\"modalTitle\">Successfully deleted "+data.name+"!</h2>\
	           <p class=\"lead\">"+data.name+" has been successfully deleted.</p>\
	           <a class=\"close-reveal-modal\" aria-label=\"Close\">&#215;</a>\
                </div>");
            $('#alertModal').foundation('reveal', 'open');
            $(document).foundation('reveal', 'reflow');
            $(document).on('closed.fndtn.reveal', '[data-reveal]', function () {
              //var modal = $(this);
              location.reload();
            });
        } else {
          //$(".alerts").append("<div class=\"alert-box alert\" data-alert>Failed to delete<a class=\"close\">&times;</a></div>");
          //$(document).foundation('alert','reflow');
            $(".alerts").append("<div id=\"alertModal\" class=\"reveal-modal\" data-reveal aria-labelledby=\"modalTitle\" aria-hidden=\"true\" role=\"dialog\">\
	           <h2 id=\"modalTitle\">Failed to delete "+data.name+"!</h2>\
	           <p class=\"lead\">"+data.name+" was unable to be deleted for some reason :( </p>\
	           <a class=\"close-reveal-modal\" aria-label=\"Close\">&#215;</a>\
                </div>");
            $('#alertModal').foundation('reveal', 'open');
            $(document).foundation('reveal', 'reflow');
            $(document).on('closed.fndtn.reveal', '[data-reveal]', function () {
              //var modal = $(this);
              location.reload();
            });          
        }
    });    
  });

  $("#login").submit(function(event){
    event.preventDefault();   
    $.post( "login", $( this ).serialize(), function(data){
      if(data.success){
        $(location).attr('href', data.name);
        //$(".alerts").append("<div class=\"alert-box success\" data-alert>Successful login<a class=\"close\">&times;</a></div>");
        //$("#login-form").remove();
        //$(document).foundation('alert','reflow');
      } else {
        $(".alerts").append("<div class=\"alert-box alert\" data-alert>Failed login<a class=\"close\">&times;</a></div>");
{'fraction_non_alphanumeric': 0.2478847473130574, 'fraction_numerical': 0.001829407729247656, 'mean_word_length': 2.9890544238370325, 'pattern_counts': {'":': 0, '<': 195, '<?xml version=': 0, '>': 195, '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': '865359', 'n_tokens_mistral': 3961, 'n_tokens_neox': 3916, 'n_words': 617}