Fix several issue in JS

This commit is contained in:
Dany De Bontridder 2017-01-14 14:02:36 +01:00
parent 434f2f53d1
commit 5fd9bc0b13

View file

@ -64,6 +64,10 @@
- input
*/
/**
* @class ManageTable
* @param string p_table_name name of the table and schema
*/
var ManageTable = function (p_table_name)
{
@ -108,7 +112,7 @@ var ManageTable = function (p_table_name)
private object "answer"
@param req Ajax answer
*/
var parseXML = function (req) {
this.parseXML = function (req) {
var xml = req.responseXML;
var status = getElementsByTagName("status");
var ctl = xml.getElementsByTagName("ctl");
@ -121,7 +125,7 @@ var ManageTable = function (p_table_name)
answer['status'] = getNodeText(status[0]);
answer['ctl'] = getNodeText(ctl[0]);
answer['html'] = getNodeText(html[0]);
return answer;
};
/**
*@brief call the ajax with the action save
@ -141,7 +145,7 @@ var ManageTable = function (p_table_name)
/// or add , the name of the row in the table has the
/// if p_ctl_row does not exist it means it is a new
/// row , otherwise an update
parseXML(req);
this.parseXML(req);
if (answer ['status'] == 'OK') {
if ($(answer['ctl'])) {
$(answer['ctl']).update(answer['html']);
@ -174,14 +178,14 @@ var ManageTable = function (p_table_name)
parameters: this.parm,
method: "get",
onSuccess: function (req) {
parseXML(req);
this.parseXML(req);
if (answer['status'] == 'OK') {
$(answer['ctl']).hide();
}
}
});
}
};
/**
*@brief display a dialog box with the information
* of the data row
@ -192,17 +196,22 @@ var ManageTable = function (p_table_name)
this.param['p_id'] = p_id;
this.param['action'] = 'input';
this.param['ctl_row'] = p_ctl_row;
var control = this.control;
var parsexml=this.parseXML;
// display the form to enter data
new Ajax.Request(this.callback, {
parameters: this.param,
method: "get",
onSuccess: function (req) {
remove_waiting_box();
var obj = {"id": this.control, "cssclass": "inner_box", "html": loading()};
create_div(obj);
var x=parsexml(req);
console.log("x");
console.log(x);
var obj = {id:control, "cssclass": "inner_box", "html": loading()};
add_div(obj);
var pos = calcy(250);
$(this.control).setStyle({top: pos + 'px'});
obj.update(req.responseText);
$(obj.id).setStyle({position:"absolute",top: pos + 'px',width:"auto","margin-left":"10%"});
$(obj.id).update(req.responseText);
}
});