Skip to content

Commit

Permalink
changed name space to community.led / added javascript error handling…
Browse files Browse the repository at this point in the history
… for hexadecimal input
  • Loading branch information
Andy Wu committed Oct 16, 2012
1 parent 7a7004f commit eaeda7e
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
16 changes: 8 additions & 8 deletions BB10/LED/README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ The LED API allows you to control the LED.


1. Clone the repo to your local machine 1. Clone the repo to your local machine
2. Locate your BlackBerry WebWorks SDK **C:\Program Files\Research In Motion\BlackBerry 10 WebWorks SDK <version>\Framework\ext** (Windows) or **~/SDKs/BlackBerry 10 WebWorks SDK <version>/Framework/ext** (Mac) 2. Locate your BlackBerry WebWorks SDK **C:\Program Files\Research In Motion\BlackBerry 10 WebWorks SDK <version>\Framework\ext** (Windows) or **~/SDKs/BlackBerry 10 WebWorks SDK <version>/Framework/ext** (Mac)
3. Create a new directory **webworks.bbalert.led** in the **ext** directory. 3. Create a new directory **community.led** in the **ext** directory.
4. Copy **output/webworks.bbalert.led/ledJnext.so** to **/path/to/sdk/ext/webworks.bbalert.led/device/ledJnext.so** 4. Copy **output/community.led/ledJnext.so** to **/path/to/sdk/ext/community.led/device/ledJnext.so**
5. Copy everything in **javascript_src** to **/path/to/sdk/ext/webworks.bbalert.led/** 5. Copy everything in **javascript_src** to **/path/to/sdk/ext/community.led/**


## Required Feature ID ## Required Feature ID
Whenever you use the below feature id in any of your WebWorks applications this extension will be loaded for use. Whenever you use the below feature id in any of your WebWorks applications this extension will be loaded for use.


<feature id="webworks.bbalert.led" required="true" version="1.0.0.0" /> <feature id="community.led" required="true" version="1.0.0.0" />


## Summary ## Summary


var id = webworks.bbalert.led.startLed([String: color], [String: blinkCount]) var id = community.led.startLed([String: color], [String: blinkCount])


Parameters: Parameters:
color: hex string with with format "RRGGBB", default: "FF0000" color: hex string with with format "RRGGBB", default: "FF0000"
Expand All @@ -36,15 +36,15 @@ blinkCount: String Integer >=0, default: "0" (0 means Blink indefinitely until s
Return: Return:
request id - used to reference the LED request request id - used to reference the LED request


webworks.bbalert.led.stopLed([String:id]) community.led.stopLed([String:id])
Parameter: Parameter:
id: request id - given when startLed command was issued. id: request id - given when startLed command was issued.


Example: Example:


<script type="text/javascript" > <script type="text/javascript" >
var id = webworks.bbalert.led.startLed("FFFF00", "10"); var id = community.led.startLed("FFFF00", "10");
webworks.bbalert.led.stopLed(id) community.led.stopLed(id)
</script> </script>


## Disclaimer ## Disclaimer
Expand Down
4 changes: 2 additions & 2 deletions BB10/LED/TestApplication/config.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
version="1.0.0.5" id="helloworld" xml:lang="en"> version="1.0.0.5" id="helloworld" xml:lang="en">
<author href="http://www.example.com/" <author href="http://www.example.com/"
rim:copyright="Copyright 1998-2012 My Corp">My Corp</author> rim:copyright="Copyright 1998-2012 My Corp">My Corp</author>
<name>helloWorld</name> <name>Hello LED</name>
<content src="index.html"/> <content src="index.html"/>
<rim:permissions> <rim:permissions>
<rim:permit>access_led_control</rim:permit> <rim:permit>access_led_control</rim:permit>
</rim:permissions> </rim:permissions>
<feature id="webworks.bbalert.led" required="true" version="1.0.0.0"/> <feature id="community.led" required="true" version="1.0.0.0"/>
</widget> </widget>
4 changes: 2 additions & 2 deletions BB10/LED/TestApplication/index.html
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
currColor = parseInt(colors[i].value, 16) | currColor; currColor = parseInt(colors[i].value, 16) | currColor;
} }
} }
var id = webworks.bbalert.led.startLed(currColor.toString(16), document.getElementById("blinkCount").value); var id = community.led.startLed(currColor.toString(16), document.getElementById("blinkCount").value);


var button = document.createElement("button") var button = document.createElement("button")
var buttonContent = document.createTextNode("Stop Led - " + id); var buttonContent = document.createTextNode("Stop Led - " + id);
button.appendChild(buttonContent); button.appendChild(buttonContent);
button.setAttribute("id", id); button.setAttribute("id", id);
button.onclick = function (){ button.onclick = function (){
webworks.bbalert.led.stopLed(this.id); community.led.stopLed(this.id);
stopButtons.removeChild(this); stopButtons.removeChild(this);


}; };
Expand Down
5 changes: 5 additions & 0 deletions BB10/LED/javascript_src/index.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ module.exports = {
flashLedStart: function (success, fail, args, env) { flashLedStart: function (success, fail, args, env) {
try { try {
var stringArgs = ""; var stringArgs = "";
if(isNaN(parseInt(JSON.parse(decodeURIComponent(args["color"])), 16))){
fail(-1, "invalid Hexdecimal color code");
return;
}

for (key in args) { for (key in args) {
stringArgs += " " + JSON.parse(decodeURIComponent(args[key])); stringArgs += " " + JSON.parse(decodeURIComponent(args[key]));
} }
Expand Down
2 changes: 1 addition & 1 deletion BB10/LED/javascript_src/manifest.json
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
{ {
"global": false, "global": false,
"namespace": "webworks.bbalert.led", "namespace": "community.led",
"dependencies": [] "dependencies": []
} }
File renamed without changes.

0 comments on commit eaeda7e

Please sign in to comment.