function DataTableCellUI(dataTableView, cell, rowIndex, cellIndex, td) { this._dataTableView = dataTableView; this._cell = cell; this._rowIndex = rowIndex; this._cellIndex = cellIndex; this._td = td; this._render(); }; DataTableCellUI.prototype._render = function() { var self = this; var cell = this._cell; $(this._td).empty(); var divContent = $('
').appendTo(this._td); if (cell == null || ("v" in cell && cell.v == null)) { $(divContent).html(" "); } else if ("e" in cell) { $('').addClass("data-table-error").text(cell.e).appendTo(divContent); } else if (!("r" in cell) || cell.r == null) { $(divContent).text(cell.v); } else { var r = cell.r; if (r.j == "new") { $(divContent).text(cell.v + " (new topic)"); $(' ').appendTo(divContent); $('re-match') .addClass("data-table-recon-action") .appendTo(divContent).click(function(evt) { self._doRematch(); }); } else if (r.j == "matched" && "m" in r && r.m != null) { var match = cell.r.m; $('') .attr("href", "http://www.freebase.com/view" + match.id) .attr("target", "_blank") .text(match.name) .appendTo(divContent); $(' ').appendTo(divContent); $('re-match') .addClass("data-table-recon-action") .appendTo(divContent).click(function(evt) { self._doRematch(); }); } else { $(divContent).text(cell.v); if (this._dataTableView._showRecon) { var ul = $('').addClass("data-table-recon-candidates").appendTo(divContent); if ("c" in r && r.c.length > 0) { var candidates = r.c; var renderCandidate = function(candidate, index) { var li = $('').addClass("data-table-recon-candidate").appendTo(ul); $(' ') .addClass("data-table-recon-match-similar") .attr("title", "Match this topic to this cell and other cells with the same content") .appendTo(li).click(function(evt) { self._doMatchTopicToSimilarCells(candidate); }); $(' ') .addClass("data-table-recon-match") .attr("title", "Match this topic to this cell") .appendTo(li).click(function(evt) { self._doMatchTopicToOneCell(candidate); }); $('') .addClass("data-table-recon-topic") .attr("href", "http://www.freebase.com/view" + candidate.id) .attr("target", "_blank") .click(function(evt) { self._previewCandidateTopic(candidate.id, this); evt.preventDefault(); return false; }) .text(candidate.name) .appendTo(li); $('').addClass("data-table-recon-score").text("(" + Math.round(candidate.score) + ")").appendTo(li); }; for (var i = 0; i < candidates.length; i++) { renderCandidate(candidates[i], i); } } var liNew = $('').addClass("data-table-recon-candidate").appendTo(ul); $(' ') .addClass("data-table-recon-match-similar") .attr("title", "Create a new topic for this cell and other cells with the same content") .appendTo(liNew).click(function(evt) { self._doMatchNewTopicToSimilarCells(); }); $(' ') .addClass("data-table-recon-match") .attr("title", "Create a new topic for this cell") .appendTo(liNew).click(function(evt) { self._doMatchNewTopicToOneCell(); }); $('').text("(New topic)").appendTo(liNew); $('') .addClass("data-table-recon-search") .click(function(evt) { self._searchForMatch(); return false; }) .text("search for match") .appendTo($('