天天看点

Script to accelerate your accessibility test in Adobe Designer form - my IP

Put this script in the body page.

var dum = 0;

startTraverse(dum);

function startTraverse( dummy )

{

       var nodes = this.nodes;

       var length = nodes.length;

       for ( var i = 0; i < length;i++)

       {

               var subnode = nodes.item(i);

               traver(subnode.somExpression);

       }

}

function traver( folder ) // folder should be a subform's name; type:string

       //xfa.host.messageBox("reslove:" + folder);

       var node = xfa.resolveNode(folder);

       var subnodes = node.nodes;

       var length = subnodes.length;

       for(var i = 0;i < length;i++)

               //xfa.host.messageBox("name:" + subnodes.item(i).name);

               var classname = subnodes.item(i).className;

               var nodename = subnodes.item(i).name;

               if( classname == "subform")

               {

                       //xfa.host.messageBox("it is a subform");

                       //xfa.host.messageBox(subnodes.item(i).somExpression);

                       var passi = subnodes.item(i).somExpression;

                       traver(passi);

               }

               else

                       //xfa.host.messageBox("not a subform:" + nodename);

                       if(( classname == "field") || ( classname == "draw"))

                       {

                               isFieldSettingRight(subnodes.item(i));

                               //xfa.host.messageBox("acess:" + subnodes.item(i).access);

                               var setting = subnodes.item(i).assist.speak.priority;

                               var sompath = subnodes.item(i).somExpression;

                               //xfa.host.messageBox("name:" + nodename + "setting:" + setting);

                               //xfa.host.messageBox("sompath:" + sompath);

                       }

function isFieldSettingRight( folder ) // folder should be a non-subform's name type:template path)

       //xfa.host.messageBox("in isFunction!");

       var type = folder.className;

       var setting = folder.assist.speak.priority;

       var isDisable = folder.assist.speak.disable;

       if( type == "draw" )

               if( isDisable != 1 )

               {      

                       xfa.host.messageBox("wrong setting:" + setting + "Disable?:" + isDisable);

                       xfa.host.messageBox("field:     " + folder.somExpression + "    wrong accessibility setting!:" + setting   +"      It should be set to NONE!");

                       return 0;

       else if ( type == "field" )

               if( folder.presence == "hidden" )

                       if( isDisable != 1 )

                               xfa.host.messageBox("Field:      " + folder.somExpression + "        Wrong acessibility setting!:" + setting+"        It should be set to NONE!");

                               return 0;

               }              

               var captionsetting = folder.caption.reserve;  // two condition -1 or positive number

               //xfa.host.messageBox("caption reserve:" + captionsetting);

               //xfa.host.messageBox("setting:" + setting);

               if ( captionsetting != "-1in" ) // has caption

                       //xfa.host.messageBox("into the condition that has caption!should set to caption!");

                       if( setting != "caption" )

                               xfa.host.messageBox("Field:     " + folder.somExpression + "     should set to Caption");

       return 1;

继续阅读