tvheadend/vendor/ext-3.4.1/examples/direct/direct.js
Adam Sutton bafcfff42d webui: restructure webui/extjs source files
I want to keep the 3rd-party packages away from the main source
where possible.
2013-06-03 17:11:01 +01:00

102 lines
2.9 KiB
JavaScript

/*
This file is part of Ext JS 3.4
Copyright (c) 2011-2013 Sencha Inc
Contact: http://www.sencha.com/contact
GNU General Public License Usage
This file may be used under the terms of the GNU General Public License version 3.0 as
published by the Free Software Foundation and appearing in the file LICENSE included in the
packaging of this file.
Please review the following information to ensure the GNU General Public License version 3.0
requirements will be met: http://www.gnu.org/copyleft/gpl.html.
If you are unsure which license is appropriate for your use, please contact the sales department
at http://www.sencha.com/contact.
Build date: 2013-04-03 15:07:25
*/
Ext.onReady(function(){
Ext.Direct.addProvider(
Ext.app.REMOTING_API,
{
type:'polling',
url: 'php/poll.php'
}
);
var out = new Ext.form.DisplayField({
cls: 'x-form-text',
id: 'out'
});
var text = new Ext.form.TextField({
width: 300,
emptyText: 'Echo input'
});
var call = new Ext.Button({
text: 'Echo',
handler: function(){
TestAction.doEcho(text.getValue(), function(result, e){
var t = e.getTransaction();
out.append(String.format('<p><b>Successful call to {0}.{1} with response:</b><xmp>{2}</xmp></p>',
t.action, t.method, Ext.encode(result)));
out.el.scroll('b', 100000, true);
});
}
});
var num = new Ext.form.TextField({
width: 80,
emptyText: 'Multiply x 8',
style: 'text-align:left;'
});
var multiply = new Ext.Button({
text: 'Multiply',
handler: function(){
TestAction.multiply(num.getValue(), function(result, e){
var t = e.getTransaction();
if(e.status){
out.append(String.format('<p><b>Successful call to {0}.{1} with response:</b><xmp>{2}</xmp></p>',
t.action, t.method, Ext.encode(result)));
}else{
out.append(String.format('<p><b>Call to {0}.{1} failed with message:</b><xmp>{2}</xmp></p>',
t.action, t.method, e.message));
}
out.el.scroll('b', 100000, true);
});
}
});
text.on('specialkey', function(t, e){
if(e.getKey() == e.ENTER){
call.handler();
}
});
num.on('specialkey', function(t, e){
if(e.getKey() == e.ENTER){
multiply.handler();
}
});
var p = new Ext.Panel({
title: 'Remote Call Log',
//frame:true,
width: 600,
height: 300,
layout:'fit',
items: [out],
bbar: [text, call, '-', num, multiply]
}).render(Ext.getBody());
Ext.Direct.on('message', function(e){
out.append(String.format('<p><i>{0}</i></p>', e.data));
out.el.scroll('b', 100000, true);
});
});