<commit_before>$(document).ready(function() {
  $('input[type=file]').bootstrapFileInput();
  $('.file-inputs').bootstrapFileInput();
  $('.fancybox').fancybox();

  $('#newImageForm').submit(submitNewImg);

  loadAlbum();
});

function submitNewImg(e) {
  e.preventDefault();

  var table = $('.albumTable');
  var albumID = table.attr('id');

  $.ajax({
    url: '/api/album/'+albumID+'/upload',
    type: 'POST',
    data: new FormData(this),
    processData: false,
    contentType: false,
    success: function(data) {
      location.reload();
    },
    failure: function(err) {
      throw err;
    }
  });
}

function loadAlbum() {
  var table = $('.albumTable');
  var albumID = table.attr('id');
  console.log("ALBUM ID:", albumID);

  // Fetch album
  $.ajax({
    url: '/api/album/'+albumID,
    type: 'GET',
    success: function(album) {
      // Load title
      $('#singleAlbumTitle').text(album.title);

      // Load assets
      for (var i = 0; i < album.assets.length; i++) {
        var asset = album.assets[i];

        var div = $('<div>');
        div.attr('class', 'col-md-4 albumCell');

        var a = $('<a>');
        a.attr('class', 'fancybox');
        a.attr('rel', 'group');
        a.attr('href', asset.fullURL);

        var img = $('<img>');
        img.attr('src', asset.thumbURL);

        a.append(img);
        div.append(a);
        table.append(div);
      }
    },
    failure: function(err) {
      throw err;
    }
  });
}<commit_msg>Prepend photos instead of append. Newest in front<commit_after>$(document).ready(function() {
  $('input[type=file]').bootstrapFileInput();
  $('.file-inputs').bootstrapFileInput();
  $('.fancybox').fancybox();

  $('#newImageForm').submit(submitNewImg);

  loadAlbum();
});

function submitNewImg(e) {
  e.preventDefault();

  var table = $('.albumTable');
  var albumID = table.attr('id');

  $.ajax({
    url: '/api/album/'+albumID+'/upload',
    type: 'POST',
    data: new FormData(this),
    processData: false,
    contentType: false,
    success: function(data) {
      location.reload();
    },
    failure: function(err) {
      throw err;
    }
  });
}

function loadAlbum() {
  var table = $('.albumTable');
  var albumID = table.attr('id');
  console.log("ALBUM ID:", albumID);

  // Fetch album
  $.ajax({
    url: '/api/album/'+albumID,
    type: 'GET',
    success: function(album) {
      // Load title
      $('#singleAlbumTitle').text(album.title);

      // Load assets
      for (var i = 0; i < album.assets.length; i++) {
        var asset = album.assets[i];

        var div = $('<div>');
        div.attr('class', 'col-md-4 albumCell');

        var a = $('<a>');
        a.attr('class', 'fancybox');
        a.attr('rel', 'group');
        a.attr('href', asset.fullURL);

        var img = $('<img>');
        img.attr('src', asset.thumbURL);

        a.append(img);
        div.append(a);
        table.prepend(div);
      }
    },
    failure: function(err) {
      throw err;
    }
  });
}
{'fraction_non_alphanumeric': 0.20453787120453787, 'fraction_numerical': 0.001334668001334668, 'mean_word_length': 2.5229142185663926, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '4299241', 'n_tokens_mistral': 1022, 'n_tokens_neox': 994, 'n_words': 199}