1
function GRAPHCONTROL(showid,showcontrolsdiv,imgdiv,windowref,graphimg,emaildiv,sensordiv){
2
this.showhidebutton = document.getElementById(showcontrolsdiv);
3
this.controls = document.getElementById(showid);
4
this.imgdiv = document.getElementById(imgdiv);
5
this.graphimg = document.getElementById(graphimg);
6
this.emaildiv = document.getElementById(emaildiv);
7
this.sensordiv = document.getElementById(sensordiv);
11
Event.observe(this.showhidebutton,'click', this.showhide.bindAsEventListener(this));
12
Event.observe(this.controls, 'click', this.showhide.bindAsEventListener(this));
14
GRAPHCONTROL.prototype.showhide = function(ev){
16
this.controls.style.visibility = 'visible';
19
this.controls.style.visibility = 'hidden';
22
this.StopPropagation(ev);
24
GRAPHCONTROL.prototype.StopPropagation = function(ev){
25
if (!ev) var ev = window.event;
26
if (ev)if (ev.cancelBubble)ev.cancelBubble = true;
27
if (ev)if (ev.stopPropagation) ev.stopPropagation();
30
GRAPHCONTROL.prototype.sendEmail = function(){
32
var props = "url="+ window.location;
33
props += "&from="+ document.getElementById('from').value;
34
props += "&to="+document.getElementById('tomail').value;
35
props += "&message="+document.getElementById('message').value;
36
props += "&attachement=" + this.path;
37
props += "&task=Send";
38
props = props.replace('#','&');
40
adei.GetServiceURL('email',props),
43
onSuccess: this.MailSent(this),
44
onFailure: this.MailFail(this)
48
alert("FAILED : "+ err);
53
GRAPHCONTROL.prototype.MailSent = function(graphcontrol) {
54
return function(transport) {
55
if (!transport && !transport.responseText) alert("Unexpected content received");
56
else alert("Success : " + transport.responseText);
60
GRAPHCONTROL.prototype.MailFail = function(graphcontrol) {
61
return function(transport) {
62
alert("No data was returned by the service");
66
GRAPHCONTROL.prototype.openMailForm = function() {
67
var serviceurl = adei.GetService('email');
68
this.emaildiv.style.visibility = 'visible';
69
adei.UpdateDIV('emailform',serviceurl,'email');
72
GRAPHCONTROL.prototype.closediv = function(type) {
73
if (type=='imgdiv')this.imgdiv.style.visibility = 'hidden';
74
if (type=='emailform')this.emaildiv.style.visibility = 'hidden';
75
if (type=='sensordiv')this.sensordiv.style.visibility = 'hidden';
76
this.StopPropagation();
79
GRAPHCONTROL.prototype.getSensors = function(){
81
var serviceurl = adei.GetService('email');
82
serviceurl += "&"+adei.config.GetProps();
83
serviceurl += "&task=getSensorList";
84
this.sensordiv.style.visibility = 'visible';
85
adei.UpdateDIV('sensorlist',serviceurl,'sensorlist',true);
89
GRAPHCONTROL.prototype.loadImage = function(){
90
var props = adei.config.GetProps();
91
props += "&width=1024&height=640&task=genpic";
94
adei.GetServiceURL('email',props),
97
onSuccess: this.getFilePath(this),
98
onFailure: this.failed(this)
103
alert("Request Failed : "+ err);
107
GRAPHCONTROL.prototype.failed = function(graphcontrol) {
108
return function(transport) {
109
alert("Request returned onFailure : " + transport.responseText);
112
GRAPHCONTROL.prototype.getFilePath = function(self) {
113
return function(transport) {
114
if (!transport && !transport.responseText) alert("Request returned no content");
116
if (transport.responseText=='FAIL') alert("Creating temporary folder for image failed");
117
else self.path = transport.responseText;
122
GRAPHCONTROL.prototype.genIMG = function(ev) {
123
this.StopPropagation();
127
GRAPHCONTROL.prototype.UseWindow = function(prop) {
130
this.win.window.CenterZoomIn();
132
case "centerzoomout":
133
this.win.window.CenterZoomOut();
136
this.win.window.MoveRight();
139
this.win.window.MoveLeft();
142
this.win.window.MoveUp();
145
this.win.window.MoveDown();
148
this.StopPropagation();