/*user*/ $(function(){ $(".user-wrap").load("https://www.zidonghua.com.cn/index.php?m=member&c=index&a=mini&type=1&forward="+encodeURIComponent(location.href)+"&siteid=1"); }); //cookie var cookie_pre = 'xwSQY_'; var cookie_domain = ''; var cookie_path = '/'; function getcookie(name) { name = cookie_pre+name; var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while(i < clen) { var j = i + alen; if(document.cookie.substring(i, j) == arg) return getcookieval(j); i = document.cookie.indexOf(" ", i) + 1; if(i == 0) break; } return null; } function setcookie(name, value, days) { name = cookie_pre+name; var argc = setcookie.arguments.length; var argv = setcookie.arguments; var secure = (argc > 5) ? argv[5] : false; var expire = new Date(); if(days==null || days==0) days=1; expire.setTime(expire.getTime() + 3600000*24*days); document.cookie = name + "=" + escape(value) + ("; path=" + cookie_path) + ((cookie_domain == '') ? "" : ("; domain=" + cookie_domain)) + ((secure == true) ? "; secure" : "") + ";expires="+expire.toGMTString(); } function delcookie(name) { var exp = new Date(); exp.setTime (exp.getTime() - 1); var cval = getcookie(name); name = cookie_pre+name; document.cookie = name+"="+cval+";expires="+exp.toGMTString(); } function getcookieval(offset) { var endstr = document.cookie.indexOf (";", offset); if(endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr)); } //loading $(document).on("click", "#btn_loading", function() { var cookiepage = getcookie('loadpage') ? getcookie('loadpage') : '0'; var loadednum = $('#news_list').children('a').length; var newpage = Math.ceil(loadednum/10) + 1; var thepage = $('#news_list').attr('data-page') ? $('#news_list').attr('data-page') : newpage; if(parseInt(cookiepage) < parseInt(thepage)){ ajaxRead(thepage); setcookie('loadpage',thepage,'1'); }else{ ajaxRead(newpage); } }); setcookie('loadpage','0','1'); function show(){ if($(window).scrollTop()+$(window).height()+20>=$(document).height() && $('.btn-more').length > 0){ var cookiepage = getcookie('loadpage') ? getcookie('loadpage') : '0'; var loadednum = $('#news_list').children('li').length; var newpage = Math.ceil(loadednum/15) + 1; var thepage = $('#news_list').attr('data-page') ? $('#news_list').attr('data-page') : newpage; if(parseInt(cookiepage) < parseInt(thepage)){ ajaxRead(thepage); setcookie('loadpage',thepage,'1'); }else{ } } }; function ajaxRead(page){ var html=""; var loadednum = $('#news_list').children('a').length; var newpage = Math.ceil(loadednum/10) + 1; var thepage = $('#news_list').attr('data-page') ? $('#news_list').attr('data-page') : newpage; var page = thepage; var thenum = $('#news_list').attr('data-num') ? $('#news_list').attr('data-num') : '0'; thenum = parseInt(thenum); page = parseInt(page); $.ajax({ type:'get', dataType:'json', url:'https://www.zidonghua.com.cn/index.php?m=content&c=index&a=ajaxlists&catid=15&page='+page, beforeSend:function(){}, success:function(data){ //alert(obj2string(data)); if(JSON.stringify(data) != '[]'){ $('#news_list').attr('data-load','ture'); $.each(data,function(i,item){ if(item.thumb){ html+='
'; html+='

'+item.title+'

'; html+='
'+date('Y-m-d H:i:s',item.inputtime)+'
'; }else{ html+=''; html+='

'+item.title+'

'; html+='
'+date('Y-m-d H:i:s',item.inputtime)+'
'; } thenum = thenum +1; $('#news_list').attr('data-num',thenum); }); $('#news_list').attr('data-load','true'); page = page + 1; //alert(page); $('#news_list').attr('data-page',page); $('#news_list').append($(html)); }else{ $('#news_list').attr('data-load','false'); $('#btn_loading').html('暂无更多的数据了'); return false; } }, complete:function(){ var theload = $('#news_list').attr('data-load') ? $('#news_list').attr('data-load') : 'true'; if(theload == 'true'){ }else{ $('#btn_loading').html('暂无更多的数据了'); } } }); }