<commit_before>"use strict";

function query(pos) {
    let ul = document.querySelector('ul');
    ul.textContent = '';

    let month = form.elements['month'].value;

    let url = `/api/query?temp=${form.elements['temp'].value}&month=${month}`;
    if (pos) {
        url += `&latlong=${pos.latitude},${pos.longitude}`
    }
    fetch(url).then(response => response.json()).then(results => {
        document.body.classList.toggle('sonne-no-results', results.length === 0);
        for (let result of results) {
            console.log(result);
            let li = document.createElement('li');
            li.classList.add('list-group-item');
            li.appendChild(document.importNode(document.querySelector('#sonne-city-template').content, true));
            let a = li.querySelector('.sonne-city a');
            a.href = `https://www.google.com/maps/dir/Current+Location/${result.name}`;
            a.textContent = result.name;
            li.querySelector('.sonne-temp').textContent = `${result.temps[month]} °C`;
            if (result.dist) {
                li.querySelector('.sonne-dist').textContent = `${Math.round(result.dist)} km`;
            }
            ul.appendChild(li);
        }
    });
}

let form = document.querySelector('form');
form.addEventListener('submit', event => {
    event.preventDefault();
    navigator.geolocation.getCurrentPosition(pos => {
        query(pos.coords);
    }, e => {
        query();
    });<commit_msg>Show cities<commit_after>"use strict";

function query(pos) {
    let ul = document.querySelector('ul');
    ul.textContent = '';

    let month = form.elements['month'].value;

    let url = `/api/query?temp=${form.elements['temp'].value}&month=${month}`;
    if (pos) {
        url += `&latlong=${pos.latitude},${pos.longitude}`
    }
    fetch(url).then(response => response.json()).then(results => {
        document.body.classList.toggle('sonne-no-results', results.length === 0);
        for (let result of results) {
            console.log(result);
            let li = document.createElement('li');
            li.classList.add('list-group-item');
            li.appendChild(document.importNode(document.querySelector('#sonne-city-template').content, true));
            let a = li.querySelector('.sonne-city a');
            a.href = `https://www.google.com/maps/dir/Current+Location/${result.name}`;
            a.textContent = result.name;
            li.querySelector('.sonne-city small').textContent = result.country;
            li.querySelector('.sonne-temp').textContent = `${result.temps[month]} °C`;
            if (result.dist) {
                li.querySelector('.sonne-dist').textContent = `${Math.round(result.dist)} km`;
            }
            ul.appendChild(li);
        }
    });
}

let form = document.querySelector('form');
form.addEventListener('submit', event => {
    event.preventDefault();
    navigator.geolocation.getCurrentPosition(pos => {
        query(pos.coords);
    }, e => {
        query();
    });
{'fraction_non_alphanumeric': 0.17895086321381143, 'fraction_numerical': 0.0006640106241699867, 'mean_word_length': 2.5911799761620977, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '3465134', 'n_tokens_mistral': 873, 'n_tokens_neox': 889, 'n_words': 128}