<commit_before>var scripts = document.getElementsByTagName('script'),
    script = scripts[scripts.length - 1];

var get_time_display = function(stamp) {
    var dt = new Date(stamp);
    var period = dt.getHours() < 12 ? 'AM' : 'PM';
    var hours = dt.getHours() > 12 ? dt.getHours() - 12 : dt.getHours();
    if (hours === 0) {
        hours = 12;
    }
    var minutes = dt.getMinutes() < 10 ? '0' + dt.getMinutes() : dt.getMinutes();
    return hours + ':' + minutes + ' ' + period;
};

function Timeline(loc, start_time, end_time, width, height) {
    this.loc = loc;
    this.start_time = start_time;
    this.end_time = end_time;
    this.width = width;
    this.height = height;

    this.container = d3.select(this.loc).append('svg');

    // Settings
    this.draw_width = this.width - 40; // Draw inside the svg without clipping
    this.y_offset = 20; // Height offset from time marker
    this.interval = 3600000; // One hour in milliseconds
    this.edge_offset = 20; // Come off the edge
}

Timeline.prototype.draw = function() {
    var dt = this.end_time - this.start_time;

    this.line_offset = this.draw_width / (dt / this.interval);

    for(var i = 0; i <= dt / this.interval; i++) {
        var x_offset = i * this.line_offset + this.edge_offset;

        this.container.append('line')
            .attr('x1', x_offset).attr('x2', x_offset)
            .attr('y1', this.y_offset).attr('y2', this.height - this.y_offset)
            .style('stroke', '#000000');

        var time = get_time_display(new Date(this.start_time + this.interval * i));

        this.container.append('text')
            .attr('x', x_offset - 15).attr('y', 10)
            .style('font-size', '10px')
            .style('fill', '#000000')
            .style('opacity', 1)
            .text(time);
    }
};
<commit_msg>First pass at making the time intervals change if the browser is too small or too much time has elapsed to show the markers hourly<commit_after>var scripts = document.getElementsByTagName('script'),
    script = scripts[scripts.length - 1];

var get_time_display = function(stamp) {
    var dt = new Date(stamp);
    var period = dt.getHours() < 12 ? 'AM' : 'PM';
    var hours = dt.getHours() > 12 ? dt.getHours() - 12 : dt.getHours();
    if (hours === 0) {
        hours = 12;
    }
    var minutes = dt.getMinutes() < 10 ? '0' + dt.getMinutes() : dt.getMinutes();
    return hours + ':' + minutes + ' ' + period;
};

function Timeline(loc, start_time, end_time, width, height) {
    this.loc = loc;
    this.start_time = start_time;
    this.end_time = end_time;
    this.width = width;
    this.height = height;

    this.container = d3.select(this.loc).append('svg');

    // Settings
    this.draw_width = this.width - 40; // Draw inside the svg without clipping
    this.y_offset = 20; // Height offset from time marker
    var one_hour = 60 * 60 * 1000; // One hour in milliseconds
    this.interval = one_hour;
    var span_in_hours = (this.end_time - this.start_time) / one_hour,
        width_span_ratio = Math.ceil(this.draw_width / span_in_hours);
    /*
    If the browser is small enough or more than a day has elapsed, show six
    time interval markers
    */
    if (width_span_ratio < 60 || span_in_hours > 24) {
        this.interval = Math.floor((span_in_hours * one_hour) / 6);
    }
    this.edge_offset = 20; // Come off the edge
}

Timeline.prototype.draw = function() {
    var dt = this.end_time - this.start_time;

    this.line_offset = this.draw_width / (dt / this.interval);

    for(var i = 0; i <= dt / this.interval; i++) {
        var x_offset = i * this.line_offset + this.edge_offset;

        this.container.append('line')
            .attr('x1', x_offset).attr('x2', x_offset)
            .attr('y1', this.y_offset).attr('y2', this.height - this.y_offset)
            .style('stroke', '#000000');

        var time = get_time_display(new Date(this.start_time + this.interval * i));

        this.container.append('text')
            .attr('x', x_offset - 15).attr('y', 10)
            .style('font-size', '10px')
            .style('fill', '#000000')
            .style('opacity', 1)
            .text(time);
    }
};

{'fraction_non_alphanumeric': 0.14891070146037827, 'fraction_numerical': 0.025855877423988507, 'mean_word_length': 2.5257383966244724, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 6, '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': '1367499', 'n_tokens_mistral': 1480, 'n_tokens_neox': 1361, 'n_words': 342}