You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Leffel, Daniel" <dl...@ebay.com> on 2006/12/18 22:45:52 UTC

Problem implementing countdown timer

I have a really simple app that I'm trying to build. Shown on a page is
an object that expires within 20-60 seconds. Once it expires, a new
object is created with the same time to live (and so on and so on). The
current object is loaded through a Tacos AjaxAutoInvoker. Additionally,
I'm using the Tacos form submit on the page to enable users to
manipulate the object.

I'm trying to implement a countdown that shows in real time how many
seconds are left until the object expires. I tried using another
AjaxAutoInvoker without specifying a listener, but it makes an AJAX call
anyway. I don't want to cause an AJAX call to happen every second to
simply decrement the counter (the AjaxAutoInvoker otherwise refreshes
the object every 5 seconds). So, I tried a little bit of Javascript. The
problem is, this Javascript causes the AjaxForm to be submitted in a
non-AJAX way (Debug message is: XMLHTTP Transport Error:0). Any ideas on
the best way to accomplish this?


<script LANGUAGE="JavaScript">
var now = new Date();
var seconds = (event - now) / 1000;

ID=window.setTimeout("update();", 1000);
function update() {
now = new Date();
seconds = (document.getElementById('ends').innerHTML-now)/1000;
seconds = Math.round(seconds);
document.getElementById('countdown').innerHTML = seconds;
ID=window.setTimeout("update();",1000);
}
</script>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Problem implementing countdown timer

Posted by Jesse Kuhnert <jk...@gmail.com>.
It's hard to tell what's going wrong without seeing exactly how all of
the interactions are happening but can quite confidently say that this
would be much easier to do in tapestry 4.1.1 . Ie:

http://tapestry.apache.org/tapestry4.1/javascript/form.html
tapestry.form.submitAsync();

I'd probably even go so far as to use a Timer object to do the
repeated calls for me:
http://trac.dojotoolkit.org/browser/trunk/src/lang/timing/Timer.js

var timer=new dojo.lang.Timer(1000);
timer.onTick=update();
timer.start();

Besides that, we'd probably really have to see what "update()" is
doing to say for sure what the problem is.

On 12/18/06, Leffel, Daniel <dl...@ebay.com> wrote:
> I have a really simple app that I'm trying to build. Shown on a page is
> an object that expires within 20-60 seconds. Once it expires, a new
> object is created with the same time to live (and so on and so on). The
> current object is loaded through a Tacos AjaxAutoInvoker. Additionally,
> I'm using the Tacos form submit on the page to enable users to
> manipulate the object.
>
> I'm trying to implement a countdown that shows in real time how many
> seconds are left until the object expires. I tried using another
> AjaxAutoInvoker without specifying a listener, but it makes an AJAX call
> anyway. I don't want to cause an AJAX call to happen every second to
> simply decrement the counter (the AjaxAutoInvoker otherwise refreshes
> the object every 5 seconds). So, I tried a little bit of Javascript. The
> problem is, this Javascript causes the AjaxForm to be submitted in a
> non-AJAX way (Debug message is: XMLHTTP Transport Error:0). Any ideas on
> the best way to accomplish this?
>
>
> <script LANGUAGE="JavaScript">
> var now = new Date();
> var seconds = (event - now) / 1000;
>
> ID=window.setTimeout("update();", 1000);
> function update() {
> now = new Date();
> seconds = (document.getElementById('ends').innerHTML-now)/1000;
> seconds = Math.round(seconds);
> document.getElementById('countdown').innerHTML = seconds;
> ID=window.setTimeout("update();",1000);
> }
> </script>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Problem implementing countdown timer

Posted by D&J Gredler <dj...@gmail.com>.
Not moving makes them easier to hit with a railgun, though!

On 12/20/06, Jesse Kuhnert <jk...@gmail.com> wrote:
>
> God damn campers..... ;)
>
> On 12/20/06, Daniel Jue <te...@gmail.com> wrote:
> > Daniel,
> >
> > As an avid eBay user, I've been eagerly awaiting a feature like this!
> > Now everyone can be a sniper. =)
> > Now we just need some suspense music that streams in the background...
> >
> > Dan
> >
> > On 12/18/06, Leffel, Daniel <dl...@ebay.com> wrote:
> > > I have a really simple app that I'm trying to build. Shown on a page
> is
> > > an object that expires within 20-60 seconds. Once it expires, a new
> > > object is created with the same time to live (and so on and so on).
> The
> > > current object is loaded through a Tacos AjaxAutoInvoker.
> Additionally,
> > > I'm using the Tacos form submit on the page to enable users to
> > > manipulate the object.
> > >
> > > I'm trying to implement a countdown that shows in real time how many
> > > seconds are left until the object expires. I tried using another
> > > AjaxAutoInvoker without specifying a listener, but it makes an AJAX
> call
> > > anyway. I don't want to cause an AJAX call to happen every second to
> > > simply decrement the counter (the AjaxAutoInvoker otherwise refreshes
> > > the object every 5 seconds). So, I tried a little bit of Javascript.
> The
> > > problem is, this Javascript causes the AjaxForm to be submitted in a
> > > non-AJAX way (Debug message is: XMLHTTP Transport Error:0). Any ideas
> on
> > > the best way to accomplish this?
> > >
> > >
> > > <script LANGUAGE="JavaScript">
> > > var now = new Date();
> > > var seconds = (event - now) / 1000;
> > >
> > > ID=window.setTimeout("update();", 1000);
> > > function update() {
> > > now = new Date();
> > > seconds = (document.getElementById('ends').innerHTML-now)/1000;
> > > seconds = Math.round(seconds);
> > > document.getElementById('countdown').innerHTML = seconds;
> > > ID=window.setTimeout("update();",1000);
> > > }
> > > </script>
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> Jesse Kuhnert
> Tapestry/Dojo team member/developer
>
> Open source based consulting work centered around
> dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Problem implementing countdown timer

Posted by Jesse Kuhnert <jk...@gmail.com>.
God damn campers..... ;)

On 12/20/06, Daniel Jue <te...@gmail.com> wrote:
> Daniel,
>
> As an avid eBay user, I've been eagerly awaiting a feature like this!
> Now everyone can be a sniper. =)
> Now we just need some suspense music that streams in the background...
>
> Dan
>
> On 12/18/06, Leffel, Daniel <dl...@ebay.com> wrote:
> > I have a really simple app that I'm trying to build. Shown on a page is
> > an object that expires within 20-60 seconds. Once it expires, a new
> > object is created with the same time to live (and so on and so on). The
> > current object is loaded through a Tacos AjaxAutoInvoker. Additionally,
> > I'm using the Tacos form submit on the page to enable users to
> > manipulate the object.
> >
> > I'm trying to implement a countdown that shows in real time how many
> > seconds are left until the object expires. I tried using another
> > AjaxAutoInvoker without specifying a listener, but it makes an AJAX call
> > anyway. I don't want to cause an AJAX call to happen every second to
> > simply decrement the counter (the AjaxAutoInvoker otherwise refreshes
> > the object every 5 seconds). So, I tried a little bit of Javascript. The
> > problem is, this Javascript causes the AjaxForm to be submitted in a
> > non-AJAX way (Debug message is: XMLHTTP Transport Error:0). Any ideas on
> > the best way to accomplish this?
> >
> >
> > <script LANGUAGE="JavaScript">
> > var now = new Date();
> > var seconds = (event - now) / 1000;
> >
> > ID=window.setTimeout("update();", 1000);
> > function update() {
> > now = new Date();
> > seconds = (document.getElementById('ends').innerHTML-now)/1000;
> > seconds = Math.round(seconds);
> > document.getElementById('countdown').innerHTML = seconds;
> > ID=window.setTimeout("update();",1000);
> > }
> > </script>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Problem implementing countdown timer

Posted by Daniel Jue <te...@gmail.com>.
Daniel,

As an avid eBay user, I've been eagerly awaiting a feature like this!
Now everyone can be a sniper. =)
Now we just need some suspense music that streams in the background...

Dan

On 12/18/06, Leffel, Daniel <dl...@ebay.com> wrote:
> I have a really simple app that I'm trying to build. Shown on a page is
> an object that expires within 20-60 seconds. Once it expires, a new
> object is created with the same time to live (and so on and so on). The
> current object is loaded through a Tacos AjaxAutoInvoker. Additionally,
> I'm using the Tacos form submit on the page to enable users to
> manipulate the object.
>
> I'm trying to implement a countdown that shows in real time how many
> seconds are left until the object expires. I tried using another
> AjaxAutoInvoker without specifying a listener, but it makes an AJAX call
> anyway. I don't want to cause an AJAX call to happen every second to
> simply decrement the counter (the AjaxAutoInvoker otherwise refreshes
> the object every 5 seconds). So, I tried a little bit of Javascript. The
> problem is, this Javascript causes the AjaxForm to be submitted in a
> non-AJAX way (Debug message is: XMLHTTP Transport Error:0). Any ideas on
> the best way to accomplish this?
>
>
> <script LANGUAGE="JavaScript">
> var now = new Date();
> var seconds = (event - now) / 1000;
>
> ID=window.setTimeout("update();", 1000);
> function update() {
> now = new Date();
> seconds = (document.getElementById('ends').innerHTML-now)/1000;
> seconds = Math.round(seconds);
> document.getElementById('countdown').innerHTML = seconds;
> ID=window.setTimeout("update();",1000);
> }
> </script>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org