Mercurial > repos > yating-l > hac
annotate doc/_build/html/_static/searchtools.js @ 0:0bca8a6364a7 draft default tip
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
| author | yating-l | 
|---|---|
| date | Wed, 21 Dec 2016 17:21:18 -0500 | 
| parents | |
| children | 
| rev | line source | 
|---|---|
| 0 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 1 /* | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 2 * searchtools.js_t | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 3 * ~~~~~~~~~~~~~~~~ | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 4 * | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 5 * Sphinx JavaScript utilities for the full-text search. | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 6 * | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 7 * :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS. | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 8 * :license: BSD, see LICENSE for details. | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 9 * | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 10 */ | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 11 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 12 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 13 /* Non-minified version JS is _stemmer.js if file is provided */ | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 14 /** | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 15 * Porter Stemmer | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 16 */ | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 17 var Stemmer = function() { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 18 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 19 var step2list = { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 20 ational: 'ate', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 21 tional: 'tion', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 22 enci: 'ence', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 23 anci: 'ance', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 24 izer: 'ize', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 25 bli: 'ble', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 26 alli: 'al', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 27 entli: 'ent', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 28 eli: 'e', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 29 ousli: 'ous', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 30 ization: 'ize', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 31 ation: 'ate', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 32 ator: 'ate', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 33 alism: 'al', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 34 iveness: 'ive', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 35 fulness: 'ful', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 36 ousness: 'ous', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 37 aliti: 'al', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 38 iviti: 'ive', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 39 biliti: 'ble', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 40 logi: 'log' | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 41 }; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 42 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 43 var step3list = { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 44 icate: 'ic', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 45 ative: '', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 46 alize: 'al', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 47 iciti: 'ic', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 48 ical: 'ic', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 49 ful: '', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 50 ness: '' | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 51 }; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 52 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 53 var c = "[^aeiou]"; // consonant | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 54 var v = "[aeiouy]"; // vowel | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 55 var C = c + "[^aeiouy]*"; // consonant sequence | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 56 var V = v + "[aeiou]*"; // vowel sequence | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 57 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 58 var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 59 var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 60 var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 61 var s_v = "^(" + C + ")?" + v; // vowel in stem | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 62 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 63 this.stemWord = function (w) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 64 var stem; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 65 var suffix; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 66 var firstch; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 67 var origword = w; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 68 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 69 if (w.length < 3) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 70 return w; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 71 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 72 var re; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 73 var re2; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 74 var re3; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 75 var re4; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 76 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 77 firstch = w.substr(0,1); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 78 if (firstch == "y") | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 79 w = firstch.toUpperCase() + w.substr(1); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 80 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 81 // Step 1a | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 82 re = /^(.+?)(ss|i)es$/; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 83 re2 = /^(.+?)([^s])s$/; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 84 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 85 if (re.test(w)) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 86 w = w.replace(re,"$1$2"); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 87 else if (re2.test(w)) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 88 w = w.replace(re2,"$1$2"); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 89 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 90 // Step 1b | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 91 re = /^(.+?)eed$/; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 92 re2 = /^(.+?)(ed|ing)$/; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 93 if (re.test(w)) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 94 var fp = re.exec(w); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 95 re = new RegExp(mgr0); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 96 if (re.test(fp[1])) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 97 re = /.$/; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 98 w = w.replace(re,""); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 99 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 100 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 101 else if (re2.test(w)) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 102 var fp = re2.exec(w); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 103 stem = fp[1]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 104 re2 = new RegExp(s_v); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 105 if (re2.test(stem)) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 106 w = stem; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 107 re2 = /(at|bl|iz)$/; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 108 re3 = new RegExp("([^aeiouylsz])\\1$"); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 109 re4 = new RegExp("^" + C + v + "[^aeiouwxy]$"); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 110 if (re2.test(w)) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 111 w = w + "e"; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 112 else if (re3.test(w)) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 113 re = /.$/; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 114 w = w.replace(re,""); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 115 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 116 else if (re4.test(w)) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 117 w = w + "e"; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 118 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 119 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 120 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 121 // Step 1c | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 122 re = /^(.+?)y$/; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 123 if (re.test(w)) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 124 var fp = re.exec(w); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 125 stem = fp[1]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 126 re = new RegExp(s_v); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 127 if (re.test(stem)) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 128 w = stem + "i"; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 129 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 130 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 131 // Step 2 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 132 re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 133 if (re.test(w)) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 134 var fp = re.exec(w); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 135 stem = fp[1]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 136 suffix = fp[2]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 137 re = new RegExp(mgr0); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 138 if (re.test(stem)) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 139 w = stem + step2list[suffix]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 140 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 141 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 142 // Step 3 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 143 re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 144 if (re.test(w)) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 145 var fp = re.exec(w); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 146 stem = fp[1]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 147 suffix = fp[2]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 148 re = new RegExp(mgr0); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 149 if (re.test(stem)) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 150 w = stem + step3list[suffix]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 151 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 152 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 153 // Step 4 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 154 re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 155 re2 = /^(.+?)(s|t)(ion)$/; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 156 if (re.test(w)) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 157 var fp = re.exec(w); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 158 stem = fp[1]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 159 re = new RegExp(mgr1); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 160 if (re.test(stem)) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 161 w = stem; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 162 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 163 else if (re2.test(w)) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 164 var fp = re2.exec(w); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 165 stem = fp[1] + fp[2]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 166 re2 = new RegExp(mgr1); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 167 if (re2.test(stem)) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 168 w = stem; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 169 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 170 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 171 // Step 5 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 172 re = /^(.+?)e$/; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 173 if (re.test(w)) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 174 var fp = re.exec(w); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 175 stem = fp[1]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 176 re = new RegExp(mgr1); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 177 re2 = new RegExp(meq1); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 178 re3 = new RegExp("^" + C + v + "[^aeiouwxy]$"); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 179 if (re.test(stem) || (re2.test(stem) && !(re3.test(stem)))) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 180 w = stem; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 181 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 182 re = /ll$/; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 183 re2 = new RegExp(mgr1); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 184 if (re.test(w) && re2.test(w)) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 185 re = /.$/; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 186 w = w.replace(re,""); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 187 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 188 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 189 // and turn initial Y back to y | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 190 if (firstch == "y") | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 191 w = firstch.toLowerCase() + w.substr(1); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 192 return w; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 193 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 194 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 195 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 196 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 197 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 198 /** | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 199 * Simple result scoring code. | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 200 */ | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 201 var Scorer = { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 202 // Implement the following function to further tweak the score for each result | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 203 // The function takes a result array [filename, title, anchor, descr, score] | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 204 // and returns the new score. | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 205 /* | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 206 score: function(result) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 207 return result[4]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 208 }, | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 209 */ | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 210 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 211 // query matches the full name of an object | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 212 objNameMatch: 11, | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 213 // or matches in the last dotted part of the object name | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 214 objPartialMatch: 6, | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 215 // Additive scores depending on the priority of the object | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 216 objPrio: {0: 15, // used to be importantResults | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 217 1: 5, // used to be objectResults | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 218 2: -5}, // used to be unimportantResults | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 219 // Used when the priority is not in the mapping. | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 220 objPrioDefault: 0, | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 221 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 222 // query found in title | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 223 title: 15, | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 224 // query found in terms | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 225 term: 5 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 226 }; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 227 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 228 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 229 /** | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 230 * Search Module | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 231 */ | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 232 var Search = { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 233 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 234 _index : null, | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 235 _queued_query : null, | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 236 _pulse_status : -1, | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 237 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 238 init : function() { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 239 var params = $.getQueryParameters(); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 240 if (params.q) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 241 var query = params.q[0]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 242 $('input[name="q"]')[0].value = query; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 243 this.performSearch(query); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 244 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 245 }, | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 246 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 247 loadIndex : function(url) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 248 $.ajax({type: "GET", url: url, data: null, | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 249 dataType: "script", cache: true, | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 250 complete: function(jqxhr, textstatus) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 251 if (textstatus != "success") { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 252 document.getElementById("searchindexloader").src = url; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 253 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 254 }}); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 255 }, | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 256 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 257 setIndex : function(index) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 258 var q; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 259 this._index = index; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 260 if ((q = this._queued_query) !== null) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 261 this._queued_query = null; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 262 Search.query(q); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 263 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 264 }, | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 265 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 266 hasIndex : function() { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 267 return this._index !== null; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 268 }, | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 269 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 270 deferQuery : function(query) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 271 this._queued_query = query; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 272 }, | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 273 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 274 stopPulse : function() { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 275 this._pulse_status = 0; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 276 }, | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 277 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 278 startPulse : function() { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 279 if (this._pulse_status >= 0) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 280 return; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 281 function pulse() { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 282 var i; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 283 Search._pulse_status = (Search._pulse_status + 1) % 4; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 284 var dotString = ''; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 285 for (i = 0; i < Search._pulse_status; i++) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 286 dotString += '.'; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 287 Search.dots.text(dotString); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 288 if (Search._pulse_status > -1) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 289 window.setTimeout(pulse, 500); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 290 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 291 pulse(); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 292 }, | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 293 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 294 /** | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 295 * perform a search for something (or wait until index is loaded) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 296 */ | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 297 performSearch : function(query) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 298 // create the required interface elements | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 299 this.out = $('#search-results'); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 300 this.title = $('<h2>' + _('Searching') + '</h2>').appendTo(this.out); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 301 this.dots = $('<span></span>').appendTo(this.title); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 302 this.status = $('<p style="display: none"></p>').appendTo(this.out); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 303 this.output = $('<ul class="search"/>').appendTo(this.out); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 304 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 305 $('#search-progress').text(_('Preparing search...')); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 306 this.startPulse(); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 307 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 308 // index already loaded, the browser was quick! | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 309 if (this.hasIndex()) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 310 this.query(query); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 311 else | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 312 this.deferQuery(query); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 313 }, | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 314 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 315 /** | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 316 * execute search (requires search index to be loaded) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 317 */ | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 318 query : function(query) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 319 var i; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 320 var stopwords = ["a","and","are","as","at","be","but","by","for","if","in","into","is","it","near","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 321 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 322 // stem the searchterms and add them to the correct list | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 323 var stemmer = new Stemmer(); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 324 var searchterms = []; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 325 var excluded = []; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 326 var hlterms = []; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 327 var tmp = query.split(/\W+/); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 328 var objectterms = []; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 329 for (i = 0; i < tmp.length; i++) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 330 if (tmp[i] !== "") { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 331 objectterms.push(tmp[i].toLowerCase()); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 332 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 333 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 334 if ($u.indexOf(stopwords, tmp[i].toLowerCase()) != -1 || tmp[i].match(/^\d+$/) || | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 335 tmp[i] === "") { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 336 // skip this "word" | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 337 continue; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 338 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 339 // stem the word | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 340 var word = stemmer.stemWord(tmp[i].toLowerCase()); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 341 var toAppend; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 342 // select the correct list | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 343 if (word[0] == '-') { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 344 toAppend = excluded; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 345 word = word.substr(1); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 346 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 347 else { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 348 toAppend = searchterms; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 349 hlterms.push(tmp[i].toLowerCase()); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 350 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 351 // only add if not already in the list | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 352 if (!$u.contains(toAppend, word)) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 353 toAppend.push(word); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 354 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 355 var highlightstring = '?highlight=' + $.urlencode(hlterms.join(" ")); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 356 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 357 // console.debug('SEARCH: searching for:'); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 358 // console.info('required: ', searchterms); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 359 // console.info('excluded: ', excluded); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 360 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 361 // prepare search | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 362 var terms = this._index.terms; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 363 var titleterms = this._index.titleterms; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 364 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 365 // array of [filename, title, anchor, descr, score] | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 366 var results = []; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 367 $('#search-progress').empty(); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 368 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 369 // lookup as object | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 370 for (i = 0; i < objectterms.length; i++) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 371 var others = [].concat(objectterms.slice(0, i), | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 372 objectterms.slice(i+1, objectterms.length)); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 373 results = results.concat(this.performObjectSearch(objectterms[i], others)); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 374 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 375 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 376 // lookup as search terms in fulltext | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 377 results = results.concat(this.performTermsSearch(searchterms, excluded, terms, titleterms)); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 378 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 379 // let the scorer override scores with a custom scoring function | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 380 if (Scorer.score) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 381 for (i = 0; i < results.length; i++) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 382 results[i][4] = Scorer.score(results[i]); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 383 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 384 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 385 // now sort the results by score (in opposite order of appearance, since the | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 386 // display function below uses pop() to retrieve items) and then | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 387 // alphabetically | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 388 results.sort(function(a, b) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 389 var left = a[4]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 390 var right = b[4]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 391 if (left > right) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 392 return 1; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 393 } else if (left < right) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 394 return -1; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 395 } else { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 396 // same score: sort alphabetically | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 397 left = a[1].toLowerCase(); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 398 right = b[1].toLowerCase(); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 399 return (left > right) ? -1 : ((left < right) ? 1 : 0); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 400 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 401 }); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 402 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 403 // for debugging | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 404 //Search.lastresults = results.slice(); // a copy | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 405 //console.info('search results:', Search.lastresults); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 406 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 407 // print the results | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 408 var resultCount = results.length; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 409 function displayNextItem() { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 410 // results left, load the summary and display it | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 411 if (results.length) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 412 var item = results.pop(); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 413 var listItem = $('<li style="display:none"></li>'); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 414 if (DOCUMENTATION_OPTIONS.FILE_SUFFIX === '') { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 415 // dirhtml builder | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 416 var dirname = item[0] + '/'; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 417 if (dirname.match(/\/index\/$/)) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 418 dirname = dirname.substring(0, dirname.length-6); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 419 } else if (dirname == 'index/') { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 420 dirname = ''; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 421 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 422 listItem.append($('<a/>').attr('href', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 423 DOCUMENTATION_OPTIONS.URL_ROOT + dirname + | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 424 highlightstring + item[2]).html(item[1])); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 425 } else { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 426 // normal html builders | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 427 listItem.append($('<a/>').attr('href', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 428 item[0] + DOCUMENTATION_OPTIONS.FILE_SUFFIX + | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 429 highlightstring + item[2]).html(item[1])); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 430 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 431 if (item[3]) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 432 listItem.append($('<span> (' + item[3] + ')</span>')); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 433 Search.output.append(listItem); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 434 listItem.slideDown(5, function() { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 435 displayNextItem(); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 436 }); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 437 } else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 438 $.ajax({url: DOCUMENTATION_OPTIONS.URL_ROOT + '_sources/' + item[0] + '.txt', | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 439 dataType: "text", | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 440 complete: function(jqxhr, textstatus) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 441 var data = jqxhr.responseText; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 442 if (data !== '' && data !== undefined) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 443 listItem.append(Search.makeSearchSummary(data, searchterms, hlterms)); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 444 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 445 Search.output.append(listItem); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 446 listItem.slideDown(5, function() { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 447 displayNextItem(); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 448 }); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 449 }}); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 450 } else { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 451 // no source available, just display title | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 452 Search.output.append(listItem); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 453 listItem.slideDown(5, function() { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 454 displayNextItem(); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 455 }); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 456 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 457 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 458 // search finished, update title and status message | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 459 else { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 460 Search.stopPulse(); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 461 Search.title.text(_('Search Results')); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 462 if (!resultCount) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 463 Search.status.text(_('Your search did not match any documents. Please make sure that all words are spelled correctly and that you\'ve selected enough categories.')); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 464 else | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 465 Search.status.text(_('Search finished, found %s page(s) matching the search query.').replace('%s', resultCount)); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 466 Search.status.fadeIn(500); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 467 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 468 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 469 displayNextItem(); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 470 }, | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 471 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 472 /** | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 473 * search for object names | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 474 */ | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 475 performObjectSearch : function(object, otherterms) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 476 var filenames = this._index.filenames; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 477 var objects = this._index.objects; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 478 var objnames = this._index.objnames; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 479 var titles = this._index.titles; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 480 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 481 var i; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 482 var results = []; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 483 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 484 for (var prefix in objects) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 485 for (var name in objects[prefix]) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 486 var fullname = (prefix ? prefix + '.' : '') + name; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 487 if (fullname.toLowerCase().indexOf(object) > -1) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 488 var score = 0; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 489 var parts = fullname.split('.'); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 490 // check for different match types: exact matches of full name or | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 491 // "last name" (i.e. last dotted part) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 492 if (fullname == object || parts[parts.length - 1] == object) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 493 score += Scorer.objNameMatch; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 494 // matches in last name | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 495 } else if (parts[parts.length - 1].indexOf(object) > -1) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 496 score += Scorer.objPartialMatch; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 497 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 498 var match = objects[prefix][name]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 499 var objname = objnames[match[1]][2]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 500 var title = titles[match[0]]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 501 // If more than one term searched for, we require other words to be | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 502 // found in the name/title/description | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 503 if (otherterms.length > 0) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 504 var haystack = (prefix + ' ' + name + ' ' + | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 505 objname + ' ' + title).toLowerCase(); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 506 var allfound = true; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 507 for (i = 0; i < otherterms.length; i++) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 508 if (haystack.indexOf(otherterms[i]) == -1) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 509 allfound = false; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 510 break; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 511 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 512 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 513 if (!allfound) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 514 continue; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 515 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 516 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 517 var descr = objname + _(', in ') + title; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 518 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 519 var anchor = match[3]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 520 if (anchor === '') | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 521 anchor = fullname; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 522 else if (anchor == '-') | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 523 anchor = objnames[match[1]][1] + '-' + fullname; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 524 // add custom score for some objects according to scorer | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 525 if (Scorer.objPrio.hasOwnProperty(match[2])) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 526 score += Scorer.objPrio[match[2]]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 527 } else { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 528 score += Scorer.objPrioDefault; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 529 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 530 results.push([filenames[match[0]], fullname, '#'+anchor, descr, score]); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 531 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 532 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 533 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 534 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 535 return results; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 536 }, | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 537 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 538 /** | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 539 * search for full-text terms in the index | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 540 */ | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 541 performTermsSearch : function(searchterms, excluded, terms, titleterms) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 542 var filenames = this._index.filenames; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 543 var titles = this._index.titles; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 544 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 545 var i, j, file; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 546 var fileMap = {}; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 547 var scoreMap = {}; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 548 var results = []; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 549 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 550 // perform the search on the required terms | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 551 for (i = 0; i < searchterms.length; i++) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 552 var word = searchterms[i]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 553 var files = []; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 554 var _o = [ | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 555 {files: terms[word], score: Scorer.term}, | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 556 {files: titleterms[word], score: Scorer.title} | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 557 ]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 558 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 559 // no match but word was a required one | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 560 if ($u.every(_o, function(o){return o.files === undefined;})) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 561 break; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 562 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 563 // found search word in contents | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 564 $u.each(_o, function(o) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 565 var _files = o.files; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 566 if (_files === undefined) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 567 return | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 568 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 569 if (_files.length === undefined) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 570 _files = [_files]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 571 files = files.concat(_files); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 572 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 573 // set score for the word in each file to Scorer.term | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 574 for (j = 0; j < _files.length; j++) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 575 file = _files[j]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 576 if (!(file in scoreMap)) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 577 scoreMap[file] = {} | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 578 scoreMap[file][word] = o.score; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 579 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 580 }); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 581 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 582 // create the mapping | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 583 for (j = 0; j < files.length; j++) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 584 file = files[j]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 585 if (file in fileMap) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 586 fileMap[file].push(word); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 587 else | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 588 fileMap[file] = [word]; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 589 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 590 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 591 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 592 // now check if the files don't contain excluded terms | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 593 for (file in fileMap) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 594 var valid = true; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 595 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 596 // check if all requirements are matched | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 597 if (fileMap[file].length != searchterms.length) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 598 continue; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 599 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 600 // ensure that none of the excluded terms is in the search result | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 601 for (i = 0; i < excluded.length; i++) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 602 if (terms[excluded[i]] == file || | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 603 titleterms[excluded[i]] == file || | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 604 $u.contains(terms[excluded[i]] || [], file) || | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 605 $u.contains(titleterms[excluded[i]] || [], file)) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 606 valid = false; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 607 break; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 608 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 609 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 610 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 611 // if we have still a valid result we can add it to the result list | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 612 if (valid) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 613 // select one (max) score for the file. | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 614 // for better ranking, we should calculate ranking by using words statistics like basic tf-idf... | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 615 var score = $u.max($u.map(fileMap[file], function(w){return scoreMap[file][w]})); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 616 results.push([filenames[file], titles[file], '', null, score]); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 617 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 618 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 619 return results; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 620 }, | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 621 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 622 /** | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 623 * helper function to return a node containing the | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 624 * search summary for a given text. keywords is a list | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 625 * of stemmed words, hlwords is the list of normal, unstemmed | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 626 * words. the first one is used to find the occurrence, the | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 627 * latter for highlighting it. | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 628 */ | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 629 makeSearchSummary : function(text, keywords, hlwords) { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 630 var textLower = text.toLowerCase(); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 631 var start = 0; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 632 $.each(keywords, function() { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 633 var i = textLower.indexOf(this.toLowerCase()); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 634 if (i > -1) | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 635 start = i; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 636 }); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 637 start = Math.max(start - 120, 0); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 638 var excerpt = ((start > 0) ? '...' : '') + | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 639 $.trim(text.substr(start, 240)) + | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 640 ((start + 240 - text.length) ? '...' : ''); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 641 var rv = $('<div class="context"></div>').text(excerpt); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 642 $.each(hlwords, function() { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 643 rv = rv.highlightText(this, 'highlighted'); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 644 }); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 645 return rv; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 646 } | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 647 }; | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 648 | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 649 $(document).ready(function() { | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 650 Search.init(); | 
| 
0bca8a6364a7
planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
 yating-l parents: diff
changeset | 651 }); | 
