Mercurial > hg > NetworkVis
diff ismi-python-neo4jrestclient/static/commentaries_authors3.html @ 21:d964d9a23837
now with clickable author names in detail panel.
author | casties |
---|---|
date | Fri, 09 Oct 2015 15:01:20 +0200 |
parents | d8bbf6d5920b |
children | b709419d4235 |
line wrap: on
line diff
--- a/ismi-python-neo4jrestclient/static/commentaries_authors3.html Fri Oct 09 12:54:39 2015 +0200 +++ b/ismi-python-neo4jrestclient/static/commentaries_authors3.html Fri Oct 09 15:01:20 2015 +0200 @@ -39,14 +39,13 @@ <div class="col-md-5"> <div class="panel panel-default"> <div class="panel-heading"> - <span>Texts by this author</span> + <span id="author">Titles by this author</span> <span class="clickhide">(click to hide)</span> <span class="clickhide" style="display:none;">(click to show)</span> </div> <table id="results" class="table table-striped table-hover"> <thead> <tr> - <th>Author (translit)</th> <th>Title (translit)</th> <th>Title (arabic)</th> <th>ismi_id</th> @@ -124,7 +123,10 @@ if (!data) return; $("#title").text("Title: "+data.title); var $list = $("#info").empty(); - $list.append($("<li> author: " + data.author + "</li>")); + $list.append($("<li> Author: " + data.author.label + "</li>") + .click(function() { + search(data.author.ismi_id, true); + })); for (var key in data.attrs) { var val = data.attrs[key]; if (key === "link") { @@ -135,6 +137,7 @@ // re-set selected $("#graph .selected").each(function(){this.classList.remove("selected")}); $("#graph .ismi-"+data.attrs.ismi_id).each(function(){this.classList.add("selected")}); + // add commentaries var $commentaries = $("#commentaries").empty(); for (var key in data.commentaries) { var val = data.commentaries[key]; @@ -150,19 +153,23 @@ }, "json"); return false; } - function search() { - var query=$("#search").find("input[name=search]").val(); + function search(query, keep_detail_view) { + if (query == null) { + query=$("#search").find("input[name=search]").val(); + } $.get(backendApiPrefix+"/search?q=" + encodeURIComponent(query), function (data) { var t = $("table#results tbody").empty(); if (!data || data.length == 0) return; // clear all marks $("#graph .marked").each(function(){this.classList.remove("marked")}); + // fill table of titles data.forEach(function (row) { var text = row.text; var author = row.author; + $("#author").text("Titles by Author: "+author.label+" ["+author.ismi_id+"]"); var comm = row.is_commentary || row.has_commentaries; - var $row = $("<tr><td>" + author.label + "</td><td>" + text.label + "</td><td>" + text.full_title + "</td><td class='text_id'>" + text.ismi_id + "</td></tr>").appendTo(t) + var $row = $("<tr><td>" + text.label + "</td><td>" + text.full_title + "</td><td class='text_id'>" + text.ismi_id + "</td></tr>").appendTo(t) .click(function() { showText($(this).find("td.text_id").text());}); if (comm) { $row.addClass("marked"); @@ -170,7 +177,10 @@ // set mark $("#graph .ismi-"+text.ismi_id).each(function(){this.classList.add("marked")}); }); - showText(data[0].text.ismi_id); + if (!keep_detail_view) { + // show first title + showText(data[0].text.ismi_id); + } }, "json"); return false; } @@ -212,7 +222,7 @@ .attr("class","arrowHead"); // load graph - d3.json(backendApiPrefix+"/graph?limit=1000", function(error, graph) { + d3.json(backendApiPrefix+"/graph?limit=10", function(error, graph) { if (error) return; force.nodes(graph.nodes).links(graph.links).start(); @@ -231,7 +241,6 @@ .attr("r", 8) // 10 .attr("data-ismi_id", function(d) {return d.ismi_id}) .on("click", function() { - console.log("click on ", this); var id = this.getAttribute("data-ismi_id"); searchApi.showText(id); })