Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gem
capsuledb
Commits
1c0608ac
Commit
1c0608ac
authored
Feb 20, 2012
by
Bertrand NÉRON
Browse files
add support of "start with" for requesting the db by name
parent
f1619f7e
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/couchapp/secreton/_attachments/index.html
View file @
1c0608ac
...
...
@@ -13,6 +13,10 @@
<fieldset>
<label
for=
"nameSearch"
>
by replicon name (ex:BUMA001c02)
</label>
<input
type=
"text"
name=
"nameSearch"
id=
"nameInput"
/>
<select
name=
"queryType"
id=
"nameQueryType"
>
<option
value=
"is"
selected=
"selected"
>
is
</option>
<option
value=
"start_with"
>
start_with
</option>
</select>
<button
type=
"button"
id=
"nameButton"
>
search by name
</button>
</fieldset>
</form>
...
...
@@ -42,9 +46,19 @@ $(".tooltip" , "#results").live('mouseenter', function(){
$
(
"
#results
"
).
load
(
url
,
args
);
}
$
(
"
#nameButton
"
).
click
(
function
(){
var
params
=
{
limit
:
45
};
var
key
=
$
(
"
#nameInput
"
).
attr
(
"
value
"
);
if
(
key
){
params
.
key
=
'
"
'
+
key
+
'
"
'
}
var
params
=
{
limit
:
45
+
1
};
var
$query
=
$
(
"
#nameQueryType
"
).
attr
(
"
value
"
)
if
(
$query
==
"
start_with
"
){
var
key
=
$
(
"
#nameInput
"
).
attr
(
"
value
"
);
if
(
key
){
params
.
startkey
=
'
"
'
+
key
+
'
"
'
;
params
.
endkey
=
'
"
'
+
key
+
'
\
uFFFF"
'
;
params
.
query_type
=
"
start_with
"
;
}
}
else
{
var
key
=
$
(
"
#nameInput
"
).
attr
(
"
value
"
);
if
(
key
){
params
.
key
=
'
"
'
+
key
+
'
"
'
}
}
get_results
(
'
by_replicon_name
'
,
$
.
param
(
params
));
});
...
...
src/couchapp/secreton/lists/index.js
View file @
1c0608ac
function
(
head
,
req
)
{
//!json templates.replicon
//
!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
limit
=
(
req
.
query
.
limit
)?
req
.
query
.
limit
-
1
:
0
;
var
curr_page
=
(
req
.
query
.
curr_page
)?
parseInt
(
req
.
query
.
curr_page
)
:
0
;
var
query_type
=
(
req
.
query
.
query_type
)?
req
.
query
.
query_type
:
"
is
"
;
provides
(
"
html
"
,
function
()
{
var
first_key
,
last_key
;
var
first_docid
,
last_docid
;
var
row
,
system
;
send
(
Mustache
.
to_html
(
templates
.
replicon
.
head
,
{}));
var
item
=
0
;
var
item_in_col
=
0
;
var
item
=
0
var
col_height
=
15
;
var
more_results
=
false
;
var
next_key
=
null
;
var
next_docid
=
null
;
while
(
row
=
getRow
())
{
if
(
!
first_key
){
first_key
=
row
.
key
};
if
(
!
first_docid
){
first_docid
=
row
.
id
};
item
++
;
if
(
item
>
limit
){
more_results
=
true
;
next_key
=
row
.
key
;
next_docid
=
row
.
id
;
break
;
}
item_in_col
++
;
last_key
=
row
.
key
;
last_docid
=
row
.
id
;
if
(
item
>=
col_height
){
send
(
'
</ol></div><div class="left"><ol>
'
)
item
=
0
;
}
system
=
row
.
value
;
send
(
Mustache
.
to_html
(
templates
.
replicon
.
body
,
{
"
url
"
:
path
.
show
(
"
secretion_system
"
,
system
.
id
)
,
"
code
"
:
system
.
code
,
"
T3SS_family
"
:
system
.
T3SS_family
,
"
name
"
:
system
.
name
,
"
taxid
"
:
system
.
taxid
,
"
strain
"
:
system
.
strain
,
"
taxonomy
"
:
system
.
taxonomy
,
"
type
"
:
system
.
type
"
url
"
:
path
.
show
(
"
secretion_system
"
,
system
.
id
)
,
"
code
"
:
system
.
code
,
"
T3SS_family
"
:
system
.
T3SS_family
,
"
name
"
:
system
.
name
,
"
taxid
"
:
system
.
taxid
,
"
strain
"
:
system
.
strain
,
"
taxonomy
"
:
system
.
taxonomy
,
"
type
"
:
system
.
type
}));
item
++
;
if
(
item_in_col
>=
col_height
){
send
(
'
</ol></div><div class="left"><ol>
'
);
item_in_col
=
0
;
}
}
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
});
}
else
{
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
(
limit
){
if
(
query_type
==
"
is
"
){
if
(
!
req
.
query
.
descending
){
if
(
more_results
){
pagination
.
next
=
path
.
list
(
"
index
"
,
"
by_replicon_name
"
,{
startkey
:
next_key
,
startkey_docid
:
next_docid
,
limit
:
limit
+
1
,
curr_page
:
curr_page
+
1
});
}
if
(
curr_page
>
0
){
pagination
.
prev
=
path
.
list
(
"
index
"
,
"
by_replicon_name
"
,{
startkey
:
first_key
,
startkey_docid
:
first_docid
,
limit
:
limit
+
1
,
skip
:
1
,
descending
:
true
,
curr_page
:
curr_page
-
1
});
}
}
else
{
// si je descend il ya forecement un next
pagination
.
next
=
path
.
list
(
"
index
"
,
"
by_replicon_name
"
,{
startkey
:
first_key
,
startkey_docid
:
first_docid
,
limit
:
limit
+
1
,
skip
:
1
,
curr_page
:
curr_page
+
1
});
if
(
more_results
){
pagination
.
prev
=
path
.
list
(
"
index
"
,
"
by_replicon_name
"
,{
startkey
:
next_key
,
startkey_docid
:
next_docid
,
limit
:
limit
+
1
,
descending
:
true
,
curr_page
:
curr_page
-
1
});
}
}
if
(
curr_page
<
page_nb
-
1
){
if
(
req
.
query
.
descending
){
pagination
.
next
=
path
.
list
(
"
index
"
,
"
by_replicon_name
"
,{
startkey
:
first_key
,
startkey_docid
:
first_docid
,
limit
:
limit
,
skip
:
1
,
curr_page
:
curr_page
+
1
});
}
else
{
pagination
.
next
=
path
.
list
(
"
index
"
,
"
by_replicon_name
"
,{
startkey
:
last_key
,
startkey_docid
:
last_docid
,
limit
:
limit
,
skip
:
1
,
curr_page
:
curr_page
+
1
});
}
else
if
(
query_type
==
"
start_with
"
){
var
storeendkey
=
(
req
.
query
.
storeendkey
)?
req
.
query
.
storeendkey
:
req
.
query
.
endkey
;
var
storestartkey
=
(
req
.
query
.
storestartkey
)?
req
.
query
.
storestartkey
:
'
"
'
+
first_key
+
'
"
'
;
if
(
!
req
.
query
.
descending
){
if
(
more_results
){
pagination
.
next
=
path
.
list
(
"
index
"
,
"
by_replicon_name
"
,{
startkey
:
next_key
,
startkey_docid
:
next_docid
,
endkey
:
storeendkey
,
limit
:
limit
+
1
,
curr_page
:
curr_page
+
1
,
query_type
:
"
start_with
"
,
storeendkey
:
storeendkey
,
storestartkey
:
storestartkey
});
}
if
(
curr_page
>
0
){
pagination
.
prev
=
path
.
list
(
"
index
"
,
"
by_replicon_name
"
,{
startkey
:
first_key
,
startkey_docid
:
first_docid
,
endkey
:
storestartkey
,
limit
:
limit
+
1
,
skip
:
1
,
descending
:
true
,
curr_page
:
curr_page
-
1
,
query_type
:
"
start_with
"
,
storeendkey
:
storeendkey
,
storestartkey
:
storestartkey
});
}
}
else
{
// je descend
if
(
more_results
){
pagination
.
prev
=
path
.
list
(
"
index
"
,
"
by_replicon_name
"
,{
startkey
:
next_key
,
startkey_docid
:
next_docid
,
end_key
:
storestartkey
,
limit
:
limit
+
1
,
descending
:
true
,
curr_page
:
curr_page
-
1
,
query_type
:
"
start_with
"
,
storestartkey
:
storestartkey
,
storeendkey
:
storeendkey
,
});
}
// si je descend il ya forecement un next
pagination
.
next
=
path
.
list
(
"
index
"
,
"
by_replicon_name
"
,{
startkey
:
first_key
,
startkey_docid
:
first_docid
,
endkey
:
storeendkey
,
limit
:
limit
+
1
,
skip
:
1
,
curr_page
:
curr_page
+
1
,
query_type
:
"
start_with
"
,
storestartkey
:
storestartkey
,
storeendkey
:
storeendkey
,
});
}
}
}
}
return
(
Mustache
.
to_html
(
templates
.
replicon
.
tail
,
pagination
));
});
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment