home *** CD-ROM | disk | FTP | other *** search
/ Netscape Plug-Ins Developer's Kit / Netscape_Plug-Ins_Developers_Kit.iso / DOCS / se_javas / 15EXM04.TXT < prev    next >
Encoding:
Text File  |  1996-07-08  |  25.0 KB  |  754 lines

  1. <html>
  2. <head>
  3. <title>The Show</title>
  4. <script language="JavaScript">
  5. <!-- begin script
  6. //******************************************************
  7. // Chapter 16 - Visual Effects
  8. // Functions/Objects
  9. //******************************************************
  10. var hexchars = '0123456789ABCDEF';
  11. function fromHex (str) {
  12.   var high = str.charAt(0); // Note: Netscape 2.0 bug workaround
  13.   var low = str.charAt(1);
  14.   return (16 * hexchars.indexOf(high)) +
  15.     hexchars.indexOf(low);
  16. }
  17. function toHex (num) {
  18.   return hexchars.charAt(num >> 4) + hexchars.charAt(num & 0xF);
  19. }
  20. function Color (str) {
  21.   this.red = fromHex(str.substring(0,2));
  22.   this.green = fromHex(str.substring(2,4));
  23.   this.blue = fromHex(str.substring(4,6));
  24.   this.toString = ColorString;
  25.   return this;
  26. }
  27. function ColorString () {
  28.   return toHex(this.red) + toHex(this.green) + toHex(this.blue);
  29. }
  30. function BodyColor (bgColor,fgColor,linkColor,vlinkColor,alinkColor) {
  31.   this.bgColor = bgColor;
  32.   this.fgColor = fgColor;
  33.   this.linkColor = linkColor;
  34.   this.vlinkColor = vlinkColor;
  35.   this.alinkColor = alinkColor;
  36.   this.toString = BodyColorString;
  37.   return this;
  38. }
  39. function BodyColorString () {
  40.   return '<body' +
  41.     ((this.bgColor == null) ? '' : ' bgcolor="#' + this.bgColor + '"') +
  42.     ((this.fgColor == null) ? '' : ' text="#' + this.fgColor + '"') +
  43.     ((this.linkColor == null) ? '' : ' link="#' + this.linkColor + '"') +
  44.     ((this.vlinkColor == null) ? '' : ' vlink="#' + this.vlinkColor + '"') +
  45.     ((this.alinkColor == null) ? '' : ' alink="#' + this.alinkColor + '"') +
  46.     '>';
  47. }
  48. function IntColor (start, end, step, steps) {
  49.   this.red = Math.round(start.red+(((end.red-start.red)/(steps-1))*step));
  50.   this.green = Math.round(start.green+(((end.green-start.green)/(steps-1))*step));
  51.   this.blue = Math.round(start.blue+(((end.blue-start.blue)/(steps-1))*step));
  52.   this.toString = ColorString;
  53.   return this;
  54. }
  55. function Alternator (bodyA, bodyB, text) {
  56.   this.bodyA = bodyA;
  57.   this.bodyB = bodyB;
  58.   this.currentBody = "A";
  59.   this.text = text;
  60.   this.toString = AlternatorString;
  61.   return this;
  62. }
  63. function AlternatorString () {
  64.   var str = "<html>";
  65.   with (this) {
  66.     if (currentBody == "A") {
  67.       str += bodyA;
  68.       currentBody = "B";
  69.     }
  70.     else {
  71.       str += bodyB;
  72.       currentBody = "A";
  73.     }
  74.     str += text + '</body></html>';
  75.   }
  76.   return str;
  77. }
  78. function Fader (bodyA, bodyB, steps, text) {
  79.   this.bodyA = bodyA;
  80.   this.bodyB = bodyB;
  81.   this.step = 0;
  82.   this.steps = steps;
  83.   this.text = text;
  84.   this.toString = FaderString;
  85.   return this;
  86. }
  87. function FaderString () {
  88.   var intBody = new BodyColor();
  89.   with (this) {
  90.     if (bodyA.bgColor != null && bodyB.bgColor != null)
  91.       intBody.bgColor = new IntColor (bodyA.bgColor, bodyB.bgColor, step, steps);
  92.     if (bodyA.fgColor != null && bodyB.fgColor != null)
  93.       intBody.fgColor = new IntColor (bodyA.fgColor, bodyB.fgColor, step, steps);
  94.     if (bodyA.linkColor != null && bodyB.linkColor != null)
  95.       intBody.linkColor = new IntColor (bodyA.linkColor, bodyB.linkColor, step, steps);
  96.     if (bodyA.vlinkColor != null && bodyB.vlinkColor != null)
  97.       intBody.vlinkColor = new IntColor (bodyA.vlinkColor, bodyB.vlinkColor, step, steps);
  98.     if (bodyA.alinkColor != null && bodyB.alinkColor != null)
  99.       intBody.alinkColor = new IntColor (bodyA.alinkColor, bodyB.alinkColor, step, steps);
  100.     step++;
  101.     if (step >= steps)
  102.       step = 0;
  103.   }
  104.   return '<html>' + intBody + this.text + '</body></html>';
  105. }
  106. function Static (body, text) {
  107.   this.body = body;
  108.   this.text = text;
  109.   this.toString = StaticString;
  110.   return this;
  111. }
  112. function StaticString () {
  113.   return '<html>' + this.body + this.text + '</body></html>';
  114. }
  115. function Text (text, size, format, color) {
  116.   this.text = text;
  117.   this.length = text.length;
  118.   this.size = size;
  119.   this.format = format;
  120.   this.color = color;
  121.   this.toString = TextString;
  122.   this.substring = TextString;
  123.   return this;
  124. }
  125. function TextString (start, end) {
  126.   with (this) {
  127.     if (TextString.arguments.length < 2 || start >= length) start = 0;
  128.     if (TextString.arguments.length < 2 || end > length) end = length;
  129.     var str = text.substring(start,end);
  130.     if (format != null) {
  131.       if (format.indexOf("b") >= 0) str = str.bold();
  132.       if (format.indexOf("i") >= 0) str = str.italics();
  133.       if (format.indexOf("f") >= 0) str = str.fixed();
  134.     }
  135.     if (size != null) str = str.fontsize(size);
  136.     if (color != null) { 
  137.       var colorstr = color.toString(); // Note: Netscape 2.0 bug workaround
  138.       str = str.fontcolor(colorstr);
  139.     }
  140.   }
  141.   return str;
  142. }
  143. function Block () {
  144.   var argv = Block.arguments;
  145.   var argc = argv.length;
  146.   var len = 0;
  147.   for (var i = 0; i < argc; i++) {
  148.     len += argv[i].length;
  149.     this[i] = argv[i];
  150.   }
  151.   this.length = len;
  152.   this.entries = argc;
  153.   this.toString = BlockString;
  154.   this.substring = BlockString;
  155.   return this;
  156. }  
  157. function BlockString (start, end) {
  158.   with (this) {
  159.     if (BlockString.arguments.length < 2 || start >= length) start = 0;
  160.     if (BlockString.arguments.length < 2 || end > length) end = length;
  161.   }
  162.   var str = "";
  163.   var segstart = 0;
  164.   var segend = 0;
  165.   for (var i = 0; i < this.entries; i++) {
  166.     segend = segstart + this[i].length;
  167.     if (segend > start)
  168.       str += this[i].substring(Math.max(start,segstart)-segstart, Math.min(end,segend)-segstart);
  169.     segstart += this[i].length;
  170.     if (segstart >= end)
  171.       break;
  172.   }
  173.   return str;
  174. }
  175. function Marquee (body, text, maxlength, step) {
  176.   this.body = body;
  177.   this.text = text;
  178.   this.length = text.length;
  179.   this.maxlength = maxlength;
  180.   this.step = step;
  181.   this.offset = 0;
  182.   this.toString = MarqueeString;
  183.   return this;
  184. }
  185. function MarqueeString () {
  186.   with (this) {
  187.     var endstr = offset + maxlength;
  188.     var remstr = 0;
  189.     if (endstr > text.length) {
  190.       remstr = endstr - text.length;
  191.       endstr = text.length;
  192.     }
  193.     var str = nbsp(text.substring(offset,endstr) +
  194.       ((remstr == 0) ? "" : text.substring(0,remstr)));
  195.     offset += step;
  196.     if (offset >= text.length)
  197.       offset = 0;
  198.     else if (offset < 0)
  199.       offset = text.length - 1;
  200.   }
  201.   return '<html>' + this.body + '<table border=0 width=100% height=100%><tr>' +
  202.     '<td align="center" valign="center">' + str + '</td></tr></table></body></html>';
  203. }
  204. function nbsp (strin) {
  205.   var strout = "";
  206.   var intag = false;
  207.   var len = strin.length;
  208.   for(var i=0, j=0; i < len; i++) {
  209.     var ch = strin.charAt(i);
  210.     if (ch == "<")
  211.       intag = true;
  212.     else if (ch == ">")
  213.       intag = false;
  214.     else if (ch == " " && !intag) {
  215.       strout += strin.substring(j,i) + " ";
  216.       j = i + 1;
  217.     }
  218.   }
  219.   return strout + strin.substring(j,len);
  220. }
  221. function Image (url, width, height) {
  222.   this.url = url;
  223.   this.width = width;
  224.   this.height = height;
  225.   return this;
  226. }
  227. function Animator (name, body) {
  228.   var argv = Animator.arguments;
  229.   var argc = argv.length;
  230.   for (var i = 2; i < argc; i++)
  231.     this[i-2] = argv[i];
  232.   this.name = name;
  233.   this.body = body;
  234.   this.images = argc - 2;
  235.   this.image = 0;
  236.   this.ready = "y";
  237.   this.toString = AnimatorString;
  238.   return this;
  239. }
  240. function AnimatorString () {
  241.   var bodystr = this.body.toString();
  242.   var bodystr = bodystr.substring(0, bodystr.length - 1) +
  243.     ' onLoad="parent.' + this.name + '.ready=\'y\'">';
  244.   var str = '<html>' + bodystr + 
  245.     '<table border=0 width=100% height=100%><tr><td align="center" valign="center">' +
  246.     '<img src="' + this[this.image].url + '" width=' + this[this.image].width + 
  247.     ' height=' + this[this.image].height + '></td></table></body></html>';
  248.   this.image++;
  249.   if (this.image >= this.images)
  250.     this.image = 0;
  251.   this.ready = "n";
  252.   return str;
  253. }
  254. function Event (start, loops, delay, action) {
  255.   this.start = start * 1000;
  256.   this.next = this.start;
  257.   this.loops = loops;
  258.   this.loopsRemaining = loops;
  259.   this.delay = delay * 1000;
  260.   this.action = action;
  261.   return this;
  262. }
  263. function EventQueue (name, delay, loopAfter, loops, stopAfter) {
  264.   this.active = true;
  265.   this.name = name;
  266.   this.delay = delay * 1000;
  267.   this.loopAfter = loopAfter * 1000;
  268.   this.loops = loops;
  269.   this.loopsRemaining = loops;
  270.   this.stopAfter = stopAfter * 1000;
  271.   this.event = new Object();
  272.   this.start = new Date ();
  273.   this.loopStart = new Date();
  274.   this.eventID = 0;
  275.   this.addEvent = AddEvent;
  276.   this.processEvents = ProcessEvents;
  277.   this.startQueue = StartQueue;
  278.   this.stopQueue = StopQueue;
  279.   return this;
  280. }
  281. function AddEvent (event) {
  282.   this.event[this.eventID++] = event;
  283. }
  284. function StartQueue () {
  285.   with (this) {
  286.     active = true;
  287.     start = new Date();
  288.     loopStart = new Date();
  289.     loopsRemaining = loops;
  290.     setTimeout (name + ".processEvents()", this.delay);
  291.   }
  292. }
  293. function StopQueue () {
  294.   this.active = false;
  295. }
  296. function ProcessEvents () {
  297.   with (this) {
  298.     if (!active) return;
  299.     var now = new Date();
  300.     if (now.getTime() - start.getTime() >= stopAfter) {
  301.       active = false;
  302.       return;
  303.     }
  304.     var elapsed = now.getTime() - loopStart.getTime();
  305.     if (elapsed >= loopAfter) {
  306.       if (--loopsRemaining <= 0) {
  307.         active = false;
  308.         return;
  309.       }
  310.       loopStart = new Date();
  311.       elapsed = now.getTime() - loopStart.getTime();
  312.       for (var i in event)
  313.         if (event[i] != null) {
  314.           event[i].next = event[i].start;
  315.           event[i].loopsRemaining = event[i].loops;
  316.         }
  317.     }
  318.     for (var i in event)
  319.       if (event[i] != null)
  320.         if (event[i].next <= elapsed)
  321.           if (event[i].loopsRemaining-- > 0) {
  322.             event[i].next = elapsed + event[i].delay;
  323.             eval (event[i].action);
  324.           }
  325.     setTimeout (this.name + ".processEvents()", this.delay);
  326.   }
  327. }
  328. function xbmDrawPoint (x,y) {
  329.   if (x < 0 || x >= this.pixelWidth ||
  330.       y < 0 || y >= this.height)
  331.     return;
  332.   this.row[y].col[x>>4] |= 1<<(x&0xF);
  333.   this.row[y].redraw = true;
  334. }
  335. function xbmDrawLine (x1,y1,x2,y2) {
  336.   var x,y,e,temp;
  337.   var dx = Math.abs(x1-x2);
  338.   var dy = Math.abs(y1-y2);
  339.   if ((dx >= dy && x1 > x2) || (dy > dx && y1 > y2)) {
  340.     temp = x2;
  341.     x2 = x1;
  342.     x1 = temp;
  343.     temp = y2;
  344.     y2 = y1;
  345.     y1 = temp;
  346.   }
  347.   if (dx >= dy) {
  348.     e = (y2-y1)/((dx == 0) ? 1 : dx);
  349.     for (x = x1, y = y1; x <= x2; x++, y += e)
  350.       this.drawPoint(x,Math.round(y));
  351.   }
  352.   else {
  353.     e = (x2-x1)/dy;
  354.     for (y = y1, x = x1; y <= y2; y++, x += e)
  355.       this.drawPoint(Math.round(x),y);
  356.   }
  357. }
  358. function xbmDrawRect (x1,y1,x2,y2) {
  359.   this.drawLine (x1,y1,x2,y1);
  360.   this.drawLine (x1,y1,x1,y2);
  361.   this.drawLine (x1,y2,x2,y2);
  362.   this.drawLine (x2,y1,x2,y2);
  363. }
  364. function xbmDrawFilledRect (x1,y1,x2,y2) {
  365.   var x,temp;
  366.   if (x1 > x2) {
  367.     temp = x2;
  368.     x2 = x1;
  369.     x1 = temp;
  370.     temp = y2;
  371.     y2 = y1;
  372.     y1 = temp;
  373.   }
  374.   for (x = x1; x <= x2; x++)
  375.     this.drawLine(x,y1,x,y2);
  376. }
  377. function xbmDrawCircle (x,y,radius) {
  378.   for (var a=0, b=1; a < b; a++) {
  379.     b = Math.round(Math.sqrt(Math.pow(radius,2)-Math.pow(a,2)));
  380.     this.drawPoint(x+a,y+b);
  381.     this.drawPoint(x+a,y-b);
  382.     this.drawPoint(x-a,y+b);
  383.     this.drawPoint(x-a,y-b);
  384.     this.drawPoint(x+b,y+a);
  385.     this.drawPoint(x+b,y-a);
  386.     this.drawPoint(x-b,y+a);
  387.     this.drawPoint(x-b,y-a);
  388.   }
  389. }
  390. function xbmDrawFilledCircle (x,y,radius) {
  391.   for (var a=0, b=1; a < b; a++) {
  392.     b = Math.round(Math.sqrt(Math.pow(radius,2)-Math.pow(a,2)));
  393.     this.drawLine(x+a,y+b,x+a,y-b);
  394.     this.drawLine(x-a,y+b,x-a,y-b);
  395.     this.drawLine(x+b,y+a,x+b,y-a);
  396.     this.drawLine(x-b,y+a,x-b,y-a);
  397.   }
  398. }
  399. function xbmReverse () {
  400.   this.negative = !this.negative;
  401.   for (var i = 0; i < this.height; i++)
  402.     this.row[i].redraw = true;
  403. }
  404. function xbmClear (value) {
  405.   if (value == null)
  406.     value = this.initialValue;
  407.   for (var i = 0; i < this.height; i++) {
  408.     this.row[i].redraw = true;
  409.     for (var j = 0; j < this.width; j++)
  410.       this.row[i].col[j] = value;
  411.   }
  412. }
  413. function xbmRowString () {
  414.   if (this.redraw) {
  415.     this.redraw = false;
  416.     this.text = "";
  417.     for (var i = 0; i < this.parent.width; i++) {
  418.       var pixels = this.col[i];
  419.       if (this.parent.negative)
  420.         pixels ^= 0xFFFF;
  421.       var buf = "0x" + hexchars.charAt((pixels>>4)&0xF) +
  422.         hexchars.charAt(pixels&0xF) + ",0x" +
  423.         hexchars.charAt((pixels>>12)&0xF) +
  424.         hexchars.charAt((pixels>>8)&0xF) + ",";
  425.       this.text += buf;
  426.     }
  427.   }
  428.   return this.text;
  429. }
  430. function xbmPartitionString (left,right) {
  431.   if (left == right) {
  432.     var str = this.row[left].toString();
  433.     if (left == 0)
  434.       str = this.head + str;
  435.     else if (left == this.height - 1)
  436.       str += "};\n";
  437.     return str;
  438.   }
  439.   var mid = (left+right)>>1;
  440.   return this.partition(left,mid) + this.partition(mid+1,right);
  441. }
  442. function xbmString () {
  443.   return this.partition(0,this.height - 1);
  444. }
  445. function xbmRow (parent, columns, initialValue) {
  446.   this.redraw = true;
  447.   this.text = null;
  448.   this.parent = parent;
  449.   this.col = new Object();
  450.   for (var i = 0; i < columns; i++)
  451.     this.col[i] = initialValue;
  452.   this.toString = xbmRowString;
  453.   return this;
  454. }
  455. function xbmImage (width, height, initialValue) {
  456.   this.width = (width+15)>>4;
  457.   this.pixelWidth = this.width<<4;
  458.   this.height = height;
  459.   this.head = "#define xbm_width " + (this.pixelWidth) +
  460.     "\n#define xbm_height " + this.height +
  461.     "\nstatic char xbm_bits[] = {\n";
  462.   this.initialValue = ((initialValue == null) ? 0 : initialValue);
  463.   this.negative = false;
  464.   this.row = new Object();
  465.   for (var i = 0; i < height; i++)
  466.     this.row[i] = new xbmRow(this, this.width, this.initialValue);
  467.   this.drawPoint = xbmDrawPoint;
  468.   this.drawLine = xbmDrawLine;
  469.   this.drawRect = xbmDrawRect;
  470.   this.drawFilledRect = xbmDrawFilledRect;
  471.   this.drawCircle = xbmDrawCircle;
  472.   this.drawFilledCircle = xbmDrawFilledCircle;
  473.   this.reverse = xbmReverse;
  474.   this.clear = xbmClear;
  475.   this.partition = xbmPartitionString;
  476.   this.toString = xbmString;
  477.   return this;
  478. }
  479. //******************************************************
  480. // The Show
  481. //******************************************************
  482.  
  483. var black = new Color ("000000");
  484. var white = new Color ("FFFFFF");
  485. var red = new Color ("FF0000");
  486. var green = new Color ("00FF00");
  487. var blue = new Color ("0000FF");
  488. var yellow = new Color ("FFFF00");
  489. var cyan = new Color ("00FFFF");
  490. var magenta = new Color ("FF00FF");
  491. var pink = new Color ("FF80A0");
  492. var orange = new Color ("FF5010");
  493.  
  494. var blackOnBlack = new BodyColor (black,black);
  495. var blackOnWhite = new BodyColor (white,black);
  496. var whiteOnWhite = new BodyColor (white,white);
  497. var whiteOnBlack = new BodyColor (black,white);
  498. var redOnWhite = new BodyColor (white,red);
  499. var whiteOnRed = new BodyColor (red,white);
  500. var blueOnWhite = new BodyColor (white,blue);
  501. var redOnYellow = new BodyColor (yellow,red);
  502. var yellowOnRed = new BodyColor (red,yellow);
  503. var pinkOnGreen = new BodyColor (green,pink);
  504. var greenOnPink = new BodyColor (pink,green);
  505. var orangeOnWhite = new BodyColor (white,orange);
  506. var whiteOnOrange = new BodyColor (orange,white);
  507. var blueOnYellow = new BodyColor (yellow,blue);
  508. var yellowOnBlue = new BodyColor (blue,yellow);
  509. var blueOnBlack = new BodyColor (black,blue);
  510. var yellowOnBlack = new BodyColor (black,yellow);
  511. var blueOnRed = new BodyColor (red,blue);
  512. var orangeOnGreen = new BodyColor (green,orange);
  513.  
  514. var blackout = new Static (blackOnBlack, "");
  515. var whiteout = new Static (whiteOnWhite, "");
  516.  
  517. var square1 = new xbmImage (48,48);
  518. square1.drawRect (23,23,24,24);
  519. square1.drawRect (19,19,28,28);
  520. square1.drawRect (15,15,32,32);
  521. square1.drawRect (11,11,36,36);
  522. square1.drawRect (7,7,40,40);
  523. square1.drawRect (3,3,44,44);
  524. var sq1str = square1.toString();
  525.  
  526. var square2 = new xbmImage (48,48);
  527. square2.drawRect (22,22,25,25);
  528. square2.drawRect (18,18,29,29);
  529. square2.drawRect (14,14,33,33);
  530. square2.drawRect (10,10,37,37);
  531. square2.drawRect (6,6,41,41);
  532. square2.drawRect (2,2,45,45);
  533. var sq2str = square2.toString();
  534.  
  535. var square3 = new xbmImage (48,48);
  536. square3.drawRect (21,21,26,26);
  537. square3.drawRect (17,17,30,30);
  538. square3.drawRect (13,13,34,34);
  539. square3.drawRect (9,9,38,38);
  540. square3.drawRect (5,5,42,42);
  541. square3.drawRect (1,1,46,46);
  542. var sq3str = square3.toString();
  543.  
  544. var square4 = new xbmImage (48,48);
  545. square4.drawRect (20,20,27,27);
  546. square4.drawRect (16,16,31,31);
  547. square4.drawRect (12,12,35,35);
  548. square4.drawRect (8,8,39,39);
  549. square4.drawRect (4,4,43,43);
  550. square4.drawRect (0,0,47,47);
  551. var sq4str = square4.toString();
  552.  
  553. var circle1 = new xbmImage (48,48);
  554. circle1.drawCircle (23,23,1);
  555. circle1.drawCircle (23,23,7);
  556. circle1.drawCircle (23,23,13);
  557. circle1.drawCircle (23,23,19);
  558. circle1.drawCircle (23,23,25);
  559. var cir1str = circle1.toString();
  560.  
  561. var circle2 = new xbmImage (48,48);
  562. circle2.drawCircle (23,23,2.5);
  563. circle2.drawCircle (23,23,8.5);
  564. circle2.drawCircle (23,23,14.5);
  565. circle2.drawCircle (23,23,20.5);
  566. circle2.drawCircle (23,23,26.5);
  567. var cir2str = circle2.toString();
  568.  
  569. var circle3 = new xbmImage (48,48);
  570. circle3.drawCircle (23,23,4);
  571. circle3.drawCircle (23,23,10);
  572. circle3.drawCircle (23,23,16);
  573. circle3.drawCircle (23,23,22);
  574. var cir3str = circle3.toString();
  575.  
  576. var circle4 = new xbmImage (48,48);
  577. circle4.drawCircle (23,23,5.5);
  578. circle4.drawCircle (23,23,11.5);
  579. circle4.drawCircle (23,23,17.5);
  580. circle4.drawCircle (23,23,23.5);
  581. var cir4str = circle4.toString();
  582.  
  583. var sqanim = new Animator ("sqanim", blueOnYellow,
  584.   new Image ("javascript:parent.sq1str",48,48),
  585.   new Image ("javascript:parent.sq2str",48,48),
  586.   new Image ("javascript:parent.sq3str",48,48),
  587.   new Image ("javascript:parent.sq4str",48,48)
  588.   );
  589.  
  590. var ciranim = new Animator ("ciranim", blueOnYellow,
  591.   new Image ("javascript:parent.cir1str",48,48),
  592.   new Image ("javascript:parent.cir2str",48,48),
  593.   new Image ("javascript:parent.cir3str",48,48),
  594.   new Image ("javascript:parent.cir4str",48,48)
  595.   );
  596.  
  597. var evq = new EventQueue ("evq", .05, 200, 3, 600);
  598.  
  599. // Object to hold a list of objects
  600. var objlist = new Object();
  601. var obj = 0;
  602.  
  603. // Function to use table to center vertically/horizontally
  604. function center (text) {
  605.   return '<table width=100% height=100% border=0 cellpadding=0 cellspacing=0>' +
  606.     '<tr><td align="center" valign="center">' + text + '</td></tr></table>';
  607. }
  608.  
  609. // Function to create a bunch of objects/events
  610. function makeList (frame, start, loops, delay, object) {
  611.   var argv = makeList.arguments;
  612.   var argc = argv.length;
  613.   if (argc % 5 != 0) {
  614.     alert ("Invalid number of arguments")
  615.     return;
  616.   }
  617.   for (var i = 0; i < argc; i += 5, obj++) {
  618.     objlist[obj] = argv[i+4];
  619.     evq.addEvent (new Event(argv[i+1], argv[i+2], argv[i+3],
  620.       ((objlist[obj].ready == null) ? '' : ('if (' + objlist[obj].name + '.ready=="y")')) +
  621.       'self.f' + argv[i] + '.location = "javascript:parent.objlist[' + obj + ']"'));
  622.   }
  623. }
  624.  
  625. // Note: maximum args to a function appears to be 255,
  626. // so makeList is called twice.
  627.  
  628. // the countdown
  629. makeList (
  630.   5, 0, 8, .1, new Fader(whiteOnWhite, redOnWhite, 8, center(new Text("10","7","b"))),
  631.   5, 3, 8, .1, new Fader(redOnWhite, whiteOnWhite, 8, center(new Text("10","7","b"))),
  632.   0, 2, 8, .1, new Fader(whiteOnWhite, redOnWhite, 8, center(new Text("9","7","b"))),
  633.   0, 5, 8, .1, new Fader(redOnWhite, whiteOnWhite, 8, center(new Text("9","7","b"))),
  634.   8, 4, 8, .1, new Fader(whiteOnWhite, redOnWhite, 8, center(new Text("8","7","b"))),
  635.   8, 7, 8, .1, new Fader(redOnWhite, whiteOnWhite, 8, center(new Text("8","7","b"))),
  636.   2, 6, 8, .1, new Fader(whiteOnWhite, redOnWhite, 8, center(new Text("7","7","b"))),
  637.   2, 9, 8, .1, new Fader(redOnWhite, whiteOnWhite, 8, center(new Text("7","7","b"))),
  638.   3, 8, 8, .1, new Fader(whiteOnWhite, redOnWhite, 8, center(new Text("6","7","b"))),
  639.   3, 11, 8, .1, new Fader(redOnWhite, whiteOnWhite, 8, center(new Text("6","7","b"))),
  640.   7, 10, 8, .1, new Fader(whiteOnWhite, redOnWhite, 8, center(new Text("5","7","b"))),
  641.   7, 13, 8, .1, new Fader(redOnWhite, whiteOnWhite, 8, center(new Text("5","7","b"))),
  642.   1, 12, 8, .1, new Fader(whiteOnWhite, redOnWhite, 8, center(new Text("4","7","b"))),
  643.   1, 15, 8, .1, new Fader(redOnWhite, whiteOnWhite, 8, center(new Text("4","7","b"))),
  644.   6, 14, 8, .1, new Fader(whiteOnWhite, redOnWhite, 8, center(new Text("3","7","b"))),
  645.   6, 17, 8, .1, new Fader(redOnWhite, whiteOnWhite, 8, center(new Text("3","7","b"))),
  646.   9, 16, 8, .1, new Fader(whiteOnWhite, redOnWhite, 8, center(new Text("2","7","b"))),
  647.   9, 19, 8, .1, new Fader(redOnWhite, whiteOnWhite, 8, center(new Text("2","7","b"))),
  648.   4, 18, 8, .1, new Fader(whiteOnWhite, redOnWhite, 8, center(new Text("1","7","b"))),
  649.   4, 21, 8, .1, new Fader(redOnWhite, whiteOnWhite, 8, center(new Text("1","7","b"))),
  650. // all frames to black
  651.   0, 24, 1, .1, blackout,
  652.   1, 24, 1, .1, blackout,
  653.   2, 24, 1, .1, blackout,
  654.   3, 24, 1, .1, blackout,
  655.   4, 24, 1, .1, blackout,
  656.   5, 24, 1, .1, blackout,
  657.   6, 24, 1, .1, blackout,
  658.   7, 24, 1, .1, blackout,
  659.   8, 24, 1, .1, blackout,
  660.   9, 24, 1, .1, blackout,
  661. // Welcome to the show
  662.   0, 26, 10, .1, new Alternator(yellowOnRed,redOnYellow,center(new Text("Welcome","7","b"))),
  663.   3, 28, 10, .1, new Alternator(pinkOnGreen,greenOnPink,center(new Text("to","7","bf"))),
  664.   4, 30, 10, .1, new Alternator(whiteOnOrange,orangeOnWhite,center(new Text("The","6","bi"))),
  665.   7, 32, 10, .1, new Alternator(orangeOnWhite,whiteOnOrange,center(new Text("Show","7","bi"))),
  666.   0, 34, 1, .1, blackout,
  667.   3, 34, 1, .1, blackout,
  668. // Ladies and Gentlemen...
  669.   1, 34.2, 300, .2, new Marquee(blueOnBlack,
  670.     new Text(" Ladies and Gentlemen, Welcome to the Visual Effects Show! ","7","bf"),15,2), 
  671.   2, 34.2, 300, .2, new Marquee(yellowOnBlack,
  672.     new Text(" Ladies and Gentlemen, Welcome to the Visual Effects Show! ","7","bf"),15,-2),
  673. // Animated circles and squares
  674.   4, 40, 1, .1, blackout,
  675.   7, 40, 1, .1, blackout,
  676.   5, 40, 500, .1, sqanim,
  677.   9, 40, 500, .1, ciranim
  678.   );
  679. // All the World's Your Stage (alternating Alternators!)
  680. makeList (
  681.   0, 40, 60, 2, new Alternator(yellowOnBlue,yellowOnBlue,center(new Text("All","7","b"))),
  682.   0, 41, 60, 2, new Alternator(blueOnYellow,blueOnYellow,center(new Text("The","7","b"))),
  683.   3, 40.5, 60, 2, new Alternator(redOnWhite,redOnWhite,center(new Text("The","7","b"))),
  684.   3, 41.5, 60, 2, new Alternator(whiteOnRed,whiteOnRed,center(new Text("World\'s","7","b"))),
  685.   6, 41, 60, 2, new Alternator(pinkOnGreen,pinkOnGreen,center(new Text("World\'s","7","b"))),
  686.   6, 42, 60, 2, new Alternator(greenOnPink,greenOnPink,center(new Text("Your","7","b"))),
  687.   8, 41.5, 60, 2, new Alternator(blackOnWhite,blackOnWhite,center(new Text("Your","7","b"))),
  688.   8, 42.5, 60, 2, new Alternator(whiteOnBlack,whiteOnBlack,center(new Text("Stage","7","b"))),
  689. // Visual Effects
  690.   4, 43.3, 300, .2, new Fader(orangeOnWhite,yellowOnRed,32,center(new Text("Visual","7","b"))),
  691.   7, 43.6, 300, .2, new Fader(blueOnRed,orangeOnGreen,32,center(new Text("Effects","7","b"))),
  692. // All black, then all white
  693.   0, 190, 1, .1, blackout,
  694.   1, 190, 1, .1, blackout,
  695.   2, 190, 1, .1, blackout,
  696.   3, 190, 1, .1, blackout,
  697.   4, 190, 1, .1, blackout,
  698.   5, 190, 1, .1, blackout,
  699.   6, 190, 1, .1, blackout,
  700.   7, 190, 1, .1, blackout,
  701.   8, 190, 1, .1, blackout,
  702.   9, 190, 1, .1, blackout,
  703.   0, 198, 1, .1, whiteout,
  704.   1, 198, 1, .1, whiteout,
  705.   2, 198, 1, .1, whiteout,
  706.   3, 198, 1, .1, whiteout,
  707.   4, 198, 1, .1, whiteout,
  708.   5, 198, 1, .1, whiteout,
  709.   6, 198, 1, .1, whiteout,
  710.   7, 198, 1, .1, whiteout,
  711.   8, 198, 1, .1, whiteout,
  712.   9, 198, 1, .1, whiteout
  713.   );
  714. function initialize() {
  715.   evq.startQueue();
  716. }
  717. var emptyFrame = '<html><body bgcolor="#FFFFFF"></body></html>';
  718. // end script -->
  719. </script>
  720. <frameset rows="*,*,*,*,*" onLoad="initialize()">
  721.   <frameset cols="3*,2*">
  722.     <frame name="f0" src="javascript:parent.emptyFrame" scrolling="no" noresize
  723.        marginwidth=1 marginheight=1>
  724.     <frame name="f1" src="javascript:parent.emptyFrame" scrolling="no" noresize
  725.        marginwidth=1 marginheight=1>
  726.   </frameset>
  727.   <frameset cols="2*,3*">
  728.     <frame name="f2" src="javascript:parent.emptyFrame" scrolling="no" noresize
  729.        marginwidth=1 marginheight=1>
  730.     <frame name="f3" src="javascript:parent.emptyFrame" scrolling="no" noresize
  731.        marginwidth=1 marginheight=1>
  732.   </frameset>
  733.   <frameset cols="3*,2*">
  734.     <frame name="f4" src="javascript:parent.emptyFrame" scrolling="no" noresize
  735.        marginwidth=1 marginheight=1>
  736.     <frame name="f5" src="javascript:parent.emptyFrame" scrolling="no" noresize
  737.        marginwidth=1 marginheight=1>
  738.   </frameset>
  739.   <frameset cols="2*,3*">
  740.     <frame name="f6" src="javascript:parent.emptyFrame" scrolling="no" noresize
  741.        marginwidth=1 marginheight=1>
  742.     <frame name="f7" src="javascript:parent.emptyFrame" scrolling="no" noresize
  743.        marginwidth=1 marginheight=1>
  744.   </frameset>
  745.   <frameset cols="3*,2*">
  746.     <frame name="f8" src="javascript:parent.emptyFrame" scrolling="no" noresize
  747.        marginwidth=1 marginheight=1>
  748.     <frame name="f9" src="javascript:parent.emptyFrame" scrolling="no" noresize
  749.        marginwidth=1 marginheight=1>
  750.   </frameset>
  751. </frameset>
  752. <noframes>
  753. <h1 align="center">Sorry, JavaScript-enabled browser required</h1>
  754. </noframes>