new RuntimeApi()
Do not instantiate this class. The RuntimeApi class is automatically assigned to the variable mc as well as MiraCheck. Call all methods in the class from the Value Trigger panel in MiraCheck Cloud with the prefix mc or MiraCheck.
Example 1 - mc.getValue(); Example 2 - MiraCheck.getValue();
Methods
-
setGlobalVar(name, value)
-
Sets a global variable. This variable can be accessed at anytime within the checklist.
Parameters:
Name Type Description namestring The name of the variable to set. valuestring The value to assign to the variable. Example
// Example - Increment total var total = mc.getGlobalVar("total"); mc.setGlobalVar("total",total+1); -
getGlobalVar(name)
-
Gets a global variable.
Parameters:
Name Type Description namestring The name of the variable to get. Example
// Example - Increment total var total = mc.getGlobalVar("total"); mc.setGlobalVar("total",total+1); -
isChecked(id)
-
Tests if the item is checked.
Parameters:
Name Type Description iditemId (Optional) The id of the item. If no id is provided then it gets the value of the currently selected item. Returns:
- Returns true if the item is checked. Returns false if the item is not checked.- Type
- boolean
Examples
// Example 1 - Tests if the item with id 'gear' is checked. var isChecked = mc.isChecked("gear");// Example 2 - Tests if the currentely selected item is checked. var isChecked = mc.isChecked();
-
getValue(id)
-
Gets the value if the item is checked.
Parameters:
Name Type Description iditemId (Optional) The id of the item. If no id is provided then it gets the value of the currently selected item. Returns:
- Returns the value of the item.- Type
- number | string | Object
Examples
// Example 1 - Get value of item with id yesNoApproach. var itemValue = mc.getValue("yesNoApproach");// Example 2 // Set sections and items visible. Since no parameter was provided to getValue then it gets the value of the current item which is a Yes / No item type. // There is an SketchPad item with an id of 'craft'. // There is a List with an id of 'approach'. This will make all Sections and Items in the List with an id 'approach' visible. var itemValue = mc.getValue(); if (itemValue === "yes") { mc.setVisible("craft"); mc.setVisible("approach"); } else { mc.setHidden("craft"); mc.setHidden("approach"); } -
getItemIndex(item)
-
Sets a List, Section or Item visible.
Parameters:
Name Type Description itemstring The Item object. Example
var itemIndex = mc.getItemIndex(item);
-
getTotalItems()
-
Get the number of items in a section.
Example
var numItems = mc.getTotalItems();
-
setVisible(id, visible)
-
Sets a List, Section or Item visible.
Parameters:
Name Type Default Description idstring The id of the List, Section or Item. visibleboolean true (Optional) Set to true for visible, false for hidden. The default is true. Example
var itemValue = mc.getValue(); if (itemValue === "yes") { mc.setVisible("craft"); mc.setVisible("approach"); } else { mc.setHidden("craft"); mc.setHidden("approach"); } -
setHidden(id)
-
Sets a List, Section or Item hidden.
Parameters:
Name Type Description idstring The id of the List, Section or Item. Example
var itemValue = mc.getValue(); if (itemValue === "yes") { mc.setVisible("craft"); mc.setVisible("approach"); } else { mc.setHidden("craft"); mc.setHidden("approach"); } -
isVisible(id)
-
Tests if the item is visible.
Parameters:
Name Type Description iditemId The id of the item. Example
// Example var softFieldTakeoffVisible = mc.isVisible("softFieldTakeoff"); -
setGroupVisible(groupName, visible)
-
Sets a Group visible.
Parameters:
Name Type Default Description groupNamegroupName The group name of the group. visiblegroupName true (Optional) Set to true for visible, false for hidden. The default is true. Examples
// Example 1 var ifrYesNoQuestion = mc.getValue("ifrYesNoQuestion"); if (ifrYesNoQuestion === "yes") { mc.setGroupVisible("ifr"); } else { mc.setGroupHidden("ifr"); }// Example 2 mc.setGroupVisible("ifr",mc.getValue("ifrYesNoQuestion")?true:false); -
setGroupHidden(groupName)
-
Sets a Group hidden.
Parameters:
Name Type Description groupNamegroupName The group name of the group. Examples
// Example 1 var ifrYesNoQuestion = mc.getValue("ifrYesNoQuestion"); if (ifrYesNoQuestion === "yes") { mc.setGroupVisible("ifr"); } else { mc.setGroupHidden("ifr"); }// Example 2 mc.setGroupHidden("ifr"); -
setListTitle(id, title, groupName)
-
Sets the title of a List.
Parameters:
Name Type Description idstring The id of the List. titlestring The title of the List. groupNamegroupName The group name of the group. Example
// Example mc.setListTitle("preflight","Preflight"); -
setSectionTitle(id, title)
-
Sets the title of a Section.
Parameters:
Name Type Description idstring The id of the Section. titlestring The title of the Section. Example
// Example mc.setSectionTitle("runup","Run Up"); -
getItemLabel1(id)
-
Get the label 1 of an Item.
Parameters:
Name Type Description idstring The id of the Item. Setting the id to null will set the label of the currently selected item. Examples
// Example 1 var label1= mc.getItemLabel1("error1");// Example 2 var label1 = mc.getItemLabel1("route"); -
setItemLabel1(id, label)
-
Sets the label 1 of an Item.
Parameters:
Name Type Description idstring The id of the Item. Setting the id to null will set the label of the currently selected item. labelstring The label 1 of the Item. Examples
// Example 1 mc.setItemLabel1("error1","The value you entered " + mc.getValue("item1") + " is invalid.");// Example 2 mc.setItemLabel1("route","Route: " + mc.getValue("departure") + " " + mc.getValue("arrival")); -
getItemLabel2(id)
-
Get the label 2 of an Item.
Parameters:
Name Type Description idstring The id of the Item. Setting the id to null will set the label of the currently selected item. Examples
// Example 1 var label2= mc.getItemLabel1("error1");// Example 2 var label2 = mc.getItemLabel1("route"); -
setItemLabel2(id, label)
-
Sets the label 2 of an Item. Setting the id to null will set the label of the currently selected item.
Parameters:
Name Type Description idstring The id of the Item. labelstring The label 2 of the Item. Example
// Example if (mc.getValue("questionYesNo") === "yes") { mc.setItemLabel2("feedback","Correct!"); } else { mc.setItemLabel2("feedback","Incorrect"); } -
getItemLabel3(id)
-
Get the label 3 of an Item.
Parameters:
Name Type Description idstring The id of the Item. Setting the id to null will set the label of the currently selected item. Examples
// Example 1 var label3= mc.getItemLabel1("error1");// Example 2 var label3 = mc.getItemLabel1("route"); -
setItemLabel3(id, label)
-
Sets the label 3 of an Item. Setting the id to null will set the label of the currently selected item.
Parameters:
Name Type Description idstring The id of the Item. labelstring The label 3 of the Item. Example
// Example mc.setItemLabel1("routeSummary","**Route Summary**"); mc.setItemLabel2("routeSummary","Departure: " + mc.getValue("departure")); mc.setItemLabel3("routeSummary","Arrival: " + mc.getValue("arrival"));