Skip to content

Commit

Permalink
update SkillfactoryCoding#10 add new buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
cookieru committed Feb 5, 2024
1 parent 1c9cce0 commit 8449413
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
4 changes: 2 additions & 2 deletions bjs/10_function_object/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ <h4>Отчество:<span id="fatherNameOutput">Генерация отчест
</div>
</div>
<div class="card-footer text-right">
<button class="btn btn-primary">Сгенерировать</button>
<button class="btn btn-primary">Очистить</button>
<button class="btn btn-primary" id="reloadBtn">Сгенерировать</button>
<button class="btn btn-primary" id="clearBtn">Очистить</button>
</div>
</div>
</div>
Expand Down
35 changes: 27 additions & 8 deletions bjs/10_function_object/init.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@

window.onload = function()
const load = function()
{
const initPerson = personGenerator.getPerson();
document.querySelector('#firstNameOutput').innerText = initPerson.firstName;
document.querySelector('#surnameOutput').innerText = initPerson.surName;
document.querySelector('#fatherNameOutput').innerText = initPerson.fathername;
document.querySelector('#genderOutput').innerText = initPerson.gender;
document.querySelector('#birthYearOutput').innerText = initPerson.birthday;
document.querySelector('#jobOutput').innerText = initPerson.job;

console.log(initPerson);

document.querySelector('#firstNameOutput').textContent = initPerson.firstName;
document.querySelector('#surnameOutput').textContent = initPerson.surName;
document.querySelector('#fatherNameOutput').textContent = initPerson.fathername;
document.querySelector('#genderOutput').textContent = initPerson.gender;
document.querySelector('#birthYearOutput').textContent = initPerson.birthday;
document.querySelector('#jobOutput').textContent = initPerson.job;
};

const clear = function()
{
document.querySelector('#firstNameOutput').textContent = "-";
document.querySelector('#surnameOutput').textContent = "-";
document.querySelector('#fatherNameOutput').textContent = "-";
document.querySelector('#genderOutput').textContent = "-";
document.querySelector('#birthYearOutput').textContent = "-";
document.querySelector('#jobOutput').textContent = "-";


};

addEventListener("load", load);

document.querySelector("#reloadBtn").addEventListener("click", load);

document.querySelector("#clearBtn").addEventListener("click", clear);

0 comments on commit 8449413

Please sign in to comment.