let observer = new MutationObserver(function(mutations) {
mutations.forEach(function(e) {
if (e.type == "attributes" && e.attributeName == "class") {
if (e.oldValue.indexOf("active") == -1 && e.target.classList.contains("active")) {
console.log("Класс active добавлен к элементу с ID:#"+e.target.id);
}
if (e.oldValue.indexOf("active") != -1 && !e.target.classList.contains("active")) {
console.log("Класс active убран с элемента с ID:#"+e.target.id);
}
}
});
});
observer.observe(document.querySelector("#myelem"), {
attributes: true,
attributeOldValue: true
});
function drawImageOnCanvas(size, reduct, reductPixel) {
canvas.width = size;
canvas.height = size;
const colorImage = localStorage.getItem('saveImage');/// <---------------- цветное изображение
ctx.drawImage(colorImage, 0, 0, size, size);
ctx.globalCompositeOperation='color';
ctx.fillStyle = "white";
ctx.globalAlpha = 1;
ctx.fillRect(0, 0, size,size);
canvasSize = size;
reductionNumber = reduct;
reductionPixelNumber = reductPixel;
}
document.querySelector("#status").addEventListener("change",function (evt) {
Array.from(evt.target.children).forEach((e)=>{
if(evt.srcElement.value == "-222" && e.value != "-222" || evt.srcElement.value != "-222" && e.value == "-222")
e.selected = false;
});
});
document.querySelector("#status").addEventListener("change", evt=> {
[...evt.target.children].forEach(e=> e.selected =e.selected && !(evt.srcElement.value == "-222" && e.value != "-222" || evt.srcElement.value != "-222" && e.value == "-222") );
});
ctx.save();
ctx.translate(50,0); // тут координаты смещения
ctx.beginPath();
ctx.moveTo(0,100);
ctx.lineTo(200,100);
ctx.lineTo(100,0);
ctx.closePath();
ctx.fill();
ctx.restore();
var offX = 300;//по х
var offY = 50;//по у
ctx.beginPath();
ctx.moveTo(offX+0,offY+100);
ctx.lineTo(offX+200,offY+100);
ctx.lineTo(offX+100,offY+0);
ctx.closePath();
ctx.fill();
let input = document.querySelector('.input');
let p = document.querySelector('.resultParagraph');
input.addEventListener("input",(e)=>{
if(e.target.value.trim() == "")
Array.from(p.children).forEach(el=>{
p.replaceChild(document.createTextNode(el.textContent),el);
});
});
input.addEventListener("change",(e)=>{
p.innerHTML = p.innerHTML.replace(new RegExp(input.value, 'gmi'), (a)=>
`<span style="background: red;">${a}</span>`
);
});
let input = document.querySelector('.input');
let p = document.querySelector('.resultParagraph');
input.addEventListener("input",(e)=>{
Array.from(p.children).forEach(el=>{
p.replaceChild(document.createTextNode(el.textContent),el);
});
p.innerHTML = p.innerHTML.replace(new RegExp(input.value, 'gmi'), (a)=>
`<span style="background: red;">${a}</span>`
);
});
x.sort(function(a, b){a-b})
//Нужно или
x.sort(function(a, b){return a-b})
//или
x.sort((a, b)=>a-b)
var keys = ["key1","key2","key3"];
var checkCount = keys.length;
keys.forEach(el=>{
$.get(
"https://www.googleapis.com/youtube/v3/search",{
part: 'id',
key: el})
.done((d)=>check(d,el))
.fail((d)=>check(d,el));
});
function check(data,key){
if(data.statusText == "error" && data.status == 400 && data.responseJSON.error.errors[0].reason == "keyInvalid")
keys.splice(keys.indexOf(key),1);
if(--checkCount == 0)
alert(`Валидные ключи: ${keys}`);
}
if(gamer.offsetTop == 520){
gamer.style.top = "0 px";
}