<commit_before>
Crypto = require 'crypto'
{View, EditorView} = require 'atom'

Firebase = require 'firebase'
Firepad = require './firepad-lib'

class ShareView extends View
  @content: ->
    @div class: 'firepad overlay from-bottom', =>
      @div 'This file is being shared', class: 'message'

  show: ->
    atom.workspaceView.append(this)

module.exports =
class FirepadView extends View
  @activate: -> new FirepadView

  @content: ->
    @div class: 'firepad overlay from-top mini', =>
      @subview 'miniEditor', new EditorView(mini: true)
      @div class: 'message', outlet: 'message'

  detaching: false

  initialize: ->
    atom.workspaceView.command 'firepad:share', => @share()
    atom.workspaceView.command 'firepad:unshare', => @unshare()

    @miniEditor.hiddenInput.on 'focusout', => @detach() unless @detaching
    @on 'core:confirm', => @confirm()
    @on 'core:cancel', => @detach()

    @miniEditor.preempt 'textInput', (e) =>
      false unless e.originalEvent.data.match(/[a-zA-Z0-9\-]/)

  detach: ->
    return unless @hasParent()
    @detaching = true
    @miniEditor.setText('')
    super
    @detaching = false

  share: ->
    if editor = atom.workspace.getActiveEditor()
      atom.workspaceView.append(this)
      randomString = Math.random().toString(36).slice(2, 10)
      @miniEditor.setText(randomString)
      @message.text('Enter a string to identify this share session')
      @miniEditor.focus()

  confirm: ->
    shareId = @miniEditor.getText()
    hash = Crypto.createHash('sha256').update(shareId).digest('base64');
    @detach()
    @ref = new Firebase('https://atom-firepad.firebaseio.com').child(hash);

    editor = atom.workspace.getActiveEditor()
    @ref.once 'value', (snapshot) =>
      options = {sv_: Firebase.ServerValue.TIMESTAMP}
      if !snapshot.val() && editor.getText() != ''<commit_msg>Resolve deprecated calls #11<commit_after>
Crypto = require 'crypto'
{View, EditorView} = require 'atom'

Firebase = require 'firebase'
Firepad = require './firepad-lib'

class ShareView extends View
  @content: ->
    @div class: 'firepad overlay from-bottom', =>
      @div 'This file is being shared', class: 'message'

  show: ->
    workspaceView = atom.views.getView(atom.workspace)
    workspaceView.append(this)

module.exports =
class FirepadView extends View
  @activate: -> new FirepadView

  @content: ->
    @div class: 'firepad overlay from-top mini', =>
      @subview 'miniEditor', new EditorView(mini: true)
      @div class: 'message', outlet: 'message'

  detaching: false

  initialize: ->
    atom.commands.add 'firepad:share', => @share()
    atom.commands.add 'firepad:unshare', => @unshare()

    @miniEditor.hiddenInput.on 'focusout', => @detach() unless @detaching
    @on 'core:confirm', => @confirm()
    @on 'core:cancel', => @detach()

    @miniEditor.preempt 'textInput', (e) =>
      false unless e.originalEvent.data.match(/[a-zA-Z0-9\-]/)

  detach: ->
    return unless @hasParent()
    @detaching = true
    @miniEditor.setText('')
    super
    @detaching = false

  share: ->
    if editor = atom.workspace.getActiveEditor()
      workspaceView = atom.views.getView(atom.workspace)
      workspaceView.append(this)
      randomString = Math.random().toString(36).slice(2, 10)
      @miniEditor.setText(randomString)
      @message.text('Enter a string to identify this share session')
      @miniEditor.focus()

  confirm: ->
    shareId = @miniEditor.getText()
    hash = Crypto.createHash('sha256').update(shareId).digest('base64');
    @detach()
    @ref = new Firebase('https://atom-firepad.firebaseio.com').child(hash);

    editor = atom.workspace.getActiveEditor()
    @ref.once 'value', (snapshot) =>
      options = {sv_: Firebase.ServerValue.TIMESTAMP}
      if !snapshot.val() && editor.getText() != ''
{'fraction_non_alphanumeric': 0.15487772810938732, 'fraction_numerical': 0.0068367078622140415, 'mean_word_length': 3.5285714285714285, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 37, 'https://': 2, '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': '3173083', 'n_tokens_mistral': 1255, 'n_tokens_neox': 1201, 'n_words': 273}