View Single Post
  #3  
Old 03-27-2007, 02:07 PM
StevieG StevieG is offline
Senior Member
 
Join Date: Jan 2003
Location: b-more
Posts: 3,558
Default Bookmarklet to Improve Search on the Two Plus Two Forum Archives

Making Archive Search Easier

There is an archive of posts that have not been updated since December 31, 2005. You can search the archives also.

In addition to the search problems you know from the active site, the archive search has the added problem of date range. The date range is required and that is not very easy to work with, because you need to put in a start and stop range for the date, in terms of weeks or days ago, and you need to figure out how long ago Dec 31, 2005 was.

Here is a bookmarklet to specify date ranges for searching the 2+2 archives:

<font class="small">Code:</font><hr /><pre>
javascriptfunction() {maxDays=120; archDate=new Date(2006,00,01);
today=new Date(); var interval=parseInt(prompt("What " +
maxDays + " day interval?\n(1 starts back from " +
(archDate.getMonth()+1) +"/" + (archDate.getDate()+1)
+"/" + (archDate.getYear()+1900) + ")", "1"));
if (isNaN(interval)) {interval=1; };
older=Math.ceil((today.getTime()-archDate.getTime())/(1000*60*60*24)) + (maxDays * (interval-1));
document.forms[0]["newertype"].value="d";
document.forms[0]["oldertype"].value="d";
document.forms[0]["olderval"].value=older;
document.forms[0]["newerval"].value=older+maxDays;})()</pre><hr />

Here's how to use the bookmarklet:

1. Copy all of the above text inside the lines above to your favorite simple text editor, like Notepad.

2. Remove all of the carriage returns, so that all the text is on one line.

3. Create a bookmark or favorite in your browser. Give it a title like "Specify date range for 2+2 archive search"

4. Copy the one line text from step 2 into the URL or Location for the Favorire or Bookmark

Go to the archive page, and once you are there, select the bookmark. When you use the bookmark link on the archive search page, a dialog will come up asking you to select the interval. Use "1" for the 120 days previous to 1/1/2006, "2" for the 120 days before that, and so on.

The code will then automatically insert the correct values into the date range.