// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require_tree .
//

$(document).ready(function() {
  var callerCode = $('<div id="caller-code"></div>');
  $('body').append(callerCode);
  var editor = ace.edit("caller-code");
  editor.getSession().setMode("ace/mode/ruby");
  editor.setReadOnly(true);

  $('.caller-link').on('click', function (e) {
    var $this = $(this);
    e.preventDefault();

    $.ajax({
      url: $this.attr("href"),
      //async: false,
      success: function (data) {
        console.log('data: ', data);
        var editor = ace.edit("caller-code");
        editor.setValue(data.code);
        editor.gotoLine(data.line, 0, true);
        //editor.scrollToLine(data.line, true);

				//editor.setTheme("ace/theme/monokai");
				//editor.getSession().setMode("ace/mode/javascript");
      },
      error: function () {
        e.preventDefault();
      }
    });
  })
});

@@ -624,16 +624,36 @@
 ion() %7B%0A
+  // add editor div%0A
   var ca
@@ -729,16 +729,39 @@
 erCode);
+%0A%0A  // configure editor
 %0A  var e
@@ -870,16 +870,217 @@
 true);%0A%0A
+  // Override default click behavior to make ajax%0A  // request to get the source code from the locator%0A  // and set the value of the editor to the response.%0A  // Then jump to the line in the response.%0A
   $('.ca
@@ -1216,30 +1216,8 @@
 %22),%0A
-      //async: false,%0A
     
@@ -1257,312 +1257,78 @@
     
-console.log('data: ', data);%0A        var editor = ace.edit(%22caller-code%22);%0A        editor.setValue(data.code);%0A        editor.gotoLine(data.line, 0, true);%0A        //editor.scrollToLine(data.line, true);%0A%0A%09%09%09%09//editor.setTheme(%22ace/theme/monokai%22);%0A%09%09%09%09//editor.getSession().setMode(%22ace/mode/javascript%22
+editor.setValue(data.code);%0A        editor.gotoLine(data.line, 0, true
 );%0A 
@@ -1358,16 +1358,20 @@
 nction (
+data
 ) %7B%0A    
@@ -1374,33 +1374,66 @@
         
-e.preventDefault(
+console.error('could not get source. data: ', data
 );%0A     

Clean up JS