<commit_before>var $docs = $('#docs');
var connector = "memory";

function showDocChooser()
{
  $('#docChooserWrapper').addClass('active');
  $('#docChooserWrapper').attr('style', '');

  shownoteseditor.connectors[connector].listDocuments({ save: "localStorage" },
    function (err, docs)
    {
      tabletools.clear($docs);

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

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

      function addDoc (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.find('button.open').click(
          function ()
          {
            openDoc(doc.name);
          }
        );
      }
    }
  );
}

showDocChooser();

$('#docsSearch').keyup(
  function ()
  {
    $.uiTableFilter($docs, $('#docsSearch').val(), "Name");
  }
);

$('#btnCreateDoc').click(
  function ()
  {
    var name = $('#txtCreateDoc').val();
    openDoc(name);
  }
);

function openDoc (name)
{
  var options =
  {
    connector:
    {
      name: connector,
      options:
      {
        docname: name,
        save: "localStorage"
      }
    },
    ui:
    {
      player:
      {
        name: "audiojs",
        options:
        {
          element: $("#player")[0],
          files:
            [
              { src: "./ls000-der-lautsprecher.mp3", type: "audio/mpeg" }
            ]
        }
      },
      list:
      {
        name: "standard",
        options:
        {
          element: $('#notes')[0]
        }
      },
      editor:
      {
        name: "inline",
        options:
        {
          element: $('#maineditor')[0]
        }
      }
    }
  };

  $('#notes, #maineditor, #player').empty();

  sne = new shownoteseditor.sne(options,
    function (err)
    {
      console.log("done, err=%s", err);

      move("#docChooserWrapper").set('opacity', 0).duration("0.5s").end();
      setTimeout(function (){ $('#docChooserWrapper').removeClass('active'); }, 500);
    }
  );
}

$('#btnShowImportExport').click(
  function ()
  {
    var $exportImport = $('#exportImport');
    $exportImport.toggleClass('hidden');
    if($exportImport.hasClass('hidden'))
    {
      move("#exportImport").set("right", -550).end();
    }
    else
    {
      move("#exportImport").set("right", 0).end();
    }
  }
);

$('#btnShowDocChooser').click(
  function ()
  {
    showDocChooser();
  }
);

var $txtOsf = $('#txtOsf');

$('#btnExport').click(
  function ()
  {
    var notes = sne.connector.getFriendlyJson();
    var osf = osftools.osfNotes(notes);
    $txtOsf.val(osf);
  }
);


$('#btnImport').click(
  function ()
  {
    var osf = $txtOsf.val();
    var notes = osftools.parseNotes(osf);
    sne.loadNotes(notes);
  }
);
<commit_msg>create docs by pressing enter<commit_after>var $docs = $('#docs');
var connector = "memory";

function showDocChooser()
{
  $('#docChooserWrapper').addClass('active');
  $('#docChooserWrapper').attr('style', '');

  shownoteseditor.connectors[connector].listDocuments({ save: "localStorage" },
    function (err, docs)
    {
      tabletools.clear($docs);

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

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

      function addDoc (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.find('button.open').click(
          function ()
          {
            openDoc(doc.name);
          }
        );
      }
    }
  );
}

showDocChooser();

$('#docsSearch').keyup(
  function ()
  {
    $.uiTableFilter($docs, $('#docsSearch').val(), "Name");
  }
);

var createDocTxtIds = [ "txtCreateDoc" ];

$('#' + createDocTxtIds.join(',#')).keypress(
  function (e)
  {
    if(e.which == 13)
      createDoc();
  }
)

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

function createDoc ()
{
  var name = $('#txtCreateDoc').val();
  openDoc(name);
}

function openDoc (name)
{
  var options =
  {
    connector:
    {
      name: connector,
      options:
      {
        docname: name,
        save: "localStorage"
      }
    },
    ui:
    {
      player:
      {
        name: "audiojs",
        options:
        {
          element: $("#player")[0],
          files:
            [
              { src: "./ls000-der-lautsprecher.mp3", type: "audio/mpeg" }
            ]
        }
      },
      list:
      {
        name: "standard",
        options:
        {
          element: $('#notes')[0]
        }
      },
      editor:
      {
        name: "inline",
        options:
        {
          element: $('#maineditor')[0]
        }
      }
    }
  };

  $('#notes, #maineditor, #player').empty();

  sne = new shownoteseditor.sne(options,
    function (err)
    {
      console.log("done, err=%s", err);

      move("#docChooserWrapper").set('opacity', 0).duration("0.5s").end();
      setTimeout(function (){ $('#docChooserWrapper').removeClass('active'); }, 500);
    }
  );
}

$('#btnShowImportExport').click(
  function ()
  {
    var $exportImport = $('#exportImport');
    $exportImport.toggleClass('hidden');
    if($exportImport.hasClass('hidden'))
    {
      move("#exportImport").set("right", -550).end();
    }
    else
    {
      move("#exportImport").set("right", 0).end();
    }
  }
);

$('#btnShowDocChooser').click(
  function ()
  {
    showDocChooser();
  }
);

var $txtOsf = $('#txtOsf');

$('#btnExport').click(
  function ()
  {
    var notes = sne.connector.getFriendlyJson();
    var osf = osftools.osfNotes(notes);
    $txtOsf.val(osf);
  }
);


$('#btnImport').click(
  function ()
  {
    var osf = $txtOsf.val();
    var notes = osftools.parseNotes(osf);
    sne.loadNotes(notes);
  }
);

{'fraction_non_alphanumeric': 0.19760479041916168, 'fraction_numerical': 0.006473539407671145, 'mean_word_length': 2.161125319693095, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4348331', 'n_tokens_mistral': 2129, 'n_tokens_neox': 2079, 'n_words': 324}