var stage, shape, oldX, oldY, size;

$(function() {
  stage = new createjs.Stage("dashboard-canvas");
  stage.enableDOMEvents = true;

  shape = new createjs.Shape();
  stage.addChild(shape);

  size = 3;

  stage.addEventListener('stagemousedown', function(e) {
    stage.addEventListener('stagemousemove', function(e) {
      if (oldX) {
        shape.graphics.beginStroke(color)
                      .setStrokeStyle(size, "round")
                      .moveTo(oldX, oldY)
                      .lineTo(e.stageX, e.stageY);
        stage.update();
      }
      /* Save event */
      saveEvent(color, oldX, oldY, e.stageX, e.stageY, dashboard_id);

      oldX = e.stageX;
      oldY = e.stageY;
    });
  });
  // need to get mouseup event working correctly...
  stage.update();

  replayEvents(dashboard_id);
});

function saveEvent(color, oldX, oldY, newX, newY, dashboard_id) {
    endpoint = "/api/saveEvent";
    $.ajax({
      url: endpoint,
      method: "POST",
      headers: {'X-CSRFToken': $.cookie('csrftoken')},
      data: {'color': color, 'oldX': oldX, 'oldY': oldY, 'newX': newX, 'newY': newY, 'dashboard_id': dashboard_id},
      success: function() {}
    });
}

function replayEvents(dashboard_id) {
    endpoint = "/api/getEvents";
    $.ajax({
      url: endpoint,
      method: "POST",
      headers: {'X-CSRFToken': $.cookie('csrftoken')},
      data: {'dashboard_id': dashboard_id},
      success: function(data) {
        $.each(data.events, function(index, event) {
          event = JSON.parse(event);
          if (oldX) {
            shape.graphics.beginStroke(event.color)
                          .setStrokeStyle(size, "round")
                          .moveTo(event.oldX, event.oldY)
                          .lineTo(event.newX, event.newY);
            stage.update();
          }
          oldX = event.newX;
          oldY = event.newY;
        });
      }
    });
@@ -871,34 +871,32 @@
 dashboard_id) %7B%0A
-  
   endpoint = %22/a
@@ -910,18 +910,16 @@
 Event%22;%0A
-  
   $.ajax
@@ -917,34 +917,32 @@
 %0A  $.ajax(%7B%0A    
-  
 url: endpoint,%0A 
@@ -932,34 +932,32 @@
  url: endpoint,%0A
-  
     method: %22POS
@@ -956,34 +956,32 @@
 od: %22POST%22,%0A    
-  
 headers: %7B'X-CSR
@@ -1005,34 +1005,32 @@
 ('csrftoken')%7D,%0A
-  
     data: %7B'colo
@@ -1123,34 +1123,32 @@
 hboard_id%7D,%0A    
-  
 success: functio
@@ -1156,18 +1156,16 @@
 () %7B%7D%0A  
- 
- 
 %7D);%0A%7D%0A%0Af
@@ -1201,18 +1201,16 @@
 d_id) %7B%0A
-  
   endpoi
@@ -1234,18 +1234,16 @@
 nts%22;%0A  
- 
- 
 $.ajax(%7B
@@ -1243,18 +1243,16 @@
 .ajax(%7B%0A
-  
     url:
@@ -1266,18 +1266,16 @@
 nt,%0A    
- 
- 
 method: 
@@ -1282,18 +1282,16 @@
 %22POST%22,%0A
-  
     head
@@ -1339,18 +1339,16 @@
 )%7D,%0A    
- 
- 
 data: %7B'
@@ -1377,18 +1377,16 @@
 rd_id%7D,%0A
-  
     succ
@@ -1413,18 +1413,16 @@
 %7B%0A      
-  
 $.each(d
@@ -1454,26 +1454,24 @@
 x, event) %7B%0A
-  
         even
@@ -1497,26 +1497,24 @@
 t);%0A        
-  
 if (oldX) %7B%0A
@@ -1509,26 +1509,24 @@
 if (oldX) %7B%0A
-  
           sh
@@ -1579,34 +1579,32 @@
                 
-  
 .setStrokeStyle(
@@ -1610,34 +1610,32 @@
 (size, %22round%22)%0A
-  
                 
@@ -1690,34 +1690,32 @@
                 
-  
 .lineTo(event.ne
@@ -1737,26 +1737,24 @@
 ;%0A          
- 
- 
 stage.update
@@ -1761,26 +1761,24 @@
 ();%0A        
-  
 %7D%0A          
@@ -1771,26 +1771,24 @@
   %7D%0A        
- 
- 
 oldX = event
@@ -1794,18 +1794,16 @@
 t.newX;%0A
-  
         
@@ -1831,18 +1831,16 @@
     
- 
- 
 %7D);%0A    
   %7D%0A
@@ -1839,15 +1839,13 @@
     
-  
 %7D%0A  
- 
- 
 %7D);
+%0A%7D

fix JS syntax error