Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

New BBJamAsia folder

  • Loading branch information...
commit 103abf22ec8cb0f2bf831425bc6f47b77abb3ca8 1 parent fbf3660
Adam Stanley authored
Showing with 15,317 additions and 0 deletions.
  1. +39 −0 2012-BlackBerryJam-Asia/JAM843/README.md
  2. BIN  2012-BlackBerryJam-Asia/JAM843/app/device/wic.bar
  3. BIN  2012-BlackBerryJam-Asia/JAM843/app/simulator/wic.bar
  4. +17 −0 2012-BlackBerryJam-Asia/JAM843/load.bat
  5. +18 −0 2012-BlackBerryJam-Asia/JAM843/load.sh
  6. +44 −0 2012-BlackBerryJam-Asia/JAM843/source/advanced.html
  7. +42 −0 2012-BlackBerryJam-Asia/JAM843/source/config.xml
  8. +47 −0 2012-BlackBerryJam-Asia/JAM843/source/console.html
  9. +5,126 −0 2012-BlackBerryJam-Asia/JAM843/source/css/bbui-0.9.4.css
  10. +36 −0 2012-BlackBerryJam-Asia/JAM843/source/css/elements.css
  11. +46 −0 2012-BlackBerryJam-Asia/JAM843/source/elements.html
  12. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/actionBar/cog_dark_theme.png
  13. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/background.png
  14. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/button/dropDownRight.png
  15. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/button/pillButtonRight.png
  16. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/hippo.png
  17. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icon.png
  18. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon1.png
  19. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon10.png
  20. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon11.png
  21. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon12.png
  22. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon13.png
  23. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon14.png
  24. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon15.png
  25. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon16.png
  26. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon17.png
  27. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon18.png
  28. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon19.png
  29. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon2.png
  30. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon20.png
  31. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon21.png
  32. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon22.png
  33. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon23.png
  34. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon24.png
  35. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon25.png
  36. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon3.png
  37. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon4.png
  38. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon5.png
  39. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon6.png
  40. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon7.png
  41. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon8.png
  42. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon9.png
  43. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/loading1.gif
  44. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/menu_icons/icon1.png
  45. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/menu_icons/icon2.png
  46. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/menu_icons/icon3.png
  47. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/tabs/address.png
  48. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/tabs/contact.png
  49. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/tabs/phone.png
  50. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/tabs/tab.png
  51. BIN  2012-BlackBerryJam-Asia/JAM843/source/images/tabs/tabRight.png
  52. +95 −0 2012-BlackBerryJam-Asia/JAM843/source/index.html
  53. +68 −0 2012-BlackBerryJam-Asia/JAM843/source/js/advanced.js
  54. +7,830 −0 2012-BlackBerryJam-Asia/JAM843/source/js/bbui-0.9.4.js
  55. +52 −0 2012-BlackBerryJam-Asia/JAM843/source/js/console.js
  56. +40 −0 2012-BlackBerryJam-Asia/JAM843/source/js/elements.js
  57. +60 −0 2012-BlackBerryJam-Asia/JAM843/source/js/profiles.js
  58. +213 −0 2012-BlackBerryJam-Asia/JAM843/source/js/resources.js
  59. +60 −0 2012-BlackBerryJam-Asia/JAM843/source/js/sources.js
  60. +1,258 −0 2012-BlackBerryJam-Asia/JAM843/source/js/webworks.js
  61. +28 −0 2012-BlackBerryJam-Asia/JAM843/source/main.html
  62. +36 −0 2012-BlackBerryJam-Asia/JAM843/source/profiles.html
  63. +74 −0 2012-BlackBerryJam-Asia/JAM843/source/resources.html
  64. BIN  2012-BlackBerryJam-Asia/JAM843/source/settings.png
  65. +37 −0 2012-BlackBerryJam-Asia/JAM843/source/sources.html
  66. +43 −0 2012-BlackBerryJam-Asia/JAM843/source/timelinenetwork.html
  67. +8 −0 2012-BlackBerryJam-Asia/README.md
View
39 2012-BlackBerryJam-Asia/JAM843/README.md
@@ -0,0 +1,39 @@
+# JAM843 Hands-on Lab
+
+## Session
+Optimization and Performance for Web Developers
+
+## Description
+Get some kick out of your web apps. This lab will walk you through BlackBerry® 10 web application samples, showing tips and tricks for debugging and optimizing for performance. Follow along as you learn more about remote web inspector including such profiling and debugging features as: timeline, live editing and setting XHR breakpoints. This session is ideal for developers who want to refine their skills in app development to speed up development cycles and get the best performance from their web apps.
+
+## Key-Takeaways
+Learn coding and debugging tips and tricks to improve performance in your web apps
+
+## Presented at
+[BlackBerry Jam Asia](http://www.blackberryjamconference.com/asia) (Nov 29-30, 2012)
+
+## Created and Presented By
+* [Adam Stanley](https://twitter.com/#!/n_adam_stanley)
+* [Justin Lee](https://twitter.com/#!/triplez82)
+
+## Agenda and format (2 hrs)
+All content for this presentation was made available as a PDF and **sample code** for attendees to download at the start of the session.
+Attendees are encouraged to complete tasks in order but can do so at their own pace. Each task has beginner, intermediate and advanced materials.
+Speakers are available to assist attendees understand the requirements of the lab and guide them through completing each step if they get stuck.
+
+## Lab Setup
+This lab requires that attendees have the following development tools available:
+* [Chrome desktop browser](https://www.google.com/chrome)
+* [BlackBerry 10 WebWorks SDK](https://developer.blackberry.com/html5/download/)
+* BlackBerry 10 Dev Alpha A or B, running OS version 10.0.9.388 or higher.
+
+Load the wic.bar sample, located within the /app folder, onto your BlackBerry 10 Dev Alpha device:
+```
+1) Enable development mode on your device (Settings --> Security --> Development Mode)
+2) Connect your BlackBerry Dev Alpha device to your computer via USB
+3) Clone or download this repo to a local folder such as C:\JAM843
+4) Open a command prompt (Start --> Run ... --> cmd)
+5) cd C:\JAM843
+6) Load the app by running the following script: load_win.bat <device IP address> <device password> (e.g. load_win.bat 169.254.0.1 pass)
+7) Confirm the wic.bar app was successfully loaded.
+```
View
BIN  2012-BlackBerryJam-Asia/JAM843/app/device/wic.bar
Binary file not shown
View
BIN  2012-BlackBerryJam-Asia/JAM843/app/simulator/wic.bar
Binary file not shown
View
17 2012-BlackBerryJam-Asia/JAM843/load.bat
@@ -0,0 +1,17 @@
+@echo off
+REM This script can be used to sideload a BAR file
+REM Dependencies: BlackBerry 10 WebWorks SDK
+REM Change the SDK variable to match the path of the WebWorks SDK installed on your machine:
+
+SET SDK=C:\Program Files\Research In Motion\BlackBerry 10 WebWorks SDK 1.0.2.9\dependencies\tools\bin
+
+IF "%1" == "" GOTO MISSINGPARAMS
+IF "%2" == "" GOTO MISSINGPARAMS
+
+"%SDK%\blackberry-deploy.bat" -package app\device\wic.bar -device %1 -installApp -password %2
+GOTO END
+
+:MISSINGPARAMS
+ECHO Missing parameters. Correct usage: load_win.bat [device ip] [device password]
+
+:END
View
18 2012-BlackBerryJam-Asia/JAM843/load.sh
@@ -0,0 +1,18 @@
+# This script can be used to sideload a BAR file
+# Dependencies: BlackBerry 10 WebWorks SDK
+# Change the tools variable to match the path of the WebWorks SDK installed on your machine:
+#
+tools=/Developer/SDKs/Research\ In\ Motion/BlackBerry\ 10\ WebWorks\ SDK\ 1.0.2.9/dependencies/tools/bin
+echo $tools
+device=$1
+password=$2
+if [[ $device == '' ]]; then
+ echo Missing parameters. Correct usage: load.sh device-ip device-pwd
+ exit
+fi
+if [[ $password == '' ]]; then
+ echo Missing parameters. Correct usage: load.sh device-ip device-pwd
+ exit
+fi
+
+blackberry-deploy -installApp -launchApp -package app/device/wic.bar -device $1 -password $2
View
44 2012-BlackBerryJam-Asia/JAM843/source/advanced.html
@@ -0,0 +1,44 @@
+<!--
+* Copyright 2012 Research In Motion Limited.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+-->
+<div data-bb-type="screen" data-bb-title="Advanced Features" data-bb-effect="fade">
+ <div data-bb-type="title" data-bb-caption="Advanced Features" data-bb-back-caption="Back"></div>
+
+ <script id="advancedJS" src="js/advanced.js"></script>
+
+ <div data-bb-type="round-panel">
+
+ <div data-bb-type="panel-header">Customize Your Web Inspector</div>
+ <div>Define various options for Web Inspector as well as allows the developer to mimic the user agent of another browser. You can access the settings through the <img src="settings.png" /> icon in the bottom right corner of Web Inspector.</div>
+ <br/>
+ <div>Ripple will need to be reloaded if the User Agent changes. Try <b>window.location.reload()</b> from the console!</div>
+ <div data-bb-type="row">
+ <div data-bb-type="button" id="btnDisplayUserAgent" onclick="showUA();">Display User Agent</div>
+ <div data-bb-type="label" id="useragent"></div>
+ </div>
+ </div>
+
+ <div data-bb-type="round-panel">
+ <div data-bb-type="panel-header">Experiments</div>
+ <div>Use experimental Web Inspector features to test advanced application features. Example: override GPS values with your own input.</div>
+ <br/>
+ <div>Experiments must be enabled when first connecting to remote Web inspector. </div>
+ <div data-bb-type="row">
+ <div data-bb-type="button" id="btnDisplayGPS" onclick="showGPS()">Display GPS</div>
+ <div data-bb-type="label" id="gps"></div>
+ </div>
+
+ </div>
+</div>
View
42 2012-BlackBerryJam-Asia/JAM843/source/config.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2012 Research In Motion Limited.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<widget xmlns="http://www.w3.org/ns/widgets"
+ xmlns:rim="http://www.blackberry.com/ns/widgets"
+ version="1.0.0.0" id="wic" xml:lang="en">
+
+ <name>WIC</name>
+ <description>The Web inspector companion application. Used to demonstrate the various capabilities of BlackBerry Remote Web inspector.</description>
+ <author>Erik Oros, Adam Stanley</author>
+
+ <content src="index.html"/>
+ <icon src="images/icon.png"/>
+
+ <rim:navigation mode="focus" />
+ <feature id="blackberry.app" />
+ <feature id="blackberry.ui.dialog" />
+
+ <feature id="blackberry.invoke"/>
+
+ <access subdomains="true" uri="http://www.joelambert.co.uk"/>
+ <access subdomains="true" uri="https://developer.blackberry.com"/>
+ <access subdomains="true" uri="http://developer.blackberry.com"/>
+
+ <rim:permissions>
+ <rim:permit>read_geolocation</rim:permit>
+ </rim:permissions>
+
+</widget>
View
47 2012-BlackBerryJam-Asia/JAM843/source/console.html
@@ -0,0 +1,47 @@
+<!--
+* Copyright 2012 Research In Motion Limited.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+-->
+<div data-bb-type="screen" data-bb-title="Console" data-bb-effect="fade">
+ <div data-bb-type="title" data-bb-caption="Console" data-bb-back-caption="Back"></div>
+
+ <script id="consoleJS" src="js/console.js"></script>
+
+ <div data-bb-type="round-panel">
+
+ <div data-bb-type="panel-header">Custom Logging</div>
+ <div>Log your own messages to the console via <b>console.log()</b>.</div>
+ <div data-bb-type="button" id="btnLogMessage" onclick="logMsg()" >Log Message</div>
+
+ <div data-bb-type="panel-header">Warnings</div>
+ <div>Log warning messages to the console via <b>console.warn()</b>.</div>
+ <div data-bb-type="button" id="btnLogWarning" onclick="logWarning()" >Log Warning</div>
+
+ <div data-bb-type="panel-header">Error Logging</div>
+ <div>Notice your page is not behaving correctly? First thing you should do is open the console and check to see if there are any runtime errors.</div>
+ <div data-bb-type="button" id="btnLogError" onclick="generateError()" >blackberry.doesntexist.doSomething();</div>
+ </div>
+
+ <div data-bb-type="round-panel">
+ <div data-bb-type="panel-header">Open Browser</div>
+ <div>Notice your page is not behaving correctly? First thing you should do is open the console and check to see if there are any runtime errors.</div>
+ <div data-bb-type="button" id="btnOpenBrowser" onclick="openBrowserBad()">Open Browser</div>
+ </div>
+
+ <div data-bb-type="round-panel">
+ <div data-bb-type="panel-header">Command Line</div>
+ <div>Need to reload the current page? Type <b>window.location.reload()</b> from the console command line. Executing <b>$0</b> in the console will give you reference to the currently selected element in the elements panel.</div>
+ </div>
+
+</div>
View
5,126 2012-BlackBerryJam-Asia/JAM843/source/css/bbui-0.9.4.css
5,126 additions, 0 deletions not shown
View
36 2012-BlackBerryJam-Asia/JAM843/source/css/elements.css
@@ -0,0 +1,36 @@
+/*
+* Copyright 2012 Research In Motion Limited.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+h2 {
+ font-weight: bold;
+ margin: 0 0;
+}
+ul {
+ list-style: none;
+}
+li {
+ padding-bottom: 1em;
+ float: left;
+ width: 45%;
+}
+div {
+ clear: both;
+}
+#layoutIssue {
+ padding: 0.5em;
+ margin: 0 5em 1em -5em;
+ border: 3px dashed black;
+}
View
46 2012-BlackBerryJam-Asia/JAM843/source/elements.html
@@ -0,0 +1,46 @@
+<!--
+* Copyright 2012 Research In Motion Limited.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+-->
+<div data-bb-type="screen" data-bb-title="Elements" data-bb-effect="fade">
+ <div data-bb-type="title" data-bb-back-caption="Back"></div>
+
+ <script id="elementsJS" src="js/elements.js"></script>
+ <link id="elementsCSS" href="css/elements.css" rel="stylesheet"/>
+
+ <div data-bb-type="round-panel">
+ <div data-bb-type="panel-header">Live DOM editing</div>
+ <div>Want to see what adding an extra character of text to an element does to the layout? Double click on target element and change its value.</div>
+ <h2>Elements panel</h2>
+ <ul>
+ <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse non arcu ligula. Ut aliquet vestibulum enim.</li>
+ <li>Duis iaculis nulla pulvinar dolor tempus a ullamcorper enim dapibus. Nam sem elit, vestibulum eget dignissim vel.</li>
+ </ul>
+ </div>
+
+ <div data-bb-type="round-panel">
+ <div data-bb-type="panel-header">Event Listeners</div>
+ <div>Button isn't working? Check to see if a button has an event handler correctly assigned to it.</div>
+ <div data-bb-type="button" id="noaction">No Action</div>
+ <div data-bb-type="button" id="cantaction" data-bb-disabled="true" onclick="alert('Clicked!');">Can't Action</div>
+ <div data-bb-type="button" id="fullaction">Full Action</div>
+ </div>
+
+ <div data-bb-type="round-panel">
+ <div data-bb-type="panel-header">DOM Properties</div>
+ <div>Element looking too wide or incorrect? Confirm the layout properties and dimension values.</div>
+ <p id="layoutIssue"> Fusce mattis magna mattis sem faucibus gravida. In id felis in tellus vulputate tincidunt. Phasellus mauris metus, interdum vel tempor eget, pellentesque quis dolor. Phasellus quis dapibus lectus. </p>
+ </div>
+
+</div>
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/actionBar/cog_dark_theme.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/background.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/button/dropDownRight.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/button/pillButtonRight.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/hippo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon10.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon11.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon12.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon13.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon14.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon15.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon16.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon17.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon18.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon19.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon20.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon21.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon22.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon23.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon24.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon25.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon4.png
Diff not rendered
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon5.png
Diff not rendered
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon6.png
Diff not rendered
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon7.png
Diff not rendered
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon8.png
Diff not rendered
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/icons/icon9.png
Diff not rendered
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/loading1.gif
Diff not rendered
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/menu_icons/icon1.png
Diff not rendered
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/menu_icons/icon2.png
Diff not rendered
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/menu_icons/icon3.png
Diff not rendered
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/tabs/address.png
Diff not rendered
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/tabs/contact.png
Diff not rendered
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/tabs/phone.png
Diff not rendered
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/tabs/tab.png
Diff not rendered
View
BIN  2012-BlackBerryJam-Asia/JAM843/source/images/tabs/tabRight.png
Diff not rendered
View
95 2012-BlackBerryJam-Asia/JAM843/source/index.html
@@ -0,0 +1,95 @@
+<!DOCTYPE html>
+<!--
+* Copyright 2012 Research In Motion Limited.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+-->
+<html>
+ <head>
+ <title>Web Inspector Companion</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <link rel="stylesheet" type="text/css" href="css/bbui-0.9.4.css"><link />
+ <script type="text/javascript" src="js/bbui-0.9.4.js"></script>
+ <script type="text/javascript" src="js/webworks.js"></script>
+ </head>
+ <body>
+ <script type="text/javascript">
+ /*global window, document, console, XMLHttpRequest, bb, onscreenready, ondomready */
+
+ function webworksready() {
+ "use strict";
+ try {
+ console.log("webworksready.");
+ document.removeEventListener("webworksready", webworksready, false);
+
+ bb.init({
+ onscreenready: function (element, id) {
+ try {
+ console.log("onscreenready - routing id selected to page");
+ if (id === "main") {
+ element.querySelector("#elements").onclick = function () {
+ bb.pushScreen('elements.html', 'elements');
+ };
+ element.querySelector("#resources").onclick = function () {
+ bb.pushScreen('resources.html', 'resources');
+ };
+ element.querySelector("#timelinenetwork").onclick = function () {
+ bb.pushScreen('timelinenetwork.html', 'timelinenetwork');
+ };
+ element.querySelector("#sources").onclick = function () {
+ bb.pushScreen('sources.html', 'sources');
+ };
+ element.querySelector("#console").onclick = function () {
+ bb.pushScreen('console.html', 'console');
+ };
+ element.querySelector("#profiles").onclick = function () {
+ bb.pushScreen('profiles.html', 'profiles');
+ };
+ element.querySelector("#advanced").onclick = function () {
+ bb.pushScreen('advanced.html', 'advanced');
+ };
+ }
+ } catch (err) {
+ console.log("onscreenready: " + err);
+ }
+ },
+ ondomready: function (element, id) {
+ try {
+ console.log("ondomready");
+ console.log(id);
+ } catch (err) {
+ console.log("ondomready: " + err);
+ }
+ }
+ });
+ bb.pushScreen('main.html', 'main');
+ } catch (err) {
+ console.log("webworksready: " + err);
+ }
+ }
+
+ function load() {
+ "use strict";
+ try {
+ console.log("load");
+ window.removeEventListener("load", load, false);
+ document.addEventListener("webworksready", webworksready, false);
+ } catch (err) {
+ console.log("load: " + err);
+ }
+ }
+
+ window.addEventListener("load", load, false);
+ </script>
+ </body>
+</html>
View
68 2012-BlackBerryJam-Asia/JAM843/source/js/advanced.js
@@ -0,0 +1,68 @@
+/*
+* Copyright 2012 Research In Motion Limited.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+function showUA() {
+ document.getElementById("useragent").innerHTML = navigator.userAgent;
+}
+
+function showGPS() {
+ navigator.geolocation.getCurrentPosition(geolocationSuccess, geolocationError);
+}
+
+function geolocationSuccess(position) {
+
+ var lat, lon, alt, acc, altAcc, head, speed, sb;
+
+ lat = position.coords.latitude;
+ lon = position.coords.longitude;
+ alt = position.coords.altitude;
+ acc = position.coords.accuracy;
+ altAcc = position.coords.altitudeAccuracy;
+ head = position.coords.heading;
+ speed = position.coords.speed;
+
+ var sb = [];
+
+ sb.push("<h3>Current Location:</h3>");
+ sb.push("<b>Latitude:</b> " + position.coords.latitude + "<br/>");
+ sb.push("<b>Longitude:</b> " + position.coords.longitude + "<br/>");
+ sb.push("<b>Altitude:</b> " + position.coords.altitude + "<br/>");
+ sb.push("<b>Accuracy:</b> " + position.coords.accuracy + "<br/>");
+ sb.push("<b>Altitude Accuracy:</b> " + position.coords.altitudeAccuracy + "<br/>");
+ sb.push("<b>Heading:</b> " + position.coords.heading + "<br/>");
+ sb.push("<b>Speed:</b> " + position.coords.speed + "<br/>");
+
+ document.getElementById("gps").innerHTML = sb.join("");
+}
+
+function geolocationError(posError) {
+ if (posError) {
+ switch(posError.code) {
+ case posError.TIMEOUT:
+ console.warn("TIMEOUT: " + posError.message);
+ break;
+ case posError.PERMISSION_DENIED:
+ console.warn("PERMISSION DENIED: " + posError.message);
+ break;
+ case posError.POSITION_UNAVAILABLE:
+ console.warn("POSITION UNAVAILABLE: " + posError.message);
+ break;
+ default:
+ console.warn("UNHANDLED MESSAGE CODE (" + posError.code + "): " + posError.message);
+ break;
+ }
+ }
+}
View
7,830 2012-BlackBerryJam-Asia/JAM843/source/js/bbui-0.9.4.js
7,830 additions, 0 deletions not shown
View
52 2012-BlackBerryJam-Asia/JAM843/source/js/console.js
@@ -0,0 +1,52 @@
+/*
+* Copyright 2012 Research In Motion Limited.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/*global window, document, console, blackberry */
+
+function generateError() {
+ "use strict";
+ blackberry.doesntexist.doSomething();
+}
+
+function logMsg() {
+ "use strict";
+ console.log("This is a message from your application.");
+}
+
+function logWarning() {
+ "use strict";
+ console.warn("Danger, Will Robertson. Danger!");
+}
+
+function onSuccess() {
+ console.log("Invocation successful.")
+}
+function onError() {
+ console.warn("Invocation failed.")
+}
+function openBrowserBad() {
+ blackberry.wrong.api.name({
+ target: "sys.browser",
+ uri: "http://www.blackberry.com"
+ }, onSuccess, onError);
+}
+
+function openBrowser() {
+ blackberry.invoke.invoke({
+ target: "sys.browser",
+ uri: "http://www.blackberry.com"
+ }, onSuccess, onError);
+}
View
40 2012-BlackBerryJam-Asia/JAM843/source/js/elements.js
@@ -0,0 +1,40 @@
+/*
+* Copyright 2012 Research In Motion Limited.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+function clickHandler(e) {
+ console.log("click");
+ alert('Clicked!');
+}
+function touchStartHandler(e) {
+ console.log("touch start");
+}
+function touchEndHandler(e) {
+ console.log("touch end");
+}
+
+function setButtonEvents() {
+ var el = document.getElementById("fullaction");
+ if (el) {
+ console.log("setting button events for full action")
+ el.addEventListener("click", clickHandler, false);
+ el.addEventListener("touchstart", touchStartHandler, false);
+ el.addEventListener("touchend", touchEndHandler, false);
+ } else {
+ console.log("fullaction element not found")
+ }
+}
+
+setTimeout(setButtonEvents, 200);
View
60 2012-BlackBerryJam-Asia/JAM843/source/js/profiles.js
@@ -0,0 +1,60 @@
+/*
+* Copyright 2012 Research In Motion Limited.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/*global window, document, console, alert, setTimeout */
+
+var running = true;
+
+function updatePhysics() {
+ "use strict";
+ var i = 0;
+ for (i = 0; i < 1000; ++i) {
+ }
+}
+
+function updateGraphics() {
+ "use strict";
+ var i = 0;
+ for (i = 0; i < 10000; ++i) {
+ }
+}
+
+function renderScene() {
+ "use strict";
+ var i = 0;
+ for (i = 0; i < 100; ++i) {
+ }
+}
+
+function runSimulation() {
+ "use strict";
+
+ var start = (new Date()).getTime();
+ var now = (new Date()).getTime()
+ while (now - start < 5000) {
+ updatePhysics();
+ updateGraphics();
+ renderScene();
+ now = (new Date()).getTime()
+ }
+ alert("Complete!");
+}
+
+function autoProfile() {
+ console.profile("runSimulation");
+ runSimulation();
+ console.profileEnd();
+}
View
213 2012-BlackBerryJam-Asia/JAM843/source/js/resources.js
@@ -0,0 +1,213 @@
+/*
+* Copyright 2012 Research In Motion Limited.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/*global window, document, console, mynamespace */
+
+
+/* Web DB */
+var App = {};
+function onDBCreate(database) {
+ App.db = database;
+ database.transaction(
+ function (tx) {
+ tx.executeSql(
+ 'CREATE TABLE my_custom_table (uid int unique, name text, created text);',
+ [],
+ function (tx, res) {
+ console.log("table: OK!");
+ },
+ function (tx, err) {
+ console.log("table (" + err.code + "): " + err.message);
+ }
+ );
+ }
+ );
+}
+function initWebDB() {
+ App.db = window.openDatabase('MyDatabase', '1.0', 'Description.', 5 * 1024 * 1024, onDBCreate);
+}
+function displayWebDBCount() {
+ App.db.transaction(
+ function (tx) {
+ tx.executeSql(
+ 'SELECT uid, name, created FROM my_custom_table;',
+ [],
+ function (tx, res) {
+ console.log("SELECT: OK!");
+ var num = res.rows.length;
+ var message = "There are " + num + " item(s) saved in Web DB.";
+ document.getElementById("webDBCount").innerHTML = message;
+ },
+ function (tx, err) {
+ console.log("SELECT (" + err.code + "): " + err.message);
+ }
+ );
+ }
+ );
+
+}
+function clearWebDB() {
+ App.db.transaction(
+ function (tx) {
+ tx.executeSql(
+ 'DELETE FROM my_custom_table;',
+ [],
+ function (tx, res) {
+ console.log("DELETE: OK!");
+ },
+ function (tx, err) {
+ console.log("DELETE (" + err.code + "): " + err.message);
+ }
+ );
+ }
+ );
+
+ displayWebDBCount();
+}
+function addWebDBItem() {
+ var key = (new Date()).getTime();
+ var val = document.getElementById("txtWebDBValue").value;
+
+ App.db.transaction(
+ function (tx) {
+ tx.executeSql(
+ 'INSERT INTO my_custom_table (uid, name, created) VALUES(' + key + ', "' + val + '", "' + new Date().toString() + '");',
+ [],
+ function (tx, res) {
+ console.log("table: OK!");
+ },
+ function (tx, err) {
+ console.log("table (" + err.code + "): " + err.message);
+ }
+ );
+ }
+ );
+ displayWebDBCount();
+}
+
+
+ /* Local Storage */
+function displayLocalStorageCount() {
+ var num = window.localStorage.length;
+ var message = "There are " + num + " item(s) saved in Local Storage.";
+ document.getElementById("localStorageCount").innerHTML = message;
+}
+function clearLocalStorage() {
+ localStorage.clear();
+ displayLocalStorageCount();
+}
+function addLocalStorageItem() {
+ var key = (new Date()).getTime();
+ var val = document.getElementById("txtLocalStorageValue").value;
+ window.localStorage.setItem(key, val);
+ displayLocalStorageCount();
+}
+
+/* Cookies */
+function displayCookiesCount() {
+ var cookies = document.cookie.split(";");
+ var num = ((document.cookie == "") ? 0 : cookies.length);
+ var message = "There are " + num + " cookie(s).";
+ document.getElementById("cookieCount").innerHTML = message;
+}
+function clearCookies() {
+ if (document.cookie != "") {
+ var cookies = document.cookie.split(";");
+ for (var i = 0; i < cookies.length; i++) {
+ console.log("erasing " + cookies[i].split("=")[0] + " cookies");
+
+ var expiry = new Date();
+ expiry.setDate(expiry.getDate() - 1);
+ setCookie(cookies[i].split("=")[0], cookies[i].split("=")[1], expiry.toUTCString());
+ }
+ }
+ displayCookiesCount();
+}
+function setCookie(name, val, expires) {
+ document.cookie = name + "=" + val + "; expires=" + expires;
+}
+function addCookie() {
+ var key = (new Date()).getTime();
+ var val = document.getElementById("txtCookieValue").value;
+ var expiry = new Date();
+ expiry.setDate(expiry.getDate() + 1);
+
+ setCookie(key, escape(val), expiry.toUTCString());
+ displayCookiesCount();
+}
+
+
+function initResources() {
+ initWebDB();
+ displayWebDBCount();
+ displayLocalStorageCount();
+ displayCookiesCount();
+}
+setTimeout(initResources, 200);
+
+
+
+/*
+//Create a namespace to hold our database variable
+if (typeof mynamespace === 'undefined') {
+ mynamespace = {};
+}
+
+function insertIntoDB() {
+ "use strict";
+ mynamespace.db.transaction(
+ function (tx) {
+ tx.executeSql(
+ 'INSERT INTO my_custom_table (key, name) VALUES(' + new Date().getTime() + ', "Database Tester");',
+ [],
+ function (tx, res) {
+ console.log("table: OK!");
+ },
+ function (tx, err) {
+ console.log("table (" + err.code + "): " + err.message);
+ }
+ );
+ }
+ );
+}
+
+(function () {
+ "use strict";
+ function onDBCreate(database) {
+ mynamespace.db = database;
+ database.transaction(
+ function (tx) {
+ tx.executeSql(
+ 'CREATE TABLE my_custom_table (key int unique, name text);',
+ [],
+ function (tx, res) {
+ console.log("table: OK!");
+ },
+ function (tx, err) {
+ console.log("table (" + err.code + "): " + err.message);
+ }
+ );
+ }
+ );
+ }
+
+ if (window.openDatabase) {
+ mynamespace.db = window.openDatabase('MyDatabase', '1.0', 'Database description.', 5 * 1024 * 1024, onDBCreate);
+ } else {
+ console.log("This device does not have HTML5 Database support");
+ }
+}());
+*/
View
60 2012-BlackBerryJam-Asia/JAM843/source/js/sources.js
@@ -0,0 +1,60 @@
+/*
+* Copyright 2012 Research In Motion Limited.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/*global window, document, console */
+
+/**
+ * This sample will run through the numbers from 2 to 50 and check whether each number is divisible by a value between 2 and 9.
+ *
+ * We use the variable log to keep track of the divisible numbers. For instance, the number 2 is divisible by 2, 3 is divisible by 3, and 4 is divisible by 2.
+ * For those three numbers, the sequence will then be:
+ * 232
+ *
+ * For any numbers that we encounter which are not divisible by 2 to 9, we record a # symbol.
+ *
+ * This can be used to help outline setting break points and stepping through an application.
+ */
+
+function seeMeGo() {
+ "use strict";
+ var log = "", i = 0;
+
+ //50 iterations of the Mod operator
+ for (i = 2; i < 50; ++i) {
+
+ if (i % 2 === 0) {
+ log = log + "2";
+ } else if (i % 3 === 0) {
+ log = log + "3";
+ } else if (i % 4 === 0) {
+ log = log + "4";
+ } else if (i % 5 === 0) {
+ log = log + "5";
+ } else if (i % 6 === 0) {
+ log = log + "6";
+ } else if (i % 7 === 0) {
+ log = log + "7";
+ } else if (i % 8 === 0) {
+ log = log + "8";
+ } else if (i % 9 === 0) {
+ log = log + "9";
+ } else {
+ log = log + "#";
+ }
+
+ }
+ alert(log);
+}
View
1,258 2012-BlackBerryJam-Asia/JAM843/source/js/webworks.js
@@ -0,0 +1,1258 @@
+/*
+ * Copyright 2012 Research In Motion Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+(function () {
+/*
+ * Copyright 2012 Research In Motion Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var define,
+ require;
+
+(function () {
+ var unpreparedModules = {},
+ readyModules = {},
+ ACCEPTABLE_EXTENSIONS = [".js", ".json"],
+ DEFAULT_EXTENSION = ".js";
+
+ function hasValidExtension(moduleName) {
+ return ACCEPTABLE_EXTENSIONS.some(function (element, index, array) {
+ return moduleName.match("\\" + element + "$");
+ });
+ }
+
+
+ function normalizeName(originalName, baseName) {
+ var nameParts,
+ name = originalName.slice(0);
+ //remove ^local:// (if it exists) and .js$
+ //This will not work for local:// without a trailing js
+ name = name.replace(/(?:^local:\/\/)/, "");
+ if (name.charAt(0) === '.' && baseName) {
+ //Split the baseName and remove the final part (the module name)
+ nameParts = baseName.split('/');
+ nameParts.pop();
+ nameParts = nameParts.concat(name.split('/'));
+
+ name = nameParts.reduce(function (previous, current, index, array) {
+ var returnValue,
+ slashIndex;
+
+ //If previous is a dot, ignore it
+ //If previous is ever just .. we're screwed anyway
+ if (previous !== '.') {
+ returnValue = previous;
+ }
+
+ //If we have a .. then remove a chunk of previous
+ if (current === "..") {
+ slashIndex = previous.lastIndexOf('/');
+ //If there's no slash we're either screwed or we remove the final token
+ if (slashIndex !== -1) {
+ returnValue = previous.slice(0, previous.lastIndexOf('/'));
+ } else {
+ returnValue = "";
+ }
+ } else if (current !== '.') {
+ //Otherwise simply append anything not a .
+ //Only append a slash if we're not empty
+ if (returnValue.length) {
+ returnValue += "/";
+ }
+ returnValue += current;
+ }
+
+ return returnValue;
+ });
+
+ }
+
+ //If there is no acceptable extension tack on a .js
+ if (!hasValidExtension(name)) {
+ name = name + DEFAULT_EXTENSION;
+ }
+
+ return name;
+ }
+
+ function buildModule(name, dependencies, factory) {
+ var module = {exports: {}},
+ localRequire = function (moduleName) {
+ return require(moduleName, name);
+ },
+ args = [];
+ localRequire.toUrl = function (moduleName, baseName) {
+ return require.toUrl(moduleName, baseName || name);
+ };
+ dependencies.forEach(function (dependency) {
+ if (dependency === 'require') {
+ args.push(localRequire);
+ } else if (dependency === 'exports') {
+ args.push(module.exports);
+ } else if (dependency === 'module') {
+ args.push(module);
+ } else {
+ //This is because jshint cannot handle out of order functions
+ /*global loadModule:false */
+ args.push(loadModule(dependency));
+ /*global loadModule:true */
+ }
+ });
+
+ //No need to process dependencies, webworks only has require, exports, module
+ factory.apply(this, args);
+
+ //For full AMD we would need logic to also check the return value
+ return module.exports;
+
+ }
+
+ function getDefineString(moduleName, body) {
+ var evalString = 'define("' + moduleName + '", function (require, exports, module) {',
+ isJson = /\.json$/.test(moduleName);
+
+ evalString += isJson ? ' module.exports = ' : '';
+ evalString += body.replace(/^\s+|\s+$/g, '');
+ evalString += isJson ? ' ;' : '';
+ evalString += '});';
+
+ return evalString;
+ }
+
+ function loadModule(name, baseName) {
+ var normalizedName = normalizeName(name, baseName),
+ url,
+ xhr,
+ loadResult;
+ //Always check undefined first, this allows the user to redefine modules
+ //(Not used in WebWorks, although it is used in our unit tests)
+ if (unpreparedModules[normalizedName]) {
+ readyModules[normalizedName] = buildModule(normalizedName, unpreparedModules[normalizedName].dependencies, unpreparedModules[normalizedName].factory);
+ delete unpreparedModules[normalizedName];
+ }
+
+ //If the module does not exist, load the module from external source
+ //Webworks currently only loads APIs from across bridge
+ if (!readyModules[normalizedName]) {
+ //If the module to be loaded ends in .js then we will define it
+ //Also if baseName exists than we have a local require situation
+ if (hasValidExtension(name) || baseName) {
+ xhr = new XMLHttpRequest();
+ url = name;
+ //If the module to be loaded starts with local:// go over the bridge
+ //Else If the module to be loaded is a relative load it may not have .js extension which is needed
+ if (/^local:\/\//.test(name)) {
+ url = "http://localhost:8472/extensions/load/" + normalizedName.replace(/(?:^ext\/)(.+)(?:\/client.js$)/, "$1");
+
+ xhr.open("GET", url, false);
+ xhr.send(null);
+ try {
+ loadResult = JSON.parse(xhr.responseText);
+
+ loadResult.dependencies.forEach(function (dep) {
+ /*jshint evil:true */
+ eval(getDefineString(dep.moduleName, dep.body));
+ /*jshint evil:false */
+ });
+
+ //Trimming responseText to remove EOF chars
+ /*jshint evil:true */
+ eval(getDefineString(normalizedName, loadResult.client));
+ /*jshint evil:false */
+ } catch (err1) {
+ err1.message += ' in ' + url;
+ throw err1;
+ }
+ } else {
+ if (baseName) {
+ url = normalizedName;
+ }
+
+ xhr.open("GET", url, false);
+ xhr.send(null);
+ try {
+ //Trimming responseText to remove EOF chars
+ /*jshint evil:true */
+ eval(getDefineString(normalizedName, xhr.responseText));
+ /*jshint evil:false */
+ } catch (err) {
+ err.message += ' in ' + url;
+ throw err;
+ }
+ }
+
+ if (unpreparedModules[normalizedName]) {
+ readyModules[normalizedName] = buildModule(normalizedName, unpreparedModules[normalizedName].dependencies, unpreparedModules[normalizedName].factory);
+ delete unpreparedModules[normalizedName];
+ }
+ } else {
+ throw "module " + name + " cannot be found";
+ }
+
+ }
+
+ return readyModules[normalizedName];
+
+ }
+
+ //Use the AMD signature incase we ever want to change.
+ //For now we will only be using (name, baseName)
+ require = function (dependencies, callback) {
+ if (typeof dependencies === "string") {
+ //dependencies is the module name and callback is the relName
+ //relName is not part of the AMDJS spec, but we use it from localRequire
+ return loadModule(dependencies, callback);
+ } else if (Array.isArray(dependencies) && typeof callback === 'function') {
+ //Call it Asynchronously
+ setTimeout(function () {
+ buildModule(undefined, dependencies, callback);
+ }, 0);
+ }
+ };
+
+ require.toUrl = function (originalName, baseName) {
+ return normalizeName(originalName, baseName);
+ };
+
+ //Use the AMD signature incase we ever want to change.
+ //For now webworks will only be using (name, factory) signature.
+ define = function (name, dependencies, factory) {
+ if (typeof name === "string" && typeof dependencies === 'function') {
+ factory = dependencies;
+ dependencies = ['require', 'exports', 'module'];
+ }
+
+ //According to the AMDJS spec we should parse out the require statments
+ //from factory.toString and add those to the list of dependencies
+
+ //Normalize the name. Remove local:// and .js
+ name = normalizeName(name);
+ unpreparedModules[name] = {
+ dependencies: dependencies,
+ factory: factory
+ };
+ };
+}());
+
+//Export for use in node for unit tests
+if (typeof module === "object" && typeof require === "function") {
+ module.exports = {
+ require: require,
+ define: define
+ };
+}
+
+define('builder', function (require, exports, module) {
+/*
+ * Copyright 2010-2011 Research In Motion Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+var utils = require(!!require.resolve ? "../utils" : "lib/utils");
+
+function buildNamespace(currentNamespace, namespaceParts, featureProperties) {
+ var featureId,
+ nextPart;
+
+ if (namespaceParts.length === 1) {
+ //base case, feature properties go here
+ featureId = namespaceParts[0];
+ if (currentNamespace[featureId] === undefined) {
+ currentNamespace[featureId] = {};
+ }
+
+ currentNamespace = utils.mixin(featureProperties, currentNamespace[featureId]);
+ return currentNamespace;
+ }
+ else {
+ nextPart = namespaceParts.shift();
+ if (currentNamespace[nextPart] === undefined) {
+ currentNamespace[nextPart] = {};
+ }
+
+ return buildNamespace(currentNamespace[nextPart], namespaceParts, featureProperties);
+ }
+}
+
+function include(parent, featureIdList) {
+ var featureId,
+ featureProperties,
+ localUrl,
+ i;
+
+ for (i = 0; i < featureIdList.length; i++) {
+ featureId = featureIdList[i];
+
+ localUrl = "local://ext/" + featureId + "/client.js";
+ featureProperties = utils.loadModule(localUrl);
+
+ buildNamespace(parent, featureId.split("."), featureProperties);
+ }
+}
+
+var _self = {
+ build: function (featureIdList) {
+ return {
+ into: function (target) {
+ include(target, featureIdList);
+ }
+ };
+ }
+};
+
+module.exports = _self;
+
+});
+
+define('window', function (require, exports, module) {
+/*
+ * Copyright 2010-2011 Research In Motion Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// HACK have to live with differentiating node from browser for now
+module.exports = {
+ "window": function () {
+ return !!require.resolve ? null : window;
+ }
+};
+});
+
+define('event', function (require, exports, module) {
+/*
+* Copyright 2010-2011 Research In Motion Limited.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+var _handlers = {};
+
+function _add(featureId, name, cb, success, fail, once) {
+ var handler;
+ if (featureId && name && typeof cb === "function") {
+ handler = {
+ func: cb,
+ once: !!once
+ };
+ //If this is the first time we are adding a cb
+ if (!_handlers.hasOwnProperty(name)) {
+ _handlers[name] = [handler];
+ //Do not call exec for once because its not necessary
+ if (!once) {
+ window.webworks.exec(success, fail, featureId, "add", {"eventName": name});
+ }
+ } else if (!_handlers[name].some(function (element, index, array) {
+ return element.func === cb;
+ })) {
+ //Only add unique callbacks
+ _handlers[name].push(handler);
+ }
+ }
+}
+
+module.exports = {
+ add: function (featureId, name, cb, success, fail) {
+ _add(featureId, name, cb, success, fail, false);
+ },
+
+ once: function (featureId, name, cb, success, fail) {
+ _add(featureId, name, cb, success, fail, true);
+ },
+
+ isOn: function (name) {
+ return !!_handlers[name];
+ },
+
+ remove: function (featureId, name, cb, success, fail) {
+ if (featureId && name && typeof cb === "function") {
+ if (_handlers.hasOwnProperty(name)) {
+ _handlers[name] = _handlers[name].filter(function (element, index, array) {
+ return element.func !== cb || element.once;
+ });
+
+ if (_handlers[name].length === 0) {
+ delete _handlers[name];
+ window.webworks.exec(success, fail, featureId, "remove", {"eventName": name});
+ }
+ }
+ }
+ },
+
+ trigger: function (name, args) {
+ var parsedArgs;
+ if (_handlers.hasOwnProperty(name)) {
+ if (args && args !== "undefined") {
+ parsedArgs = JSON.parse(decodeURIComponent(args));
+ }
+ //Call the handlers
+ _handlers[name].forEach(function (handler) {
+ if (handler) {
+ //args should be an array of arguments
+ handler.func.apply(undefined, parsedArgs);
+ }
+ });
+ //Remove the once listeners
+ _handlers[name] = _handlers[name].filter(function (handler) {
+ return !handler.once;
+ });
+ //Clean up the array if it is empty
+ if (_handlers[name].length === 0) {
+ delete _handlers[name];
+ //No need to call remove since this would only be for callbacks
+ }
+ }
+ }
+};
+
+});
+
+define('lib/utils', function (require, exports, module) {
+/*
+ * Copyright 2012 Research In Motion Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var self,
+ exception = require('./exception');
+
+function S4() {
+ return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
+}
+
+self = module.exports = {
+ validateNumberOfArguments: function (lowerBound, upperBound, numberOfArguments, customExceptionType, customExceptionMessage, customExceptionObject) {
+
+ customExceptionMessage = customExceptionMessage || "";
+
+ if (arguments.length < 3 || arguments.length > 6) {
+ exception.raise(exception.types.Argument, "Wrong number of arguments when calling: validateNumberOfArguments()");
+ }
+
+ if (isNaN(lowerBound) && isNaN(upperBound) && isNaN(numberOfArguments)) {
+ exception.raise(exception.types.ArgumentType, "(validateNumberOfArguments) Arguments are not numbers");
+ }
+
+ lowerBound = parseInt(lowerBound, 10);
+ upperBound = parseInt(upperBound, 10);
+ numberOfArguments = parseInt(numberOfArguments, 10);
+
+ if (numberOfArguments < lowerBound || numberOfArguments > upperBound) {
+ exception.raise((customExceptionType || exception.types.ArgumentLength), (customExceptionMessage + "\n\nWrong number of arguments"), customExceptionObject);
+ }
+
+ },
+
+ validateArgumentType: function (arg, argType, customExceptionType, customExceptionMessage, customExceptionObject) {
+ var invalidArg = false,
+ msg;
+
+ switch (argType) {
+ case "array":
+ if (!arg instanceof Array) {
+ invalidArg = true;
+ }
+ break;
+ case "date":
+ if (!arg instanceof Date) {
+ invalidArg = true;
+ }
+ break;
+ case "integer":
+ if (typeof arg === "number") {
+ if (arg !== Math.floor(arg)) {
+ invalidArg = true;
+ }
+ }
+ else {
+ invalidArg = true;
+ }
+ break;
+ default:
+ if (typeof arg !== argType) {
+ invalidArg = true;
+ }
+ break;
+ }
+
+ if (invalidArg) {
+ msg = customExceptionMessage + ("\n\nInvalid Argument type. argument: " + arg + " ==> was expected to be of type: " + argType);
+ exception.raise((customExceptionType || exception.types.ArgumentType), msg, customExceptionObject);
+ }
+ },
+
+ validateMultipleArgumentTypes: function (argArray, argTypeArray, customExceptionType, customExceptionMessage, customExceptionObject) {
+ for (var i = 0; i < argArray.length; i++) {
+ this.validateArgumentType(argArray[i], argTypeArray[i], customExceptionType, customExceptionMessage, customExceptionObject);
+ }
+ },
+
+ arrayContains: function (array, obj) {
+ var i = array.length;
+ while (i--) {
+ if (array[i] === obj) {
+ return true;
+ }
+ }
+ return false;
+ },
+
+ some: function (obj, predicate, scope) {
+ if (obj instanceof Array) {
+ return obj.some(predicate, scope);
+ }
+ else {
+ var values = self.map(obj, predicate, scope);
+
+ return self.reduce(values, function (some, value) {
+ return value ? value : some;
+ }, false);
+ }
+ },
+
+ count: function (obj) {
+ return self.sum(obj, function (total) {
+ return 1;
+ });
+ },
+
+ sum: function (obj, selector, scope) {
+ var values = self.map(obj, selector, scope);
+ return self.reduce(values, function (total, value) {
+ return total + value;
+ });
+ },
+
+ max: function (obj, selector, scope) {
+ var values = self.map(obj, selector, scope);
+ return self.reduce(values, function (max, value) {
+ return max < value ? value : max;
+ }, Number.MIN_VALUE);
+ },
+
+ min: function (obj, selector, scope) {
+ var values = self.map(obj, selector, scope);
+ return self.reduce(values, function (min, value) {
+ return min > value ? value : min;
+ }, Number.MAX_VALUE);
+ },
+
+ forEach: function (obj, action, scope) {
+ if (obj instanceof Array) {
+ return obj.forEach(action, scope);
+ }
+ else {
+ self.map(obj, action, scope);
+ }
+ },
+
+ filter: function (obj, predicate, scope) {
+ if (obj instanceof Array) {
+ return obj.filter(predicate, scope);
+ }
+ else {
+ var result = [];
+ self.forEach(obj, function (value, index) {
+ if (predicate.apply(scope, [value, index])) {
+ result.push(value);
+ }
+
+ }, scope);
+
+ return result;
+ }
+ },
+
+ reduce: function (obj, func, init, scope) {
+ var i,
+ initial = init === undefined ? 0 : init,
+ result = initial;
+
+
+ if (obj instanceof Array) {
+ return obj.reduce(func, initial);
+ }
+ else if (obj instanceof NamedNodeMap) {
+ for (i = 0; i < obj.length; i++) {
+ result = func.apply(scope, [result, obj[i], i]);
+ }
+ }
+ else {
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ result = func.apply(scope, [result, obj[i], i]);
+ }
+ }
+ }
+
+ return result;
+
+ },
+
+ map: function (obj, func, scope) {
+ var i,
+ returnVal = null,
+ result = [];
+
+ if (obj instanceof Array) {
+ return obj.map(func, scope);
+ }
+ else if (obj instanceof NamedNodeMap) {
+ for (i = 0; i < obj.length; i++) {
+ returnVal = func.apply(scope, [obj[i], i]);
+ result.push(returnVal);
+ }
+ }
+ else {
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ returnVal = func.apply(scope, [obj[i], i]);
+ result.push(returnVal);
+ }
+ }
+ }
+
+ return result;
+ },
+
+ series: function (tasks, callback) {
+
+ var execute = function () {
+ var args = [],
+ task;
+
+ if (tasks.length) {
+ task = tasks.shift();
+ args = args.concat(task.args).concat(execute);
+ task.func.apply(this, args);
+ }
+ else {
+ callback.func.apply(this, callback.args);
+ }
+ };
+
+ execute();
+ },
+
+ regexSanitize: function (regexString) {
+ return regexString.replace("^", "\\^")
+ .replace("$", "\\$")
+ .replace("(", "\\(")
+ .replace(")", "\\)")
+ .replace("<", "\\<")
+ .replace("[", "\\[")
+ .replace("{", "\\{")
+ .replace(/\\/, "\\\\")
+ .replace("|", "\\|")
+ .replace(">", "\\>")
+ .replace(".", "\\.")
+ .replace("*", "\\*")
+ .replace("+", "\\+")
+ .replace("?", "\\?");
+ },
+
+ find: function (comparison, collection, startInx, endInx, callback) {
+ var results = [],
+ compare = function (s, pattern) {
+
+ if (typeof(s) !== "string" || pattern === null) {
+ return s === pattern;
+ }
+
+ var regex = pattern.replace(/\./g, "\\.")
+ .replace(/\^/g, "\\^")
+ .replace(/\*/g, ".*")
+ .replace(/\\\.\*/g, "\\*");
+
+ regex = "^".concat(regex, "$");
+
+ return !!s.match(new RegExp(regex, "i"));
+ };
+
+ self.forEach(collection, function (c) {
+ var match,
+ fail = false;
+
+ self.forEach(comparison, function (value, key) {
+ if (!fail && value !== undefined) {
+
+ if (compare(c[key], value)) {
+ match = c;
+ }
+ else {
+ fail = true;
+ match = null;
+ }
+ }
+ });
+
+ if (match) {
+ results.push(match);
+ }
+ });
+
+ if (callback) {
+ if (startInx === undefined) {
+ startInx = 0;
+ }
+ if (endInx === undefined) {
+ endInx = results.length;
+ }
+ if (startInx === endInx) {
+ endInx = startInx + 1;
+ }
+
+ callback.apply(null, [results.slice(startInx, endInx)]);
+ }
+ },
+
+ mixin: function (mixin, to) {
+ Object.getOwnPropertyNames(mixin).forEach(function (prop) {
+ if (Object.hasOwnProperty.call(mixin, prop)) {
+ Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(mixin, prop));
+ }
+ });
+ return to;
+ },
+
+ copy: function (obj) {
+ var i,
+ newObj = (obj === null ? false : global.toString.call(obj) === "[object Array]") ? [] : {};
+
+ if (typeof obj === 'number' ||
+ typeof obj === 'string' ||
+ typeof obj === 'boolean' ||
+ obj === null ||
+ obj === undefined) {
+ return obj;
+ }
+
+ if (obj instanceof Date) {
+ return new Date(obj);
+ }
+
+ if (obj instanceof RegExp) {
+ return new RegExp(obj);
+ }
+
+ for (i in obj) {
+ if (obj.hasOwnProperty(i)) {
+ if (obj[i] && typeof obj[i] === "object") {
+ if (obj[i] instanceof Date) {
+ newObj[i] = obj[i];
+ }
+ else {
+ newObj[i] = self.copy(obj[i]);
+ }
+ }
+ else {
+ newObj[i] = obj[i];
+ }
+ }
+ }
+
+ return newObj;
+ },
+
+ startsWith : function (str, substr) {
+ return str.indexOf(substr) === 0;
+ },
+
+ endsWith : function (str, substr) {
+ return str.indexOf(substr, str.length - substr.length) !== -1;
+ },
+
+ parseUri : function (str) {
+ var i, uri = {},
+ key = [ "source", "scheme", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor" ],
+ matcher = /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(str);
+
+ for (i = key.length - 1; i >= 0; i--) {
+ uri[key[i]] = matcher[i] || "";
+ }
+
+ return uri;
+ },
+
+ // uri - output from parseUri
+ isAbsoluteURI : function (uri) {
+ if (uri && uri.source) {
+ return uri.relative !== uri.source;
+ }
+
+ return false;
+ },
+
+ fileNameToImageMIME : function (fileName) {
+
+ var extensionsToMIME = {},
+ ext;
+
+ extensionsToMIME.png = 'image/png';
+ extensionsToMIME.jpg = 'image/jpeg';
+ extensionsToMIME.jpe = 'image/jpeg';
+ extensionsToMIME.jpeg = 'image/jpeg';
+ extensionsToMIME.gif = 'image/gif';
+ extensionsToMIME.bmp = 'image/bmp';
+ extensionsToMIME.bm = 'image/bmp';
+ extensionsToMIME.svg = 'image/svg+xml';
+ extensionsToMIME.tif = 'image/tiff';
+ extensionsToMIME.tiff = 'image/tiff';
+
+ ext = fileName.split('.').pop();
+ return extensionsToMIME[ext];
+ },
+
+ isLocalURI : function (uri) {
+ return uri && uri.scheme && "local:///".indexOf(uri.scheme.toLowerCase()) !== -1;
+ },
+
+ isFileURI : function (uri) {
+ return uri && uri.scheme && "file://".indexOf(uri.scheme.toLowerCase()) !== -1;
+ },
+
+ isHttpURI : function (uri) {
+ return uri && uri.scheme && "http://".indexOf(uri.scheme.toLowerCase()) !== -1;
+ },
+
+ isHttpsURI : function (uri) {
+ return uri && uri.scheme && "https://".indexOf(uri.scheme.toLowerCase()) !== -1;
+ },
+
+ // Checks if the specified uri starts with 'data:'
+ isDataURI : function (uri) {
+ return uri && uri.scheme && "data:".indexOf(uri.scheme.toLowerCase()) !== -1;
+ },
+
+ performExec : function (featureId, property, args) {
+ var result;
+
+ window.webworks.exec(function (data, response) {
+ result = data;
+ }, function (data, response) {
+ throw data;
+ }, featureId, property, args, true);
+
+ return result;
+ },
+
+ inNode : function () {
+ return !!require.resolve;
+ },
+
+ requireWebview : function () {
+ return require("./webview");
+ },
+ convertDataToBinary : function (data, dataEncoding) {
+ var rawData,
+ uint8Array,
+ i;
+
+ if (data) {
+ if (dataEncoding.toLowerCase() === "base64") {
+ rawData = window.atob(data);
+ }
+ else {
+ rawData = data;
+ }
+
+ uint8Array = new Uint8Array(new ArrayBuffer(rawData.length));
+
+ for (i = 0; i < uint8Array.length; i++) {
+ uint8Array[i] = rawData.charCodeAt(i);
+ }
+
+ return uint8Array.buffer;
+ }
+ },
+ getBlobWithArrayBufferAsData : function (data, dataEncoding) {
+ var rawData,
+ blobBuilderObj = new window.WebKitBlobBuilder();
+ rawData = this.convertDataToBinary(data, dataEncoding);
+ blobBuilderObj.append(rawData);
+
+ return blobBuilderObj.getBlob("arraybuffer");
+ },
+ loadModule: function (module) {
+ return require(module);
+ },
+ loadExtensionModule: function (extBasename, path) {
+ var ext = require("./manifest")[extBasename];
+
+ if (ext) {
+ return require("../ext/" + ext.namespace + "/" + path);
+ } else {
+ return null;
+ }
+ },
+ hasPermission: function (config, permission) {
+ if (config && config.permissions && config.permissions.length) {
+ return config.permissions.indexOf(permission) >= 0;
+ }
+
+ return false;
+ },
+ guid: function () {
+ return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
+ },
+ getURIPrefix: function () {
+ return "http://localhost:8472/";
+ }
+};
+
+});
+
+define('lib/exception', function (require, exports, module) {
+/*
+ * Copyright 2012 Research In Motion Limited.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+module.exports = {
+
+ types: {
+ Application: "Application",
+ ArgumentLength: "ArgumentLength",
+ ArgumentType: "ArgumentType",
+ Argument: "Argument",
+ NotificationType: "NotificationType",
+ NotificationStateType: "NotificationStateType",
+ DomObjectNotFound: "DomObjectNotFound",
+ MethodNotImplemented: "MethodNotImplemented",
+ InvalidState: "InvalidState",
+ ApplicationState: "ApplicationState"
+ },
+
+ handle: function handle(exception, reThrow) {
+ reThrow = reThrow || false;
+
+ var eMsg = exception.message || "exception caught!",
+ msg = eMsg + "\n\n" + (exception.stack || "*no stack provided*") + "\n\n";
+
+ console.error(msg);
+
+ if (reThrow) {
+ throw exception;
+ }
+ },
+
+ raise: function raise(exceptionType, message, customExceptionObject) {
+ var obj = customExceptionObject || {
+ type: "",
+ message: "",
+
+ toString: function () {
+ var result = this.name + ': "' + this.message + '"';
+
+ if (this.stack) {
+ result += "\n" + this.stack;
+ }
+ return result;
+ }
+ };
+
+ message = message || "";
+
+ obj.name = exceptionType;
+ obj.type = exceptionType;
+ // TODO: include the exception objects original message if exists
+ obj.message = message;
+
+ throw obj;
+ }
+};
+
+});
+define('lib/webworks-info', function (require, exports, module) {
+module.exports = {
+ hash: "0ce47be0f0e032b04d4c4ba14e243218",
+ version: "1.0.2.9"
+};
+});
+/*
+* Copyright 2010-2012 Research In Motion Limited.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+(function () {
+ var _d = document.addEventListener,
+ _webworksReady = false,
+ _alreadyFired = false,
+ _listenerRegistered = false;
+
+ //Only fire the webworks event when both webworks is ready and a listener is registered
+ function fireWebworksReadyEvent() {
+ if (_listenerRegistered && _webworksReady && !_alreadyFired) {
+ _alreadyFired = true;
+ var evt = document.createEvent("Events");
+ evt.initEvent("webworksready", true, true);
+ document.dispatchEvent(evt);
+ }
+ }
+
+ //Trapping when users add listeners to the webworks ready event
+ //This way we can make sure not to fire the event before there is a listener
+ document.addEventListener = function (event, callback, capture) {
+ _d.call(document, event, callback, capture);
+ if (event.toLowerCase() === "webworksready") {
+ _listenerRegistered = true;
+ fireWebworksReadyEvent();
+ }
+ };
+
+
+ function createWebworksReady() {
+ function RemoteFunctionCall(functionUri) {
+ var params = {};
+
+ function composeUri() {
+ return require("lib/utils").getURIPrefix() + functionUri;
+ }
+
+ function createXhrRequest(uri, isAsync) {
+ var request = new XMLHttpRequest();
+
+ request.open("POST", uri, isAsync);
+ request.setRequestHeader("Content-Type", "application/json");
+
+ return request;
+ }
+
+ this.addParam = function (name, value) {
+ params[name] = encodeURIComponent(JSON.stringify(value));
+ };
+
+ this.makeSyncCall = function (success