debugging an old script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yousuf Khan

    debugging an old script

    Hi, I have this pre-built JS routine that creates a text animation
    special-effect. The routine was included inside a freeware HTML editor,
    called AceHTML. The problem is that it seems to work only on IE and
    IE-emulating browsers (such as Opera). According to what other people have
    told me, the problem is because this script has an outdated browser
    detection scheme, and that the procedure it uses for Netscape is no longer
    valid in modern Netscapes/Mozillas, etc. Now, I'm no JS expert, I just
    started doing HTML a couple of weeks ago to put up a personal page, so I
    wasn't expecting to get involved in the bowels of JS programming and
    debugging until much later when I'd become more advanced.

    Specifically, the JSconsole error messages on Firefox shows that any lines
    that start with "document.wds.d ocument.write(. ..)" as being undefined.

    If you want to see what this script looks like when it's working, then go to
    this site, and look at the animated heading for this page (but use IE or a
    compatible):



    I need to know how to make this thing work on any W3C-compliant browser. I
    understand that even the IE portion of the script is outdated and irrelevant
    to modern IE, but it still maintains backwards compatibility with it.

    Yousuf Khan

    I've pasted the script from the above mentioned page down below:

    ----------
    <script language="JavaS cript">

    <!-- Begin

    // Original: Charles Foster (wcms_sf@msn.co m)

    // Web Site: http://kylo.ml.org/flash


    // This script and many more are available free online at

    // The JavaScript Source!! http://javascript.internet.com



    var speed = 100;

    var cycledelay = 2000;

    var maxsize = 28;


    var x = 0;

    var y = 0;

    var themessage, size;

    var esize = "</font>";


    function initArray() {

    this.length = initArray.argum ents.length;

    for (var i = 0; i < this.length; i++) {

    this[i] = initArray.argum ents[i];

    }

    }

    var themessage2 = new initArray(

    "SOLD!",

    "Thanks for your interest"

    );

    if(navigator.ap pName == "Netscape")

    document.write( '<layer id="wds"></layer><br>');

    if (navigator.appV ersion.indexOf( "MSIE") != -1)

    document.write( '<span id="wds"></span><br>');

    function upwords(){

    themessage = themessage2[y];

    if (x < maxsize) {

    x++;

    setTimeout("upw ords()",speed);

    }

    else setTimeout("dow nwords()",cycle delay);


    if(navigator.ap pName == "Netscape") {

    size = "<font point-size='"+x+"pt'> ";

    document.wds.do cument.write(si ze+"<center>"+t hemessage+"</center>"+esize) ;

    document.wds.do cument.close();

    }

    if (navigator.appV ersion.indexOf( "MSIE") != -1){

    wds.innerHTML = "<center>"+them essage+"</center>";

    wds.style.fontS ize=x+'px';

    }

    }

    function downwords(){

    if (x > 1) {

    x--;

    setTimeout("dow nwords()",speed );

    }

    else {

    setTimeout("upw ords()",cyclede lay);

    y++;

    if (y > themessage2.len gth - 1) y = 0;

    }

    if(navigator.ap pName == "Netscape") {

    size = "<font point-size='"+x+"pt'> ";

    document.wds.do cument.write(si ze+"<center>"+t hemessage+"</center>"+esize) ;

    document.wds.do cument.close();

    }

    if (navigator.appV ersion.indexOf( "MSIE") != -1){

    wds.innerHTML = "<center>"+them essage+"</center>";

    wds.style.fontS ize=x+'px';

    }

    }

    setTimeout("upw ords()",speed);

    // End -->

    </script>


    --
    Humans: contact me at ykhan at rogers dot com
    Spambots: just reply to this email address ;-)



  • Michael Winter

    #2
    Re: debugging an old script

    On Thu, 26 Aug 2004 18:05:59 GMT, Yousuf Khan <bbbl67@ezrs.co m> wrote:

    [snip]
    [color=blue]
    > I need to know how to make this thing work on any W3C-compliant browser.
    > I understand that even the IE portion of the script is outdated and
    > irrelevant to modern IE, but it still maintains backwards compatibility
    > with it.[/color]

    If I may be frank, abandon it. It would be much simpler to create an
    animated GIF that displayed the same thing. Adding, "Sold! Thanks for your
    interest.", to the alt attribute of such an image would also make your
    page much more accessible. An animated GIF would also not cause the page
    dimensions to constantly change.

    To make the script, another example of the "high" quality of The
    JavaScript Source's collection, workable in a wide range of browsers would
    require it to be re-written from scratch. Considering the alternative, I
    don't honestly think it's worth the effort.

    [snip]

    Sorry,
    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.

    Comment

    • Yousuf Khan

      #3
      Re: debugging an old script

      Michael Winter wrote:[color=blue]
      > If I may be frank, abandon it. It would be much simpler to create an
      > animated GIF that displayed the same thing. Adding, "Sold! Thanks for
      > your interest.", to the alt attribute of such an image would also
      > make your page much more accessible. An animated GIF would also not
      > cause the page dimensions to constantly change.[/color]

      Actually, I kind of liked that effect. Made it look like a heartbeat or a
      balloon.
      [color=blue]
      > To make the script, another example of the "high" quality of The
      > JavaScript Source's collection, workable in a wide range of browsers
      > would require it to be re-written from scratch. Considering the
      > alternative, I don't honestly think it's worth the effort.[/color]

      I'll take it with advisement.

      Yousuf Khan


      Comment

      • Michael Winter

        #4
        Re: debugging an old script

        On Fri, 27 Aug 2004 18:53:57 GMT, Yousuf Khan <bbbl67@ezrs.co m> wrote:
        [color=blue]
        > Michael Winter wrote:[color=green]
        >> If I may be frank, abandon it. It would be much simpler to create an
        >> animated GIF that displayed the same thing. Adding, "Sold! Thanks for
        >> your interest.", to the alt attribute of such an image would also
        >> make your page much more accessible. An animated GIF would also not
        >> cause the page dimensions to constantly change.[/color]
        >
        > Actually, I kind of liked that effect. Made it look like a heartbeat or a
        > balloon.[/color]

        You missed the point. You can get the same effect, just with an animated
        image rather than playing around with the font size. An image will be more
        accessible (provided that you use the alt attribute), and it's guaranteed
        to work almost in every graphical browser[1]. The same cannot be said for
        that script, or any other like it.

        [snip]

        Mike


        [1] "Almost" because some open-source graphical browsers do not implement
        GIF loading properly because of the patent held on the GIF compression
        algorithm.

        --
        Michael Winter
        Replace ".invalid" with ".uk" to reply by e-mail.

        Comment

        • victor ebuwa

          #5
          Re: debugging an old script

          "Yousuf Khan" <bbbl67@ezrs.co m> wrote in message news:<bEpXc.695 10$pTn.68559@ne ws01.bloor.is.n et.cable.rogers .com>...[color=blue]
          > Hi, I have this pre-built JS routine that creates a text animation
          > special-effect. The routine was included inside a freeware HTML editor,
          > called AceHTML. The problem is that it seems to work only on IE and
          > IE-emulating browsers (such as Opera). According to what other people have
          > told me, the problem is because this script has an outdated browser
          > detection scheme, and that the procedure it uses for Netscape is no longer
          > valid in modern Netscapes/Mozillas, etc. Now, I'm no JS expert, I just
          > started doing HTML a couple of weeks ago to put up a personal page, so I
          > wasn't expecting to get involved in the bowels of JS programming and
          > debugging until much later when I'd become more advanced.
          >
          > Specifically, the JSconsole error messages on Firefox shows that any lines
          > that start with "document.wds.d ocument.write(. ..)" as being undefined.
          >
          > If you want to see what this script looks like when it's working, then go to
          > this site, and look at the animated heading for this page (but use IE or a
          > compatible):
          >
          > http://ca.geocities.com/bbbl67/mower4sale.html
          >
          > I need to know how to make this thing work on any W3C-compliant browser. I
          > understand that even the IE portion of the script is outdated and irrelevant
          > to modern IE, but it still maintains backwards compatibility with it.
          >
          > Yousuf Khan
          >
          > I've pasted the script from the above mentioned page down below:
          >[/color]

          That's a very old script and, apologies to the author, not a very good
          visual effect.

          Try this one: - seems to be hidden from Opera though.


          ----------------------------------------|


          <script type="text/javascript">

          if ((document.getE lementById) &&
          window.addEvent Listener || window.attachEv ent){

          var win = window.toString (); //No Opera!
          if (win != "[object Object]" ){

          (function(){

          //Configure here.

          var message = "your message here";
          var col = new Array('#ff0000' ,'#00aa00','#00 00ff'); //add more.
          var xyz = 26; //max grow size.
          var spd = 40; //setTimeout speed.

          //End.

          var msg = message.split(" ");
          var timer = null;
          var clrPos = 0;
          var msgPos = 0;
          var jog = 1;
          var currentStep = 10;
          var step = 8;
          var h,w,y,x,r,xy;
          var d = document;
          var pix = "px";
          var domWw = (typeof window.innerWid th == "number");
          var domSy = (typeof window.pageYOff set == "number");
          var running = true;
          var box,txt;
          var ovrflw = (d.documentElem ent.style &&
          typeof d.documentEleme nt.style.MozOpa city == "string")
          ?"-moz-scrollbars-none":"hidden";
          var idx = d.getElementsBy TagName('div'). length;

          d.write("<div id='_box"+idx+" ' style='position :absolute;top:0 px;"
          +"left:0px;heig ht:10px;width:1 0px;text-align:center;"
          +"overflow:"+ov rflw+"'>"

          +"<div id='_txt"+idx+" ' style='position :absolute;top:0 px;left:0px;"
          +"width:1px;hei ght:1px;font-family:arial,sa ns-serif;font-size:1px'>."
          +"<\/div><\/div>");

          if (domWw) r = window;
          else{
          if (d.documentElem ent &&
          typeof d.documentEleme nt.clientWidth == "number" &&
          d.documentEleme nt.clientWidth != 0)
          r = d.documentEleme nt;
          else{
          if (d.body &&
          typeof d.body.clientWi dth == "number")
          r = d.body;
          }
          }

          function winsize(){
          var oh,sy,ow,sx,rh, rw;
          if (domWw){
          if (d.documentElem ent && d.defaultView &&
          typeof d.defaultView.s crollMaxY == "number"){
          oh = d.documentEleme nt.offsetHeight ;
          sy = d.defaultView.s crollMaxY;
          ow = d.documentEleme nt.offsetWidth;
          sx = d.defaultView.s crollMaxX;
          rh = oh-sy;
          rw = ow-sx;
          }
          else{
          rh = r.innerHeight;
          rw = r.innerWidth;
          }
          h = rh;
          w = rw;
          }
          else{
          h = r.clientHeight;
          w = r.clientWidth;
          }
          y = Math.floor(h/2);
          x = Math.floor(w/2);

          xy = (w >= h)?w:h;
          }

          function scrl(yx){
          var sy,sx;
          if (domSy){
          sy = r.pageYOffset;
          sx = r.pageXOffset;
          }
          else{
          sy = r.scrollTop;
          sx = r.scrollLeft;
          }
          return (yx == 0)?sy:sx;
          }

          function dsply(){
          step += 15;
          currentStep += step;

          txt.top = y + Math.floor(-currentStep/16) + pix;
          txt.left = x + Math.floor(-currentStep/2) + pix;
          txt.width = currentStep + pix;
          txt.fontSize = Math.floor(curr entStep/8) + pix;
          txt.color = col[clrPos];
          d.getElementByI d("_txt"+idx).f irstChild.data = msg[msgPos];
          if (currentStep > xy * xyz){
          currentStep = 10;
          step = 8;
          msgPos += jog;
          clrPos += jog;
          }
          if (clrPos >= col.length){
          clrPos = 0;
          }
          timer = setTimeout(dspl y,spd);
          if (msgPos >= msg.length){
          running = false;
          box.width = 1 + pix;
          box.height = 1 + pix;
          box.visibility = "hidden";
          txt.width = 1 + pix;
          txt.height = 1 + pix;
          txt.visibility = "hidden";
          clearTimeout(ti mer);
          }
          box.top = scrl(0) + pix;
          box.left = scrl(1) + pix;
          }


          function dims(){
          if (domWw) box.width = "100%";
          else box.width = w + pix;
          box.height = h + pix;
          }


          function init(){
          winsize();
          box = document.getEle mentById("_box" +idx).style;
          txt = document.getEle mentById("_txt" +idx).style;
          dims();
          dsply();
          }

          function rsz(){
          if (running){
          winsize();
          dims();
          }
          }


          if (window.addEven tListener){
          window.addEvent Listener("resiz e",rsz,false );
          window.addEvent Listener("load" ,init,false);
          }
          else if (window.attachE vent){
          window.attachEv ent("onresize", rsz);
          window.attachEv ent("onload",in it);
          }

          })();
          }
          }//End.
          </script>

          Comment

          • Yousuf Khan

            #6
            Re: debugging an old script

            victor ebuwa wrote:[color=blue]
            > That's a very old script and, apologies to the author, not a very good
            > visual effect.
            >
            > Try this one: - seems to be hidden from Opera though.[/color]

            Are you trying to tempt me to use a different special effect? Well, it's
            working. :-)

            Wow! OMG, this one blows me away.

            How do you get the text to display even over graphics without affecting
            them?

            Are you the original author of this script? If so, then I can credit you
            with it in the comments.

            Yousuf Khan


            Comment

            • Yousuf Khan

              #7
              Re: debugging an old script

              Michael Winter wrote:[color=blue]
              > You missed the point. You can get the same effect, just with an
              > animated image rather than playing around with the font size. An
              > image will be more accessible (provided that you use the alt
              > attribute), and it's guaranteed to work almost in every graphical
              > browser[1]. The same cannot be said for that script, or any other
              > like it.[/color]

              Well, the problem with the graphical way you mention is that I'd have to
              obtain a GIF animation package, possibly search around for a freeware one
              (if freeware GIF animators even exist considering the patents on GIF), and
              then to top it off I'd have to learn to use it in a quick amount of time.
              Plus in addition to that those facts, adding another GIF image would
              necessarily add a large download strain to anybody viewing the page. It's
              easy to forget that with broadband that there are dialup users out there
              still, where each additional image is a highly noticeable. I do expect
              dialup users will be viewing my page too.

              Yousuf Khan


              Comment

              • victor ebuwa

                #8
                Re: debugging an old script

                "Yousuf Khan" <bbbl67@ezrs.co m> wrote in message news:<tbVXc.679 67$UTP.286@twis ter01.bloor.is. net.cable.roger s.com>...[color=blue]
                > victor ebuwa wrote:[color=green]
                > > That's a very old script and, apologies to the author, not a very good
                > > visual effect.
                > >
                > > Try this one: - seems to be hidden from Opera though.[/color]
                >
                > Are you trying to tempt me to use a different special effect? Well, it's
                > working. :-)
                >
                > Wow! OMG, this one blows me away.
                >
                > How do you get the text to display even over graphics without affecting
                > them?
                >
                > Are you the original author of this script? If so, then I can credit you
                > with it in the comments.
                >
                > Yousuf Khan[/color]

                No I didn't write it. I found it on an email stationary forum a few months ago.

                Comment

                • Yousuf Khan

                  #9
                  Re: debugging an old script

                  victor ebuwa wrote:[color=blue][color=green]
                  >> Are you the original author of this script? If so, then I can credit
                  >> you with it in the comments.
                  >>
                  >> Yousuf Khan[/color]
                  >
                  > No I didn't write it. I found it on an email stationary forum a few
                  > months ago.[/color]

                  Okay, then I guess we can call it public domain then. :-)

                  Yousuf Khan


                  Comment

                  • Ian Stirling

                    #10
                    Re: debugging an old script

                    Yousuf Khan <bbbl67@ezrs.co m> wrote:[color=blue]
                    > Michael Winter wrote:[color=green]
                    >> You missed the point. You can get the same effect, just with an
                    >> animated image rather than playing around with the font size. An
                    >> image will be more accessible (provided that you use the alt
                    >> attribute), and it's guaranteed to work almost in every graphical
                    >> browser[1]. The same cannot be said for that script, or any other
                    >> like it.[/color]
                    >
                    > Well, the problem with the graphical way you mention is that I'd have to
                    > obtain a GIF animation package, possibly search around for a freeware one
                    > (if freeware GIF animators even exist considering the patents on GIF), and[/color]

                    Now-expired patents.

                    Comment

                    • Yousuf Khan

                      #11
                      Re: debugging an old script

                      Ian Stirling wrote:[color=blue][color=green]
                      >> Well, the problem with the graphical way you mention is that I'd
                      >> have to obtain a GIF animation package, possibly search around for a
                      >> freeware one (if freeware GIF animators even exist considering the
                      >> patents on GIF), and[/color]
                      >
                      > Now-expired patents.[/color]

                      Really? So GIF is can now be used for free again?

                      Yousuf Khan


                      Comment

                      • Jim Ley

                        #12
                        Re: debugging an old script

                        On 29 Aug 2004 00:41:11 GMT, Ian Stirling <root@mauve.dem on.co.uk>
                        wrote:
                        [color=blue]
                        >Yousuf Khan <bbbl67@ezrs.co m> wrote:[color=green]
                        >> Well, the problem with the graphical way you mention is that I'd have to
                        >> obtain a GIF animation package, possibly search around for a freeware one
                        >> (if freeware GIF animators even exist considering the patents on GIF), and[/color]
                        >
                        >Now-expired patents.[/color]

                        Is it expired everywhere now? I know US went in 2003, Europe in 2004
                        (both June time wasn't it?) but does the patent still exist in any
                        countries?

                        Jim.

                        Comment

                        • Thomas 'PointedEars' Lahn

                          #13
                          Re: debugging an old script

                          Jim Ley wrote:
                          [color=blue]
                          > On 29 Aug 2004 00:41:11 GMT, Ian Stirling <root@mauve.dem on.co.uk>
                          > wrote:[/color]

                          Please do not write attribution novels by duplicating header information.
                          It does not serve any greater purpose but reduces legibility of discussions.
                          [color=blue][color=green]
                          >> Yousuf Khan <bbbl67@ezrs.co m> wrote:[color=darkred]
                          >>> Well, the problem with the graphical way you mention is that I'd have to
                          >>> obtain a GIF animation package, possibly search around for a freeware
                          >>> one (if freeware GIF animators even exist considering the patents on
                          >>> GIF), and[/color]
                          >>
                          >> Now-expired patents.[/color]
                          >
                          > Is it expired everywhere now? I know US went in 2003, Europe in 2004
                          > (both June time wasn't it?) but does the patent still exist in any
                          > countries?[/color]

                          Unisys' GIF patent expired in the USA, Europe, Japan and Canada,
                          however the U.S. IBM patent is still valid until August 11, 2006.

                          <http://www.gnu.org/philosophy/gif.html>


                          PointedEars
                          --
                          But who will take down the flypaper?

                          Comment

                          • Ian Stirling

                            #14
                            Re: debugging an old script

                            Yousuf Khan <bbbl67@ezrs.co m> wrote:[color=blue]
                            > Ian Stirling wrote:[color=green][color=darkred]
                            >>> Well, the problem with the graphical way you mention is that I'd
                            >>> have to obtain a GIF animation package, possibly search around for a
                            >>> freeware one (if freeware GIF animators even exist considering the
                            >>> patents on GIF), and[/color]
                            >>
                            >> Now-expired patents.[/color]
                            >
                            > Really? So GIF is can now be used for free again?[/color]

                            I believe so.

                            Comment

                            Working...