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
Expand Up @@ -16,18 +16,18 @@ The LED API allows you to control the LED.

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)
3. Create a new directory **webworks.bbalert.led** in the **ext** directory.
4. Copy **output/webworks.bbalert.led/ledJnext.so** to **/path/to/sdk/ext/webworks.bbalert.led/device/ledJnext.so**
5. Copy everything in **javascript_src** to **/path/to/sdk/ext/webworks.bbalert.led/**
3. Create a new directory **community.led** in the **ext** directory.
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/community.led/**

## Required Feature ID
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

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

Parameters:
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:
request id - used to reference the LED request

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

Example:

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

## Disclaimer
Expand Down
4 changes: 2 additions & 2 deletions BB10/LED/TestApplication/config.xml
Expand Up @@ -4,10 +4,10 @@
version="1.0.0.5" id="helloworld" xml:lang="en">
<author href="http://www.example.com/"
rim:copyright="Copyright 1998-2012 My Corp">My Corp</author>
<name>helloWorld</name>
<name>Hello LED</name>
<content src="index.html"/>
<rim:permissions>
<rim:permit>access_led_control</rim:permit>
</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>
4 changes: 2 additions & 2 deletions BB10/LED/TestApplication/index.html
Expand Up @@ -42,14 +42,14 @@
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 buttonContent = document.createTextNode("Stop Led - " + id);
button.appendChild(buttonContent);
button.setAttribute("id", id);
button.onclick = function (){
webworks.bbalert.led.stopLed(this.id);
community.led.stopLed(this.id);
stopButtons.removeChild(this);

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

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

0 comments on commit eaeda7e

Please sign in to comment.