var topPos = (this.id.indexOf ("bottom") == -1) ? 0 : screen. availHeight-200; var leftPos = (this.id.indexOf ("Right") == -1) ? 0 : screen. availWidth-300;
We're creating two new variables ,
topPos and
leftPos , based on
screen.availHeight and
screen.availWidth . Each of these lines is a conditional statement, using the alternative method of writing an
if...else conditional we described in the "There's No One Right Way" sidebar in Chapter 2. Here's the way it works: if the word
"bottom" is in the
id (that is,
id as specified in Script 6.12 is either
bottomLeftWin or
bottomRightWin ), we know that the newly opened window needs to be pegged to the bottom of the screen. So,
topPos will be set to whatever the available height is of the screen minus 200 (the height of the window being opened). If
"bottom" isn't in the
id ( causing the
indexOf() check to return -1, meaning not found), then
topPos is set to zero, because it should be pegged to the top of the screen. And ditto for
leftPos and
"Right" .