其实这个本身就是个展示意义罢了,本身也不是真实的数据
var AI = {
getData: function() {
var _this = this
$.ajax({
dataType:'json',
type:'GET',
url:'//url-query.api.pc120.com/warty/getPhishingBlockCounter.json',
data:null,
cache:false,
crossDomain: true == !(document.all),
success: function (json) {
if (json) {
var count = json.counter || 0
$("#J_Num").attr("data-num", count).text(formatNumberRgx(count))
}
},
error: function (error) {
},
complete: function() {
_this.createNum()
}
});
},
queryTimer: function() {
setInterval(this.getData, 1000 * 60 * 60)
},
countTimer: null,
createNum: function() {
if(this.countTimer){
clearInterval(this.countTimer)
this.countTimer = null
}
var $num = $('#J_Num'),
num,
count
this.countTimer = setInterval(function(){
num = $num.attr('data-num') - 0
count = Math.floor(Math.random() * 5)
$num.text(formatNumberRgx(num + count)).attr('data-num', num + count)
}, 100)
},
init: function() {
this.getData()
this.queryTimer()
}
}
function formatNumberRgx(num) {
num = num + ''
num = num.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
return num;
}
$(function() {
AI.init()
})
|