Jump to content

TrayClock (on the client side)


Recommended Posts

Let's add TrayClock to UniStatusBar (can be added to other controls).

image.png.3aa181507df732f0bde729dc339978e3.png

1. 

initialization
  UniAddCSSLibrary('build/packages/ux/classic/classic/resources/ux-all.css', False, [upoFolderJS, upoPlatformDesktop]);
  UniAddJSLibrary('build/packages/ux/classic/ux.js', False, [upoFolderJS, upoPlatformDesktop]);

2. UniStatusBar.ClientEvents.ExtEvents ->

function afterrender(sender, eOpts) 
{
    if (Ext.isDefined(Ext.ux)) {
        sender.add({
            xtype: 'tbfill'
        });
        sender.add(
            new Ext.ux.desktop.TrayClock()
        );
    }
}

 

Let's modify by adding a style, a time format, and an update time of one second.

image.png.a567e0b40407234b04b882ed7e072e61.png

(2).

function afterrender(sender, eOpts) 
{
    if (Ext.isDefined(Ext.ux)) {
        sender.add({
            xtype: 'tbfill'
        });
        sender.add(new Ext.ux.desktop.TrayClock({
            tpl: '<span style="color: green; font-weight: bold;">{time}</span>', //default = '{time}'
            timeFormat: 'Y-m-d H:i:s', //default = 'g:i A'

            updateTime: function() {
                var me = this,
                    time = Ext.Date.format(new Date(), me.timeFormat),
                    text = me.tpl.apply({
                        time: time
                    });

                if (me.lastText !== text) {
                    me.setText(text);
                    me.lastText = text;
                }

                me.timer = Ext.defer(me.updateTime, 1000, me);
            }
        }));
    }
}

 

  • Like 1
  • Happy 1
Link to comment
Share on other sites

It would be possible to create a timer on the client side, which would need a play and a stop, and still take this time on the server side. I once tried to do this on the client side and was unsuccessful.

Link to comment
Share on other sites

I would like when starting a registration to show a time counter, and when saving the registration, I can save this time, I did it using UniTimer, but it keeps talking to the server all the time

Link to comment
Share on other sites

I needed a clock that would show how many minutes the person has been in the register, but the timer should only update on the client side. When saving, I could stop the timer and get the time value.

Capturar.PNG

Link to comment
Share on other sites

On 4/5/2024 at 9:53 PM, picyka said:

I needed a clock that would show how many minutes the person has been in the register, but the timer should only update on the client side. When saving, I could stop the timer and get the time value.

Hello,

I will give you an example.

  • Like 1
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...