<commit_before>$(function() {
  
  // get gallery name
  var gal = $('title').text().split(" / ")[1];
  
  // get image list
  var images = $('#container').find('img').map(function() { return this.id; }).get();

  // get previews list
  var previews = $('#controls').find('img.preview').map(function() { return this.id; }).get();
  
  // get id of current image
  var currentImgId = '#' + images[0];

  // place holder for the current image number
  var currentImgNumber = previews[0];
//  var currentImgNumber = $(previews).get(-1);
  currentImgNumber = currentImgNumber.replace('picteria-', '');
  currentImgNumber = currentImgNumber.replace('-prev', '');
  console.log( 'currentImgNumber : ' + currentImgNumber);


  // image mode : screen / image
  var mode = 'image';

  // total number of previews
  var numPreviews = 0;

  // number of previews showed in previous previews screens
  var previewShowed = 0;

  
  var PreviousNumPreviews = 0;

  // -- show first image on page load -----------------------------------------
  showImage(currentImgId, mode);

  setTimeout(function() {
    PreviousNumPreviews = numPreviews;
    numPreviews = countPreviews(previews);
  }, 60);
  

  // add active state style
  console.log( 'currentImgId : ' + currentImgId );
  $('#picteria-' + currentImgNumber + '-prev').css('border', '1px solid white');


  // -- handle screen resize --------------------------------------------------
  $(window).resize(function() {
    showImage(currentImgId, mode);
    showPreviews(previews);
  });


  // -- Handle show image -----------------------------------------------------
  $('.preview').click(function() {

//    $.each(images, function(index, item) {
//      $('#' + item).addClass('hide');
//    });

    $(currentImgId + '-prev').css('border', 'none');
    
    // get clicked element id    
    var id = $(this).attr('id');

    // get corresponding img id
    var img = id.replace('-prev', '');

    currentImgId = '#' + img;

    $(currentImgId + '-prev').css('border', '1px solid white');
    
    currentImgNumber = img.replace('picteria-', '');

    $.ajax({
      url: '/' + gal + '/' + currentImgNumber,
      type: "get",
      success: function(data){
        $("#container").html(data);
        showImage('#picteria-1', mode); 
      },
      error:function(){
        $("#container").html('There is error while submit');
      }
    });
    
//    $.each(images, function(index, item) {
//      if ( item == img ) {

    showImage('#picteria-1', mode);
    $('#picteria-1').removeClass('hide');
        
//      }
//      else {
//        $('#' + item).addClass('hide');
//      }
//    });
  });


  // -- Handle next previews --------------------------------------------------
  $('#next').click(function() {
    
//    console.log('');
    
//    setTimeout(function() {
//      PreviousNumPreviews = numPreviews;
//      numPreviews = countPreviews(previews);
//    }, 60);
  });


  // -- Handle previous previews ----------------------------------------------
  $('#prev').click(function() {
    setTimeout(function() {
      PreviousNumPreviews = numPreviews;
      numPreviews = countPreviews(previews);
    }, 60);
  });


  // -- Handle mode change ----------------------------------------------------
  $('#mode').click(function() {
    mode = switchMode(currentImgId, mode);
    return mode;
  });


  // -- keyboard shortcuts ----------------------------------------------------
  // r :           switch mode
  // up arrow :    show next previews
  // down arrow :  show previous previews
  // right arrow : show next image
  // left arrow  : show previous image
  // b :           back to galleries index
  $(document).keydown(function(e) {
//    console.log(e.which);
    if ( e.which == 82 ) {
      mode = switchMode(currentImgId, mode);
    }
    else if ( e.which == 38 ) {
      nextPreviews(previews, numPreviews);
    }
    else if ( e.which == 40 ) {
      prevPreviews(previews, numPreviews);
    }
    else if ( e.which == 39 ) {
      
      if ($('#picteria-' + ( parseInt(currentImgNumber) + 1 ) + '-prev').length == 0) {

        var galItems = $('#controls').attr('data-galItems');
        
        if ( currentImgNumber == galItems ) {
          return false;
        }
        
        url = '/' + gal + '/' + getWidth() + '/' + ( parseInt(currentImgNumber) + 1 );
        
        console.log('url : ' + url);
        $.ajax({
          url: url,
          type: "get",
          success: function(data){
            $("body").html(data);
            $('#picteria-' + currentImgNumber + '-prev').css('border', '1px solid white');
          },
          error:function() {
            $("#container").html('There is error while submit');
          }
        });
        currentImgNumber++;
      }
      else {
        currentImgNumber = nextImage(gal, currentImgNumber, mode);
      }
    }
    else if ( e.which == 37 ) {
      
      if ($('#picteria-' + ( parseInt(currentImgNumber) - 1 ) + '-prev').length == 0) {

        if ( currentImgNumber == 1 ) {
          return false;
        }

        url = '/' + gal + '/' + getWidth() + '/' + ( parseInt(currentImgNumber) - 1 );
        window.location.href = url;
      }
      else {
        currentImgNumber = prevImage(gal, currentImgNumber, mode);
      }
    }
    else if ( e.which == 66 ) {
      window.location.href = "http://picteria/index.php/";
    }<commit_msg>fixed bug in forward key pic navigation<commit_after>$(function() {
  
  // get gallery name
  var gal = $('title').text().split(" / ")[1];
  
  // get image list
  var images = $('#container').find('img').map(function() { return this.id; }).get();

  // get previews list
  var previews = $('#controls').find('img.preview').map(function() { return this.id; }).get();
  
  // get id of current image
  var currentImgId = '#' + images[0];

  // place holder for the current image number
  var currentImgNumber = previews[0];
//  var currentImgNumber = $(previews).get(-1);
  currentImgNumber = currentImgNumber.replace('picteria-', '');
  currentImgNumber = currentImgNumber.replace('-prev', '');
  console.log( 'currentImgNumber : ' + currentImgNumber);


  // image mode : screen / image
  var mode = 'image';

  // total number of previews
  var numPreviews = 0;

  // number of previews showed in previous previews screens
  var previewShowed = 0;

  
  var PreviousNumPreviews = 0;

  // -- show first image on page load -----------------------------------------
  showImage(currentImgId, mode);

  setTimeout(function() {
    PreviousNumPreviews = numPreviews;
    numPreviews = countPreviews(previews);
  }, 60);
  

  // add active state style
  console.log( 'currentImgId : ' + currentImgId );
  $('#picteria-' + currentImgNumber + '-prev').css('border', '1px solid white');


  // -- handle screen resize --------------------------------------------------
  $(window).resize(function() {
    showImage(currentImgId, mode);
    showPreviews(previews);
  });


  // -- Handle show image -----------------------------------------------------
  $('.preview').click(function() {

//    $.each(images, function(index, item) {
//      $('#' + item).addClass('hide');
//    });

    $(currentImgId + '-prev').css('border', 'none');
    
    // get clicked element id    
    var id = $(this).attr('id');

    // get corresponding img id
    var img = id.replace('-prev', '');

    currentImgId = '#' + img;

    $(currentImgId + '-prev').css('border', '1px solid white');
    
    currentImgNumber = img.replace('picteria-', '');

    $.ajax({
      url: '/' + gal + '/' + currentImgNumber,
      type: "get",
      success: function(data){
        $("#container").html(data);
        showImage('#picteria-1', mode); 
      },
      error:function(){
        $("#container").html('There is error while submit');
      }
    });
    
//    $.each(images, function(index, item) {
//      if ( item == img ) {

    showImage('#picteria-1', mode);
    $('#picteria-1').removeClass('hide');
        
//      }
//      else {
//        $('#' + item).addClass('hide');
//      }
//    });
  });


  // -- Handle next previews --------------------------------------------------
  $('#next').click(function() {
    
//    console.log('');
    
//    setTimeout(function() {
//      PreviousNumPreviews = numPreviews;
//      numPreviews = countPreviews(previews);
//    }, 60);
  });


  // -- Handle previous previews ----------------------------------------------
  $('#prev').click(function() {
    setTimeout(function() {
      PreviousNumPreviews = numPreviews;
      numPreviews = countPreviews(previews);
    }, 60);
  });


  // -- Handle mode change ----------------------------------------------------
  $('#mode').click(function() {
    mode = switchMode(currentImgId, mode);
    return mode;
  });


  // -- keyboard shortcuts ----------------------------------------------------
  // r :           switch mode
  // up arrow :    show next previews
  // down arrow :  show previous previews
  // right arrow : show next image
  // left arrow  : show previous image
  // b :           back to galleries index
  $(document).keydown(function(e) {
//    console.log(e.which);
    if ( e.which == 82 ) {
      mode = switchMode(currentImgId, mode);
    }
    else if ( e.which == 38 ) {
      nextPreviews(previews, numPreviews);
    }
    else if ( e.which == 40 ) {
      prevPreviews(previews, numPreviews);
    }
    else if ( e.which == 39 ) {
      
      if ($('#picteria-' + ( parseInt(currentImgNumber) + 1 ) + '-prev').length == 0) {

        var galItems = $('#controls').attr('data-galItems');
        
        if ( currentImgNumber == galItems ) {
          return false;
        }
        
        url = '/' + gal + '/' + getWidth() + '/' + ( parseInt(currentImgNumber) + 1 );
        
        console.log('url : ' + url);
        $.ajax({
          url: url,
          type: "get",
          success: function(data){
            $("body").html(data);
            showImage(currentImgId, mode);
            $('#picteria-' + currentImgNumber + '-prev').css('border', '1px solid white');
          },
          error:function() {
            $("#container").html('There is error while submit');
          }
        });
        currentImgNumber++;
      }
      else {
        currentImgNumber = nextImage(gal, currentImgNumber, mode);
      }
    }
    else if ( e.which == 37 ) {
      
      if ($('#picteria-' + ( parseInt(currentImgNumber) - 1 ) + '-prev').length == 0) {

        if ( currentImgNumber == 1 ) {
          return false;
        }

        url = '/' + gal + '/' + getWidth() + '/' + ( parseInt(currentImgNumber) - 1 );
        window.location.href = url;
      }
      else {
        currentImgNumber = prevImage(gal, currentImgNumber, mode);
      }
    }
    else if ( e.which == 66 ) {
      window.location.href = "http://picteria/index.php/";
    }
{'fraction_non_alphanumeric': 0.23088923556942278, 'fraction_numerical': 0.00697439662292374, 'mean_word_length': 1.7907810499359795, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5169893', 'n_tokens_mistral': 3234, 'n_tokens_neox': 3124, 'n_words': 692}