<commit_before><!DOCTYPE html>
<html>
<head>
  <title>Chat-io</title>
  <link rel="stylesheet" type="text/css" href="css/chat.css">
  <script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
</head>
<body>
  <header>
    <h1>Chat-io</h1>
  </header>
  <aside>
    <h2>Users</h2>
    <ul id="users"></ul>
  </aside>
  <section id="messages">
    <h2>Messages</h2>
  </section>
  <section id="new-message">
    <input type="text" id="input" />
    <button id="send">Send</button>
  </section>
  <script>

    var socket = io.connect();
    var userList = document.getElementById('users');
    var sendButton = document.getElementById('send');
    var messages = document.getElementById('messages');
    var textIn = document.getElementById('input');
    var user = prompt('username?');

    socket.emit('login', user);

    function addNewUser(name){
      var item = document.createElement('li');
      var txt = document.createTextNode(name);
      item.appendChild(txt);
      userList.appendChild(item);
    }

    function sendMessage(e){
      e.preventDefault();
      var msg = textIn.value;
      socket.emit('new message', {name: user, message: msg});
      textIn.value = '';
    }

    function addMessage(data){
      var entry = document.createElement('div');
      var txt = document.createTextNode(data.name + ': ' + data.message);
      entry.appendChild(txt);
      messages.appendChild(entry);
    }

    function sendOnEnter(e){
      if(e.keyCode === 13){
        sendMessage(e);
      }
    }

    sendButton.addEventListener('click', sendMessage, false);
    textIn.addEventListener('keypress', sendOnEnter, false);

    socket.on('online users', function(data){

      while (userList.firstChild) {
        userList.removeChild(userList.firstChild);
      }

      data.forEach(function(el){
        addNewUser(el);
      });

    });

    socket.on('new user', function(data){
      addNewUser(data);
    });

    socket.on('message', function(data){
      addMessage(data);
    });

  </script>
</body>
</html>
<commit_msg>store username in session storage<commit_after><!DOCTYPE html>
<html>
<head>
  <title>Chat-io</title>
  <link rel="stylesheet" type="text/css" href="css/chat.css">
  <script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
</head>
<body>
  <header>
    <h1>Chat-io</h1>
  </header>
  <aside>
    <h2>Users</h2>
    <ul id="users"></ul>
  </aside>
  <section id="messages">
    <h2>Messages</h2>
  </section>
  <section id="new-message">
    <input type="text" id="input" />
    <button id="send">Send</button>
  </section>
  <script>

    var socket = io.connect();
    var userList = document.getElementById('users');
    var sendButton = document.getElementById('send');
    var messages = document.getElementById('messages');
    var textIn = document.getElementById('input');
    var user;

    console.log(sessionStorage.getItem("username"));

    if (sessionStorage.getItem("username") == 'null' ||
        sessionStorage.getItem("username") == null){

      user = prompt('username?');

      sessionStorage.setItem('username', user);

    } else {

      user = sessionStorage.getItem("username");

    }

    socket.emit('login', user);

    function addNewUser(name){
      var item = document.createElement('li');
      var txt = document.createTextNode(name);
      item.appendChild(txt);
      userList.appendChild(item);
    }

    function sendMessage(e){
      e.preventDefault();
      var msg = textIn.value;
      socket.emit('new message', {name: user, message: msg});
      textIn.value = '';
    }

    function addMessage(data){
      var entry = document.createElement('div');
      var txt = document.createTextNode(data.name + ': ' + data.message);
      entry.appendChild(txt);
      messages.appendChild(entry);
    }

    function sendOnEnter(e){
      if(e.keyCode === 13){
        sendMessage(e);
      }
    }

    sendButton.addEventListener('click', sendMessage, false);
    textIn.addEventListener('keypress', sendOnEnter, false);

    socket.on('online users', function(data){

      while (userList.firstChild) {
        userList.removeChild(userList.firstChild);
      }

      data.forEach(function(el){
        addNewUser(el);
      });

    });

    socket.on('new user', function(data){
      addNewUser(data);
    });

    socket.on('message', function(data){
      addMessage(data);
    });

  </script>
</body>
</html>

{'fraction_non_alphanumeric': 0.17077027332279196, 'fraction_numerical': 0.004969505308335216, 'mean_word_length': 3.0364630811303557, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 69, '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': '7345555', 'n_tokens_mistral': 1416, 'n_tokens_neox': 1370, 'n_words': 250}