<commit_before>// Each function in this file corresponds to one visualization in the history
// page. Each function should be named the same as the id of the HTML element
// in history.html that links to the visualization, e.g. showHistory

// Shows a list of all visited websites
function showHistory(visits) {
    if (!visits) {
        var filter = {minTime: new Date().getTime() - 1 * 24 * 60 * 60 * 1000}
        var visits = getVisits(filter);
    }
    $("#results").append("<input id='search-text' type='text'/>");
    $("#results").append("<input id='search-submit' type='submit' value='Search'/><br/>");
    sortBy(visits, "time");
    visits.reverse();
    outputVisits(visits);

    $("#search-submit").click(function() {
        var text = $("#search-text").val();
        allVisits(function(visits) {
            $("#results").html("");;
            showHistory(visits);
        }, false, text);
    });
}

function renderUrlView(url) {
    $("#results").html("");

    var filter = {url: url};
    var visits = getVisits(filter);
    $("#results").append("<h2>" + url + "</h2>");
    $("#results").append("<div>You've visited this url " + visits.length + " times</div>");

    outputVisits(visits);
}

function renderDomainView(domain) {
    var d = new Date();
    var minDate = new Date(d.getFullYear(), d.getMonth(), d.getDate());
    var minTime = minDate.getTime();
    var maxTime = minTime + 86400*1000;
    var domains = new Array();
    domains.push(domain);

    var htmlString = '<div class="chart_title" style="margin-top:20px">Spotlight on <a href="javascript:void(0)">' + domain + '<\/a><\/div>';
    htmlString += "<div class='chart_heading'>Average Hourly Visits to " + domain + "</div>";
    htmlString += "<div id='chart'></div>";
    htmlString += "<div class='chart_heading' style='margin-top: 30px'>Visits for " + dateToStr(minDate);
    htmlString += "</div><div id='pings'></div>";

    $("#results").html(htmlString);

    renderAreaGraph('chart', domain, TimeScale.HOUR, true);
    renderPingsGraph('pings', minTime, maxTime, domains);

    $("#results").append("<br/>");
    outputVisits(getVisits({domain: domain}));
}

function renderDateView(date) {
    $("#results").html("");
    var left = "<img class='arrow' id='left' src='left-green.png' alt='Back one day'/>";
    var right = "<img class='arrow' id='right' src='right-green.png' alt='Back one day'/>";
    $("#results").append("<h2>Overview for " +  left + dateToStr(date) + right + "</h2>");
    $("#results").append("<div id='chart'></div>");
    $("#results").append("<div>Pages you visited on this day</div>");
    var start = getDayMin(date);
    var end = getDayMax(date);
    var filter = {
        minTime: start,
        maxTime: end
    }
    var visits = getVisits(filter);
    renderNumVisitsGraph(visits, 'chart', TimeScale.HOUR, true);
    outputVisits(visits);

    $("#left").click(function() {
        renderDateView(new Date(date.getTime() - 24 * 60 * 60 * 1000));<commit_msg>Don't allow user to select a date in the future<commit_after>// Each function in this file corresponds to one visualization in the history
// page. Each function should be named the same as the id of the HTML element
// in history.html that links to the visualization, e.g. showHistory

// Shows a list of all visited websites
function showHistory(visits) {
    if (!visits) {
        var filter = {minTime: new Date().getTime() - 1 * 24 * 60 * 60 * 1000}
        var visits = getVisits(filter);
    }
    $("#results").append("<input id='search-text' type='text'/>");
    $("#results").append("<input id='search-submit' type='submit' value='Search'/><br/>");
    sortBy(visits, "time");
    visits.reverse();
    outputVisits(visits);

    $("#search-submit").click(function() {
        var text = $("#search-text").val();
        allVisits(function(visits) {
            $("#results").html("");;
            showHistory(visits);
        }, false, text);
    });
}

function renderUrlView(url) {
    $("#results").html("");

    var filter = {url: url};
    var visits = getVisits(filter);
    $("#results").append("<h2>" + url + "</h2>");
    $("#results").append("<div>You've visited this url " + visits.length + " times</div>");

    outputVisits(visits);
}

function renderDomainView(domain) {
    var d = new Date();
    var minDate = new Date(d.getFullYear(), d.getMonth(), d.getDate());
    var minTime = minDate.getTime();
    var maxTime = minTime + 86400*1000;
    var domains = new Array();
    domains.push(domain);

    var htmlString = '<div class="chart_title" style="margin-top:20px">Spotlight on <a href="javascript:void(0)">' + domain + '<\/a><\/div>';
    htmlString += "<div class='chart_heading'>Average Hourly Visits to " + domain + "</div>";
    htmlString += "<div id='chart'></div>";
    htmlString += "<div class='chart_heading' style='margin-top: 30px'>Visits for " + dateToStr(minDate);
    htmlString += "</div><div id='pings'></div>";

    $("#results").html(htmlString);

    renderAreaGraph('chart', domain, TimeScale.HOUR, true);
    renderPingsGraph('pings', minTime, maxTime, domains);

    $("#results").append("<br/>");
    outputVisits(getVisits({domain: domain}));
}

function renderDateView(date) {
    $("#results").html("");
    var left = "<img class='arrow' id='left' src='left-green.png' alt='Back one day'/>";
    var right = "<img class='arrow' id='right' src='right-green.png' alt='Back one day'/>";
    if (date.getTime() + 24 * 60 * 60 * 1000 > new Date().getTime()) {
        right = "";
    }
    $("#results").append("<h2>Overview for " +  left + dateToStr(date) + right + "</h2>");


    $("#results").append("<div id='chart'></div>");
    $("#results").append("<div>Pages you visited on this day</div>");
    var start = getDayMin(date);
    var end = getDayMax(date);
    var filter = {
        minTime: start,
        maxTime: end
    }
    var visits = getVisits(filter);
    renderNumVisitsGraph(visits, 'chart', TimeScale.HOUR, true);
    outputVisits(visits);

    $("#left").click(function() {
        renderDateView(new Date(date.getTime() - 24 * 60 * 60 * 1000));
{'fraction_non_alphanumeric': 0.19630899885676956, 'fraction_numerical': 0.014372039849746856, 'mean_word_length': 3.563338301043219, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 60, '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': '4394844', 'n_tokens_mistral': 1981, 'n_tokens_neox': 1911, 'n_words': 477}