//NumberOfTerminals local code let drop = this.getField("NumberOfTerminals").value; //Tests for 1 or 2 digits at the beginning of the string, then looks for the end of the string, children will fail this test let parentMask = /^[\d]{1,2}$/; //Tests for 1 or 2 digits at the beginning of the string, then looks for a dash, then 1 or 2 digits, then the end let childMask = /^[\d]{1,2}-[\d]{1,2}$/; //Tests for 1 or 2 digits at the beginning of the string, then possibly (allowed to fail) a dash and 1 or 2 digits, then the end let tapsMask = /^\d{1,2}(-\d{1,2})?$/; //Creates an array of all layer names let layerList = this.getOCGs(); //this loop will cycle through each layer name and perform the following for each for (let i = 0; i < layerList.length; i++) { //creates a variable to hold the current layer name for testing var fname = layerList[i].name; //checks to see if it is a numbered layer, then if name is just a number, checks against main dropdown for greater than OR if the substring before the dash in the layer name is greater than the dropdown if (tapsMask.test(fname) && (fname > drop || fname.substring(0, fname.indexOf("-")) > drop)) { //if match, turn off layer layerList[i].state = false; layerList[i].initstate = false; //If parent fails the previous, and is NOT greater than } else if (parentMask.test(fname)) { //Turn it on layerList[i].state = true; layerList[i].initstate = true; //if it fails all previous and is a child layer, this works because all parent and children greater than the main are already off } else if (childMask.test(fname)) { //All the children whos group is equal or less than dropdown are going to pass what group they belong to var currentTap = fname.substring(0, fname.indexOf("-")); //Uses group name to grab the value of the associated dropdown, compares the substring after the dash. If the sub is greater than if (fname.substring(fname.indexOf("-") + 1) > this.getField("NumberOfTaps" + currentTap).value) { //Turn it off layerList[i].state = false; layerList[i].initstate = false; //otherwise, turn on } else { layerList[i].state = true; layerList[i].initstate = true; } } }