Announcement

Collapse
No announcement yet.

show clock in header

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

  • show clock in header

    Hello:

    I was wondering if any of you guys know a way to display a clock in the header of a grid, i've tried with jscript unsucessfuly and i got blocked lol any ideas?.

    Regards

  • #2
    Originally posted by kafecadm View Post
    Hello:

    I was wondering if any of you guys know a way to display a clock in the header of a grid, i've tried with jscript unsucessfuly and i got blocked lol any ideas?.

    Regards
    What code you tried and how?
    /Giuseppe

    Professional Scriptcase Services
    Some Customers opinions

    Comment


    • #3
      I remember that MikeDE posted some code for that, should be searchable here on the forum.
      Albert Drent
      aducom software netherlands
      scriptcase partner, reseller, support and (turn-key) development
      www.scriptcase.eu / www.scriptcase.nl

      Comment


      • #4
        The following code was published here as a count down, but should be convertable for showing the current time. It's put in the header (layout->htmltemplates).

        Code:
        <script type = "text/javascript">
        /*author Philip M. 2010*/
        
        var timeInSecs;
        var ticker;
        
        function startTimer(secs)
        {
        	timeInSecs = parseInt(secs)-1;
        	ticker = setInterval("tick()",1000);   // every second
        }
        
        function tick()
        {
        	var secs = timeInSecs;
        	if (secs>0)
        	{
        		timeInSecs--;
        	}
        	else
        	{
        		clearInterval(ticker); // stop counting at zero
        		// startTimer(60);  // remove forward slashes in front of startTimer to repeat if required
        	}
        
        	document.getElementById("countdown").innerHTML = 'Next refresh in '+secs+' seconds!';
        }
        
        //startTimer(60);  // 60 seconds 
        
        </script>
        
        <style>
        	#lin1_col1 { padding-left:9px; padding-top:7px;  height:27px; overflow:hidden; text-align:left;}			 
        	#lin1_col2 { padding-right:9px; padding-top:7px; height:27px; text-align:right; overflow:hidden;   font-size:12px; font-weight:normal;}
        </style>
        
        <div style="width: 100%">
        	<div {NM_CSS_FUN_CAB} style="height:11px; display: block; border-width:0px; "></div>
        	<div style="height:37px; border-width:0px 0px 1px 0px;  border-style: dashed; border-color:#ddd; display: block">
        		<table style="width:100%; border-collapse:collapse; padding:0;">
        			<tr>
        				<td id="lin1_col1" {NM_CSS_CAB}><span id="countdown" style="font-weight: bold; color: red">Next refresh in 60 seconds</span></td>
        				<td id="lin1_col2" {NM_CSS_CAB}><span>{LIN1_COL2}</span></td>
        			</tr>
        		</table>		 
        	</div>
        </div>
        
        <script>startTimer(60);</script>
        Albert Drent
        aducom software netherlands
        scriptcase partner, reseller, support and (turn-key) development
        www.scriptcase.eu / www.scriptcase.nl

        Comment


        • #5
          Thank you so much guys, I've tried something similar my problem was on calling the js function... no mather what i get an error stating "undfined fuction"

          this is the code im using:

          onApplicationInit

          PHP Code:
          echo '
          <script type="text/javascript"> 

          function display_c(){
          var refresh=100; // Refresh rate in milli seconds
          mytime=setTimeout(\'display_ct()\',refresh)
          }

          function display_ct() {
          var strcount
          var x = new Date()
          document.getElementsByName(\'ct\').innerHTML = x;
          tt=display_c();
          }

          display_ct();
          </script>
          '


          then in the header I'm using something like

          <span name="ct"></span>

          so the html contect gets modified and updates the clock
          Last edited by kafecadm; 04-05-2015, 01:40 PM.

          Comment


          • #6
            ok guys I figured it out... in the onapplicationinit i created a global variable

            PHP Code:
            [g_Clock] = '<p id="demo"></p>

            <script>
            function clock(){
            var d = new Date();
            document.getElementById("demo").innerHTML = d.toString();
            }
            setInterval(clock,100);
            </script>
            '

            =D

            Comment


            • #7
              bingo ))))

              Comment


              • #8
                sempai
                after bingo, any indication how to change and play with the format? also it shows +5GMT.... i want to customize this along with addming some html colors stuff

                Comment

                Working...
                X