hed_jsdk

  svn

hed_jsdk
Search:
 
This is the API documentation for the HED JavaScript Development Kit (hed_jsdk).
To understand this API it is necessary to take into account some important concepts:
  • Except for the specific cases documented, most of the functions do not give the result of the operation back as a returned value, they use the callback concept instead: when the operation is finished, the result is returned by calling the appropriate callback function. Thus, most of the functions receive these two arguments:
    • fCallbackSuccess: the callback function that is called when the operation ends successfully. In most cases it receives as a parameter an object with the result of the operation, or the string 'ok' if the operation has no result. If not specified, the 'ok' string is the default behavior.
    • fCallbackError: the callback function that is called when the operation ends with an error. In most cases it receives as a parameter an error object with three properties:
      • class: middleware class that caused the error.
      • code: internal code for the error.
      • data: data associated to the error.
    For instance, the following code requests the MAC addresses of the system and logs them using the console.log command:

     	 	 
                                HED.configuration.get_mac_address( 	 	 
                                   function(oResult){ 	 	 
                                      for(var i in oResult){ 	 	 
                                         console.log('MAC for interface '+i+' is '+oResult[i]); 	 	 
                                      } 	 	 
                                   }, 	 	 
                                   function(oError){ 	 	 
                                      console.log('Operation ends with error', oError); 	 	 
                                   }); 	 	 
                            

    Another example, the following code shows the MAC addresses on screen by appending them to the dom of the page:

     	 	 
                                <a href="#" onclick="showMAC">Load MAC</a>" 	 	 
                                <div id="MAC"> <!-- --> </div> 	 	 
                                <script type="text/javascript"> 	 	 
                                   function showMAC(){ 	 	 
                                      HED.configuration.get_mac_address( 	 	 
                                         function(oResult){ 	 	 
                                            //Clean the div 	 	 
                                            #MAC.html(''); 	 	 
    
                                            //Add the result. 	 	 
                                            for(var i in oResult){ 	 	 
                                            #MAC.append('<span id="interface">'+i+'</span>'+ 	 	 
                                               '<span id="value">'+oResult[i]+'</span>'); 	 	 
                                        } 	 	 
                                     }, 	 	 
                                     function(oError){ 	 	 
                                        #MAC.html("<span id='error'>Error, retry it</span>"); 	 	 
                                        console.error(oError); 	 	 
                                     } 	 	 
                                  ); 	 	 
                               } 	 	 
                            </script> 	 	 
                            

  • The middleware date object is the format used by the system to manage dates, this is an object with the following fields:
    • year <integer>: the year number.
    • month <integer>: the month number (starting in 0, December is 11).
    • day <integer>: the day number (starting in 0).
    • hour <integer>: the hours component.
    • minute <integer>: the minutes component.
    • second <integer>: the seconds component.
    On the HED.utils section there are several functions to manage and convert this object to an equivalent JS object date format.

Copyright © 2014 Interoud. All rights reserved.