text: // Generated by CoffeeScript 1.12.4
  (function() {
    window.App = {};
  
  
    /*
      Init
     */
  
    App.init = function() {
      App.canvas = document.createElement('canvas');
      App.canvas.height = 400;
      App.canvas.width = 800;
      document.getElementsByTagName('article')[0].appendChild(App.canvas);
      App.ctx = App.canvas.getContext("2d");
      App.ctx.fillStyle = "solid";
      App.ctx.strokeStyle = "#ECD018";
      App.ctx.lineWidth = 10;
      App.ctx.lineCap = "round";
      App.img = document.getElementById('img');
      App.ctx.drawImage(App.img, 0, 0);
      App.socket = io.connect('http://sniddl.app:8000');
      App.socket.on("draw:" + App.img.url, function(data) {
        return App.draw(data.x, data.y, data.type);
      });
      App.draw = function(x, y, type) {
        if (type === "dragstart") {
          App.ctx.beginPath();
          return App.ctx.moveTo(x, y);
        } else if (type === "drag") {
          App.ctx.lineTo(x, y);
          return App.ctx.stroke();
        } else {
          App.ctx.closePath();
          App.canvas.data = App.canvas.toDataURL('image/png');
          return App.socket.emit('save', String(App.canvas.data), App.img.url);
        }
      };
    };
  
  
    /*
    	Draw Events
     */
  
    $('canvas').live('drag dragstart dragend', function(e) {
      var offset, type, x, y;
      type = e.handleObj.type;
      offset = $(this).offset();
      e.clientX = e.layerX + offset.left;
      e.clientY = e.layerY - offset.top;
      x = e.offsetX;
      y = e.offsetY;
      App.draw(x, y, type);
      App.socket.emit('drawClick', {
        x: x,
        y: y,
        type: type,
        channel: App.img.url
      });
    });
  
    $(function() {
      return App.init();
    });
  
  }).call(this);
  