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 moList = [{id: 1, name: 'NameMO-1'}, {id: 2, name: 'NameMO-2'}, {id: 3, name: 'NameMO-3'}]; | |
let find = (() => { | |
let store = {}; | |
return (list, id, key = 'id') => { | |
if (store[id]) { | |
return store[id]; | |
} else { | |
let item = list.find(item => item[key] === id); |
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
const deepClone = obj => { | |
let clone = Object.assign({}, obj); | |
Object.keys(clone).forEach( | |
key => (clone[key] = typeof obj[key] === 'object' ? deepClone(obj[key]) : obj[key]) | |
); | |
return Array.isArray(obj) ? (clone.length = obj.length) && Array.from(clone) : clone; | |
}; |
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="text" oninput="this.style.width = (this.value.length + 1 ) * 8 + 'px'"> |
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 xPathToCss(xpath) { | |
return xpath | |
.replace(/\[(\d+?)\]/g, function(s,m1){ return '['+(m1-1)+']'; }) | |
.replace(/\/{2}/g, '') | |
.replace(/\/+/g, ' > ') | |
.replace(/@/g, '') | |
.replace(/\[(\d+)\]/g, ':eq($1)') | |
.replace(/^\s+/, ''); | |
} |
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 decodeHtmlEntity = (str) => { | |
return str.replace(/&#?x(.+?);/gi, (match, dec) => String.fromCharCode('0x' + dec)); | |
}; | |
// decodeHtmlEntity('БУ ХМАО-Югры МИАЦ') | |
// "БУ ХМАО-Югры МИАЦ" |
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 typographer( | |
string, | |
words = ['в', 'во', 'без', 'до', 'из', 'к', 'ко', 'на', 'по', 'о', 'от', 'при', 'с', 'у', 'не', 'за', 'над', 'для', 'об', 'под', 'про', 'и', 'а', 'но', 'да', 'или', 'ли', 'бы', 'то', 'что', 'как', 'я', 'он', 'мы', 'они', 'ни', 'же', 'вы', 'им'] | |
){ | |
if (!string && typeof string !== 'string') throw Error('can\'t find string'); | |
let pattern = new RegExp( words.map(w => ` ${w} `).join('|'), 'gi' ); | |
return string.replace(pattern, str => str.slice(0, -1) + ' ' ); | |
} | |
console.log( typographer('Экспериментаниум – идеальная площадка для проведения открытых уроков и интерактивных занятий') ); |
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
const detectDeviceType = () => | |
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) | |
? 'Mobile' | |
: 'Desktop'; | |
detectDeviceType(); // "Mobile" or "Desktop" |
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
$breakpoints: ( | |
"xs": 'max-width: 768px', | |
"sm": 'min-width: 768px', | |
"md": 'min-width: 992px', | |
"lg": 'min-width: 1200px', | |
"xlg": 'min-width: 1400px' | |
); | |
$gap: 15px; | |
$column: 12; |
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 getURLParameter = (name) => decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null; |