const sortByLevel = ()=>{
document.querySelectorAll('.card .level').forEach(item=>{
item.style.display = cardLevels.includes(item.textContent)?'block':'none';
});
};
function getTimer() {
let now = new Date();
var d = new Date();
d.setHours(9);
d.setMinutes(0);
d.setSeconds(0);
d.setDate(d.getDate()+1);
let diff = (d.getTime()-now.getTime())/1000;
let days = Math.floor(diff/(60*60*24));
diff%=60*60*24;
let hours = Math.floor(diff/(60*60));
diff%=60*60;
let min = Math.floor(diff/60);
diff%=60;
diff = Math.floor(diff);
return `${hours}:${min}:${diff}`;
}
(function(){
document.querySelector("#timer").innerHTML = getTimer();
setTimeout(arguments.callee,1000);
})();
let arr =[
{ name: "Sasha", apple: 8, banana: 6, cherry: 9 },
{ name: "Artur", apple: 4, banana: 2, cherry: 1 },
{ name: "Sasha", apple: 5, banana: 7, cherry: 3 },
{ name: "Bogdan", apple: 6, banana: 11, cherry: 8 },
{ name: "Artur", apple: 8, banana: 6, cherry: 9 }
]
arr = arr.map(e=>e.name).filter((value,index,self)=> self.indexOf(value) === index).map(e=>{
res = {name:e};
arr.filter(e1=>e1.name == e).forEach(v=>{
for(let key in v)
if(key != "name")
res[key] = (res[key] || 0) + v[key];
});
return res;
})
console.log(arr);
function getFri(now) {
var d = new Date(now.getFullYear(), now.getMonth() + 1, 0);
d.setDate(d.getDate() + [-2, -3, -4, -5, -6, 0, -1][d.getDay()]);
let diff = (d.getTime()-now.getTime())/1000;
let days = Math.floor(diff/(60*60*24));
diff%=60*60*24;
let hours = Math.floor(diff/(60*60));
diff%=60*60;
let min = Math.floor(diff/60);
diff%=60;
diff = Math.floor(diff)
return `${days} дней ${hours} часов ${min} минут ${diff} секунд`;
}
alert(getFri(new Date()));
$('.tabs__item-tab').not(':eq(1)').hide();
$('.tab').click(function() {
$('.tab').removeClass('active').eq($(this).index()).addClass('active');
$('.tabs__item-tab').hide().eq($(this).index()).fadeIn()
}).eq(1).addClass('active');
function trueRussianDecline(d1, d2, d3, c){
let res = "";
switch (c%100){
case 11: case 12: case 13: case 14:return d1;
default:
switch (c%10){
case 0:case 5:case 6:case 7:case 8:case 9:return d1;
case 1: return d2;
case 2:case 3:case 4: return d3;
}
}
return "";
}
let text = trueRussianDecline("лет","год","года",5);