- Timestamp:
- 10/21/15 14:12:37 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vlo/branches/vlo-3.3/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/HighlightSearchTermScriptFactory.java
r6691 r6694 27 27 public class HighlightSearchTermScriptFactory implements Serializable { 28 28 29 p rivate static final String HIGHLIGHT_FUNCTION = "$('%s').highlight(%s, {className:'%s'})";29 public static final String HIGHLIGHT_FUNCTION = "$('%s').highlight(%s, {className:'%s', wordsOnly: %s})"; 30 30 31 private static final Collection<String> DEFAULT_EXCLUDE_WORDS = ImmutableSet.of("and", "or", "not", "to"); 31 public static final Collection<String> DEFAULT_EXCLUDE_WORDS = ImmutableSet.of("and", "or", "not", "to"); 32 33 public static final String DEFAULT_CSS_CLASS = "searchword"; 32 34 33 35 public String createScript(String componentSelector, final String words) { 36 return createScript(componentSelector, words, DEFAULT_CSS_CLASS); 37 } 38 39 public String createScript(String componentSelector, final String words, String cssClass) { 34 40 return String.format(HIGHLIGHT_FUNCTION, 35 41 componentSelector, 36 42 makeWordListArray(words), 37 getSearchWordClass() 43 cssClass, 44 matchWordsOnly(words) 38 45 ); 46 } 47 48 protected boolean matchWordsOnly(String query) { 49 // string with asterixes or question marks should match by character 50 return !query.matches(".*[\\*\\?].*"); 39 51 } 40 52 … … 78 90 //or boosting values 79 91 + "|['\"]?\\^.*" 80 + ")$", 92 + ")$" 93 //also remove wildcard characters 94 + "|[\\?\\*]", 81 95 //replace with empty string 82 96 ""); 83 }84 85 /**86 *87 * @return CSS class to mark matches with88 */89 protected String getSearchWordClass() {90 return "searchword";91 97 } 92 98
Note: See TracChangeset
for help on using the changeset viewer.