function checkTheInputString()

in content/flexunit/asdoc/cilistener/help.js [521:593]


function checkTheInputString()
{
	var myArr = new Array();
	var tempArr = new Array();
	var foundStopOrShortWord = 0;
	var ptn1 = /\d\D/;
	var ptn2 = /\D\d/;

	handleWhitespaceRemoval();
	searchTerm = searchTerm.replace (/(%20)+/g," ") ;
	searchTerm = searchTerm.toLowerCase();

	searchTerm = filterTheChars(searchTerm);
		
	handleWhitespaceRemoval();

	if( searchTerm.length ) {
		
		// Split the searchTerm
			tempArr = searchTerm.split(" ",100);
			if(showInputStringAlerts){alert( "size of tempArr: " + tempArr.length );}

		// Handle periods
			for( var ndx = 0; ndx < tempArr.length; ndx++ ) {
				if( tempArr[ndx].charCodeAt(0) == 46 ) {	// periods at the start of word
					//tempArr[ndx] = tempArr[ndx].substr(1); // NOTE: We don't want to do this. (e.g. ".txt")
				}
				if( tempArr[ndx].charCodeAt(tempArr[ndx].length-1) == 46 ) { // end of word
					tempArr[ndx] = tempArr[ndx].substr(0,tempArr[ndx].length-1);
				}
			}
			
		// Do stopwords and shortwords removal
			for( var ndx = 0; ndx < tempArr.length; ndx++ ) {
				var word = tempArr[ndx];
				if(showInputStringAlerts){alert( "Checking word: " + word );}
				
				if( ! sw[word] ) {
					if( word.length < 2 ) {
						foundStopOrShortWord = 1;
					}
					else if( (word.length > 2) || (ptn1.test(word) || ptn2.test(word)) ) {
						myArr[myArr.length] = tempArr[ndx];
					}
					else {
						foundStopOrShortWord = 1;
					}
				}
				else {
					foundStopOrShortWord = 1;
				}
			}

		// Now reconstruct the searchTerm, based upon the 'myArr'
			searchTerm = "";
			for( var ndx = 0; ndx < myArr.length; ndx++ ) {
				searchTerm = searchTerm + myArr[ndx] + " ";
			}

		handleWhitespaceRemoval();

		if(showInputStringAlerts){alert( "FINAL SEARCH TERM: *" + searchTerm + "*" );}
			
		if( foundStopOrShortWord && ! searchTerm.length ) {
			return MSG_stopAndShortWords;
		}
		srch_input_massaged = searchTerm;
		return "";
	} 
	else {
		return MSG_noSearchTermEntered;
	}
}