const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);
const expression = /[-–—]/g;
while (walker.nextNode()) {
const node = walker.currentNode;
if (expression.test(node.textContent)) {
node.textContent = node.textContent.replace(expression, '-');
}
}
$('#child').on('event', function(event){
event.stopPropagation(); // запрещает дальнейщую передачу события
// обработка события
});
$('<селектор шапки>').offset().top
function offset(el) {
var rect = el.getBoundingClientRect(),
scrollLeft = window.pageXOffset || document.documentElement.scrollLeft,
scrollTop = window.pageYOffset || document.documentElement.scrollTop;
return { top: rect.top + scrollTop, left: rect.left + scrollLeft }
}
function onClickClose(elem) { // вызвать в момент показа окна, где elem - окно
function outsideClickListener(event) {
if (!elem.contains(event.target) && isVisible(elem)) { // проверяем, что клик не по элементу и элемент виден
elem.style.display = 'none'; //скрыть
document.removeEventListener('click', outsideClickListener);
}
}
document.addEventListener('click', outsideClickListener)
}
function isVisible(elem) { //открыто ли условное окно
return !!elem && !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
}
const webpack = require('webpack')
const path = require('path')
const merge = require('webpack-merge')
module.exports = merge(require('./webpack.config'), {
devtool: 'source-map',
devServer: {
compress: false,
host: ''192.168.01.01',',//your ip adress"
port: 9000,
contentBase: path.resolve(__dirname, '../src')
}
})
// // development config
const merge = require('webpack-merge');
const webpack = require('webpack');
const commonConfig = require('./common');
module.exports = merge(commonConfig, {
entry: [
'react-hot-loader/patch', // activate HMR for React
'webpack-dev-server/client?http://localhost:8080',// bundle the client for webpack-dev-server and connect to the provided endpoint
'webpack/hot/only-dev-server', // bundle the client for hot reloading, only- means to only hot reload for successful updates
'./index.js' // the entry point of our app
],
devServer: {
hot: true, // enable HMR on the server
stats: {
assets: true,
children: false,
chunks: false,
hash: false,
modules: false,
publicPath: false,
timings: true,
version: false,
warnings: true,
optimizationBailout: true,
colors: {
green: '\u001b[32m',
}
}
},
devtool: 'cheap-module-eval-source-map',
plugins: [
new webpack.HotModuleReplacementPlugin(), // enable HMR globally
new webpack.NamedModulesPlugin(), // prints more readable module names in the browser console on HMR updates
],
});
const merge = require('webpack-merge');
const {resolve} = require('path');
const commonConfig = require('./common');
module.exports = merge(commonConfig, {
entry: './index.js',
devtool: 'source-map',
output: {
filename: 'bundle.min.js',
path: resolve(__dirname, '../../dist'),
publicPath: '/',
},
stats: {
assets: true,
children: false,
chunks: false,
hash: false,
modules: false,
publicPath: false,
timings: true,
version: false,
warnings: true,
optimizationBailout: true,
colors: {
green: '\u001b[32m',
}
},
plugins: [],
});
<meta property="og:title" content="">
<meta property="og:site_name" content="">
<meta property="og:url" content="">
<meta property="og:description" content="">
<meta property="og:image" content="">
npm - пакетный менеджер, нужен для установки пакетов вашего приложения
bower пакетный менеджер, для установки сторонних js библиотек. Также есть технические особенности того как он устанавливает пакеты.
const indexes = [2, 0, 1, 1, 1, 2];
/**
*
* @param {number} amount
* @param {string[]} cases For slavic languages: ['яблоко', 'яблока', 'яблок']
* @returns {string}
*/
function pluralize(amount, cases) {
const mod100 = amount % 100;
const mod10 = amount % 10;
const index = (mod100 > 4 && mod100 < 20) ? 2 : indexes[(mod10 < 5) ? mod10 : 5];
return cases[index];
}
background-attachment: fixed;