Changeset 22304 for extensions/rv_autocomplete/res/suggest-core.js
- Timestamp:
- Apr 20, 2013, 6:49:01 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/rv_autocomplete/res/suggest-core.js
r22246 r22304 119 119 inew++; 120 120 } 121 121 122 122 var inp = $("#qsearchInput"); 123 123 if (data.length && inp.is(":focus")) { … … 191 191 } 192 192 193 if (res.length > RVAC.suggestions) {//try filter 194 // compute number of matched "words" or "expressions" 195 found={}; 196 var foundWords=0, word; 197 for (i=0; i<res.length; i++) { 198 word = res[i]._matchWord = ac_match_word( res[i], this.options.rv.q ); 199 if (!found.hasOwnProperty(word)) { 200 foundWords++; 201 found[word]=1; 202 if (foundWords == RVAC.maxSuggestions) 203 res = res.slice(0, i+1); 204 } 205 else 206 found[word]++; 207 } 208 209 if (foundWords==1) 210 res = res.slice(0, RVAC.maxSuggestions); 211 else if (foundWords > RVAC.suggestions) { 212 for (i=1; i<foundWords; i++) { 213 word = res[i]._matchWord; 214 if ( found[word] > 1 ) { 215 for (j=i-1; j>=0; j--) { 216 if (res[j]._matchWord == word) { 217 res.splice(i--, 1); 218 found[word]--; 219 break; 220 } 193 // compute number of matched "words" or "expressions" 194 found={}; 195 var foundWords=0, word; 196 for (i=0; i<res.length; i++) { 197 word = res[i]._matchWord = ac_match_word( res[i], this.options.rv.q ); 198 if (!found.hasOwnProperty(word)) { 199 foundWords++; 200 found[word]=1; 201 if (foundWords == RVAC.maxSuggestions) 202 res = res.slice(0, i+1); 203 } 204 else 205 found[word]++; 206 } 207 208 if (foundWords==1) 209 res = res.slice(0, RVAC.maxSuggestions); 210 else if (foundWords > RVAC.suggestions) { 211 for (i=1; i<foundWords; i++) { 212 word = res[i]._matchWord; 213 if ( found[word] > 1 ) { 214 for (j=i-1; j>=0; j--) { 215 if (res[j]._matchWord == word) { 216 res.splice(i--, 1); 217 found[word]--; 218 break; 221 219 } 222 220 } 223 221 } 224 res = res.slice(0, foundWords);225 }226 else {227 for (i=res.length-1; i>=0 && res.length > RVAC.suggestions; i--){228 word = res[i]._matchWord;229 for (j=i-1; j>=0; j--) {230 if (res[j]._matchWord == word) {231 res.splice(i, 1);232 break;233 }234 }235 } 236 } 237 } 238 239 var that = this;222 } 223 res = res.slice(0, foundWords); 224 } 225 else { 226 for (i=res.length-1; i>=0 && res.length > RVAC.suggestions; i--) { 227 word = res[i]._matchWord; 228 for (j=i-1; j>=0; j--) { 229 if (res[j]._matchWord == word) { 230 res.splice(i, 1); 231 break; 232 } 233 } 234 } 235 } 236 237 // check for multi tags 240 238 if (!RVAC.requestingContexts && this.options.rv.q.length > 1) { 241 239 var eligible = $.grep( res, function(item) { 242 240 if (item._matchIdx > 0 243 || item.w <= 25241 || item.w <= RVAC.minWeightForContextTrigger 244 242 || item.value === -1 245 243 || item.value[0]!="$" || item.value[1]!="t") … … 247 245 if (RVAC.requestedContexts.hasOwnProperty(item.value)) 248 246 return 0; 249 if (item.q.length - that.options.rv.q.length > 3)250 return 0;251 247 return 1; 252 248 } ); 249 250 if (eligible.length==1) { 251 if (res.length > RVAC.suggestions || foundWords>1) { 252 if (this.options.rv.q.length <= eligible[0].q.length/2 ) 253 eligible.length = 0; 254 } 255 } 256 else { 257 for (i=0; i<eligible.length; i++) 258 if (this.options.rv.q.length == eligible[i].q.length) { 259 eligible = [ eligible[i] ]; 260 break; 261 } 262 263 if (eligible.length > 1) 264 eligible.length = 0; 265 } 253 266 254 267 if (eligible.length) {
Note: See TracChangeset
for help on using the changeset viewer.