<commit_before>//jshint browser: true, strict: false
/*global Mousetrap */
if (typeof window.plugins !== "object") {
  window.plugins = {};
}
(function (root) {
  function bindingNew() {
    window.cozyMails.messageNew();
  }
  function bindingHelp() {
    var self, container, help;
    container = document.getElementById('mailkeysHelp');
    if (container) {
      document.body.removeChild(container);
      return;
    }
    self      = this;
    container = document.createElement('div');
    help      = document.createElement('dl');
    container.id = 'mailkeysHelp';
    Object.keys(this._binding).forEach(function (key) {
      help.innerHTML += "<dt>" + key + "&nbsp;: </dt><dd>" + self._binding[key].name + "</dd>";
    });
    container.appendChild(help);
    container.classList.add('mailkeys-container');
    help.classList.add('mailkeys-help');
    document.body.appendChild(container);
    Mousetrap.bind("esc", function () {
      document.body.removeChild(container);
      Mousetrap.unbind("esc");
    });
  }
  root.mailkeys = {
    _binding: {
      'enter': {
        name: "Display current message",
        action: function () {window.cozyMails.messageDisplay(); }
      },
      'x': {
        name: "Close current message",
        action: function () {window.cozyMails.messageClose(); }
      },
      'esc': {
        name: "Close current message",
        action: function () {window.cozyMails.messageClose(); }
      },
      'j': {
        name: "Next Message",
        action: function () {window.cozyMails.messageNavigate('next'); }
      },
      'down': {
        name: "Next Message",
        action: function () {window.cozyMails.messageNavigate('next'); }
      },
      'k': {
        name: "Previous Message",
        action: function () {window.cozyMails.messageNavigate('prev'); }
      },
      'up': {
        name: "Previous Message",
        action: function () {window.cozyMails.messageNavigate('prev'); }
      },
      'ctrl+down': {
        name: 'Scroll message down',
        action: function () {
            var panel = document.querySelector("#panels > .panel:nth-of-type(2)");
            if (panel) {
                panel.scrollTop += panel.clientHeight * 0.8;
            }
        }
      },
      'ctrl+up': {
        name: 'Scroll message up',
        action: function () {
            var panel = document.querySelector("#panels > .panel:nth-of-type(2)");
            if (panel) {
                panel.scrollTop -= panel.clientHeight * 0.8;
            }
        }
      },
      'pageDown': {
        name: 'Scroll message up',
        action: function () {
        }
      },
      'n': {
        name: "New message",
        action: bindingNew
      },
      'd': {
        name: "Delete message",
        action: function () {window.cozyMails.messageDeleteCurrent(); }
      },
      'backspace': {
        name: "Delete message",
        action: function () {window.cozyMails.messageDeleteCurrent(); }
      },
      'del': {
        name: "Delete message",
        action: function () {window.cozyMails.messageDeleteCurrent(); }
      },
     'u': {
        name: "Undelete message",
        action: function () {window.cozyMails.messageUndo(); }
      },
      '?': {
        name: "Toggle display of available bindings",
        action: bindingHelp
      }
    },
    name: "Keyboard shortcuts",
    active: true,
    onAdd: {
      /**
       * Should return true if plugin applies on added subtree
       *
       * @param {DOMNode} root node of added subtree
       */
      condition: function (node) {
        return false;
      },
      /**
       * Perform action on added subtree
       *<commit_msg>Allow to undo last action with Ctrl-Z<commit_after>//jshint browser: true, strict: false
/*global Mousetrap */
if (typeof window.plugins !== "object") {
  window.plugins = {};
}
(function (root) {
  function bindingNew() {
    window.cozyMails.messageNew();
  }
  function bindingHelp() {
    var self, container, help;
    container = document.getElementById('mailkeysHelp');
    if (container) {
      document.body.removeChild(container);
      return;
    }
    self      = this;
    container = document.createElement('div');
    help      = document.createElement('dl');
    container.id = 'mailkeysHelp';
    Object.keys(this._binding).forEach(function (key) {
      help.innerHTML += "<dt>" + key + "&nbsp;: </dt><dd>" + self._binding[key].name + "</dd>";
    });
    container.appendChild(help);
    container.classList.add('mailkeys-container');
    help.classList.add('mailkeys-help');
    document.body.appendChild(container);
    Mousetrap.bind("esc", function () {
      document.body.removeChild(container);
      Mousetrap.unbind("esc");
    });
  }
  root.mailkeys = {
    _binding: {
      'enter': {
        name: "Display current message",
        action: function (e) {
          e.preventDefault();
          window.cozyMails.messageDisplay();
        }
      },
      'x': {
        name: "Close current message",
        action: function (e) {
          e.preventDefault();
          window.cozyMails.messageClose();
        }
      },
      'esc': {
        name: "Close current message",
        action: function (e) {
          e.preventDefault();
          window.cozyMails.messageClose();
        }
      },
      'j': {
        name: "Next Message",
        action: function (e) {
          e.preventDefault();
          window.cozyMails.messageNavigate('next');
        }
      },
      'down': {
        name: "Next Message",
        action: function (e) {
          e.preventDefault();
          window.cozyMails.messageNavigate('next');
        }
      },
      'k': {
        name: "Previous Message",
        action: function (e) {
          e.preventDefault();
          window.cozyMails.messageNavigate('prev');
        }
      },
      'up': {
        name: "Previous Message",
        action: function (e) {
          e.preventDefault();
          window.cozyMails.messageNavigate('prev');
        }
      },
      'ctrl+down': {
        name: 'Scroll message down',
        action: function (e) {
          e.preventDefault();
          var panel = document.querySelector("#panels > .panel:nth-of-type(2)");
          if (panel) {
            panel.scrollTop += panel.clientHeight * 0.8;
          }
        }
      },
      'ctrl+up': {
        name: 'Scroll message up',
        action: function (e) {
          e.preventDefault();
          var panel = document.querySelector("#panels > .panel:nth-of-type(2)");
          if (panel) {
            panel.scrollTop -= panel.clientHeight * 0.8;
          }
        }
      },
      'n': {
        name: "New message",
        action: bindingNew
      },
      'd': {
        name: "Delete message",
        action: function (e) {
          e.preventDefault();
          window.cozyMails.messageDeleteCurrent();
        }
      },
      'ctrl+z': {
        name: 'Undelete message',
        action: function (e) {
          e.preventDefault();
          var MessageActionCreator = window.require('actions/message_action_creator');
          MessageActionCreator.undelete();
        }
      },
      'backspace': {
        name: "Delete message",
        action: function (e) {
          e.preventDefault();
          window.cozyMails.messageDeleteCurrent();
        }
      },
      'del': {
        name: "Delete message",
        action: function (e) {
          e.preventDefault();
          window.cozyMails.messageDeleteCurrent();
        }
      },
      'u': {
        name: "Undelete message",
        action: function (e) {
          e.preventDefault();
          window.cozyMails.messageUndo();
        }
      },
      '?': {
        name: "Toggle display of available bindings",
        action: bindingHelp
      }
    },
    name: "Keyboard shortcuts",
    active: true,
    onAdd: {
      /**
       * Should return true if plugin applies on added subtree
       *
       * @param {DOMNode} root node of added subtree
       */
      condition: function (node) {
        return false;
      },
      /**
       * Perform action on added subtree
       *
{'fraction_non_alphanumeric': 0.14670106892738666, 'fraction_numerical': 0.001474382602285293, 'mean_word_length': 1.9061049625133881, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '1544062', 'n_tokens_mistral': 2337, 'n_tokens_neox': 2344, 'n_words': 479}