Source language: Translate to:

Countdown Timer

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Countdown Timer

Postby stevec » Fri Dec 05, 2014 12:41 pm

I am trying to come up with a simple countdown time that displays the remaining time.

For example. Starting at 5 minutes and counting down to zero.

Is there any examples out there of the code?
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho

Re: Countdown Timer

Postby dec » Fri Dec 05, 2014 1:03 pm

Hello stevec,

If you like, can take a look at my npHour plugin, which allow the "clocks" to be customized and act like countdown timers and provide the appropiate event/subroutine when the countdown is reached. Don't forget the "Countdown.pub" publication sample included by this plugin. ;)

Image
.
Enhance your NeoBook applications!
.
58 plugins, 1131 actions and 233 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: Countdown Timer

Postby stevec » Fri Dec 05, 2014 1:08 pm

I built a countdown timer years ago and can't find the code to it. :cry: :cry: :cry: :cry:
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho

Re: Countdown Timer

Postby dec » Fri Dec 05, 2014 1:10 pm

Hello,

stevec wrote:I built a countdown timer years ago and can't find the code to it. :cry: :cry: :cry: :cry:


Don't worry, probably other mate can help you! Start here for example!
.
Enhance your NeoBook applications!
.
58 plugins, 1131 actions and 233 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: Countdown Timer

Postby stevec » Fri Dec 05, 2014 2:54 pm

Thanks DEC.
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho

Re: Countdown Timer

Postby dec » Fri Dec 05, 2014 3:02 pm

Hello,

stevec wrote:Thanks DEC.


You're welcome stevec!
.
Enhance your NeoBook applications!
.
58 plugins, 1131 actions and 233 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: Countdown Timer

Postby stevec » Fri Dec 05, 2014 3:40 pm

I looked on your site and didn't see how to register the npHour. Almost done for the day will check later. Thanks
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho

Re: Countdown Timer

Postby dec » Fri Dec 05, 2014 3:59 pm

Hello,

stevec wrote:I looked on your site and didn't see how to register the npHour. Almost done for the day will check later. Thanks


First of all, try the plugin without time limit to be sure you found useful for your project. After that, without worries, visit the NeoPlugins Store and choose the plugin(s) you want to register. And, if you have any question, do not hesitate to contact me, for example, using this contact form, or just send me a PM on this forum, or write me an email, or post here or in any other post any question you have stevec.

Thanks for your interest! ;)
.
Enhance your NeoBook applications!
.
58 plugins, 1131 actions and 233 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: Countdown Timer

Postby fkapnist » Sat Dec 06, 2014 7:47 pm

Here is a simple JavaScript countdown you can put into a NeoBook WebBrowser object

Code: Select all
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>JavaScript 30 Seconds Countdown</title>
    <script language="javascript">
    var max_time = 30;
    var cinterval;
     
    function countdown_timer(){
    // decrease timer
    max_time--;
    document.getElementById('countdown').innerHTML = max_time;
    if(max_time == 0){
    clearInterval(cinterval);
    }
    }
    // 1,000 means 1 second.
    cinterval = setInterval('countdown_timer()', 1000);
    </script>
    </head>
    <body>
    <p>Download will start in <span id="countdown">30</span> seconds.</p>
    </body>
    </html>



Here is another JScript countdown timer that sets off a function (it sends you to the Neosoft home page). It can also trigger a NeoBook Action...

Code: Select all
<HEAD>
<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
var start=new Date();
   start=Date.parse(start)/1000;
   var counts=30;
   function CountDown(){
      var now=new Date();
      now=Date.parse(now)/1000;
      var x=parseInt(counts-(now-start),10);
      if(document.form1){document.form1.clock.value = x;}
      if(x>0){
         timerID=setTimeout("CountDown()", 30)
      }else{
         location.href="http://www.neosoftware.com/"
      }
   }
//  End -->
</script>
<SCRIPT LANGUAGE="JavaScript">
<!--
window.setTimeout('CountDown()',30);
-->
</script>

</HEAD>

<BODY>

</center>
<FORM NAME="form1">
You are being redirected to the NeoSoft Corp. Page in <INPUT TYPE="text" NAME="clock" SIZE="2" VALUE="10"> seconds.
</FORM>
</center>



Note:

If you copy the code directly from the Neobook forum post and pasted it into a HTML editor it has the wrong character set and it will look something like this:

& lt ;FORM NAME= & quot; form1 " ;& gt ;< br>
You are being redirected to the NeoSoft Corp. Page in & lt ; INPUT
TYPE =& quot;text & quot; NAME="clock" SIZE=& quot ;2& quot;
VALUE = & quot ;10"> ; seconds.<br
& lt; FORM & gt;


It will not execute as HTML. You must first paste it into Notepad (which automatically converts it to ANSI) then copy it out of notepad and into your HTML editor. It will look like this and it will work:


FORM NAME="form1">
You are being redirected to the NeoSoft Corp. Page in <INPUT TYPE="text" NAME="clock" SIZE="2" VALUE="10"> seconds.
</FORM


Below I have a link to a sample NeoBook PUB which demonstrated the countdown scripts.

http://www.verticalbrowser.com/zips/countdowndemo.zip

:arrow:
Last edited by fkapnist on Thu Dec 11, 2014 8:46 pm, edited 1 time in total.
User avatar
fkapnist
 
Posts: 348
Joined: Mon Nov 17, 2014 4:24 pm
Location: Greece

Re: Countdown Timer

Postby stevec » Tue Dec 09, 2014 7:43 am

Thanks for all the input.

Here is what I was able to do. This code was not mine, I did alter it.

******** Button properties***************

Math "[M1]*60" "0" "[T1]"
SetVar "[thisCount]" "[T1]"
GoSub "DisplayCountDown"
TimerStart "Timer1" "1000"

**********************Subroutine*************

:DisplayCountDown
Math "trunc([thisCount]/60)" "0" "[thisMinute]"
Math "[thisCount]-(60*[thisMinute])" "0" "[thisSecond]"
.my change below
If "[ThisCount2]" ">" "120"
SetObjectFont "TextEntry1" "Lime" "Kingthings Christmas 2" "150" "Normal" "ANSI_CHARSET"
SetObjectFont "TextEntry2" "Lime" "Kingthings Christmas 2" "150" "Normal" "ANSI_CHARSET"
Else
If "[ThisCount2]" "<" "121"
SetObjectFont "TextEntry1" "255,86,4" "Kingthings Christmas 2" "150" "Normal" "ANSI_CHARSET"
SetObjectFont "TextEntry2" "255,86,4" "Kingthings Christmas 2" "150" "Normal" "ANSI_CHARSET"
GotoLine "13"
If "[ThisCount2]" "<" "61"
SetObjectFont "TextEntry1" "Red" "Kingthings Christmas 2" "150" "Normal" "ANSI_CHARSET"
SetObjectFont "TextEntry2" "Red" "Kingthings Christmas 2" "150" "Normal" "ANSI_CHARSET"
Return

************************Timer Properties***********************
Math "[thisCount]-1" "0" "[thisCount]"
Math "([thisMinute]*60)+[thisSecond]" "0" "[ThisCount2]"
GoSub "DisplayCountDown"
If "[thisCount]" "=" "0"
TimerStop "Timer1"
EndIf

*******************************************************************

many thanks again. :D :D :D
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho

Re: Countdown Timer

Postby MiNeoBook » Tue Dec 09, 2014 11:21 am

Estoy atrasado???
ButtonCode
~~~~~~~~~~~~
setvar "[nHours]" "3"
setvar "[nMinutes]" "2"
setvar "[nSeconds]" "1"
math "[nHours]*3600+[nMinutes]*60+[nSeconds]" "" "[HMS]"
timerstart "HMS" "1000"
---------------------------------
TimerCode
~~~~~~~~~
math "[HMS]-1" "" "[HMS]"
math "trunc([HMS]/3600)" "" "[vHr]"
math "trunc(([HMS]-([vHr]*3600))/60)" "" "[vMi]"
math "([HMS]-([vMi]*60)-([vHr]*3600))/100" "2" "[vSc]"
math "[vHr]/100" "2" "[vHr]"
math "[vMi]/100" "2" "[vMi]"
substr "[vHr]" "3" "2" "[hh]"
substr "[vMi]" "3" "2" "[mm]"
substr "[vSc]" "3" "2" "[ss]"
if "[HMS]" "=" "0"
timerstop "HMS"
alertbox "ALERT" "READY"
endif
MiNeoBook
 
Posts: 7
Joined: Mon Dec 08, 2014 9:40 am

Re: Countdown Timer

Postby stevec » Tue Dec 09, 2014 5:36 pm

cool.
That is what is so amazing, is that there are multiple ways of doing things.
I had a grasp on 'subroutines' a while ago, but since I don't use it often enough, I lose it.

many thanks;
Steve Christensen
stevec
 
Posts: 223
Joined: Fri Apr 15, 2005 7:33 am
Location: Boise, Idaho


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 1 guest

cron