<commit_before>var spot_seeker_map, spot_seeker_infowindow, spot_seeker_marker_ids = {}, spot_seeker_markers = [];

function openInfoWindow(marker, info) {
    if (!window.spot_seeker_infowindow) {
        window.spot_seeker_infowindow = $("#info_list");
    }

    window.spot_seeker_infowindow.html(["<h1>", info.name, "</h1><div>This is the content window about the space.  Here's some info: <ul><li>Hours available: ", info.display_hours_available, "</li><li>Capacity: ", info.capacity, "</li></ul></div><div><a href='/spot/"+info.id+"'>View more</a></div>"].join(""));
    //window.spot_seeker_infowindow.open(window.spot_seeker_map, marker);
}

function addMarkerListener(marker, data) {
    google.maps.event.addListener(marker, 'click', function() {
        openInfoWindow(marker, data);
    });

}

/* function run_custom_search() {
    // Clear the map
    for (var i = 0; i < window.spot_seeker_markers.length; i++) {
        window.spot_seeker_markers[i].setMap(null);
    }
    window.spot_seeker_markers = [];
    window.spot_seeker_marker_ids = {};

    // Set the search values, so they'll stick through zooms and pans
    window.spot_seeker_search_options = {};
    window.spot_seeker_search_options["name"] = $("#spot_name").val();

    // Run the search
    fetch_data();
    $("#dialog-modal").dialog("close");
} */

function initialize() {
    var i;

    /*$("#cancel_custom_search").click(function() {
        $( "#dialog-modal" ).dialog("close");
    });

    $("#custom_search").click(function() {
        $( "#dialog-modal" ).dialog({
            height: 340,
            width: 500,
            modal: true
        });
    });

    $("#run_custom_search").click(run_custom_search);*/

    window.spot_seeker_search_options = {};

    if (navigator.geolocation) {
        // Doing a timeout here, to make sure we load something...
        window.position_timeout = window.setTimeout(function() {
            load_map(window.default_latitude, window.default_longitude, window.default_zoom);
        }, 5000);

        navigator.geolocation.getCurrentPosition(
            // Success...
            function(position) {
                window.clearTimeout(window.position_timeout);
                load_map(position.coords.latitude, position.coords.longitude, window.default_zoom);
            }
        );
    }
    else {
        load_map(window.default_latitude, window.default_longitude, window.default_zoom);
    }

}

function load_map(latitude, longitude, zoom) {
    var myOptions = {
        center: new google.maps.LatLng(latitude, longitude),
        zoom: zoom,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    window.spot_seeker_map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    google.maps.event.addListener(window.spot_seeker_map, 'idle', reload_on_idle);
}

function display_search_results(data) {
    var mcOpts = {zoomOnClick: false};
    var mc = new MarkerClusterer(spot_seeker_map, [], mcOpts);
    for (i = 0; i < data.length; i++) {
        if (!window.spot_seeker_marker_ids[data[i].id]) {
            marker = new google.maps.Marker({
                position: new google.maps.LatLng(data[i].location.latitude, data[i].location.longitude),
                title: data[i].name
            });

            //marker.setMap(window.spot_seeker_map);
            mc.addMarker(marker);
            addMarkerListener(marker, data[i]);

            window.spot_seeker_marker_ids[data[i].id] = true;
            window.spot_seeker_markers.push(marker);
        }
    }
}

function load_data(data) {
    display_search_results(data);
}

function reload_on_idle() {
    fetch_data();
}

function fetch_data() {
    var args = window.spot_seeker_search_options;
    if (!args) {
        args = {};
    }

    var display_bounds = window.spot_seeker_map.getBounds();
    var ne = display_bounds.getNorthEast();
    var sw = display_bounds.getSouthWest();<commit_msg>Load a list of the spots into the infowindow if a cluster is clicked.<commit_after>var spot_seeker_map, spot_seeker_infowindow, spot_seeker_marker_ids = {}, spot_seeker_markers = [];
var mc = null;

function openInfoWindow(marker, info) {
    window.spot_seeker_infowindow = $("#info_list");

    window.spot_seeker_infowindow.html(["<h1>", info.name, "</h1><div>This is the content window about the space.  Here's some info: <ul><li>Hours available: ", info.display_hours_available, "</li><li>Capacity: ", info.capacity, "</li></ul></div><div><a href='/spot/"+info.id+"'>View more</a></div>"].join(""));
    //window.spot_seeker_infowindow.open(window.spot_seeker_map, marker);
}

function addMarkerListener(marker, data) {
    google.maps.event.addListener(marker, 'click', function() {
        openInfoWindow(marker, data);
    });

}

function openClusterInfoWindow(cluster) {
    window.spot_seeker_infowindow = $("#info_list");
    infohtml = "<ul>";
    for (i = 0; i < cluster.getMarkers().length; i++) {
        mark = cluster.getMarkers()[i];
        infohtml += "<li>" + mark.title + "</li>";
    }
    infohtml += "</ul>";
    
    window.spot_seeker_infowindow.html(infohtml);
}

function addClusterListener(markerCluster) {
    google.maps.event.addListener(markerCluster, 'click', function(c) {
        openClusterInfoWindow(c);
    });

}

/* function run_custom_search() {
    // Clear the map
    for (var i = 0; i < window.spot_seeker_markers.length; i++) {
        window.spot_seeker_markers[i].setMap(null);
    }
    window.spot_seeker_markers = [];
    window.spot_seeker_marker_ids = {};

    // Set the search values, so they'll stick through zooms and pans
    window.spot_seeker_search_options = {};
    window.spot_seeker_search_options["name"] = $("#spot_name").val();

    // Run the search
    fetch_data();
    $("#dialog-modal").dialog("close");
} */

function initialize() {
    var i;

    /*$("#cancel_custom_search").click(function() {
        $( "#dialog-modal" ).dialog("close");
    });

    $("#custom_search").click(function() {
        $( "#dialog-modal" ).dialog({
            height: 340,
            width: 500,
            modal: true
        });
    });

    $("#run_custom_search").click(run_custom_search);*/

    window.spot_seeker_search_options = {};

    if (navigator.geolocation) {
        // Doing a timeout here, to make sure we load something...
        window.position_timeout = window.setTimeout(function() {
            load_map(window.default_latitude, window.default_longitude, window.default_zoom);
        }, 5000);

        navigator.geolocation.getCurrentPosition(
            // Success...
            function(position) {
                window.clearTimeout(window.position_timeout);
                load_map(position.coords.latitude, position.coords.longitude, window.default_zoom);
            }
        );
    }
    else {
        load_map(window.default_latitude, window.default_longitude, window.default_zoom);
    }

}

function load_map(latitude, longitude, zoom) {
    var myOptions = {
        center: new google.maps.LatLng(latitude, longitude),
        zoom: zoom,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    window.spot_seeker_map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    google.maps.event.addListener(window.spot_seeker_map, 'idle', reload_on_idle);
}

function display_search_results(data) {
    var mcOpts = {zoomOnClick: false};
    mc = new MarkerClusterer(spot_seeker_map, [], mcOpts);
    for (i = 0; i < data.length; i++) {
        if (!window.spot_seeker_marker_ids[data[i].id]) {
            marker = new google.maps.Marker({
                position: new google.maps.LatLng(data[i].location.latitude, data[i].location.longitude),
                title: data[i].name
            });

            //marker.setMap(window.spot_seeker_map);
            mc.addMarker(marker);
            addMarkerListener(marker, data[i]);

            window.spot_seeker_marker_ids[data[i].id] = true;
            window.spot_seeker_markers.push(marker);
        }
    }
    addClusterListener(mc);
}

function load_data(data) {
    display_search_results(data);
}

function reload_on_idle() {
    fetch_data();
}

function fetch_data() {
    var args = window.spot_seeker_search_options;
    if (!args) {
        args = {};
    }

    var display_bounds = window.spot_seeker_map.getBounds();
    var ne = display_bounds.getNorthEast();
    var sw = display_bounds.getSouthWest();
{'fraction_non_alphanumeric': 0.14449704142011835, 'fraction_numerical': 0.0034319526627218937, 'mean_word_length': 3.0090132827324476, 'pattern_counts': {'":': 0, '<': 40, '<?xml version=': 0, '>': 35, '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': '767041', 'n_tokens_mistral': 2719, 'n_tokens_neox': 2658, 'n_words': 446}