This file contains hidden or 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
| (async () => { | |
| let nodes = document.getElementsByTagName('img'); | |
| for (let node of nodes) { | |
| await new Promise(res => { | |
| node.src = node.dataset.src; | |
| node.onload = () => res(); | |
| }) | |
| } | |
| })() |
This file contains hidden or 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
| // When the modal is shown, we want a fixed body | |
| document.body.style.position = 'fixed'; | |
| document.body.style.top = `-${window.scrollY}px`; | |
| // When the modal is hidden, we want to remain at the top of the scroll position | |
| const scrollY = document.body.style.top; | |
| document.body.style.position = ''; | |
| document.body.style.top = ''; | |
| window.scrollTo(0, parseInt(scrollY || '0') * -1); |
This file contains hidden or 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
| document.addEventListener("DOMContentLoaded", function() { | |
| var lazyloadImages; | |
| if ("IntersectionObserver" in window) { | |
| lazyloadImages = document.querySelectorAll(".lazy"); | |
| var imageObserver = new IntersectionObserver(function(entries, observer) { | |
| entries.forEach(function(entry) { | |
| if (entry.isIntersecting) { | |
| var image = entry.target; | |
| image.src = image.dataset.src; |
This file contains hidden or 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 memoizer(fun){ | |
| let cache = {} | |
| return function (n){ | |
| if (cache[n] != undefined ) { | |
| return cache[n] | |
| } else { | |
| let result = fun(n) | |
| cache[n] = result | |
| return result | |
| } |
This file contains hidden or 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 getScrollTop() { | |
| self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop); | |
| } |
This file contains hidden or 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 printText = (phrases, el, cb) => { | |
| let printPhrase = (phraseIndex) => { | |
| if (phraseIndex >= phrases.length) { | |
| cb(); | |
| return; | |
| } | |
| let phrase = texts[phraseIndex]; | |
| let phraseLength = phrase.length; | |
| let div = document.createElement('div'); |
This file contains hidden or 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 declOfNum(number, titles) { | |
| let cases = [2, 0, 1, 1, 1, 2]; | |
| return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ]; | |
| } |
This file contains hidden or 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
| // собираем все якоря; устанавливаем время анимации и количество кадров | |
| const anchors = [].slice.call(document.querySelectorAll('a[href*="#"]')), | |
| animationTime = 300, | |
| framesCount = 20; | |
| anchors.forEach(function(item) { | |
| // каждому якорю присваиваем обработчик события | |
| item.addEventListener('click', function(e) { | |
| // убираем стандартное поведение | |
| e.preventDefault(); |
This file contains hidden or 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
| <?php | |
| require_once '../vendor/autoload.php'; | |
| use \Twig\Environment; | |
| use \Twig\Loader\Filesystem; | |
| use \Twig\Extension\Debug; | |
| $loader = new Twig_Loader_Filesystem('./templates/'); | |
| $twig = new Twig_Environment($loader); |
This file contains hidden or 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
| // Возвращает случайное целое число между min (включительно) и max (не включая max) | |
| // Использование метода Math.round() даст вам неравномерное распределение! | |
| function getRandomInt(min, max) { | |
| return Math.floor(Math.random() * (max - min)) + min; | |
| } |