|
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.
|