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") .attr("title", "Edit this cell") .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 || ("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) { if (typeof cell.v !== "string") { if (typeof cell.v == "number") { divContent.addClass("data-table-cell-content-numeric"); } $('') .addClass("data-table-value-nonstring") .text(cell.v) .appendTo(divContent); } else if (URL.looksLikeUrl(cell.v)) { $('') .text(cell.v) .attr("href", cell.v) .attr("target", "_blank") .appendTo(divContent); } else { $('') .text(cell.v) .appendTo(divContent); } } else { var r = cell.r; var service = (r.service) ? ReconciliationManager.getServiceFromUrl(r.service) : null; if (r.j == "new") { $('').text(cell.v + " (new topic) ").appendTo(divContent); $('') .text("re\u2011match") .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; var a = $('') .text(match.name) .attr("target", "_blank") .appendTo(divContent); if (service && (service.view) && (service.view.url)) { a.attr("href", service.view.url.replace("{{id}}", match.id)); } else if (ReconciliationManager.isFreebaseIdOrMid(r.identifierSpace)) { a.attr("href", "http://www.freebase.com/view" + match.id); } $(' ').appendTo(divContent); $('') .text("re\u2011match") .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); }); var a = $('') .addClass("data-table-recon-topic") .attr("target", "_blank") .text(candidate.name) .appendTo(li); if ((service) && (service.view) && (service.view.url)) { a.attr("href", service.view.url.replace("{{id}}", candidate.id)); } else if (ReconciliationManager.isFreebaseIdOrMid(r.identifierSpace)) { a.attr("href", "http://www.freebase.com/view" + candidate.id); } var preview = null; if ((service) && (service.preview)) { preview = service.preview; } else if (ReconciliationManager.isFreebaseIdOrMid(r.identifierSpace)) { preview = DataTableCellUI.topicBlockPreview; } if (preview) { a.click(function(evt) { if (!evt.metaKey && !evt.ctrlKey) { self._previewCandidateTopic(candidate, this, preview); evt.preventDefault(); return false; } }); } var score; if (candidate.score < 1) { score = Math.round(candidate.score * 1000) / 1000; } else { score = Math.round(candidate.score); } $('').addClass("data-table-recon-score").text("(" + 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); var suggestOptions; var addSuggest = false; if ((service) && (service.suggest) && (service.suggest.entity)) { suggestOptions = service.suggest.entity; addSuggest = true; } else if (ReconciliationManager.isFreebaseIdOrMid(r.identifierSpace)) { addSuggest = true; } if (addSuggest) { $('') .addClass("data-table-recon-search") .click(function(evt) { self._searchForMatch(suggestOptions); return false; }) .text("search for match") .appendTo($('