JavaScript

From SpinetiX Support Wiki

Jump to: navigation, search
"Info"
The HMP conforms with the ECMAScript Standard (ECMA-262) and implements SpiderMonkey as JavaScript engine.

Contents

ECMAScript

JavaScript engine and core objects

As JavaScript engine, the HMP uses the open-source SpiderMonkey JavaScript engine, which is currently maintained by the Mozilla Foundation.

  • As of firmware 3.0.0 the HMP uses version 1.8.5 of SpiderMonkey, firmware 2.2.x uses version 1.8.0.
  • SpiderMonkey 1.8.5 implements ECMAScript 5, 1.8.0 implements ECMAScript 3.
  • To get started with the JavaScript language, refer to Mozilla's JavaScript Guide. You can also check out W3Schools' JavaScript Tutorial or JavaScript Wikibook.
  • For the complete documentation of JavaScript language features, refer to the JavaScript Reference.

The following are particularly relevant to digital signage applications:

Supported APIs

  • New APIs introduced in 3.0 firmware:

Including the JavaScript code

To include JavaScript code inside an SVG file, the <script> element is used. The JavaScript code can either be placed inline in the <script> element (as character data) or as an external resource, referenced through xlink:href attribute.

<script xlink:href="http://download.spinetix.com/spxjslibs/jSignage.js" />
 
<script>
   <![CDATA[
       // Your code goes here ...
   ]]>
</script>

In case of interactive projects, the JavaScript code can also be included using the <handler> element in a similar manner as above.