implement OR operator for text search
Этот коммит содержится в:
		
							родитель
							
								
									d7fd372826
								
							
						
					
					
						Коммит
						a4c655ef36
					
				
										
											
												Различия файлов скрыты, потому что одна или несколько строк слишком длинны
											
										
									
								
							
										
											
												Различия файлов скрыты, потому что одна или несколько строк слишком длинны
											
										
									
								
							
										
											
												Различия файлов скрыты, потому что одна или несколько строк слишком длинны
											
										
									
								
							| @ -53,7 +53,7 @@ | ||||
| 
 | ||||
|   function highlight(s) { | ||||
|     if (!$textSearchFilter || $textSearchFilter === '') return s; | ||||
|     return s.replace(new RegExp($textSearchFilter, 'gi'), (match) => `<span class="highlighted">${match}</span>`); | ||||
|     return s.replace(new RegExp($textSearchFilter.toLowerCase().split(' or ').join('|'), 'gi'), (match) => `<span class="highlighted">${match}</span>`); | ||||
|   } | ||||
| 
 | ||||
|   $: if (showTooltip) { | ||||
|  | ||||
| @ -75,7 +75,7 @@ | ||||
|             .map((d) => ({ | ||||
|               ...d, | ||||
|               recentylAdded: Math.ceil(((new Date()) - d.timestamp) / (1000 * 60 * 60 * 24)) <= observeDays, | ||||
|               search: [d.shortTitle, d.shortDescription, d.platforms, d.methods, d.sourceNation, d.source, d.sourceCategory].flat().join('__').toUpperCase(), | ||||
|               search: [d.shortTitle, d.shortDescription, d.platforms, d.methods, d.sourceNation, d.source, d.sourceCategory].flat().join('__').toLowerCase(), | ||||
|               show: false | ||||
|             })); | ||||
| 
 | ||||
|  | ||||
| @ -42,7 +42,13 @@ export const haveOverlap = (filter, arr) => | ||||
| export const withinRange = (arr, num) => num >= arr[0] && num <= arr[1]; | ||||
| 
 | ||||
| // check, if a search string (filter) is included in a string
 | ||||
| export const includesTextSearch = (filter, s) => s.indexOf(filter.toUpperCase()) > -1; | ||||
| export const includesTextSearch = (filter, s) => { | ||||
|   const filterArr = filter.toLowerCase().split(' or '); | ||||
|   if (filterArr.length === 0) return true; | ||||
|   return filterArr.some((f) => { | ||||
|     return s.indexOf(f) > -1; | ||||
|   }); | ||||
| }; | ||||
| 
 | ||||
| // check if case id filter is set and if id is matching
 | ||||
| export const isCaseId = (filter, id) => filter === undefined ? true : (filter === id); | ||||
|  | ||||
| @ -11,7 +11,7 @@ export const urlFromFilters = (disinformantNations, | ||||
|                                contextData, | ||||
|                                caseId = '') => { | ||||
|   const params = { | ||||
|     ts: textSearch, | ||||
|     ts: encodeURIComponent(textSearch), | ||||
|     as: [attributionScores[0], attributionScores[1]].join(';'), | ||||
|     f: filtersToHex([disinformantNations, platforms, methods, sources, sourceCategories, contextData]), | ||||
|     id: caseId | ||||
| @ -43,7 +43,7 @@ export const parseUrl = (hash) => { | ||||
|     sourceCategories: binaryToBool(hexToBinary(sourceCategories)), | ||||
|     contextData: binaryToBool(hexToBinary(contextData)), | ||||
|     caseId: caseId === '' ? undefined : +caseId, | ||||
|     textSearch, | ||||
|     textSearch: decodeURIComponent(textSearch), | ||||
|     attributionScores: attributionScores.split(';').map((d) => +d) | ||||
|   }; | ||||
| };  | ||||
|  | ||||
		Загрузка…
	
	
			
			x
			
			
		
	
		Ссылка в новой задаче
	
	Block a user
	 higsch
						higsch