const priceVariants = [
{
servers: ['na', 'oce', 'las', 'lan', 'br', 'jp'],
priceTiers: [2.9, 1.8, 1.8, 2.8, 3.6, 4.3, 6, 9, 10, 11]
},
{
servers: ['other'],
priceTiers: [2, 1.5, 1.65, 2, 2.5, 3, 4.5, 7, 8, 9]
},
];
const defaultPrice = 1000;
const pricePerGame = priceVariants.find(variant => variant.servers.includes(server))?.priceTiers[current_tier_num] ?? defaultPrice;
const sumForm = document.forms.Sum;
const totalBlock = document.querySelector('#sum');
const baseValue = 500;
sumForm.addEventListener('change', () => {
const checkedImputValues = Array.from(
document.querySelectorAll('.form-check-input:checked'),
input => Number(input.value)
);
const servicesSum = (checkedImputValues.length !== 0)
? checkedImputValues.reduce((a, b) => a + b)
: 0;
totalBlock.textContent = servicesSum + baseValue;
});
'url(' + (img ? img : superImg) + ')'
`url('${img ? img : superImg}')`
const matchIndex = str.search(/((.+)?[;,!?"':”“]\n){3}/);
const newStr = str.slice((matchIndex > 0) ? matchIndex : 0);
const descriptionTextFunctions = (function () {
const getElements = () => {
const dtTable = document.querySelector('.description_text');
const dtMax = document.querySelector('.description_text-maximize-icon');
const dtMin = document.querySelector('.description_text-minimize-icon');
return [dtTable, dtMax, dtMin];
}
const expand = () => {
const [dtTable, dtMax, dtMin] = getElements();
dtMax.addEventListener('click', function () {
dtTable.classList.remove('description_collapse');
dtMax.classList.add('icon-hidden');
dtMin.classList.remove('icon-hidden');
})
}
const collapse = () => {
const [dtTable, dtMax, dtMin] = getElements();
...
document.querySelector('.calculator-block-btn').addEventListener('click', calculateThis);
function calculateThis() {
const inputs = [...document.querySelectorAll('.calculator-value')];
const getNumValue = (inputName) => Number(document.querySelector(`#${inputName}`).value);
const [heightValue, widthValue, lengthValue, amountValue] = ['height', 'width', 'length', 'amount'].map(name => getNumValue(name));
inputs.forEach((input) => input.classList.toggle('empty', !Number(input.value)));
const isInvalidAmounts = inputs.some(input => input.classList.contains('empty'));
const payment = () => (1 / ((widthValue * heightValue * lengthValue) / 1000000000)) * amountValue;
const surfaceArea = () => ((heightValue * widthValue * 2) + (heightValue * lengthValue * 2) + (widthValue * lengthValue * 2)) / 1000000 * amountValue;
document.getElementById('result').innerHTML = isInvalidAmounts ? 'Введите значения' : payment().toFixed(3) + ' шт. бруса';
document.getElementById('surface-area').innerHTML = isInvalidAmounts ? 'Введите значения' : surfaceArea().toFixed(1) + ' общая площадь, м²';
}
target.closest('a')
const tabstov = document.querySelectorAll(".tabstovnl");
const blocks = document.querySelectorAll(".tabstovb");
const tabClickHandler = ({ target }) => {
const targetTab = target.closest('a');
const block = document.querySelector(`${targetTab.getAttribute('href')}`);
const isTargetNotActive = !targetTab.classList.contains('tabstovnl--active');
if (isTargetNotActive) {
tabstov.forEach(tab => tab.classList.remove("tabstovnl--active"));
blocks.forEach(block => block.classList.remove("tabstovb--active"));
}
targetTab.classList.toggle("tabstovnl--active", isTargetNotActive);
block.classList.toggle("tabstovb--active", isTargetNotActive);
}
tabstov.forEach(tab => tab.addEventListener("click", tabClickHandler));
libs/bootstrap-reboot.min.css
margin-top
у списка ul
. Из-за которого и возникает эта неровность.margin-top: 0
в .navbar-menu
Do not allocate extra space for another array. You must do this by modifying the input array in-place with O(1) extra memory.
console.log()
ничего не возвращает, поэтому в следующий then()
передаётся undefined .then(response => {
console.log(response);
return response;
})
или.then(response => (console.log(response), response))