let searchBar = document.querySelector('.search'),
searchInput = searchBar.querySelector('input'),
searchToggleBtn = document.querySelector('.search-toggle'),
searchParent = document.querySelector('.header_content');
searchInput.addEventListener('focus', function (event) {
searchBar.classList.add('expanded');
});
searchInput.addEventListener('blur', function (event) {
searchInput.value || searchBar.classList.remove('expanded');
});
searchToggleBtn.addEventListener('click', function (event) {
searchToggleBtn.classList.toggle('active');
searchParent.classList.toggle('search');
searchBar.classList.toggle('visible');
searchInput.focus();
});
var arr = [];
$(document).on('click', '.product__cart', function (event) {
event.preventDefault();
var id_product = $(this).data("id");
arr.push(id_product);
});
function tag(input, key, value) {
if (typeof key === 'string' && value !== undefined) {
return input.replace('{' + key + '}', value);
} else {
for (let index in key) {
input = input.replace('{' + index + '}', key[index]);
}
}
return input;
}
function foo(bar) {
this["new_" + bar] = bar;
return this;
}
console.log(new foo(10));
$('#go').click(function(){
let term = $('#term').val().split(' '),
text = 'Планшет Apple iPad купить недорого',
reg = term.reduce((acc, item) => acc.replace(new RegExp(item, "gi"), "<strong>$&</strong>"), text)
$('#rez').html(reg);
});
"use strict";
var handleChange = function handleChange(e) {
return function (dispatch) {
dispatch({
type: PROMO_CODE,
payload: e.target.value
});
};
};
class entity {
isDead = false;
heals = 100;
damage = 10;
strike(entity, damage) {
if (!this.isDead) {
entity.heals -= damage;
if (entity.heals <= 0) {
this.isDead = true
console.log(entity, 'is dead');
}
}
}
}
class heroEntity extends entity {
heals = 150;
damage = 15;
}
class mobEntity extends entity {
}
const hero = new heroEntity(),
mob = new mobEntity();
hero.strike(mob, 100); // mobEntity {isDead: false, heals: 0, damage: 10} "is dead"