<commit_before>/*****************************************************************************/
/*                          Main JS for whileaway                            */
/*****************************************************************************/

$(document).ready(function(){
    $('#form').on('submit', function(e){
        e.preventDefault();

        amount = $('#number').val();
        scope = $('#date option:selected').val();
        keyword = $('#keyword option:selected').val();

        try {
            validate(amount, scope, keyword);
        } catch (e) {
            alert(e);
            return;
        }

        // function getNews from get.js
        response = getNews(amount, scope, keyword);

        //test
        test(response);
    });
});

function test(response){
    str = '<ul>';
    for (var i = 0; i < response[0].length; i++) {
        str += '<li>' + response[0][i] + ': <a href="' + response[1][i] + '">' + response[1][i] + '</a></li>';
    };
    str += '</ul>'
    $('#test').html(str);
}

function validate(amount, scope, keyword) {
    scopes = ['days', 'weeks', 'months'];
    if (scopes.indexOf(scope) < 0) {
        throw 'Invalid scope';
    }
<commit_msg>News keyword<commit_after>/*****************************************************************************/
/*                          Main JS for whileaway                            */
/*****************************************************************************/

$(document).ready(function(){
    $('#form').on('submit', function(e){
        e.preventDefault();

        amount = $('#number').val();
        scope = $('#date option:selected').val();
        keyword = $('#keyword option:selected').val();
        if (keyword == 'news') {
            keyword = '';
        };

        try {
            validate(amount, scope, keyword);
        } catch (e) {
            alert(e);
            return;
        }

        // function getNews from get.js
        response = getNews(amount, scope, keyword);

        //test
        test(response);
    });
});

function test(response){
    str = '<ul>';
    for (var i = 0; i < response[0].length; i++) {
        str += '<li>' + response[0][i] + ': <a href="' + response[1][i] + '">' + response[1][i] + '</a></li>';
    };
    str += '</ul>'
    $('#test').html(str);
}

function validate(amount, scope, keyword) {
    scopes = ['days', 'weeks', 'months'];
    if (scopes.indexOf(scope) < 0) {
        throw 'Invalid scope';
    }

{'fraction_non_alphanumeric': 0.30469690887193895, 'fraction_numerical': 0.004817342432757929, 'mean_word_length': 2.215483870967742, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 15, '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': '471274', 'n_tokens_mistral': 678, 'n_tokens_neox': 647, 'n_words': 147}