<commit_before>document.forms['search-form'].onsubmit = function onSubmitSearch(event) {
    // Obtain the name of the stop the user is looking for
    var stopName = event.target.getElementsByClassName('item-input')[0].value;

    // Perform the search using the SDK
    Ruter.findPlace(stopName, 'Stop').then(onSearchSuccess, onSearchError);

    // Cancel the form submission
    event.stopPropagation();
    return false;
};

document.getElementById('add-places-button').onclick = function () {
    addSelectedPlacesToLocalStorage();
    //TODO Return to previous screen
};

/**
 * Callback invoked after the server has responded to the search query.
 *
 * @param resultSet Array of places (see PlaceInterface.ts in the Ruter SDK)
 */
function onSearchSuccess(resultSet) {
    var resultsNode = document.getElementById('search-results');

    // Clean the previous results, if any
    while (resultsNode.firstChild) {
        resultsNode.removeChild(resultsNode.firstChild);
    }

    // Populate the results
    resultSet.forEach(function populateItem(item) {
        resultsNode.appendChild(createListItem(item.Name, item.ID));
    });

    // Update the styles using Slate
    Zepto('.item-checkbox').itemCheckbox();
}

function onSearchError(error) {
    console.error(error);
}

/**
 * Takes the user's current selection and persists it into local storage.
 */
function addSelectedPlacesToLocalStorage() {
    var storedPlaces = [];
    if (localStorage.getItem('places') != null) {
        try {
            storedPlaces = JSON.parse(localStorage.getItem('places'));
        } catch (e) {
            console.warn('Could not read stored places, overwriting.', e);
        }
    }<commit_msg>Added more documentation to add_stop.js<commit_after>/**
 * Event listener for the "Search" button (submits the search form)
 */
document.forms['search-form'].onsubmit = function onSubmitSearch(event) {
    // Obtain the name of the stop the user is looking for
    var stopName = event.target.getElementsByClassName('item-input')[0].value;

    // Perform the search using the SDK
    Ruter.findPlace(stopName, 'Stop').then(onSearchSuccess, onSearchError);

    // Cancel the form submission
    event.stopPropagation();
    return false;
};

/**
 * Event listener for the "Add" button
 */
document.getElementById('add-places-button').onclick = function () {
    addSelectedPlacesToLocalStorage();
    //TODO Return to previous screen
};

/**
 * Callback invoked after the server has responded to the search query.
 *
 * @param {Array} resultSet Array of places (see PlaceInterface.ts in the Ruter SDK)
 */
function onSearchSuccess(resultSet) {
    var resultsNode = document.getElementById('search-results');

    // Clean the previous results, if any
    while (resultsNode.firstChild) {
        resultsNode.removeChild(resultsNode.firstChild);
    }

    // Populate the results
    resultSet.forEach(function populateItem(item) {
        resultsNode.appendChild(createListItem(item.Name, item.ID));
    });

    // Update the styles using Slate
    Zepto('.item-checkbox').itemCheckbox();
}

/**
 * Callback invoked when the search fails, either due to a bug or a failed API request.
 *
 * @param {string} error Error message.
 */
function onSearchError(error) {
    console.error(error);
}

/**
 * Takes the user's current selection and persists it into local storage.
 */
function addSelectedPlacesToLocalStorage() {
    var storedPlaces = [];
    if (localStorage.getItem('places') != null) {
        try {
            storedPlaces = JSON.parse(localStorage.getItem('places'));
        } catch (e) {
            console.warn('Could not read stored places, overwriting.', e);
        }
    }
{'fraction_non_alphanumeric': 0.11594594594594594, 'fraction_numerical': 0.0005405405405405405, 'mean_word_length': 3.411203814064362, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3554532', 'n_tokens_mistral': 1036, 'n_tokens_neox': 1017, 'n_words': 289}