function compression(str){
var out = "";
var cnt = 1;
for(var i = 0; i < str.length; i++)
if(str[i] == str[i+1] && i < str.length)
cnt++;
else{
out+= str[i]+ (cnt > 1?cnt:"");
cnt = 1;
}
return out;
}
function uncompression(str){
var out = "";
for(var i = 0; i < str.length; i++){
if(!isNaN(parseInt(str[i])))
continue;
if(i < str.length && !isNaN(parseInt(str[i+1])))
for(var j = 0; j < str[i+1];j++)
out+= str[i];
else
out+=str[i];
}
return out;
}
alert(compression("aabcccabb"));//a2bc3ab2
alert(uncompression("a2bc3ab2"));//aabcccabb
<div class="def" data-firstclass="начальный класс" data-secondclass="класс на который поменять" data-px="на какой высоте скролла поменять в px"></div>
//ctx.drawImage(img,0,0,ctxW,ctxH - offset);
и закоментируйctx.fillRect(0,0,ctxW,ctxH - offset);
Uncaught SecurityError: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data.
<button pButton type="button" data-secondname="Сохранить" style="width:auto">Редактировать</button>
document.querySelectorAll("button").forEach(function(el){
el.addEventListener("click",function(){
if(!this.dataset.secondname)
return;
var tmp = this.innerHTML;
this.innerHTML = this.dataset.secondname;
this.dataset.secondname = tmp;
},false)
})
$('#typeProject').click(function(){
if(!$(".typeProject").attr("data-numcolor"))
$(".typeProject").attr("data-numcolor",0);
var colors = ['green', 'red', 'blue', 'yellow'];
var num = $(".typeProject").attr("data-numcolor");
$('.typeProject').css('background-color', colors[num++]);
num %= colors.length;
$(".typeProject").attr("data-numcolor",num);
});
document.querySelector("#hideFrame").addEventListener("click",function(){
document.querySelectorAll("iframe").forEach(function(el){
el.style.display = window.getComputedStyle(el).display == "block"?"none":"block";
});
},false);
iframe{
display:block;
}