How to control NetImaging in JavaScript.

NetImaging supports several functions available in JavaScript.
To call a function in JavaScript do the following:

  1. Specify the applet attribute "name", for example
        <applet name="imaging" archive="imaging.jar" ... >
            ... parameters ...
        </applet>
    
  2. Use this name to access the applet as follows:
        <script language="javascript">
            var imaging = document.applets['imaging'];
            imaging.someFunc(); // call someFunc()
        </script>
    

Here is the list of available functions:

getImageWidth() Returns the current image width.
getImageHeight() Returns the current image height.
setSelect(spec) Displays the selecion box. The format of the "spec" parameter corresponds to the applet parameter select, for example: setSelect("10,10,400,300"); The specified selector is set regardless of the current proportion constraint. But the selector will be adjusted if the user manipulates it with the mouse.
getSelect() Returns the current selector state. The format of the returned string is: "x,y,width,height". You can parse the returned string with the method split(). If there is no selection the empty string is returned.
setProportion(spec) Specifies the proportion constraint. The format of the "spec" parameter corresponds to the applet's parameter proportion, for example: setProportion("4,3"); This function removes the current selector (if it exists).
isChanged() Returns true if the user has changed the original image, and false otherwise.
upload(saveURL, jpeg_quality) Triggers the upload (save) process (i.e. it acts similar to the "Save" button). Note: You can hide the regular "Save" button from the top panel using the applet parameter visible_buttons.
addUploadField(name, value) Appends a user defined field in the upload (save) request. This function should be invoked before the function upload().