<commit_before>var values = {
    friction: 0.1,
    timeStep: 0.01,
    amount: 6
};

var path;
var sinPath;

var tilt = 0;
var iOS = false;

function isiOS()
{
    return (navigator.userAgent.match(/(iPad|iPhone|iPod)/i) != null);
}

function createPath() {
    var bg = new Path.Circle(new Point(0.5, 0.5) * size, size.width * 0.45);
    bg.fillColor = '#c70a0d';

    sinPath = new Path();
    var boxPath = new Path([
        new Point(0.0, 0.5) * size,
        new Point(0.0, 1.0) * size,
        new Point(1.0, 1.0) * size,
        new Point(1.0, 0.5) * size
    ]);

    for (var i = 0; i <= values.amount; i++) {
        var segment = sinPath.add(
            new Point(i / values.amount, 0.5) * size
        );
        var point = segment.point;
        point.fixed = i < 1 || i > values.amount - 1;
        point.i = i;
        point.vy = 0;
        point.ty = 0.5;
    }

    path = new CompoundPath({
        children: [
            sinPath,
            boxPath
        ],
        fillColor: '#211657',
    });

    var mask = new CompoundPath({
        children: [
            new Path.Circle(new Point(0.5, 0.5) * size, size.width * 0.45),
            new Path.Rectangle(new Point(0,0), new Point(1,1) * size)
        ],
        fillColor: '#ffffff'
    });

    var raster = new Raster("static/image/python-white.png");
    raster.position = view.center;
    raster.scale(0.26);
}

function onResize() {
    size =  new Size(480, 480);
    view.viewSize = size;
    createPath();
}

function onFrame(event) {
    updateWave(sinPath);

    var t = tilt / 35.0;
    for (var i = 0; i <= values.amount; i++) {
        var point = sinPath.segments[i].point;
        point.ty = (Math.sin(point.i*Math.PI/values.amount*2)*0.17+0.5+(t * (values.amount/2-point.i))) * size.height;
    }
}

function updateWave(path) {
    var force = (1 - values.friction) * values.timeStep;

    for (var i = 1, l = path.segments.length - 1; i < l; i++) {
        var point = path.segments[i].point;
        point.vy += (point.ty - point.y) * force;
        point.vy *= 0.95;

        var previous_point = path.segments[i - 1].point;
        point.vy -= previous_point.vy * 0.1;

        var next_point = path.segments[i + 1].point;
        point.vy += next_point.vy * 0.1;

        point.y = Math.max(point.y + point.vy, 0);
    }
    path.smooth();
}

function onMouseMove(event) {
    var location = sinPath.getNearestLocation(event.point);
    var segment = location.segment;
    var point = segment.point;

    if (!point.fixed && location.distance < size.height / 4) {
        var y = event.point.y;
        point.vy += (y - point.y) / 6 * values.friction;
        if (segment.previous && !segment.previous.point.fixed) {
            var previous = segment.previous.point;
            previous.vy += (y - previous.y) / 24 * values.friction;
        }
        if (segment.next && !segment.next.point.fixed) {
            var next = segment.next.point;
            next.vy += (y - next.y) / 24 * values.friction;
        }
    }
}

function onKeyDown(event) {
    if (event.key == 'space') {
        path.fullySelected = !path.fullySelected;
    } else if (event.key == 'a') {
        tilt = -10;
    } else if (event.key == 'b') {
        tilt = 0;
    } else if (event.key == 'c') {
        tilt = 10;
    }
}

$(function() {
    iOS = isiOS();
    window.ondevicemotion = function(event) {
        if( iOS )
        {
            tilt = event.accelerationIncludingGravity.x;
        }
        else
        {
            tilt = -event.accelerationIncludingGravity.x;
        }
    }
});
<commit_msg>Fixes #26 with a dirty-workaround<commit_after>var values = {
    friction: 0.1,
    timeStep: 0.01,
    amount: 6
};

var path;
var sinPath;

var tilt = 0;
var iOS = false;

function isiOS()
{
    return (navigator.userAgent.match(/(iPad|iPhone|iPod)/i) != null);
}

function createPath() {
    var bg = new Path.Circle(new Point(0.5, 0.5) * size, size.width * 0.45);
    bg.fillColor = '#c70a0d';

    sinPath = new Path();
    var boxPath = new Path([
        new Point(0.0, 0.5) * size,
        new Point(0.0, 1.0) * size,
        new Point(1.0, 1.0) * size,
        new Point(1.0, 0.5) * size
    ]);

    for (var i = 0; i <= values.amount; i++) {
        var segment = sinPath.add(
            new Point(i / values.amount, 0.5) * size
        );
        var point = segment.point;
        point.fixed = i < 1 || i > values.amount - 1;
        point.i = i;
        point.vy = 0;
        point.ty = 0.5;
    }

    path = new CompoundPath({
        children: [
            sinPath,
            boxPath
        ],
        fillColor: '#211657',
    });

    var mask = new CompoundPath({
        children: [
            new Path.Circle(new Point(0.5, 0.5) * size, size.width * 0.45),
            new Path.Rectangle(new Point(0,0), new Point(1,1) * size)
        ],
        fillColor: '#ffffff'
    });

    var raster = new Raster("static/image/python-white.png");
    raster.position = view.center;
    raster.scale(0.26);
}

function onResize() {
    size =  new Size(480, 480);
    view.viewSize = size;
    createPath();
}

function onFrame(event) {
    updateWave(sinPath);

    var t = tilt / 35.0;
    for (var i = 0; i <= values.amount; i++) {
        var point = sinPath.segments[i].point;
        point.ty = (Math.sin(point.i*Math.PI/values.amount*2)*0.17+0.5+(t * (values.amount/2-point.i))) * size.height;
    }
}

function updateWave(path) {
    var force = (1 - values.friction) * values.timeStep;

    for (var i = 1, l = path.segments.length - 1; i < l; i++) {
        var point = path.segments[i].point;
        point.vy += (point.ty - point.y) * force;
        point.vy *= 0.95;

        var previous_point = path.segments[i - 1].point;
        point.vy -= previous_point.vy * 0.1;

        var next_point = path.segments[i + 1].point;
        point.vy += next_point.vy * 0.1;

        point.y = Math.max(point.y + point.vy, 0);
    }
    path.smooth();
}

$.support.touch = 'ontouchstart' in window;
if( !$.support.touch ) {
    onMouseMove = function(event) {
        var location = sinPath.getNearestLocation(event.point);
        var segment = location.segment;
        var point = segment.point;

        if (!point.fixed && location.distance < size.height / 4) {
            var y = event.point.y;
            point.vy += (y - point.y) / 6 * values.friction;
            if (segment.previous && !segment.previous.point.fixed) {
                var previous = segment.previous.point;
                previous.vy += (y - previous.y) / 24 * values.friction;
            }
            if (segment.next && !segment.next.point.fixed) {
                var next = segment.next.point;
                next.vy += (y - next.y) / 24 * values.friction;
            }
        }
    }
}

function onKeyDown(event) {
    if (event.key == 'space') {
        path.fullySelected = !path.fullySelected;
    } else if (event.key == 'a') {
        tilt = -10;
    } else if (event.key == 'b') {
        tilt = 0;
    } else if (event.key == 'c') {
        tilt = 10;
    }
}

$(function() {
    iOS = isiOS();
    window.ondevicemotion = function(event) {
        if( iOS )
        {
            tilt = event.accelerationIncludingGravity.x;
        }
        else
        {
            tilt = -event.accelerationIncludingGravity.x;
        }
    }
});

{'fraction_non_alphanumeric': 0.15608429639700883, 'fraction_numerical': 0.028008157715839564, 'mean_word_length': 1.8412514484356894, 'pattern_counts': {'":': 0, '<': 13, '<?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': '3706475', 'n_tokens_mistral': 2692, 'n_tokens_neox': 2536, 'n_words': 574}