ryykko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Feb-11 10:46 UTC
setTimeout and increment
hi
just a fast question, really dont get it :
_up: function(val,pourcent) {
this.val = val;
this.pourcent = pourcent;
var k=0;
if(k<=val){
$(pourcent).update(parseInt(k/3)+''%'');
z=0;
while(z<100)
++z;
setTimeout(function()
{this._up(this.val,this.pourcent);}.bind(this), 80);
++k;
}
},
just a code to increment and screen a var but stay at zero.
tx for any help :)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
I cannot make any sense of your posting. Please explain a bit more. On Feb 11, 5:46 am, "ryy...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <ryy...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi > > just a fast question, really dont get it : > > _up: function(val,pourcent) { > > this.val = val; > this.pourcent = pourcent; > > var k=0; > if(k<=val){ > $(pourcent).update(parseInt(k/3)+''%''); > z=0; > while(z<100) > ++z; > setTimeout(function() > {this._up(this.val,this.pourcent);}.bind(this), 80); > ++k; > } > > }, > > just a code to increment and screen a var but stay at zero. > tx for any help :)--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
ryykko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Feb-11 19:25 UTC
Re: setTimeout and increment
yes sry , it s really mean nothing ;;)
to make a summary
i try to increase a percentage ''k'' limited by
''val'' in the loop.
the setTimout should make a break to display the increase of
''k'' on
screen like this 1.2.3.4 etc etc till ''val'' is reached..
of course like this, the percentage stuck at 0.
i try so many thing to get it work ,
i try to get out the this by reference
function Ref( o_, fct_){
return( function(){o_[ fct_]()});
}
setTimout(Ref( this, this_up), 80);
no error and stuck at 0
i really dont know how to do this.
hope yu can figure out sthg!!:)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
ryykko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Feb-11 21:04 UTC
Re: setTimeout and increment
im so S.....
upp: function(val,pourcent,k,z) {
if(!k)var k=0;
if(k<=val){
$(pourcent).update(k+''%'');
if(!z) var z=0;
while(z<100)
++z;
setTimeout(function(){this.upp(val,pourcent,k,z);}.bind(this), 50);
++k;
}
},
wonder if there s no clean way to do this
;)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
ok. so color me stupid, but why are you calling the function from within itself? On Mon, Feb 11, 2008 at 4:04 PM, ryykko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <ryykko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > im so S..... > > upp: function(val,pourcent,k,z) { > > > if(!k)var k=0; > if(k<=val){ > $(pourcent).update(k+''%''); > if(!z) var z=0; > while(z<100) > ++z; > setTimeout(function(){this.upp(val,pourcent,k,z);}.bind(this), 50); > ++k; > } > }, > wonder if there s no clean way to do this > ;) > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I''m not sure if I understand correctly what you want. If it is
something that updates a container element with an increasing number
(from 0 to a provided limit), then this will do it:
var progressIndicator = function(element, upTo) {
var element = $(element), upTo = upTo || 100, percent = 0;
new PeriodicalExecuter(function() {
if (percent >= upTo) this.stop()
element.update(percent++ + "%");
}, 0.05);
}
progressIndicator("container"); // will go all the way up to 100%
progressIndicator(someElement, 50); // will finish in 50%
Best,
-Nicolas
On Feb 11, 2008 7:04 PM, ryykko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
<ryykko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> im so S.....
>
> upp: function(val,pourcent,k,z) {
>
>
> if(!k)var k=0;
> if(k<=val){
> $(pourcent).update(k+''%'');
> if(!z) var z=0;
> while(z<100)
> ++z;
> setTimeout(function(){this.upp(val,pourcent,k,z);}.bind(this), 50);
> ++k;
> }
> },
> wonder if there s no clean way to do this
>
> ;)
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
ryykko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Feb-12 00:53 UTC
Re: setTimeout and increment
but why are you calling the function from within itself? cause i m so newww :) and split my code too much to figure it out :) at least tx for your code nicolas, very useful and implement in my code tx again guys --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---