Skip to content
Snippets Groups Projects
Commit 6e6915d3 authored by Johannes Hörmann's avatar Johannes Hörmann
Browse files

update adocs

parent 75e996e6
No related branches found
No related tags found
No related merge requests found
......@@ -10,30 +10,23 @@ How to write JDito code
== code structure ==
=== vars and others (var, let) ===
* declaration of variables go on top (what actually happens in JS anyway by default -> hoisting)
* you can define them later
* avoid `let` as much as possible because you cannot debug these variables
Example:
[source,javascript]
----
import("system.result");
import("system.vars");
var data, cond, i, resStr;
data = vars.get.......
----
=== brackets ===
* `{` are placed at the end of the expression
* `{` are placed on a new line
Example:
[source,javascript]
----
for (i = 0, i < dataLen; i++) {
for (i = 0, i < dataLen; i++)
{
//code here
}
myArray.forEach(function(item)
{
// Do something
});
----
=== loops ===
......@@ -44,14 +37,18 @@ Even better would be a good and describing name.
Example:
[source,javascript]
----
for (i = 0, i < dataLen; i++) {
for (ii = 0, ii < dataLen[i].length; ii++) {
for (i = 0, i < dataLen; i++)
{
for (ii = 0, ii < dataLen[i].length; ii++)
{
//code...
}
}
for (row = 0, row < dataLen; row++) {
for (col = 0, col < dataLen[row].length; col++) {
for (row = 0, row < dataLen; row++)
{
for (col = 0, col < dataLen[row].length; col++)
{
//code...
}
}
......@@ -80,7 +77,8 @@ function CommValidationUtil(){}<1>
* returns a blueprint for validation extensions; these extensions are needed for validating comm data and can be passed to other functions
* @return {object} a object with properties that have a specific default value; normally you want to overwrite that value
*/
CommValidationUtil.getExtensionsBlueprint = function() {<2>
CommValidationUtil.getExtensionsBlueprint = function() <2>
{
return {
countryCode: null
};
......@@ -113,7 +111,8 @@ Definition:
* @param {String} [alias=the current alias] the database alias where the condition shall be executed later (important for column types of preparedStatements) <2>
* @example //TODO: add missing example <3>
*/
function SqlCondition(alias) {<4>
function SqlCondition(alias) <4>
{
//setting null is only needed to provide autocomplete for the ADITO-designer
this.preparedValues = null;
this._init();//the properties are initalized in an extra function because init is nearly the same as resetting (clearing) the SqlConditions
......@@ -124,7 +123,8 @@ function SqlCondition(alias) {<4>
* @param {String} cond the condition string which shall be appended
* @return {Object} current SqlCondition-object
*/
SqlCondition.prototype.and = function(cond) {<5>
SqlCondition.prototype.and = function(cond) <5>
{
if (!cond)
return this;
if (this._sqlStorage)
......@@ -160,7 +160,8 @@ Required parameter: alias
* @example Here is an example
* @class
*/
function SqlCondition(alias) {
function SqlCondition(alias)
{
...
}
----
......
......@@ -15,7 +15,8 @@ import("...");
* @example var myUtil = new UtilClass("-");
* @class
*/
function UtilClass(param1) {
function UtilClass(param1)
{
// here is the constructor.
// create class variables like this:
this.myVariable = param1;
......@@ -31,7 +32,8 @@ function UtilClass(param1) {
*
* @return {String} a result
*/
UtilClass.prototype.myFunction = function(param1, param2) {
UtilClass.prototype.myFunction = function(param1, param2)
{
return this._privateStaticFunction1(param1, param2, this.myVariable);
}
......@@ -45,8 +47,10 @@ UtilClass.prototype.myFunction = function(param1, param2) {
* @return {String} a result
* @ignore
*/
UtilClass.prototype._myPrivateFunction = function(param1, param2, param3) {
if(param1 && param2 && param3) {
UtilClass.prototype._myPrivateFunction = function(param1, param2, param3)
{
if(param1 && param2 && param3)
{
...
return param1 + param3 + param2;
}
......
......@@ -25,7 +25,8 @@ function ExampleUtils() {} // leave this function empty! A constructor is not ne
*
* @return {String} a result
*/
ExampleUtils.staticFunction1 = function(param1, param2) {
ExampleUtils.staticFunction1 = function(param1, param2)
{
return this._privateStaticFunction1(param1, param2, "-")
}
......@@ -41,8 +42,10 @@ ExampleUtils.staticFunction1 = function(param1, param2) {
* @return {String} a result
* @ignore
*/
ExampleUtils._privateStaticFunction1 = function(param1, param2, param3) {
if(param1 && param2) {
ExampleUtils._privateStaticFunction1 = function(param1, param2, param3)
{
if(param1 && param2)
{
...
return param1 + param3 + param2;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment