source: trunk/web/addons/job_monarch/lib/extjs-30/examples/direct/direct.js @ 625

Last change on this file since 625 was 625, checked in by ramonb, 15 years ago

lib/extjs-30:

  • new ExtJS 3.0
File size: 2.5 KB
Line 
1/*!
2 * Ext JS Library 3.0.0
3 * Copyright(c) 2006-2009 Ext JS, LLC
4 * licensing@extjs.com
5 * http://www.extjs.com/license
6 */
7Ext.onReady(function(){
8    Ext.Direct.addProvider(
9        Ext.app.REMOTING_API,
10        {
11            type:'polling',
12            url: 'php/poll.php'
13        }
14    );
15
16    var out = new Ext.form.DisplayField({
17        cls: 'x-form-text',
18        id: 'out'
19    });
20
21    var text = new Ext.form.TextField({
22        width: 300,
23        emptyText: 'Echo input'
24    });
25
26    var call = new Ext.Button({
27        text: 'Echo',
28        handler: function(){
29            TestAction.doEcho(text.getValue(), function(result, e){
30                var t = e.getTransaction();
31                out.append(String.format('<p><b>Successful call to {0}.{1} with response:</b><xmp>{2}</xmp></p>',
32                       t.action, t.method, Ext.encode(result)));
33                out.el.scroll('b', 100000, true);
34            });
35        }
36    });
37
38    var num = new Ext.form.TextField({
39        width: 80,
40        emptyText: 'Multiply x 8',
41        style:  'text-align:left;'
42    });
43
44    var multiply = new Ext.Button({
45        text: 'Multiply',
46        handler: function(){
47            TestAction.multiply(num.getValue(), function(result, e){
48                var t = e.getTransaction();
49                if(e.status){
50                    out.append(String.format('<p><b>Successful call to {0}.{1} with response:</b><xmp>{2}</xmp></p>',
51                        t.action, t.method, Ext.encode(result)));
52                }else{
53                    out.append(String.format('<p><b>Call to {0}.{1} failed with message:</b><xmp>{2}</xmp></p>',
54                        t.action, t.method, e.message));
55                }
56                out.el.scroll('b', 100000, true);
57            });
58        }
59    });
60
61    text.on('specialkey', function(t, e){
62        if(e.getKey() == e.ENTER){
63            call.handler();
64        }
65    });
66
67        num.on('specialkey', function(t, e){
68        if(e.getKey() == e.ENTER){
69            multiply.handler();
70        }
71    });
72
73        var p = new Ext.Panel({
74        title: 'Remote Call Log',
75        //frame:true,
76                width: 600,
77                height: 300,
78                layout:'fit',
79               
80                items: [out],
81        bbar: [text, call, '-', num, multiply]
82        }).render(Ext.getBody());
83
84    Ext.Direct.on('message', function(e){
85        out.append(String.format('<p><i>{0}</i></p>', e.data));
86                out.el.scroll('b', 100000, true);
87    });
88});
Note: See TracBrowser for help on using the repository browser.