📄 zoom_search.js
字号:
}
document.writeln("</div><br />");
document.writeln("<div class=\"results\">");
numwords = searchWords.length;
kw_ptr = 0;
outputline = 0;
usewildcards = 0;
ipage = 0;
matches = 0;
var SWord;
pagesCount = urls.length;
// Initialise a result table the size of all pages
res_table = new Array(pagesCount);
for (i = 0; i < pagesCount; i++)
{
res_table[i] = new Array(3);
res_table[i][0] = 0;
res_table[i][1] = 0;
res_table[i][2] = 0;
}
if (skipwords) {
for (sw = 0; sw < numwords; sw++) {
// check min length
if (searchWords[sw].length < MinWordLen) {
SkipSearchWord(sw);
continue;
}
// check skip word list
for (i = 0; i < skipwords.length; i++) {
if (searchWords[sw] == skipwords[i]) {
SkipSearchWord(sw);
break;
}
}
}
}
if (SkippedWords > 0)
document.writeln("<i>" + STR_SKIPPED_FOLLOWING_WORDS + " " + SkippedOutputStr + ".</i><br /><br />");
// Begin searching...
for (sw = 0; sw < numwords; sw++) {
if (searchWords[sw] == "")
continue;
if (searchWords[sw].indexOf("*") == -1 && searchWords[sw].indexOf("?") == -1) {
UseWildCards = 0;
} else {
UseWildCards = 1;
searchWords[sw] = pattern2regexp(searchWords[sw]);
if (SearchAsSubstring == 0)
pattern = "^" + searchWords[sw] + "$";
else
pattern = searchWords[sw];
re = new RegExp(pattern, "g");
}
for (kw_ptr = 0; kw_ptr < dictwords.length; kw_ptr++) {
data = dictwords[kw_ptr].split(",");
if (UseWildCards == 0) {
if (SearchAsSubstring == 0)
//match_result = data[0].search("^" + SWord + "$");
if (data[0] == searchWords[sw])
match_result = 0;
else
match_result = -1;
else
match_result = data[0].indexOf(searchWords[sw]);
} else
match_result = data[0].search(re);
if (match_result != -1) {
// keyword found, include it in the output list
for (kw = 1; kw < data.length; kw += 2) {
// check if page is already in output list
pageexists = 0;
ipage = data[kw];
if (res_table[ipage][0] == 0) {
matches++;
res_table[ipage][0] += parseInt(data[kw+1]);
}
else {
if (res_table[ipage][0] > 10000) {
// take it easy if its too big to prevent gigantic scores
res_table[ipage][0] += 1;
} else {
res_table[ipage][0] += parseInt(data[kw+1]); // add in score
res_table[ipage][0] *= 2; // double score as we have two words matching
}
}
res_table[ipage][1] += 1;
// store the 'and' user search terms matched' value
if (res_table[ipage][2] == sw || res_table[ipage][2] == sw-SkippedWords)
res_table[ipage][2] += 1;
}
if (UseWildCards == 0 && SearchAsSubstring == 0)
break; // this search word was found, so skip to next
}
}
}
// Count number of output lines that match ALL search terms
oline = 0;
fullmatches = 0;
ResFiltered = false;
output = new Array();
var full_numwords = numwords - SkippedWords;
for (i = 0; i < pagesCount; i++) {
IsFiltered = false;
if (res_table[i][0] != 0) {
if (UseCats && cat != -1) {
// using cats and not doing an "all cats" search
if (catpages[i] != cat) {
IsFiltered = true;
}
}
if (IsFiltered == false) {
if (res_table[i][2] >= full_numwords) {
fullmatches++;
} else {
if (andq == 1)
IsFiltered = true;
}
}
if (IsFiltered == false) {
// copy if not filtered out
output[oline] = new Array(3);
output[oline][0] = i;
output[oline][1] = res_table[i][0];
output[oline][2] = res_table[i][1];
oline++;
} else {
ResFiltered = true;
}
}
}
if (ResFiltered == true)
matches = output.length;
// Sort results in order of score, use "SortCompare" function
if (matches > 1)
{
if (sort == 1 && UseDateTime == 1)
output.sort(SortByDate); // sort by date
else
output.sort(SortCompare); // sort by relevance
}
// prepare query_out
var query_out = query.replace(/\s/g, "+");
query_out = escape(query_out);
//Display search result information
document.writeln("<div class=\"summary\">");
if (matches == 0)
document.writeln(STR_SUMMARY_NO_RESULTS_FOUND + "<br />");
else if (numwords > 1 && andq == 0) {
//OR
SomeTermMatches = matches - fullmatches;
document.writeln(PrintNumResults(fullmatches) + " " + STR_SUMMARY_FOUND_CONTAINING_ALL_TERMS + " ");
if (SomeTermMatches > 0)
document.writeln(PrintNumResults(SomeTermMatches) + " " + STR_SUMMARY_FOUND_CONTAINING_SOME_TERMS);
document.writeln("<br />");
}
else if (numwords > 1 && andq == 1) //AND
document.writeln(PrintNumResults(fullmatches) + " " + STR_SUMMARY_FOUND_CONTAINING_ALL_TERMS + "<br />");
else
document.writeln(PrintNumResults(matches) + " " + STR_SUMMARY_FOUND + "<br />");
document.writeln("</div>\n");
// number of pages of results
num_pages = Math.ceil(matches / per_page);
if (num_pages > 1)
document.writeln("<br />" + num_pages + " " + STR_PAGES_OF_RESULTS + "<br />\n");
// Show sorting options
if (matches > 1)
{
if (UseDateTime == 1)
{
document.writeln("<div class=\"sorting\">");
if (sort == 1)
document.writeln("<a href=\"" + SelfURL + "?zoom_query=" + query_out + "&zoom_page=" + page + "&zoom_per_page=" + per_page + "&zoom_cat=" + cat + "&zoom_and=" + andq + "&zoom_sort=0\">" + STR_SORTBY_RELEVANCE + "</a> / <b>" + STR_SORTEDBY_DATE + "</b>");
else
document.writeln("<b>" + STR_SORTEDBY_RELEVANCE + "</b> / <a href=\"" + SelfURL + "?zoom_query=" + query_out + "&zoom_page=" + page + "&zoom_per_page=" + per_page + "&zoom_cat=" + cat + "&zoom_and=" + andq + "&zoom_sort=1\">" + STR_SORTBY_DATE + "</a>");
document.writeln("</div>");
}
}
// determine current line of result from the output array
if (page == 1) {
arrayline = 0;
} else {
arrayline = ((page - 1) * per_page);
}
// the last result to show on this page
result_limit = arrayline + per_page;
// display the results
while (arrayline < matches && arrayline < result_limit) {
ipage = output[arrayline][0];
score = output[arrayline][1];
document.writeln("<p></p>\n");
document.writeln("<div class=\"result_title\">");
if (DisplayNumber == 1)
document.writeln("<b>" + (arrayline+1) + ".</b> ");
if (DisplayTitle == 1)
{
if (GotoHighlight == 1)
{
if (SearchAsSubstring == 1)
document.writeln("<a href=\"" + urls[ipage] + "?zoom_highlightsub=" + query_out + "\"" + target + ">" + titles[ipage] + "</a>");
else
document.writeln("<a href=\"" + urls[ipage] + "?zoom_highlight=" + query_out + "\"" + target + ">" + titles[ipage] + "</a>");
}
else
document.writeln("<a href=\"" + urls[ipage] + "\"" + target + ">" + titles[ipage] + "</a>");
}
else
document.writeln("<a href=\"" + urls[ipage] + "\"" + target + ">" + urls[ipage] + "</a>");
if (UseCats) {
catindex = catpages[ipage];
document.writeln("<span class=\"category\">[" + catnames[catindex] + "]</span>");
}
document.writeln("</div>");
if (DisplayMetaDesc == 1)
{
document.writeln("<div class=\"description\">");
if (Highlighting == 1)
document.writeln(HighlightDescription(descriptions[ipage]));
else
document.writeln(descriptions[ipage]);
document.writeln("<b>...</b></div>\n");
}
info_str = "";
if (DisplayTerms == 1)
info_str += STR_RESULT_TERMS_MATCHED + " " + output[arrayline][2];
if (DisplayScore == 1) {
if (info_str.length > 0)
info_str += " - ";
info_str += STR_RESULT_SCORE + " " + score;
}
if (DisplayDate == 1) {
if (info_str.length > 0)
info_str += " - ";
info_str += datetime[ipage].getDate() + " " + months[datetime[ipage].getMonth()] + " " + datetime[ipage].getFullYear();
}
if (DisplayURL == 1) {
if (info_str.length > 0)
info_str += " - ";
info_str += STR_RESULT_URL + " " + urls[ipage];
}
document.writeln("<div class=\"infoline\">");
document.writeln(info_str);
document.writeln("</div>\n");
arrayline++;
}
// Show links to other result pages
if (num_pages > 1) {
// 10 results to the left of the current page
start_range = page - 10;
if (start_range < 1)
start_range = 1;
// 10 to the right
end_range = page + 10;
if (end_range > num_pages)
end_range = num_pages;
document.writeln("<p></p>" + STR_RESULT_PAGES + " ");
if (page > 1)
document.writeln("<a href=\"" + SelfURL + "?zoom_query=" + query_out + "&zoom_page=" + (page-1) + "&zoom_per_page=" + per_page + "&zoom_cat=" + cat + "&zoom_and=" + andq + "&zoom_sort=" + sort + "\"><< " + STR_RESULT_PAGES_PREVIOUS + "</a> ");
for (i = start_range; i <= end_range; i++) {
if (i == page) {
document.writeln(page + " ");
} else {
document.writeln("<a href=\"" + SelfURL + "?zoom_query=" + query_out + "&zoom_page=" + i + "&zoom_per_page=" + per_page + "&zoom_cat=" + cat + "&zoom_and=" + andq + "&zoom_sort=" + sort + "\">" + i + "</a> ");
}
}
if (page != num_pages)
document.writeln("<a href=\"" + SelfURL + "?zoom_query=" + query_out + "&zoom_page=" + (page+1) + "&zoom_per_page=" + per_page + "&zoom_cat=" + cat + "&zoom_and=" + andq + "&zoom_sort=" + sort + "\">" + STR_RESULT_PAGES_NEXT + " >></a> ");
}
document.writeln("</div>"); // end results style tag
if (Timing == 1) {
timeEnd = new Date();
timeDifference = timeEnd - timeStart;
document.writeln("<br /><br /><small>" + STR_SEARCH_TOOK + " " + (timeDifference/1000) + " " + STR_SECONDS + ".</small>\n");
}
if (ZoomInfo == 1)
document.writeln("<center><p><small>" + STR_POWEREDBY + " <a href=\"http://www.wrensoft.com/zoom/\" target=\"_blank\"><b>Zoom Search Engine</b></a></small></p></center>");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -