Commit 33d42d92 authored by Bertrand  NÉRON's avatar Bertrand NÉRON

add search by name feature.

on index.html page ther is a field to search replicon by name.
the list of matches replicon is dispalyed under the search box.
each entry is a link 
the mouse over each link display a tooltip with some informations on the entry
click on the link open the corresponding secreton system page
if no thing is specified in the seach box all replicon are display (45 by 45) order by replicon name.

parent 008a234b
<!DOCTYPE html>
<title>Example CouchApp</title>
<link rel="stylesheet" href="style/main.css" type="text/css">
<link rel="stylesheet" href="style/tooltip.css" type="text/css">
<script src="/_utils/script/jquery.js"></script>
<script src="/_utils/script/jquery.couch.js"></script>
<div id="account"></div>
<h1>Example CouchApp</h1>
<div id="profile">
<div id="content"></div>
<div id="sidebar">
<p>Edit welcome message.</p>
<p>Ideas: You could easily turn this into a photo sharing app,
or a grocery list, or a chat room. <a href="">Code for this app is on Github.</a></p>
<div id="request">
<label for="nameSearch">by replicon name (ex:BUMA001c02)</label>
<input type="text" name="nameSearch" id="nameInput"/>
<button type="button" id="nameButton">search by name</button>
<div id="results">
<script src="/_utils/script/sha1.js"></script>
<script src="/_utils/script/json2.js"></script>
<script src="/_utils/script/jquery.js"></script>
<script src="/_utils/script/jquery.couch.js"></script>
<script src="vendor/couchapp/jquery.couchLogin.js"></script>
<script src="vendor/couchapp/jquery.couchProfile.js"></script>
<script src="vendor/couchapp/md5.js"></script>
<script src="vendor/couchapp/jquery.mustache.js"></script>
<script type="text/javascript">
$(".tooltip" , "#results").live('mouseenter', function(){
var link$ = $(this).find("a");
timer = setTimeout(function(){
var pos = link$.position();
var top = + link$.outerHeight(true)+3;
var left = pos.left + link$.outerWidth(false)-25;
link$.next().css({top: top+"px", left: left+"px"}).show(300)},
}).live( 'mouseleave', function(){
<!-- templates used by app.js -->
<script id="new-message" type="text/x-mustache" charset="utf-8">
<div class="avatar">
{{#gravatar_url}}<img src="{{gravatar_url}}"/>{{/gravatar_url}}
<div class="name">
<form id="create-message">
<label>New message from {{nickname}}: <input type="text" name="message" size=60 value=""></label>
<div style="clear:left;"></div>
<script type="text/javascript">
var get_results = function( view , args ){
var url= document.location.href.split('/').slice(0, -1).concat(['_list','index',view]).join('/');
$("#results").load(url , args );
$("#nameButton").click( function(){
var params = {limit:45};
var key= $("#nameInput").attr("value");
if( key ){ params.key='"'+key+'"'}
get_results( 'by_replicon_name', $.param(params));
$("#paginate .nav_page").live( 'click', function(){
console.log('paginate click' );
var url = $(this).attr('data-href');
$("#results").load( url );
<script id="recent-messages" type="text/x-mustache" charset="utf-8">
<h3>Recent Messages</h3>
<ul id="items">
<div class="avatar">
{{#gravatar_url}}<img src="{{gravatar_url}}" alt="{{name}}"/>{{/gravatar_url}}
<div class="name">
<div style="clear:left;"></div>
<p><em>Protip:</em> If you setup continuous replication between this database and a remote one, this list will reflect remote changes in near real-time.</p>
<p>This would be a good place to add pagination.</p>
<script src="script/app.js"></script>
#results {
margin-left: 20px;
margin-right: 20%;
//background-color: yellow;
div .left{
//background-color: green;
margin-right: 5em;
#results ol>li{
li a {
position: relative;
li a:hover{
color: red;
.tooltip ul{
display: none;
border: 1px solid #777;
border-radius : 10px;
position: absolute;
background-color: #FFFFCC;
z-index: 20000;
/* setting tooltip opacity to opaque */
color: black;
font-weight: normal;
list-style-type: disc;
list-style-position: inside;
padding-left: 10px;
padding-right: 3px;
font-weight: bold;
clear: left;
margin: 1.5em 25%;
padding: 1em;
#paginate .nav_page{
color: blue;
text-decoration: underline;
#paginate .nav_page:hover{
color: red;
......@@ -2,14 +2,29 @@ function(head, req) {
//!json templates.replicon
var Mustache = require("vendor/couchapp/lib/mustache");
var path = require("vendor/couchapp/lib/path").init(req);
var limit = (req.query.limit)? req.query.limit: 0;
var curr_page = (req.query.curr_page)? parseInt(req.query.curr_page) : 0 ;
provides("html", function() {
var row, url;
var first_key, last_key ;
var first_docid, last_docid;
var row, system;
send(Mustache.to_html(templates.replicon.head , {}));
var item = 0;
var col_height = 15;
while (row = getRow()) {
if (!first_key){ first_key = row.key };
if (!first_docid){ first_docid = };
last_key = row.key;
last_docid =;
if( item >= col_height){
send('</ol></div><div class="left"><ol>')
item = 0;
system = row.value ;
send( Mustache.to_html(templates.replicon , {
"url" :"secretion_system" , ) ,
send( Mustache.to_html(templates.replicon.body , {
"url" :"secretion_system" , ) ,
"code" : system.code ,
"T3SS_family" : system.T3SS_family,
"name" :,
......@@ -18,8 +33,33 @@ function(head, req) {
"taxonomy" : system.taxonomy,
"type" : system.type
var pagination = {};
if( req.query.limit ){
var page_nb = Math.ceil( item / limit);
if( page_nb >1 ){
//a faire que si plusieurs pages
//var curr_page = Math.ceil( head.offset / limit) + 1;
if ( curr_page > 0 ){
if( req.query.descending ){
pagination.prev = path.list( "index" ,"by_replicon_name" ,{ startkey:last_key , startkey_docid: last_docid, limit: limit, skip:1, descending:true, curr_page: curr_page-1 });
pagination.prev = path.list( "index" ,"by_replicon_name" ,{ startkey:first_key , startkey_docid: first_docid, limit: limit, skip:1, descending:true, curr_page: curr_page-1});
if( curr_page < page_nb -1 ){
if( req.query.descending ){ = path.list( "index" ,"by_replicon_name" ,{ startkey:first_key , startkey_docid: first_docid, limit: limit , skip:1, curr_page: curr_page+1});
}else{ = path.list( "index" ,"by_replicon_name" ,{ startkey:last_key , startkey_docid: last_docid, limit: limit , skip:1, curr_page: curr_page+1 });
return(Mustache.to_html(templates.replicon.tail , pagination));
\ No newline at end of file
<li class="tooltip">
<a href="{{url}}">{{name}}</a>
<ul class="tooltip">
<li><span class="replicon_property">code</span>: {{code}}</li>
<li><span class="replicon_property">T3SS_family</span>: {{T3SS_family}}</li>
<li><span class="replicon_property">taxid</span>: {{taxid}}</li>
<div id="paginate">
{{#prev}}<a href="{{prev}}">&lt; previous</a> {{/prev}}|{{#next}}<a href="{{next}}">next &gt;</a>{{/next}}
{{#prev}}<span class="nav_page" data-href="{{prev}}">&lt; previous</span>{{/prev}}|{{#next}}<span class="nav_page" data-href="{{next}}">next &gt;</span>{{/next}}
......@@ -220,7 +220,7 @@
$(this).toggleClass( "grabbable" ).toggleClass( "grabbing" );
error: function(status) { console.log(status); }
error: function(status) { "<p>Error document not found</p>" }
$(document).ready( getdoc( "{{code}}"));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment