Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pingcdn #5

Open
jadenben01 opened this issue Apr 4, 2019 · 0 comments
Open

pingcdn #5

jadenben01 opened this issue Apr 4, 2019 · 0 comments

Comments

@jadenben01
Copy link
Owner

var cdnPing=function(i,a){if(!i||!Array.isArray(i)||i.length<=0)console.log("cdns is empty");else for(var l=0,r=!1,t=0;t<i.length;t++)!function(){var n=i[t],e=n+"/"+"cdn/A03PF/externals/img",o=new Image;o.onload=function(){r||(r=!0,a(e))},o.onerror=function(){-1!=o.src.indexOf("cdn_test_50k.jpg")&&(o.failed||l++,o.failed=!0,l==i.length&&console.error("all domian ping failed"))},o.src=e+"/cdn_test_50k.jpg?v="+Math.ceil(Math.random()*Math.pow(10,10)),setTimeout(function(){o.complete&&o.naturalWidth||(o.failed||l++,o.failed=!0,console.log(n+"...img load timeout"),l==i.length&&console.error("all domian ping failed"))},1e3)}()},cdns=yunweiConfig.cdns;cdnPing(cdns,function(n){yunweiConfig.imageServer=n,console.log("change imageServer to "+n)});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant