Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Popup window timer in Javascript?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Popup window timer in Javascript?

    My brother runs a sign company in which he wants to track how much time is spent at each phase of constructing a sign.

    My thought was to create a dialog and fill in fields with barcode scanner and have each station hit a <start> button which would grab now() and also have a Modeless Popup with a large stopwatch come onscreen that each station would see. When finished, the station would hit a <stop> button on the original dialog which would again grab now() and close the Modeless Popup.

    I have figured out how to popup the dialog with just text from the <start> button, and then close the popup dialog from the <stop> button with the CloseLastOpenedA5Window() in the OnClick event.

    My question is how to get some type of minute:second counter javascript running in the popup starting at 0.

    Wasn't sure if I could open a popup Ajax window Javascript event and then paste in some code in the windows content set - local?

    Can I go to a site such as: http://www.hashemian.com/tools/javascript-countdown.htm and somehow paste the javascript code into Alpha somewhere/somehow? I tried pasting the code into the Javascript OnShow event, but didn't work. I realize this code can be modified to count up, which is what I will want.

    Saw lots of questions on the forum regarding timers, but nothing seemed to fit the bill for what I am doing.

    Maybe there is a better way.....it doesn't have to be a popup, it could stay on the dialog page.

    Thanks.....Andy

    #2
    Re: Popup window timer in Javascript?

    There's a couple of ways to go here... one, which I'm going to look at in a min is using jQuery 'cause I'll bet there's some really cool looking timers there.

    But, for now... here's some javascript I found - thanks to SLaks and Ganesh - that will do the trick.

    Open your dialog and just put one control on it - a label - and in the Field Label properties, under Label put this

    Code:
    <div id="box_header"></div>
    So, we've set up a Label, and given it a DIV name - so we can get to it.

    In the same Field Label section, under Style, change it to how you want your timer to look... size, font, etc.

    Code:
    font-family: OCR A Std; font-size: 36px; color: #000080;
    Next, add this function to the Javascript Functions, found under Code in the main navigation bar of the Dialog. This function will get called when the Dialog opens.

    Code:
     function get_elapsed_time_string(total_seconds) {
      function pretty_time_string(num) {
        return ( num < 10 ? "0" : "" ) + num;
      }
    
      var hours = Math.floor(total_seconds / 3600);
      total_seconds = total_seconds % 3600;
    
      var minutes = Math.floor(total_seconds / 60);
      total_seconds = total_seconds % 60;
    
      var seconds = Math.floor(total_seconds);
    
      // Pad the minutes and seconds with leading zeros, if required
      hours = pretty_time_string(hours);
      minutes = pretty_time_string(minutes);
      seconds = pretty_time_string(seconds);
    
      // Compose the string for display
      var currentTimeString = hours + ":" + minutes + ":" + seconds;
    
      return currentTimeString;
    }
    And finally, add this to the Dialog Events, Client-side event. This code runs when the Dialog is opened, and it fires off the function to get and format the time. It's using the JS setInterval method.

    Code:
    var elapsed_seconds = 0;
    setInterval(function() {
      elapsed_seconds = elapsed_seconds + 1;
      $('box_header').innerHTML = (get_elapsed_time_string(elapsed_seconds));
    }, 1000);
    Now I'm going to go find a really cool time in jQuery
    Last edited by Davidk; 01-31-2012, 07:38 PM.

    Comment


      #3
      Re: Popup window timer in Javascript?

      Worked exactly as I wanted...many thanks.

      Only wrinkle I am researching now is that when the dialog timer is opened again. It starts at zero, but flashes back to the prior timers numbers, which are continuing, i.e. multiple timers are running at the same time on the one single display.

      I have tried unchecking the "Use Cached Dialog" in the Open a Dialog Component javascript action to force a reload. That did not work. I was not 100% sure in what event the last section of code should be in, but I put it in the OnInitializeComplete Event. Not sure if that would have anything to do with the problem. I am assuming the function variables need to be reset, but not sure where and how.

      Thanks...

      Comment


        #4
        Re: Popup window timer in Javascript?

        Not sure how you're using it. Are the timers running in separate browser tabs? I opened an a5w page with the dialog time on it 3 times. Each opens in it's own tab and all are different times... all starting at 0.

        Yes... I see what you mean... it's a mess 'cause every time you open it, the prior instances are still running... yikes. Having a look. Too funny.
        Last edited by Davidk; 02-03-2012, 07:53 PM.

        Comment


          #5
          Re: Popup window timer in Javascript?

          I was hoping this would be simple and logical... and it was. We need to clear the timer. setInterval returns an ID for the timer. We'll use that ID with the clearInterval method to clear the timer.

          Event: onInitializeComplete

          Code:
          var elapsed_seconds = 0;
          var intID = setInterval(function(){
            elapsed_seconds = elapsed_seconds + 1;
            $('box_header').innerHTML = (get_elapsed_time_string(elapsed_seconds));
          }, 1000);
          window['setIndId']=intID;
          On the button that closes the timer
          Code:
          var intID = window['setIndId'];
          intID=clearInterval(intID);
          {dialog.Object}.closeContainerWindow(this);
          Last edited by Davidk; 02-03-2012, 08:55 PM.

          Comment


            #6
            Re: Popup window timer in Javascript?

            I could not get it to work. I am not enough of a javascript programmer to be of any help. I created a stop timer button on the popup window and pasted in the second window of code. The button appears to work and closes the window. I then made the onInitializeComplete modifications. When I hit the start time button on the dialog below the first time, the window pops up and everything works good. When I hit start timer on the dialog below it a second time, it pops up the timer window again with the second displaying where it stopped the first time, but they do not start counting.

            I was hoping for all buttons on the dialog window below the timer to start and close the timer window and reset the javascript variables. I was actually going to tie this in with an onBlur event because all entry will be done with a barcode scanner. I was hoping for no user required action with the actual timer window and am trying to stay away from any mouse movement requirements or keyboard entry.

            Comment


              #7
              Hi Guys, I am creating an app to monitor a rugby match, so time someone scores points, times someone was subbed to the bench etc. I need to do this through a timer/stop clock which is displayed on a page. Would you be able to help, or share your components in a zip file to me so i can see how yours works? Thanks :)

              Comment

              Working...
              X