Skip to content
This repository has been archived by the owner on Sep 25, 2018. It is now read-only.

Commit

Permalink
Updated README to support AMD.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeard4 committed Apr 1, 2013
1 parent 5d0754c commit 3b4227f
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions README.md
Expand Up @@ -121,8 +121,6 @@ There are then **4 steps** that must be performed to go from an SCXML document t
<script src="http://cdnjs.cloudflare.com/ajax/libs/es5-shim/1.2.4/es5-shim.min.js"></script> <script src="http://cdnjs.cloudflare.com/ajax/libs/es5-shim/1.2.4/es5-shim.min.js"></script>
<script type="text/javascript" src="http://jbeard4.github.com/SCION/builds/latest/scion-min.js"></script> <script type="text/javascript" src="http://jbeard4.github.com/SCION/builds/latest/scion-min.js"></script>
<script> <script>
var scion = require('scion');
$(document).ready(function(){ $(document).ready(function(){
var rect = document.getElementById("rect"); var rect = document.getElementById("rect");
Expand Down Expand Up @@ -223,20 +221,30 @@ Furthermore, for the `onTransition` callback, argument `targetStateIds` will be


# Usage in Browser # Usage in Browser


Add the following script tags to your web page: Add the following script tags to your web page, which will make SCION available as a global variable `scion`:


```html ```html
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/es5-shim/1.2.4/es5-shim.min.js"></script> <script src="http://cdnjs.cloudflare.com/ajax/libs/es5-shim/1.2.4/es5-shim.min.js"></script>
<script type="text/javascript" src="http://jbeard4.github.com/SCION/builds/latest/scion.js"></script> <script type="text/javascript" src="http://jbeard4.github.com/SCION/builds/latest/scion.js"></script>
``` ```


SCION is also available as an AMD module, so if you are using RequireJS in your page, then you can do the following:

```html
<script src="http://cdnjs.cloudflare.com/ajax/libs/es5-shim/1.2.4/es5-shim.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/require-jquery/0.25.0/require-jquery.min.js "></script>

require(["http://jbeard4.github.com/SCION/builds/latest/scion-min.js"],function(scion){
//use SCION here
});
```

Note that SCION assumes the presence of jQuery to handle cross-browser XMLHTTPRequest, however an alternative Ajax library could instead be used. This is set up in the following way: Note that SCION assumes the presence of jQuery to handle cross-browser XMLHTTPRequest, however an alternative Ajax library could instead be used. This is set up in the following way:


```javascript ```javascript
//perform this setup once, before SCION is used //perform this setup once, before SCION is used
var platform = require('platform'); scion.platformModule.platform.ajax = {
platform.ajax = {
get : function(url,successCallback,dataType){ get : function(url,successCallback,dataType){
//call your preferred Ajax library here to do HTTP GET //call your preferred Ajax library here to do HTTP GET
//if dataType is 'xml', the Ajax response must be parsed as DOM //if dataType is 'xml', the Ajax response must be parsed as DOM
Expand Down

0 comments on commit 3b4227f

Please sign in to comment.