//加载更多
var p = 2;
var loading = true;
function loadData() {
if (!loading) {
return;
}
loading = false;
var key = $('#softlist').data('key');
//数据请求
$.ajax({
type: 'GET',
url: host + '/api/new.html',
data: {'p': p, 'key': key},
dataType: 'json',
success: function (ret) {
if (ret.code == 200) {
loading = true;
var khtml = '';
$.each(ret.data, function (k, item) {
khtml += '
['+item.sort+']';
khtml += ''+item.fullname+'';
khtml += ''+item.size+'';
khtml += ''+item.language+''+item.time+'';
});
$('#softlist').append(khtml);
p++;
} else {
loading = false;
}
}
})
}
//置顶
$(window).scroll(function () {
var t = $(document).height(), n = $(document).scrollTop(), a = window.innerHeight;
"undefined" != typeof window.pageYOffset ? n = window.pageYOffset : "undefined" != typeof document.compatMode && "BackCompat" != document.compatMode ? n = document.documentElement.scrollTop : "undefined" != typeof document.body && (n = document.body.scrollTop);
if (n >= t - a - 180) {
loadData();
}
}
);