In AskiaScript, ADX, or Askia Design eXtension, encapsulates both ADC (Askia Design Control) and ADP (Askia Design Page). It is an object that can be used inside an ADX and provides the ADX context and useful information about the currently displayed ADX. This variable is in the ADX scope, so is available only on the ADX itself. It is accessible through a local variable named CurrentADC for an ADC or CurrentADP for an ADP.
See also:
In this topic:
Returns the unique identifier of the ADX instance displayed on the page. The same ADX could appear several times on the same page, with each instance having its own unique identifier that can be retrieved through this property.
Returns a Number.
CurrentADC.InstanceId ' => 1, for the first ADC instance ' available in the current page
Returns the name of the ADX.
Returns a String.
See also: <name>
CurrentADC.Name ' => "Gender"
CurrentADP.Name ' => "MyBeautifulPage"
Returns the ID of the current, in-use, ADX output.
Returns a String.
See also: Output selection rules.
CurrentADC.OutputId ' => "mobileHTMLOutput"
CurrentADP.OutputId ' => "DesktopPage"
Returns the file-name of the master page in use. Using it in an ADC will return an empty string.
Returns a String.
Also see: Output selection rules.
CurrentADP.MasterPage' => "DesktopPage"
CurrentADC.MasterPage ' => "" 'No master page inside ADC
Returns the entire collection of properties defined in the ADX.
Returns a collection of ADX Properties.
See also: <properties>
CurrentADC.Properties.Count ' => 2
CurrentADC.Properties[1] ' => <ADXProperty::tickColor>
CurrentADP.Properties[2] ' => <ADXProperty::autoSubmit>
Returns the list of ADX contents (files) in the currently-selected ADX output.
Returns an Array of ADX Content.
See also: <content>.
CurrentADC.Contents.Count ' => 2
CurrentADC.Contents[1] ' => <ADCContent::dynamic:default.html>
CurrentADP.Contents[1] ' => <ADCContent::dynamic:styles.css>
Returns the list of errors during the interview associated with the ADC. This allows ADCs to indicate if there is an error associated with a specific entry, as opposed to the page as a whole.
See also: Error
Returns an Array of Errors.
CurrentADC.Errors.Count ' => 0
CurrentADC.Errors[1].Key ' => "expected_answer"
CurrentADC.Errors[1].Message ' => "A response is expected for question 'q1'"
{% If CurrentADC.Errors.Count Then %}
<ul class="question-errors"><li>{%= CurrentQuestion.ShortCaption %}
<ul>
{% Dim errIter
For errIter = 1 To CurrentADC.Errors.Count
%}
<li>{%= CurrentADC.Errors[errITer].Message %}</li>
{% Next %}
</ul>
</li></ul>
{% EndIf %}
Produces:
<ul class="question-errors"><li>Ranking
<ul>
<li>Rank 2 is missing for question `Ranking`</li>
<li>Rank 3 has been given more than once for question `Ranking`</li>
</ul>
</li></ul>
Returns the value of the ADX property as a variant. If the value of the variable is an object (like a question), the system calls its ToString() method. If you want to access the question object associated with the variable, use the PropQuestion method instead.
Returns a Variant.
The inner type of the variant depends on the type of the property, as follows:
string, color, file or questionnumber, booleanThis is a shorthand for:
CurrentADC.GetProperty( propertyId ).Value
If CurrentADC.Var("enableTooltip") = true Then
' Rest of the code
End If
{%= CurrentADC.Var("tickColour") %} ' Print: 0,255,0
CurrentADC.Var("boxNumbers").ToNumber() + 1 ' 12 + 1
CurrentADC.Var("additionalQuestion").InnerTypeOf() ' => "string"
CurrentADC.Var("additionalQuestion") ' => "{
"shortcut":"q1",
"shortCaption":"Q1",
"longCaption":"Q1",
"type":"single"
}"
Returns the value of the ADX property as a string. If the value of the variable is an object (like a question), the system calls its ToString() method. If you want to access the question object associated with the variable, use the PropQuestion method instead.
This is a shorthand for:
CurrentADC.GetProperty( propertyId ).Value.ToString()
Returns a String (take note).
CurrentADC.PropValue("defaultDisplay") ' => "FlashEnable"
CurrentADC.PropValue("tickColour") ' => "0,255,0"
CurrentADC.PropValue("additionalQuestion") ' => "{
"shortcut":"q1",
"shortCaption":"Q1",
"longCaption":"Q1",
"type":"single"
}"
Returns the question associated with the ADX property (type question). This is shorthand for:
CurrentADC.GetProperty( propertyId ).Question
Returns a Question.
CurrentADC.PropQuestion("other") ' => <Question::Q1_Other>
CurrentADC.PropQuestion("other").Shortcut ' => "Q1_Other"
Returns a key/value pair of properties using the JSON Object representation.
Returns a String.
{ and }true or false.
CurrentADC.PropsToJSONObject()
' {
' "prop1" : "value1",
' "prop2" : "value2",
' "prop3" : true,
' "prop4" : 12
' }
CurrentADC.PropsToJSONObject({"prop1"; "prop4"})
' {
' "prop1" : "value1",
' "prop4" : 12
' }
CurrentADC.PropsToJSONObject({"prop1"; "prop4"}, true) ' Don't wrap
' "prop1" : "value1",
' "prop4" : 12
Build a complex JSON representation using don't wrap and wrap.
var obj = {
{%= CurrentADC.PropsToJSONObject({"prop1"; "prop4"}, true) ' Don't wrap %}
, "subKeys" : {%= CurrentADC.PropsToJSONObject({"prop2"; "prop3"}) ' Wrap %}
}; // End
' var obj = {
' "prop1" : "value1",
' "prop4" : 12
' , "subKeys" : {
' "prop2" : "value2",
' "prop3" : true
' }
' }; // End
Returns an array of property values, separated with comma delimiters (JSON representation of array).
Returns a String.
[ and ]true or false.CurrentADC.PropsToJSONArray() ' ["value1", "value2", true, 12' ]
CurrentADC.PropsToJSONObject({"prop1"; "prop4"})
' ["value1", 12 ]
CurrentADC.PropsToJSONObject({"prop1"; "prop4"}, true) ' Don't wrap
' "value1", 12
Build a complex JSON representation using the don't wrap and wrap.
var arr = [
{%= CurrentADC.PropsToJSONArray({"prop1"; "prop4"}, true) ' Don't wrap %}
, {%= CurrentADC.PropsToJSONObject({"prop2"; "prop3"}) ' Wrap (sub-array) %}
]; // End
' var arr = [
' "value1", 12
' , ["value2", true]
' ]; // End
The don't wrap could also be use to call javascript function with the properties as arguments:
console.log({%= CurrentADC.PropsToJSONArray({"prop1"; "prop4"}, true) ' Don't wrap %});
' console.log("value1", 12);
Returns the property object with the specified id.
Returns an ADX Property.
Parameters
See also: <properties>
CurrentADC.GetProperty("tickColor")
' => <ADCProperty::tickColor>
CurrentADC.GetProperty("tickColor").Name
' => "Tick color"
Returns the ADX content with the specified location.
See also: Content location
Returns an ADX Content.
CurrentADC.GetContent("share/jquery.js") ' => <ADCContent::share:jquery.js>
CurrentADC.GetContent("static/styles.css").Type ' => "css"
Returns the relative URL path to the content file at the specified location.
Returns a String.
For a dynamic file:
Also see: Content location
CurrentADC.URLTo("static/tick.png")
' => "../Resources/[Survey]/[ADC]/tick.png"
CurrentADC.URLTo("shared/jquery.js")
' => "../Resources/[Survey]/jquery.js"
CurrentADC.URLTo("dynamic/default.js")
' => "AskiaExt.dll?Action=GetADCContent
' &SurveyName=TestSurvey
' &Intvw=BNYOXYCYVIUJDBBD
' &Position=4
' &ADCName=GenderADC
' &InstanceId=1
' &Content=dynamic/default.js"
Returns the HTML code of the ADP as string.
Returns a String.
This method is to use in the final pages and if you use also SetProperty() and/or Redirect() methods, then you need to use ShowMessage() at the end.
!!CurrentADP.ShowMessage("my message")!!
!!CurrentADP.SetProperty("display_previous","no").SetProperty("display_next","no").Redirect("http://www.askia.com",5).ShowMessage("
<center>
<br/>
Thank you for your participation<br/><br/>
You will be redirect in <span id='countdown'>5</span> s<br/><br/>
</center>
<script type='text/javascript'>
document.addEventListener('DOMContentLoaded', function(event) {
var timeleft = 4;
var downloadTimer = setInterval(function(){
document.getElementById('countdown').innerHTML = timeleft;
timeleft -= 1;
if (timeleft <= 0){
clearInterval(downloadTimer);
}
}, 1000);
});
</script>
")!!
Returns the current ADP with the modified property.
This method is to use in the final pages and you need to use ShowMessage() at the end.
!!CurrentADP.SetProperty("display_previous","no").SetProperty("display_next","no").Redirect("http://www.askia.com",5).ShowMessage("
<center>
<br/>
Thank you for your participation<br/><br/>
You will be redirect in <span id='countdown'>5</span> s<br/><br/>
</center>
<script type='text/javascript'>
document.addEventListener('DOMContentLoaded', function(event) {
var timeleft = 4;
var downloadTimer = setInterval(function(){
document.getElementById('countdown').innerHTML = timeleft;
timeleft -= 1;
if (timeleft <= 0){
clearInterval(downloadTimer);
}
}, 1000);
});
</script>
")!!
Returns the current ADP with a meta http-equiv refresh added in the head of the html page.
This method is to use in the final pages and you need to use ShowMessage() at the end.
!!CurrentADP.SetProperty("display_previous","no").SetProperty("display_next","no").Redirect("http://www.askia.com",5).ShowMessage("
<center>
<br/>
Thank you for your participation<br/><br/>
You will be redirect in <span id='countdown'>5</span> s<br/><br/>
</center>
<script type='text/javascript'>
document.addEventListener('DOMContentLoaded', function(event) {
var timeleft = 4;
var downloadTimer = setInterval(function(){
document.getElementById('countdown').innerHTML = timeleft;
timeleft -= 1;
if (timeleft <= 0){
clearInterval(downloadTimer);
}
}, 1000);
});
</script>
")!!
Returns a string which represents the ADX object, in JSON notation.
CurrentADC.ToString() ' => {
"name":"Gender",
"guid":"0dba9f18-a026-421e-afa9-0ec01128a663",
"version":"2.0.0",
"date":"2012-03-05",
"description":"Question gender",
"categories":[ "Gender", "Closed" ],
"author":"Jerome Duparc, Mamadou Sy",
"company":"Askia SAS",
"helpURL":"http://dev.askia.com",
"site":"http://www.askia.com"
}
CurrentADP.ToString() ' => {
"name":"MyBeautifulPath",
"guid":"17e47dff-8d4b-4ab9-a461-78f2388acd22",
"version":"1.0.0",
"date":"2015-12-16",
"description":"Beautiful page template with auto-submit",
"categories":[ "Auto-submit" ],
"author":"John Doe",
"company":"My company",
"helpURL":"http://my.helpurl.com",
"site":"http://my.url.com"
}
Always returns "adc" or "adp".
Returns a String.
CurrentADC.TypeOf() ' => "adc"
CurrentADP.TypeOf() ' => "adp"
The content location is a special relative URL based on the ADX Resources folder. To get a specific ADX Content or the final URL of a file under the ADC Resources folder, you may use the following location pattern:
Mode/FileName
Where Mode could be "share", "static" or "dynamic" and FileName is the full name of the file to be obtained.
Example:
shared/jquery.js static/styles.css dynamic/controls.html