<commit_before>define(['leaflet', 'wq/locate', 'wq/map'],
function(L, locate, map) {

L.Icon.Default.imagePath = "/css/lib/images";

function main($elems) {
    simple($elems.filter('#simple-example'));
    locator($elems.filter('#locator-example'));
}

function simple($elems) {
    $elems.find('button').click(function() {
        locate.locate(success, error);
    });

    function success(evt) {
        var lat = evt.latlng.lat, lng = evt.latlng.lng;
        $elems.find('p').html("Location: " + lat + ", " + lng);
    }
    function error(evt) {
        $elems.find('p').html("Error retrieving location.");
    }
}

function locator($elems) {
    var m = L.map($elems.find('#loc-map')[0]).setView([45, -93.25], 8);
    var basemaps = map.createBaseMaps();
    basemaps['Street'].addTo(m);
    var fields = {
       'latitude': $elems.find('#loc-lat'),
       'longitude': $elems.find('#loc-long'),
       'accuracy': $elems.find('#loc-acc'),
       'toggle': $elems.find('input[name=mode]')
    }
    locate.Locator(m, fields);
}

return main;
<commit_msg>onupdate example<commit_after>define(['leaflet', 'wq/locate', 'wq/map'],
function(L, locate, map) {

L.Icon.Default.imagePath = "/css/lib/images";

function main($elems) {
    simple($elems.filter('#simple-example'));
    locator($elems.filter('#locator-example'));
}

function simple($elems) {
    $elems.find('button').click(function() {
        locate.locate(success, error);
    });

    function success(evt) {
        var lat = evt.latlng.lat, lng = evt.latlng.lng;
        $elems.find('p').html("Location: " + lat + ", " + lng);
    }
    function error(evt) {
        $elems.find('p').html("Error retrieving location.");
    }
}

function locator($elems) {
    var m = L.map($elems.find('#loc-map')[0]).setView([45, -93.25], 8);
    var basemaps = map.createBaseMaps();
    basemaps['Street'].addTo(m);
    var fields = {
       'latitude': $elems.find('#loc-lat'),
       'longitude': $elems.find('#loc-long'),
       'accuracy': $elems.find('#loc-acc'),
       'toggle': $elems.find('input[name=mode]')
    }
    var locator = locate.Locator(m, fields);
    locator.onupdate = function(loc, accuracy) {
        if (accuracy > 1000) {
            $elems.find('#loc-message').html(
                "Note: your location accuracy appears to be off by more than 1km."
            );
        } else {
            $elems.find('#loc-message').html("");
        }
    };
}

return main;

{'fraction_non_alphanumeric': 0.20644634842921256, 'fraction_numerical': 0.008567931456548347, 'mean_word_length': 2.961227786752827, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '1745892', 'n_tokens_mistral': 878, 'n_tokens_neox': 871, 'n_words': 138}