/**
 * FCViz 
 * Payload script for loan requests page
 */
 
//We don't need this mutation observer since we are in the requests page
window.fcVizObserver.disconnect();
 
var prependLinkToCell = function(){$(this).before(
  $(document.createElement("span")).attr("class","see_more").before("[").html("+").after("] ")
)};
 
$("#watch_form").find("a.mediumText").each(prependLinkToCell);

$(".see_more").on("click", function(){
  $(this).html($(this).html() === "+"? "-" : "+");
  var tr = $(this).closest("tr");
  if (tr.next().attr("class") !== "filler") {
    createPreviewUnder(tr);
  }
  tr.next().next().animate({height: "toggle"}, "slow");
});

function createPreviewUnder(row) {
  //Create a junk element that is hidden from the user
  //so that we can somehow give the illusion of maintaining
  //the table row background colors.
  var filler = $(document.createElement("tr"))
    .attr("class", "filler")
    .attr("id", "filler-"+row.attr("id"));
  filler.attr("style", "display: none;");
  
  var id = "preview-"+row.attr("id");
  
  var td = $(document.createElement("td"))
    .attr("colspan", 9)
    .attr("id", id)
    .html("Loading...");
  
  var href = row.find("a.mediumText").attr("href");
  
  var total = +row.find("td").eq(3).html().replace("£","").replace(",","");
  
  $.get(href, window.populatePreview.bind(window, id, total)).fail(function(jqXHR, textStatus, errorThrown) {
    $(td).html("Failed to retrieve "+href+", chart render aborted: "+errorThrown);
  });
  
  var preview = $(document.createElement("tr"))
    .attr("class", "preview");

  preview.append(td);
  preview.attr("style", "display: none;");
  row.after(filler,preview);
}

window.summaryVizDimensions = {
  height: 65,
  width: 300,
  margin: {top: 2, right: 10, bottom: 10, left: 10}
};

window.populatePreview = function (id, total, data){
  var dataTableStartIndex = data.indexOf("<table class='brand'>");
  
  var previewBidsId = "preview_bids_"+id;
  var previewBids = $(document.createElement("span"))
    .attr("id", previewBidsId)
    .attr("style", "width: 300px")
    .html(data.substring(dataTableStartIndex, data.indexOf("</table>", dataTableStartIndex)) + "</table>" );
  previewBids.find("table").attr("style", "display: none");
  $("#"+id).html("").append(previewBids);

  window.renderBidSummaryCharts(total, "#"+id, previewBidsId);
  $("#"+id).find("svg").find("g.tick").attr("style", "display: none;");
  $("#"+id).find("svg").find("g").find("text").attr("style", "display: none;");
}
@@ -1838,21 +1838,174 @@
 %7B%0A  
-var dataTable
+$(%22#%22+id).html(%22%22);%0A  var detailsStartIndex = data.indexOf(%22%3Cdiv class='span5'%3E%5Cn%3Ch3%3E%22);%0A  var dl = $(document.createElement(%22span%22))%0A    .html(data.substring(details
 Star
@@ -2002,34 +2002,33 @@
 etailsStartIndex
- =
+,
  data.indexOf(%22%3C
@@ -2031,75 +2031,697 @@
 f(%22%3C
-table class='brand'%3E%22);%0A  %0A  var previewBidsId = %22preview_bids_%22+id
+/div%3E%22, detailsStartIndex)))%0A    .find(%22dl%22).attr(%22style%22, %22display: initial;%22);%0A  dl.children().attr(%22style%22, %22font-size: 14px;%22).slice(2,6).detach();%0A  var title = %5B%5D;%0A  dl.find(%22dd%22).each(function()%7Btitle.push($(this).html().trim())%7D);%0A  indicateMoreThan = /more than/.test(title%5B2%5D)? %22%3E%22 : %22%22;%0A  title%5B2%5D = indicateMoreThan + (/%5Cd+/.exec(title%5B2%5D)%5B0%5D);%0A  var previewDetails = $(document.createElement(%22span%22))%0A    .attr(%22id%22, id+%22-details%22)%0A    .append(title%5B0%5D).append(document.createElement(%22br%22)).append(title%5B1%5D + %22, %22 + title%5B2%5D + %22 years%22);%0A  $(%22#%22+id).append(previewDetails);%0A  %0A  var dataTableStartIndex = data.indexOf(%22%3Ctable class='brand'%3E%22);%0A  var previewBidsId = id+%22-bids%22
 ;%0A  
@@ -3023,17 +3023,8 @@
 id).
-html(%22%22).
 appe
@@ -3252,13 +3252,53 @@
 y: none;%22);%0A
+  previewBids.find(%22table%22).detach();  %0A
 %7D

Add company name, type, age to preview pane