<commit_before>// Get IRC updates from the couch
Couch.urlPrefix = '/couch';
var db = Couch.db('rochackircmarkov');
db.changes(null, {
    include_docs: true
}).onChange(function (resp) {
    if (resp.results) resp.results.forEach(addChatRow);
});

// Get latest IRC messages
db.view('couchgrams/all', {
    descending: true,
    limit: 15,
    include_docs: true,
    error: function () {},
    success: function (resp) {
        if (resp && resp.rows) resp.rows.reverse().forEach(addChatRow);
    }
});

var chatList = document.getElementById("chat-messages");

function addChatRow(row) {
    var date = new Date(row.id * 1000);
    var text = row.doc.text;
    // Insert chat message
    var li = document.createElement("li");
    li.appendChild(document.createTextNode(text));
    li.title = date.toLocaleString();
    chatList.appendChild(li);
}

var localVideoEl = document.getElementById('localVideo');
var remoteVideosEl = document.getElementById('remotes');

// create our webrtc connection
var webrtc = new WebRTC({
    localVideoEl: 'localVideo',
    remoteVideosEl: remoteVideosEl,
    // immediately ask for camera access
    autoRequestMedia: true,<commit_msg>Chat: add URL highlighting and sender name<commit_after>var chatList = document.getElementById("chat-messages");

if (chatList) {
    // Get IRC updates from the couch
    Couch.urlPrefix = '/couch';
    var db = Couch.db('rochackircmarkov');
    db.changes(null, {
        include_docs: true,
        filter: 'couchgrams/text'
    }).onChange(function (resp) {
        if (resp.results) resp.results.forEach(addChatRow);
    });

    // Get latest IRC messages
    db.view('couchgrams/text', {
        descending: true,
        limit: 25,
        include_docs: true,
        error: function () {},
        success: function (resp) {
            if (resp && resp.rows) resp.rows.reverse().forEach(addChatRow);
        }
    });
}

var urlRegex = /[a-z]{2,}:\/\/*[^ ]*(?= |$)/g;

function addChatRow(row) {
    var date = new Date(row.id * 1000);
    var text = row.doc.text;
    var sender = row.doc.sender;
    // Insert chat message
    var li = document.createElement("li");
    if (sender) li.appendChild(document.createTextNode('<' + sender + '> '));

    // Turn URLs into links.
    var urls = [];
    var match;
    while (match = urlRegex.exec(text)) {
        urls.push(match[0]);
    }
    text.split(urlRegex).forEach(function (text) {
        // Write text segment
        li.appendChild(document.createTextNode(text));
        // Write link
        if (urls.length == 0) return;
        var url = urls.pop();
        var link = document.createElement("a");
        link.setAttribute("href", url);
        link.appendChild(document.createTextNode(url));
        li.appendChild(link);
    });

    li.title = date.toLocaleString();
    chatList.appendChild(li);
}

var localVideoEl = document.getElementById('localVideo');
var remoteVideosEl = document.getElementById('remotes');

// create our webrtc connection
var webrtc = new WebRTC({
    localVideoEl: 'localVideo',
    remoteVideosEl: remoteVideosEl,
    // immediately ask for camera access
    autoRequestMedia: true,
{'fraction_non_alphanumeric': 0.14236001265422335, 'fraction_numerical': 0.004745333755140778, 'mean_word_length': 3.0434782608695654, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '160815', 'n_tokens_mistral': 995, 'n_tokens_neox': 959, 'n_words': 228}