Web Paint

I had a busy day, so I decided to go back to my canvas drawing element. I wanted to create a web version of paint that would allow a user to paint over an existing image (linked via a URL) and then save the drawing. I was pleasantly successful in this with just a few commands. I started with my previous code that allowed one to paint, then added some ability to key in an image found somewhere on the web.

The JavaScript for this was not too complicated, and mostly adapted from previous sources. I did have to play around with form in jsfiddle, but ultimately, I found a pretty simple (albeit clumsy) solution.

var img = new Image;

$("#pretendSubmit").on("click",function() {
img.src = $('#inputURL').val();
console.log(img.src);
canvas.width = img.width;
canvas.height = img.height;
img.onload = function() {
    context.drawImage(img,0,0);
};

});

The full code is below, and at this link.