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() { | |
| if (!Element.prototype.matches) { | |
| // определяем свойство | |
| Element.prototype.matches = Element.prototype.matchesSelector || | |
| Element.prototype.webkitMatchesSelector || | |
| Element.prototype.mozMatchesSelector || | |
| Element.prototype.msMatchesSelector; |
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
| <style> | |
| .object-fit img { | |
| object-fit: cover; | |
| width: 30%; | |
| height: 100px; | |
| } |
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
| // отложенная загрузка скриптов | |
| <script> | |
| window.addEventListener('load', function() { | |
| let element = document.createElement('script'); | |
| element.src = 'script.js'; | |
| document.body.appendChild(element); | |
| }); | |
| </script> |
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
| // Array.prototype.findIndex | |
| if (!Array.prototype.findIndex) { | |
| Array.prototype.findIndex = function(predicate) { | |
| if (this == null) { | |
| throw new TypeError('Array.prototype.findIndex called on null or undefined'); | |
| } | |
| if (typeof predicate !== 'function') { | |
| throw new TypeError('predicate must be a function'); | |
| } |
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
| //https://www.html5rocks.com/ru/tutorials/workers/basics/ | |
| var worker = new Worker('doWork.js'); | |
| worker.addEventListener('message', function(e) { | |
| console.log('Worker said: ', e.data); | |
| }, false); | |
| worker.postMessage('Hello World'); |
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 applyForVisa(document) { | |
| console.log("Обработка заявления..."); | |
| return new Promise( (resolve, reject) => { | |
| setTimeout(() => { | |
| Math.random() > 0.5? resolve({value: "visa"}) : reject("В визу отказано"); | |
| }, 1000); | |
| } ) | |
| } | |
| function getVisa(visa) { |
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
| http://milkywaydoor.ru/znania/web-stat/biblioteka-animate-css-primer/ |
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
| // install Babel | |
| npm install --save-dev gulp-babel@7 babel-core babel-preset-env |
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
| if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { | |
| // код для мобильных устройств | |
| } else { | |
| // код для обычных устройств | |
| } | |
| // Проверить есть ли поддержка touch евентов | |
| function is_touch_device() { |
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 setSelectionRange(input, selectionStart, selectionEnd) { // функция для постановки курсора | |
| if (input.setSelectionRange) { | |
| input.focus(); | |
| input.setSelectionRange(selectionStart, selectionEnd); | |
| } | |
| else if (input.createTextRange) { | |
| var range = input.createTextRange(); | |
| range.collapse(true); | |
| range.moveEnd('character', selectionEnd); | |
| range.moveStart('character', selectionStart); |
NewerOlder