forked from pubnub/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
69 lines (65 loc) · 2.36 KB
/
Copy pathapp.js
File metadata and controls
69 lines (65 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
var pubnub = PUBNUB({
publish_key : 'demo',
subscribe_key : 'demo',
ssl : false,
origin : 'pubsub.pubnub.com'
});
Ext.application({
launch: function () {
var myStore = Ext.create('Ext.data.Store', {
storeId: 'list',
fields: ['txt']
}); // create()
Ext.create('Ext.List', {
fullscreen: true,
store: 'list',
itemTpl: '{txt}',
items: [{
xtype: 'titlebar',
docked: 'top',
items: [
{
xtype: 'textfield',
label: 'Channel',
name: 'channel',
id: 'channel',
align: 'left',
},
{
text: 'Subscribe',
align: 'left',
handler: function () {
var channel = Ext.getCmp('channel').getValue() || 'sencha-demo-channel';
myStore.removeAll();
pubnub.subscribe({
channel: channel,
callback: function(message){
myStore.insert(0,{txt : JSON.stringify(message)});
}
});
}
},
{
xtype: 'textfield',
label: 'Message',
name: 'message',
id: 'message',
align: 'right'
},
{
text: 'Publish',
align: 'right',
handler: function () {
var channel = Ext.getCmp('channel').getValue() || 'sencha-demo-channel';
var message = Ext.getCmp('message').getValue() || 'default-dummy-message';
pubnub.publish({
channel: channel,
message: message
});
}
}
]
}]
});
}
});