var plCtrl = {
loaded:0,
total:0,
now:0,
maxl:5,
nshow:false,
cbfun:null,
isOk:false,
toLoad:[],
res:[],
checkLoadComplete:function(){
if(this.loaded>=this.total) {
this.isOk=true;
}
var per = parseInt(this.loaded*100/this.total);
if(per>=100) {
per=100;
alertTips.hide();
this.nshow=false;
if(typeof(this.cbfun)=='function') {
this.cbfun();
}
} else {
$('#lper2').html(per+'');
}
},
show:function(cf){
this.cbfun=cf;
this.nshow=true;
},
loadImage:function(iData,iobj){
var _this = this;
var img = iobj;
if(!img) {
img = new Image();
}
var t=0;
img.onload = function () {
_this.loaded++;
_this.checkLoadComplete();
_this.doLoad(img);
};
img.onerror = function(){
t++;
if(t>3) {
_this.loaded++;
_this.checkLoadComplete();
_this.doLoad(img);
} else {
img.src = iData+'?r=1';
}
}
img.src = iData;
},
doLoad:function(iobj){
if(this.now>=this.total) {
return;
}
this.loadImage(this.toLoad[this.now],iobj);
this.now++;
},
load:function(list,cf){
this.res = [];
this.cbfun=cf;
this.total = list.length;
this.loaded = 0;
this.now = 0;
var maxp = this.total;
this.toLoad = list;
for(var i=0;i<this.maxl;i++) {
this.loadImage(list[i]);
}
this.now=this.maxl;
}
}