screen.availHeight
let element = document.querySelector("Ваш элемент");
document.onscroll = () => {
let percent = ( screen.availHeight - window.pageYOffset / 2 ) / screen.availHeight;
if(percent <= 0) element.style.opacity = 0;
else element.style.opacity = percent;
console.log(percent);
};
exports.getPerson = function(id) {
return new Promise((resolve, reject) => {
// Любая асинхронная операция. Например:
sql.query(`select * from users where id='${id}'`, data => {
// Если запрос произошел успешно
resolve(data);
}, error => {
// Если с ошибкой
reject(error);
});
});
};
let {getPerson} = require("path/to/module");
let person = await getPerson('some id');
var i18n = module.exports = function (opt) {
...
if (opt.locales && opt.locales.forEach) {
this.locales = {};
opt.locales.forEach(function (locale) {
self.readFile(locale);
});
}
...
}
i18n.prototype = {
...
readFile: function (locale) {
var file = this.locateFile(locale);
...
try {
var localeFile = fs.readFileSync(file);
...
},
...
}
const checkArrayForInteger = data => {
if(data.length < 1) return false;
let result = true;
data.forEach(num => {
if((num ^ 0) !== num) {
result = false;
return false;
}
});
return result;
};
const checkArrayForInteger = data => data.length > 1 ? _.every(data, num => _.isInteger(num)) : false;
navigator.geolocation.getCurrentPosition(
function(position) {
// success function
},
function(error) {
// error function
// Посмотреть какая ошибка
console.log(error);
});
PositionError("User denied Geolocation")
<form>
<p><input type="checkbox" data-name="chbx" value="first">first</p>
<p><input type="checkbox" data-name="chbx" value="second">second</p>
<p><input type="checkbox" data-name="chbx" value="third">third</p>
<p><input type="checkbox" data-name="chbx" value="fourth">fourth</p>
<p><input type="checkbox" data-name="chbx" value="fifth">fifth</p>
<input type="hidden" name="chbx">
<button onclick="myFilter()" class="sbtn">Подобрать</button>
</form>
function myFilter() {
var arr = [];
document.querySelectorAll("input[data-name='chbx']:checked").forEach(input => arr.push(input.value));
document.querySelector("input[name='chbx']").value = arr.join();
}