(s_host, s_para)
| 1040 | } |
| 1041 | |
| 1042 | function search_score(s_host, s_para) |
| 1043 | { |
| 1044 | if (s_para=="") return 0; |
| 1045 | var n_score=0; |
| 1046 | var n_words_matched=0; |
| 1047 | if (s_host==s_para) n_score+=10000; |
| 1048 | if (s_host.indexOf(s_para)>=0) n_score+=2000; // exact match |
| 1049 | s_hw=s_host.split(" "); |
| 1050 | s_pw=s_para.split(" "); |
| 1051 | s_hw=remove_duplicate_words(s_hw); |
| 1052 | s_pw=remove_duplicate_words(s_pw); |
| 1053 | var i=0,j=0; |
| 1054 | for (i=0;i<s_hw.length;i++) |
| 1055 | { |
| 1056 | for (j=0;j<s_pw.length;j++) |
| 1057 | { |
| 1058 | if (s_hw[i]==s_pw[j]) |
| 1059 | { |
| 1060 | n_words_matched++; |
| 1061 | n_score+=100; |
| 1062 | } |
| 1063 | } |
| 1064 | } |
| 1065 | |
| 1066 | // We also want it to score higher for words in the same order. |
| 1067 | var s_word_pair=""; |
| 1068 | for (j=0;j<s_pw.length-1;j++) |
| 1069 | { |
| 1070 | s_word_pair=s_pw[j]+" "+s_pw[j+1]; |
| 1071 | if (s_host.indexOf(s_word_pair)>=0) n_score+=2037; |
| 1072 | } |
| 1073 | |
| 1074 | if (n_words_matched==s_pw.length) n_score+=1000; |
| 1075 | |
| 1076 | return n_score; |
| 1077 | } |
| 1078 | |
| 1079 | function show_event(evt) |
| 1080 | { |
no test coverage detected