<commit_before>$(document).ready(function() {
  var title = $('#post-title h1')
    ,body = $('#post-body')
    ,actions = $('#post-actions')
    ,menu = $('#post-menu')
    ,editing = false
    ,normal_actions = $('#post-actions').html()
    ,last_title, last_body, last_actions, base_title, base_body, base_actions;

  function fadeInAll(callback, fade_menu) {
    title.fadeIn(250, ()=>
        body.fadeIn(250, ()=>
          actions.fadeIn(250, function() {
            if (fade_menu) {
              menu.fadeIn(250, callback);
            } else if (callback) {
              callback();
            }
          })));
  }

  function fadeOutAll(callback, fade_menu) {
    title.fadeOut(500);
    body.fadeOut(500);
    actions.fadeOut(500, callback);
    if (fade_menu)
      menu.fadeOut(500);
  }

  var toast = document.querySelector('#login-toast')
    ,toast_message = toast.querySelector('.mdl-snackbar__text').innerHTML

  function showToast() {
    // can't use jQuery with MaterialSnackbar
    toast.MaterialSnackbar.showSnackbar({
      message: toast_message
    });
  }

  function checkIfPass(callback) {
    if ($('#password').val() != '') {
      if (callback)
        callback();
    } else {
      showToast();
    }
  }

  title.hide();
  body.hide();
  actions.hide();
  menu.hide();

  base_title = title.html();
  base_body = body.html();
  base_actions = actions.html();

  var posts = [], post;

  function showPost(eid) {
    // pass an EID to be "shifted down" to find a post
    // you can also pass the direct EID for a post
    var post_index = eid ? eid : posts.length;
    var old_post = post;
    while (post_index >= 0 && !posts[post_index])
      post_index--;

    if (post && post_index == post.eid)
      return;

    if (post = posts[post_index])
      fadeOutAll(()=> {
        title.html(post.title);
        body.html(post.post);
        actions.html(normal_actions);
        fadeInAll(null, true);
      });
    else
      fadeOutAll(()=> {
        title.html(base_title);
        body.html(base_body);
        actions.html(base_actions);
        fadeInAll();
      });
  }

  function reload(start, direction) {<commit_msg>static/js/app.js: re-set old `post` if no new post found<commit_after>$(document).ready(function() {
  var title = $('#post-title h1')
    ,body = $('#post-body')
    ,actions = $('#post-actions')
    ,menu = $('#post-menu')
    ,editing = false
    ,normal_actions = $('#post-actions').html()
    ,last_title, last_body, last_actions, base_title, base_body, base_actions;

  function fadeInAll(callback, fade_menu) {
    title.fadeIn(250, ()=>
        body.fadeIn(250, ()=>
          actions.fadeIn(250, function() {
            if (fade_menu) {
              menu.fadeIn(250, callback);
            } else if (callback) {
              callback();
            }
          })));
  }

  function fadeOutAll(callback, fade_menu) {
    title.fadeOut(500);
    body.fadeOut(500);
    actions.fadeOut(500, callback);
    if (fade_menu)
      menu.fadeOut(500);
  }

  var toast = document.querySelector('#login-toast')
    ,toast_message = toast.querySelector('.mdl-snackbar__text').innerHTML

  function showToast() {
    // can't use jQuery with MaterialSnackbar
    toast.MaterialSnackbar.showSnackbar({
      message: toast_message
    });
  }

  function checkIfPass(callback) {
    if ($('#password').val() != '') {
      if (callback)
        callback();
    } else {
      showToast();
    }
  }

  title.hide();
  body.hide();
  actions.hide();
  menu.hide();

  base_title = title.html();
  base_body = body.html();
  base_actions = actions.html();

  var posts = [], post;

  function showPost(eid) {
    // pass an EID to be "shifted down" to find a post
    // you can also pass the direct EID for a post
    var post_index = eid ? eid : posts.length;
    var old_post = post;
    while (post_index >= 0 && !posts[post_index])
      post_index--;

    if (post && post_index == post.eid)
      return;

    if (post = posts[post_index])
      fadeOutAll(()=> {
        title.html(post.title);
        body.html(post.post);
        actions.html(normal_actions);
        fadeInAll(null, true);
      });
    else if (old_post)
      post = old_post;
    else
      fadeOutAll(()=> {
        title.html(base_title);
        body.html(base_body);
        actions.html(base_actions);
        fadeInAll();
      });
  }

  function reload(start, direction) {
{'fraction_non_alphanumeric': 0.15316941123392736, 'fraction_numerical': 0.011730205278592375, 'mean_word_length': 2.450583657587549, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '1599919', 'n_tokens_mistral': 1499, 'n_tokens_neox': 1426, 'n_words': 297}