Hardware Reference
In-Depth Information
Solution
Recipe 6.5 shows how to use BoneScript in a browser to read GPIO pins on the Bone, but it
requires the use of an external website. This recipe shows how to move from jsfiddle to the
Bone, with a few simple steps.
Go to a working jsfiddle page (such as the one shown in Figure 6-4 ) and do the following:
1. In the lower-left panel, select all the BoneScript code and copy it to a file. In this
case, call it jQueryDemo.js . Save it in the serverExample directory.
2. From the upper-left panel, select all the HTML code and copy it to
jQueryDemo.html in the serverExample directory.
3. We need to add code to inform the browser where to find the external libraries we
are using. Edit jQueryDemo.html and before your HTML, add the following lines:
<html>
<head>
<title> BoneScript jQuery Demo </title>
<script src= "static/jquery.js" ></script>
<script src= "static/bonescript.js" ></script>
<script src= "jQueryDemo.js" ></script>
</head>
<body>
4. Add the following lines after your HTML:
</body>
</html>
5. Open http://192.168.7.2/serverExample/jQueryDemo.html , and you'll now see
your values in your own web page.
NOTE
There are several useful JavaScript libraries already located in /var/lib/cloud9/static , and this
recipe makes use of a couple of them here.
Search WWH ::




Custom Search