String sizePart = "";
if (attr.containsKey("width") && attr.containsKey("height")) {
sizePart = "&width=" + attr.get("width") + "&height=" + attr.get("height");
}
attr.put("src", "/imagecreator/?text=+"+FProxyToadlet.l10n("imageinitializing")+"+" + sizePart);
whenJsEnabled.addChild(makeHtmlNodeForParsedTag(new ParsedTag(originalImg, attr)));
whenJsEnabled.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "fetchedBlocks", String.valueOf(0) });
whenJsEnabled.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "requiredBlocks", String.valueOf(1) });
}
} else {
FProxyFetchResult fr = null;
FProxyFetchWaiter waiter = null;
try {
try {
waiter = tracker.makeFetcher(key, maxSize, null, REFILTER_POLICY.RE_FILTER);
fr = waiter.getResultFast();
} catch (FetchException fe) {
whenJsEnabled.addChild("div", "error");
}
if (fr == null) {
whenJsEnabled.addChild("div", "No fetcher found");
} else {
if (fr.isFinished() && fr.hasData()) {
if (logMINOR) {
Logger.minor(this, "ImageElement is completed");
}
whenJsEnabled.addChild(makeHtmlNodeForParsedTag(originalImg));
} else if (fr.failed != null) {
if (logMINOR) {
Logger.minor(this, "ImageElement is errorous");
}
whenJsEnabled.addChild(makeHtmlNodeForParsedTag(originalImg));
} else {
if (logMINOR) {
Logger.minor(this, "ImageElement is still in progress");
}
int total = fr.requiredBlocks;
int fetchedPercent = (int) (fr.fetchedBlocks / (double) total * 100);
Map<String, String> attr = originalImg.getAttributesAsMap();
String sizePart = new String();
if (attr.containsKey("width") && attr.containsKey("height")) {
sizePart = "&width=" + attr.get("width") + "&height=" + attr.get("height");
}
attr.put("src", "/imagecreator/?text=" + fetchedPercent + "%25" + sizePart);
whenJsEnabled.addChild(makeHtmlNodeForParsedTag(new ParsedTag(originalImg, attr)));
whenJsEnabled.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "fetchedBlocks", String.valueOf(fr.fetchedBlocks) });
whenJsEnabled.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "requiredBlocks", String.valueOf(fr.requiredBlocks) });
}
}
} finally {