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") { $('') .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; 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; $('') .text(match.name) .attr("href", "http://www.freebase.com/view" + match.id) .attr("target", "_blank") .appendTo(divContent); $(' ').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); }); $('') .addClass("data-table-recon-topic") .attr("href", "http://www.freebase.com/view" + candidate.id) .attr("target", "_blank") .text(candidate.name) .appendTo(li) .click(function(evt) { if (!evt.metaKey && !evt.ctrlKey) { self._previewCandidateTopic(candidate, this); 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); $('') .addClass("data-table-recon-search") .click(function(evt) { self._searchForMatch(); return false; }) .text("search for match") .appendTo($('Search Freebase for topic to match ' + this._cell.v + ' | |
' + ' | Match other cells with same content | ' + '
' + '' + ' | ' + '||||
' +
' ' + 'Enter' + ' | ' +
'' +
' ' + 'Esc' + ' | ' +
'' + '' + ' | ' + '' + '' + ' | ' + '' +
'apply to other cells with ' + 'same content (Ctrl-Enter)' + ' | ' +
'