1
function WINDOW_CONFIG() {
11
function WINDOW(win_sel_id, start_id, end_id, ymin_id, ymax_id) {
12
this.cfg = new WINDOW_CONFIG;
14
this.source_winsel = new SELECT(win_sel_id, windowUpdateWidth, this);
16
this.sin = document.getElementById(start_id);
17
if (!this.sin) alert("Custom window start time input field (\"" + start_id + "\") is not found");
18
this.ein = document.getElementById(end_id);
19
if (!this.ein) alert("Custom window end time input field (\"" + end_id + "\") is not found");
20
this.minin = document.getElementById(ymin_id);
21
if (!this.minin) alert("Custom window ymin input field (\"" + ymin_id + "\") is not found");
22
this.maxin = document.getElementById(ymax_id);
23
if (!this.maxin) alert("Custom window ymax input field (\"" + ymax_id + "\") is not found");
27
WINDOW.prototype.SetSource = function(src) {
31
WINDOW.prototype.SetInterval = function(interval) {
36
WINDOW.prototype.SetConfig = function(config) {
40
WINDOW.prototype.SetUpdater = function(updater) {
41
this.updater = updater;
45
WINDOW.prototype.RegisterGraph = function(graph) {
46
// DS. Provide support for multiple attached graphs
49
if (!graph.window) graph.AttachWindow(this);
53
WINDOW.prototype.Update = function(props, opts) {
56
this.source_winsel.Update(adei.GetService("timewindow", props), opts, opts?opts.window_width:null);
57
} else if ((opts.window_width)||(opts.reset)) {
58
if (!opts.window_width) opts.window_width = this.source_winsel.GetValue(0);
60
this.UpdateWidth(opts.window_width, opts);
62
if ((opts.window_width)&&(this.source_winsel.GetValue() != opts.window_width))
63
this.source_winsel.SetValue(opts.window_width);
64
} else if (opt.confirm) {
65
this.config.Confirm(this);
70
WINDOW.prototype.UpdateWidth = function (value, opts) {
71
var reset_custom = true;
73
if ((opts)&&(opts.window == "auto")) {
74
this.SetCustomWindow(0,0,0,0);
78
if (((opts)&&(opts.reload))||(this.cfg.width != value)) {
84
if (this.cfg.width >= 0) {
85
if ((reset_custom)&&((!opts)||(!opts.keep_custom))) {
88
this.minin.value = '';
89
this.maxin.value = '';
92
cssShowClass('.hide_window_custom');
94
if (!this.module_on_display) this.fix_hidden = true;
97
if (typeof this.geometry_cb == "function") {
98
this.geometry_cb(this.geometry_cbattr);
102
if (this.cfg.width < 0) {
103
cssHideClass('.hide_window_custom');
105
if (!this.module_on_display) this.fix_hidden = true;
109
if (this.cfg.width != value) show = true;
112
this.cfg.width = value;
114
if ((opts)&&(opts.confirm)) {
115
this.config.Confirm(this);
119
if ((typeof opts == "undefined")||((opts)&&(opts.apply))) this.Apply();
121
} else if ((opts)&&(opts.confirm)) {
122
this.config.Confirm(this);
127
WINDOW.prototype.UpdateRange = function() {
133
WINDOW.prototype.ApplyConfig = function(subcall) {
138
var width = this.cfg.width;
141
var tmp = this.sin.value;
142
if (tmp) sin = adeiDateParse(tmp);
145
tmp = this.ein.value;
146
if (tmp) ein = adeiDateParse(tmp);
149
tmp = this.minin.value;
150
if (tmp) minin = tmp;
153
tmp = this.maxin.value;
154
if (tmp) maxin = tmp;
158
minin = 0; maxin = 0;
161
this.config.SetWindow(width, sin, ein, minin, maxin);
163
if (typeof subcall == "undefined") {
169
if (this.graph) this.graph.Clear();
172
WINDOW.prototype.ReadConfig = function(opts) {
173
opts.window = "auto";
174
opts.window_width = this.config.win_width;
175
// this.SetCustomWindow(0,0,0,0);
178
WINDOW.prototype.Apply = function() {
180
if (this.updater) this.updater.Update();
184
WINDOW.prototype.ResetY = function() {
185
this.config.win_min = 0;
186
this.config.win_max = 0;
188
this.SetCustomWindow(0,0,0,0);
192
WINDOW.prototype.SetCustomWindow = function (from, to, miny, maxy) {
193
if ((from)||(to)||(miny)||(maxy)) {
195
this.config.SetSelection(from, to);
197
this.sin.value = adeiDateFormat(from, adeiMathPreciseSubstract(to, from));
198
this.ein.value = adeiDateFormat(to, adeiMathPreciseSubstract(to, from));
201
this.config.SetSelection();
203
if ((this.config.win_from)&&(this.config.win_to)&&(this.config.win_from!=this.config.win_to)) {
204
this.sin.value = adeiDateFormat(this.config.win_from, this.config.win_to - this.config.win_from);
205
this.ein.value = adeiDateFormat(this.config.win_to, this.config.win_to - this.config.win_from);
206
} else /*if (this.cfg.width >= 0)*/ {
207
this.sin.value = adeiDateFormat(this.graph.xmin, this.graph.xmax - this.graph.xmin);
208
this.ein.value = adeiDateFormat(this.graph.xmax, this.graph.xmax - this.graph.xmin);
215
if ((miny)||(maxy)) {
216
this.minin.value = miny;
217
this.maxin.value = maxy;
219
if (/*(this.config.win_min)&&(this.config.win_max)&&*/(this.config.win_min!=this.config.win_max)) {
220
this.minin.value = this.config.win_min;
221
this.maxin.value = this.config.win_max;
223
this.minin.value = '';
224
this.maxin.value = '';
228
this.UpdateWidth(-1, new Object({keep_custom: true}));
229
this.source_winsel.SetValue(-1);
231
if (!this.config) return;
233
this.config.SetSelection();
235
if (this.config.win_width<0) {
236
if ((this.config.win_from)&&(this.config.win_to)&&(this.config.win_from!=this.config.win_to)) {
237
this.sin.value = adeiDateFormat(this.config.win_from, this.config.win_to - this.config.win_from);
238
this.ein.value = adeiDateFormat(this.config.win_to, this.config.win_to - this.config.win_from);
244
if (/*(this.config.win_min)&&(this.config.win_max)&&*/(this.config.win_min!=this.config.win_max)) {
245
this.minin.value = this.config.win_min;
246
this.maxin.value = this.config.win_max;
248
this.minin.value = '';
249
this.maxin.value = '';
254
this.minin.value = '';
255
this.maxin.value = '';
257
this.UpdateWidth(this.config.win_width, new Object({keep_custom: true}));
258
this.source_winsel.SetValue(this.config.win_width);
263
WINDOW.prototype.Lock = function() {
264
if ((this.graph)&&(this.cfg.width >= 0)) {
265
var xmin = this.graph.xmin;
266
var xmax = this.graph.xmax;
267
if ((xmin)&&(xmax)) {
268
this.SetCustomWindow(xmin, xmax, 0, 0);
274
WINDOW.prototype.ZoomIn = function(x,y) {
275
var width = this.config.win_width;
277
var sel = this.source_winsel;
278
var len = sel.GetLastIndex();
279
var i = sel.GetIndex(width);
281
var current = this.graph.xsize;
283
var val = sel.GetValue(++i);
284
if (current > val) break;
289
this.cfg.width = sel.GetValue();
296
var new_size = this.graph.xsize / adei.cfg.zoom_ratio;
297
var diff = adeiMathPreciseSubstract(this.graph.xsize, new_size) / 2;
299
var from = adeiMathPreciseAdd(this.graph.xmin, diff);
300
var to = adeiMathPreciseSubstract(this.graph.xmax, diff);
302
this.SetCustomWindow(from, to, 0, 0);
306
WINDOW.prototype.ZoomOut = function(x,y) {
307
var width = this.config.win_width;
310
var new_size = this.graph.xsize * adei.cfg.zoom_ratio;
311
var diff = adeiMathPreciseSubstract(new_size, this.graph.xsize) / 2;
314
var diff = (adei.cfg.zoom_ratio - 1) * this.graph.xsize / 2;
316
var from = adeiMathPreciseSubstract(this.graph.xmin, diff);
317
// alert(this.graph.xsize + " = " + diff);
318
// alert(this.graph.xmin + "," + diff + "=" + from);
319
var to = adeiMathPreciseAdd(this.graph.xmax, diff);
321
this.SetCustomWindow(from, to, 0, 0);
323
} else if (width > 0) {
324
var sel = this.source_winsel;
325
var i = sel.GetIndex(width);
328
this.cfg.width = sel.GetValue();
336
WINDOW.prototype.RegisterGeometryCallback = function(cb, cbattr) {
337
this.geometry_cb = cb;
338
this.geometry_cbattr = cbattr;
341
WINDOW.prototype.FixHidden = function() {
342
if ((this.fix_hidden)&&(this.module_on_display)) {
343
if (this.cfg.width<0) {
344
cssHideClass('.hide_window_custom');
345
cssShowClass('.hide_window_custom');
347
cssShowClass('.hide_window_custom');
348
cssHideClass('.hide_window_custom');
350
this.fix_hidden = false;
354
function windowUpdateWidth(window, value, opts) {
355
window.UpdateWidth(value, opts);
358
function windowUpdateRange(window) {
359
window.UpdateRange();
362
function windowUpdateRangeFunction(window) {
363
return function() { window.UpdateRange(); }