~cdparra/gelee/trunk

« back to all changes in this revision

Viewing changes to webui/ecosystem/workspace/extjs/docs/source/Direct.html (Case Conflict 1)

  • Committer: parra
  • Date: 2010-03-15 15:56:56 UTC
  • Revision ID: svn-v4:ac5bba68-f036-4e09-846e-8f32731cc928:trunk/gelee:1448
merged gelee at svn

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<html>
 
2
<head>
 
3
  <title>The source code</title>
 
4
    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
 
5
    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
 
6
</head>
 
7
<body  onload="prettyPrint();">
 
8
    <pre class="prettyprint lang-js">Ext.onReady(function(){
 
9
    Ext.Direct.addProvider(
 
10
        Ext.app.REMOTING_API,
 
11
        {
 
12
            type:'polling',
 
13
            url: 'php/poll.php'
 
14
        }
 
15
    );
 
16
 
 
17
    var out = new Ext.form.DisplayField({
 
18
        cls: 'x-form-text',
 
19
        id: 'out'
 
20
    });
 
21
 
 
22
    var text = new Ext.form.TextField({
 
23
        width: 300,
 
24
        emptyText: 'Echo input'
 
25
    });
 
26
 
 
27
    var call = new Ext.Button({
 
28
        text: 'Echo',
 
29
        handler: function(){
 
30
            TestAction.doEcho(text.getValue(), function(result, e){
 
31
                var t = e.getTransaction();
 
32
                out.append(String.format('<p><b>Successful call to {0}.{1} with response:</b><xmp>{2}</xmp></p>',
 
33
                       t.action, t.method, Ext.encode(result)));
 
34
                out.el.scroll('b', 100000, true);
 
35
            });
 
36
        }
 
37
    });
 
38
 
 
39
    var num = new Ext.form.TextField({
 
40
        width: 80,
 
41
        emptyText: 'Multiply x 8',
 
42
        style:  'text-align:left;'
 
43
    });
 
44
 
 
45
    var multiply = new Ext.Button({
 
46
        text: 'Multiply',
 
47
        handler: function(){
 
48
            TestAction.multiply(num.getValue(), function(result, e){
 
49
                var t = e.getTransaction();
 
50
                if(e.status){
 
51
                    out.append(String.format('<p><b>Successful call to {0}.{1} with response:</b><xmp>{2}</xmp></p>',
 
52
                        t.action, t.method, Ext.encode(result)));
 
53
                }else{
 
54
                    out.append(String.format('<p><b>Call to {0}.{1} failed with message:</b><xmp>{2}</xmp></p>',
 
55
                        t.action, t.method, e.message));
 
56
                }
 
57
                out.el.scroll('b', 100000, true);
 
58
            });
 
59
        }
 
60
    });
 
61
 
 
62
    text.on('specialkey', function(t, e){
 
63
        if(e.getKey() == e.ENTER){
 
64
            call.handler();
 
65
        }
 
66
    });
 
67
 
 
68
        num.on('specialkey', function(t, e){
 
69
        if(e.getKey() == e.ENTER){
 
70
            multiply.handler();
 
71
        }
 
72
    });
 
73
 
 
74
        var p = new Ext.Panel({
 
75
        title: 'Remote Call Log',
 
76
        //frame:true,
 
77
                width: 600,
 
78
                height: 300,
 
79
                layout:'fit',
 
80
                
 
81
                items: [out],
 
82
        bbar: [text, call, '-', num, multiply]
 
83
        }).render(Ext.getBody());
 
84
 
 
85
    Ext.Direct.on('message', function(e){
 
86
        out.append(String.format('<p><i>{0}</i></p>', e.data));
 
87
                out.el.scroll('b', 100000, true);
 
88
    });
 
89
});
 
90
</pre>    
 
91
</body>
 
92
</html>
 
 
b'\\ No newline at end of file'