1function newsData(type, condition, callback) { 2 type = type ? type : 0; 3 // this.cid = jQuery('.info-nav li').eq(0).data('cid'); 4 this.cid = jQuery('.info-nav-select').data('cid'); 5 this.s = getUrlParam('s'); 6 this.action = 'category_list'; 7 this.page = condition && condition.page ? condition.page : 0; 8 this.author = jQuery('#author-id').val(); 9 this.option = getTemplateOption(type); 10 this.condition = condition; 11 this.callback = callback; 12 this.init(); 13} 14 15newsData.prototype = { 16 constructor : newsData, 17 18 init: function() { 19 var that = this; 20 21 jQuery('.info-left-other').on('click', function() { 22 var cid = jQuery('.info-nav .info-nav-select').data('cid'); 23 that.fetchData(1); 24 }); 25 26 jQuery('.content-title span, .info-nav li').on('click', function() { 27 if (jQuery(this).attr('class') != 'info-nav-select') { 28 that.page = 0; 29 jQuery('.info-nav li, .content-title span').removeClass('info-nav-select'); 30 jQuery(this).addClass('info-nav-select'); 31 that.cid = jQuery(this).data('cid'); 32 that.fetchData(0); 33 } 34 }) 35 }, 36 37 fetchData: function(type) { 38 var that = this; 39 jQuery.post(ajaxurl, this._initParam(), function(rst) { 40 jsonObj = JSON.parse(rst); 41 if (jsonObj.state === 0) { 42 var htmlList = jsonObj.result.map(function(e) { 43 return that.option.templateFill(e); 44 }); 45 that.page ++; 46 if (type) { 47 htmlList.unshift(jQuery('.info-list').html()); 48 } 49 jQuery('.info-list').html(htmlList.join('')); 50 loadOver(jsonObj.result.length, that.condition && that.condition.size ? that.condition.size : 15); 51 that.callback && that.callback(jsonObj) 52 } 53 }); 54 }, 55 _initParam: function() { 56 if (this.condition && this.condition.action) { 57 this.condition.page = this.page; 58 return this.condition; 59 } 60 var param = { 61 action : 'category_list', 62 page : this.page 63 }; 64 this.cid && (param['cid'] = this.cid); 65 this.s && (param['s'] = this.s); 66 this.author && (param['author'] = this.author); 67 return param; 68 } 69}; 70 71function getTemplateOption(type) { 72 if (type === 0) { 73 var template = document.getElementById('news-list-item-temp').innerHTML; 74 } else { 75 var template = jQuery('#news-search-item-temp').html(); 76 } 77 78 return { 79 template: template, 80 templateFill: function(e) { 81 return this.template.replace(/{{title}}/g, e.title) 82 .replace(/{{desc}}/, e.desp) 83 .replace(/{{publish_time}}/, e.publish_time) 84 .replace(/{{pic}}/, e.pic) 85 .replace(/{{author_pic}}/, e.author_pic) 86 .replace(/{{author_name}}/, e.author_name) 87 .replace(/{{link}}/g, e.link) 88 .replace(/{{news-icon}}/, e.isnews ? '<span style="background: #ec9b00;" class="tag-flag tag-flag-color1">快讯</span>' : '') 89 } 90 }; 91} 92
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.