(function(win) { win.CB = win.CB || {}; //CB javascript template (author: John Resig http://ejohn.org/blog/javascript-micro-templating/) var cache = {}; this.tmpl = function tmpl(str, data){ var fn = !/\W/.test(str) ? cache[str] = cache[str] || tmpl(document.getElementById(str).innerHTML) : new Function("obj", "var p=[],print=function(){p.push.apply(p,arguments);};" + "with(obj){p.push('" + str.replace(/[\r\t\n]/g, " ") .split("<%").join("\t") .replace(/((^|%>)[^\t]*)'/g, "$1\r") .replace(/\t=(.*?)%>/g, "',$1,'") .split("\t").join("');") .split("%>").join("p.push('") .split("\r").join("\\'") + "');}return p.join('');"); return data ? fn( data ) : fn; }; CB.tmpl = function (str, data) { var fn = !/\W/.test(str) ? cache[str] = cache[str] || tmpl(str) : new Function("obj", "var p=[],print=function(){p.push.apply(p,arguments);};" + "with(obj){p.push('" + str.replace(/[\r\t\n]/g, " ").split("<%").join("\t").replace(/((^|%>)[^\t]*)'/g, "$1\r").replace(/\t=(.*?)%>/g, "',$1,'").split("\t").join("');").split("%>").join("p.push('").split("\r").join("\\'") + "');}return p.join('');"); return data ? fn(data) : fn; }; })(window); function winReady(fn){ if(document.addEventListener){ //标准浏览器 document.addEventListener('DOMContentLoaded',function(){ //注销事件,避免反复触发 document.removeEventListener('DOMContentLoaded',arguments.callee,false); fn(); },false) } else if(document.attachEvent){ //IE,两个条件 document.attachEvent('onreadystatechange',function(){ if(document.readyState=='complete'){ //注销事件,避免反复触发 document.detachEvent('onreadystatechange',arguments.callee); fn(); } }); } } var mobile_bs = { versions: function() { var u = navigator.userAgent; return { trident: u.indexOf("Trident") > -1, presto: u.indexOf("Presto") > -1, webKit: u.indexOf("AppleWebKit") > -1, gecko: u.indexOf("Gecko") > -1 && u.indexOf("KHTML") == -1, mobile: !!u.match(/AppleWebKit.*Mobile.*/) || !!u.match(/AppleWebKit/) && u.indexOf("QIHU") && u.indexOf("QIHU") > -1 && u.indexOf("Chrome") < 0, ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), android: u.indexOf("Android") > -1 || u.indexOf("Linux") > -1, iPhone: u.indexOf("iPhone") > -1 || u.indexOf("Mac") > -1, iPad: u.indexOf("iPad") > -1, webApp: u.indexOf("Safari") == -1 } } () }; winReady(function(){ //画中画 var hzh = {}; hzh.flag = 0; hzh.divid = "cbhahaha"; hzh.surround_num = 100; if (parseInt(window.innerWidth) > 900) { hzh.surround_num = 700; } hzh.str_sum = 0; hzh.str_temp = 0; hzh.p_num = 0; //正文页p标签节点个数 hzh.nodes = []; //所有子节点 hzh.p_node = [];//子节点的p标签数组(不包含孙节点) hzh.img_num = null; //hzh.$ = function(id){return document.getElementById(id);} hzh.$ = function(vArg){ this.elements = []; switch(typeof vArg){ case 'function': //window.onload = vArg hzh.addEvent(window,'load',vArg); break; case 'string': switch(vArg.charAt(0)){ case '#': //id var obj = document.getElementById(vArg.substring(1)); return obj; break; case '.': //class this.elements = hzh.getClass(document,vArg.substring(1)); return this.elements; break; default: //tagName this.elements = document.getElementsByTagName(vArg); return this.elements; } break; case 'object': this.elements.push(vArg); return this.elements; } } hzh.getClass = function(oParent,sClass){ var parent = oParent || document; var re = new RegExp('\b'+sClass+'\b'); var aEles = parent.getElementsByTagName('*'); var arr = []; for(var i=0; i]*>/g,''); //去除HTML tag str = str.replace(/[ | ]*\n/g,'\n'); //去除行尾空白 //str = str.replace(/\n[\s| | ]*\r/g,'\n'); //去除多余空行 str=str.replace(/ /ig,'');//去掉  return str; } hzh.Len = function(str){ //计算字符数 var i,sum; sum=0; for(i=0;i=0) && (str.charCodeAt(i)<=255)) sum=sum+1; else sum=sum+2; } return sum; } hzh.insertAfter = function(newElement,targetElement) { var parent = targetElement.parentNode; if (parent.lastChild == targetElement) { parent.appendChild(newElement); }else { parent.insertBefore(newElement,targetElement.nextSibling); } } hzh.createHzh = function(){ //创建画中画容器(div标签) var oDiv = document.createElement("div"); oDiv.id = hzh.divid; oDiv.className = hzh.className; oDiv.style.cssText = hzh.cssText; oDiv.innerHTML = ''; return oDiv; } hzh.insertAd_after = function(insert_p){ var cur_p = insert_p; hzh.insertAfter(hzh.createHzh(),cur_p); } hzh.insertAd_before = function(thisDiv){ var parent = thisDiv.parentNode; parent.insertBefore(hzh.createHzh(),thisDiv); } hzh.insertClear =function(insert_p){ var oDivClear = document.createElement("div"); oDivClear.style.fontSize = "0px"; oDivClear.style.height = "0px"; oDivClear.style.clear = "both"; var last_p = insert_p; hzh.insertAfter(oDivClear,last_p); } for(var i=0;i= hzh.surround_num) { hzh.p_node.push(hzh.startNode); break; } } else { hzh.startNode = null; hzh.str_sum = 0; continue; } } if(!hzh.noAD){ if (hzh.p_node.length == 1) { if (hzh.p.length > 1) { hzh.insertAd_after(hzh.p_node[hzh.p_node.length-1]); } else { hzh.insertAd_before(hzh.p_node[hzh.p_node.length-1]); } if (1 && $('#CbADsArticle').length > 0) { hzh.$('#CbADsArticle').innerHTML = ''; hzh.hzh_div = hzh.$("#"+hzh.divid); hzh.hzh_div.style.display = 'block'; } } } }); var m_new_tp = '\
  • \

    \ \
  • '; var wap_new_tp = '\ '; var m_new_hot_tp = '\
  • \

    \ \
  • '; var wap_new_hot_tp = '\ '; GV.DETAIL.ADS = {}; var showLatest = function(page) { var latestArea = $("#J_latest_info"), latestHotArea = $("#J_latest_hotinfo"), pageSize = 10; var offset = 0; var showNum = offset + pageSize; if(showNum > GV.DETAIL.NEW.length) showNum = GV.DETAIL.NEW.length; if (latestArea.data('loaded') != '1' && GV.DETAIL.NEW.length > 0) { for (var i=offset; i < showNum; i++) { var html = ''; // new if (typeof GV.DETAIL.NEW[i] == 'object' && GV.DETAIL.SID == GV.DETAIL.NEW[i].sid) { (GV.DETAIL.NEW).splice(i, 1); } if (typeof GV.DETAIL.NEW[i] == 'object') { if ($("#J_sid_"+GV.DETAIL.NEW[i].sid).length > 0) continue; // filter if (typeof GV.DETAIL.NEW[i].inputtime != 'undefined') { GV.DETAIL.NEW[i].posttime = (GV.DETAIL.NEW[i].inputtime).substr(11); } if (GV.MT == 'm') { html = CB.tmpl(m_new_tp, GV.DETAIL.NEW[i]); } else if (GV.MT == 'wap') { html = CB.tmpl(wap_new_tp, GV.DETAIL.NEW[i]); } } if (parseInt(GV.DETAIL.ADS.latest.position) == i + 1 && GV.DETAIL.ADS.latest.content) { html += '
    ' + GV.DETAIL.ADS.latest.content + '
    '; } if (html) latestArea.append(html); } } if (latestHotArea.data('loaded') != '1' && GV.DETAIL.HOT.length > 0) { for (var i=offset; i < showNum; i++) { var hothtml = ''; // hot if (typeof GV.DETAIL.HOT[i] == 'object' && GV.DETAIL.SID == GV.DETAIL.HOT[i].sid) { (GV.DETAIL.HOT).splice(i, 1); } if (typeof GV.DETAIL.HOT[i] == 'object') { if ($("#J_sid_"+GV.DETAIL.HOT[i].sid).length > 0) continue; // filter if (typeof GV.DETAIL.HOT[i].inputtime != 'undefined') { GV.DETAIL.HOT[i].posttime = (GV.DETAIL.HOT[i].inputtime).substr(11); } if (GV.MT == 'm') { hothtml = CB.tmpl(m_new_hot_tp, GV.DETAIL.HOT[i]); } else if (GV.MT == 'wap') { hothtml = CB.tmpl(wap_new_hot_tp, GV.DETAIL.HOT[i]); } if (parseInt(GV.DETAIL.ADS.hot.position) == i + 1 && GV.DETAIL.ADS.hot.content) { hothtml += '
    ' + GV.DETAIL.ADS.hot.content + '
    '; } if (hothtml) latestHotArea.append(hothtml); } } } $(".J_an_load").hide(); }; setTimeout(function(){ if (GV.DETAIL.SID) { $.ajax({ async: true, type: "get", url: GV.VURL ? GV.VURL : '/home/v?id=' + GV.DETAIL.SID + '&from=m', dataType: "json", cache: !0, data: {'op':'mobile'}, beforeSend: function() { }, success: function(data) { if (data.state == 'success') { var res = typeof data.result == 'string' ? $.parseJSON(data.result) : data.result; if (typeof res.ads == 'object') { GV.DETAIL.ADS = res.ads; } // init latest infos if (typeof res.latest.list != 'undefined') { GV.DETAIL.NEW = res.latest.list; GV.DETAIL.HOT = typeof res.latest.hot != 'undefined' ? res.latest.hot : {}; showLatest(1); } else { GV.DETAIL.NEW = GV.DETAIL.HOT = {}; } if (typeof res.neighbor.last != 'undefined') { $('#go_pre').attr('href', '/view/' + res.neighbor.last + '.htm'); } if (typeof res.neighbor.next != 'undefined') { $('#go_next').attr('href', '/view/' + res.neighbor.next + '.htm'); } else { $('#go_next').html('没有了'); $('#go_nav').addClass('half'); } } $(".J_an_load").hide(); } }); } }, 2000);