1 line
2.1 KiB
JavaScript
1 line
2.1 KiB
JavaScript
$(document).ready(function(){$("*").off("click mousemove mousedown mouseup mouseleave").on("click mousemove mousedown mouseup mouseleave",function(a){return a.preventDefault,!1}),$('a[href^="http"]').tap(function(a){a.preventDefault();{var b=$(this).attr("href");new MozActivity({name:"view",data:{type:"url",url:b}})}}),$('a[href^="mailto"]').tap(function(a){a.preventDefault();var b=/mailto:(.*)/.exec($(this).attr("href"))[1],b=new MozActivity({name:"new",data:{type:"mail",url:b}})}),window.save=function(){switch(save.background){case"white":c.fillStyle="white",c.globalCompositeOperation="destination-over",c.fillRect(0,0,width(),height()),c.fillStyle=settings.color,c.globalCompositeOperation=settings.composite;break;case"current color":c.fillStyle=settings.bg,c.globalCompositeOperation="destination-over",c.fillRect(0,0,width(),height()),c.globalCompositeOperation=settings.composite}var a=$c[0].toDataURL();if("sketchy project"==save.type){var b,d=JSON.parse(localStorage.getItem("projects"));d&&d.some(function(a,c){return a.name==save["file name"]?(b=c,!0):!1})?(console.log(b),d[b]={name:save["file name"],data:a,points:window.points,settings:settings},localStorage.setItem("projects",JSON.stringify(d))):d?d.push({name:save["file name"],data:a,points:window.points}):d=[{name:save["file name"],data:a,points:window.points}],localStorage.setItem("projects",JSON.stringify(d))}else window.open(a,"_blank").focus();c.putImageData(window.points.history[window.points.history.last].data,0,0)},window.load=function(){var a=JSON.parse(localStorage.getItem("projects")).filter(function(a){return a.name==load.file})[0],b=document.createElement("img");b.src=a.data,b.onload=function(){c.clearRect(0,0,width(),height()),c.drawImage(b,0,0),window.points=a.points,window.points.history=[{data:c.createImageData($c.width(),$c.height()),points:[]},{data:c.getImageData(0,0,width(),height()),points:a.points}],$c.first().css("background",a.settings.bg),window.settings.bg=a.settings.bg}},localStorage.getItem("sawTips")!=settings.version&&($(".tour").removeClass("hidden"),localStorage.setItem("sawTips",settings.version))}); |