Friday, January 27, 2006

Scripting: ActiveMenu script update

I've made a few modifications to the ActiveMenu script, mostly to the internal processing and order. A quick overview of the changes:
  • Added two new global variables that affect how the ActiveMenu script operates. These variables required minor modification to the activeMenu_init() function: the event assigned to the headlines in the headline list now uses the activeMenu_strEvent variable for the event type; the active item is now set on page load using the index in the activeMenu_intActiveItem variable.

  • The activeMenu_init() function was modified to enable a more accurate calculation of the story box height. This functionality was moved to the bottom of the script after the rest of the menu intialization has been completed. The calculation is also only done if the activeMenu_bolResize2Fit variable is set to true.

  • The activeMenu_init() function was changed so that the initally viewable story is selected and made visible after the menu is fully initialized. This is done by calling the activeMenu_change() function and based on the value of the activeMenu_intActiveItem variable. This was in part necessitated by the change to the height calculation functionality.

  • Modified the activeMenu_change() function so that it only requires a single parameter, the zero-based index of the story to highlight. Previously the function had to be passed the class associated with the story and the id associated with the headline, but since those values are set in script it was not really necessary as the index is sufficient to identify both.

Notes:
1) IE seems to be producing a height calculation that may not be entirely accurate on the individual nodes of each story. This only seems to affect it, though, when a floated image isn't used on the first DD. This is something that will need additional investigation.

2) One piece of weirdness I encountered was IE calculating the wrong height unless an alert() was inserted in the height calculation code. I suspect that IE may have been too slow to update the offsetHeight value after a DT/DD was set to display='block'. The alert may have been enough of a stall to allow IE to make the appropriate calculation.

I decided to change the method used to do the calculation after discovering this flaw. Now this section of code uses the previously developed activeMenu_change() function to manage the display of each story. The list nodes are then parsed for the storySelected class.

Tuesday, January 17, 2006

Scripting: VBScript and function calls

I noticed some weirdness with some of the data being placed in SQL Server for the mass mailing list. If data entered through a web form contained an apostrophe (such as O'Brien) then the records in the database would duplicate the number of apostrophes on each insert after the initial one (O''Brien, O''''Brien, etc.).

Immediately I supsected that this had to do with the SQLEncode() function provided by Microsoft in the iasutil.asp file. I was correct, and the problem was beginning to look supsiciously familiar (I'm pretty sure I've seen it before, though I'm not sure I actually took the time to resolve the problem). I took a quick glance at the function to see if I could determine the source of the problem.

Basically the problem boils down to the way that VBScript handles the passing of variables to functions. Some languages allow passing of variables by value (byval) or by reference (byref). VBScript has this functionality, but by default passes variable byref. In effect this means that any modification of the function variable will also modify the original one passed to the function.

For example, take the following code:
Dim intGlobalVar
intGlobalVar = 1
Function addOneToNum (intFuncArg)
intFuncArg = intFuncArg + 1
addOneToNum = intFuncArg
End Function
Response.Write(intGlobalVar)
Response.Write(addOneToNum(intGlobalVar))
Response.Write(intGlobalVar)

The first Response.Write() prints out "1". The second Response.Write() prints out "2". While you might expect the third Response.Write() to print out "1" it in fact prints out "2" because intGlobalVar was passed byref to the function and then modified.

There are two methods of solving this particular problem
  1. Specify byval in the function argument list
  2. Reassign function arguments to variables local to the function
I updated the SQLEncode() function so that the arguments are passed byval. I also updated the variables so that they have more uniqueness (to avoid possible confusion).

(Note: In JavaScript simple types are passed by value while complex types are passed by reference. There is no way to modify this behavior ... though I have seen indications that a future version will have this capability.)

References:

Thursday, January 12, 2006

Design: Site Updates

The web oversight group recently had a discussion about making modifications to the AAAS template header so that the end user would have an obvious indication that they were viewing content related to Project 2061. This was sparked in part by the significant modifications made by the annual conference people. That and our dislike of the default header which we seem powerless to influence (but at least the image has been slightly improved).

In the end we decided upon a rather low-key update to our template that provides the end use with the kind of information we think helps in orientation ... a breadcrumb. It's basically a hanging box off the header that provides some basic orientation. I'm not sure exaclty how it will evolve, but for now it contains the text "AAAS » Project 2061" which should be sufficient at least initially. I believe that as we further refine the site structure we'll work on adding additional levels.

Friday, January 06, 2006

Mass Mailing: 2061 Today - Fall 2005

The notice for the Fall 2005 issue of 2061 Today went out on 6 Jan 2005 at 4:23 PM to 1328 recipients.

Scripting: Mass Mailer Updates

When I updated the mass mailing script to fix the sender address template replacement I only updated the code for the HTML template. Luckily I noticed this prior to sending a text-based mail out today and updated the code for the TEXT template.

Webtrends irregularity

Webtrends crashed once again. I had previously thought it was a specific set of characters that cuases the problem. Namely "{}" in the user-agent field. But after this crash that doesn't appear to be the case. A few more problems like this and I may be able to pinpoint the problem. For now, though, I'll just keep winnowing it down until I find the culprit.

The offender this time around ...

2005-12-07 07:32:30 W3SVC48143651 WIZZLE 198.151.218.130 GET /publications/sfaa/online/Chap13.htm - 80 - 202.133.13.234 HTTP/1.0 Mozilla/4.0+(compatible;+MSIE+5.01;+Windows+NT+5.0) - http://www.google.com/search?hl=en&ie=ISO-8859-1&q=effective+learning+process+ www.project2061.org 200 0 0 32641 571 27719

Thursday, January 05, 2006

HTML Coding: CITE Revisited

In an earlier post regarding the <cite> tag I noted that it seemed to me that I was using the tag incorrectly when using it to delimit book titles.

For some reason this snuck back in my head and I spent some time yesterday trolling the newsgroups and web discussions. After a lot of reading I've come to the conclusion that there does not seem to be any kind of general concensus on how the <cite> tag is used and how a book title that is mentioned but not referenced should be marked up. Most people that even think about stuff like this seem to be of the opinion that any of the methods is fine as long as your intended audience gets the meaning.

No doubt communications would like to keep using AP style formatting. I think I'll stick with <cite> and use class names to further categorize if necessary.


References: