<commit_before>!!!
%html
  %head
    %title Chat Room
    %meta{ 'http-equiv' => 'Content-Type', content: 'text/html', charset: 'utf-8' }
    %link{ rel: 'stylesheet', href: 'screen.css', type: 'text/css' }

  %body
    %div{ id: 'main'}
      %ol{ id: 'messages' }
      %form{ action: '/chat', method: 'POST' }
        %input{ type: 'text', id: 'message', name: 'message' }
    %div{ id: 'sidebar' }
      %ol{ id: 'presence' }
    %script{src: "/pusher.min.js"}
    %script{src: "/jquery.js"}
    :javascript
      Pusher.host    = "#{@use_pusher ? 'ws.pusherapp.com' : '0.0.0.0' }"
      Pusher.ws_port = "#{@use_pusher ? 80 : 8080}"
      Pusher.log = function(data) {
        console.log('\t\t', data);
      };
      var pusher = new Pusher('#{Pusher.key}');
      var myChannel = pusher.subscribe('presence-channel');
      myChannel.bind('chat_message', function(msg) {
        $('#messages').append("<li><strong>" + msg['sender'] + "</strong>: " + msg['body'] + "</li>")
      })

      myChannel.bind('pusher:subscription_succeeded', function(members) {
        members.each(function(member) {
          $('#presence').append($('<li>' + member.info.name + '</li>').attr('id', member.id))
        })
      })

      myChannel.bind('pusher:member_added', function(member) {
        $('#messages').append($('<li class="info">**** ' + member.info.name + ' entered the chat ****</li>'))
        $('#presence').append($('<li>' + member.info.name + '</li>').attr('id', member.id))
      })

      myChannel.bind('pusher:member_removed', function(member) {
        $('#messages').append($('<li class="info">**** ' + member.info.name + ' left the chat ****</li>'))
        $('#' + member.id).remove()
      })


      $('#main form').submit(function(ev) {
        $.post('/chat', { message: $('#message').val() })
        $('#message').val(null)
        return false
      })

      $('#message').focus()
<commit_msg>add disconnect behaviour to chat example<commit_after>!!!
%html
  %head
    %title Chat Room
    %meta{ 'http-equiv' => 'Content-Type', content: 'text/html', charset: 'utf-8' }
    %link{ rel: 'stylesheet', href: 'screen.css', type: 'text/css' }

  %body
    %div{ id: 'main'}
      %ol{ id: 'messages' }
      %form{ action: '/chat', method: 'POST' }
        %input{ type: 'text', id: 'message', name: 'message' }
    %div{ id: 'sidebar' }
      %ol{ id: 'presence' }
    %script{src: "/pusher.min.js"}
    %script{src: "/jquery.js"}
    :javascript
      Pusher.host    = "#{@use_pusher ? 'ws.pusherapp.com' : '0.0.0.0' }"
      Pusher.ws_port = "#{@use_pusher ? 80 : 8080}"
      Pusher.log = function(data) {
        console.log('\t\t', data);
      };
      var pusher = new Pusher('#{Pusher.key}');
      var myChannel = pusher.subscribe('presence-channel');
      myChannel.bind('chat_message', function(msg) {
        $('#messages').append("<li><strong>" + msg['sender'] + "</strong>: " + msg['body'] + "</li>")
      })

      myChannel.bind('pusher:subscription_succeeded', function(members) {
        members.each(function(member) {
          $('#presence').append($('<li>' + member.info.name + '</li>').attr('id', member.id))
        })
      })

      pusher.bind('pusher:connection_disconnected', function(ev) {
        $('#presence').empty()
         $('#messages').append($('<li class="info">**** Unexpectedly lost connection to server ****</li>'))
      })

      myChannel.bind('pusher:member_added', function(member) {
        $('#messages').append($('<li class="info">**** ' + member.info.name + ' entered the chat ****</li>'))
        $('#presence').append($('<li>' + member.info.name + '</li>').attr('id', member.id))
      })

      myChannel.bind('pusher:member_removed', function(member) {
        $('#messages').append($('<li class="info">**** ' + member.info.name + ' left the chat ****</li>'))
        $('#' + member.id).remove()
      })

      $('#main form').submit(function(ev) {
        $.post('/chat', { message: $('#message').val() })
        $('#message').val(null)
        return false
      })

      $('#message').focus()

{'fraction_non_alphanumeric': 0.23921568627450981, 'fraction_numerical': 0.005392156862745098, 'mean_word_length': 2.8645833333333335, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '5264325', 'n_tokens_mistral': 1357, 'n_tokens_neox': 1376, 'n_words': 246}