{"size": 1314, "ext": "js", "max_stars_repo_path": "public/js/index.js", "max_stars_repo_name": "Valdir2018/chatbot", "max_stars_repo_stars_event_min_datetime": "2021-12-19T15:34:08.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-26T23:05:13.000Z", "max_issues_repo_path": "public/js/index.js", "max_issues_repo_name": "Valdir2018/chatbot", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "public/js/index.js", "max_forks_repo_name": "Valdir2018/chatbot", "max_forks_repo_forks_event_min_datetime": "2021-12-19T15:34:09.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-19T15:34:09.000Z"}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 32.0487804878, "max_line_length": 83, "alphanum_fraction": 0.6407914764}
const buttonClick = document.querySelector('.button-cadastrar');
var currentKeyword = document.querySelector('#key');
var currentText = document.querySelector('#conteudo'); 

buttonClick.addEventListener('click', writeFromJson );

function writeFromJson(event) {
    event.preventDefault();
    const response = new XMLHttpRequest();

    let formData = {
         keyword_name: currentKeyword.value,
         text_context: currentText.value
    };
    

    let newObject = JSON.stringify(formData);
    response.open('POST', './source/DialogSave.php', true);
    response.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

    response.setRequestHeader("Cache-Control", "no-cache, no-store max-age=0");
    response.setRequestHeader("Expires", "Tue, 01 Jan 1980 1:00:00 GMT");
    response.setRequestHeader("Pragma", "no-cache");

    response.onreadystatechange = function() {
        if (response.readyState === 4 && response.status === 200) {
            console.log('request sucess, '+response.status);

            if (formData.keyword_name !== '' && formData.currentText !== '') {
                alert('Dados Salvo com sucesso !');
            }

            currentKeyword.value = '';
            currentText.value = '';
    
        }
    }
    response.send('data='+newObject);
}

