<commit_before>(function ($, undefined) {

    function createElem(tag, attr, content) {
	// TODO: remove jQuery dependency
	var el = $("<" + tag + "/>").attr(attr);
	if (content) {
	    el.append(content);
	}
	return el[0];
    }

    // A widget must expose an id field which identifies it to the backend,
    // an elem attribute which is will be added to the DOM, and
    // a getState method which returns the value to be sent to the backend
    var Widget = {
	id: undefined,
	elem: undefined,
	getState: function () {
	    return this.elem.value;
	}
    };

    var Slider = function (typ, id, init) {
	var attr = { type: "range",
		     value: init.value,
		     min:   init.min,
		     max:   init.max };
	elem = createElem("input", attr);

	elem.onchange = InputWidgets.updateSender(this);

	this.id = id;
	this.elem = elem;
    }
    Slider.prototype = Widget;

    var InputWidgets = {
	Slider: Slider,
	setCommHandler: function (f) {
	    // TODO: wrap f to throttle
	    InputWidgets._communicate = f;
	},
	updateSender: function (widget) {
	    return function () {
		InputWidgets._communicate(widget);
	    };
	},
	_communicate: function (widget) {
	    console.log("State update (", widget.id, "):", widget.getState());
	}<commit_msg>Changed structure of widget, added label field.<commit_after>(function ($, undefined) {

    function createElem(tag, attr, content) {
	// TODO: remove jQuery dependency
	var el = $("<" + tag + "/>").attr(attr);
	if (content) {
	    el.append(content);
	}
	return el[0];
    }

    // A widget must expose an id field which identifies it to the backend,
    // an elem attribute which is will be added to the DOM, and
    // a getState() method which returns the value to be sent to the backend
    // a sendUpdate() method which sends its current value to the backend
    var Widget = {
	id: undefined,
	elem: undefined,
	label: undefined,
	getState: function () {
	    return this.elem.value;
	},
	sendUpdate: function () {
	}
    };

    var Slider = function (typ, id, init) {
	var attr = { type:  "range",
		     value: init.value,
		     min:   init.min,
		     max:   init.max,
		     step:  init.step },
	    elem = createElem("input", attr),
	    self = this;

	elem.onchange = function () {
	    console.log("state change", self.getState());
	    self.sendUpdate();
	}

	this.id = id;
	this.elem = elem;
	this.label = init.label;

	InputWidgets.commInitializer(this); // Initialize communication
    }
    Slider.prototype = Widget;

    var InputWidgets = {
	Slider: Slider,
	// a central way to initalize communication
	// for widgets.
	commInitializer: function (widget) {
	    widget.sendUpdate = function () {};
	}
{'fraction_non_alphanumeric': 0.13059701492537312, 'fraction_numerical': 0.0007462686567164179, 'mean_word_length': 2.786723163841808, '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': '2304354', 'n_tokens_mistral': 880, 'n_tokens_neox': 838, 'n_words': 266}