<commit_before>if(typeof sne == "undefined") sne = { steps: {} };
sne.steps.docchooser = {};

(function ()
{
  var previewPlayerTimeout = -1;
  var docchooserCallback = null;
  var docs = [];
  var $docs = $('#docs');

  sne.steps.docchooser.show = function (cb)
  {
    logNavigation('docchoser');
    $('#docChooser').addClass('active');
    reloadDocsTable();
    docchooserCallback = cb;
  };

  sne.steps.docchooser.hide = function ()
  {
    $('#docChooser').removeClass('active');
    docchooserCallback();
  };

  function reloadDocsTable ()
  {
    shownoteseditor.connectors[sne.connectorName].listDocuments(sne.connectorOptions,
      function (err, _docs)
      {
        docs = _docs;
        tabletools.clear($docs);

        $('#noDocs').css('display', (docs.length == 0) ? 'block' : 'none');

        for (var i = 0; i < docs.length; i++)
        {
          var doc = docs[i];
          addDocToTable(doc);
        }
      }
    );
  }

  function addDocToTable (doc)
  {
    var $btns = $('#btnsTemplate').clone();
    var accessDate = moment(doc.accessDate).format("DD.MM.YYYY");
    var $td = tabletools.addRow($docs, [ doc.name, accessDate, doc.notesCount, $btns ]);

    $btns = $td.find('.btns').parent().addClass('btns');
    $td.click(
      function (e)
      {
        var $target = $(e.target);

        if($target.prop('tagName').toLowerCase() == "button" ||
           $target.parent().prop('tagName').toLowerCase() == "button")
        {
          return;
        }

        openDoc(doc.id);
      }
    );
    $td.find('button.download').click(
      function ()
      {
        downloadDoc(doc.id, doc.name);
      }
    );
    $td.find('button.edit').click(
      function ()
      {
        sne.steps.docedit.show("edit", doc,
          function (success, doc)
          {
            $('#docChooser').addClass('active');
            reloadDocsTable();
          }
        );
      }
    );
    $td.find('button.delete').click(
      function ()
      {
        deleteDoc(doc.id,
          function (err)
          {
            reloadDocsTable();
            if(err)
              alert(err);
          }
        );
      }
    );
  }
  $('#docsSearch').keyup(
    function ()
    {
      $.uiTableFilter($docs, $('#docsSearch').val(), "Name");
    }
  );

  $('#createDoc').click(showCreateDoc);

  function showCreateDoc ()
  {
    sne.steps.docedit.show("create", null,
      function (success, doc)
      {
        if(success)
        {
          docs.push(doc);
          openDoc(doc.id);
        }<commit_msg>fix aborting of doc creation<commit_after>if(typeof sne == "undefined") sne = { steps: {} };
sne.steps.docchooser = {};

(function ()
{
  var previewPlayerTimeout = -1;
  var docchooserCallback = null;
  var docs = [];
  var $docs = $('#docs');

  sne.steps.docchooser.show = function (cb)
  {
    logNavigation('docchoser');
    $('#docChooser').addClass('active');
    reloadDocsTable();
    docchooserCallback = cb;
  };

  sne.steps.docchooser.hide = function ()
  {
    $('#docChooser').removeClass('active');
    docchooserCallback();
  };

  function reloadDocsTable ()
  {
    shownoteseditor.connectors[sne.connectorName].listDocuments(sne.connectorOptions,
      function (err, _docs)
      {
        docs = _docs;
        tabletools.clear($docs);

        $('#noDocs').css('display', (docs.length == 0) ? 'block' : 'none');

        for (var i = 0; i < docs.length; i++)
        {
          var doc = docs[i];
          addDocToTable(doc);
        }
      }
    );
  }

  function addDocToTable (doc)
  {
    var $btns = $('#btnsTemplate').clone();
    var accessDate = moment(doc.accessDate).format("DD.MM.YYYY");
    var $td = tabletools.addRow($docs, [ doc.name, accessDate, doc.notesCount, $btns ]);

    $btns = $td.find('.btns').parent().addClass('btns');
    $td.click(
      function (e)
      {
        var $target = $(e.target);

        if($target.prop('tagName').toLowerCase() == "button" ||
           $target.parent().prop('tagName').toLowerCase() == "button")
        {
          return;
        }

        openDoc(doc.id);
      }
    );
    $td.find('button.download').click(
      function ()
      {
        downloadDoc(doc.id, doc.name);
      }
    );
    $td.find('button.edit').click(
      function ()
      {
        sne.steps.docedit.show("edit", doc,
          function (success, doc)
          {
            $('#docChooser').addClass('active');
            reloadDocsTable();
          }
        );
      }
    );
    $td.find('button.delete').click(
      function ()
      {
        deleteDoc(doc.id,
          function (err)
          {
            reloadDocsTable();
            if(err)
              alert(err);
          }
        );
      }
    );
  }
  $('#docsSearch').keyup(
    function ()
    {
      $.uiTableFilter($docs, $('#docsSearch').val(), "Name");
    }
  );

  $('#createDoc').click(showCreateDoc);

  function showCreateDoc ()
  {
    sne.steps.docedit.show("create", null,
      function (success, doc)
      {
        if(success)
        {
          docs.push(doc);
          openDoc(doc.id);
        }
        else
        {
          $('#docChooser').addClass('active');
        }
{'fraction_non_alphanumeric': 0.17702520685010584, 'fraction_numerical': 0.0011545122185876468, 'mean_word_length': 1.9500567536889897, 'pattern_counts': {'":': 0, '<': 5, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '196247', 'n_tokens_mistral': 1689, 'n_tokens_neox': 1665, 'n_words': 250}