Permalink
Browse files

changed name space to community.led / added javascript error handling…

… for hexadecimal input
  • Loading branch information...
1 parent 7a7004f commit eaeda7ee5fd824a97386ff56a9882dd5fc4d5704 Andy Wu committed Oct 16, 2012
View
@@ -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"
@@ -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
@@ -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>
@@ -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);
};
@@ -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]));
}
@@ -1,5 +1,5 @@
{
"global": false,
- "namespace": "webworks.bbalert.led",
+ "namespace": "community.led",
"dependencies": []
}

0 comments on commit eaeda7e

Please sign in to comment.