[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 119/151: correct syntax
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 119/151: correct syntax |
Date: |
Sat, 4 Feb 2017 17:14:33 +0000 (UTC) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit bda0fbc874b07a9181ddd97d355eb694b305bdc5
Author: Dany De Bontridder <address@hidden>
Date: Sat Jan 14 10:11:14 2017 +0100
correct syntax
---
html/js/managetable.js | 292 ++++++++++++++++++++++++------------------------
1 file changed, 147 insertions(+), 145 deletions(-)
diff --git a/html/js/managetable.js b/html/js/managetable.js
index 7b766db..8a5e662 100644
--- a/html/js/managetable.js
+++ b/html/js/managetable.js
@@ -1,5 +1,4 @@
- <script>
- /*
+/*
* This file is part of NOALYSS.
*
* NOALYSS is free software; you can redistribute it and/or modify
@@ -28,184 +27,187 @@
address@hidden p_table_name the data table on which we're working
in javascript , to create an object to manipulate the table
version.
-
-Example of code
+
+ Example of code
@code
// Version will manage the table "version"
var version=new ManageTable("version");
-
+
// the file ajax_my.php will be called
version.set_callback("ajax_my.php");
-
+
// Add supplemental parameter to this file
version.param_add ({"plugin_code":"OIC"};
-
+
// Set the id of dialog box , table and tr prefix
version.set_control("dialbox1");
-
+
@endcode
+
+
+ The answer from ajax must be like this template
+ @verbatim
+ <xml>
+ <ctl> id of the control to update for diag.box, row </ctl>
+ <status> OK , FAIL ...</status>
+ <html> Html to display</html>
+ </xml>
+ @endverbatim
+
+ List of function
+ - set_control(p_ctl_name)
+ - set_callback (p_new_callback)
+ - param_add (json object)
+ - parseXML (private function)
+ - save
+ - delete
+ - input
+
+ */
-
-The answer from ajax must be like this template
address@hidden
-<xml>
-<ctl> id of the control to update for diag.box, row </ctl>
-<status> OK , FAIL ...</status>
-<html> Html to display</html>
-</xml>
address@hidden
-
-List of function
- - set_control(p_ctl_name)
- - set_callback (p_new_callback)
- - param_add (json object)
- - parseXML (private function)
- - save
- - delete
- - input
-
-*/
-
-var ManageTable=function(p_table_name)
+var ManageTable = function (p_table_name)
{
- this.callback="ajax.php"; //!< File to call
- this.control="dtr"; //<! Prefix Id of dialog box, table, row
- this.param={"table":p_table_name,"ctl_id":this.control}; //<! default
value to pass
- var answer={};
+ this.callback = "ajax.php"; //!< File to call
+ this.control = "dtr"; //<! Prefix Id of dialog box, table, row
+ this.param = {"table": p_table_name, "ctl_id": this.control}; //<! default
value to pass
+ var answer = {};
/**
address@hidden ManageTable.set_control
address@hidden Set the id of the control name , used as
* prefix for dialog box , table id and row
address@hidden string p_ctl_name id of dialog box
*/
- this.set_control(p_ctl_name) {
- this.control=p_ctl_name;
- }
+ this.set_control = function (p_ctl_name) {
+ this.control = p_ctl_name;
+ };
/**
address@hidden set the name of the callback file to
* call by default it is ajax.php
*/
- this.set_callback=function(p_new_callback) {
- this.callback=p_new_callback;
+ this.set_callback = function (p_new_callback) {
+ this.callback = p_new_callback;
};
/**
address@hidden By default send the json param variable
* you can add a json object to it in order to
* send it to the callback function
*/
- this.param_add= function(p_obj) {
- var result={};
- for ( var key in this.param) {
- result[key]=this.param[key];
- }
- for ( var key in p_obj) {
- result[key]=p_obj[key];
- }
- this.param=result;
- return this.param;
+ this.param_add = function (p_obj) {
+ var result = {};
+ for (var key in this.param) {
+ result[key] = this.param[key];
+ }
+ for (var key in p_obj) {
+ result[key] = p_obj[key];
+ }
+ this.param = result;
+ return this.param;
};
/**
@brief receive answer from ajax and fill up the
private object "answer"
@param req Ajax answer
- */
- var parseXML=function (req) {
- var xml=req.responseXML;
- var status =getElementsByTagName("status");
- var ctl=xml.getElementsByTagName("ctl");
- var html=xml.getElementsByTagName("html");
- if ( status.length==0 || ctl.length == 0 || html.length == 0 )
- {
- throw "Invalid answer "+req.responseText;
-
- }
- answer['status']=getNodeText(status[0]);
- answer['ctl']=getNodeText(ctl[0]);
- answer['html']=getNodeText(html[0]);
+ */
+ var parseXML = function (req) {
+ var xml = req.responseXML;
+ var status = getElementsByTagName("status");
+ var ctl = xml.getElementsByTagName("ctl");
+ var html = xml.getElementsByTagName("html");
+ if (status.length == 0 || ctl.length == 0 || html.length == 0)
+ {
+ throw "Invalid answer " + req.responseText;
+
+ }
+ answer['status'] = getNodeText(status[0]);
+ answer['ctl'] = getNodeText(ctl[0]);
+ answer['html'] = getNodeText(html[0]);
};
- /**
- address@hidden call the ajax with the action save
- address@hidden update or append
- * As a hidden parameter the Manage_Table:object_name must be
- * set
- */
- this.save=function(form_id) {
- waiting_box();
- var form=$F(form_id);
- this.param_add(form);
- new Ajax.Request(this.callback,{
- parameters:this.param,
- method:"post",
- onSuccess:function(req) {
- /// Display the result of the update
- /// 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);
- if (answer ['status'] == 'OK' ) {
- if ( $(answer['ctl'])) {
- $(answer['ctl']).update(answer['html']);
- } else {
- var new_row=new Element("tr");
- new_row.id=answer['ctl'];
- new_row.innerHTML=answer['html'];
- $("tb"+this.control).appendChild(new_row);
- }
- } else {
- console.error("Error in save");
- throw Exception "error in save";
- }
-
-
- }
-
-
- };
- /**
- address@hidden call the ajax with action delete
- address@hidden id (pk) of the data row
- */
- this.delete=function (p_id,p_ctl_row) {
- this.param['p_id']=p_id;
- this.param['action']='delete';
-
- new Ajax.Request(this.callback,{
- parameters:this.parm,
- method:"get",
- onSuccess:function (req) {
- parseXML(req);
- if ( answer['status'] == 'OK') {
- $(answer['ctl']).hide();}
- }
-
- };
- /**
- address@hidden display a dialog box with the information
- * of the data row
- address@hidden id (pk) of the data row
- */
- this.input=function (p_id,p_ctl_row) {
- waiting_box();
- this.param['p_id']=p_id;
- this.param['action']='input';
- this.param['ctl_row']=p_ctl_row;
- // 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 pos=calcy(250);
- $(this.control).setStyle({top:pos+'px'});
- obj.update(req.responseText);
+ /**
+ address@hidden call the ajax with the action save
+ address@hidden update or append
+ * As a hidden parameter the Manage_Table:object_name must be
+ * set
+ */
+ this.save = function (form_id) {
+ waiting_box();
+ var form = $F(form_id);
+ this.param_add(form);
+ new Ajax.Request(this.callback, {
+ parameters: this.param,
+ method: "post",
+ onSuccess: function (req) {
+ /// Display the result of the update
+ /// 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);
+ if (answer ['status'] == 'OK') {
+ if ($(answer['ctl'])) {
+ $(answer['ctl']).update(answer['html']);
+ } else {
+ var new_row = new Element("tr");
+ new_row.id = answer['ctl'];
+ new_row.innerHTML = answer['html'];
+ $("tb" + this.control).appendChild(new_row);
+ }
+ } else {
+ console.error("Error in save");
+ throw "error in save";
+ }
+
+
+ }
+
+
+ })
+ };
+ /**
+ address@hidden call the ajax with action delete
+ address@hidden id (pk) of the data row
+ */
+ this.delete = function (p_id, p_ctl_row) {
+ this.param['p_id'] = p_id;
+ this.param['action'] = 'delete';
+
+ new Ajax.Request(this.callback, {
+ parameters: this.parm,
+ method: "get",
+ onSuccess: function (req) {
+ parseXML(req);
+ if (answer['status'] == 'OK') {
+ $(answer['ctl']).hide();
+ }
+ }
+
+ });
+ }
+ /**
+ address@hidden display a dialog box with the information
+ * of the data row
+ address@hidden id (pk) of the data row
+ */
+ this.input = function (p_id, p_ctl_row) {
+ waiting_box();
+ this.param['p_id'] = p_id;
+ this.param['action'] = 'input';
+ this.param['ctl_row'] = p_ctl_row;
+ // 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 pos = calcy(250);
+ $(this.control).setStyle({top: pos + 'px'});
+ obj.update(req.responseText);
+
+ }
+ });
+ };
- }
- });
- };
-
}
-</script>
+
- [Noalyss-commit] [noalyss] 03/151: CSS : Update style mobile, (continued)
- [Noalyss-commit] [noalyss] 03/151: CSS : Update style mobile, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 57/151: CSS : Update style mobile, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 117/151: Indent properly, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 89/151: remove debug info, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 114/151: Move class_table_sql to lib , since it is usable without Noalyss, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 127/151: Add the noalyss version in the info page, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 121/151: Fix several issue in JS, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 98/151: Correct simul.py remove old file, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 146/151: Merge branch 'master' of ns3:/srv/git/noalyss, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 142/151: Doc : complete documentation, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 119/151: correct syntax,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 151/151: Improve description, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 145/151: change name alternate_row_color, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 137/151: Remove console.log from JS Safer function for XML (problem with escaping), Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 122/151: Test ManageTable ; fix several bugs and add the ajax answer , it not yet finished, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 62/151: Experiment less, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 149/151: Correct doxygen, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 49/151: Remove unused documentation, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 100/151: Remove unused documentation, Dany De Bontridder, 2017/02/04