Date: Tue, 30 Sep 1997 19:22:10 +0200 (CEST) From: Mikael Karpberg <karpen@ocean.campus.luth.se> To: hackers@FreeBSD.ORG Subject: TIP: cvs commit readers Message-ID: <199709301722.TAA03502@ocean.campus.luth.se>
next in thread | raw e-mail | index | archive | help
Hi! For all you guys out there that read the cvs commit lists, I have a little practical javascript code. Some of you have probably (like me) read the messages, and when wanting to see the diff for a file, used something like the page posted quite some time ago: http://www-intern.bik-gmbh.de/test/cvsmsg.html This works by a CGI script bouncing you to the right page, which is slow. Specially if that server is down or unreachable. :-) So I set out (with the help of a javascipt programmer I know) to correct this problem. The final result is a little javascript function which can be used very easilly with a HTML form to do the same thing, but without CGI programming, and it's therefor a lot easier to add to your own homepage, or so. Having it locally, and not using a CGI scipt makes the thing so much faster. So... For those who are interested, here is the javascript code, embeded into a small page with just a form on it. Feel free to copy and use. Maybe ever add to some page like http://www.freebsd.org/support.html, or let the cgi-script for the cvs pages add it to the CVS root page, or something. -------8<-------- <html> <script language="javascript"> // First we declare a string variable with the basic URL to the cvs var BAS = "http://www.freebsd.org/cgi/cvsweb.cgi/"; // Then we declare the rev offset string. var OBAS = "#rev"; // This is the function which produces the correct cvs-URL for our application. function makecvs(refString) { // Declare two variables to hold the revision and filename, and final URL. var fileString=""; var revString=""; var finalURL=""; // Remove initial spaces... while (refString.charAt(0) == " ") { refString=refString.substring(1,refString.length); } // Using the first space character as delimiter, find the revision. revString=refString.substring(0,refString.indexOf(" ")); if (revString.length==0) { alert("No revision found!"); return false; } // The last part of the string (ending spaces excluded) is the filename while (fileString.length==0) { fileString=refString.substring(refString.lastIndexOf(" ")+1,refString.length); if (fileString.length==0) refString=refString.substring(0,refString.length-1); } // Put the final URL together from the smaller parts. finalURL = BAS+fileString+OBAS+revString; // Change page to the URL we have computed. this.document.location.href=finalURL; return false; } </script> <body> <form onsubmit="return makecvs(document.forms[0].textfield.value);"> Enter change-lines below: <input type=text name="textfield" maxlength=800 size=80> </form> </body> </html> -------8<-------- Enjoy! Please comment on the script if you feel like it. /Mikael
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199709301722.TAA03502>