Class: Info

Configurator. Info


new Info(configurator)

Provide an object to manipulate the meta-information of the ADX (config.xml > info)

 const ADX = require('adxutil').ADX;

 const myAdx = new ADX('path/to/adx/');
 myAdx.load(function (err) {
     if (err) {
         throw err;
     }

     // Get the instance of the Info
     const info = myAdx.configurator.info;

     console.log(info.get());

 });
Parameters:
Name Type Description
configurator ADX.Configurator

Instance of the configurator

Members


configurator :Configurator

Parent configurator

Type:

Methods


author( [data])

Get or set the author(s) of the ADX

  // Get the author(s) of the ADX
  adxInfo.author();

  // Set the author(s) of the ADX
  adxInfo.author("John Doe <john.doe@unknow.com>, Foo Bar <foo@bar.com>");
Parameters:
Name Type Argument Description
data String <optional>

Author(s) to set

Returns:

Author(s)

Type
String

categories( [data])

Get or set the categories

  // Get the categories of the ADC
  adxInfo.categories();

  // Set the categories of the ADC
  adxInfo.categories(["General", "Slider", "Single"]);
Parameters:
Name Type Argument Description
data Array.<String> <optional>

Array of string which represent the categories to set

Deprecated:
  • Yes
Returns:

Name of categories

Type
Array.<String>

company( [data])

Get or set the company name of the ADX creator

  // Get the company of the ADX
  adxInfo.company();

  // Set the company of the ADX
  adxInfo.company("Askia SAS");
Parameters:
Name Type Argument Description
data String <optional>

Company name to set

Returns:

Company of the ADX creator

Type
String

constraint(where, attName [, attValue])

Get or set the constraint (ADC Only)

  // Get the constraint 'single' on questions
  adxInfo.constraint('questions', 'single');

  // Set the constraint 'single' on questions
  adxInfo.constraint('questions', 'single', true);
Parameters:
Name Type Argument Description
where String

Which constraint to target

attName String

Name of the constraint attribute to get or set

attValue Boolean | Number <optional>

Value of the attribute to set

Returns:

Value of the attribute

Type
Boolean | Number

constraints( [data])

Get or set the constraints

  // Get the constraints of the ADC
  adxInfo.constraints();

  // Set the constraints of the ADC
  adxInfo.constraints({
     questions : {
         single : true,
         multiple : true
     },
     controls : {
         responseBlock : true,
         label : false
     },
     responses : {
         max : 25
     }
  });
Parameters:
Name Type Argument Description
data Object <optional>

Constraint data to set (ADC ONLY)

Returns:

Constraints

Type
Object

date( [data])

Get or set the date creation of the ADX

  // Get the date
  adxInfo.date();

  // Set the date
  adxInfo.date("2015-06-25");
Parameters:
Name Type Argument Description
data String <optional>

Date to set

Returns:

Date

Type
String

description( [data])

Get or set the description of the ADX

  // Get the description of the ADX
  adxInfo.description();

  // Set the description of the ADX
  adxInfo.description("This is the description of the ADX");
Parameters:
Name Type Argument Description
data String <optional>

Description of the ADX to set

Returns:

Description of the ADX

Type
String

get()

Get the entire information as object

  // Get the info object
  adxInfo.get();
  // {
  //   name : "My ADC"
  //   version : "2.2.0.beta1",
  //   date  : "2015-06-25",
  //   guid  : "the-guid",
  //   description : "Description of the ADC"
  //   author  : "The author name",
  //   company : "The company name",
  //   site    : "http://website.url.com",
  //   helpURL : "http://help.url.com",
  //   constraints : {
  //       questions : {
  //          single : true,
  //          multiple : true
  //       },
  //       controls : {
  //           responseBlock : true
  //       },
  //       responses : {
  //           max : 10
  //       }
  //   }
  // }
Returns:
Type
Object

guid( [data])

Get or set the GUID of the ADX

  // Get the guid of the ADX
  adxInfo.guid();

  // Set the guid of the ADC
  var uuid = require('node-uuid'');
  adxInfo.guid(uuid.v4());
Parameters:
Name Type Argument Description
data String <optional>

GUID of the ADX to set

Returns:

GUID of the ADX

Type
String

helpURL( [data])

Get or set the help URL of the ADX

  // Get the help URL
  adxInfo.helpURL();

  // Set the help URL
  adxInfo.helpURL("http://my.help.file.com");
Parameters:
Name Type Argument Description
data String <optional>

URL to set

Returns:

Help URL

Type
String

name( [data])

Get or set the name of the ADX

  // Get the name of the ADX
  adxInfo.name();

  // Set the name of the ADX
  adxInfo.name("New name");
Parameters:
Name Type Argument Description
data String <optional>

Name of the ADX to set

Returns:

Name of the ADX

Type
String

set(data)

Set the information using a plain object

  // Get the info object
  adxInfo.set({
     name : "My ADC"
     version : "2.2.0.beta1",
     date  : "2015-06-25",
     guid  : "the-guid",
     description : "Description of the ADC"
     author  : "The author name",
     company : "The company name",
     site    : "http://website.url.com",
     helpURL : "http://help.url.com",
     constraints : {
         questions : {
            single : true,
            multiple : true
         },
         controls : {
             responseBlock : true
         },
         responses : {
             max : 10
         }
     }
   });
Parameters:
Name Type Description
data Object

Data to set

Properties
Name Type Argument Description
name String <optional>

Name of the ADX

version String <optional>

Version of the ADX

date String <optional>

Date of the ADX (YYYY-MM-dd)

guid String <optional>

GUID of the ADX

description String <optional>

Description of the ADX

author String <optional>

Author(s) of the ADX (name1 )

company String <optional>

Company name of the creator

site String <optional>

Web site URL of the creator

helpURL String <optional>

URL to the ADX help

style Object <optional>

[DEPRECATED] Style of the ADC

Properties
Name Type Argument Description
width Number <optional>

[DEPRECATED] Width of the ADC (in pixel)

height Number <optional>

[DEPRECATED] Height of the ADC (in pixel)

categories Array.<String> <optional>

[DEPREACATED] Categories of the ADC

constraints Object <optional>

Constraints of the ADC (ADC ONLY)

Properties
Name Type Argument Description
questions Object <optional>

Questions constraints of the ADC (ADC ONLY)

Properties
Name Type Argument Description
chapter Boolean <optional>

Allow or not on chapter

single Boolean <optional>

Allow or not on single questions

multiple Boolean <optional>

Allow or not on multi-coded questions

numeric Boolean <optional>

Allow or not on numeric questions

open Boolean <optional>

Allow or not on open-ended questions

date Boolean <optional>

Allow or not on date questions

requireParentLoop Boolean <optional>

Require or not on a parent loop question

controls Object <optional>

Controls constraints of the ADC (ADC ONLY)

Properties
Name Type Argument Description
responseBlock Boolean <optional>

Allow or not on response-block

label Boolean <optional>

Allow or not on label

textbox Boolean <optional>

Allow or not on text-box

listbox Boolean <optional>

Allow or not on list-box

checkbox Boolean <optional>

Allow or not on checkbox

radiobutton Boolean <optional>

Allow or not on radio button

responses Object <optional>

Responses constraints of the ADC (ADC ONLY)

Properties
Name Type Argument Description
min Number <optional>

Minimum allowed responses

max Number <optional>

Maximum allowed responses


site( [data])

Get or set the website URL of the ADX creator

  // Get the site
  adxInfo.site();

  // Set the site URL
  adxInfo.site("http://my.website.com");
Parameters:
Name Type Argument Description
data String <optional>

URL to set

Returns:

Site URL

Type
String

style( [data])

Get or set the style

  // Get the style of the ADC
  adxInfo.style();

  // Set the style of the ADC
  adxInfo.style({
     width  : 400,
     height : 200
  });
Parameters:
Name Type Argument Description
data Object <optional>

Style to set

Properties
Name Type Argument Description
width Number <optional>

Style width

height Number <optional>

Style height

Deprecated:
  • Yes
Returns:
Type
Object

toXml()

Return the info as xml string

  // Serialize the info to XML
  adxInfo.toXml();
  // -> <info><name>MyADC</name><guid>the-guid</guid>....</info>
Returns:
Type
String

version( [data])

Get or set the version of the ADX

  // Get the version of the ADX
  adxInfo.version();

  // Set the version of the ADX
  adxInfo.version("2.0.0.beta1");
Parameters:
Name Type Argument Description
data String <optional>

Version of the ADX to set

Returns:

Version of the ADX

Type
String