<commit_before><!DOCTYPE html>
<html>
<head>
  <title>SpeakIt</title>
  <%= stylesheet_link_tag    'application', media: 'all' %>
  <%= javascript_include_tag 'application' %>
  <%= csrf_meta_tags %>
</head>
<body>

<%= render partial: "welcome/navbar" %>

<% if flash[:notice]%>
  <% flash[:notice].each do |msg| %>
    <p class="notice"> <%= msg %></p>
  <% end %>
<% elsif flash[:alert] %>
  <% flash[:alert].each do |msg| %>
    <p class="alert"> <%= msg %></p>
  <% end %>
<% end %>

<script src="//js.pusher.com/2.2/pusher.min.js"></script>

<%= yield %>

<script src="/assets/invitationButton.js"></script>
<script>
  $(document).ready(function(){
    var removeFlash = setTimeout(function(){
      $('.notice').remove();
      $('.alert').remove();
    }, 2000);
   })
</script>
<script>
$(function() {
  // initialize Pusher with api-key
  var pusher = new Pusher('510b272a7e1299e4d1e7');
  // assign channel name with current user id
  var channelName = 'private-conversation.' + '<%= current_user ? current_user.id.to_s : 'null' %>';
  // have Pusher subscribe the channel
  var channel = pusher.subscribe(channelName);
  // bind to changes in the channel and use the returned data
  channel.bind('new_invitation', function(data) {
    console.log(data);
    var senderId = data.invitation.sender_id;
    var recipientId = data.invitation.recipient_id;
    var username = data.username;
    // create a partial to append to the <ul> in the DOM
    var partial = "";
    partial += '<li><p>' + username + ': just now</p>' +
      '<div id="flex-container"><form method="post" action="/chat_rooms" id="create_chat_room">' +
        '<input type="hidden" value="'+ data.invitation.id + '" name="invitation[id]"/>' +
        '<input type="submit" value="Accept" class="btn btn-success"/>' +
      '</form>' +
      '<button class="btn btn-danger delete_invitation" data-id="' + data.invitation.id + '">Decline</button></div>' +
    '</li>';
    $('#notification-list').append(partial);
    // re-invoke event listener to delete invitation if user clicks 'decline'
    deleteInvitation();
    removeFlash();
  });

  channel.bind('create_chat_room', function(data) {
    console.log(data);
    window.location = "/chat_rooms/" + data;
  });
});
</script>


</body>
</html>
<commit_msg>Style flash messages and add a timer so they disappear after an interval<commit_after><!DOCTYPE html>
<html>
<head>
  <title>SpeakIt</title>
  <%= stylesheet_link_tag    'application', media: 'all' %>
  <%= javascript_include_tag 'application' %>
  <%= csrf_meta_tags %>
</head>
<body>

<%= render partial: "welcome/navbar" %>

<% if flash[:notice]%>
  <% flash[:notice].each do |msg| %>
    <div class="alert alert-success" role="alert">
    <span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span>
    <span class="sr-only">Error:</span>
      <%= msg %>
    </div>
  <% end %>
<% elsif flash[:alert] %>
  <% flash[:alert].each do |msg| %>
    <div class="alert alert-danger" role="alert">
    <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
    <span class="sr-only">Error:</span>
      <%= msg %>
    </div>
  <% end %>
<% end %>

<script src="//js.pusher.com/2.2/pusher.min.js"></script>

<%= yield %>

<script src="/assets/invitationButton.js"></script>
<script>
  $(document).ready(function(){
    var removeFlash = setTimeout(function(){
      $('.notice').remove();
      $('.alert').remove();
    }, 2000);
   })

</script>
<script>
$(function() {
  // initialize Pusher with api-key
  var pusher = new Pusher('510b272a7e1299e4d1e7');
  // assign channel name with current user id
  var channelName = 'private-conversation.' + '<%= current_user ? current_user.id.to_s : 'null' %>';
  // have Pusher subscribe the channel
  var channel = pusher.subscribe(channelName);
  // bind to changes in the channel and use the returned data
  channel.bind('new_invitation', function(data) {
    console.log(data);
    var senderId = data.invitation.sender_id;
    var recipientId = data.invitation.recipient_id;
    var username = data.username;
    // create a partial to append to the <ul> in the DOM
    var partial = "";
    partial += '<li><p>' + username + ': just now</p>' +
      '<div id="flex-container"><form method="post" action="/chat_rooms" id="create_chat_room">' +
        '<input type="hidden" value="'+ data.invitation.id + '" name="invitation[id]"/>' +
        '<input type="submit" value="Accept" class="btn btn-success"/>' +
      '</form>' +
      '<button class="btn btn-danger delete_invitation" data-id="' + data.invitation.id + '">Decline</button></div>' +
    '</li>';
    $('#notification-list').append(partial);
    // re-invoke event listener to delete invitation if user clicks 'decline'
    deleteInvitation();
    // removeFlash();
  });

  channel.bind('create_chat_room', function(data) {
    console.log(data);
    window.location = "/chat_rooms/" + data;
  });
});
</script>


</body>
</html>

{'fraction_non_alphanumeric': 0.19427650141072147, 'fraction_numerical': 0.008061265618702136, 'mean_word_length': 3.660093896713615, 'pattern_counts': {'":': 0, '<': 109, '<?xml version=': 0, '>': 109, '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': '6524938', 'n_tokens_mistral': 1712, 'n_tokens_neox': 1629, 'n_words': 368}