<commit_before>var app = angular.module("ChatersockApp", []);

app.controller("ChatersockCtrl", function($scope, $sce, $http) {
    var sock = new SockJS("/chatersock");

    $scope.messages = [];
    $scope.roster = [];
    $scope.name = "";
    $scope.text = "";

    sock.onopen = function() {};
    sock.onmessage = function(e) {
      if (e.data) {
          try {
            var data = JSON.parse(e.data);

            if (data.text) {
                $scope.messages.push(data);
            }
            else if (data.clear) {
                $scope.messages.length = 0;
            }
            else {
                $scope.roster = data;
            }
          }
          catch (err) {}

          $scope.$apply();
      }
    };
    sock.onclose = function() {
      console.log("close");
    };

    $scope.send = function send() {
      $scope.setName();

      console.log("Sending message:", $scope.text);
      sock.send($scope.text);
      $scope.text = "";
    };

    $scope.setName = function setName() {
      sock.send(JSON.stringify({ name: $scope.name }));
    };

    $scope.clear = function clear() {
      sock.send(JSON.stringify({ clear: $scope.name }));
    };
});<commit_msg>add urls support<commit_after>var app = angular.module("ChatersockApp", []);

app.controller("ChatersockCtrl", function($scope, $sce, $http) {
    var sock = new SockJS("/chatersock");

    $scope.messages = [];
    $scope.roster = [];
    $scope.name = "";
    $scope.text = "";

    sock.onopen = function() {};
    sock.onmessage = function(e) {
      if (e.data) {
          try {
            var data = JSON.parse(e.data);

            if (data.text) {
                data.text = urlify(data.text);
                $scope.messages.push(data);
            }
            else if (data.clear) {
                $scope.messages.length = 0;
            }
            else {
                $scope.roster = data;
            }
          }
          catch (err) {}

          $scope.$apply();
      }
    };
    sock.onclose = function() {
      console.log("close");
    };

    $scope.send = function send() {
      $scope.setName();

      console.log("Sending message:", $scope.text);
      sock.send($scope.text);
      $scope.text = "";
    };

    $scope.setName = function setName() {
      sock.send(JSON.stringify({ name: $scope.name }));
    };

    $scope.clear = function clear() {
      sock.send(JSON.stringify({ clear: $scope.name }));
    };

    function urlify(text) {
        if (text && text.replace) {
            var urlRegex = /(https?:\/\/[^\s]+)/g;
            return text.replace(urlRegex, function(url) {
                return "<a href=\"" + url + "\">" + url + "</a>";
            });
        }
        else {
          return text;
        }
    }
});
{'fraction_non_alphanumeric': 0.1758595988538682, 'fraction_numerical': 0.0007163323782234957, 'mean_word_length': 1.6200750469043153, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2123768', 'n_tokens_mistral': 878, 'n_tokens_neox': 852, 'n_words': 150}