<commit_before>var App = (function() {
  var self = {};
  var navBar = document.querySelector("nav");

  ace.config.set("basePath", "js/ace");
  var editor = ace.edit("content");
  editor.setTheme("ace/theme/monokai");
  editor.getSession().setMode("ace/mode/javascript");

  //Hide/Show the menu bar
  document.body.addEventListener("mousemove", function(e) {
    if(e.pageY < 30 && navBar.className === "hidden") navBar.className = "visible";
    else if(e.pageY >= 30 && navBar.className === "visible") navBar.className = "hidden";
  });

  //Adding button event listeners
  document.getElementById("open").addEventListener("click", function() {
    chrome.fileSystem.chooseEntry({}, function(fileEntry) {
      fileEntry.file(function(file){
        var reader = new FileReader();
        reader.onload = function(e) {
          document.getElementById("content").innerHTML = e.target.result;
        };
        reader.readAsText(file);
      });
      
      self.currentFileEntry = fileEntry;
    });    
  });

  document.getElementById("save").addEventListener("click", function() {
    chrome.fileSystem.getWritableEntry(self.currentFileEntry, function(fileEntry) {
      fileEntry.createWriter(function(fileWriter) {
        fileWriter.onwriteend = function() {
          console.log("Writing DONE");
        };
        fileWriter.onerror = function(err) {
          console.log("err", err, err.toString());
        }
      
        var blob = new Blob([document.getElementById("content").innerText], {type: 'text/plain'});
        fileWriter.write(blob);
      }, function(err) {
        console.log("shit", err);
      });
    });
  });

  // return the instance<commit_msg>Using proper Ace methods to get and set editor content<commit_after>var App = (function() {
  var self = {};
  var navBar = document.querySelector("nav");

  ace.config.set("basePath", "js/ace");

  self.editor = ace.edit("content");
  self.editor.setTheme("ace/theme/monokai");
  self.editor.getSession().setMode("ace/mode/javascript");

  //Hide/Show the menu bar
  document.body.addEventListener("mousemove", function(e) {
    if(e.pageY < 30 && navBar.className === "hidden") navBar.className = "visible";
    else if(e.pageY >= 30 && navBar.className === "visible") navBar.className = "hidden";
  });

  //Adding button event listeners
  document.getElementById("open").addEventListener("click", function() {
    chrome.fileSystem.chooseEntry({}, function(fileEntry) {
      fileEntry.file(function(file){
        var reader = new FileReader();
        reader.onload = function(e) {
          self.editor.setValue(e.target.result);
        };
        reader.readAsText(file);
      });
      
      self.currentFileEntry = fileEntry;
    });    
  });

  document.getElementById("save").addEventListener("click", function() {
    chrome.fileSystem.getWritableEntry(self.currentFileEntry, function(fileEntry) {
      fileEntry.createWriter(function(fileWriter) {
        fileWriter.onwriteend = function() {
          console.log("Writing DONE");
        };
        fileWriter.onerror = function(err) {
          console.log("err", err, err.toString());
        }
      
        var blob = new Blob([self.editor.getValue()], {type: 'text/plain'});
        fileWriter.write(blob);
      }, function(err) {
        console.log("shit", err);
      });
    });
  });

  // return the instance
{'fraction_non_alphanumeric': 0.16163410301953818, 'fraction_numerical': 0.002368265245707519, 'mean_word_length': 3.0759951749095293, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5669343', 'n_tokens_mistral': 993, 'n_tokens_neox': 965, 'n_words': 168}