<commit_before>//main.js
/*var flights = [[{dest: "Poland", price: "242", carrier: "Ryan Air"},
                    {dest: "Poland", price: "60", carrier: "British Airways"},
                    {dest: "Poland", price: "260", carrier: "Joe's Hardware"}],
            [ {dest: "Bristol", price: "160", carrier: "British Airways"},
                    {dest: "Bristol", price: "20", carrier: "Joe's Hardware"}]];
*/
var flights;
var keys = [];
var ready = false;
//get flight data
$.get( "/top_flights", function( data ) {
    flights = JSON.parse(data);
    populate_data();
});
$(document).ready( function () {

    $("#test").tooltip();
    $(".btn-modal").on("click", function () {
        //set modal to loading!
        if(ready) {
            reset_modal();
            $('#myModal').modal('toggle');
            //populate the modal here!!!
            populate_modal($(this).attr("location"));
        }
    });

});
function reset_modal() {
    //resets the modal to a loading screen
    $("#modalTitle").text("Loading...");
    $("#flight-data tr").remove();
    $("#flight-data").html("<tr><th>Date</th><th>Airline</th><th>Fly Now!</th></tr>");
}
function populate_modal(city_id) {
    //this gets all relevant data for the modal
    var data = flights[keys[city_id]];
    $("#modalTitle").text(data.name[0]+", "+data.name[1]+", "+data.name[2]);
    $("#flight-data tr:last").after(prepare_flight(data.cheapest_quote));
    data.quotes.forEach(function (entry) { 
        $("#flight-data tr:last").after(prepare_flight(entry)); 
    });
    $(".date-tooltip").tooltip();
}
function populate_data() {
    ready = true;
    for (var data in flights) {
        keys.push(data);
    }
    $("#Loading-Content").addClass("hidden");
    $("#first-location h1").html(flights[keys[0]].name[1] + "<br />&pound;"+flights[keys[0]].cheapest_quote.MinPrice);
    $("#first-location p").html("Go and see <em>"+flights[keys[0]].friends[0].name+"</em> in "+flights[keys[0]].name[1]+", "+flights[keys[0]].name[2]);
    $("#first-location button").attr("location", 0);
    $("#first-location").removeClass("hidden");
    $("#second-location h1").html(flights[keys[1]].name[1] + "<br />&pound;"+flights[keys[1]].cheapest_quote.MinPrice);
    $("#second-location p").html("You have <em>"+flights[keys[1]].friends.length+"</em> friends near "+flights[keys[1]].name[1]);
    $("#second-location button").attr("location", 1);
    $("#second-location").removeClass("hidden");
    $("#third-location h1").html(flights[keys[2]].name[1] + "<br />&pound;"+flights[keys[2]].cheapest_quote.MinPrice);
    $("#third-location p").html("Flights available to go and see <em>"+flights[keys[2]].friends[0].name+"</em> in "+flights[keys[2]].name[1]);
    $("#third-location button").attr("location", 2);
    $("#third-location").removeClass("hidden");
}
function prepare_flight(dest) {
    var date = moment(dest.OutboundLeg.DepartureDate).format('ll');
    var rel_date = moment(dest.OutboundLeg.DepartureDate).fromNow();
    //add a 'time until' event using .fromNow() as a tooltip
    var r = "<tr>";
    r += "<td class='date'><div class='date-tooltip' data-toggle='tooltip' data-placement='auto left' title='"+rel_date+"'>"+date+"</div></td>";
    r += "<td class='carrier'>"+dest.OutboundLeg.CarrierIds[0]+"</td>";
    r += "<td class='price'><button class='btn btn-success'>&pound;"+dest.MinPrice+"</button></td>";
    r += "</tr>";
    return r;
}<commit_msg>changing format so tooltip may work<commit_after>//main.js
/*var flights = [[{dest: "Poland", price: "242", carrier: "Ryan Air"},
                    {dest: "Poland", price: "60", carrier: "British Airways"},
                    {dest: "Poland", price: "260", carrier: "Joe's Hardware"}],
            [ {dest: "Bristol", price: "160", carrier: "British Airways"},
                    {dest: "Bristol", price: "20", carrier: "Joe's Hardware"}]];
*/
var flights;
var keys = [];
var ready = false;
//get flight data
$.get( "/top_flights", function( data ) {
    flights = JSON.parse(data);
    populate_data();
});
$(document).ready( function () {

    $("#test").tooltip();
    $(".btn-modal").on("click", function () {
        //set modal to loading!
        if(ready) {
            reset_modal();
            $('#myModal').modal('toggle');
            //populate the modal here!!!
            populate_modal($(this).attr("location"));
        }
    });

});
function reset_modal() {
    //resets the modal to a loading screen
    $("#modalTitle").text("Loading...");
    $("#flight-data tr").remove();
    $("#flight-data").html("<tr><th>Date</th><th>Airline</th><th>Fly Now!</th></tr>");
}
function populate_modal(city_id) {
    //this gets all relevant data for the modal
    var data = flights[keys[city_id]];
    $("#modalTitle").text(data.name[0]+", "+data.name[1]+", "+data.name[2]);
    $("#flight-data tr:last").after(prepare_flight(data.cheapest_quote));
    data.quotes.forEach(function (entry) { 
        $("#flight-data tr:last").after(prepare_flight(entry)); 
    });
    $(".date-tooltip").tooltip();
}
function populate_data() {
    ready = true;
    for (var data in flights) {
        keys.push(data);
    }
    $("#Loading-Content").addClass("hidden");
    $("#first-location h1").html(flights[keys[0]].name[1] + "<br />&pound;"+flights[keys[0]].cheapest_quote.MinPrice);
    $("#first-location p").html("Go and see <em>"+flights[keys[0]].friends[0].name+"</em> in "+flights[keys[0]].name[1]+", "+flights[keys[0]].name[2]);
    $("#first-location button").attr("location", 0);
    $("#first-location").removeClass("hidden");
    $("#second-location h1").html(flights[keys[1]].name[1] + "<br />&pound;"+flights[keys[1]].cheapest_quote.MinPrice);
    $("#second-location p").html("You have <em>"+flights[keys[1]].friends.length+"</em> friends near "+flights[keys[1]].name[1]);
    $("#second-location button").attr("location", 1);
    $("#second-location").removeClass("hidden");
    $("#third-location h1").html(flights[keys[2]].name[1] + "<br />&pound;"+flights[keys[2]].cheapest_quote.MinPrice);
    $("#third-location p").html("Flights available to go and see <em>"+flights[keys[2]].friends[0].name+"</em> in "+flights[keys[2]].name[1]);
    $("#third-location button").attr("location", 2);
    $("#third-location").removeClass("hidden");
}
function prepare_flight(dest) {
    var date = moment(dest.InboundLeg.DepartureDate).format('ll');
    var rel_date = moment(dest.InboundLeg.DepartureDate).fromNow();
    //add a 'time until' event using .fromNow() as a tooltip
    var r = "<tr>";
    r += "<td class='date'><div class='date-tooltip' data-toggle='tooltip' data-placement='auto left' title='"+rel_date+"'></div>"+date+"</td>";
    r += "<td class='carrier'>"+dest.InboundLeg.CarrierIds[0]+"</td>";
    r += "<td class='price'><button class='btn btn-success'>&pound;"+dest.MinPrice+"</button></td>";
    r += "</tr>";
    return r;
}
{'fraction_non_alphanumeric': 0.23771561095810986, 'fraction_numerical': 0.013045368894042614, 'mean_word_length': 3.8797736916548797, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 61, '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': '201113', 'n_tokens_mistral': 2329, 'n_tokens_neox': 2276, 'n_words': 425}