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; var divContent = $('
') .addClass("data-table-cell-content"); var editLink = $('') .addClass("data-table-cell-edit") .text("edit") .appendTo(divContent) .click(function() { self._startEdit(this); }); $(this._td).empty() .unbind() .mouseenter(function() { editLink.css("visibility", "visible"); }) .mouseleave(function() { editLink.css("visibility", "hidden"); }); if (cell == null || ("v" in cell && cell.v == null)) { $('').html(" ").appendTo(divContent); } else if ("e" in cell) { $('').addClass("data-table-error").text(cell.e).appendTo(divContent); } else if (!("r" in cell) || cell.r == null) { $('').text(cell.v).appendTo(divContent); } else { var r = cell.r; if (r.j == "new") { $('').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; $('') .text(match.name) .attr("href", "http://www.freebase.com/view" + match.id) .attr("target", "_blank") .appendTo(divContent); $(' ').appendTo(divContent); $('') .text("re-match") .addClass("data-table-recon-action") .appendTo(divContent) .click(function(evt) { self._doRematch(); }); } else { $('').text(cell.v).appendTo(divContent); 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($('' + ' text ' + ' number ' + ' boolean' + ' date' + ' | ' + '' + '' + ' | ' + '