background-image: url(?do/tag/ZC300/&).attr("value") == "") {
$("#icon_remove").hide();
}
function removeText() {
$("#kw").attr("value", "");
$("#icon_remove").hide();
}
$("#kw").bind("input", function() {
if ($("#kw").attr("value") == "" || $("#kw").attr("value").match(/^\s+$/)) {
$("#icon_remove").hide();
} else {
$("#icon_remove").show();
}
});
var isNext = 1;
$(window).scroll(function() {
if ($(this).scrollTop() + $(window).height() + 50 >= $(document).height() && $(this).scrollTop() > 50 && '' !== '1') {
nextPage();
}
});
$("#bottom_logo2_div").hide();
totalPage = 9
var pageNo = 1;
var hasIamge = false;
var hasAbstract = false;
var hasUrl = false;
var hasHorizontalStructure = false;
var hasVerticalStructure = false;
var hasHorizontalStructureForum = false;
var resultParamPrefix = '' + 'image';
var summary_abstract_mtd;
summary_abstract_mtd = 1;
hasIamge = true;
hasAbstract = true;
hasUrl = true;
var curPage = 0;
function nextPage() {
if (pageNo < totalPage && curPage !== pageNo) {
curPage = pageNo;
$("#bottom_logo2_div").show();
var url = "/api/customsearch/searchwap?q=ZC300&p=" + pageNo + "&cc=jb51.net";
var tplId = '0';
var addStr = "";
baiduAdUtil.get(url, function (dataJson) {
if (dataJson.status == 0) {
if (tplId == 0 || tplId == 1) {
addStr = getResultNormal(dataJson, tplId);
$("#results").append(addStr);
if (tplId == 1) {
subSpanMovieFooter();
}
} else if (tplId == 2 || tplId == 3) {
addStr = getResultGameSc(dataJson, tplId);
$("#result-list-game").append(addStr);
} else if (tplId == 5) {
addStr = getResultForumSc(dataJson, tplId);
$("#results").append(addStr);
subSpanFooter();
} else if (tplId == 6 || tplId == 8) {
addStr = getResultNormalSc(dataJson, tplId);
$("#results").append(addStr);
}
pageNo = pageNo + 1;
$(".result-game-item-uspan").click(function(event) {
event.stopPropagation();
event.preventDefault();
});
nextPageLog();
}
$("#bottom_logo2_div").hide();
});
}
}
function getResultNormal(dataJson, tplId) {
var addStr = "";
var resultLength = 0;
if (dataJson.results) {
resultLength = dataJson.results.length;
}
for (var i = 0; i < resultLength; i++) {
var result = dataJson.results[i];
var url = result["url"];
var title = result["title"];
var dispUrl = "";
if (hasUrl) {
var showurl = url.replace(/http[s]?:\/\//,'');
dispUrl = '
'
+ showurl.substr(0,37) + ( showurl.length > 37 ? "... " : " " )
+ result["lastModified"] + '
';
}
var resultImage = "";
var imgClass = '';
if (hasIamge) {
if (result['data']
&& result['data']['thumbnail_loc']
&& result['data']['thumbnail_loc'].length > 0
) {
resultImage = result['data']['thumbnail_loc'][0];
imgClass = 'c-image';
} else if (result['data']
&& result['data']['image_loc']
&& result['data']['image_loc'].length > 0
) {
resultImage = result['data']['image_loc'][0];
imgClass = 'c-image';
} else if (result['data']
&& result['data'][resultParamPrefix]
&& result['data'][resultParamPrefix].length > 0
) {
resultImage = result['data'][resultParamPrefix][0];
imgClass = 'c-image';
}
else if (result['data'] && result['data']['general_pic'] && result['data']['general_pic']['url']) {
resultImage = result['data']['general_pic']['url'];
imgClass = 'c-image page-pic';
}
}
var horizontalStructure = "";
var verticalStructure = "";
if (hasHorizontalStructure
&& result['summaryWords']
&& result['summaryWords'].length > 0
) {
horizontalStructure = getStructureWords(result['summaryWords'], 1);
}
if (hasVerticalStructure
&& result['summaryWords']
&& result['summaryWords'].length > 0
) {
if (resultImage != "" && tplId == 1) {
verticalStructure = getStructureWords(result['summaryWords'], 2, true, tplId);
} else {
verticalStructure = getStructureWords(result['summaryWords'], 2);
}
}
var dispTitle = '';
if (tplId == 0) {
dispTitle = '
' + title + '
';
} else {
dispTitle = '
' + title + '
';
}
var abstract = horizontalStructure;
if (hasAbstract) {
if (tplId == 0) {
abstract += '
' + result["abstract"] + '
';
} else {
if (resultImage === "") {
abstract += '
' + result["abstract"] + '
';
} else {
abstract += '
' + result["abstract"] + '
';
}
}
}
abstract += verticalStructure;
if (tplId == 0) {
if (resultImage === "") {
addStr += '
';
} else {
addStr += '
';
}
} else {
if (resultImage === "") {
addStr += '
' + dispTitle + abstract + '
' + dispUrl + '
';
} else {
addStr += '
'+ '
' + dispTitle + '
'
+ abstract + '
' + dispUrl + '
';
}
}
}
return addStr;
}
function getResultNormalSc(dataJson, tplId) {
var addStr = "";
var resultLength = 0;
if (dataJson.results) {
resultLength = dataJson.results.length;
}
for (var i = 0; i < resultLength; i++) {
var result = dataJson.results[i];
for (var key in result) {
if (result[key] === "0") {
result[key] = "";
}
}
var url = result['url'];
var content;
var title;
//SC中获取标题
if (tplId === '6') {
if (dataJson.highlighting
&& dataJson.highlighting[url]
&& dataJson.highlighting[url]['title']
&& dataJson.highlighting[url]['title'].length > 0
) {
title = dataJson.highlighting[url]['title'][0];
} else {
if (result["title"] && result["title"].length > 15) {
title = result["title"].substr(0,15) + "...";
} else {
title = result["title"];
}
}
if (dataJson.highlighting
&& dataJson.highlighting[url]
&& dataJson.highlighting[url]['content']
&& dataJson.highlighting[url]['content'].length > 0
) {
content = dataJson.highlighting[url]['content'][0];
} else {
if (result["content"] && result["content"].length > 60) {
content = result["content"].substr(0,60) + "...";
} else {
if (result["content"] === "0") {
result["content"] = "";
}
content = result["content"];
}
}
}
else {
if (dataJson.highlighting
&& dataJson.highlighting[url]
&& dataJson.highlighting[url]['name']
&& dataJson.highlighting[url]['name'].length > 0
) {
title = dataJson.highlighting[url]['name'][0];
} else {
if (result["name"] && result["name"].length > 15) {
title = result["name"].substr(0,15) + "...";
} else {
title = result["name"];
}
}
if (dataJson.highlighting
&& dataJson.highlighting[url]
&& dataJson.highlighting[url]['description']
&& dataJson.highlighting[url]['description'].length > 0
) {
content = dataJson.highlighting[url]['description'][0].replace(/\ /, '').replace(/\<.*\>/, '').replace('<', '<').replace('>', '>')
.replace('<em>', '
').replace('</em>', '');
} else {
if (result["description"] && result["description"].length > 60) {
content = result["description"].replace(/\ /, '').replace(/\<.*\>/, '').replace(/(<[^>]+>)+(.+?)(<\/.*?\>)+/, '').replace(/<.*\/\s*>/, '').substr(0,60) + "...";
} else {
if (result["description"] === "0") {
result["description"] = "";
}
content = result["description"].replace(/\ /, '').replace(/\<.*\>/, '').replace(/(<[^>]+>)+(.+?)(<\/.*?\>)+/, '').replace(/<.*\/\s*>/, '');
}
}
}
//SC中获取摘要
var dispUrl = "";
if (hasUrl && tplId !== '8') {
var dateModified = '';
if (result['pubTime']) {
var dateModifiedYear = new Date(parseInt(result['pubTime']) * 1000).getFullYear();
var dateModifiedMonth = new Date(parseInt(result['pubTime']) * 1000).getMonth() + 1;
var dateModifiedDay = new Date(parseInt(result['pubTime']) * 1000).getDate();
dateModified = dateModifiedYear + "-" + dateModifiedMonth + "-" + dateModifiedDay;
}
var showurl = url.replace(/http[s]?:\/\//,'');
dispUrl = '
'
+ showurl.substr(0,37) + ( showurl.length > 37 ? "... " : " " )
+ dateModified + '
';
}
var resultImage = "";
if (hasIamge && tplId === '6') {
if (result
&& result['thumbnail_loc']
) {
resultImage = result['thumbnail_loc'];
} else if (result
&& result['image_loc']
) {
resultImage = result['image_loc'];
} else if (result
&& result[resultParamPrefix]
) {
resultImage = result[resultParamPrefix];
}
}
else if (hasIamge && tplId === '8') {
if (result['image'] && result['image'].length > 0) {
resultImage = result['image'][0];
}
}
var verticalStructure = "";
if (hasVerticalStructure) {
verticalStructure = getStructureWordsSc(result, tplId, content);
}
var dispTitle = '
' + title + '
';
if (tplId == 6) {
var abstract = "";
if (hasAbstract) {
abstract += '
' + content + '
';
}
abstract += verticalStructure;
if (resultImage === "") {
addStr += '
';
} else {
addStr += '
';
}
}
else {
var abstract = "";
abstract += verticalStructure;
if (resultImage === "") {
addStr += '
' + dispTitle + abstract + '
';
} else {
addStr += '
'+ '
' + dispTitle
+ abstract + '
';
}
}
}
return addStr;
}
function getResultForum(dataJson, tplId) {
var addStr = "";
var resultLength = 0;
if (dataJson.results) {
resultLength = dataJson.results.length;
}
for (var i = 0; i < resultLength; i++) {
var result = dataJson.results[i];
var summaryWords = null;
var url = "";
var dispUrl = "";
var title = "";
var abstract = "";
var resultImage = "";
var structureWords = "";
if (result['data']
&& result['data']['meta_di_info']
&& result['data']['meta_di_info']["cse_threadTitle"]
) {
var fresult = result['data']['meta_di_info'];
if (fresult["cse_threadTitle"] && fresult["cse_threadTitle"].length > 0) {
title = fresult["cse_threadTitle"][0];
}
url = result['url'];
var hasAbstract = false;
var hasImage = false;
if (hasHorizontalStructureForum) {
structureWords = getStructureWordsForum(summaryWords, fresult);
for (var j = 0; j < summaryWords.length; j++) {
var word = summaryWords[j];
if (word['field'] === 'description') {
hasAbstract = true;
}
if (word['field'] === 'image') {
hasImage = true;
}
}
} else {
if (summary_abstract_mtd != 0) {
hasAbstract = true;
hasImage = true;
}
}
if (hasAbstract) {
abstract = '
' + result["abstract"] + '
';
}
if (hasImage) {
if (fresult['cse_post']
&& fresult['cse_post'][0]
&& fresult['cse_post'][0]['cse_attachment']
&& fresult['cse_post'][0]['cse_attachment'][0]
&& fresult['cse_post'][0]['cse_attachment'][0]['cse_attachmentUrl']
&& fresult['cse_post'][0]['cse_attachment'][0]['cse_attachmentUrl'].length > 0
) {
resultImage = fresult['cse_post'][0]['cse_attachment'][0]['cse_attachmentUrl'][0];
}
}
var image = '';
var imageDiv = '
';
if (resultImage != undefined && resultImage != null && resultImage != "") {
imageDiv = '
';
image = '
';
}
addStr += '
'
+ title + '
' + '
' + imageDiv + abstract + '
'
+ image + '
' + structureWords + '
';
} else {
url = result["url"];
title = result["title"];
abstract = '
' + result["abstract"] + '
';
dispUrl = '
' + result["data"]["DispUrl"] + " "
+ result["lastModified"] + '
';
addStr += '
';
}
}
return addStr;
}
function getResultForumSc(dataJson, tplId) {
var addStr = "";
var resultLength = 0;
if (dataJson.results) {
resultLength = dataJson.results.length;
}
for (var i = 0; i < resultLength; i++) {
var result = dataJson.results[i];
var summaryWords = null;
var url = "";
var dispUrl = "";
var title = "";
var content = "";
var abstract = "";
var resultImage = "";
var structureWords = "";
for (var key in result) {
if (result[key] === "0") {
result[key] = "";
}
}
url = result['url'];
//SC中获取标题
if (dataJson.highlighting
&& dataJson.highlighting[url]
&& dataJson.highlighting[url]['threadTitle']
&& dataJson.highlighting[url]['threadTitle'].length > 0
) {
title = dataJson.highlighting[url]['threadTitle'][0];
} else {
if (result["threadTitle"] && result["threadTitle"].length > 15) {
title = result["threadTitle"].substr(0,15) + "...";
} else {
title = result["threadTitle"];
}
}
//SC中获取摘要
if (dataJson.highlighting
&& dataJson.highlighting[url]
&& dataJson.highlighting[url]['post_postContent']
&& dataJson.highlighting[url]['post_postContent'].length > 0
) {
content = dataJson.highlighting[url]['post_postContent'][0].replace(/\[hide\].*\[\/hide\]/, '【回复后可见】').replace(/\[hide\](.*?\s*.*)$/, '【回复后可见】');
} else {
if (result["post_postContent"] && result["post_postContent"].length > 60) {
content = result["post_postContent"].replace(/\[hide\].*\[\/hide\]/, '【回复后可见】').replace(/\[hide\](.*?\s*.*)$/, '【回复后可见】').substr(0,60) + "...";
} else {
if (result["post_postContent"] === "0") {
result["post_postContent"] = "";
}
content = result["post_postContent"].replace(/\[hide\].*\[\/hide\]/, '【回复后可见】').replace(/\[hide\](.*?\s*.*)$/, '【回复后可见】');
}
}
var hasAbstract = false;
var hasImage = false;
if (hasHorizontalStructureForum) {
structureWords = getStructureWordsForumSc(summaryWords, result);
for (var j = 0; j < summaryWords.length; j++) {
var word = summaryWords[j];
if (word['field'] === 'description') {
hasAbstract = true;
}
if (word['field'] === 'image') {
hasImage = true;
}
}
} else {
if (summary_abstract_mtd != 0) {
hasAbstract = true;
hasImage = true;
}
}
if (hasAbstract) {
abstract = '
' + content + '
';
}
if (hasImage) {
if (result['post_attachment_attachmentUrl']
&& result['post_attachment_attachmentUrl'].length > 0
) {
resultImage = result['post_attachment_attachmentUrl'][0];
}
}
var image = '';
var imageDiv = '
';
if (resultImage != undefined && resultImage != null && resultImage != "") {
imageDiv = '
';
image = '
';
}
addStr += '
'
+ title + '
' + '
' + imageDiv + abstract + '
'
+ image + '
' + structureWords + '
';
}
return addStr;
}
function getResultGame(dataJson, tplId) {
var addStr = "";
var resultLength = 0;
if (dataJson.results) {
resultLength = dataJson.results.length;
}
for (var k = 0; k < resultLength; k++) {
var result = dataJson.results[k];
var url = result['dispData']['url'];
if (url == '' || url == null) {
url = result['dispData']['loc'];
}
var title = result['dispData']['name'];
title = title.replace(new RegExp('<em>',"gm"), '');
title = title.replace(new RegExp('</em>',"gm"), '');
addStr += '
';
var resultImage = "";
if (tplId == 3) {
if (result['dispData']
&& result['dispData']['image']
&& result['dispData']['image'][0]
&& result['dispData']['image'][0]['url']
&& result['dispData']['image'][0]['url'] != ""
) {
resultImage = result['dispData']['image'][0]['url'];
} else {
resultImage = result['dispData']['image']['url'];
}
} else {
resultImage = result['dispData']['image'];
}
if (resultImage != undefined && resultImage != null && resultImage != "") {
if (tplId == 3) {
addStr += '
'
+ '
';
} else {
addStr += '
'
+ '
';
}
}
addStr += '
'
+ '
'
+ title + '
';
var hasDesc = '1';
var description = result['dispData']['description'];
description = description.replace(new RegExp('<em>',"gm"), '');
description = description.replace(new RegExp('</em>',"gm"), '');
if (description != undefined && description != null && description != "" && hasDesc == 1) {
addStr += '
' + description + '
';
}
addStr += '
';
var summaryWords = null;
var summaryLength = 0;
if (summaryWords) {
summaryLength = summaryWords.length;
}
for (var i = 0; i < summaryLength; i++) {
if (summaryWords[i]['field'] !== 'image'
&& summaryWords[i]['field'] !== 'description'
&& summaryWords[i]['field'] !== 'name'
) {
addStr += '
';
var pre = summaryWords[i]['pre'];
if (pre.indexOf(":") === -1 && pre.indexOf(":") === -1) {
pre = pre + ": ";
}
pre = pre + " ";
addStr += pre + '';
if (summaryWords[i]['field'] === 'tag' && tplId == 3) {
var tagwords = [];
if (result['dispData']
&& result['dispData']['tag']
) {
tagwords = result['dispData']['tag'].split(",");
}
if (tagwords.length > 0) {
for (var j = 0; j < tagwords.length; j++) {
var item = tagwords[j];
item = item.replace(new RegExp('',"gm"), '');
item = item.replace(new RegExp('',"gm"), '');
item = "'" + item + "'";
addStr += '' + tagwords[j] + ' ';
}
}
} else if (summaryWords[i]['field'] === 'author_name' && tplId == 2) {
var authorUrl = result['dispData']['author']['url'];
var authorName = result['dispData']['author']['name'];
if (authorUrl != undefined && authorUrl != null && authorUrl != "") {
authorUrl = "'" + authorUrl + "'";
addStr += '' + authorName + '';
} else {
addStr += '' + authorName + '';
}
} else if (summaryWords[i]['field'] === 'newestChapter' && tplId == 2) {
if (result['dispData']['newestChapter'] && result['dispData']['newestChapter'][0]) {
var chapterUrl = result['dispData']['newestChapter'][0]['url'];
var chapterName = result['dispData']['newestChapter'][0]['headline'];
if (chapterUrl != undefined && chapterUrl != null && chapterUrl != "") {
chapterUrl = "'" + chapterUrl + "'";
addStr += '' + chapterName + '';
} else {
addStr += '' + chapterName + '';
}
}
} else if (summaryWords[i]['field'] === 'author_name' && tplId == 2) {
if (result['dispData']['listPage'] && result['dispData']['listPage'][0]) {
var listUrl = result['dispData']['listPage'][0]['url'];
var listName = result['dispData']['listPage'][0]['headline'];
if (listUrl != undefined && listUrl != null && listUrl != "") {
listUrl = "'" + listUrl + "'";
addStr += '' + listName + '';
} else {
addStr += '' + listName + '';
}
}
} else {
var field = summaryWords[i]['field'];
addStr += '' + result['dispData'][field] + '';
}
addStr += '
';
}
}
addStr += '
';
}
return addStr;
}
function getResultGameSc(dataJson, tplId) {
var addStr = "";
var resultLength = 0;
if (dataJson.results) {
resultLength = dataJson.results.length;
}
for (var k = 0; k < resultLength; k++) {
var result = dataJson.results[k];
var url = result['url'];
var title;
var authorName;
var tag;
var description;
for (var key in result) {
if (result[key] === "0") {
result[key] = "";
}
}
//SC中获取标题
if (dataJson.highlighting
&& dataJson.highlighting[url]
&& dataJson.highlighting[url]['name']
&& dataJson.highlighting[url]['name'].length > 0
) {
title = dataJson.highlighting[url]['name'][0];
} else {
if (result["name"] && result["name"].length > 15) {
title = result["name"].substr(0,15) + "...";
} else {
title = result["name"];
}
}
if (dataJson.highlighting
&& dataJson.highlighting[url]
&& dataJson.highlighting[url]['description']
&& dataJson.highlighting[url]['description'].length > 0
) {
description = dataJson.highlighting[url]['description'][0];
} else {
if (result["description"] && result["description"].length > 30) {
description = result["description"].substr(0,30) + "...";
} else {
description = result["description"];
}
}
if (tplId == 2 && dataJson.highlighting
&& dataJson.highlighting[url]
&& dataJson.highlighting[url]['author_name']
&& dataJson.highlighting[url]['author_name'].length > 0
) {
authorName = dataJson.highlighting[url]['author_name'][0];
} else {
if (result["author_name"] && result["author_name"].length > 15) {
authorName = result["author_name"].substr(0,15) + "...";
} else {
authorName = result["author_name"];
}
}
if (tplId == 3 && dataJson.highlighting
&& dataJson.highlighting[url]
&& dataJson.highlighting[url]['tag_index']
&& dataJson.highlighting[url]['tag_index'].length > 0
) {
tag = dataJson.highlighting[url]['tag_index'][0];
} else {
if (result["tag_index"] && result["tag_index"][0]) {
tag = result["tag_index"].join(",");
}
else {
tag = "";
}
}
addStr += '
';
var resultImage = "";
if (tplId == 3) {
try {
result['image_url'] = eval(result['image_url']);
}
catch(e) {
}
if (Object.prototype.toString.call(result['image_url']) === '[object Array]' && result['image_url'][0]) {
resultImage = result['image_url'][0];
}
else {
resultImage = result['image_url'];
}
}
else {
resultImage = result['image'];
}
if (resultImage != undefined && resultImage != null && resultImage != "") {
if (tplId == 3) {
addStr += '
'
+ '
';
} else {
addStr += '
'
+ '
';
}
}
else {
if (tplId == 3) {
addStr += '
'
+ '
';
}
}
addStr += '
'
+ '
'
+ title + '
';
var hasDesc = '1';
description = description.replace(new RegExp('<em>',"gm"), '');
description = description.replace(new RegExp('</em>',"gm"), '');
if (description != undefined && description != null && description != "" && hasDesc == 1) {
addStr += '
' + description + '
';
}
addStr += '
';
var summaryWords = null;
var summaryLength = 0;
if (summaryWords) {
summaryLength = summaryWords.length;
}
for (var i = 0; i < summaryLength; i++) {
if (summaryWords[i]['field'] !== 'image'
&& summaryWords[i]['field'] !== 'description'
&& summaryWords[i]['field'] !== 'name'
) {
addStr += '
';
var pre = summaryWords[i]['pre'];
if (pre.indexOf(":") === -1 && pre.indexOf(":") === -1) {
pre = pre + ": ";
}
pre = pre + " ";
addStr += pre + '';
if (summaryWords[i]['field'] === 'tag' && tplId == 3) {
var tagwords = [];
if (tag && tag !== "") {
tagwords = tag.split(",");
}
if (tagwords.length > 0) {
for (var j = 0; j < tagwords.length; j++) {
var item = tagwords[j];
item = "'" + "tag:" + item + "'";
item = item.replace(new RegExp('',"gm"), '');
item = item.replace(new RegExp('',"gm"), '');
addStr += '' + tagwords[j] + ' ';
}
}
} else if (summaryWords[i]['field'] === 'author_name' && tplId == 2) {
var authorUrl = result['author_url'];
if (authorUrl != undefined && authorUrl != null && authorUrl != "") {
authorUrl = "'" + authorUrl + "'";
addStr += '' + authorName + '';
} else {
addStr += '' + authorName + '';
}
} else if (summaryWords[i]['field'] === 'newestChapter' && tplId == 2) {
var newchapter = result['newestChapter_headline'];
var newurl = result['newestChapter_url'];
if (newurl != undefined && newurl != null && newurl != "") {
newurl = "'" + newurl + "'";
addStr += '' + newchapter + '';
} else {
addStr += '' + newchapter + '';
}
} else if (summaryWords[i]['field'] === 'listPage' && tplId == 2) {
var listpage = result['listPage_url'];
if (listpage != undefined && listpage != null && listpage.length > 0) {
var listurl = "'" + listpage[0] + "'";
addStr += '' + title + '';
}
} else if (summaryWords[i]['field'] === 'dateModified' || summaryWords[i]['field'] === 'datePublished') {
if (result[summaryWords[i]['field']]) {
var dateModifiedYear = new Date(parseInt(result[summaryWords[i]['field']]) * 1000).getFullYear();
var dateModifiedMonth = new Date(parseInt(result[summaryWords[i]['field']]) * 1000).getMonth() + 1;
var dateModifiedDay = new Date(parseInt(result[summaryWords[i]['field']]) * 1000).getDate();
var dateModified = dateModifiedYear + "-" + dateModifiedMonth + "-" + dateModifiedDay;
}
addStr += '' + dateModified + '';
} else if (summaryWords[i]['field'] === 'gameSubCategory' || summaryWords[i]['field'] === 'typicalAgeRange') {
if (result[summaryWords[i]['field']] && result[summaryWords[i]['field']][0]) {
var field = summaryWords[i]['field'];
addStr += '' + result[field][0] + '';
}
}
else if (summaryWords[i]['field'] === 'inLanguage') {
if (result[summaryWords[i]['field']] && result[summaryWords[i]['field']].length > 0) {
var field = summaryWords[i]['field'];
var fieldValue = "";
for (var l = 0; l < result[summaryWords[i]['field']].length; l++) {
fieldValue = fieldValue + result[field][l] + " ";
}
addStr += '' + fieldValue + '';
}
}
else {
var field = summaryWords[i]['field'];
addStr += '' + result[field] + '';
}
addStr += '
';
}
}
addStr += '
';
}
return addStr;
}
function getStructureWords(structureWords, direction, hasImage, tplId) {
var resStructureWords = '';
if (direction == 1) {
resStructureWords += '
';
} else if (direction == 2) {
resStructureWords += '
';
}
var structureLength = 0;
if (structureWords) {
structureLength = structureWords.length;
}
for (var i = 0; i < structureLength; i++) {
var word = structureWords[i];
var contents = word['content'];
var pre = word['pre'];
if (tplId == 1 && pre!="") {
if (pre.indexOf(":") === -1 && pre.indexOf(":") === -1) {
pre = pre + ": ";
}
}
var spanStart = '' + pre;
if (tplId == 1 && direction == 2 && hasImage) {
spanStart = '' + pre;
}
resStructureWords += spanStart;
var contentLength = 0;
if (contents) {
contentLength = contents.length;
}
for (var j = 0; j < contentLength; j++) {
var unit = contents[j];
if (unit['url'] != undefined && unit['url'] != null && unit['url'] !="" ) {
var unitUrl = "'" + unit['url'] + "'";
resStructureWords += '' + unit['text'] + '';
} else {
resStructureWords += unit['text'];
}
if (j !== contentLength - 1) {
resStructureWords += '|';
}
}
resStructureWords += word['post'] + '';
// if (direction == 2 && i < structureWords.length-1) {
// resStructureWords += '
';
// }
}
resStructureWords += '
';
return resStructureWords;
}
function getStructureWordsSc(result, tplId, content) {
var resStructureWords = '';
resStructureWords += '
';
resStructureWords += '
';
return resStructureWords;
}
function getStructureWordsForum(summaryWords, fresult) {
var addStr = '
';
var summaryLength = 0;
if (summaryWords) {
summaryLength = summaryWords.length;
}
for (var i = 0; i < summaryLength; i++) {
var word = summaryWords[i];
if (word['field'] !== 'title'
&& word['field'] !== 'description'
&& word['field'] !== 'image'
) {
//addStr += '';
if (word['field'] === 'plate') {
if (fresult['cse_forumIn']
&& fresult['cse_forumIn'][0]
&& fresult['cse_forumIn'][0]['cse_forumName']
&& fresult['cse_forumIn'][0]['cse_forumName'].length > 0
) {
var reg = /(<[^>]+>)+(.+?)(<\/.*?\>)+/;
var strFr = fresult['cse_forumIn'][0]['cse_forumName'][0].replace(reg, "$2");
addStr += '来自: ' + strFr + word['post'] + '';
}
} else if (word['field'] === 'author'
&& (fresult['cse_author']
&& fresult['cse_author'].length > 0)
) {
addStr += '' + word['pre'] + ': ' + fresult['cse_author'][0] + word['post'] + '';
} else if (word['field'] === 'dataPublished') {
addStr += '发布: ';
if (fresult['cse_post']
&& fresult['cse_post'][0]
&& fresult['cse_post'][0]['cse_createdTime']
&& fresult['cse_post'][0]['cse_createdTime'].length > 0
) {
var pubTime = fresult['cse_post'][0]['cse_createdTime'][0];
if (pubTime.length > 10) {
pubTime = pubTime.substring(0,10);
}
addStr += pubTime + word['post'] + '';
}
} else if (word['field'] === 'dataLastReplied'
&& (fresult['cse_lastReplyTime']
&& fresult['cse_lastReplyTime'].length > 0)
) {
var recentReply = fresult['cse_lastReplyTime'][0];
if (recentReply.length > 10) {
recentReply = recentReply.substring(0,10);
}
addStr += '最新回复: ' + recentReply + word['post'] + '';
} else if (word['field'] === 'replyCount'
&& (fresult['cse_replyCount']
&& fresult['cse_replyCount'].length > 0
&& fresult['cse_replyCount'][0] != 0)
) {
addStr += '回复: ' + fresult['cse_replyCount'][0] + word['post'] + '';
} else if (word['field'] === 'browseCount'
&& (fresult['cse_viewCount']
&& fresult['cse_viewCount'].length > 0
&& fresult['cse_viewCount'][0] != 0)
) {
addStr += '浏览: ' + fresult['cse_viewCount'][0] + word['post'] + '';
} else if (word['field'] === 'postType'
&& (fresult['cse_threadClassify']
&& fresult['cse_threadClassify'].length > 0)
) {
addStr += '状态: ' + fresult['cse_threadClassify'][0] + word['post'] + '';
}
}
}
addStr += '
';
return addStr;
}
function getStructureWordsForumSc(summaryWords, fresult) {
var addStr = '
';
var summaryLength = 0;
if (summaryWords) {
summaryLength = summaryWords.length;
}
for (var i = 0; i < summaryLength; i++) {
var word = summaryWords[i];
if (word['field'] !== 'title'
&& word['field'] !== 'description'
&& word['field'] !== 'image'
) {
//addStr += '';
if (word['field'] === 'plate') {
if (fresult['forumIn_forumName']) {
var reg = /(<[^>]+>)+(.+?)(<\/.*?\>)+/;
var strFr = fresult['forumIn_forumName'].replace(reg, "$2");
addStr += '来自: ' + strFr + word['post'] + '';
}
} else if (word['field'] === 'author'
&& fresult['post_author']
) {
addStr += '' + word['pre'] + ': ' + fresult['post_author'] + word['post'] + '';
} else if (word['field'] === 'dataPublished') {
addStr += '发布: ';
if (fresult['post_createdTime']) {
var pubTimeNs = fresult['post_createdTime'];
var pubTimeYear = new Date(parseInt(pubTimeNs) * 1000).getFullYear();
var pubTimeMonth = new Date(parseInt(pubTimeNs) * 1000).getMonth() + 1;
var pubTimeDay = new Date(parseInt(pubTimeNs) * 1000).getDate();
var pubTime = pubTimeYear + "-" + pubTimeMonth + "-" + pubTimeDay;
addStr += pubTime + word['post'] + '';
}
} else if (word['field'] === 'dataLastReplied'
&& fresult['lastReplyTime']
) {
var recentReplyNs = fresult['lastReplyTime'];
var recentReplyYear = new Date(parseInt(recentReplyNs) * 1000).getFullYear();
var recentReplyMonth = new Date(parseInt(recentReplyNs) * 1000).getMonth() + 1;
var recentReplyDay = new Date(parseInt(recentReplyNs) * 1000).getDate();
var recentReply = recentReplyYear + "-" + recentReplyMonth + "-" + recentReplyDay;
addStr += '最新回复: ' + recentReply + word['post'] + '';
} else if (word['field'] === 'replyCount'
&& fresult['replyCount']
) {
addStr += '回复: ' + fresult['replyCount'] + word['post'] + '';
} else if (word['field'] === 'browseCount'
&& fresult['viewCount']
) {
addStr += '浏览: ' + fresult['viewCount'] + word['post'] + '';
} else if (word['field'] === 'postType'
&& fresult['threadClassify']
) {
addStr += '状态: ' + fresult['threadClassify'] + word['post'] + '';
}
}
}
addStr += '
';
return addStr;
}
function subSpanFooter() {
var forumWidth = $(".c-summary-1").width() - 20;
var str = ".nextPage" + pageNo;
$("#results").find(str).each(function (k, itemOut) {
var span_w = 0;
var isShow = false;
$(itemOut).find("span").each(function (i, item) {
span_w = span_w + $(item).width();
if (span_w > forumWidth) {
$(item).hide();
} else {
isShow = true;
}
if ($(item).width()>0) {
span_w = span_w + 20;
}
});
if (!isShow) {
$(itemOut).hide();
}
});
}
function subSpanMovieFooter() {
$("#results").find(".structure-words-vertical").each(function (k, itemOut) {
var str = ".c-image-span-nextPage" + pageNo;
$(itemOut).find(str).each(function (i, item) {
if ($(item).height() > 32) {
$(item).height(32);
}
});
});
}
function urlFormat(url) {
if (url.substr(0,7) === 'http://'){
return url;
} else {
return 'http://' + url;
}
}
function nextPageLog() {
var params = {};
var strUrl = decodeURIComponent(window.location.href);
var location = window.location;
if (document) {
params.url = strUrl || '';
}
var args = '';
for (var i in params) {
if (args != '') {
args += '&';
}
args += i + '=' + encodeURIComponent(params[i]);
}
var img = new Image();
var t = new Date().getTime();
img.onload = img.onerror = img.onabort = function () {
img.onload = img.onerror = img.onabort = null;
try {
img = null;
} catch (e) {
//完成后销毁生成的图片对象
img = null;
}
}
var imgName = "cse.gif";
if (location.port) {
img.src = location.protocol + "//" + location.hostname + ":" + location.port + "/static/img/" + imgName + "?" + args + '&r=' + t;
} else {
img.src = location.protocol + "//" + location.hostname + "/static/img/" + imgName + "?" + args + '&r=' + t;
}
}