[FIXED HUDSON-4590] Defer injection of the script until the page load event fires, so that inability to load scripts from java.net wouldn't block other things that's wating for the firing of the onload event.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@22347 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
kohsuke committed 2009-10-02 18:09:47 +00:00
1 parent 7e2ef35d59
commit 967531a1e3
2 files changed
+9 -3

No files matched your search

@@ -65,7 +65,9 @@ public class DownloadService extends PageDecorator {
long now = System.currentTimeMillis();
for (Downloadable d : Downloadable.all()) {
if(d.getDue()<now) {
buf.append("<script>downloadService.download(")
buf.append("<script>")
.append("Behaviour.addLoadEvent(function() {")
.append(" downloadService.download(")
.append(QuotedStringTokenizer.quote(d.getId()))
.append(',')
.append(QuotedStringTokenizer.quote(d.getUrl()))
@@ -74,7 +76,9 @@ public class DownloadService extends PageDecorator {
.append(',')
.append(QuotedStringTokenizer.quote(Stapler.getCurrentRequest().getContextPath()+'/'+getUrl()+"/byId/"+d.getId()+"/postBack"))
.append(',')
.append("null);</script>");
.append("null);")
.append("});")
.append("</script>");
}
}
}