<commit_before>require 'atom'
require 'window'

$ = require 'jquery'
{$$} = require 'space-pen'
GuestSession = require './guest-session'

window.setDimensions(width: 350, height: 125)
window.setUpEnvironment('editor')
{sessionId} = atom.getLoadSettings()

loadingView = $$ ->
  @div style: 'margin: 10px', =>
    @h4 style: 'text-align: center', 'Joining Session'
    @div class: 'progress progress-striped active', style: 'margin-bottom: 10px', =>
      @div class: 'progress-bar', style: 'width: 0%'
    @div class: 'progress-bar-message', 'Establishing connection\u2026'
$(window.rootViewParentSelector).append(loadingView)
atom.show()

updateProgressBar = (message, percentDone) ->
  loadingView.find('.progress-bar-message').text("#{message}\u2026")
  loadingView.find('.progress-bar').css('width', "#{percentDone}%")

guestSession = new GuestSession(sessionId)
guestSession.on 'started', -> loadingView.remove()
guestSession.on 'connection-opened', -> updateProgressBar('Downloading session data', 25)
guestSession.on 'document-received', -> updateProgressBar('Synchronizing repository', 50)
operationsDone = -1
guestSession.on 'mirror-progress', (message, command, operationCount) ->
  operationsDone++
  percentDone = Math.round((operationsDone / operationCount) * 50) + 50
  updateProgressBar(message, percentDone)

atom.guestSession = guestSession<commit_msg>Add missing connection prefix to event name<commit_after>require 'atom'
require 'window'

$ = require 'jquery'
{$$} = require 'space-pen'
GuestSession = require './guest-session'

window.setDimensions(width: 350, height: 125)
window.setUpEnvironment('editor')
{sessionId} = atom.getLoadSettings()

loadingView = $$ ->
  @div style: 'margin: 10px', =>
    @h4 style: 'text-align: center', 'Joining Session'
    @div class: 'progress progress-striped active', style: 'margin-bottom: 10px', =>
      @div class: 'progress-bar', style: 'width: 0%'
    @div class: 'progress-bar-message', 'Establishing connection\u2026'
$(window.rootViewParentSelector).append(loadingView)
atom.show()

updateProgressBar = (message, percentDone) ->
  loadingView.find('.progress-bar-message').text("#{message}\u2026")
  loadingView.find('.progress-bar').css('width', "#{percentDone}%")

guestSession = new GuestSession(sessionId)
guestSession.on 'started', -> loadingView.remove()
guestSession.on 'connection-opened', -> updateProgressBar('Downloading session data', 25)
guestSession.on 'connection-document-received', -> updateProgressBar('Synchronizing repository', 50)
operationsDone = -1
guestSession.on 'mirror-progress', (message, command, operationCount) ->
  operationsDone++
  percentDone = Math.round((operationsDone / operationCount) * 50) + 50
  updateProgressBar(message, percentDone)

atom.guestSession = guestSession
{'fraction_non_alphanumeric': 0.15581144296509536, 'fraction_numerical': 0.02087081684059014, 'mean_word_length': 6.02020202020202, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '7142783', 'n_tokens_mistral': 891, 'n_tokens_neox': 832, 'n_words': 185}