<commit_before>
var control = io(document.location.origin+'/livedraft');

control.on('connect', function() {
    control.emit('join', {room: 'livedraft', admin: true});
});

//TODO - Process config push from server

var classes_label = "label-primary label-default label-info label-success label-danger label-warning";

function send(message) {
    control.emit('broadcast', message);
    console.log(message);
}

$('#url').blur(function() {
    result = $('#url').val().substr($('#url').val().lastIndexOf('/')+1);
    pattern = new RegExp(/[0-9]+/);
    if (pattern.test(result)) {
        $('[name=url').removeClass('has-error');
    } else {
        $('[name=url').removeClass('has-success').addClass('has-error');
    }
});

$('#btnConnect').click(function() {
    result = $('#url').val().substr($('#url').val().lastIndexOf('/')+1);
    pattern = new RegExp(/[0-9]+/);
    if (pattern.test(result)) {
        console.log(result);
        send({ event: 'message', data: { action: 'connect', value: result }});
    }
});

$("#btnReload").click(function() {
    send({ event: 'reload' });
});<commit_msg>stub - admin page receiving websocket data<commit_after>
var control = io(document.location.origin+'/livedraft');

/**** Control Functions *****/

control.on('connect', function() {
    control.emit('join', {room: 'livedraft', admin: true});
});

control.on('message', function(data) {
    switch (data.action) {
        case "connect":
            draftid = data.value;
            livedraftConnect();
            console.log("initiating connection to livedraft url");
            break;
        case "disconnect":
            livedraft.disconnect();
            console.log("administratively disconnected");
            break;
        case 'pause':
            console.log('videos paused');
            break;
        case 'play':
            console.log('videos resumed');
            break;
        default:
            console.log(data);
    }
});

/**** LiveDraft Functions ****/

livedraft.on('connect', function(data) {
    console.log("livedraft connected");
    $('#btnConnect').hide();
    $('#btnDisconnect').show();
});

livedraft.on('disconnect', function(data) {
    console.log("livedraft connected");
    $('#btnConnect').show();
    $('#btnDisconnect').hide();
});

function send(message) {
    control.emit('broadcast', message);
    console.log(message);
}

$('#url').blur(function() {
    result = $('#url').val().substr($('#url').val().lastIndexOf('/')+1);
    pattern = new RegExp(/[0-9]+/);
    if (pattern.test(result)) {
        $('[name=url').removeClass('has-error');
    } else {
        $('[name=url').removeClass('has-success').addClass('has-error');
    }
});

$('#btnConnect').click(function() {
    result = $('#url').val().substr($('#url').val().lastIndexOf('/')+1);
    pattern = new RegExp(/[0-9]+/);
    if (pattern.test(result)) {
        console.log(result);
        send({ event: 'message', data: { action: 'connect', value: result }});
    }
});

$("#btnReload").click(function() {
    send({ event: 'reload' });
});
{'fraction_non_alphanumeric': 0.2245430809399478, 'fraction_numerical': 0.0039164490861618795, 'mean_word_length': 3.2043895747599453, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, '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': '369549', 'n_tokens_mistral': 940, 'n_tokens_neox': 935, 'n_words': 164}