Loading ...
Sorry, an error occurred while loading the content.
 

Refresh or polling mechanism in YUI (revisited)

Expand Messages
  • groovepapa82
    I d like to re-visit this discussion. I m trying to put a polling connection inside a javascript class like so: ProcessList = Class.create();
    Message 1 of 14 , Jul 18, 2006
      I'd like to re-visit this discussion. I'm trying to put a polling connection inside a javascript class like so:

      ProcessList = Class.create();

      ProcessList.prototype = {
      initialize: function() {
      this.pCallback = {
      success: this.refreshThreads,
      failure: this.refreshThreads,
      scope: this
      };
      this.refreshInterval = 2;
      },

      refreshThreads: function(request){
      $('threadDisplay').innerHTML = (request) ? request.responseText : "";
      if ($('secondsRefresh').value){
      var secValue = parseFloat($('secondsRefresh').value);
      if (isNaN(secValue)){
      alert("Invalid entry for refresh interval, resetting to default 3");
      this.refreshInterval = 2;
      } else {
      this.refreshInterval = secValue;
      }
      }
      if(this.refreshInterval > 0){
      setInterval(this.updateThreadInfo, this.refreshInterval*1000);
      }
      },

      updateThreadInfo: function(){
      alert("this.refreshInterval: " + this.refreshInterval);
      var processURL = "processlist.php?"; // server-side script

      for (var i=0;i<filters.length;i++){
      var filter = filters;
      var filterInputEl = document.getElementById(filter);
      if(filterInputEl.value){
      processURL += filter+"="+filterInputEl.value+"&";
      }else{
      processURL += filter+"=ALL&";
      }
      }
      YAHOO.util.Connect.asyncRequest('GET', processURL, this.pCallback);
      }
      };

      But I get an error from connection.js (line 32): "
      callback has no properties"; ProcessList.js (line 42). As near as I can tell, the use of "setInterval" destroys the scope of "this" keyword? Because when I changed the calling code to call updateThreadInfo() directly instead of going thru the refreshThreads() function, it works fine ONCE, and then fails the second time - after it's gone thru refreshThreads. If I take the setInterval out of refreshThreads, it works every time, but it fires off requests way too fast to be practical.

      Does anyone know of a good way to add polling-like mechanisms to js objects?

      I checked out ACE (www.lishen.name), but it doesn't have all the features that YUI does. Inside the ACE code, it looks like he's constructing his connection class without the use of "this" variable scope? Can anyone explain how to do that?

      Thanks in advance.


      --- In ydn-javascript@yahoogroups.com, "Daniel" <danielmd3000@...> wrote:
      >
      > Hi,
      >
      > I need to create a simple RSS widget in my webapge, i want the RSS
      > feed container to update every 30 minutes, how do i do this with YUI?
      > Do i need to use javascript method setTimeout, or is there another way
      > to do it?
      >
      > Thanks,
      > Dan
      >
    • Nige White
      Have a go with the setInterval line like this: var self = this; setInterval(function() { self.updateThreadInfo(); }, this.refreshInterval*1000); ...
      Message 2 of 14 , Jul 18, 2006
        Have a go with the setInterval line like this:

        var self = this;
        setInterval(function()
        {
        self.updateThreadInfo();
        }, this.refreshInterval*1000);

        groovepapa82 wrote:

        > I'd like to re-visit this discussion. I'm trying to put a polling
        > connection inside a javascript class like so:
        >
        > ProcessList = Class.create();
        >
        > ProcessList.prototype = {
        >
        > initialize: function() {
        >
        > this.pCallback = {
        >
        > success: this.refreshThreads,
        > failure: this.refreshThreads,
        > scope: this
        >
        > };
        > this.refreshInterval = 2;
        >
        > },
        >
        >
        > refreshThreads: function(request){
        >
        > $('threadDisplay').innerHTML = (request) ?
        > request.responseText : "";
        > if ($('secondsRefresh').value){
        >
        > var secValue = parseFloat($('secondsRefresh').value);
        > if (isNaN(secValue)){
        >
        > alert("Invalid entry for refresh interval, resetting
        > to default 3");
        > this.refreshInterval = 2;
        >
        > } else {
        >
        > this.refreshInterval = secValue;
        >
        > }
        >
        > }
        > if(this.refreshInterval > 0){
        >
        > setInterval(this.updateThreadInfo, this.refreshI
        > nterval*1000);
        >
        > }
        >
        > },
        >
        >
        > updateThreadInfo: function(){
        >
        > alert("this.refreshInterval: " + this.refreshInterval);
        > var processURL = "processlist.php?"; // server-side script
        >
        > for (var i=0;i<filters.length;i++){
        >
        > var filter = filters;
        > var filterInputEl = document.getElementById(filter);
        > if(filterInputEl.value){
        >
        > processURL += filter+"="+filterInputEl.value+"&";
        >
        > }else{
        >
        > processURL += filter+"=ALL&";
        >
        > }
        >
        > }
        > YAHOO.util.Connect.asyncRequest('GET', processURL,
        > this.pCallback);
        >
        > }
        >
        > };
        >
        > But I get an error from connection.js (line 32): "callback has no
        > properties/"/; ProcessList.js (line 42). As near as I can tell, the
        > use of "setInterval" destroys the scope of "this" keyword? Because
        > when I changed the calling code to call updateThreadInfo() directly
        > instead of going thru the refreshThreads() function, it works fine
        > ONCE, and then fails the second time - after it's gone thru
        > refreshThreads. If I take the setInterval out of refreshThreads, it
        > works every time, but it fires off requests way too fast to be practical.
        >
        > Does anyone know of a good way to add polling-like mechanisms to js
        > objects?
        >
        > I checked out ACE (www.lishen.name), but it doesn't have all the
        > features that YUI does. Inside the ACE code, it looks like he's
        > constructing his connection class without the use of "this" variable
        > scope? Can anyone explain how to do that?
        >
        > Thanks in advance.
        >
        >
        > --- In ydn-javascript@yahoogroups.com, "Daniel" <danielmd3000@...> wrote:
        > >
        > > Hi,
        > >
        > > I need to create a simple RSS widget in my webapge, i want the RSS
        > > feed container to update every 30 minutes, how do i do this with YUI?
        > > Do i need to use javascript method setTimeout, or is there another way
        > > to do it?
        > >
        > > Thanks,
        > > Dan
        > >
        >
        > _____________________________________________________________________
        > This message has been checked for all known viruses. Virus scanning
        > powered by Messagelabs http://www.messagelabs.com For more information
        > e-mail : hostmaster@...



        _____________________________________________________________________
        This message has been checked for all known viruses. Virus scanning
        powered by Messagelabs http://www.messagelabs.com For more information
        e-mail : hostmaster@...
      • dav.glass@yahoo.com
        When the setInterval is being called it is loosing scope, you can t pass it a this var.. You should be able to call it like this:
        Message 3 of 14 , Jul 18, 2006
          When the setInterval is being called it is loosing scope, you can't pass it a this var..

          You should be able to call it like this:
          setInterval(ProcessList.updateThreadInfo, ProcessList.refreshInterval*1000);

          Hope that helps...
           
          Dav Glass
          dav.glass@...
          davglass.com
          618.694.3476

          + Windows: n. - The most successful computer virus, ever. +
          + A computer without a Microsoft operating system is like a dog
          without bricks tied to its head +
          + A Microsoft Certified Systems Engineer is to computing what a
          McDonalds Certified Food Specialist is to fine cuisine +


          ----- Original Message ----
          From: groovepapa82 <luke.crouch@...>
          To: ydn-javascript@yahoogroups.com
          Sent: Tuesday, July 18, 2006 7:22:41 AM
          Subject: [ydn-javascript] Refresh or polling mechanism in YUI (revisited)

          I'd like to re-visit this discussion. I'm trying to put a polling connection inside a javascript class like so:

          ProcessList = Class.create();

          ProcessList.prototype = {

          initialize: function() {
          this.pCallback = {
          success: this.refreshThreads,
          failure: this.refreshThreads,
          scope: this
          };
          this.refreshInterval = 2;
          },

          refreshThreads: function(request){
          $('threadDisplay').innerHTML = (request) ? request.responseText : "";
          if ($('secondsRefresh').value){
          var secValue = parseFloat($('secondsRefresh').value);
          if (isNaN(secValue)){
          alert("Invalid entry for refresh interval, resetting to default 3");
          this.refreshInterval = 2;
          } else {
          this.refreshInterval = secValue;
          }
          }
          if(this.refreshInterval > 0){
          setInterval(this.updateThreadInfo, this.refreshInterval*1000);
          }
          },

          updateThreadInfo: function(){
          alert("this.refreshInterval: " + this.refreshInterval);
          var processURL = "processlist.php?"; // server-side script

          for (var i=0;i<filters.length;i++){
          var filter = filters;
          var filterInputEl = document.getElementById(filter);
          if(filterInputEl.value){
          processURL += filter+"="+filterInputEl.value+"&";
          }else{
          processURL += filter+"=ALL&";
          }
          }
          YAHOO.util.Connect.asyncRequest('GET', processURL, this.pCallback);
          }
          };

          But I get an error from connection.js (line 32): "
          callback has no properties"; ProcessList.js (line 42). As near as I can tell, the use of "setInterval" destroys the scope of "this" keyword? Because when I changed the calling code to call updateThreadInfo() directly instead of going thru the refreshThreads() function, it works fine ONCE, and then fails the second time - after it's gone thru refreshThreads. If I take the setInterval out of refreshThreads, it works every time, but it fires off requests way too fast to be practical.

          Does anyone know of a good way to add polling-like mechanisms to js objects?

          I checked out ACE (www.lishen.name), but it doesn't have all the features that YUI does. Inside the ACE code, it looks like he's constructing his connection class without the use of "this" variable scope? Can anyone explain how to do that?

          Thanks in advance.


          --- In ydn-javascript@yahoogroups.com, "Daniel" <danielmd3000@...> wrote:
          >
          > Hi,
          >
          > I need to create a simple RSS widget in my webapge, i want the RSS
          > feed container to update every 30 minutes, how do i do this with YUI?
          > Do i need to use javascript method setTimeout, or is there another way
          > to do it?
          >
          > Thanks,
          > Dan
          >


        • Francisco
          May be you have this function in your general carrier bag , it has proved very useful for me you then forget about using self! /** * Sets a timeout in
          Message 4 of 14 , Jul 18, 2006

            May be you have this function in your general ‘carrier bag’, it has proved very useful for me you then forget about using self!

             

            /**

             * Sets a timeout in milliseconds to execute a function in a given context

             * with optional arguments.

             *

             * mySetTimeout (Object context, function func, number delay[, arg1[, ...]]);

             * mySetTimeout (function func, number delay[, arg1[, ...]]);

             */

            mySetTimeout = function(func, delay){

                        var context = window, argsStart = 2;

                        if(typeof func == ‘Function’ || typeof func == ‘function’){

                                    context = func;

                                    func = delay;

                                    delay = arguments[2];

                                    argsStart++;

                        }

             

                        if(typeof func == ‘String’ || typeof func == ‘string’){

                                    func = context[func];

                        }

                       

                        var args = [];

                        for (var i = argsStart; i < arguments.length; i++) {

                                    args.push(arguments[i]);

                        }

                        return setTimeout(function () { func.apply(context, args); }, delay);

            }

             

            Francisco


            From: ydn-javascript@yahoogroups.com [mailto:ydn-javascript@yahoogroups.com] On Behalf Of Nige White
            Sent: 18 July 2006 15:30
            To: ydn-javascript@yahoogroups.com
            Subject: Re: [ydn-javascript] Refresh or polling mechanism in YUI (revisited)

             

            Have a go with the setInterval line like this:

            var self = this;
            setInterval( function( )
            {
            self.updateThreadIn fo();
            }, this.refreshInterva l*1000);

            groovepapa82 wrote:

            > I'd like to re-visit this discussion. I'm trying to put a polling
            > connection inside a javascript class like so:
            >
            > ProcessList = Class.create( );
            >
            > ProcessList. prototype = {
            >
            > initialize: function() {
            >
            > this.pCallback = {
            >
            > success: this.refreshThreads ,
            > failure: this.refreshThreads ,
            > scope: this
            >
            > };
            > this.refreshInterva l = 2;
            >
            > },
            >
            >
            > refreshThreads: function(request) {
            >
            > $('threadDisplay' ).innerHTML = (request) ?
            > request.responseTex t : "";
            > if ($('secondsRefresh' ).value){
            >
            > var secValue = parseFloat($ ('secondsRefresh ').value) ;
            > if (isNaN(secValue) ){
            >
            > alert("Invalid entry for refresh interval, resetting
            > to default 3");
            > this.refreshInterva l = 2;
            >
            > } else {
            >
            > this.refreshInterva l = secValue;
            >
            > }
            >
            > }
            > if(this.refreshInte rval > 0){
            >
            > setInterval( this.updateThrea dInfo, this.refreshI
            > nterval*1000) ;
            >
            > }
            >
            > },
            >
            >
            > updateThreadInfo: function(){
            >
            > alert("this. refreshInterval: " + this.refreshInterva l);
            > var processURL = "processlist. php?"; // server-side script
            >
            > for (var i=0;i<filters. length;i+ +){
            >
            > var filter = filters;
            > var filterInputEl = document.getElement ById(filter) ;
            > if(filterInputEl. value){
            >
            > processURL += filter+"="+filterIn putEl.value+ "&";
            >
            > }else{
            >
            > processURL += filter+"=ALL& ";
            >
            > }
            >
            > }
            > YAHOO.util.Connect. asyncRequest( 'GET', processURL,
            > this.pCallback) ;
            >
            > }
            >
            > };
            >
            > But I get an error from connection.js (line 32): "callback has no
            > properties/" /; ProcessList. js (line 42). As near as I can
            tell, the
            > use of "setInterval" destroys the scope of "this"
            keyword? Because
            > when I changed the calling code to call updateThreadInfo( ) directly
            > instead of going thru the refreshThreads( ) function, it works fine
            > ONCE, and then fails the second time - after it's gone thru
            > refreshThreads. If I take the setInterval out of refreshThreads, it
            > works every time, but it fires off requests way too fast to be practical.
            >
            > Does anyone know of a good way to add polling-like mechanisms to js
            > objects?
            >
            > I checked out ACE (www.lishen. name), but it doesn't have all the
            > features that YUI does. Inside the ACE code, it looks like he's
            > constructing his connection class without the use of "this"
            variable
            > scope? Can anyone explain how to do that?
            >
            > Thanks in advance.
            >
            >
            > --- In ydn-javascript@ yahoogroups. com,
            "Daniel" <danielmd3000@ ...> wrote:
            > >
            > > Hi,
            > >
            > > I need to create a simple RSS widget in my webapge, i want the RSS
            > > feed container to update every 30 minutes, how do i do this with YUI?
            > > Do i need to use javascript method setTimeout, or is there another
            way
            > > to do it?
            > >
            > > Thanks,
            > > Dan
            > >
            >
            > ____________ _________ _________ _________ _________ _________ _
            > This message has been checked for all known viruses. Virus scanning
            > powered by Messagelabs http://www.messagel abs.com
            For more information
            > e-mail : hostmaster@forward- comp.co.uk

            ____________ _________ _________ _________ _________ _________ _
            This message has been checked for all known viruses. Virus scanning
            powered by Messagelabs http://www.messagel abs.com For more information
            e-mail : hostmaster@forward- comp.co.uk

          • groovepapa82
            Neither IE6 nor Firefox 1.5 seem to support the apply function? I received func.apply is not a function from Firefox, and a Object doesn t support this
            Message 5 of 14 , Jul 18, 2006
              Neither IE6 nor Firefox 1.5 seem to support the "apply" function? I
              received "func.apply is not a function" from Firefox, and a "Object
              doesn't support this property or method" from IE.

              I also tried changing "apply" to "call" and got the same result.

              --- In ydn-javascript@yahoogroups.com, "Francisco" <monteiro@...> wrote:
              >
              > May be you have this function in your general 'carrier bag', it has
              proved
              > very useful for me you then forget about using self!
              >
              >
              >
              > /**
              >
              > * Sets a timeout in milliseconds to execute a function in a given
              context
              >
              > * with optional arguments.
              >
              > *
              >
              > * mySetTimeout (Object context, function func, number delay[, arg1[,
              > ...]]);
              >
              > * mySetTimeout (function func, number delay[, arg1[, ...]]);
              >
              > */
              >
              > mySetTimeout = function(func, delay){
              >
              > var context = window, argsStart = 2;
              >
              > if(typeof func == 'Function' || typeof func == 'function'){
              >
              > context = func;
              >
              > func = delay;
              >
              > delay = arguments[2];
              >
              > argsStart++;
              >
              > }
              >
              >
              >
              > if(typeof func == 'String' || typeof func == 'string'){
              >
              > func = context[func];
              >
              > }
              >
              >
              >
              > var args = [];
              >
              > for (var i = argsStart; i < arguments.length; i++) {
              >
              > args.push(arguments[i]);
              >
              > }
              >
              > return setTimeout(function () { func.apply(context,
              args); },
              > delay);
              >
              > }
              >
              >
              >
              > Francisco
              >
              > _____
              >
              > From: ydn-javascript@yahoogroups.com
              [mailto:ydn-javascript@yahoogroups.com]
              > On Behalf Of Nige White
              > Sent: 18 July 2006 15:30
              > To: ydn-javascript@yahoogroups.com
              > Subject: Re: [ydn-javascript] Refresh or polling mechanism in YUI
              > (revisited)
              >
              >
              >
              > Have a go with the setInterval line like this:
              >
              > var self = this;
              > setInterval(function()
              > {
              > self.updateThreadInfo();
              > }, this.refreshInterval*1000);
              >
              > groovepapa82 wrote:
              >
              > > I'd like to re-visit this discussion. I'm trying to put a polling
              > > connection inside a javascript class like so:
              > >
              > > ProcessList = Class.create();
              > >
              > > ProcessList.prototype = {
              > >
              > > initialize: function() {
              > >
              > > this.pCallback = {
              > >
              > > success: this.refreshThreads,
              > > failure: this.refreshThreads,
              > > scope: this
              > >
              > > };
              > > this.refreshInterval = 2;
              > >
              > > },
              > >
              > >
              > > refreshThreads: function(request){
              > >
              > > $('threadDisplay').innerHTML = (request) ?
              > > request.responseText : "";
              > > if ($('secondsRefresh').value){
              > >
              > > var secValue = parseFloat($('secondsRefresh').value);
              > > if (isNaN(secValue)){
              > >
              > > alert("Invalid entry for refresh interval, resetting
              > > to default 3");
              > > this.refreshInterval = 2;
              > >
              > > } else {
              > >
              > > this.refreshInterval = secValue;
              > >
              > > }
              > >
              > > }
              > > if(this.refreshInterval > 0){
              > >
              > > setInterval(this.updateThreadInfo, this.refreshI
              > > nterval*1000);
              > >
              > > }
              > >
              > > },
              > >
              > >
              > > updateThreadInfo: function(){
              > >
              > > alert("this.refreshInterval: " + this.refreshInterval);
              > > var processURL = "processlist.php?"; // server-side script
              > >
              > > for (var i=0;i<filters.length;i++){
              > >
              > > var filter = filters;
              > > var filterInputEl = document.getElementById(filter);
              > > if(filterInputEl.value){
              > >
              > > processURL += filter+"="+filterInputEl.value+"&";
              > >
              > > }else{
              > >
              > > processURL += filter+"=ALL&";
              > >
              > > }
              > >
              > > }
              > > YAHOO.util.Connect.asyncRequest('GET', processURL,
              > > this.pCallback);
              > >
              > > }
              > >
              > > };
              > >
              > > But I get an error from connection.js (line 32): "callback has no
              > > properties/"/; ProcessList.js (line 42). As near as I can tell, the
              > > use of "setInterval" destroys the scope of "this" keyword? Because
              > > when I changed the calling code to call updateThreadInfo() directly
              > > instead of going thru the refreshThreads() function, it works fine
              > > ONCE, and then fails the second time - after it's gone thru
              > > refreshThreads. If I take the setInterval out of refreshThreads, it
              > > works every time, but it fires off requests way too fast to be
              practical.
              > >
              > > Does anyone know of a good way to add polling-like mechanisms to js
              > > objects?
              > >
              > > I checked out ACE (www.lishen.name), but it doesn't have all the
              > > features that YUI does. Inside the ACE code, it looks like he's
              > > constructing his connection class without the use of "this" variable
              > > scope? Can anyone explain how to do that?
              > >
              > > Thanks in advance.
              > >
              > >
              > > --- In ydn-javascript@ <mailto:ydn-javascript%40yahoogroups.com>
              > yahoogroups.com, "Daniel" <danielmd3000@> wrote:
              > > >
              > > > Hi,
              > > >
              > > > I need to create a simple RSS widget in my webapge, i want the RSS
              > > > feed container to update every 30 minutes, how do i do this with
              YUI?
              > > > Do i need to use javascript method setTimeout, or is there
              another way
              > > > to do it?
              > > >
              > > > Thanks,
              > > > Dan
              > > >
              > >
              > > __________________________________________________________
              > > This message has been checked for all known viruses. Virus scanning
              > > powered by Messagelabs http://www.messagel
              <http://www.messagelabs.com>
              > abs.com For more information
              > > e-mail : hostmaster@forward- <mailto:hostmaster%40forward-comp.co.uk>
              > comp.co.uk
              >
              > __________________________________________________________
              > This message has been checked for all known viruses. Virus scanning
              > powered by Messagelabs http://www.messagel <http://www.messagelabs.com>
              > abs.com For more information
              > e-mail : hostmaster@forward- <mailto:hostmaster%40forward-comp.co.uk>
              > comp.co.uk
              >
            • groovepapa82
              This did work, but it also created a closure which caused the browser to hog up memory and cpu very quickly. So I need some solution without defining the
              Message 6 of 14 , Jul 18, 2006
                This did work, but it also created a closure which caused the browser
                to hog up memory and cpu very quickly. So I need some solution without
                defining the function within the object.

                -L

                --- In ydn-javascript@yahoogroups.com, Nige White <nigelw@...> wrote:
                >
                > Have a go with the setInterval line like this:
                >
                > var self = this;
                > setInterval(function()
                > {
                > self.updateThreadInfo();
                > }, this.refreshInterval*1000);
                >
                > groovepapa82 wrote:
                >
                > > I'd like to re-visit this discussion. I'm trying to put a polling
                > > connection inside a javascript class like so:
                > >
                > > ProcessList = Class.create();
                > >
                > > ProcessList.prototype = {
                > >
                > > initialize: function() {
                > >
                > > this.pCallback = {
                > >
                > > success: this.refreshThreads,
                > > failure: this.refreshThreads,
                > > scope: this
                > >
                > > };
                > > this.refreshInterval = 2;
                > >
                > > },
                > >
                > >
                > > refreshThreads: function(request){
                > >
                > > $('threadDisplay').innerHTML = (request) ?
                > > request.responseText : "";
                > > if ($('secondsRefresh').value){
                > >
                > > var secValue = parseFloat($('secondsRefresh').value);
                > > if (isNaN(secValue)){
                > >
                > > alert("Invalid entry for refresh interval, resetting
                > > to default 3");
                > > this.refreshInterval = 2;
                > >
                > > } else {
                > >
                > > this.refreshInterval = secValue;
                > >
                > > }
                > >
                > > }
                > > if(this.refreshInterval > 0){
                > >
                > > setInterval(this.updateThreadInfo, this.refreshI
                > > nterval*1000);
                > >
                > > }
                > >
                > > },
                > >
                > >
                > > updateThreadInfo: function(){
                > >
                > > alert("this.refreshInterval: " + this.refreshInterval);
                > > var processURL = "processlist.php?"; // server-side script
                > >
                > > for (var i=0;i<filters.length;i++){
                > >
                > > var filter = filters;
                > > var filterInputEl = document.getElementById(filter);
                > > if(filterInputEl.value){
                > >
                > > processURL += filter+"="+filterInputEl.value+"&";
                > >
                > > }else{
                > >
                > > processURL += filter+"=ALL&";
                > >
                > > }
                > >
                > > }
                > > YAHOO.util.Connect.asyncRequest('GET', processURL,
                > > this.pCallback);
                > >
                > > }
                > >
                > > };
                > >
                > > But I get an error from connection.js (line 32): "callback has no
                > > properties/"/; ProcessList.js (line 42). As near as I can tell, the
                > > use of "setInterval" destroys the scope of "this" keyword? Because
                > > when I changed the calling code to call updateThreadInfo() directly
                > > instead of going thru the refreshThreads() function, it works fine
                > > ONCE, and then fails the second time - after it's gone thru
                > > refreshThreads. If I take the setInterval out of refreshThreads, it
                > > works every time, but it fires off requests way too fast to be
                practical.
                > >
                > > Does anyone know of a good way to add polling-like mechanisms to js
                > > objects?
                > >
                > > I checked out ACE (www.lishen.name), but it doesn't have all the
                > > features that YUI does. Inside the ACE code, it looks like he's
                > > constructing his connection class without the use of "this" variable
                > > scope? Can anyone explain how to do that?
                > >
                > > Thanks in advance.
                > >
                > >
                > > --- In ydn-javascript@yahoogroups.com, "Daniel" <danielmd3000@> wrote:
                > > >
                > > > Hi,
                > > >
                > > > I need to create a simple RSS widget in my webapge, i want the RSS
                > > > feed container to update every 30 minutes, how do i do this with
                YUI?
                > > > Do i need to use javascript method setTimeout, or is there
                another way
                > > > to do it?
                > > >
                > > > Thanks,
                > > > Dan
                > > >
                > >
                > > _____________________________________________________________________
                > > This message has been checked for all known viruses. Virus scanning
                > > powered by Messagelabs http://www.messagelabs.com For more information
                > > e-mail : hostmaster@...
                >
                >
                >
                > _____________________________________________________________________
                > This message has been checked for all known viruses. Virus scanning
                > powered by Messagelabs http://www.messagelabs.com For more information
                > e-mail : hostmaster@...
                >
              • groovepapa82
                When I tried that, I got useless setInterval call (missing quotes around argument? so I changed it to:
                Message 7 of 14 , Jul 18, 2006
                  When I tried that, I got "useless setInterval call (missing quotes
                  around argument?" so I changed it to:

                  setInterval(ProcessList.updateThreadInfo(),ProcessList.refreshInterval*1000);

                  and got:

                  ProcessList.updateThreadInfo is not a function

                  so I changed it to:

                  setInterval("ProcessList.updateThreadInfo()",ProcessList.refreshInterval*1000);

                  and got the same message.

                  --- In ydn-javascript@yahoogroups.com, <dav.glass@...> wrote:
                  >
                  > When the setInterval is being called it is loosing scope, you can't
                  pass it a this var..
                  >
                  > You should be able to call it like this:
                  > setInterval(ProcessList.updateThreadInfo,
                  ProcessList.refreshInterval*1000);
                  >
                  > Hope that helps...
                  >
                  > Dav Glass
                  > dav.glass@...
                  > davglass.com
                  > 618.694.3476
                  >
                  > + Windows: n. - The most successful computer virus, ever. +
                  > + A computer without a Microsoft operating system is like a dog
                  > without bricks tied to its head +
                  > + A Microsoft Certified Systems Engineer is to computing what a
                  > McDonalds Certified Food Specialist is to fine cuisine +
                  >
                  > ----- Original Message ----
                  > From: groovepapa82 <luke.crouch@...>
                  > To: ydn-javascript@yahoogroups.com
                  > Sent: Tuesday, July 18, 2006 7:22:41 AM
                  > Subject: [ydn-javascript] Refresh or polling mechanism in YUI
                  (revisited)
                  >
                  > I'd like to re-visit this discussion. I'm
                  trying to put a polling connection inside a javascript class like so:
                  >
                  > ProcessList = Class.create();
                  >
                  > ProcessList.prototype = {
                  >
                  > initialize: function() {
                  > this.pCallback = {
                  > success: this.refreshThreads,
                  > failure: this.refreshThreads,
                  > scope: this
                  > };
                  > this.refreshInterval = 2;
                  > },
                  >
                  > refreshThreads: function(request){
                  > $('threadDisplay').innerHTML = (request) ? request.responseText : "";
                  > if ($('secondsRefresh').value){
                  > var secValue = parseFloat($('secondsRefresh').value);
                  > if (isNaN(secValue)){
                  > alert("Invalid entry for refresh interval, resetting to default 3");
                  > this.refreshInterval = 2;
                  > } else {
                  > this.refreshInterval = secValue;
                  > }
                  > }
                  > if(this.refreshInterval > 0){
                  > setInterval(this.updateThreadInfo, this.refreshInterval*1000);
                  > }
                  > },
                  >
                  > updateThreadInfo: function(){
                  > alert("this.refreshInterval: " + this.refreshInterval);
                  > var processURL = "processlist.php?"; // server-side script
                  >
                  > for (var i=0;i<filters.length;i++){
                  > var filter = filters;
                  > var filterInputEl = document.getElementById(filter);
                  > if(filterInputEl.value){
                  > processURL += filter+"="+filterInputEl.value+"&";
                  > }else{
                  > processURL += filter+"=ALL&";
                  > }
                  > }
                  > YAHOO.util.Connect.asyncRequest('GET', processURL, this.pCallback);
                  > }
                  > };
                  >
                  > But I get an error from connection.js (line 32): "callback has no
                  properties"; ProcessList.js (line 42). As near as I can tell, the use
                  of "setInterval" destroys the scope of "this" keyword? Because when I
                  changed the calling code to call updateThreadInfo() directly instead
                  of going thru the refreshThreads() function, it works fine ONCE, and
                  then fails the second time - after it's gone thru refreshThreads. If I
                  take the setInterval out of refreshThreads, it works every time, but
                  it fires off requests way too fast to be practical.
                  >
                  > Does anyone know of a good way to add polling-like mechanisms to js
                  objects?
                  >
                  > I checked out ACE (www.lishen.name), but it doesn't have all the
                  features that YUI does. Inside the ACE code, it looks like he's
                  constructing his connection class without the use of "this" variable
                  scope? Can anyone explain how to do that?
                  >
                  > Thanks in advance.
                  >
                  >
                  > --- In ydn-javascript@yahoogroups.com, "Daniel" <danielmd3000@>
                  wrote:
                  > >
                  > > Hi,
                  > >
                  > > I need to create a simple RSS widget in my webapge, i want the RSS
                  > > feed container to update every 30 minutes, how do i do this with YUI?
                  > > Do i need to use javascript method setTimeout, or is there another way
                  > > to do it?
                  > >
                  > > Thanks,
                  > > Dan
                  > >
                  >
                • groovepapa82
                  I also tried the setInterval line like so: setInterval(this.updateThreadInfo, this.refreshInterval*1000, this.pCallback); which worked as well, but also
                  Message 8 of 14 , Jul 18, 2006
                    I also tried the setInterval line like so:

                    setInterval(this.updateThreadInfo, this.refreshInterval*1000,
                    this.pCallback);

                    which worked as well, but also created a closure and hogged up memory
                    + cpu.

                    -L

                    --- In ydn-javascript@yahoogroups.com, "groovepapa82"
                    <luke.crouch@...> wrote:
                    >
                    > I'd like to re-visit this discussion. I'm trying to put a polling
                    > connection inside a javascript class like so:
                    >
                    > ProcessList = Class.create();
                    >
                    > ProcessList.prototype = {
                    > initialize: function() {
                    > this.pCallback = {
                    > success: this.refreshThreads,
                    > failure: this.refreshThreads,
                    > scope: this
                    > };
                    > this.refreshInterval = 2;
                    > },
                    >
                    > refreshThreads: function(request){
                    > $('threadDisplay').innerHTML = (request) ? request.responseText : "";
                    > if ($('secondsRefresh').value){
                    > var secValue = parseFloat($('secondsRefresh').value);
                    > if (isNaN(secValue)){
                    > alert("Invalid entry for refresh interval, resetting to default 3");
                    > this.refreshInterval = 2;
                    > } else {
                    > this.refreshInterval = secValue;
                    > }
                    > }
                    > if(this.refreshInterval > 0){
                    > setInterval(this.updateThreadInfo, this.refreshInterval*1000);
                    > }
                    > },
                    >
                    > updateThreadInfo: function(){
                    > alert("this.refreshInterval: " + this.refreshInterval);
                    > var processURL = "processlist.php?"; // server-side script
                    >
                    > for (var i=0;i<filters.length;i++){
                    > var filter = filters;
                    > var filterInputEl = document.getElementById(filter);
                    > if(filterInputEl.value){
                    > processURL += filter+"="+filterInputEl.value+"&";
                    > }else{
                    > processURL += filter+"=ALL&";
                    > }
                    > }
                    > YAHOO.util.Connect.asyncRequest('GET', processURL, this.pCallback);
                    > }
                    > };
                    >
                    > But I get an error from connection.js (line 32): "callback has no
                    > properties"; ProcessList.js (line 42). As near as I can tell, the use of
                    > "setInterval" destroys the scope of "this" keyword? Because when I
                    > changed the calling code to call updateThreadInfo() directly instead of
                    > going thru the refreshThreads() function, it works fine ONCE, and then
                    > fails the second time - after it's gone thru refreshThreads. If I take
                    > the setInterval out of refreshThreads, it works every time, but it fires
                    > off requests way too fast to be practical.
                    >
                    > Does anyone know of a good way to add polling-like mechanisms to js
                    > objects?
                    >
                    > I checked out ACE (www.lishen.name), but it doesn't have all the
                    > features that YUI does. Inside the ACE code, it looks like he's
                    > constructing his connection class without the use of "this" variable
                    > scope? Can anyone explain how to do that?
                    >
                    > Thanks in advance.
                    >
                    >
                    > --- In ydn-javascript@yahoogroups.com, "Daniel" <danielmd3000@>
                    > wrote:
                    > >
                    > > Hi,
                    > >
                    > > I need to create a simple RSS widget in my webapge, i want the RSS
                    > > feed container to update every 30 minutes, how do i do this with YUI?
                    > > Do i need to use javascript method setTimeout, or is there another way
                    > > to do it?
                    > >
                    > > Thanks,
                    > > Dan
                    > >
                    >
                  • hkclark
                    If anyone gets this working, please report back to the group. I m having the same issue. :-(
                    Message 9 of 14 , Jul 20, 2006
                      If anyone gets this working, please report back to the group. I'm
                      having the same issue. :-(

                      --- In ydn-javascript@yahoogroups.com, "groovepapa82"
                      <luke.crouch@...> wrote:
                      >
                      > I also tried the setInterval line like so:
                      >
                      > setInterval(this.updateThreadInfo, this.refreshInterval*1000,
                      > this.pCallback);
                      >
                      > which worked as well, but also created a closure and hogged up memory
                      > + cpu.
                      >
                      > -L
                      >
                    Your message has been successfully submitted and would be delivered to recipients shortly.