<commit_before>K2.Bar = function(args) {
    if (arguments.length) {
        this.getready(args);
    }
};

K2.extend(K2.Bar, K2.UIElement);

K2.Bar.prototype.getready = function(args) {

    // Call the constructor from the superclass.
    K2.Bar.superclass.getready.call(this, args);

    this.values = {'barPos' : [],
                   'dragStart': [],
                   'dragEnd': []
                   };
    this.defaultSlot = 'barPos';

    this.setWidth(args.width);
    this.setHeight(args.height);
    this.orientation = args.orientation || 0;
    this.barColor = args.barColor || 'black';
    this.thickness = args.thickness || 1;

};

// This methods returns true if the point given belongs to this element.
K2.Bar.prototype.isInROI = function(x, y) {
    if ((x > this.ROILeft) && (y > this.ROITop)) {
        if ((x < (this.ROILeft + this.ROIWidth)) && (y < (this.ROITop + this.ROIHeight))) {
            return true;
        }
    }
    return false;
};

K2.Bar.prototype.tap = K2.Bar.prototype.drag = function(curr_x, curr_y) {

    var to_set = 0,
        ret = {};

    
    if (this.isInROI(curr_x, curr_y)) {

        var tempValue = this.values.barPos;
        var retVal = [];

        if (this.orientation === 0) {
            retVal = [curr_x, tempValue[1]];
        }

        else if (this.orientation === 1) {
            retVal = [tempValue[0], curr_y];
        }

        else {
            console.error('orientation invalid, this will probably break something');
        }

        // Click on button is completed, the button is no more triggered.
        this.triggered = false;

		ret = {'slot' : 'barPos', 'value' : retVal};
        return ret;
    }
  

    // Action is void, button was upclicked outside its ROI or never downclicked
    // No need to trigger anything, ignore this event.
    return undefined;

};

K2.Bar.prototype.dragend = function(curr_x, curr_y) {
    if (this.isInROI(curr_x, curr_y)) {
        ret = {'slot' : 'dragEnd', 'value' : [curr_x, curr_y]};
        return ret;
    }
};

K2.Bar.prototype.dragstart = function(curr_x, curr_y) {
    if (this.isInROI(curr_x, curr_y)) {
        ret = {'slot' : 'dragStart', 'value' : [curr_x, curr_y]};
        return ret;
    }
};

K2.Bar.prototype.setValue = function(slot, value) {

	console.log('Setting ' + slot + ' to ' + value);
<commit_msg>Swipe now acts as a dragEnd event<commit_after>K2.Bar = function(args) {
    if (arguments.length) {
        this.getready(args);
    }
};

K2.extend(K2.Bar, K2.UIElement);

K2.Bar.prototype.getready = function(args) {

    // Call the constructor from the superclass.
    K2.Bar.superclass.getready.call(this, args);

    this.values = {'barPos' : [],
                   'dragStart': [],
                   'dragEnd': []
                   };
    this.defaultSlot = 'barPos';

    this.setWidth(args.width);
    this.setHeight(args.height);
    this.orientation = args.orientation || 0;
    this.barColor = args.barColor || 'black';
    this.thickness = args.thickness || 1;

};

// This methods returns true if the point given belongs to this element.
K2.Bar.prototype.isInROI = function(x, y) {
    if ((x > this.ROILeft) && (y > this.ROITop)) {
        if ((x < (this.ROILeft + this.ROIWidth)) && (y < (this.ROITop + this.ROIHeight))) {
            return true;
        }
    }
    return false;
};

K2.Bar.prototype.tap = K2.Bar.prototype.drag = function(curr_x, curr_y) {

    var to_set = 0,
        ret = {};

    
    if (this.isInROI(curr_x, curr_y)) {

        var tempValue = this.values.barPos;
        var retVal = [];

        if (this.orientation === 0) {
            retVal = [curr_x, tempValue[1]];
        }

        else if (this.orientation === 1) {
            retVal = [tempValue[0], curr_y];
        }

        else {
            console.error('orientation invalid, this will probably break something');
        }

		ret = {'slot' : 'barPos', 'value' : retVal};
        return ret;
    }
  

    // Action is void, button was upclicked outside its ROI or never downclicked
    // No need to trigger anything, ignore this event.
    return undefined;

};

K2.Bar.prototype.dragend = K2.Bar.prototype.swipe = function(curr_x, curr_y) {
    if (this.isInROI(curr_x, curr_y)) {
        ret = {'slot' : 'dragEnd', 'value' : [curr_x, curr_y]};
        return ret;
    }
    else {
        // equivalent to mouseOut + triggered === true
        ret = {'slot' : 'dragEnd', 'value' : [curr_x, curr_y]};
        return ret;
    }
};

K2.Bar.prototype.dragstart = function(curr_x, curr_y) {
    if (this.isInROI(curr_x, curr_y)) {
        ret = {'slot' : 'dragStart', 'value' : [curr_x, curr_y]};
        return ret;
    }
};

K2.Bar.prototype.setValue = function(slot, value) {

	console.log('Setting ' + slot + ' to ' + value);

{'fraction_non_alphanumeric': 0.14941569282136896, 'fraction_numerical': 0.00813856427378965, 'mean_word_length': 2.216778523489933, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6503591', 'n_tokens_mistral': 1672, 'n_tokens_neox': 1629, 'n_words': 366}