|
From: <rv...@us...> - 2012-02-20 19:34:37
|
Revision: 1074
http://treebase.svn.sourceforge.net/treebase/?rev=1074&view=rev
Author: rvos
Date: 2012-02-20 19:34:27 +0000 (Mon, 20 Feb 2012)
Log Message:
-----------
Adding javascript code for simplified search UI
Modified Paths:
--------------
trunk/treebase-web/src/main/webapp/scripts/common.js
Modified: trunk/treebase-web/src/main/webapp/scripts/common.js
===================================================================
--- trunk/treebase-web/src/main/webapp/scripts/common.js 2012-02-17 18:18:14 UTC (rev 1073)
+++ trunk/treebase-web/src/main/webapp/scripts/common.js 2012-02-20 19:34:27 UTC (rev 1074)
@@ -222,3 +222,52 @@
link.title='expand';
}
}
+//expands what a user types in the text box into a PhyloWS query
+TreeBASE.expandQuery = function () {
+ var query = $('query').value;
+ var split = TreeBASE.splitWords(query);
+ var terms = new Array();
+ for ( var i = 0; i < split.length; i++ ) {
+ var type = TreeBASE.inferType(split[i]);
+ var index = predicates[type];
+ for ( var j = 0; j < index.length; j++ ) {
+ terms.push( index[j] + '=' + split[i] );
+ }
+ }
+ var joiner = ' or ';
+ if ( $('all').checked ) {
+ joiner = ' and ';
+ }
+ $('expanded').value = terms.join(joiner);
+ return false;
+};
+
+// splits a string on words (including curies) and quoted phrases
+TreeBASE.splitWords = function(query){
+ return query.match(/[A-Za-z0-9:]+|"[^"]+"|'[^']+'/g);
+};
+
+// infers whether a search word is an identifier or a string
+TreeBASE.inferType = function(word) {
+ if ( word.match(/^([A-Z][a-z]*)\d+$/) ) {
+ return 'id';
+ }
+ else if ( word.match(/^\d+$/) ) {
+ return 'integer';
+ }
+ else if ( word.match(/^doi:.+$/) ) {
+ return 'doi';
+ }
+ else if ( word.match(/^pmid:.+$/) ) {
+ return 'pubmed';
+ }
+ else {
+ return 'word';
+ }
+};
+
+// redirects to the phylows api
+TreeBASE.redirect = function(newLocation){
+ window.location = newLocation;
+ return false;
+};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rv...@us...> - 2012-02-20 21:59:06
|
Revision: 1080
http://treebase.svn.sourceforge.net/treebase/?rev=1080&view=rev
Author: rvos
Date: 2012-02-20 21:59:00 +0000 (Mon, 20 Feb 2012)
Log Message:
-----------
Splitting query string on commas instead
Modified Paths:
--------------
trunk/treebase-web/src/main/webapp/scripts/common.js
Modified: trunk/treebase-web/src/main/webapp/scripts/common.js
===================================================================
--- trunk/treebase-web/src/main/webapp/scripts/common.js 2012-02-20 21:39:26 UTC (rev 1079)
+++ trunk/treebase-web/src/main/webapp/scripts/common.js 2012-02-20 21:59:00 UTC (rev 1080)
@@ -244,7 +244,8 @@
// splits a string on words (including curies) and quoted phrases
TreeBASE.splitWords = function(query){
- return query.match(/[A-Za-z0-9:]+|"[^"]+"|'[^']+'/g);
+ //return query.match(/[A-Za-z0-9: ]+|"[^"]+"|'[^']+'|/g);
+ return query.split(",");
};
// infers whether a search word is an identifier or a string
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rv...@us...> - 2012-02-21 09:59:15
|
Revision: 1081
http://treebase.svn.sourceforge.net/treebase/?rev=1081&view=rev
Author: rvos
Date: 2012-02-21 09:59:04 +0000 (Tue, 21 Feb 2012)
Log Message:
-----------
TreeBASE.splitWords() now splits on commas, afterwords double-quotes words with spaces in them.
Modified Paths:
--------------
trunk/treebase-web/src/main/webapp/scripts/common.js
Modified: trunk/treebase-web/src/main/webapp/scripts/common.js
===================================================================
--- trunk/treebase-web/src/main/webapp/scripts/common.js 2012-02-20 21:59:00 UTC (rev 1080)
+++ trunk/treebase-web/src/main/webapp/scripts/common.js 2012-02-21 09:59:04 UTC (rev 1081)
@@ -242,10 +242,21 @@
return false;
};
-// splits a string on words (including curies) and quoted phrases
+// splits a string on commas, strip leading and trailing white space, quote words with spaces in them
TreeBASE.splitWords = function(query){
- //return query.match(/[A-Za-z0-9: ]+|"[^"]+"|'[^']+'|/g);
- return query.split(",");
+ var words = query.split(",");
+ var split = new Array();
+ for ( var i = 0; i < words.length; i++ ) {
+ var word = words[i].replace(/^ */,'');
+ word = word.replace(/ *$/,'';)
+ if ( word.match(/ /) ) {
+ split.push('"' + word + '"');
+ }
+ else {
+ split.push(word);
+ }
+ }
+ return split;
};
// infers whether a search word is an identifier or a string
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rv...@us...> - 2012-02-21 10:00:19
|
Revision: 1082
http://treebase.svn.sourceforge.net/treebase/?rev=1082&view=rev
Author: rvos
Date: 2012-02-21 10:00:10 +0000 (Tue, 21 Feb 2012)
Log Message:
-----------
Don't quote words that are already quoted.
Modified Paths:
--------------
trunk/treebase-web/src/main/webapp/scripts/common.js
Modified: trunk/treebase-web/src/main/webapp/scripts/common.js
===================================================================
--- trunk/treebase-web/src/main/webapp/scripts/common.js 2012-02-21 09:59:04 UTC (rev 1081)
+++ trunk/treebase-web/src/main/webapp/scripts/common.js 2012-02-21 10:00:10 UTC (rev 1082)
@@ -249,7 +249,7 @@
for ( var i = 0; i < words.length; i++ ) {
var word = words[i].replace(/^ */,'');
word = word.replace(/ *$/,'';)
- if ( word.match(/ /) ) {
+ if ( word.match(/ /) && ! word.match(/^".*"$/) ) {
split.push('"' + word + '"');
}
else {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rv...@us...> - 2012-02-21 10:16:56
|
Revision: 1083
http://treebase.svn.sourceforge.net/treebase/?rev=1083&view=rev
Author: rvos
Date: 2012-02-21 10:16:47 +0000 (Tue, 21 Feb 2012)
Log Message:
-----------
Typo fix, trivial commit.
Modified Paths:
--------------
trunk/treebase-web/src/main/webapp/scripts/common.js
Modified: trunk/treebase-web/src/main/webapp/scripts/common.js
===================================================================
--- trunk/treebase-web/src/main/webapp/scripts/common.js 2012-02-21 10:00:10 UTC (rev 1082)
+++ trunk/treebase-web/src/main/webapp/scripts/common.js 2012-02-21 10:16:47 UTC (rev 1083)
@@ -248,7 +248,7 @@
var split = new Array();
for ( var i = 0; i < words.length; i++ ) {
var word = words[i].replace(/^ */,'');
- word = word.replace(/ *$/,'';)
+ word = word.replace(/ *$/,'');
if ( word.match(/ /) && ! word.match(/^".*"$/) ) {
split.push('"' + word + '"');
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|