> -----Original Message----- > From: Eric Covener [mailto:cove...@gmail.com] > Sent: Tuesday, May 11, 2010 11:27 PM > To: docs@httpd.apache.org > Subject: Re: javascript in docs? > > On Tue, May 11, 2010 at 1:51 PM, Rich Bowen <rbo...@rcbowen.com> wrote: > > > > I'd like to put a little javascript in the 1.3 docs that takes the > requested > > URI and suggests an equivalent one in the 2.2 docs. Is there any > strong > > objection to doing this? > > > > I've done this. However, in some places, > > likeĀ http://httpd.apache.org/docs/1.3/mod/mod_auth.html for example, > the > > generated link isn't useful. I suppose it would be possible to be > smarter > > than this, but it's a good first step. > > Looks good here!
The links to the new docs will give you a 404 in this instance. Maybe something like this could solve the problem. (Code is not tested!) <script language='Javascript' type='text/javascript'> var oldversion = "1.3"; var newversion = "2.2"; var redirect = { 'mod/mod_auth': 'howto/auth' }; var path = location.pathname; // strip the path before the version to get the doc base path var base = path.slice(path.indexOf(oldversion)); // strip the path after the version to get the filename (+ 2 slashes) var file = path.slice(path.indexOf(oldversion) + 2 + oldversion.length); // strip of all extentions (.en.html) var ext = file.slice(file.indexOf('.')); file = file.slice(0, file.indexOf('.')); // lookup file and redirect or just replace the version number if(redirect[file]) { //FIXME: is the extention still valid? path = base + newversion + '/' + redirect[file] + ext; } else { path = base + newversion + '/' + file + ext; } document.getElementById("docLink").href=(path); </script> The redirect object/hash stores overrides for files in the old docs to the new docs. As the FIXME denotes, I'm not sure if it is safe to reuse the extention from the old docs for the new docs. If it ain't, it is possible to remove this code and provide more specific filename including extention. Vincent de Lau vinc...@delau.nl --------------------------------------------------------------------- To unsubscribe, e-mail: docs-unsubscr...@httpd.apache.org For additional commands, e-mail: docs-h...@httpd.apache.org