<commit_before>// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
var onoff = 0;
var acc = {}; // TEMP STORE
var rot = {}; // TEMP STORE
// DECLARATIONS AND RUN
// ============================================================
// point in time data captured from phone
var captures = {
    // start: Date(),
    // doSupported: false,
    // dmSupported: false
};
// var resHist = [];  // will collect our history of captures

// we set our declared variables in a function as we can later
// use that function as a reset
var vel = {}, pos = {}, cords = {};
var nIntervId; // interval stamps for our clock
var series = {  // default dots in graph
    name: 'Signature',
};
var rem = 2;  // countdown clock, 3 seconds
// And run
motionVars();
getDeviceData();

// MAIN FUNCTIONS
// ============================================================
function getDeviceData() {
    // call motion
    if (window.DeviceMotionEvent) {
        window.addEventListener('devicemotion', MotionHandler, false);
    } else {
        document.getElementById("dmEvent").innerHTML = "Motion not supported."
    }
    // call orientation
    if (window.DeviceOrientationEvent) {
        window.addEventListener('deviceorientation', OrientationHandler, false);
    } else {
        document.getElementById("dmEvent2").innerHTML = "Orientation not supported."
    }
}

function MotionHandler(eventData) {
    /* Grab the acceleration from the results
    alpha is the compass direction
    beta is the front-to-back tilt in degrees, where front is positive
    gamma is the left-to-right tilt in degrees, where right is positive */
    /*
    var info, xyz = "[X, Y, Z, ra, rb, rg, a, b, g]"; d = Date();
    document.getElementById("dmEvent").innerHTML = "DeviceMotion";
    info = xyz.replace("X", round(eventData.acceleration.x));
    info = info.replace("Y", round(eventData.acceleration.y));
    info = info.replace("Z", round(eventData.acceleration.z));
    info = info.replace("ra", round(eventData.rotationRate.alpha));
    info = info.replace("rb", round(eventData.rotationRate.beta));
    info = info.replace("rg", round(eventData.rotationRate.gamma));
    document.getElementById("moCapture").innerHTML = info;
    info = eventData.interval;
    document.getElementById("moInterval").innerHTML = info;
    */
    // captures.dmSupported = true;
    // captures.interval = eventData.interval;
    captures.milli = new Date().getMilliseconds();
    captures.acc_x = round(eventData.acceleration.x);
    captures.acc_y = round(eventData.acceleration.y);
    captures.acc_z = round(eventData.acceleration.z);
    // captures.ra = round(eventData.rotationRate.alpha);
    // captures.rb = round(eventData.rotationRate.beta);
    // captures.rg = round(eventData.rotationRate.gamma);
}

function OrientationHandler(eventData) {
    /*
    alpha is the compass direction (rotation around z axis);
    varies 0 to 360;
    beta is rotation around the long y axis on LHS of phone;
    varies -90 to +90 (so doesn't know if upside down);
    think of as capturing the off-horizontal;
    gamma is rotation around short x axis at base of phone;
    varies -180 to +180;
    /*
    var info, xyz = "[a, b, g]";
    document.getElementById("dmEvent2").innerHTML = "DeviceOrientation";
    info = xyz.replace("a", round(eventData.alpha));
    info = info.replace("b", round(eventData.beta));
    info = info.replace("g", round(eventData.gamma));
    document.getElementById("moCapture2").innerHTML = info;
    info = eventData.interval;
    document.getElementById("moInterval2").innerHTML = info;
    */
    // captures.doSupported = true;
    true_a = Math.round(eventData.alpha);
    true_b = Math.round(eventData.beta);
    true_g = Math.round(eventData.gamma);
    document.getElementById('raws').innerHTML = [
        true_a, true_b, true_g
    ]; // temp fudge
    captures.dir_a = Math.round(Math.abs(round(eventData.alpha) - 180));
    captures.dir_b = Math.round(Math.abs(round(eventData.beta)));
    captures.dir_g = Math.round(Math.abs(round(eventData.gamma)) * 2);
    captures.interval = round(eventData.interval);
    document.getElementById('north').innerHTML = [
        captures.dir_a, captures.dir_b, captures.dir_g
    ]; // temp fudge
}

// RUNNING OUR SAMPLER
// ============================================================
function addCountDownLayer(task, millis) {
     repeatit(<commit_msg>Device data graphics<commit_after>// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
var onoff = 0;
var acc = {}; // TEMP STORE
var rot = {}; // TEMP STORE
// DECLARATIONS AND RUN
// ============================================================
// point in time data captured from phone
var captures = {
    // start: Date(),
    // doSupported: false,
    // dmSupported: false
};
// var resHist = [];  // will collect our history of captures

// we set our declared variables in a function as we can later
// use that function as a reset
var vel = {}, pos = {}, cords = {};
var nIntervId; // interval stamps for our clock
var series = {  // default dots in graph
    name: 'Signature',
};
var rem = 2;  // countdown clock, 3 seconds
// And run
motionVars();
getDeviceData();

// MAIN FUNCTIONS
// ============================================================
function getDeviceData() {
    // call motion
    if (window.DeviceMotionEvent) {
        window.addEventListener('devicemotion', MotionHandler, false);
    } else {
        document.getElementById("dmEvent").innerHTML = "Motion not supported."
    }
    // call orientation
    if (window.DeviceOrientationEvent) {
        window.addEventListener('deviceorientation', OrientationHandler, false);
    } else {
        document.getElementById("dmEvent2").innerHTML = "Orientation not supported."
    }
}

function MotionHandler(eventData) {
    /* Grab the acceleration from the results
    alpha is the compass direction
    beta is the front-to-back tilt in degrees, where front is positive
    gamma is the left-to-right tilt in degrees, where right is positive */
    /*
    var info, xyz = "[X, Y, Z, ra, rb, rg, a, b, g]"; d = Date();
    document.getElementById("dmEvent").innerHTML = "DeviceMotion";
    info = xyz.replace("X", round(eventData.acceleration.x));
    info = info.replace("Y", round(eventData.acceleration.y));
    info = info.replace("Z", round(eventData.acceleration.z));
    info = info.replace("ra", round(eventData.rotationRate.alpha));
    info = info.replace("rb", round(eventData.rotationRate.beta));
    info = info.replace("rg", round(eventData.rotationRate.gamma));
    document.getElementById("moCapture").innerHTML = info;
    info = eventData.interval;
    document.getElementById("moInterval").innerHTML = info;
    */
    // captures.dmSupported = true;
    // captures.interval = eventData.interval;
    captures.milli = new Date().getMilliseconds();
    captures.acc_x = round(eventData.acceleration.x);
    captures.acc_y = round(eventData.acceleration.y);
    captures.acc_z = round(eventData.acceleration.z);
    // captures.ra = round(eventData.rotationRate.alpha);
    // captures.rb = round(eventData.rotationRate.beta);
    // captures.rg = round(eventData.rotationRate.gamma);
}

function OrientationHandler(eventData) {
    /*
    alpha is the compass direction (rotation around z axis);
    varies 0 to 360;
    beta is rotation around the long y axis on LHS of phone;
    varies -90 to +90 (so doesn't know if upside down);
    think of as capturing the off-horizontal;
    gamma is rotation around short x axis at base of phone;
    varies -180 to +180;
    /*
    var info, xyz = "[a, b, g]";
    document.getElementById("dmEvent2").innerHTML = "DeviceOrientation";
    info = xyz.replace("a", round(eventData.alpha));
    info = info.replace("b", round(eventData.beta));
    info = info.replace("g", round(eventData.gamma));
    document.getElementById("moCapture2").innerHTML = info;
    info = eventData.interval;
    document.getElementById("moInterval2").innerHTML = info;
    */
    // captures.doSupported = true;
    var true_a = Math.round(eventData.alpha);
    var true_b = Math.round(eventData.beta);
    var true_g = Math.round(eventData.gamma);
    document.getElementById('raws').innerHTML = [
        true_a, true_b, true_g
    ]; // temp fudge
    captures.dir_a = Math.round(Math.abs(round(eventData.alpha) - 180));
    captures.dir_b = Math.round(Math.abs(round(eventData.beta)));
    captures.dir_g = Math.round(Math.abs(round(eventData.gamma)) * 2);
    captures.interval = round(eventData.interval);
    document.getElementById('north').innerHTML = [
        captures.dir_a, captures.dir_b, captures.dir_g
    ]; // temp fudge
}

// RUNNING OUR SAMPLER
// ============================================================
function addCountDownLayer(task, millis) {
     repeatit(
{'fraction_non_alphanumeric': 0.16841629980810474, 'fraction_numerical': 0.005643977875606727, 'mean_word_length': 3.595435684647303, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, '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': '910974', 'n_tokens_mistral': 2676, 'n_tokens_neox': 2516, 'n_words': 660}