/dev/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/dev/trunk

« back to all changes in this revision

Viewing changes to js/export.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 EXPORT_CONFIG() {
 
2
    this.format = null;
 
3
    this.resample = null;
 
4
    this.mask = null;
 
5
    this.window = null;
 
6
}
 
7
 
 
8
function EXPORT(format_sel_id, resample_sel_id, mask_sel_id, window_sel_id) {
 
9
    this.cfg = new EXPORT_CONFIG();
 
10
 
 
11
    this.formatsel = new SELECT(format_sel_id, exportUpdateFormat, this);
 
12
    this.samplesel = new SELECT(resample_sel_id, exportUpdateSampling, this);
 
13
    this.masksel = new SELECT(mask_sel_id, exportUpdateMask, this);
 
14
    this.winsel = new SELECT(window_sel_id, exportUpdateWindow, this);
 
15
 
 
16
    this.config = null;
 
17
}
 
18
 
 
19
EXPORT.prototype.AttachConfig = function(config) {
 
20
    this.config = config;
 
21
    config.Register(this);
 
22
}
 
23
 
 
24
EXPORT.prototype.Init = function(opts) {
 
25
    if (typeof opts == "undefined") opts = new Object;
 
26
 
 
27
    opts.reload = true;
 
28
    opts.confirm = true;
 
29
 
 
30
    this.Update(opts);
 
31
}
 
32
 
 
33
EXPORT.prototype.Export = function(embedded_mode, window_type) {
 
34
 
 
35
    var opts = "format=" + this.cfg.format + "&resample=" + this.cfg.resample + "&mask_mode=" + this.cfg.mask;
 
36
    if (typeof window_type != "undefined") {
 
37
        opts += "&" + this.config.GetProps(window_type);
 
38
    } else if (embedded_mode) {
 
39
        opts += "&" + this.config.GetProps(-1);
 
40
    } else {
 
41
        opts += "&" + this.config.GetProps(this.cfg.window);
 
42
    }
 
43
 
 
44
    document.location = adei.GetServiceURL("getdata", opts);
 
45
}
 
46
 
 
47
EXPORT.prototype.SetFormat = function(val) {
 
48
    this.Update(new Object({ 'format': val, 'apply': true}));
 
49
}
 
50
 
 
51
EXPORT.prototype.SetSampling = function(val) {
 
52
    this.Update(new Object({ 'export_sampling': val, 'apply': true}));
 
53
}
 
54
 
 
55
EXPORT.prototype.SetMask = function(val) {
 
56
    this.Update(new Object({ 'export_mask': val, 'apply': true}));
 
57
}
 
58
 
 
59
EXPORT.prototype.ReadConfig = function(opts) {
 
60
    if (this.config) {
 
61
        var opts = new Object({'apply': true});
 
62
        if (this.config.cfg_extra.format) 
 
63
            opts.format = this.config.cfg_extra.format;
 
64
 
 
65
        if (this.config.cfg_extra.resample) 
 
66
            opts.export_sampling = this.config.cfg_extra.resample;
 
67
 
 
68
        if (this.config.cfg_extra.mask_mode) 
 
69
            opts.export_mask = this.config.cfg_extra.mask_mode;
 
70
        
 
71
        this.Update(opts);
 
72
    }
 
73
}
 
74
 
 
75
 
 
76
EXPORT.prototype.Update = function(opts) {
 
77
    if (opts) {
 
78
        if (opts.reload) {
 
79
            this.formatsel.Update(adei.GetService("format"), opts, opts?opts.format:null);
 
80
            this.samplesel.Update(adei.GetService("export_sampling"), opts, opts?opts.export_sampling:null);
 
81
            this.masksel.Update(adei.GetService("export_mask"), opts, opts?opts.export_mask:null);
 
82
            this.winsel.Update(adei.GetService("export_window"), opts, opts?opts.export_window:null);
 
83
        } else {
 
84
            if (opts.format) {
 
85
                this.UpdateFormat(opts.format, opts);
 
86
                if (this.formatsel.GetValue() != opts.format)
 
87
                    this.formatsel.SetValue(opts.format);
 
88
            }
 
89
            if (opts.export_sampling) {
 
90
                this.UpdateSampling(opts.export_sampling, opts);
 
91
                if (this.samplesel.GetValue() != opts.export_sampling)
 
92
                    this.samplesel.SetValue(opts.export_sampling);
 
93
            }
 
94
            if (opts.export_mask) {
 
95
                this.UpdateMask(opts.export_mask, opts);
 
96
                if (this.masksel.GetValue() != opts.export_mask)
 
97
                    this.masksel.SetValue(opts.export_mask);
 
98
            }
 
99
            if (opts.export_window) {
 
100
                this.UpdateWindow(opts.export_window, opts);
 
101
                if (this.winsel.GetValue() != opts.export_window)
 
102
                    this.winsel.SetValue(opts.export_window);
 
103
            }
 
104
        }
 
105
    }
 
106
}
 
107
 
 
108
EXPORT.prototype.UpdateFormat = function(val, opts) {
 
109
    this.cfg.format = val;
 
110
 
 
111
    if ((typeof opts == "undefined")||(opts.apply))
 
112
        this.Apply(val, null, null);
 
113
}
 
114
 
 
115
EXPORT.prototype.UpdateSampling = function(val, opts) {
 
116
    this.cfg.resample = val;
 
117
 
 
118
    if ((typeof opts == "undefined")||(opts.apply))
 
119
        this.Apply(null, val, null);
 
120
}
 
121
 
 
122
EXPORT.prototype.UpdateMask = function(val, opts) {
 
123
    this.cfg.mask = val;
 
124
 
 
125
    if ((typeof opts == "undefined")||(opts.apply))
 
126
        this.Apply(null, null, val);
 
127
}
 
128
 
 
129
EXPORT.prototype.UpdateWindow = function(val, opts) {
 
130
    this.cfg.window = val;
 
131
}
 
132
 
 
133
EXPORT.prototype.Apply = function(format, sampling, mask) {
 
134
    if ((format)||(sampling)||(mask))
 
135
        this.config.SetExportSettings(format, sampling, mask);
 
136
    else
 
137
        this.config.SetExportSettings(this.cfg.format, this.cfg.resample, this.cfg.mask);
 
138
    
 
139
    this.config.ReplaceURL();
 
140
}
 
141
 
 
142
 
 
143
EXPORT.prototype.GetTooltip = function() {
 
144
    var res = this.formatsel.GetTitle();
 
145
 
 
146
    if ((this.cfg.resample)&&(this.cfg.resample != "0")) {
 
147
        res += ", " + translate("Resampling %s", this.samplesel.GetTitle());
 
148
    }
 
149
    if ((this.cfg.mask)&&(this.cfg.mask != "0")) {
 
150
        res += ", " + translate("MultiMask");
 
151
    }
 
152
    
 
153
    return res;
 
154
}
 
155
 
 
156
function exportUpdateFormat(self, val, opts) {
 
157
    return self.UpdateFormat(val, opts);
 
158
}
 
159
 
 
160
function exportUpdateSampling(self, val, opts) {
 
161
    return self.UpdateSampling(val, opts);
 
162
}
 
163
 
 
164
function exportUpdateMask(self, val, opts) {
 
165
    return self.UpdateMask(val, opts);
 
166
}
 
167
 
 
168
function exportUpdateWindow(self, val, opts) {
 
169
    return self.UpdateWindow(val, opts);
 
170
}
 
171