Skip to content

Instantly share code, notes, and snippets.

@icarofreire
Created June 19, 2024 15:16
Show Gist options
  • Save icarofreire/d36ff6a0240f598d9cd6044b98118d47 to your computer and use it in GitHub Desktop.
Save icarofreire/d36ff6a0240f598d9cd6044b98118d47 to your computer and use it in GitHub Desktop.
teste
<html>
<head>
<title>Test</title>
<style type=text/css>
.leftdivision
{
float: left;
}
.rightdivision
{
float: left;
background-color:gray
}
div {
padding : 5%;
color: black;
background-color: #808B96;
width: 30%;
border: solid black;
}
</style>
</head>
<body>
<div class="leftdivision">
<h1>Fernanda</h1>
<p id="fernanda">...</p>
</div>
<div class="rightdivision">
<h1>Insira sua resposta</h1>
<label for="lname">Resposta:</label><br>
<input type="text" id="resposta" name="resposta">
</div>
<div class="rightdivision">
<h1>Struct</h1>
<p id="final">...</p>
</div>
<script>
function incase(arr_words, arr_words_acc){
console.log( arr_words, arr_words_acc );
const result = arr_words.filter((word) => arr_words_acc.includes(word.toLowerCase()));
return (result !== null && result !== undefined && result.length > 0);
}
function retincase(arr_words, arr_words_acc){
const result = arr_words.filter((word) => arr_words_acc.includes(word.toLowerCase()));
if (result !== null && result !== undefined && result.length > 0){
return result;
}else{
return null;
}
}
const langs = [
'python',
'c',
'c++',
'java',
'c#',
'visual Basic .NET',
'javaScript',
'typeScript',
'assembly',
'php',
'r',
'go',
'visual basic',
'swift',
'delphi',
'pascal',
'ruby',
'perl',
'objective-c',
'rust',
'scratch',
'kotlin',
'julia',
'lua',
'fortran',
'cobol',
'lisp',
'scheme',
'ada',
'dart',
'scala',
'prolog',
'd',
'bash',
'powershell',
'haskell'
];
const days = [
'domingo',
'segunda',
'terça',
'quarta',
'quinta',
'sexta',
'sabado'
];
const questions = [
'Ola, me chamo Fernanda e sou a recrutadora responsavel pela vaga de desenvolvedor da Plaza.',
'Você possui disponibilidade para trabalho presencial?',
'Perfeito. Poderia me informar quantos anos de experiencia voce tem?',
'Qual a sua linguagem de programacao preferida?',
'Interessante, e voce estaria disposto a programar em ruby?',
'Tambem esta disposto a trabalhar presencial?',
'Vamos marcar uma entrevista sua com nosso time tecnico. Como esta a sua disponibilidade?',
'Perfeito, vou verificar os horarios com a nossa equipe e retorno em breve. Tenha um bom dia!',
];
const obj_res = {
years_of_experience:0,
favorite_programming_language:'',
willing_to_work_onsite:false,
willing_to_use_ruby:false,
interview_date:'',
};
const fernanda = document.getElementById("fernanda");
const textbox = document.getElementById("resposta");
const textbox_final = document.getElementById("final");
fernanda.innerText = questions[0] + '\n' + questions[1];
let indx_question = 1;
textbox.addEventListener("keypress", function onEvent(event) {
const valor = textbox.value;
const sev = (valor !== null && valor !== undefined && valor !== '');
if (event.key === "Enter" && sev) {
const arr_positivo = ['sim', 'tenho', 'possuo', 'aceito', 'concordo', 'confirmo'];
const split_value = valor.split(' ');
if(indx_question === 1 && incase(split_value, arr_positivo) ){
obj_res.willing_to_work_onsite = true;
}
let reg = valor.match(/[0-9]+/g);
if(indx_question === 2 && reg !== null ){
obj_res.years_of_experience = reg;
}
const arrLangs = retincase(split_value, langs);
if(indx_question === 3 && arrLangs !== null && arrLangs.length > 0 ){
obj_res.favorite_programming_language = arrLangs;
}
if(indx_question === 4 && incase(split_value, arr_positivo) ){
obj_res.willing_to_use_ruby = true;
}
if(indx_question === 5 && incase(split_value, arr_positivo) ){
obj_res.willing_to_work_onsite = true;
}
reg = valor.match(/[0-9]+/g);
if(indx_question === 6 && ( reg !== null || incase(split_value, days)) ){
obj_res.interview_date = valor;
}
if(indx_question < questions.length){
indx_question++;
fernanda.innerText = questions[indx_question];
textbox.value = '';
}else{ indx_question = 0; }
if(indx_question >= 7){
textbox_final.innerText =
'years of experience:' + obj_res.years_of_experience + '\n' +
'favorite programming language: ' + obj_res.favorite_programming_language + '\n' +
'willing to work onsite: ' + obj_res.willing_to_work_onsite + '\n' +
'willing to use ruby: ' + obj_res.willing_to_use_ruby + '\n' +
'interview date: ' + obj_res.interview_date + '\n';
console.log( obj_res );
}
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment