新聞全文檢索

"; //res +=""; //res +=""; if(imgurl.length > 0){ res += ""; } return res; } function vGetTitle(title, sharelink, category){ res = "" + category + ""; res += "
"; res += "

"; res += "" + title + "

"; return res; } function vGetMeta(author, pubtime){ res =""; return res; } function vGetBrief(brief, imgurl){ if(imgurl.length > 0){ res ="
"; res += brief + "...
"; } else { res ="
"; res += brief + "...
"; } return res; } $(function(){ $("#btnAjax").click(function(){ var apiUrl = "https://search.ctee.com.tw/multiindexsearch/" + $("#kw").val(); $.ajax({ url: apiUrl, type: "GET", dataType: "json", success: function(response){ res = ""; //itemCount = 0; if(response=="[]"){ result.innerHTML = "
找不到您輸入關鍵字的相關內容,請修改後再次查詢,謝謝!
"; return; } $.each(response, function() { res += "
"; res += "
"; var title, brief, thumbUrl, shareLink, category, author, pubtime; $.each(this, function(k, v) { /// do stuff if(k=='title'){ title = v; } if(k=='category'){ category = v; } if(k=='preface'){ brief = v; } if(k=='author'){ author = v; } if(k=='mmddhhmm'){ pubtime = v; } if(k=='thumb'){ //thumbUrl = "https://cteecors.azureedge.net/wp-content/uploads/2018/09/logo300_90.png"; thumbUrl = ""; $.each(v, function(k2,v2){ //res += "url:" + JSON.stringify(thumb) + "
"; if(k2=="thumb"){ thumbUrl = v2; } }); } if(k=='sharelink'){ shareLink = v; } }); // end foreach k/v //itemCount++; res += vGetImgBox(category, shareLink, thumbUrl); res += vGetTitle(title, shareLink, category); res += vGetMeta(author, pubtime); res += vGetBrief(brief, thumbUrl); res += "
"; }); result.innerHTML = res; }, error: function(response){ //jsonText = JSON.stringify(response) result.innerHTML = "
找不到您輸入關鍵字的相關內容!,請修改後再次查詢,謝謝!
"; } }); }); });