2009/4/24 <sas...@freenetproject.org>: > Author: sashee > Date: 2009-04-23 20:06:00 +0000 (Thu, 23 Apr 2009) > New Revision: 27271 > > Added: > trunk/freenet/src/freenet/clients/http/staticfiles/js/ > trunk/freenet/src/freenet/clients/http/staticfiles/js/progresspage.js > Modified: > trunk/freenet/src/freenet/clients/http/FProxyToadlet.java > trunk/freenet/src/freenet/clients/http/ToadletContainer.java > trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java > Log: > The progress page is now refreshed with AJAX, if enabled in the configuration > and in the browser. > > Modified: trunk/freenet/src/freenet/clients/http/FProxyToadlet.java > =================================================================== > --- trunk/freenet/src/freenet/clients/http/FProxyToadlet.java 2009-04-23 > 20:04:56 UTC (rev 27270) > +++ trunk/freenet/src/freenet/clients/http/FProxyToadlet.java 2009-04-23 > 20:06:00 UTC (rev 27271) > @@ -513,12 +513,26 @@ > break; > } else { > // Still in progress > + boolean > isJsEnabled=ctx.getContainer().isFProxyJavascriptEnabled(); > HTMLNode pageNode = > ctx.getPageMaker().getPageNode(l10n("fetchingPageTitle"), ctx); > + String location = getLink(key, > requestedMimeType, maxSize, httprequest.getParam("force", null), > httprequest.isParameterSet("forcedownload")); > + HTMLNode > headNode=ctx.getPageMaker().getHeadNode(pageNode); > + if(isJsEnabled){ > + //If the user has enabled javascript, > we add a <noscript> http refresh(if he has disabled it in the browser) > + //And the script file > + > headNode.addChild("noscript").addChild("meta", "http-equiv", > "Refresh").addAttribute("content", "2;URL=" + location); > + HTMLNode > scriptNode=headNode.addChild("script","//abc"); > + scriptNode.addAttribute("type", > "text/javascript"); > + scriptNode.addAttribute("src", > "/static/js/progresspage.js"); > + }else{ > + //If he disabled it, we just put the > http refresh meta, without the noscript > + headNode.addChild("meta", > "http-equiv", "Refresh").addAttribute("content", "2;URL=" + location); > + } > HTMLNode contentNode = > ctx.getPageMaker().getContentNode(pageNode); > - > HTMLNode infobox = contentNode.addChild("div", > "class", "infobox infobox-information"); > infobox.addChild("div", "class", > "infobox-header", l10n("fetchingPageBox")); > HTMLNode infoboxContent = > infobox.addChild("div", "class", "infobox-content"); > + infoboxContent.addAttribute("id", > "infoContent"); > infoboxContent.addChild("#", > l10n("filenameLabel")+ " "); > infoboxContent.addChild("a", "href", > "/"+key.toString(false, false), key.getPreferredFilename()); > if(fr.mimeType != null) > infoboxContent.addChild("br", l10n("contentTypeLabel")+" "+fr.mimeType); > @@ -586,9 +600,8 @@ > > ul.addChild("li").addChild("p").addChild("a", > new String[] { "href", "title" }, new String[] { "/", > L10n.getString("Toadlet.homepage") }, l10n("abortToHomepage")); > > - String location = getLink(key, > requestedMimeType, maxSize, httprequest.getParam("force", null), > httprequest.isParameterSet("forcedownload")); > MultiValueTable<String, String> retHeaders = > new MultiValueTable<String, String>(); > - retHeaders.put("Refresh", "2; url="+location); > + //retHeaders.put("Refresh", "2; > url="+location); > writeHTMLReply(ctx, 200, "OK", retHeaders, > pageNode.generate()); > fr.close(); > fetch.close(); > > Modified: trunk/freenet/src/freenet/clients/http/ToadletContainer.java > =================================================================== > --- trunk/freenet/src/freenet/clients/http/ToadletContainer.java > 2009-04-23 20:04:56 UTC (rev 27270) > +++ trunk/freenet/src/freenet/clients/http/ToadletContainer.java > 2009-04-23 20:06:00 UTC (rev 27271) > @@ -64,4 +64,6 @@ > public boolean publicGatewayMode(); > > public boolean enableActivelinks(); > + > + public boolean isFProxyJavascriptEnabled(); > } > > Modified: trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java > =================================================================== > --- trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java > 2009-04-23 20:04:56 UTC (rev 27270) > +++ trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java > 2009-04-23 20:06:00 UTC (rev 27271) > @@ -375,6 +375,8 @@ > } catch (RedirectException re) { > uri = re.newuri; > redirect = true; > + } catch(Exception e){ > + > Logger.error(ToadletContextImpl.class, "Caught exception",e); > } finally { > req.freeParts(); > } > > Added: trunk/freenet/src/freenet/clients/http/staticfiles/js/progresspage.js > =================================================================== > --- trunk/freenet/src/freenet/clients/http/staticfiles/js/progresspage.js > (rev 0) > +++ trunk/freenet/src/freenet/clients/http/staticfiles/js/progresspage.js > 2009-04-23 20:06:00 UTC (rev 27271) > @@ -0,0 +1,70 @@ > +window.onload = started; > + > +var req; > + > +function loadXMLDoc(url) { > + req = false; > + if (window.XMLHttpRequest && !(window.ActiveXObject)) { > + try { > + req = new XMLHttpRequest(); > + } catch (e) { > + req = false; > + } > + } else if (window.ActiveXObject) { > + try { > + req = new ActiveXObject("Msxml2.XMLHTTP");
arugggh!! If I were you, I wouldn't support IE6/earlier. Not only this is ugly, IE6/earlier have way too many security issue.. XMLHttpRequest have been aviliable since IE7. _______________________________________________ Devl mailing list Devl@freenetproject.org http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl