Jump to content

display the time in UniLabel (client side)


gerardocrisci

Recommended Posts

Add this code to Form.Onready

UniSession.AddJS('(function () { '+
  '  function checkTime(i) { '+
  '     return (i < 10) ? "0" + i : i; '+
  ' } '+
  ' function startTime() { '+
  '     var today = new Date(), '+
  '          h = checkTime(today.getHours()),  '+
  '         m = checkTime(today.getMinutes()),  '+
  '         s = checkTime(today.getSeconds());   '+
  '     document.getElementById('''+UniLabel1.JSName+'_id'').innerHTML = h + ":" + m + ":" + s; '+
  '      t = setTimeout(function () { '+
  '         startTime()   '+
  '     }, 500);  '+
  ' }      '+
  ' startTime();  '+
  '})();');
Link to comment
Share on other sites

thank you :)
 
UniLabel1.JSName+'_id'

It is a safe definition of the name unigui components to javascript?

 

but I used in

      ClientEvents.ExtEvents.Strings = (


                  function mouseout(sender, eOpts)
                  {
                    MainForm.UniLabel1.getEl().setStyle("font-weight","normal"); 
                  }
                  function mouseover(sender, eOpts)
                  {
                    MainForm.UniLabel1.getEl().setStyle("font-weight","bold"); 
                  }


        }

his name defined in the editor...  MainForm.UniLabel1.

Link to comment
Share on other sites

  • 1 year later...

Hi Hayri, is it possible to to use your function to put the time into a specific TUniStatusbar panel eg Panel[1]?

Using the above I can get the time onto the statusbar using the above (equivalent of setting statusbar.simpletext) but I can't see how display the value in a specific panel

 

 

Link to comment
Share on other sites

Hi,

Also you can use this approach too:

UniStatusBar1 -> ClientEvents -> ExtEvents -> function afterrender:

function afterrender(sender, eOpts)
{
    var runner = new Ext.util.TaskRunner(),
        clockPnl, updateClock;
        
    clockPnl = sender.items.getAt(0); //UniStatusBar1.Panels[0] for example
    
    updateClock = function() {
        clockPnl.setHtml(Ext.Date.format(new Date(), 'g:i:s A'));
    };

    sender._task = runner.start({
        run: updateClock,
        interval: 1000
    });
    
}

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...