var chars = "123";
var passwordLength = 4;
var randomNumber = Math.floor(Math.random() * chars.length);
password += chars.substring(randomNumber, randomNumber + 1);
$('.entry__arrow--increment, .entry__arrow--decrement').click(function() {
const $this = $(this);
$this.closest('.entry__box').find('.entry__data').text(function(i, text) {
const { step, max, min } = this.dataset;
let newVal = +text + step * ($this.hasClass('entry__arrow--increment') ? 1 : -1);
if (newVal > max) {
newVal = min;
} else if (newVal < min) {
newVal = max;
}
return `${newVal}`.padStart(2, 0);
});
});
document.querySelector('.custom-select-wrapper').addEventListener('click', function() {
this.querySelector('.custom-select').classList.toggle('open');
})
for (const option of document.querySelectorAll(".custom-option")) {
option.addEventListener('click', function() {
if (!this.classList.contains('selected')) {
this.parentNode.querySelector('.custom-option.selected').classList.remove('selected');
this.classList.add('selected');
this.closest('.custom-select').querySelector('.custom-select__trigger span').textContent = this.textContent;
this.parentElement.previousElementSibling.style.backgroundImage = getComputedStyle(this).backgroundImage;
}
})
}
window.addEventListener('click', function(e) {
const select = document.querySelector('.custom-select');
if (!select.contains(e.target)) {
select.classList.remove('open');
}
});
const select = document.querySelector('.custom-select');
(function() {
let input = select.firstElementChild,
text = input.querySelector('span'),
options = select.lastElementChild;
select.addEventListener('click', function(ev) {
this.classList.toggle('open');
let el = ev.target;
if (el.classList.contains('custom-option')) {
options.querySelector('.selected').classList.remove('selected');
el.classList.toggle('selected');
text.textContent = el.textContent;
input.style.backgroundImage = getComputedStyle(el).backgroundImage;
}
});
})();
window.addEventListener('click', function(e) {
if (!select.contains(e.target)) {
select.classList.remove('open');
}
});