function initSlider() {
new Swiper('.swiper', {
loop: false,
sped: 2400,
navigation:{
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
pagination: {
el: '.swiper-pagination',
clickable: true
},
breakpoints: {
// when window width is >= 320px
320: {
slidesPerView: 2,
spaceBetween: 20
},
// when window width is >= 480px
480: {
slidesPerView: 2,
spaceBetween: 30
},
// when window width is >= 1920px
1920: {
slidesPerView: 1,
spaceBetween: 60,
autoplay:false,
}
}
});
}
function detectDevice() {
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)){
// true for mobile device
initSlider();
}else{
// false for not mobile device
}
}
detectDevice();
let login = document.getElementById("login");
let password = document.getElementById("password");
let email = document.getElementById("email");
const vLogin = /^[a-zA-Z]{4,16}$/;
const vEmail = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
const vPassword = /^[a-zA-Z0-9]{8,15}$/;
let button = document.getElementById("button");
let usersArray = [];
function addUser(array) {
vLogin.test(login.value);
vEmail.test(email.value);
vPassword.test(password.value);
const user = {
login: login.value,
email: password.value,
password: email.value,
}
array.push(user)
login.value = '';
email.value = '';
password.value = '';
}
function saveUsers() {
addUser(usersArray)
console.log(usersArray)
}
button.addEventListener('click', saveUsers)
display: flex
align-items: center
justify-content: center
document.body.style.overflow = 'hidden'
document.body.style.overflow = 'auto'
const body = document.body
//open modal
body.style.overflow = 'hidden'
//close modal
body.style.overflow = 'auto'
<a href="https://vk.com" target="_blank" onclick="popUp()">
<header>55</header>
</a>
<script>
function popUp() {
setTimeout("window.location.href='https://google.com'", 3000)
}
</script>
window.addEventListener('DOMContentLoaded', () => {
const buttons = document.querySelectorAll('.btn')
let newValues = ['2', '567', 'Т333', 'csdf', 'sdfdsggg', 'ertretret']
for (let i =0; i < buttons.length; i++) {
buttons[i].addEventListener('click', () => {
buttons.forEach((item, i) => {
item.setAttribute('value', newValues[i])
})
console.log(buttons[i].getAttribute('value'))
})
}
})
window.addEventListener('DOMContentLoaded', () => {
const buttons = document.querySelectorAll('.btn')
const rowSelector = document.querySelector('.block__row')
let newValues = ['2', '567', 'Т333', 'csdf', 'sdfdsggg', 'ertretret']
function changeValue(btn, newArr) {
for (let i = 0; i < btn.length; i++) {
btn[i].setAttribute('value', newArr[i])
}
}
function consoleOutput(parentSelector) {
parentSelector.addEventListener('click', (e) => {
if (!e.target.matches('input')) return
changeValue(buttons, newValues)
console.log(e.target.getAttribute('value'))
})
}
consoleOutput(rowSelector)
})
modal.addEventListener('click', (e) => {
if (e.target === modal || e.target.getAttribute('data-close') == '') {
closeModal()
}
})
const anchors = document.querySelectorAll('a[href*="#"]')
for (let anchor of anchors) {
anchor.addEventListener('click', (e)=> {
e.preventDefault()
const blockID = anchor.getAttribute('href').substr(1)
document.getElementById(blockID).scrollIntoView({
behavior: 'smooth',
block: 'start'
})
})
}
const gulp = require('gulp');
const ghPages = require('gulp-gh-pages');
gulp.task('deploy', function() {
return gulp.src('./dist/**/*')
.pipe(ghPages());
});
document.addEventListener("DOMContentLoaded", () => {
const menu = document.getElementById('dropdown')
menu.addEventListener('click', () => {
const el = document.getElementById('dropdownNav');
el.style.display === 'none' ? el.style.display = 'block' : el.style.display = 'none';
})
});