Application.js
2.06 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
Ext.define('treps.controller.Application.Application', {
extend: 'Ext.app.Controller',
requires: [
'treps.controller.SAMP.SAMPManager'
],
views: ['Viewport'],
init: function() {
var me = this;
this.control({
'viewport': {
render: this.onInitApplication,
scope: me
},
'tool': {
click: this.onRequestHelp,
scope: me
}
});
this.application.on(
{
helppage: me.onChangeHelp,
scope: me
}
);
Ext.EventManager.onWindowUnload(
function() {
var sampManager = treps.controller.SAMP.SAMPManager;
sampManager.disconnect();
},
me
);
},
onInitApplication: function() {
//init samp manager
var sampManager = treps.controller.SAMP.SAMPManager;
sampManager.onReceiveFile = this.onReceiveSAMPFile;
sampManager.onConnect = this.onConnectSAMP;
sampManager.onDisconnect = this.onDisconnectSAMP;
sampManager.onClientsUpdate = this.onClientsUpdateSAMP;
treps.controller.SAMP.SAMPManager.initSAMP();
//fire an event to start a new operation when the viewport is ready
this.application.fireEvent('initapp');
},
onConnectSAMP: function()
{
treps.getApplication().fireEvent('samp_connect');
},
onDisconnectSAMP: function()
{
treps.getApplication().fireEvent('samp_disconnect');
},
onReceiveSAMPFile: function(client, file, format)
{
var re = /http:\/\/127.0.0.1:/;
if (!re.test(file))
treps.getApplication().fireEvent('receivesource','url',file);
else
treps.Messages.showError("Cannot receive file from a local application");
},
onClientsUpdateSAMP: function()
{
treps.getApplication().fireEvent('samp_clients');
},
onRequestHelp: function(tool, e, eOpts)
{
if (!tool.pageId)
return;
var helpController = treps.app.getController('Application.Help.Help');
helpController.setHelp(tool.pageId);
},
onChangeHelp: function(pageId)
{
var helpController = treps.app.getController('Application.Help.Help');
helpController.setHelp(pageId);
},
setVersion: function(kernelVersion)
{
Ext.fly('header-version').update("Kernel Version: "+kernelVersion);
}
});