/* == Search == */ var searchFormConfig = {numPost: 5,summaryPost: true,summaryLength: 0,noResult: "Không tìm thấy bài nào với từ khoá",suggestion: "Gõ có dấu giúp tìm chính xác hơn !",resultThumbnail: true,thumbSize: 50,fallbackThumb: "http://3.bp.blogspot.com/-FfNFoZEoZ0s/U9i2Y9ozj7I/AAAAAAABIWI/BiUcKMwYWhI/s200-c/khong+co+hinh.gif" }; function getId(id) {return document.getElementById(id);} var config = searchFormConfig,input = getId('feed-q-input'),resultContainer = getId('search-result-container'),resultLoader = getId('search-result-loader'),skeleton = ''; function showResult(json) { var entry = json.feed.entry ? json.feed.entry : "", url, summary, img, pcm; skeleton = '
' skeleton += '

Tìm kiếm với từ khoá "'+input.value+'"

'; skeleton += '
    ';if (entry === "") { skeleton += '
  1. '+config.noResult+' "'+input.value+'". '+config.suggestion+'
  2. ';} for (var i = 0; i < config.numPost; i++) {if (i == entry.length) break;var span = new RegExp(input.value, "ig"), entries = entry[i], title = entries.title.$t;for (var j = 0; j < entries.link.length; j++) {if (entries.link[j].rel == 'alternate') {url = entries.link[j].href;break;}} for (var j = 0;j < entries.link.length;j++){if (entries.link[j].rel == 'replies' && entries.link[j].type == 'text/html'){pcm = entries.link[j].title.replace('Nhận xét','');break}} if(pcm==0){var postcomment = ''}if(pcm>=1 && pcm<=9){var postcomment = '
    '+pcm+'
    '}if(pcm>=10){var postcomment = '
    HOT
    '} summary = ("summary" in entries && config.summaryPost === true) ? entries.summary.$t : "";if (config.resultThumbnail === true) {img = ("media$thumbnail" in entries) ? entries.media$thumbnail.url.replace(/\/s[0-9]+\-c/g, "/s"+config.thumbSize+"-c") : config.fallbackThumb;}summary = summary.replace(/
    /ig, " ").replace(/<.*?>/g, "").replace(/[<>]/g, "");if (summary.length > config.summaryLength) {summary = summary.substring(0, config.summaryLength) + '...';}summary = summary.replace(); var tennhan = new Array(); var cate = entries.category;if(cate){for (var k = 0;k < entries.category.length;k++){tennhan[k] = ''+entries.category[k].term+''}}else{tennhan = ""} addmore = new Array(); for (var k = 0;k < entries.category.length;k++){if (entries.category[k].term == 'Clip'){var addmore = ''} else if (entries.category[k].term == 'Clip gây sốt giới trẻ'){var addmore = ''} else if (entries.category[k].term == 'Video bàn thắng bóng đá'){var addmore = ''} else if (entries.category[k].term == 'Sao'){var addmore = ''} else if (entries.category[k].term == 'Ảnh'){var addmore = ''} else if (entries.category[k].term == 'Xã hội - Phóng sự ảnh'){var addmore = ''}} skeleton += '
  3. '+addmore+''+title+''+tennhan[0].replace("Tin Tức","Phi thường - Kỳ quặc").replace("Phim 18","Phim 18+")+'
  4. '} skeleton += '
'; skeleton += '
Xem thêm kết quả cho '+input.value+'Hiển thị '+entry.length+' kết quả đầu tiên
'; skeleton += '
'; resultContainer.innerHTML = skeleton;resultLoader.style.display = "none";resultContainer.style.display = "block";} (function() {var s = document.createElement('script');s.type = "text/javascript";s.id = "search-feed-script";document.getElementsByTagName('head')[0].appendChild(s);})(); function updateScript() {resultContainer.style.display = "none";resultLoader.style.display = "block";var script = getId('search-feed-script'),newScript = document.createElement('script'),val = input.value;newScript.id = "search-feed-script";newScript.type = "text/javascript";newScript.src = "/feeds/posts/summary?alt=json-in-script&q="+val+"&max-results=5&callback=showResult";script.parentNode.removeChild(script);document.getElementsByTagName('head')[0].appendChild(newScript);return false;} function resetField() {if (input.value === "") {resultContainer.style.display = "none";resultLoader.style.display = "none";}} /* == UpdateComment == */ var cm_config_defaults ={max_result:1,summary:50,new_tab_link:true,ct_id:"newest-cm",new_cm:"",interval:1000,alert:true},_cookie ={set:function (g,f,j){document.cookie = g + "=" + f + h + ";path=/"},get:function (f){var e = f + "=",h = document.cookie.split(";"),j;for (var g = 0;g < h.length;g++){j = h[g];while (j.charAt(0) == " "){j = j.substring(1,j.length)}if (j.indexOf(e) == 0){return j.substring(e.length,j.length)}}return null},del:function (b){this.set(b,"",- 1)}},tt_cm = (_cookie.get('tt_cm')) ? _cookie.get('tt_cm'):0,doc_title = document.title;for (var i in cm_config_defaults){cm_config_defaults[i] = (typeof (cm_config[i]) == 'undefined') ? cm_config_defaults[i]:cm_config[i]}function showRecentComments(json){var entry = json.feed.entry,total = parseInt(json.feed.openSearch$totalResults.$t,10),originalTitle = document.title;skeleton = "",oldCount = tt_cm,co = cm_config_defaults;skeleton = '';document.getElementById(co.ct_id).innerHTML = skeleton;_cookie.set('tt_cm',total,1000);tt_cm = total}(function (){var head = document.getElementsByTagName('head')[0],script = document.createElement('script'),co = cm_config_defaults;script.type = "text/javascript";script.id = "cm-feed-script";script.src = "/feeds/comments/default?alt=json-in-script&redirect=false&max-results="+co.max_result+"&callback=showRecentComments";head.appendChild(script);setInterval(function (){var newScript = document.createElement('script');newScript.type = "text/javascript";newScript.id = "cm-feed-script";newScript.src = "/feeds/comments/default?alt=json-in-script&redirect=false&max-results="+co.max_result+"&callback=showRecentComments";var oldScript = document.getElementById('cm-feed-script');oldScript.parentNode.removeChild(oldScript);head.appendChild(newScript)},co.interval)})();