Думал получить что-то вроде живой коллекции, которая содержит все li-элементы, которым еще не назначен класс js-hide и если таких элементов нет, скрывать блок. Что-то вроде getElementsWithoutClassName().
export const copyToClipboard = function (text, onComplete) {
if (navigator.clipboard) {
navigator.clipboard.writeText(text)
.then(() => {
if (typeof onComplete === 'function') onComplete();
})
.catch(err => {
console.warn('Copy fail', err);
});
} else {
let area = document.createElement('textarea');
document.body.appendChild(area);
area.value = text;
area.select();
document.execCommand('copy');
document.body.removeChild(area);
if (typeof onComplete === 'function') onComplete();
}
};
const element = document.querySelector('...');
copyToClipboard(element.innerText, () => {
alert('Copied to clipboard!' + '\n' + element.innerText);
});
Поэтому вопрос знатокам - стоит ли плотно тестить шило, если уже есть нормальное мыло?))
const с = `-n ${this.newAccount.account_name}`
+ ` -d ${this.newAccount.start_deposit}`
+ ` -c ${this.newAccount.client_name}`
+ ` -b ${this.newAccount.ib_account_number}`
+ ` -l ${this.newAccount.leverage}`
+ ` -e ${this.newAccount.description}`
+ ` -r ${this.newAccount.rebalance_model}`;
if (this.newAccount.model_settings !== "{}") {
this.objForPost = с
+ ` -m "${this.newAccount.model_settings}"`;
} else if (this.newAccount.target_weights !== "{}") {
this.objForPost = c
+ ` -s ${this.newAccount.selected_systems}`
+ ` -w "${this.newAccount.target_weights}"`;
} else if (this.newAccount.model_settings !== "{}"
&& this.newAccount.target_weights !== "{}"
) {
this.objForPost = с
+ ` -s ${this.newAccount.selected_systems}`
+ ` -w "${this.newAccount.target_weights}"`
+ ` -m "${this.newAccount.model_settings}"`;
}
let {
account_name,
start_deposit,
client_name,
ib_account_number,
leverage,
description,
rebalance_model,
model_settings,
selected_systems,
target_weights,
} = this.newAccount;
const с = `-n ${account_name}`
+ ` -d ${start_deposit}`
+ ` -c ${client_name}`
+ ` -b ${ib_account_number}`
+ ` -l ${leverage}`
+ ` -e ${description}`
+ ` -r ${rebalance_model}`;
if (model_settings !== "{}") {
this.objForPost = с + ` -m "${model_settings}"`;
} else if (target_weights !== "{}") {
this.objForPost = c + ` -s ${selected_systems} -w "${target_weights}"`;
} else if (model_settings !== "{}" && target_weights !== "{}") {
this.objForPost = с + ` -s ${selected_systems} -w "${target_weights}" -m "${model_settings}"`;
}
function styles() {
return src('app/sass/style.sсss') // Меняем расширение у файлов
.pipe(sass()) // Это препроцессор, настройки по умолчанию
// .pipe(concat('style.min.css')) // Это лишнее
.pipe(autoprefixer({ overrideBrowserslist: ['last 10 versions'], grid: true })) // Настройки браузеров лучше задавать через файл .browserlistrc
.pipe(cleancss( { level: { 1: { specialComments: 0 } }/* , format: 'beautify' */ } ))
.pipe(dest('app/css/'))
.pipe(browserSync.stream())
}
import path from 'path';
import fs from 'fs';
import gulp from 'gulp';
import sass from 'sass';
import browserSync from 'browser-sync';
import twig from 'gulp-twig';
import data from 'gulp-data';
import gulpSass from 'gulp-sass';
import sourcemaps from 'gulp-sourcemaps';
import autoprefixer from 'gulp-autoprefixer';
const sassCompiler = gulpSass(sass);
if (!process.env.NODE_ENV) process.env.NODE_ENV = 'production';
console.log('NODE_ENV: ', process.env.NODE_ENV);
const IS_PRODUCTION = process.env.NODE_ENV === 'production';
const bs = browserSync.create();
const __dirname = process.cwd();
const loadData = function () {
const dataPath = path.resolve(__dirname, 'src/templates/data/main.json');
let customData = {};
if (fs.existsSync(dataPath)) {
customData = JSON.parse(fs.readFileSync(dataPath, 'utf8'));
} else {
console.warn('Data file NOT FOUND: ' + dataPath);
}
return {
...customData,
};
};
export default function (done) {
gulp.series(
build,
gulp.parallel(
watch,
serve,
),
)(done);
}
export function build(done) {
gulp.parallel(
copy_scripts,
copy_images,
copy_fonts,
build_twig,
build_vendor_styles,
build_styles,
build_scripts,
)(done);
}
function serve() {
bs.init({
browser: ['chrome'],
server : {
baseDir: './dist',
},
});
}
function watch() {
gulp.watch(['./src/templates/**'], build_twig);
gulp.watch(['./src/scss/**'], build_styles);
gulp.watch(['./src/js/**'], build_scripts);
gulp.watch(['./src/img/**'], copy_images);
gulp.watch(['./src/fonts/**'], copy_fonts);
}
export function build_twig() {
console.log(path.resolve(__dirname, 'src/templates'));
return gulp.src('./src/templates/*.twig')
.pipe(data(loadData))
.pipe(twig({
base: path.resolve(__dirname, 'src/templates'),
}))
.pipe(gulp.dest('./dist'))
.on('end', function () {
bs.reload();
});
}
export function build_styles() {
return gulp.src('./src/scss/main.scss')
.pipe(sourcemaps.init())
.pipe(sassCompiler({
outputStyle: IS_PRODUCTION ? 'compressed' : 'expanded',
}).on('error', sassCompiler.logError))
.pipe(autoprefixer())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./dist/design/css'))
.pipe(bs.stream());
}
export function build_vendor_styles() {
return gulp.src('./src/scss/bootstrap.scss')
.pipe(sourcemaps.init())
.pipe(sassCompiler({
outputStyle: IS_PRODUCTION ? 'compressed' : 'expanded',
}).on('error', sassCompiler.logError))
.pipe(autoprefixer())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./dist/design/css'))
.pipe(bs.stream());
}
export function build_scripts() {
return gulp.src('./src/js/*.js')
.pipe(gulp.dest('./dist/design/js'))
.pipe(bs.stream());
}
export function copy_images() {
return gulp.src('./src/img/**/*.*')
.pipe(gulp.dest('./dist/design/img'))
.on('end', function () {
bs.reload();
});
}
export function copy_fonts() {
return gulp.src('./src/fonts/**/*.*')
.pipe(gulp.dest('./dist/design/fonts'))
.on('end', function () {
bs.reload();
});
}
export function copy_scripts() {
return gulp.src([
'node_modules/jquery/dist/jquery.min.js',
'node_modules/jquery/dist/jquery.min.map',
'node_modules/bootstrap/dist/js/bootstrap.min.js',
'node_modules/bootstrap/dist/js/bootstrap.min.js.map',
])
.pipe(gulp.dest('./dist/design/js'));
}
{
"private": true,
"type": "module",
"name": "site-ru",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "gulp default"
},
"author": "delphinpro <delphinpro@yandex.ru>",
"license": "MIT",
"dependencies": {
"@popperjs/core": "^2.9.3",
"bootstrap": "^5.1.0",
"jquery": "^3.6.0"
},
"devDependencies": {
"browser-sync": "^2.27.5",
"gulp": "^4.0.2",
"gulp-autoprefixer": "^8.0.0",
"gulp-data": "^1.3.1",
"gulp-sass": "^5.0.0",
"gulp-sourcemaps": "^3.0.0",
"gulp-twig": "^1.2.0",
"sass": "^1.38.2"
}
}