/adei/ui

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/ui

« back to all changes in this revision

Viewing changes to js/adei.js

  • Committer: Suren A. Chilingaryan
  • Date: 2008-04-02 10:23:22 UTC
  • Revision ID: csa@dside.dyndns.org-20080402102322-okib92sicg2dx3o3
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function ADEI(sidebar_id, menu_id, session_id) {
 
2
    this.config = new CONFIG;
 
3
    this.module = new MODULE(null, configSetupModule, this.config);
 
4
    this.popup = new POPUP(Geometry, null);
 
5
 
 
6
    this.updater = new UPDATER(this.config, this.module, this.popup);
 
7
 
 
8
    if (menu_id) this.menu = new MENU(this.config, this.updater, menu_id);
 
9
    else this.menu = null;
 
10
    
 
11
    this.source = null;
 
12
    this.source_interval = null;
 
13
    this.source_window = null;
 
14
    
 
15
    this.data_export = null;
 
16
    this.graph = null;
 
17
    
 
18
    this.options = null;
 
19
    
 
20
    this.cfg = new Object({
 
21
        'window_border': 10,
 
22
        'parse_delay': 100,
 
23
        'subsecond_threshold': 0,
 
24
        'zoom_ratio': 2,
 
25
        'query': null
 
26
    });
 
27
    
 
28
    if (typeof session_id == "undefined")
 
29
        this.adei_session = Math.floor(Math.random() * 4294967295);
 
30
    else
 
31
        this.adei_session = session_id;
 
32
 
 
33
    this.AddToQuery('adei_session=' + session_id);
 
34
    
 
35
    this.sidebar_node = document.getElementById(sidebar_id);
 
36
 
 
37
/*
 
38
    this.key = false;
 
39
    Ext.EventManager.addListener(document, "keyup", this.keyUp, this);
 
40
    Ext.EventManager.addListener(document, "keydown", this.keyDown, this);
 
41
    Ext.EventManager.addListener(document, "keypress", this.keyPress, this);    
 
42
*/
 
43
}
 
44
 
 
45
/*
 
46
ADEI.prototype.keyPress = function(ev) {
 
47
    ev.stopEvent();
 
48
}
 
49
 
 
50
ADEI.prototype.keyUp = function(ev) {
 
51
    this.key = false;
 
52
    ev.stopEvent();
 
53
}
 
54
 
 
55
ADEI.prototype.keyDown = function(ev) {
 
56
    this.key = ev.getKey();
 
57
    ev.stopEvent();
 
58
}
 
59
*/
 
60
 
 
61
ADEI.prototype.SetOptions = function(opts) {
 
62
    this.options = opts;
 
63
}
 
64
 
 
65
ADEI.prototype.SetProperty = function(name, val) {
 
66
    this.cfg[name] = val;
 
67
}
 
68
 
 
69
ADEI.prototype.AddToQuery = function(props) {
 
70
    if (this.cfg['query']) this.cfg['query'] += '&' + props;
 
71
    else this.cfg['query'] = props;
 
72
}
 
73
 
 
74
ADEI.prototype.RegisterModule = function(mod, mod_class) {
 
75
    this.module.Register(mod, mod_class);
 
76
}
 
77
 
 
78
ADEI.prototype.AttachSourceModule = function(source, ivl, wnd) {
 
79
    this.source = source;
 
80
    this.source_interval = ivl;
 
81
    this.source_window = wnd;
 
82
 
 
83
    source.AttachConfig(this.config);
 
84
    source.Init(this.updater, this.options);
 
85
 
 
86
    if (this.menu) this.menu.AttachWindow(wnd);
 
87
}
 
88
 
 
89
ADEI.prototype.AttachExportModule = function(data_export) {
 
90
    this.data_export = data_export;
 
91
 
 
92
    data_export.AttachConfig(this.config);    
 
93
    data_export.Init();
 
94
    
 
95
    if (this.menu) this.menu.AttachExporter(data_export);
 
96
}
 
97
 
 
98
ADEI.prototype.AttachGraphModule = function(graph) {
 
99
    this.graph = graph;
 
100
 
 
101
    graph.AttachConfig(this.config);    
 
102
    graph.AttachWindow(this.source_window);
 
103
    graph.AttachExporter(this.data_export);
 
104
}
 
105
 
 
106
ADEI.prototype.Start = function(mod, update_rate) {
 
107
    this.module.Open(mod);
 
108
    this.menu.Load();
 
109
    this.updater.Start(update_rate);
 
110
}
 
111
 
 
112
ADEI.prototype.OpenModule = function(mod) {
 
113
    this.module.Open(mod);
 
114
}
 
115
 
 
116
ADEI.prototype.SwitchPopup = function(mod) {
 
117
    this.popup.Switch(mod);
 
118
}
 
119
 
 
120
ADEI.prototype.UpdateModuleGeometry = function(mod, width, height) {
 
121
    var m = this.module.GetModule(mod);
 
122
    if ((m)&&(typeof m.AdjustGeometry != "undefined"))
 
123
        m.AdjustGeometry(width - this.sidebar_node.offsetWidth, height);
 
124
}
 
125
 
 
126
ADEI.prototype.GetURL = function(page, props) {
 
127
    if (this.cfg.query) {
 
128
        if (props) return page + "?" + this.cfg.query + "&" + props;
 
129
        return page + "?" + this.cfg.query;
 
130
    } else {
 
131
        if (props) return page + "?" + props;
 
132
        return page;
 
133
    }
 
134
}
 
135
 
 
136
ADEI.prototype.GetServiceURL = function(name, props) {
 
137
    return this.GetURL("services/" + name + ".php", props);
 
138
}
 
139
 
 
140
ADEI.prototype.GetService = function(name, props) {
 
141
    return this.GetServiceURL(name, props);
 
142
}
 
143