This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ставит запятые в числах | |
function numberWithCommas(x) { | |
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function checkEmail(email) { | |
const reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; | |
(!reg.test(email)) ? return false : return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<picture> | |
<source | |
media="(min-width: 1024px)" | |
srcset="opera-fullshot-1x.jpg 1x, | |
opera-fullshot-2x.jpg 2x, | |
opera-fullshot-3x.jpg 3x"> | |
<img | |
src="opera-closeup-1x.jpg" alt="The Oslo Opera House" | |
srcset="opera-closeup-2x.jpg 2x, | |
opera-closeup-3x.jpg 3x"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input | |
type="tel" | |
name="phone" | |
placeholder="Телефон" | |
pattern="[\+]\d{2}\s[\(]\d{3}[\)]\s\d{3}[\-]\d{2}[\-]\d{2}" | |
minlength="13" | |
maxlength="13" | |
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let lastScrollTop = 0; | |
function scrollDirection() { | |
const st = window.pageYOffset || document.documentElement.scrollTop; | |
if (st > lastScrollTop) { | |
// downscroll code | |
} else { | |
// upscroll code | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default arr => new Promise((resolve) => { | |
const imgs = []; | |
arr.forEach((path) => { | |
const img = new Image(); | |
img.onload = () => { | |
imgs.push(img); | |
if (imgs.length === arr.length) resolve(imgs); | |
}; | |
img.src = `../img/phone/phone_000${path}`; | |
}); |