tofixed, умножение на 100 и деление. округление все это не подходит.
function resize() {
const el = document.getElementsByClassName('preloader-wrap')[0];
let scale = 0 < window.innerWidth - window.innerHeight
? window.innerWidth / 2200
: window.innerWidth / 800;
el.style.transform = 'translate(-50%, -50%) scale(' + scale + ')';
}
function animAdd(selector, className, timeout) {
const el = document.getElementsByClassName(selector)[0];
setTimeout(function () {
el.classList.add(className);
}, timeout);
}
function animRem(selector, className, timeout) {
const el = document.getElementsByClassName(selector)[0];
setTimeout(function () {
el.classList.remove(className);
}, timeout);
}
function getRandom() {
return 10 * Math.round((1500 * Math.random() + 500) / 10);
}
function animBannerAdd() {
animAdd('preloader-item1', 'active', getRandom());
animAdd('preloader-item2', 'active', getRandom());
animAdd('preloader-item3', 'active', getRandom());
animAdd('preloader-item4', 'active', getRandom());
animAdd('preloader-item5', 'active', getRandom());
animAdd('preloader-item6', 'active', getRandom());
animAdd('preloader-item7', 'active', getRandom());
animAdd('preloader-item8', 'active', getRandom());
animAdd('preloader-item9', 'active', getRandom());
animAdd('preloader-item10', 'active', getRandom());
animAdd('preloader-item11', 'active', getRandom());
animAdd('preloader-item12', 'active', getRandom());
animAdd('preloader-item13', 'active', getRandom());
animAdd('preloader-item14', 'active', getRandom());
animAdd('preloader-item15', 'active', getRandom());
animAdd('preloader-item16', 'active', getRandom());
animAdd('preloader-item17', 'active', getRandom());
animAdd('preloader-item18', 'active', getRandom());
animAdd('preloader-item19', 'active', getRandom());
animAdd('preloader-item20', 'active', getRandom());
animAdd('preloader-item21', 'active', getRandom());
animAdd('preloader-item22', 'active', getRandom());
animAdd('preloader-item23', 'active', getRandom());
animAdd('preloader-item24', 'active', getRandom());
animAdd('preloader-item25', 'active', getRandom());
animAdd('preloader-item26', 'active', getRandom());
animAdd('preloader-item27', 'active', getRandom());
animAdd('preloader-item28', 'active', getRandom());
animAdd('preloader-item29', 'active', getRandom());
animAdd('preloader-item30', 'active', getRandom());
animAdd('preloader-item31', 'active', getRandom());
animAdd('preloader-item32', 'active', getRandom());
}
function animBannerRem() {
animRem('preloader-item1', 'active', 0);
animRem('preloader-item2', 'active', 0);
animRem('preloader-item3', 'active', 0);
animRem('preloader-item4', 'active', 0);
animRem('preloader-item5', 'active', 0);
animRem('preloader-item6', 'active', 0);
animRem('preloader-item7', 'active', 0);
animRem('preloader-item8', 'active', 0);
animRem('preloader-item9', 'active', 0);
animRem('preloader-item10', 'active', 0);
animRem('preloader-item11', 'active', 0);
animRem('preloader-item12', 'active', 0);
animRem('preloader-item13', 'active', 0);
animRem('preloader-item14', 'active', 0);
animRem('preloader-item15', 'active', 0);
animRem('preloader-item16', 'active', 0);
animRem('preloader-item17', 'active', 0);
animRem('preloader-item18', 'active', 0);
animRem('preloader-item19', 'active', 0);
animRem('preloader-item20', 'active', 0);
animRem('preloader-item21', 'active', 0);
animRem('preloader-item22', 'active', 0);
animRem('preloader-item23', 'active', 0);
animRem('preloader-item24', 'active', 0);
animRem('preloader-item25', 'active', 0);
animRem('preloader-item26', 'active', 0);
animRem('preloader-item27', 'active', 0);
animRem('preloader-item28', 'active', 0);
animRem('preloader-item29', 'active', 0);
animRem('preloader-item30', 'active', 0);
animRem('preloader-item31', 'active', 0);
animRem('preloader-item32', 'active', 0);
}
document.addEventListener('DOMContentLoaded', function () {
resize();
});
window.onresize = function () {
resize();
};
console.log(getRandom());
animBannerAdd();
setInterval(function () {
animBannerRem();
}, 3000);
setInterval(function () {
animBannerAdd();
}, 3000);
<button class="minibutton aligh-items-center"
onmouseover="hoverb(this, '/img/blackheartFill.svg');"
onmouseout="hoverb(this, '/img/blackheart.svg');"
>
<img src="/img/blackheart.svg" alt="">
</button>
function hoverb(button, img) {
button.querySelector('img').setAttribute('src', img );
}
function getData() {
return new Promise(resolve => {
$.getJSON("https://www.cbr-xml-daily.ru/daily_json.js", function(data) {
const kyrs = Math.ceil(100 / data.Valute.KZT.Value * data.Valute.EUR.Value).toString().replace(/(\d)(?=(\d{3})+$)/g, '$1 ');
resolve(kurs);
});
})
}
function func1(kurs) {
console.log(kurs);
}
function func2(kurs) {
console.log(kurs);
}
async function go() {
const kurs = await getData();
$('#euro').html(kyrs);
func1(kurs);
func2(kurs);
}
go();
$input.val = args.value;
вообще непонятно, что вы собирались этим сделать./**
* @param {string} text Входная строка, номер карты
* @param {number} count Количество видимых цифр в конце
*/
function getHiddenCard(text, count = 4) {
if (text.length <= count) return text; // нечего скрывать звездами
const visibleDigits = text.slice(-count); // Четыре последние цифры
const stars = '*'.repeat(text.length - count); // Подсчет нужного кол-ва звезд
return stars + visibleDigits;
}
resumable.on('fileAdded', function (file) { // trigger when file picked
showProgress();
resumable.upload() // to actually start uploading.
});
button.addEventListener('click', ()=>{
showProgress();
resumable.upload() // to actually start uploading.
});
function update() {
const urlParams = new URLSearchParams(window.location.search);
const city = urlParams.get('location_location1');
const target = document.getElementById('locator_citi');
const cities = {
'arzamas' : 'Арзамас',
'abakan' : 'Абакан',
'almetevsk' : 'Альметьевск',
'angarsk' : 'Ангарск',
'armavir' : 'Армавир',
'artjom' : 'Артём',
'arhangelsk': 'Архангельск',
'astrahan' : 'Астрахань',
// ...
};
if (cities[city]) {
target.innerHTML = cities[city];
}
}
window.addEventListener('DOMContentLoaded', update);
document.querySelector('.jobsearch-onsubmit-apilocs')?.addEventListener('click', () => {
update();
});
function CLICK() {
let button = document.querySelectorAll('button');
if(button.length){
for (let i = 0; i < button.length; i++){
+ if (!button[i].classList.contains('ok'))
+ button[i].classList.add('ok');
button[i].addEventListener('click', function(EVENT){
console.log(1,button[i]);
});
+ }
}
}
}
CLICK();
function getCurrentOffset(s) {
return s.split(",", 2).map((n) => Number(n.replace(/\D/g, "")));
}
function right2_m() {
const box = document.getElementById("box");
let [left, top] = getCurrentOffset(box.style.transform);
box.style.transform = `translate(${left+30}px,${top}px)`;
}
function bottom2_m() {
const box = document.getElementById("box");
let [left, top] = getCurrentOffset(box.style.transform);
box.style.transform = `translate(${left}px,${top+30}px)`;
}
const els = [
["author", "Author - "],
["name", "Name"],
["currentTime", "00:00"],
["duration", "00:00"],
];
els.forEach(el => {
titleElement.appendChild(
create({
el: "span",
className: el[0],
text: el[1],
})
);
})
const els = [
{ el: "span", className: "author", text: "Author - " },
{ el: "span", className: "name", text: "Name" },
{ el: "span", className: "currentTime", text: "00:00" },
{ el: "span", className: "duration", text: "00:00" },
];
els.forEach( el => titleElement.appendChild( create(el) ) );
function renderTitle (d) {
return `
<div class="title">
<span class="currentTime">${d.time}</span>
<span class="author">${d.author}</span> –
<span class="name">${d.name}</span>
<span class="duration">${d.duration}</span>
</div>
`;
}
xxx.insertAdjacentHTML('beforeend', renderTitle({
author: 'Author - ',
name: 'Name',
time: '00:00',
duration: '00:00',
}));