<commit_before>function mkSlider(name, header, units, min, max, step) {
    var group = $('#' + name);
    group.append('<h3 id="' + name + '-label"></h3>')
    group.append('<div id="' + name + '-slider" class="slider"></div>');

    var control = $('#' + name + '-slider');
    var label = $('#' + name + '-label');

    var labelDigits = step < 1 ? 1 : 0;
    var putUrl = '/vessel/' + name + '/';

    control.slider({
        min: min, max: max, step: step,
        animate: true, width: 300,
        slide: onChange,
        change: onChange,
    });

    function onChange(ev, ui) {
        label.text(header + ': ' + ui.value.toFixed(labelDigits) + units);

        if (!control.slider('updating')) {
            $.put(putUrl + ui.value);
        }
    }

    control.slider('update', 0);
}

function fetchValues() {
    $.get('/vessel', function(v) {
        $('#speed-slider').slider('update', v.simSpeed);
        $('#heading-slider').slider('update', v.simHeading);
        $('#rudder-slider').slider('update', v.simRudder);
        setTimeout(fetchValues, 500);
    });
}

fetchValues();


//
// jQuery Extensions
//

function _ajax_request(url, data, callback, type, method) {
    if (jQuery.isFunction(data)) {
        callback = data;
        data = {};
    }
    return jQuery.ajax({
        type: method,
        url: url,
        data: data,
        success: callback,
        dataType: type
        });
}

jQuery.extend({
    put: function(url, data, callback, type) {
        return _ajax_request(url, data, callback, type, 'PUT');
    },
    delete_: function(url, data, callback, type) {
        return _ajax_request(url, data, callback, type, 'DELETE');
    }
});

jQuery.fn.extend(jQuery.ui.slider.prototype, {
    _updating: false,
    updating: function() {
        return this._updating;
    },
    update: function(value) {
        if (this._mouseSliding || this._keySliding) return;
        this._updating = true;
        this.value(value);
        this._updating = false;
    },
});<commit_msg>Removed custom handling of programmatic updates.<commit_after>function mkSlider(name, header, units, min, max, step) {
    var group = $('#' + name);
    group.append('<h3 id="' + name + '-label"></h3>')
    group.append('<div id="' + name + '-slider" class="slider"></div>');

    var control = $('#' + name + '-slider');
    var label = $('#' + name + '-label');

    control.slider({
        min: min, max: max, step: step,
        animate: true, width: 300,
        change: function(ev, ui) {
            labelValue(ui.value);
        },
        slide: function(ev, ui) {
            labelValue(ui.value);
            $.put('/vessel/' + name + '/' + ui.value);
        },
    });

    var labelDigits = step < 1 ? 1 : 0;
    function labelValue(value) {
        label.text(header + ': ' + value.toFixed(labelDigits) + units);
    }

    control.slider('value', 0);
}

function fetchValues() {
    $.get('/vessel', function(v) {
        $('#speed-slider').slider('value', v.simSpeed);
        $('#heading-slider').slider('value', v.simHeading);
        $('#rudder-slider').slider('value', v.simRudder);
        setTimeout(fetchValues, 500);
    });
}

fetchValues();


//
// jQuery Extensions
//

function _ajax_request(url, data, callback, type, method) {
    if (jQuery.isFunction(data)) {
        callback = data;
        data = {};
    }
    return jQuery.ajax({
        type: method,
        url: url,
        data: data,
        success: callback,
        dataType: type
        });
}

jQuery.extend({
    put: function(url, data, callback, type) {
        return _ajax_request(url, data, callback, type, 'PUT');
    },
    delete_: function(url, data, callback, type) {
        return _ajax_request(url, data, callback, type, 'DELETE');
    }
});
{'fraction_non_alphanumeric': 0.18116900290928326, 'fraction_numerical': 0.006347527109230362, 'mean_word_length': 2.398023360287511, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, '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': '3699946', 'n_tokens_mistral': 1210, 'n_tokens_neox': 1179, 'n_words': 271}