<commit_before>/*
 * haptics.js (https://github.com/EbookGlue/haptics.js)
 * Copyright (c) <NAME> 2014
 * http://sbala.org/haptics.js
 * <EMAIL>
 * Available under the MIT License.
 */

;

(function () {
    var Haptics = {},
        enabled,
        vibrate,
        currentRecording,
        log,
        durations;

    // string-integer mapping of durations for more readable code
    durations = {
        'slow': 250,
        'medium': 500,
        'fast': 750
    };

    // simple mapper function for getting string durations
    function getDuration (d) {
        return durations[d] || d;
    }

    // a console.log wrapper for debugging
    log = function(){
        // store logs to an array for reference
        log.history = log.history || [];
        log.history.push(arguments);
        if(this.console){
            console.log( Array.prototype.slice.call(arguments) );
        }
    };

    // check for navigator variables from different vendors
    enabled = vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate;

    // expose a wrapped copy of 'vibrate' function
    if (enabled) {
        Haptics.vibrate = function () {
            var params = [], i, len;
            for (i = 0, len = arguments.length; i < len; i += 1) {
                params.push(getDuration(arguments[i]));
            }
            vibrate.apply(this, params);
            return true;
        };
    }
    else {
        Haptics.vibrate = function () {
            return false;
        };
    }

    // handle click/touch event
    function onRecord(e) {
        e.preventDefault();
        currentRecording.push(new Date());
    }
    // begin recording a sequence of taps/clicks
    function record() {
        currentRecording = [];
        window.addEventListener("touchstart". onRecord, false);
        window.addEventListener("touchend". onRecord, false);
        window.addEventListener("mousedown", onRecord, false);
        window.addEventListener("mouseup". onRecord, false);
    }
    // complete a recording of a sequence of taps/clicks
    function finish() {
        log(currentRecording);
        window.removeEventListener("touchstart". onRecord);
        window.removeEventListener("touchend". onRecord);
        window.removeEventListener("mousedown", onRecord);
        window.removeEventListener("mouseup". onRecord);

        if (currentRecording.length % 2 != 0)
            currentRecording.push(new Date());<commit_msg>changed the way the function accepts parameters<commit_after>/*
 * haptics.js (https://github.com/EbookGlue/haptics.js)
 * Copyright (c) <NAME> 2014
 * http://sbala.org/haptics.js
 * <EMAIL>
 * Available under the MIT License.
 */

;

(function () {
    var Haptics = {},
        enabled,
        vibrate,
        currentRecording,
        log,
        durations;

    // string-integer mapping of durations for more readable code
    durations = {
        'slow': 250,
        'medium': 500,
        'fast': 750
    };

    // simple mapper function for getting string durations
    function getDuration (d) {
        return durations[d] || d;
    }

    // a console.log wrapper for debugging
    log = function(){
        // store logs to an array for reference
        log.history = log.history || [];
        log.history.push(arguments);
        if(this.console){
            console.log( Array.prototype.slice.call(arguments) );
        }
    };

    // check for navigator variables from different vendors
    enabled = vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate;

    // expose a wrapped copy of 'vibrate' function
    if (enabled) {
        Haptics.vibrate = function (args) {
            var params = [], i, len;
            if (typeof args == "number") {
                vibrate(args);
                return true;
            }

            if (args.length) {
                for (i = 0, len = args.length; i < len; i += 1) {
                    params.push(getDuration(args[i]));
                }
                vibrate.apply(this, params);
                return true;
            }

            return false;
        };
    }
    else {
        Haptics.vibrate = function () {
            return false;
        };
    }

    // handle click/touch event
    function onRecord(e) {
        e.preventDefault();
        currentRecording.push(new Date());
    }
    // begin recording a sequence of taps/clicks
    function record() {
        currentRecording = [];
        window.addEventListener("touchstart". onRecord, false);
        window.addEventListener("touchend". onRecord, false);
        window.addEventListener("mousedown", onRecord, false);
        window.addEventListener("mouseup". onRecord, false);
    }
    // complete a recording of a sequence of taps/clicks
    function finish() {
        log(currentRecording);
        window.removeEventListener("touchstart". onRecord);
        window.removeEventListener("touchend". onRecord);
        window.removeEventListener("mousedown", onRecord);
        window.removeEventListener("mouseup". onRecord);

        if (currentRecording.length % 2 != 0)
            currentRecording.push(new Date());
{'fraction_non_alphanumeric': 0.11748947569843092, 'fraction_numerical': 0.006505931879066207, 'mean_word_length': 2.0567251461988305, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '41070', 'n_tokens_mistral': 1496, 'n_tokens_neox': 1424, 'n_words': 359}