<commit_before>function RangeFacet(div, config, options) {
    this._div = div;
    this._config = config;
    this._options = options;
    
    this._from = ("from" in this._config) ? this._config.from : null;
    this._to = ("to" in this._config) ? this._config.to : null;
    
    this._error = false;
    this._initializedUI = false;
}

RangeFacet.prototype._setDefaults = function() {
    switch (this._config.mode) {
    case "min":
        this._from = this._config.min;
        break;
    case "max":
        this._to = this._config.max;
        break;
    default:
        this._from = this._config.min;
        this._to = this._config.max;
    }
    
};

RangeFacet.reconstruct = function(div, uiState) {
    return new RangeFacet(div, uiState.c, uiState.o);
};

RangeFacet.prototype.getUIState = function() {
    var json = {
        c: this.getJSON(),
        o: this._options
    };
    
    return json;
}


RangeFacet.prototype.getJSON = function() {
    var o = {
        type: "range",
        name: this._config.name,
        mode: this._config.mode,
        expression: this._config.expression,
        columnName: this._config.columnName
    };
    
    if (this._config.mode == "min" || this._config.mode == "range") {
        if (this._from != null) {
            o.from = this._from;
        }
    }
    if (this._config.mode == "max" || this._config.mode == "range") {
        if (this._to != null) {
            o.to = this._to;
        }
    }
    
    return o;
};

RangeFacet.prototype.hasSelection = function() {
    switch (this._config.mode) {
    case "min":
        return this._from != null && (!this._initializedUI || this._from > this._config.min);
    case "max":
        return this._to != null && (!this._initializedUI || this._to < this._config.max);
    default:
        return (this._from != null && (!this._initializedUI || this._from > this._config.min)) ||
            (this._to != null && (!this._initializedUI || this._to < this._config.max));
    }
};

RangeFacet.prototype._initializeUI = function() {
    var self = this;
    var container = this._div.empty();
    
    var headerDiv = $('<div></div>').addClass("facet-title").appendTo(container);
    $('<span></span>').text(this._config.name).appendTo(headerDiv);
    
    var resetButton = $('<a href="javascript:{}"></a>').addClass("facet-choice-link").text("reset").click(function() {
        switch (self._config.mode) {
        case "min":
            self._from = self._config.min;
            self._sliderDiv.slider("value", self._from);
            break;
        case "max":
            self._to = self._config.max;
            self._sliderDiv.slider("value", self._to);
            break;
        default:
            self._from = self._config.min;
            self._to = self._config.max;
            self._sliderDiv.slider("values", 0, self._from);
            self._sliderDiv.slider("values", 1, self._to);
        }
        self._setRangeIndicators();
        self._updateRest();
    }).prependTo(headerDiv);
    
    var removeButton = $('<img>')
        .attr("src", "images/close.png")
        .attr("title", "Remove this facet")
        .addClass("facet-choice-link")
        .click(function() {
            self._remove();
        }).prependTo(headerDiv);
        
    var bodyDiv = $('<div></div>').addClass("facet-range-body").appendTo(container);
    
    if (this._error) {
        return;
    }
    
    this._histogramDiv = $('<div></div>').addClass("facet-range-histogram").appendTo(bodyDiv);
    this._sliderDiv = $('<div></div>').addClass("facet-range-slider").appendTo(bodyDiv);
    this._statusDiv = $('<div></div>').addClass("facet-range-status").appendTo(bodyDiv);
    
    var onSlide = function(event, ui) {
        switch (self._config.mode) {
        case "min":
            self._from = ui.value;
            break;
        case "max":
            self._to = ui.value;
            break;
        default:
            self._from = ui.values[0];
            self._to = ui.values[1];
        }
        self._setRangeIndicators();
        self._updateRest();
    };
    var sliderConfig = {
        range: "max",
        min: this._config.min,
        max: this._config.max,
        value: 2,
        stop: onSlide
    };
    if ("step" in this._config) {
        sliderConfig.step = this._config.step;
    }
        
    switch (this._config.mode) {
    case "min":
        sliderConfig.range = "max";
        sliderConfig.value = this._from;
        break;
    case "max":
        sliderConfig.range = "min";<commit_msg>In the range facet, although we don't want to update the facets until the user stops dragging, we still want to update the selection indicators from-to during the dragging.<commit_after>function RangeFacet(div, config, options) {
    this._div = div;
    this._config = config;
    this._options = options;
    
    this._from = ("from" in this._config) ? this._config.from : null;
    this._to = ("to" in this._config) ? this._config.to : null;
    
    this._error = false;
    this._initializedUI = false;
}

RangeFacet.prototype._setDefaults = function() {
    switch (this._config.mode) {
    case "min":
        this._from = this._config.min;
        break;
    case "max":
        this._to = this._config.max;
        break;
    default:
        this._from = this._config.min;
        this._to = this._config.max;
    }
    
};

RangeFacet.reconstruct = function(div, uiState) {
    return new RangeFacet(div, uiState.c, uiState.o);
};

RangeFacet.prototype.getUIState = function() {
    var json = {
        c: this.getJSON(),
        o: this._options
    };
    
    return json;
}


RangeFacet.prototype.getJSON = function() {
    var o = {
        type: "range",
        name: this._config.name,
        mode: this._config.mode,
        expression: this._config.expression,
        columnName: this._config.columnName
    };
    
    if (this._config.mode == "min" || this._config.mode == "range") {
        if (this._from != null) {
            o.from = this._from;
        }
    }
    if (this._config.mode == "max" || this._config.mode == "range") {
        if (this._to != null) {
            o.to = this._to;
        }
    }
    
    return o;
};

RangeFacet.prototype.hasSelection = function() {
    switch (this._config.mode) {
    case "min":
        return this._from != null && (!this._initializedUI || this._from > this._config.min);
    case "max":
        return this._to != null && (!this._initializedUI || this._to < this._config.max);
    default:
        return (this._from != null && (!this._initializedUI || this._from > this._config.min)) ||
            (this._to != null && (!this._initializedUI || this._to < this._config.max));
    }
};

RangeFacet.prototype._initializeUI = function() {
    var self = this;
    var container = this._div.empty();
    
    var headerDiv = $('<div></div>').addClass("facet-title").appendTo(container);
    $('<span></span>').text(this._config.name).appendTo(headerDiv);
    
    var resetButton = $('<a href="javascript:{}"></a>').addClass("facet-choice-link").text("reset").click(function() {
        switch (self._config.mode) {
        case "min":
            self._from = self._config.min;
            self._sliderDiv.slider("value", self._from);
            break;
        case "max":
            self._to = self._config.max;
            self._sliderDiv.slider("value", self._to);
            break;
        default:
            self._from = self._config.min;
            self._to = self._config.max;
            self._sliderDiv.slider("values", 0, self._from);
            self._sliderDiv.slider("values", 1, self._to);
        }
        self._setRangeIndicators();
        self._updateRest();
    }).prependTo(headerDiv);
    
    var removeButton = $('<img>')
        .attr("src", "images/close.png")
        .attr("title", "Remove this facet")
        .addClass("facet-choice-link")
        .click(function() {
            self._remove();
        }).prependTo(headerDiv);
        
    var bodyDiv = $('<div></div>').addClass("facet-range-body").appendTo(container);
    
    if (this._error) {
        return;
    }
    
    this._histogramDiv = $('<div></div>').addClass("facet-range-histogram").appendTo(bodyDiv);
    this._sliderDiv = $('<div></div>').addClass("facet-range-slider").appendTo(bodyDiv);
    this._statusDiv = $('<div></div>').addClass("facet-range-status").appendTo(bodyDiv);
    
    var onSlide = function(event, ui) {
        switch (self._config.mode) {
        case "min":
            self._from = ui.value;
            break;
        case "max":
            self._to = ui.value;
            break;
        default:
            self._from = ui.values[0];
            self._to = ui.values[1];
        }
        self._setRangeIndicators();
    };
    var onStop = function() {
        self._updateRest();
    };
    var sliderConfig = {
        range: "max",
        min: this._config.min,
        max: this._config.max,
        value: 2,
        stop: onStop,
        slide: onSlide
    };
    if ("step" in this._config) {
        sliderConfig.step = this._config.step;
    }
        
    switch (this._config.mode) {
    case "min":
        sliderConfig.range = "max";
        sliderConfig.value = this._from;
        break;
    case "max":
        sliderConfig.range = "min";
{'fraction_non_alphanumeric': 0.158255651987571, 'fraction_numerical': 0.0010714668381013607, 'mean_word_length': 2.0774810418727334, 'pattern_counts': {'":': 20, '<': 37, '<?xml version=': 0, '>': 37, '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': '5822246', 'n_tokens_mistral': 2887, 'n_tokens_neox': 2868, 'n_words': 544}