1
function UPDATER(config, module, popup) {
13
this.control = new Array();
15
config.RegisterUpdater(this);
18
UPDATER.prototype.RegisterControl = function (control) {
19
this.control.push(control);
22
UPDATER.prototype.Start = function(rate) {
23
this.popup.RegisterReWidthCallback(updaterUpdate, this);
25
this.rate = rate * 1000;
31
UPDATER.prototype.Stop = function() {
35
UPDATER.prototype.Run = function () {
37
this.tm = setTimeout(function(param) { return function() { param.Run(); } } (this), this.rate);
48
UPDATER.prototype.Update = function () {
50
clearTimeout(this.tm);
57
UPDATER.prototype.Notify = function(notifier, mod) {
58
if (typeof mod != "undefined") {
60
var m = this.module.GetModule(mod);
62
var m = this.module.GetOpenModule(mod);
65
eval("if (m.Notify" + notifier + ") m.Notify" + notifier + "();");
68
for (var i = 0; i < this.module.names.length; i++) {
69
this.Notify(notifier, this.module.names[i]);
74
function updaterRequest(updater) {
75
return function(transport) {
76
if ((!transport)||(!transport.responseText)) {
77
adeiReportError("Strange internal error. No data returned by ADEI service");
78
} else if (transport.responseText.charAt(0) == '{') {
79
var json = transport.responseText.evalJSON(false);
83
if (typeof json.module == "undefined") {
84
// Everything Ok, just nothing to update
85
// alert('strange: ' + transport.responseText);
87
var module = updater.module.GetModule(json.module);
88
if ((module)&&(typeof module.Update != "undefined")) {
89
module.Update(json, updater.forced);
90
updater.forced = false;
95
alert("Unexpected content: '" + transport.responseText + "'");
98
updater.updating = false;
102
UPDATER.prototype.Request = function() {
104
if (this.updating) return; /* DS: Schedule, if forced? */
105
else this.updating = true;
107
new Ajax.Request(adei.GetServiceURL("update"),
110
requestHeaders: {Accept: 'application/json'},
111
parameters: { props: this.config.GetJSON() },
112
onSuccess: updaterRequest(this),
113
onFailure: function() {
114
this.updating = false;
115
alert('Update is failed');
120
UPDATER.prototype.Iteration = function() {
121
var current_module = this.module.GetOpenModule();
124
// alert(current_module);
125
if (current_module) {
126
if (typeof current_module.Prepare != "undefined")
127
current_module.Prepare();
129
if (typeof current_module.Request == "undefined")
130
return this.Request();
132
return current_module.Request();
139
function updaterUpdate(updater) {
140
return updater.Update();