var link = document.querySelector('селектор-ссылки');
link.href = link.href.split('?')[0] + '?active=' + active; // где active - id способа оплаты
var params = getParams();
if (params && params.active) {
var input = document.querySelector('#' + params.active); // если у инпутов есть соответствующие id
input.classList.add('active');
}
function getParams() {
var query = location.search.slice(1),
props = query.split('&'),
result = {};
props.forEach(function (prop) {
if (prop) {
var chunks = prop.split('=', 2),
key = chunks[0],
value = chunks[1];
result[key] = value ? decodeURIComponent(value) : true;
}
});
return Object.keys(result).length ? result : null;
}
var path = require('path');
var glob = require('glob');
var files = glob.sync('./app/src/views/**/*.js');
var dirs = getDirs(files);
var configs = [];
for (var dirname in dirs) {
var files = dirs[dirname];
configs.push({
entry: getEntries(files),
output: {
path: dirname.replace('app/src/views', 'build'),
filename: '[name].js'
}
});
}
module.exports = configs;
function getDirs(files) {
var dirs = {};
files.forEach(function (file) {
var dirname = path.dirname(file);
if (!dirs[dirname]) {
dirs[dirname] = [];
}
dirs[dirname].push(file);
});
return dirs;
}
function getEntries(files) {
var entries = {};
files.forEach(function (file) {
var name = path.basename(file, path.extname(file));
entries[name] = file;
});
return entries;
}
function fetchBlob(url, callbacks) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'blob';
if (callbacks) {
for (var key in callbacks) {
if (key.indexOf('on') === 0) {
xhr[key] = callbacks[key];
}
}
}
xhr.send();
}
fetchBlob('/path/to/image.jpg', {
onprogress: function (event) {
console.log(Math.round(event.loaded / event.total * 100) + '%');
},
onload: function () {
$('.container').html('<img src="' + URL.createObjectURL(this.response) + '">');
}
});
dbAudit.getAllServers = function () {
return new Promise(function (resolve, reject) {
dbAudit.query('SELECT "FSDN" AS host, "Listen_Port" AS port, "Instance" AS "clusterName", "Version" AS version FROM "COLLECTE_POSTGRES"')
.then(function (clusters) {
var remotesPromises = clusters.map(function (cluster) {
var remote = new Sequelize('postgres', collector.user, collector.password, {
host: cluster.host,
port: cluster.port,
dialect: 'postgres',
logging: false
});
return getDatabases(remote);
});
Promise.all(remotesPromises).then(function (remotes) {
resolve(remotes);
});
}, reject);
});
};
function getDatabases(remote) {
return new Promise(function (resolve) {
remote.query("SELECT datname FROM pg_catalog.pg_database WHERE datname NOT IN ('template0','template1','postgres','repmgr')")
.then(function (databases) {
resolve({ status: 'success', databases: databases });
}, function (error) {
resolve({ status: 'error', error: error });
});
});
}
dbAudit.getAllServers = function () {
return dbAudit.query('SELECT "FSDN" AS host, "Listen_Port" AS port, "Instance" AS "clusterName", "Version" AS version FROM "COLLECTE_POSTGRES"')
.then(function (clusters) {
var remotesPromises = clusters.map(function (cluster) {
var remote = new Sequelize('postgres', collector.user, collector.password, {
host: cluster.host,
port: cluster.port,
dialect: 'postgres',
logging: false
});
return getDatabases(remote);
});
return Promise.all(remotesPromises);
});
};
function getDatabases(remote) {
return remote.query("SELECT datname FROM pg_catalog.pg_database WHERE datname NOT IN ('template0','template1','postgres','repmgr')")
.then(function (databases) {
return { status: 'success', databases: databases };
}, function (error) {
return { status: 'error', error: error };
});
}
console.log('objC.pr.toString()= ' + Object.getOwnPropertyDescriptor(objC, 'pr').get.toString());
<script src="libs/plugins-scroll/plugins-scroll.js"></script>
event.preventDefault();
на onmousewheel, и это косвенно влияет на возможность масштабирования. var request = require('request');
fetchData('site.com').then(function (data) {
console.log(data);
});
function fetchData(url) {
return fetch({ method: 'GET', url: url }).then(function (body) {
var link = findLink(body);
return link ? fetchData(link) : body;
});
}
function fetch(options) {
return new Promise((resolve, reject) => {
request(options, (error, response, body) => {
if (error) {
reject(error);
} else {
resolve(body);
}
});
});
}
function findLink(body) {
// return parsed link or null
}
function createChess(x, y) {
for (var i = 0; i < y; i++) {
var string = '', a, b;
if (i % 2) {
a = '#';
b = ' ';
} else {
a = ' ';
b = '#';
}
for (var j = 0; j < x; j++) {
if (j % 2) {
string += a;
} else {
string += b;
}
}
console.log(string);
}
}
function createChess(x, y) {
for (var i = 0; i < y; i++) console.log((i % 2 ? ' #' : '# ').repeat(Math.floor(x / 2) + 1).slice(0, x % 2 - 2));
}
var path = require('path'),
gulp = require('gulp'),
sass = require('gulp-sass'),
rename = require('gulp-rename');
gulp.task('sass', function () {
return gulp.src('**/sass/*.scss')
.pipe(sass())
.pipe(rename(function (filePath) {
filePath.dirname = path.join(filePath.dirname, '../css/');
return filePath;
}))
.pipe(gulp.dest('./'));
});
$('textarea').on('keydown', function (event) {
if (event.which === 13 && event.ctrlKey) {
event.preventDefault();
// здесь код отправки
}
});