|
本帖最后由 kangatang 于 2013-4-17 13:20 编辑
模糊查询 “枫树”,所有结果都在链接地址
http://www.nature-museum.net/Aja ... 1&start=0&limit=100
查询结果是JSON数组,再解析出来即可。
下面应该是那个解析函数 (见源代码:http://www.nature-museum.net/Spd ... tectCookieSupport=1)
function FuzzyQuerySp()
{
$("#QueryResult").html("<div><img src='/images/loading1.gif' /><span>正在搜索,请稍等......</span></div>");
var cName = $("#txtSearchName").val().TrimUnnecessaryBlank();
//alert(cName);
GetFuzzyQuerySpResult(cName,0,100,"QueryResult");
}
function GetFuzzyQuerySpResult(cName,nStart,nLimit, resultContainer)
{
$.getJSON("/Ajaxserver/server.ashx?service=spdict&method=fuzzyquery&format=json", { name: cName, start: nStart, limit: nLimit },
function(r)
{
if (IsJSONMsg(r))
{
ShowJSONMsg(r);
return "";
}
else
{
var SpCount = r.ResultList.length;
if (SpCount < 1)
{
alert("您键入的物种名称不在当前物种库中,如果您确认它是正确的,请先添加到物种库当中!");
return;
}
if (SpCount > 0)
{
var data = r.ResultList;
var totalCount = r.TotalDataCount;
var searched = r.SearchStoppedLocation;
var percent = Math.round((parseFloat(searched) / parseFloat(totalCount)) * 100);
var SpListHtml = "<div class='resultTips' style='float:left;'>共搜索到" + SpCount + "条物种记录(用时" + r.ProcessTime + "毫秒," + percent + "% 已搜索)</div>";
if (totalCount > searched)
{
SpListHtml += "<div style='padding:3px 10px; border:solid 1px #333;cursor:pointer; text-align:center; width:80px; margin:5px;float:left;' onclick='GetFuzzyQuerySpResult(\"" + cName + "\"," + (searched + 1) + "," + nLimit + ",\"QueryResult\");'>继续搜索</div>";
}
SpListHtml += "<hr style='clear:both;' />";
for (var i = 0; i < SpCount; i++)
{
SpListHtml += "<table ";
if (i % 2 == 0)
{
SpListHtml += "class='nooddrow'>";
}
else
{
SpListHtml += "class='oddrow'>";
}
SpListHtml += "<tr><td valign='top' align='center' style='font-size:10px;'>";
SpListHtml += "<a href=\""+_WebRoot+"/spdb/TaxonNodeTree.aspx?spid=";
SpListHtml += data.Key;
SpListHtml += "\" target=\"_blank\">";
SpListHtml += "<img src=\"/Data/";
SpListHtml += data.PhotoID;
SpListHtml += ".photoThumbnail\" style=\"border:solid 1px #bbb; padding:1px; width:100px;\" /></a>";
SpListHtml += "<br />照片多于 " + data.PhotoCount + " 张";
SpListHtml += "</td><td style=\"padding-left:20px;\" valign='top'>";
SpListHtml += "<a href=\""+_WebRoot+"/";
SpListHtml += data.Key;
SpListHtml += ".sp\" target=\"_blank\">";
SpListHtml += "<span class='SpCName'>";
var bMathed = (data.Name_Zh.indexOf(cName) > 0 || cName.indexOf(data.Name_Zh) > 0);
if (bMathed)
SpListHtml += "<span class='foundWord'>";
SpListHtml += data.Name_Zh;
if (bMathed)
SpListHtml += "</span>";
SpListHtml += "</span>";
if (!data.IsPreferred)
SpListHtml += "<span style='color:red;font-size:12px;margin-left:20px;'>【别名】</span>";
SpListHtml += "<br />";
SpListHtml += "<span class=\"SpLatinName\">";
var bMathed = (data.Name_Latin.indexOf(cName) > 0 || cName.indexOf(data.Name_Latin) > 0);
if (bMathed)
SpListHtml += "<span class='foundWord'>";
SpListHtml += data.Name_Latin;
if (bMathed)
SpListHtml += "</span>";
SpListHtml += "</span>";
SpListHtml += "<span class='SpLatinNameSAuthor'> ";
SpListHtml += data.SAuthor;
SpListHtml += "</span>";
SpListHtml += "</a><br />";
if (!IsEmpty(data.FamilyGenus))
{
SpListHtml += data.FamilyGenus.FamilyName_Zh + " " + data.FamilyGenus.FamilyName_Latin + " " + data.FamilyGenus.GenusName_Zh + "<br />";
}
if (!IsEmpty(data.NormalNamesList))
{
SpListHtml += "别名:";
for (var j = 0; j < data.NormalNamesList.length; j++)
{
if (data.NormalNamesList[j].Name.indexOf(cName) > 0 || cName.indexOf(data.NormalNamesList[j].Name) > 0)
SpListHtml += "<span class='foundWord'>" + data.NormalNamesList[j].Name + "</span> ";
else
SpListHtml += data.NormalNamesList[j].Name + " ";
}
SpListHtml += "<br />";
}
var linkKey = ""+_WebRoot+"/" + data.Key;
SpListHtml += "<a href=\"" + linkKey + ".spage\" target=\"_blank\"><span class='hightlightlink'>物种详细信息页:" + linkKey + ".spage" + "</span></a>" + "<br />";
SpListHtml += "<a href=\"" + linkKey + ".sp\" target=\"_blank\"><span class='hightlightlink'>物种信息卡:" + linkKey + ".sp" + "</span></a>" + "<br />";
SpListHtml += "<a href=\"" + linkKey + ".spalbum\" target=\"_blank\"><span class='hightlightlink'>物种图库:" + linkKey + ".spAlbum" + "</span></a>" + "<br />";
//http: //www.cfh.ac.cn/Wiki/page.aspx?action=read&bookid=CFHWiki&target=Sp&targetid=28140
SpListHtml += "<a href=\"/Wiki/page.aspx?action=read&bookid=CFHWiki&target=Sp&targetid=" + data.Key + "\" target=\"_blank\"><span class='hightlightlink'>物种Wiki词条:" + linkKey + ".spWiki</span></a><br />";
SpListHtml += "</td></table>";
}
$("#" + resultContainer).html(SpListHtml);
}
}
}
);
}
在网页上显示出来:
|
|