HowTo:  Validate an ArcGIS for Local Government JavaScript configuration file

相关信息
Article ID: 40389
Software:
ArcGIS for Local Government 10.0, 10.1, 10.2
Platforms: N/A

问题描述
The ArcGIS for Local Government web applications have started to use JavaScript-based configuration files so that the contents of the file may be checked using JavaScript validation tools. This can be very helpful for troubleshooting or for finding errors such as missing JavaScript punctuation.

Instructions provided describe how to validate these configuration files.
已邀请:

易智瑞技术支持

赞同来自:

解决方案
Any JavaScript validation tool may be used. In general, one submits the configuration file to the validator or copies the contents of the configuration file into a form on a validation web site. One repeats the cycle of editing and validating until validation is successful.

The procedure below shows an example using a validation website called
JSLint.

Because JSLint also concerns itself with JavaScript formatting, formatting complaints can obscure true JavaScript errors. In order to be able to run JSLint and get no errors, we recommend that the configuration file's JavaScript be first run through a formatter to 'beautify' it. An example beautifier website is
JSBeautifier.
  1. Go to the JSBeautifier website and paste the configuration file’s contents into the box that has brown text beginning with '// This is just a sample script...'
  2. Uncheck the 'Preserve empty lines' option, and click the 'Beautify JavaScript or HTML' button to format the contents.
  3. Select the formatted contents (CTRL+A) and copy them.
  4. Go to the JSLint web site and paste the formatted contents into the box that has the light text '// Paste quality code here'.
  5. Near the bottom of the JSLint screen, type 'dojo' (without quotes) into the box that has the light text 'predefine global variables here'.
  6. Click the large blue button labeled 'JSLint'.
  7. Repeat steps 1 through 6 until JSLint doesn't report any errors.
     For removing errors, it is helpful to have a text editor available that allows jumping to line numbers.


创建及修改时间
Created: 6/19/2012

Last Modified: 9/10/2014
原文链接
http://support.esri.com/en/kno ... 40389

要回复问题请先登录注册