Welcome guest, is this your first visit? Create Account now to join.
Results 1 to 2 of 2

This is a discussion on Fader problem within the Chrome Plugins section, part of the Google Chrome category: ...


  1. #1
    brantfordblast is offline Junior Member
    Join Date
    Dec 2009
    Posts
    2

    Default Fader problem

    I'm having problems getting a Fader to work.
    Finally realized it's because Chrome doesn't use ActiveX.
    I don't know much about ActiveX or NPAPI. so I'm not sure what I need to do to get it to work.
    The fader code is
    Code:
    <div id="fader" style="position:absolute; top: 56px; left:279px; width:600px; text-align:left;"></div>
    and the scripit it loads from
    Code:
    <!-- Begin
    //  texts:
    //  Your messages wich may contain regular html tags but
    //  must at least contain: [ <font color='{COLOR}'> ]
    //  Use single quotes [ ' ] in your html only. If you need
    //  a double quote in the message itself use an escape
    //  sign like this: [ \" ]  (not including the brackets)
    
    var texts = new Array(
    "<font size='2pt' color='{COLOR}' face='Arial'><strong>It's nice to feel alive again! Sara, Director of Education, Stott Pilates </strong></font>",
    "<font size='2pt' color='{COLOR}' face='Arial'><strong>I've been doing a number of things to lose weight over the years and it has worked but only to a point. Seeing you has made all the difference! You have amazing strategies and they work! I know that I will be successful and reach my goals by sticking to the 'Kyle' plan. Tara, Manager Risk Reporting</strong></font>",
    "<font size='2pt' color='{COLOR}' face='Arial'><strong>With little opportunity to train, I wondered why I was in amazing shape. It was Kyle's nutrition advice! Then he helped me make weight and I felt stronger than ever during my fight. Elliott Bayev, Brazilian Jiu-Jitsu Abu Dhabi Canadian Trial Champion 2009 and Head Instructor of Openmat BJJ & MMA</strong></font>",
    "<font size='2pt' color='{COLOR}' face='Arial'><strong>I have never looked this good in a bikini! Kyle you are a genius! Y.H. Manager</strong></font>",
    "<font size='2pt' color='{COLOR}' face='Arial'><strong>Within a month of seeing Kyle I was wearing the jeans I haven’t worn in four years (yay!).  E.S. Music Industry</strong></font>",
    "<font size='2pt' color='{COLOR}' face='Arial'><strong>My schedule is insane. …Within two weeks I had tremendous results. One co-worker put it nicely… “Whoa ...have you been taking steroids?”  Chris, IT Consultant</strong></font>", 
    "<font size='2pt' color='{COLOR}' face='Arial'><strong>I had to pass a fitness test that was two weeks away! I outscored every other applicant and broke a record -- not bad for the oldest guy there! Thanks Kyle, who knows what would have happened without your program.  Special Constable RT.</strong></font>",
    "<font size='2pt' color='{COLOR}' face='Arial'><strong>I know what to eat, and most importantly WHY and WHEN in order to get results… Saying “thank you” will never be enough for setting me up for the rest of my life.  E.S. Music Industry</strong></font>",
    "<font size='2pt' color='{COLOR}' face='Arial'><strong>I have been bodybuilding regularly for ten years. I highly recommend Kyle to be your personal trainer no matter what your age or goals with fitness/nutrition. You will not be disappointed.  Jonathan K, Occupational Therapist</strong></font>",
    "<font size='2pt' color='{COLOR}' face='Arial'><strong>I lost eight pounds of fat, gained five pounds of muscle, on my 41-year old frame, in just under three months. I also have increased energy levels, a brighter outlook on life, and my blood pressure dropped 20 points!  Scott S, Management Consultant</strong></font>",
    "<font size='2pt' color='{COLOR}' face='Arial'><strong>The interactive nature of the grocery store tour was much better than reading a book. I learned how to analyze ingredients, and that even 'bad' foods can be made better, for example, loading vegetables onto a pizza.  Philip, project manager</strong></font>");
    
    var bgcolor = "#FFFFFF"; // background color, must be valid browser hex color (not color names)
    var fcolor = "#000000";  // foreground or font color
    var steps = 20; // number of steps to fade
    var show = 8000; // milliseconds to display message
    var sleep = 400; // milliseconds to pause inbetween messages
    var loop = true; // true = continue to display messages, false = stop at last message
    
    // Do Not Edit Below This Line
    var colors = new Array(steps);
    getFadeColors(bgcolor,fcolor,colors);
    var color = 0;
    var text = 0;
    var step = 1;
    
    // fade: magic fader function
    function fade() {
    
    // insert fader color into message
    var text_out = texts[text].replace("{COLOR}", colors[color]); // texts should be defined in user script, e.g.: var texts = new Array("<font color='{COLOR}' sized='+3' face='Arial'>howdy</font>");
    
    // actually write message to document
    if (document.all) fader.innerHTML = text_out; // document.all =  IE only
    if (document.layers) { document.fader.document.write(text_out); document.fader.document.close(); } // document.layers = Netscape only
    
    // select next fader color
    color += step;
    
    // completely faded in?
    if (color >= colors.length-1) {
    step = -1; // traverse colors array backward to fade out
    
    // stop at last message if loop=false
    if (!loop && text >= texts.length-1) return; // loop should be defined in user script, e.g.: var loop=true;
    }
    
    // completely faded out?
    if (color == 0) {
    step = 1; // traverse colors array forward to fade in again
    
    // select next message
    text += 1;
    if (text == texts.length) text = 0; // loop back to first message
    }
    
    // subtle timing logic...
    setTimeout("fade()", (color == colors.length-2 && step == -1) ? show : ((color == 1 && step == 1) ? sleep : 50)); // sleep and show should be defined in user script, e.g.: var sleep=30; var show=500;
    }
    // getFadeColors: fills Colors (predefined Array)
    // with color hex strings fading from ColorA to ColorB
    
    // note: Colors.length equals the number of steps to fade
    function getFadeColors(ColorA, ColorB, Colors) {
    len = Colors.length;
    
    // strip '#' signs if present
    if (ColorA.charAt(0)=='#') ColorA = ColorA.substring(1);
    if (ColorB.charAt(0)=='#') ColorB = ColorB.substring(1);
    
    // substract rgb compents from hex string
    var r = HexToInt(ColorA.substring(0,2));
    var g = HexToInt(ColorA.substring(2,4));
    var b = HexToInt(ColorA.substring(4,6));
    var r2 = HexToInt(ColorB.substring(0,2));
    var g2 = HexToInt(ColorB.substring(2,4));
    var b2 = HexToInt(ColorB.substring(4,6));
    
    // calculate size of step for each color component
    var rStep = Math.round((r2 - r) / len);
    var gStep = Math.round((g2 - g) / len);
    var bStep = Math.round((b2 - b) / len);
    
    // fill Colors array with fader colors
    for (i = 0; i < len-1; i++) {
    Colors[i] = "#" + IntToHex(r) + IntToHex(g) + IntToHex(b);
    r += rStep;
    g += gStep;
    b += bStep;
    }
    Colors[len-1] = ColorB; // make sure we finish exactly at ColorB
    }
    
    // IntToHex: converts integers between 0-255 into a two digit hex string.
    function IntToHex(n) {
    var result = n.toString(16);
    if (result.length==1) result = "0"+result;
    return result;
    }
    
    // HexToInt: converts two digit hex strings into integer.
    function HexToInt(hex) {
    return parseInt(hex, 16);
    }
    
    // body tag must include: onload="fade()" bgcolor="#000000"  where bgcolor equals bgcolor in javascript above
    //  End -->

    with other javascript before it but I don't think it has to do with the fader.

    Code:
    if (document.images) 
    { 
    
    if (document.image = "pic1")
    {
       pic1on= new Image(100,20); 
       pic1on.src="images/btnmainon.png"; 
       pic1off= new Image(100,20); 
       pic1off.src="images/btnmainoff.png"; 
       pic1down=new Image(100,20); 
       pic1down.src="images/btnmainon.png";
    }
    
    if (document.image = "pic2")
    {
       pic2on= new Image(100,50); 
       pic2on.src="images/btnabouton.png"; 
       pic2off= new Image(100,50); 
       pic2off.src="images/btnaboutoff.png"; 
       pic2down=new Image(100,50); 
       pic2down.src="images/btnabouton.png";
    }
    
    if (document.image = "pic2")
    {
       pic3on= new Image(100,20); 
       pic3on.src="images/btnserviceson.png"; 
       pic3off= new Image(100,20); 
       pic3off.src="images/btnservicesoff.png"; 
       pic3down=new Image(100,20); 
       pic3down.src="images/btnserviceson.png";
    }
    
    if (document.image = "pic4")
    {
       pic4on= new Image(100,20); 
       pic4on.src="images/btnlinkson.png"; 
       pic4off= new Image(100,20); 
       pic4off.src="images/btnlinksoff.png"; 
       pic4down=new Image(100,20); 
       pic4down.src="images/btnlinkson.png";
    }
    
    if (document.image = "pic4")
    {
       pic5on= new Image(100,20); 
       pic5on.src="images/btntestimonialson.png"; 
       pic5off= new Image(100,20); 
       pic5off.src="images/btntestimonialsoff.png"; 
       pic5down=new Image(100,20); 
       pic5down.src="images/btntestimonialson.png";
    }
    
     
    } 
    function lightup(imgName) 
    { 
    if (document.images) 
    { 
    imgOn=eval(imgName + "on.src"); 
    document[imgName].src= imgOn; 
    } 
    } 
    
    function turnoff(imgName) 
    { 
    if (document.images) 
    { 
    imgOff=eval(imgName + "off.src"); 
    document[imgName].src= imgOff; 
    } 
    } 
    
    function clickdown(imgName) 
    { 
    if (document.images) 
    { 
    imgDown=eval(imgName + "down.src"); 
    document[imgName].src= imgDown; 
    
    } 
    } 
    
    <!-- start: WarpGear JavaScript Fader v1.0 -->
    
    <!-- adjust style= to position messages -->
    
    <!-- Original:  WarpGear Software (jsfader@warpgear.com) -->
    <!-- Web Site:  http://www.warpgear.com/developer -->
    
    <!-- This script and many more are available free online at -->
    <!-- The JavaScript Source!! http://javascript.internet.com -->

    and to post everything (I think)
    Here is the script thats on the actual pages.

    Code:
    <script src="../include/javascript.js" language="javascript" type="text/javascript"></script>
    Which loads the script the fader is in


    and this one as well.
    Code:
    <script type="text/JavaScript">
    <!--
    function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }
    
    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }
    
    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    }
    
    function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
       if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }
    //-->
    </script>
    Hope someone can help me out cause I've tried, and looked online and haven't had any luck at all getting it to work in Google Chrome.

    Thanks.

    Mike.

  2. #2
    brantfordblast is offline Junior Member
    Join Date
    Dec 2009
    Posts
    2

    Default

    I gave up with NPAPI since no one was able to help me out, and was never able to find anything online to help me get it to work in google, Made it into flash instead as it works on both.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •