473,324 Members | 2,246 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

error in execution

Expand|Select|Wrap|Line Numbers
  1. function FadingTooltip(htmlElement, tooltipContent, parameters)
  2.     {
  3.  
  4.          if (!htmlElement || typeof(htmlElement)!="object") throw "Sorry, htmlElement argument of FadingTooltip should be an HTML element";
  5.       if (!tooltipContent || typeof(tooltipContent)!="string") throw "Sorry, tooltipContent argument of FadingTooltip should be a string containing text and HTML tags";
  6.  
  7.      /*if (parameters && typeof(parameters)!="object") { throw "Sorry, parameters argument of FadingTooltip should be a JSON object containing parameter values"; }
  8.       for (var parameter in parameters)
  9.         {
  10.            if (typeof(this[parameter])=="undefined") throw "Sorry, parameters passed to FadingTooltip is not recognized";
  11.                     }     */
  12.  
  13.  
  14.       this.htmlElement = htmlElement;
  15.       this.tooltipContent = tooltipContent;
  16.       for (parameter in parameters) this[parameter] = parameters[parameter];
  17.  
  18.  
  19.        var self = this;
  20.  
  21. if (htmlElement.addEventListener) { // for FF and NS and Opera
  22.            //if (this.trace) trace("FadingTooltip hooking HTML element id=" + htmlElement.id + " using DOM Level 2 event model");
  23.           htmlElement.addEventListener("mouseover", function(event) { self.handleEvent(event); }, false);
  24.            htmlElement.addEventListener("mousemove", function(event) { self.handleEvent(event); },true);
  25.          htmlElement.addEventListener("mouseout",  function(event) { self.handleEvent(event); }, true);
  26.       }
  27.  
  28.  
  29.       else if (htmlElement.attachEvent)
  30.       { // for MSIE
  31.          // if (this.trace) trace("FadingTooltip hooking HTML element id=" + htmlElement.id + " using Microsoft event model");
  32.           htmlElement.attachEvent("onmouseover", function(){self.handleEvent(window.event);});
  33.            htmlElement.attachEvent("onmousemove", function() { self.handleEvent(window.event);});
  34.           htmlElement.attachEvent("onmouseout",  function() { self.handleEvent(window.event); } );
  35.       }
  36.  
  37.  
  38.  
  39.       // Set the initial state of the finite state machine.
  40.  
  41.      this.currentState = this.initialState;
  42.  
  43. FadingTooltip.prototype = {
  44.  
  45.       tooltipClass: null, // name of a CSS style for rendering the tooltip, or "null" for default style below
  46.       tooltipOpacity: 0.8, // maximum opacity of tooltip, between 0.0 and 1.0 (after fade-in finishes, before fade-out begins)
  47.       tooltipOffsetX: 10, // horizontal offset from cursor to upper-left corner of tooltip
  48.       tooltipOffsetY: 10, // vertical offset from cursor to upper-left corner of tooltip
  49.       fadeRate: 24, // animation rate for fade-in and fade-out, in steps per second
  50.       pauseTime: 0.5, // how long the cursor must pause over HTML element before fade-in starts, in seconds
  51.       displayTime: 10, // how long the tooltip will be displayed (after fade-in finishes, before fade-out begins), in seconds
  52.       fadeinTime: 1, // how long fade-in animation will take, in seconds
  53.       fadeoutTime: 3, // how long fade-out animation will take, in seconds
  54.       currentState: null, // current state of finite state machine (one of "actionTransitionFunctions" properties)
  55.       currentTimer: null, // returned by setTimeout, if a timer is currently running
  56.       currentTicker: null, // returned by setInterval, if a ticker is currently running
  57.       currentOpacity: 0, // current opacity of tooltip, between 0.0 and "tooltipOpacity"
  58.       tooltipDivision: null, // pointer to HTML Division element, if tooltip is currently visible
  59.       lastCursorX: 0, // cursor x-position at most recent mouse event
  60.       lastCursorY: 0, // cursor y-position at most recent mouse event
  61.       trace: true, // trace execution points that may be helpful for debugging, if set to "true"
  62.  
  63.          handleEvent: function(event)
  64.          {
  65.           var actionTransitionFunction = this.actionTransitionFunctions[this.currentState][event.type];
  66.             var nextState = actionTransitionFunction.call(this, event);
  67.           if (!nextState) nextState = this.currentState;
  68.           //if (this.trace) trace(""" + event.type + "" event caused transition from "" + this.currentState + "" state to "" + nextState + "" state");
  69.          if (!this.actionTransitionFunctions[nextState]) nextState = this.undefinedState(event, nextState);
  70.          this.currentState = nextState;
  71.       } ,
  72.        unexpectedEvent: function(event) {
  73.           this.cancelTimer();
  74.           this.cancelTicker();
  75.           this.deleteTooltip();
  76.           alert("FadingTooltip handled unexpected event  + event.type +  in state  + this.currentState +  for id= + this.htmlElement.id +  running browser " + window.navigator.userAgent);
  77.           return this.initialState;
  78.      },
  79.  
  80.       undefinedState: function(event, state){
  81.           this.cancelTimer();
  82.          this.cancelTicker();
  83.           this.deleteTooltip();
  84.          alert("FadingTooltip transitioned to undefined state  + state +  from state + this.currentState +  due to event  + event.type +  from HTML element id= + this.htmlElement.id +  running browser " + window.navigator.userAgent);
  85.           return this.initialState;
  86.       },
  87.        initialState: "Inactive",
  88.        actionTransitionFunctions: {
  89.          Inactive: {
  90.  
  91.               mouseover: function(event) {
  92.                   this.cancelTimer();
  93.                  this.saveCursorPosition(event.clientX, event.clientY);
  94.                  this.startTimer(this.pauseTime*1000);
  95.                  return "Pause";
  96.            },
  97.  
  98.               mousemove: function(event) {
  99.                  return this.doActionTransition("Inactive", "mouseover", event);
  100.              },
  101.                 mouseout: function(event) {
  102.                  return this.currentState; // do nothing
  103.               }
  104.                  }, // end of FadingTooltip.prototype.actionTransitionFunctions.Inactive
  105.  
  106.                  Pause: {
  107.  
  108.                  mousemove: function(event) {
  109.                  return this.doActionTransition("Inactive", "mouseover", event);
  110.                  },
  111.  
  112.                 mouseout: function(event) {
  113.                  this.cancelTimer();
  114.                  return "Inactive";
  115.             },
  116.  
  117.               timeout: function(event) {
  118.                   this.cancelTimer();
  119.                   this.createTooltip();
  120.                  if (this.fadeinTime>0) {
  121.                      this.startTicker(1000/this.fadeRate);
  122.                      return "FadeIn";
  123.                   } else {
  124.                       this.fadeTooltip(+this.tooltipOpacity);
  125.                       this.startTimer(this.displayTime*1000);
  126.                       return "Display";
  127.                   }
  128.               }
  129.           }, // end of FadingTooltip.prototype.actionTransitionFunctions.Pause
  130.           FadeIn: {
  131.  
  132.              mousemove: function(event) {
  133.                   return this.doActionTransition("Display", "mousemove", event);
  134.              },
  135.  
  136.              mouseout: function(event) {
  137.                   return "FadeOut";
  138.               },
  139.  
  140.               timetick: function(event) {
  141.                   this.fadeTooltip(+this.tooltipOpacity/(this.fadeinTime*this.fadeRate));
  142.                  if (this.currentOpacity>=this.tooltipOpacity) {
  143.                       this.cancelTicker();
  144.                      this.startTimer(this.displayTime*1000);
  145.                      return "Display";
  146.                   }
  147.                   return this.CurrentState;
  148.              }
  149.          }, // end of FadingTooltip.prototype.actionTransitionFunctions.FadeIn
  150.  
  151.          Display: {
  152.  
  153.  
  154.               mousemove: function(event) {
  155.                   this.moveTooltip(event.clientX, event.clientY);
  156.                  return this.currentState;
  157.              },
  158.  
  159.               mouseout: function(event) {
  160.                   return this.doActionTransition("Display", "timeout", event);
  161.               },
  162.  
  163.               timeout: function(event) {
  164.                   this.cancelTimer();
  165.                   if (this.fadeoutTime>0) {
  166.                       this.startTicker(1000/this.fadeRate);
  167.                       return "FadeOut";
  168.                 } else {
  169.                       this.deleteTooltip();
  170.                      return "Inactive";
  171.                 }
  172.             }
  173.           }, // end of FadingTooltip.prototype.actionTransitionFunctions.Display
  174.  
  175.  
  176.          FadeOut: {
  177.  
  178.              mouseover: function(event) {
  179.                   this.moveTooltip(event.clientX, event.clientY);
  180.                  return "FadeIn";
  181.              },
  182.  
  183.              mousemove: function(event) {
  184.                  return this.doActionTransition("Display", "mousemove", event);
  185.              },
  186.               mouseout: function(event) {
  187.                   return this.currentState; // do nothing
  188.               },
  189.  
  190.              timetick: function(event) {
  191.                   this.fadeTooltip(-this.tooltipOpacity/(this.fadeoutTime*this.fadeRate));
  192.                   if (this.currentOpacity<=0) {
  193.                       this.cancelTicker();
  194.                       this.deleteTooltip();
  195.                      return "Inactive";
  196.                   }
  197.                  return this.currentState;
  198.              }
  199.          } // end of FadingTooltip.prototype.actionTransitionFunctions.FadeOut
  200.      }, // end of FadingTooltip.prototype.actionTransitionFunctions
  201.  
  202.  
Expand|Select|Wrap|Line Numbers
  1.       doActionTransition: function(anotherState, anotherEventType, event) {
  2.            return this.actionTransitionFunctions[anotherState][anotherEventType].call(this,event);
  3.       },
  4.  
  5.       startTimer: function(timeout) {
  6.           var self = this;
  7.           this.currentTimer = setTimeout(function() { self.handleEvent( { type: "timeout" } ); }, timeout);
  8.       },
  9.  
  10.  
  11.  
  12.      cancelTimer: function() {
  13.           if (this.currentTimer) clearTimeout(this.currentTimer);
  14.           this.currentTimer = null;
  15.       },
  16.  
  17.  
  18.  
  19.       startTicker: function(interval) {
  20.           var self = this;
  21.           this.currentTicker = setInterval(function() { self.handleEvent( { type: "timetick" } ); }, interval);
  22.       },
  23.  
  24.  
  25.  
  26.       cancelTicker: function() {
  27.           if (this.currentTicker) clearInterval(this.currentTicker);
  28.           this.currentTicker = null;
  29.       },
  30.  
  31.  
  32.       saveCursorPosition: function(x, y) {
  33.           this.lastCursorX = x;
  34.           this.lastCursorY = y;
  35.       },
  36.  
  37.  
  38.  
  39.       createTooltip: function() {
  40.  
  41.  
  42.           this.tooltipDivision = document.createElement("div");
  43.           this.tooltipDivision.innerHTML = this.tooltipContent;
  44.  
  45.  
  46.           if (this.tooltipClass) {
  47.               this.tooltipDivision.className = this.tooltipClass;
  48.           } else {
  49.               this.tooltipDivision.style.minWidth = "25px";
  50.               this.tooltipDivision.style.maxWidth = "350px";
  51.               this.tooltipDivision.style.height = "auto";
  52.               this.tooltipDivision.style.border = "thin solid black";
  53.               this.tooltipDivision.style.padding = "5px";
  54.               this.tooltipDivision.style.backgroundColor = "yellow";
  55.           }
  56.  
  57.           this.tooltipDivision.style.position = "absolute";
  58.           this.tooltipDivision.style.zIndex = 101;
  59.  
  60.           this.tooltipDivision.style.left = this.lastCursorX + this.tooltipOffsetX;
  61.           this.tooltipDivision.style.top = this.lastCursorY + this.tooltipOffsetY;
  62.  
  63.  
  64.           this.currentOpacity = 0;
  65.           this.tooltipDivision.style.opacity = 0;
  66.           if (this.tooltipDivision.filters) this.tooltipDivision.style.filter = "alpha(opacity=0)"; // for MSIE only
  67.  
  68.           // display the tooltip on the page
  69.           document.body.appendChild(this.tooltipDivision);
  70.       },
  71.  
  72.  
  73.       fadeTooltip: function(opacityDelta) {
  74.  
  75.           this.currentOpacity = Math.round((this.currentOpacity + opacityDelta)*1000000)/1000000;
  76.  
  77.  
  78.           if (this.currentOpacity<0) this.currentOpacity = 0;
  79.           if (this.currentOpacity>this.tooltipOpacity) this.currentOpacity = this.tooltipOpacity;
  80.  
  81.  
  82.           this.tooltipDivision.style.opacity = this.currentOpacity;
  83.           if (this.tooltipDivision.filters) this.tooltipDivision.filters.item("alpha").opacity = 100*this.currentOpacity; // for MSIE only
  84.       },
  85.  
  86.  
  87.       moveTooltip: function(x, y) {
  88.           this.tooltipDivision.style.left = x + this.tooltipOffsetX;
  89.           this.tooltipDivision.style.top = y + this.tooltipOffsetY;
  90.       },
  91.  
  92.  
  93.  
  94.       deleteTooltip: function() {
  95.           if (this.tooltipDivision) document.body.removeChild(this.tooltipDivision);
  96.           this.tooltipDivision = null;
  97.      }
  98.  
  99.   }; // end of FadingTooltip.prototype
  100.  
  101.   if ( (window.navigator.userAgent).indexOf("MSIE")!=-1 || (window.navigator.userAgent).indexOf("Opera")!=-1 )
  102.    {
  103.      //if (this.trace) trace("Pause/mouseover hack added to state table");
  104.       FadingTooltip.prototype.actionTransitionFunctions.Pause.mouseover = function(event) {
  105.           return this.doActionTransition("Inactive", "mouseover", event);
  106.       };
  107.  
  108. }
  109. }
  110.  
I can't figureout this code . it give error in attach event code but program runs successfully. how i remove my error?

thanks
Aug 24 '07 #1
1 1440
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

Please post code using CODE tags. Thanks!

What is the error message?
Aug 24 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I...
0
by: chak | last post by:
Hello, I am trying to access the local PC's Outlook folder , but get this 'Server execution failed" error. Any hint where the error is ? Thanks.
8
by: Toni | last post by:
Hello I'm a newbie in VB .NET and I'd like to accomplish a (I think) very simple task. What I want to do is throw an error message to the user whenever something happens. The main point is...
21
by: Anthony England | last post by:
Everyone knows that global variables get re-set in an mdb when an un-handled error is encountered, but it seems that this also happens when the variable is defined as private at form-level. So...
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
0
by: David Berman | last post by:
Hello, I'm receiving an error reading the machine.config file when I try to access my web application. This error came out of nowhere. After searching many sites, googelizing and searching here,...
5
by: Raj | last post by:
i get this error SQL30020N when selecting data from a table . I altered this table earlier today when i do it a select * from the table query runs OK, but when i join this table with 10 other...
2
by: kavyak | last post by:
This is not a mere error. because,whatever input i give from jsp, its getting updated in mysql but the page is showing some internal error.The error looks like this.Plz tell me if someone knows the...
0
by: debug03 | last post by:
I am executing a DTS package on a Windows 2000 sp4 server running SQL Server 2000 and IBM DB2 V7 client. The DTS package source data(SQL Server) is selected from SQL server table and inserts data to...
0
by: shapper | last post by:
Hello, I got the full script to create the ASP.NET Membership tables. When I run the scripts on my table I get the following: --------------------------------------- Starting execution of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.