MCPcopy Index your code
hub / github.com/hoothin/UserScripts / imgReady

Function imgReady

Picviewer CE+/dist.user.js:13935–14173  ·  view source on GitHub ↗
(img,opts)

Source from the content-addressed store, hash-verified

13933
13934 var errorList = {}, errorBlobList = {};
13935 var imgReady=function(img,opts){
13936
13937 if(/NodeList|HTMLCollection/.test(Object.prototype.toString.call(img)) || Array.isArray(img)){
13938 arrayFn.forEach.call(img,function(img,index,array){
13939 if(img instanceof HTMLImageElement){
13940 imgReady(img,opts);
13941 };
13942 });
13943 return;
13944 };
13945
13946 if(!(img instanceof HTMLImageElement)){
13947 var t_img=document.createElement('img');
13948 t_img.src=img;
13949 img=t_img;
13950 t_img=null;
13951 };
13952
13953 var ready,load,error,loadEnd,abort,timeout,time;
13954 ready=opts.ready;
13955 load=opts.load;
13956 error=opts.error;
13957 loadEnd=opts.loadEnd;
13958 abort=opts.abort;
13959 timeout=opts.timeout;
13960 time=typeof opts.time=='number'? opts.time : 0;
13961
13962 if(time){
13963 setTimeout(function(){
13964 if(!loadEndDone){
13965 aborted=true;
13966 removeListener();
13967 img.src= prefs.icons.brokenImg_small;
13968 if(timeout){
13969 timeout.call(img,{
13970 target:img,
13971 type:'timeout',
13972 });
13973 };
13974 loadEndDone=true;
13975 if(loadEnd){
13976 loadEnd.call(img,{
13977 target:img,
13978 type:'timeout',
13979 });
13980 };
13981
13982 };
13983 },time);
13984 };
13985
13986 var src=img.src;
13987 var loadEndDone;
13988
13989 function go(type,e){
13990 switch(type){
13991 case 'load':{
13992 removeListener();

Callers 5

initFunction · 0.70
popupFiddleWindowFunction · 0.70
loadImgFunction · 0.70
beginLoadImgFunction · 0.70
handleMessageFunction · 0.70

Calls 2

removeListenerFunction · 0.70
goFunction · 0.70

Tested by

no test coverage detected