Sticky notes like iOS Notes. Double click to add note. Focus note and add some text. Press "Esc" on note to delete it. Your notes are always in localStorage.
function w(){n[e]=b[j]}function v(a){b[j]+="<a onkeydown=event.keyCode^27||b.removeChild(this),w() style="+g+a.clientX+"px;top:"+a.clientY+"px;><i style="+g+"30px;top:10px;color:#a53;font-size:9px>"+Date()+"</i><img src="+r+"><"+k+" onkeyup=this."+j+"=this.value,w() style="+g+"28px;top:33px;background:transparent;width:170px;height:200px;border:0;line-height:20px;overflow:hidden>Esc</"+k+"></a>",w()}var d="fillStyle",e="dblclick",f="setAttribute",g="position:absolute;left:",h="fillRect",i="addColorStop",j="innerHTML",k="textarea",l="#ffe",m=document,n=localStorage,o,p,q,r,s=200,t=250,u=a.createLinearGradient(s,t/2,s,0);c[f]("width",202),c[f]("height",275),u[i](0,"#ff9"),u[i](1,l),a[d]=u,a.strokeStyle="#aa7",a.strokeRect(1,1,s,t),a[h](1,1,s,t),o=s,a[d]=l;while(--o){while(--p)Math.random()>.7&&a[h](o,p,1,1);p=t}a[d]="#a51",a[h](20,1,1,t),a[h](22,1,1,t),a[d]="#aaa";for(o=50;o<t;o+=20)a[h](0,o,s,1);r=c.toDataURL(),b[j]=n[e]||e+", uses "+n,m.addEventListener(e,v,0)
ZnVuY3Rpb24gdygpe25bZV09YltqXX1mdW5jdGlvbiB2KGEpe2Jbal0rPSI8YSBvbmtleWRvd249ZXZlbnQua2V5Q29kZV4yN3x8Yi5yZW1vdmVDaGlsZCh0aGlzKSx3KCkgc3R5bGU9IitnK2EuY2xpZW50WCsicHg7dG9wOiIrYS5jbGllbnRZKyJweDs+PGkgc3R5bGU9IitnKyIzMHB4O3RvcDoxMHB4O2NvbG9yOiNhNTM7Zm9udC1zaXplOjlweD4iK0RhdGUoKSsiPC9pPjxpbWcgc3JjPSIrcisiPjwiK2srIiBvbmtleXVwPXRoaXMuIitqKyI9dGhpcy52YWx1ZSx3KCkgc3R5bGU9IitnKyIyOHB4O3RvcDozM3B4O2JhY2tncm91bmQ6dHJhbnNwYXJlbnQ7d2lkdGg6MTcwcHg7aGVpZ2h0OjIwMHB4O2JvcmRlcjowO2xpbmUtaGVpZ2h0OjIwcHg7b3ZlcmZsb3c6aGlkZGVuPkVzYzwvIitrKyI+PC9hPiIsdygpfXZhciBkPSJmaWxsU3R5bGUiLGU9ImRibGNsaWNrIixmPSJzZXRBdHRyaWJ1dGUiLGc9InBvc2l0aW9uOmFic29sdXRlO2xlZnQ6IixoPSJmaWxsUmVjdCIsaT0iYWRkQ29sb3JTdG9wIixqPSJpbm5lckhUTUwiLGs9InRleHRhcmVhIixsPSIjZmZlIixtPWRvY3VtZW50LG49bG9jYWxTdG9yYWdlLG8scCxxLHIscz0yMDAsdD0yNTAsdT1hLmNyZWF0ZUxpbmVhckdyYWRpZW50KHMsdC8yLHMsMCk7Y1tmXSgid2lkdGgiLDIwMiksY1tmXSgiaGVpZ2h0IiwyNzUpLHVbaV0oMCwiI2ZmOSIpLHVbaV0oMSxsKSxhW2RdPXUsYS5zdHJva2VTdHlsZT0iI2FhNyIsYS5zdHJva2VSZWN0KDEsMSxzLHQpLGFbaF0oMSwxLHMsdCksbz1zLGFbZF09bDt3aGlsZSgtLW8pe3doaWxlKC0tcClNYXRoLnJhbmRvbSgpPi43JiZhW2hdKG8scCwxLDEpO3A9dH1hW2RdPSIjYTUxIixhW2hdKDIwLDEsMSx0KSxhW2hdKDIyLDEsMSx0KSxhW2RdPSIjYWFhIjtmb3Iobz01MDtvPHQ7bys9MjApYVtoXSgwLG8scywxKTtyPWMudG9EYXRhVVJMKCksYltqXT1uW2VdfHxlKyIsIHVzZXMgIituLG0uYWRkRXZlbnRMaXN0ZW5lcihlLHYsMCk=
// Full version of Notes ll be on my web site soon.
// Creating closure to compile with UglifyJS
// (!) After compile remove global closure manually
(function (ctx, __document__body__, canvas) {
// Dictionary for some frequently used method names and strings
var __fillStyle__ = 'fillStyle',
__dblclick__ = 'dblclick',
__setAttribute__ = 'setAttribute',
__background_and_left__ = 'position:absolute;left:',
__fillRect__ = 'fillRect',
__addColorStop__ = 'addColorStop',
__innerHTML__ = 'innerHTML',
__textarea__ = 'textarea',
__ffe__ = '#ffe',
// Other shorthands
__document__ = document,
__localStorage__ = localStorage,
i,j,c,imageData,
width = 200,
height = 250,
paperGradient = ctx.createLinearGradient(width, height/2, width, 0);
// Making fixed canvas size
canvas[__setAttribute__]('width', 202);
canvas[__setAttribute__]('height', 275);
// Creates note at e.clientX e.clientY
function createPaper(e) {
// Opera haven't onbeforeuload event
// I must save document.body content on each keyup and each keyCode=27 keydown
// Sorry... :3
// (!) replace b and save to actual after min
__document__body__[__innerHTML__] += '<a onkeydown=event.keyCode^27||b.removeChild(this),w() style=' + __background_and_left__ + e.clientX + 'px;top:' + e.clientY + 'px;><i style=' + __background_and_left__ + '30px;top:10px;color:#a53;font-size:9px>'+Date()+'</i><img src=' + imageData + '><' + __textarea__ + ' onkeyup=this.'+__innerHTML__+'=this.value,w() style=' + __background_and_left__ + '28px;top:33px;background:transparent;width:170px;height:200px;border:0;line-height:20px;overflow:hidden>Esc</' + __textarea__ + '></a>';
save();
}
// Saves document.body to localStorage
function save() {
__localStorage__[__dblclick__] = __document__body__[__innerHTML__];
}
// Making sexy paper
// Gradient
paperGradient[__addColorStop__](0, '#ff9');
paperGradient[__addColorStop__](1, __ffe__);
ctx[__fillStyle__] = paperGradient;
ctx.strokeStyle = '#aa7';
// Draw paper body
ctx.strokeRect(1,1, width,height);
ctx[__fillRect__](1,1, width,height);
// Creating paper texture
i = width;
ctx[__fillStyle__] = __ffe__;
while(--i) {
while(--j) {
Math.random()>.7&&ctx[__fillRect__](i,j,1,1);
}
j = height;
}
// 2 Vertical red lines
ctx[__fillStyle__] = '#a51';
ctx[__fillRect__](20, 1, 1, height);
ctx[__fillRect__](22, 1, 1, height);
// Some horizontal gray lines
ctx[__fillStyle__] = '#aaa';
for (i = 50; i < height; i += 20) ctx[__fillRect__](0, i, width, 1);
// Grabbing image source
imageData = canvas.toDataURL();
// Print "Hello message" or load localStorage content
__document__body__[__innerHTML__]=__localStorage__[__dblclick__] || __dblclick__+', uses ' + __localStorage__;
// Some action events
__document__.addEventListener(__dblclick__, createPaper, 0);
}(a,b,c)) // Vars must be in a, b, c order