1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    28
    Vote Rating
    0
    Shariar Shaikot is on a distinguished road

      0  

    Default Answered: Issue with Ext.util.DelayedTask!

    Answered: Issue with Ext.util.DelayedTask!


    Hello,

    I tried to create a stopwatch with Sencha Touch 2.
    I tried several way , but could not make it work.

    After all I got Ext.util.DelayedTask ... but it was also not working.

    My contrller
    Code:
    
        
        Ext.define('MeetingCost.controller.Calculator', {
        extend: 'Ext.app.Controller',
        
        config: {
            refs: {
                calculator: 'calculator',
            },
            control: {
                 'button[id=start]': {
                        tap: 'tapStart',
                        
                    },
                    'button[text=Stop]': {
                        tap: 'tapStoper'
                    }
                }
                
            },
            
           tapStart: function()
           {
            
            var interval;
            
       clearInterval(interval);
            var sec = 0;
            var min = 0;
            var hour = 0;
      reDo = function ()
       {
        
       sec++;
       
      if (sec == 60) {
       sec = 0;
       min = min + 1; }
      else {
       min = min; }
      if (min == 60) {
       min = 0; 
       hour += 1; }
       if (sec<=9) { sec = "0" + sec; }
       var myhtml = ((hour<=9) ? "0"+hour : hour) + " : " + ((min<=9) ? "0" + min : min) + " : " + sec;
       
       
       
       Ext.getCmp('min').setHtml('<span>Time: '+myhtml+' </span><br/>');
       }
       
    
    
    
       /*start = function()
       {
        clearInterval(interval);
        if(!interval)
        {
        interval = setInterval(function() { reDo()}, 1000);   
       }
       }
       
        stop = function()
        {
            if(!interval)
            {
                Ext.Msg.alert('dot dot ....', 'ma ma msa');
            }
                clearInterval(interval);
                interval = null;
            
        }
        
        
        if(Ext.getCmp('start').getText() == 'Start')
        {
            start();
            Ext.getCmp('start').setText('Pause');
        }else{
            stop();
            Ext.getCmp('start').setText('Start');
        }
        */
    
    
    
    
        var task = Ext.create('Ext.util.DelayedTask', function() {
        reDo()
            });
            if(Ext.getCmp('start').getText() == 'Start')
        {
            task.delay(1000);
            
            Ext.getCmp('start').setText('Pause');
        }else{
            task.cancel();
            Ext.getCmp('start').setText('Start');
        }
           },
           tapStoper: function()
           {
            var indexPanel = Ext.create('MeetingCost.view.Stopwatch');
            Ext.getCmp('Viewport').setActiveItem(indexPanel, {
                reverse: false,
                type: 'slide',
                cover: false,
                duration: 500
            }); 
           } 
        
        });
    With this code I got nothing to work as clock. Just show 00:00:01!!!


    Please also provide me some examples of sencha stopwatch.
    My client is getting anger so I need to fix it very badly.

    Thanks in advance.

  2. Little example;

    Code:
    var run = function (delay) {
        Ext.create('Ext.util.DelayedTask', function () {
            console.log('run');
            run(delay);
        }).delay(delay);
    };
    
    run(1000);

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,801
    Answers
    3467
    Vote Rating
    834
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    DelayedTask will only fire once. You need to create a new DelayedTask each time the task fires off.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Dec 2011
    Posts
    28
    Vote Rating
    0
    Shariar Shaikot is on a distinguished road

      0  

    Default


    Really thanks and you are great.
    Can you please explain , how to fire Ext.util.DelayedTask after every 1 sec?

  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,801
    Answers
    3467
    Vote Rating
    834
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Little example;

    Code:
    var run = function (delay) {
        Ext.create('Ext.util.DelayedTask', function () {
            console.log('run');
            run(delay);
        }).delay(delay);
    };
    
    run(1000);
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  6. #5
    Sencha User
    Join Date
    Dec 2011
    Posts
    28
    Vote Rating
    0
    Shariar Shaikot is on a distinguished road

      0  

    Default


    Many thanks, it was working.
    But , how can I pause/cancel the interval?

    Please give me a idea.

    Thanks

  7. #6
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    23
    Answers
    1
    Vote Rating
    1
    byu_risk3 is on a distinguished road

      0  

    Default Stopwatch Solution

    Stopwatch Solution


    I don't know if you still need a solution, but look at the documentation for Ext.util.TaskManager (and also Ext.util.TaskRunner). There is code for a Stopwatch function.

    This might be what you are looking for.

    Here's a link - http://docs.sencha.com/ext-js/4-1/#!...il.TaskManager

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi