<script language="Javascript" type="text/javascript">
ajax_controller = Class.create();
ajax_controller.prototype = {
initialize : function(url, target, name, parameters) {
this.url = url;
this.target = target;
this.method = 'post';
this.name = name;
this.js_stop = name + '.stop()';
this.parameters = 'STOP=' + this.js_stop + '&' + parameters;
this.xml_Http_Object = null;
this.running = false;
},
start : function() {
if (this.xml_Http_Object == null) {
this.xml_Http_Object = new Ajax.PeriodicalUpdater(this.target,
this.url, {
method : this.method,
encoding : 'ISO-8859-1',
parameters : this.parameters,
onSuccess : this.success_handler,
onInteractive : this.interactive_handler,
onComplete : this.complete_handler,
onLoading : this.loading_handler,
onLoaded : this.loaded_handler,
evalScripts : true,
asynchronous : true,
frequency : 0.8,
decay : 0.1
});
this.running = true;
} else if (!this.running) {
this.xml_Http_Object.start();
this.running = true;
}
},
stop : function() {
if ((this.xml_Http_Object != null) && (this.running)) {
this.xml_Http_Object.stop();
this.running = false;
}
},
change_parameters : function(parameters) {
this.stop();
this.xml_Http_Object = null;
this.parameters = 'STOP=' + this.js_stop + parameters;
this.start();
},
success_handler : function(request) {
},
interactive_handler : function(request) {
},
complete_handler : function(request) {
},
loading_handler : function(request) {
},
loaded_handler : function(request) {
}
}
var begin_date;
var end_date;
var my_controller = new ajax_controller('../include/stats_writer_response.php',
'div_result_open', 'my_controller', 'date_de=' + $F('date_de')
+ '&date_ah=' + $F('date_ah'));
Event.observe('sp_btn_start', 'click', start_me, false);
Event.observe('sp_btn_stop', 'click', stopp_me, false);
//Event.observe('toDate', 'click', toDate, false);
function start_me() {
my_controller.start();
}
function stopp_me() {
my_controller.stop();
}
function toDate() {
my_controller.change_parameters('&begin_day=' + $F('begin_day')
+ '&begin_month=' + $F('begin_month') + '&begin_year='
+ $F('begin_year') + '&end_day=' + $F('end_day') + '&end_month='
+ $F('end_month') + '&end_year=' + $F('end_year'));
}
</script> |
Follow Us!