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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...