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

Countdown timer in a list control

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

    #16
    Re: Countdown timer in a list control

    Pete, that's an old comment that doesn't relate to the return value anymore. If you go back to the first post you will see the innerHTML where it's used.

    Comment


      #17
      Re: Countdown timer in a list control

      Hi

      Here is a sample UX i built with the technique i would use

      this should put us on the same page.

      this was built in build 6402
      Attached Files
      Alex Collier

      "The spread of computers and the Internet will put jobs in two categories. People who tell computers what to do, and people who are told by computers what to do"

      AA Builds from 5221_5152 to Pre-releases >> Deploying to IIS in AWS

      Comment


        #18
        Re: Countdown timer in a list control

        Here is the code for all without having to download component

        Within Javascript functions (though could put in timer event without the setInterval)
        Code:
        var x = setInterval(function() {
        
        	debugger;
        	var lObj = {dialog.object}.getControl('CHECKOUTCART');
        	
        if(lObj){
        	var data = lObj._data;
        	for(i=0; i < lObj._data.length;i++) {
        		//Get Date added to List Control
        			myDate = data[i].ItemDate
        			var one_hour = 60 * 60 * 1000; /* ms */
        			
        			var endTime = new Date(myDate.getTime() + one_hour) 	
        			endTime = (Date.parse(endTime) / 1000);
        
        			var now = new Date();
        			now = (Date.parse(now) / 1000);
        
        			var timeLeft = endTime - now;
        			var id = "Timer" + i
        			var idmsg = "TimerMsg" + i
        			if(timeLeft > 0){
        	
        				var days = Math.floor(timeLeft / 86400); 
        				var hours = Math.floor((timeLeft - (days * 86400)) / 3600);
        				var minutes = Math.floor((timeLeft - (days * 86400) - (hours * 3600 )) / 60);
        				var seconds = Math.floor((timeLeft - (days * 86400) - (hours * 3600) - (minutes * 60)));
        	  
        				if (hours < "10") { hours = "0" + hours; }
        				if (minutes < "10") { minutes = "0" + minutes; }
        				if (seconds < "10") { seconds = "0" + seconds; }
        		
        				// Display the result in the element		
        				document.getElementById(id).innerHTML = "Time left: " + hours + "h " + minutes + "m " + seconds + "s ";
        				
        				//Also shown additional Message
        				if(hours = 0){
        					document.getElementById(idmsg).innerHTML = "You have one hour left!";
        				}
        			} else {
        				//Note filter the list so the records dont show on next refresh
        				document.getElementById(id).innerHTML = "Item time has expired";
        			}
        	}
        }
          
        }, 1000);
        List Control
        Data - Static
        HTML Code:
        [
        {"ItemDate" : "27/01/2020 10:15:00 000 am", "RequiredDate" : "01/09/1994 12:00:00 000 am"},
        {"ItemDate" : "27/01/2020 10:00:00 000 am", "RequiredDate" : "16/09/1994 12:00:00 000 am"},
        {"ItemDate" : "27/01/2020 09:45:00 000 am", "RequiredDate" : "05/09/1994 12:00:00 000 am"},
        {"ItemDate" : "27/01/2020 07:00:00 000 am", "RequiredDate" : "05/09/1994 12:00:00 000 am"},
        {"ItemDate" : "27/01/2020 08:00:50 000 am", "RequiredDate" : "06/09/1994 12:00:00 000 am"},
        {"ItemDate" : "27/01/2020 07:00:00 000 am", "RequiredDate" : "24/08/1994 12:00:00 000 am"},
        {"ItemDate" : "27/01/2020 06:30:00 000 am", "RequiredDate" : "08/09/1994 12:00:00 000 am"},
        {"ItemDate" : "27/01/2020 05:00:00 000 am", "RequiredDate" : "09/09/1994 12:00:00 000 am"},
        {"ItemDate" : "27/01/2020 04:00:00 000 am", "RequiredDate" : "12/09/1994 12:00:00 000 am"},
        {"ItemDate" : "27/01/2020 03:00:00 000 am", "RequiredDate" : "13/09/1994 12:00:00 000 am"}
        ]
        Fields
        Set ItemDate (Item) Transform Data Type property to: ToDate

        List Layout : Freeform
        HTML Code:
        {@[scope].countDownTimer_resolve}
        Javascript
        Code:
        // Set the date we're counting down to
        var renderIndex = data["*renderIndex"]
        var idoftimer = "Timer" + renderIndex
        var idmsg = "TimerMsg" + renderIndex
        //set the inital timer and output result creating an unquie id so we can reference it to update the timer
         
        		//Get Date added to List Control
        			myDate = data.ItemDate
        			var one_hour = 60 * 60 * 1000; /* ms */
        			var endTime = new Date(myDate.getTime() + one_hour) 	
        			endTime = (Date.parse(endTime) / 1000);
        			var now = new Date();
        			now = (Date.parse(now) / 1000);
        			var timeLeft = endTime - now;
        
        			var days = Math.floor(timeLeft / 86400); 
        			var hours = Math.floor((timeLeft - (days * 86400)) / 3600);
        			var minutes = Math.floor((timeLeft - (days * 86400) - (hours * 3600 )) / 60);
        			var seconds = Math.floor((timeLeft - (days * 86400) - (hours * 3600) - (minutes * 60)));
          
        			if (hours < "10") { hours = "0" + hours; }
        			if (minutes < "10") { minutes = "0" + minutes; }
        			if (seconds < "10") { seconds = "0" + seconds; }
        
          // Display the result in the element with id="Timer[0..x]"
          return "<span id='" + idoftimer + "'> Time left: " + hours + "h " + minutes + "m " + seconds + "s </span><span id=" + idmsg + "></span>";
        Alex Collier

        "The spread of computers and the Internet will put jobs in two categories. People who tell computers what to do, and people who are told by computers what to do"

        AA Builds from 5221_5152 to Pre-releases >> Deploying to IIS in AWS

        Comment


          #19
          Re: Countdown timer in a list control

          That almost works, Alex. I think there was one thing misunderstood. The ItemDate is the date/time that the item was ADDED to the cart, not the time it expires. The countdown should count down 12 hours from the date/time the item was added to the cart. I think you have it counting down to the ItemDate.

          And what is the RequiredDate field for? I don't see where that comes into play.

          Comment


            #20
            Re: Countdown timer in a list control

            Got it. changed

            var one_hour = 60 * 60 * 1000; /* ms */
            to
            var one_hour = 43200001; /* ms */

            which adds the 12 hours to the ItemDate. And it works as intended. Whoohoo!!! Thank you!!

            Comment


              #21
              Re: Countdown timer in a list control

              Last question on this for now. Now to filter the list based on the expiration time.

              Filter where ItemDate is within 12 hours of now. In other words, when the time expires, it filters out so it doesn't show up. Would this be best as an SQL filter or a List filter?

              Comment


                #22
                Re: Countdown timer in a list control

                I would use sql filter as there is no need to have data of expired items being pulled down to client.
                Alex Collier

                "The spread of computers and the Internet will put jobs in two categories. People who tell computers what to do, and people who are told by computers what to do"

                AA Builds from 5221_5152 to Pre-releases >> Deploying to IIS in AWS

                Comment


                  #23
                  Re: Countdown timer in a list control

                  Originally posted by dfricke10 View Post
                  That almost works, Alex. I think there was one thing misunderstood. The ItemDate is the date/time that the item was ADDED to the cart, not the time it expires. The countdown should count down 12 hours from the date/time the item was added to the cart. I think you have it counting down to the ItemDate.

                  And what is the RequiredDate field for? I don't see where that comes into play.
                  RequiredDate was just some left over data when i converted the data source from northwinds db. Please ignore:)
                  Alex Collier

                  "The spread of computers and the Internet will put jobs in two categories. People who tell computers what to do, and people who are told by computers what to do"

                  AA Builds from 5221_5152 to Pre-releases >> Deploying to IIS in AWS

                  Comment


                    #24
                    Re: Countdown timer in a list control

                    Originally posted by dfricke10 View Post
                    Got it. changed

                    var one_hour = 60 * 60 * 1000; /* ms */
                    to
                    var one_hour = 43200001; /* ms */

                    which adds the 12 hours to the ItemDate. And it works as intended. Whoohoo!!! Thank you!!
                    Good stuff :) i would update the variable ref name to addTwelveHours so when you or someone else reads the code life is made easier.
                    Alex Collier

                    "The spread of computers and the Internet will put jobs in two categories. People who tell computers what to do, and people who are told by computers what to do"

                    AA Builds from 5221_5152 to Pre-releases >> Deploying to IIS in AWS

                    Comment


                      #25
                      Re: Countdown timer in a list control

                      Good idea, Alex. Thanks again.

                      I can't figure out the SQL filter. I may be overthinking this, but 'ItemDate <= ItemDate + 12 hours' would be the method. Can't get the 'ItemDate + 12 hours' thing right.

                      Comment


                        #26
                        Re: Countdown timer in a list control

                        Originally posted by dfricke10 View Post
                        Good idea, Alex. Thanks again.

                        I can't figure out the SQL filter. I may be overthinking this, but 'ItemDate <= ItemDate + 12 hours' would be the method. Can't get the 'ItemDate + 12 hours' thing right.
                        WHERE now() <= AddHoursToDateTime(ItemDate, 12)
                        Alex Collier

                        "The spread of computers and the Internet will put jobs in two categories. People who tell computers what to do, and people who are told by computers what to do"

                        AA Builds from 5221_5152 to Pre-releases >> Deploying to IIS in AWS

                        Comment


                          #27
                          Re: Countdown timer in a list control

                          I think my problem might be the date/time format. I'm finding that time("yyyy-MM-dd 0h:0m:0s",<value>) is the US value, and it appears you're in Australia.

                          My list throws a conversion error when adding the WHERE clause. I have to save the format time("dd/MM/yyy 0h:0m:0s am",<value>) in a character field. Can't get it to insert into a datetime field.

                          And, when I use the US datetime format, it enters fine into a datetime field, but it's 1 hour off. It starts at 11 hours instead of 12 on the countdown.

                          Make sense?

                          Comment


                            #28
                            Re: Countdown timer in a list control

                            Originally posted by alexc View Post
                            WHERE now() <= AddHoursToDateTime(ItemDate, 12)
                            This seems to work.

                            now() <= AddHoursToDateTime( convert(datetime, OrderItems.ItemDate, 103) , 12)

                            Comment

                            Working...
                            X