<commit_before>'use babel';

import AddBookmarkView from './add-bookmark-view';
import EditBookmarkNotesView from './edit-bookmark-notes-view';
import CasefileView from './casefile-view';
import { casefileURI } from './pkg-vals';
import Store from './data/CasefileStore';
import Actions from './data/CasefileActions';
import { CompositeDisposable } from 'atom';
import jQuery from 'jquery';

export default {

  addBmarkView: null,
  modalAddPanel: null,
  modalEditPanel: null,
  subscriptions: null,
  
  config: {
    toolPath: {
      description: "Path used when invoking external tools",
      type: 'string',
      default: (
        process.platform == 'win32'
        ? 'C:\\Program Files\\Git\\bin;C:\\Program Files (x86)\\Git\\bin;C:\\Program Files\\GnuWin;C:\\Program Files (x86)\\GnuWin'
        : '/usr/bin:/bin:/usr/local/bin'
      )
    }
  },

  activate(state) {
    if (state.contents) {
      Actions.setState(state.contents);
    }
    
    this.addBmarkView = new AddBookmarkView();
    this.modalAddPanel = atom.workspace.addModalPanel({
      item: this.addBmarkView.getElement(),
      visible: false
    });
    
    this.editNotesView = new EditBookmarkNotesView();
    this.modalEditPanel = atom.workspace.addModalPanel({
      item: this.editNotesView.getElement(),
      visible: false
    });

    // Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable
    this.subscriptions = new CompositeDisposable();

    const Casefile = this;
    this.subscriptions.add(
      atom.workspace.addOpener(uri => {
        if (uri === casefileURI) {
          return new CasefileView();
        }
      }),
      atom.commands.add('atom-workspace', {
        'casefile:open': () => atom.workspace.open(casefileURI),
        'casefile:add-bookmark': () => this.placeMark(),
        'casefile:clear-bookmarks': () => Actions.clearBookmarks()
      }),
      atom.commands.add('casefile-viewer .bookmark-body', {
        'casefile:edit-notes': function (e) {
          Casefile.editMark(jQuery(this).data('markPath'));
        }
      }),
      atom.contextMenu.add({
        'casefile-viewer .bookmark-body': [{label: "Edit Bookmark Notes...", command: 'casefile:edit-notes'}]
      })
    );
  },

  deactivate() {
    this.modalAddPanel.destroy();
    this.modalEditPanel.destroy();
    this.subscriptions.dispose();
    this.addBmarkView.destroy();
  },

  serialize() {
    return {contents: Store.getState()};
  },
  
  placeMark() {
    var editor = atom.workspace.getActiveTextEditor();
    if (!editor) return;<commit_msg>Require confirmation before clearing all bookmarks<commit_after>'use babel';

import AddBookmarkView from './add-bookmark-view';
import EditBookmarkNotesView from './edit-bookmark-notes-view';
import CasefileView from './casefile-view';
import { casefileURI } from './pkg-vals';
import Store from './data/CasefileStore';
import Actions from './data/CasefileActions';
import { CompositeDisposable } from 'atom';
import jQuery from 'jquery';

export default {

  addBmarkView: null,
  modalAddPanel: null,
  modalEditPanel: null,
  subscriptions: null,
  
  config: {
    toolPath: {
      description: "Path used when invoking external tools",
      type: 'string',
      default: (
        process.platform == 'win32'
        ? 'C:\\Program Files\\Git\\bin;C:\\Program Files (x86)\\Git\\bin;C:\\Program Files\\GnuWin;C:\\Program Files (x86)\\GnuWin'
        : '/usr/bin:/bin:/usr/local/bin'
      )
    }
  },

  activate(state) {
    if (state.contents) {
      Actions.setState(state.contents);
    }
    
    this.addBmarkView = new AddBookmarkView();
    this.modalAddPanel = atom.workspace.addModalPanel({
      item: this.addBmarkView.getElement(),
      visible: false
    });
    
    this.editNotesView = new EditBookmarkNotesView();
    this.modalEditPanel = atom.workspace.addModalPanel({
      item: this.editNotesView.getElement(),
      visible: false
    });

    // Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable
    this.subscriptions = new CompositeDisposable();

    const Casefile = this;
    this.subscriptions.add(
      atom.workspace.addOpener(uri => {
        if (uri === casefileURI) {
          return new CasefileView();
        }
      }),
      atom.commands.add('atom-workspace', {
        'casefile:open': () => atom.workspace.open(casefileURI),
        'casefile:add-bookmark': () => this.placeMark(),
        'casefile:clear-bookmarks': () => window.confirm('Clear all Casefile bookmarks?') && Actions.clearBookmarks()
      }),
      atom.commands.add('casefile-viewer .bookmark-body', {
        'casefile:edit-notes': function (e) {
          Casefile.editMark(jQuery(this).data('markPath'));
        }
      }),
      atom.contextMenu.add({
        'casefile-viewer .bookmark-body': [{label: "Edit Bookmark Notes...", command: 'casefile:edit-notes'}]
      })
    );
  },

  deactivate() {
    this.modalAddPanel.destroy();
    this.modalEditPanel.destroy();
    this.subscriptions.dispose();
    this.addBmarkView.destroy();
  },

  serialize() {
    return {contents: Store.getState()};
  },
  
  placeMark() {
    var editor = atom.workspace.getActiveTextEditor();
    if (!editor) return;
{'fraction_non_alphanumeric': 0.14726027397260275, 'fraction_numerical': 0.00228310502283105, 'mean_word_length': 2.9407796101949026, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '865029', 'n_tokens_mistral': 1646, 'n_tokens_neox': 1594, 'n_words': 316}