mobile_template 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +22 -0
  4. data/README.md +28 -0
  5. data/Rakefile +3 -0
  6. data/bin/mobile_template +71 -0
  7. data/lib/mobile_template/version.rb +4 -0
  8. data/lib/mobile_template.rb +5 -0
  9. data/mobile_template.gemspec +21 -0
  10. data/templates/assets/Gemfile +4 -0
  11. data/templates/assets/config.rb +96 -0
  12. data/templates/assets/config.ru +4 -0
  13. data/templates/assets/source/images/vendor/ajax-loader.gif +0 -0
  14. data/templates/assets/source/images/vendor/ajax-loader.png +0 -0
  15. data/templates/assets/source/images/vendor/icons-18-black.png +0 -0
  16. data/templates/assets/source/images/vendor/icons-18-white.png +0 -0
  17. data/templates/assets/source/images/vendor/icons-36-black.png +0 -0
  18. data/templates/assets/source/images/vendor/icons-36-white.png +0 -0
  19. data/templates/assets/source/index.html.erb +2 -0
  20. data/templates/assets/source/javascripts/app/index.js.coffee +2 -0
  21. data/templates/assets/source/javascripts/application.js.coffee +5 -0
  22. data/templates/assets/source/javascripts/vendor/cordova.js +4841 -0
  23. data/templates/assets/source/javascripts/vendor/jquery.js +9267 -0
  24. data/templates/assets/source/javascripts/vendor/jquery.mobile.js +7410 -0
  25. data/templates/assets/source/layout.erb +24 -0
  26. data/templates/assets/source/stylesheets/application.css.scss +2 -0
  27. data/templates/assets/source/stylesheets/vendor/jquery.mobile.css.scss +1872 -0
  28. data/templates/cordova_android/.gitignore +18 -0
  29. data/templates/cordova_android/LICENSE +202 -0
  30. data/templates/cordova_android/NOTICE +5 -0
  31. data/templates/cordova_android/README.md +95 -0
  32. data/templates/cordova_android/VERSION +1 -0
  33. data/templates/cordova_android/bin/BOOM +4 -0
  34. data/templates/cordova_android/bin/autotest +2 -0
  35. data/templates/cordova_android/bin/bench +29 -0
  36. data/templates/cordova_android/bin/create +46 -0
  37. data/templates/cordova_android/bin/create.bat +1 -0
  38. data/templates/cordova_android/bin/create.js +88 -0
  39. data/templates/cordova_android/bin/create.xml +79 -0
  40. data/templates/cordova_android/bin/node_modules/.bin/cake +7 -0
  41. data/templates/cordova_android/bin/node_modules/.bin/coffee +7 -0
  42. data/templates/cordova_android/bin/node_modules/.bin/nodeunit +120 -0
  43. data/templates/cordova_android/bin/node_modules/coffee-script/.npmignore +11 -0
  44. data/templates/cordova_android/bin/node_modules/coffee-script/LICENSE +22 -0
  45. data/templates/cordova_android/bin/node_modules/coffee-script/README +48 -0
  46. data/templates/cordova_android/bin/node_modules/coffee-script/Rakefile +78 -0
  47. data/templates/cordova_android/bin/node_modules/coffee-script/bin/cake +7 -0
  48. data/templates/cordova_android/bin/node_modules/coffee-script/bin/coffee +7 -0
  49. data/templates/cordova_android/bin/node_modules/coffee-script/extras/jsl.conf +44 -0
  50. data/templates/cordova_android/bin/node_modules/coffee-script/lib/browser.js +75 -0
  51. data/templates/cordova_android/bin/node_modules/coffee-script/lib/cake.js +76 -0
  52. data/templates/cordova_android/bin/node_modules/coffee-script/lib/coffee-script.js +135 -0
  53. data/templates/cordova_android/bin/node_modules/coffee-script/lib/command.js +301 -0
  54. data/templates/cordova_android/bin/node_modules/coffee-script/lib/grammar.js +591 -0
  55. data/templates/cordova_android/bin/node_modules/coffee-script/lib/helpers.js +66 -0
  56. data/templates/cordova_android/bin/node_modules/coffee-script/lib/index.js +8 -0
  57. data/templates/cordova_android/bin/node_modules/coffee-script/lib/lexer.js +656 -0
  58. data/templates/cordova_android/bin/node_modules/coffee-script/lib/nodes.js +2289 -0
  59. data/templates/cordova_android/bin/node_modules/coffee-script/lib/optparse.js +111 -0
  60. data/templates/cordova_android/bin/node_modules/coffee-script/lib/parser.js +676 -0
  61. data/templates/cordova_android/bin/node_modules/coffee-script/lib/repl.js +123 -0
  62. data/templates/cordova_android/bin/node_modules/coffee-script/lib/rewriter.js +363 -0
  63. data/templates/cordova_android/bin/node_modules/coffee-script/lib/scope.js +120 -0
  64. data/templates/cordova_android/bin/node_modules/coffee-script/package.json +27 -0
  65. data/templates/cordova_android/bin/node_modules/nodeunit/.gitignore +5 -0
  66. data/templates/cordova_android/bin/node_modules/nodeunit/.npmignore +3 -0
  67. data/templates/cordova_android/bin/node_modules/nodeunit/CONTRIBUTORS.md +60 -0
  68. data/templates/cordova_android/bin/node_modules/nodeunit/LICENSE +19 -0
  69. data/templates/cordova_android/bin/node_modules/nodeunit/Makefile +126 -0
  70. data/templates/cordova_android/bin/node_modules/nodeunit/README.md +432 -0
  71. data/templates/cordova_android/bin/node_modules/nodeunit/bin/nodeunit +120 -0
  72. data/templates/cordova_android/bin/node_modules/nodeunit/bin/nodeunit.json +10 -0
  73. data/templates/cordova_android/bin/node_modules/nodeunit/deps/async.js +623 -0
  74. data/templates/cordova_android/bin/node_modules/nodeunit/deps/console.log.js +55 -0
  75. data/templates/cordova_android/bin/node_modules/nodeunit/deps/ejs.js +125 -0
  76. data/templates/cordova_android/bin/node_modules/nodeunit/deps/json2.js +483 -0
  77. data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/nodeunit.js +1757 -0
  78. data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/suite1.js +12 -0
  79. data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/suite2.js +13 -0
  80. data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/test.html +16 -0
  81. data/templates/cordova_android/bin/node_modules/nodeunit/img/example_fail.png +0 -0
  82. data/templates/cordova_android/bin/node_modules/nodeunit/img/example_pass.png +0 -0
  83. data/templates/cordova_android/bin/node_modules/nodeunit/index.js +3 -0
  84. data/templates/cordova_android/bin/node_modules/nodeunit/lib/assert.js +316 -0
  85. data/templates/cordova_android/bin/node_modules/nodeunit/lib/core.js +260 -0
  86. data/templates/cordova_android/bin/node_modules/nodeunit/lib/nodeunit.js +82 -0
  87. data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/browser.js +119 -0
  88. data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/default.js +123 -0
  89. data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/html.js +107 -0
  90. data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/index.js +9 -0
  91. data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/junit.js +183 -0
  92. data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/minimal.js +112 -0
  93. data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/skip_passed.js +105 -0
  94. data/templates/cordova_android/bin/node_modules/nodeunit/lib/track.js +48 -0
  95. data/templates/cordova_android/bin/node_modules/nodeunit/lib/types.js +187 -0
  96. data/templates/cordova_android/bin/node_modules/nodeunit/lib/utils.js +209 -0
  97. data/templates/cordova_android/bin/node_modules/nodeunit/man1/nodeunit.1 +95 -0
  98. data/templates/cordova_android/bin/node_modules/nodeunit/nodelint.cfg +4 -0
  99. data/templates/cordova_android/bin/node_modules/nodeunit/package.json +56 -0
  100. data/templates/cordova_android/bin/node_modules/nodeunit/share/junit.xml.ejs +19 -0
  101. data/templates/cordova_android/bin/node_modules/nodeunit/share/license.js +11 -0
  102. data/templates/cordova_android/bin/node_modules/nodeunit/share/nodeunit.css +70 -0
  103. data/templates/cordova_android/bin/templates/project/.cordova/android/readme.md +1 -0
  104. data/templates/cordova_android/bin/templates/project/.cordova/readme.md +3 -0
  105. data/templates/cordova_android/bin/templates/project/cordova/create +36 -0
  106. data/templates/cordova_android/bin/templates/project/cordova/debug +9 -0
  107. data/templates/cordova_android/bin/templates/project/cordova/emulate +12 -0
  108. data/templates/cordova_android/bin/templates/project/cordova/log +3 -0
  109. data/templates/cordova_android/bin/templates/project/cordova/templates/Activity.java +16 -0
  110. data/templates/cordova_android/bin/templates/project/cordova/templates/project/AndroidManifest.xml +50 -0
  111. data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/index.html +42 -0
  112. data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/main.js +146 -0
  113. data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/master.css +96 -0
  114. data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/drawable/icon.png +0 -0
  115. data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/xml/cordova.xml +5 -0
  116. data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/xml/plugins.xml +19 -0
  117. data/templates/cordova_android/bin/test +26 -0
  118. data/templates/cordova_android/bin/tests/autotest.coffee +4 -0
  119. data/templates/cordova_android/bin/tests/create.coffee +21 -0
  120. data/templates/cordova_android/bin/tests/debug.coffee +0 -0
  121. data/templates/cordova_android/bin/tests/test.coffee +0 -0
  122. data/templates/cordova_android/framework/.classpath +8 -0
  123. data/templates/cordova_android/framework/.project +33 -0
  124. data/templates/cordova_android/framework/AndroidManifest.xml +68 -0
  125. data/templates/cordova_android/framework/ant.properties +34 -0
  126. data/templates/cordova_android/framework/assets/js/accelerometer.js +137 -0
  127. data/templates/cordova_android/framework/assets/js/app.js +89 -0
  128. data/templates/cordova_android/framework/assets/js/battery.js +134 -0
  129. data/templates/cordova_android/framework/assets/js/camera.js +168 -0
  130. data/templates/cordova_android/framework/assets/js/capture.js +203 -0
  131. data/templates/cordova_android/framework/assets/js/compass.js +168 -0
  132. data/templates/cordova_android/framework/assets/js/contact.js +310 -0
  133. data/templates/cordova_android/framework/assets/js/cordova.android.js +4841 -0
  134. data/templates/cordova_android/framework/assets/js/cordova.js.base +924 -0
  135. data/templates/cordova_android/framework/assets/js/crypto.js +54 -0
  136. data/templates/cordova_android/framework/assets/js/device.js +83 -0
  137. data/templates/cordova_android/framework/assets/js/file.js +1082 -0
  138. data/templates/cordova_android/framework/assets/js/filetransfer.js +125 -0
  139. data/templates/cordova_android/framework/assets/js/geolocation.js +209 -0
  140. data/templates/cordova_android/framework/assets/js/header.txt +19 -0
  141. data/templates/cordova_android/framework/assets/js/media.js +233 -0
  142. data/templates/cordova_android/framework/assets/js/network.js +100 -0
  143. data/templates/cordova_android/framework/assets/js/notification.js +133 -0
  144. data/templates/cordova_android/framework/assets/js/position.js +100 -0
  145. data/templates/cordova_android/framework/assets/js/storage.js +439 -0
  146. data/templates/cordova_android/framework/assets/www/index.html +27 -0
  147. data/templates/cordova_android/framework/build.xml +216 -0
  148. data/templates/cordova_android/framework/libs/commons-codec-1.3.jar +0 -0
  149. data/templates/cordova_android/framework/proguard-project.txt +20 -0
  150. data/templates/cordova_android/framework/project.properties +14 -0
  151. data/templates/cordova_android/framework/res/drawable/icon.png +0 -0
  152. data/templates/cordova_android/framework/res/drawable/splash.png +0 -0
  153. data/templates/cordova_android/framework/res/layout/main.xml +29 -0
  154. data/templates/cordova_android/framework/res/values/strings.xml +23 -0
  155. data/templates/cordova_android/framework/res/xml/cordova.xml +37 -0
  156. data/templates/cordova_android/framework/res/xml/plugins.xml +37 -0
  157. data/templates/cordova_android/framework/src/com/phonegap/api/IPlugin.java +27 -0
  158. data/templates/cordova_android/framework/src/com/phonegap/api/LOG.java +28 -0
  159. data/templates/cordova_android/framework/src/com/phonegap/api/PhonegapActivity.java +28 -0
  160. data/templates/cordova_android/framework/src/com/phonegap/api/Plugin.java +27 -0
  161. data/templates/cordova_android/framework/src/com/phonegap/api/PluginManager.java +35 -0
  162. data/templates/cordova_android/framework/src/com/phonegap/api/PluginResult.java +53 -0
  163. data/templates/cordova_android/framework/src/org/apache/cordova/AccelListener.java +311 -0
  164. data/templates/cordova_android/framework/src/org/apache/cordova/App.java +198 -0
  165. data/templates/cordova_android/framework/src/org/apache/cordova/AudioHandler.java +364 -0
  166. data/templates/cordova_android/framework/src/org/apache/cordova/AudioPlayer.java +450 -0
  167. data/templates/cordova_android/framework/src/org/apache/cordova/AuthenticationToken.java +69 -0
  168. data/templates/cordova_android/framework/src/org/apache/cordova/BatteryListener.java +156 -0
  169. data/templates/cordova_android/framework/src/org/apache/cordova/CallbackServer.java +431 -0
  170. data/templates/cordova_android/framework/src/org/apache/cordova/CameraLauncher.java +500 -0
  171. data/templates/cordova_android/framework/src/org/apache/cordova/Capture.java +400 -0
  172. data/templates/cordova_android/framework/src/org/apache/cordova/CompassListener.java +308 -0
  173. data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessor.java +198 -0
  174. data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessorSdk5.java +1934 -0
  175. data/templates/cordova_android/framework/src/org/apache/cordova/ContactManager.java +113 -0
  176. data/templates/cordova_android/framework/src/org/apache/cordova/CordovaChromeClient.java +314 -0
  177. data/templates/cordova_android/framework/src/org/apache/cordova/CordovaWebViewClient.java +306 -0
  178. data/templates/cordova_android/framework/src/org/apache/cordova/Device.java +219 -0
  179. data/templates/cordova_android/framework/src/org/apache/cordova/DirectoryManager.java +161 -0
  180. data/templates/cordova_android/framework/src/org/apache/cordova/DroidGap.java +1417 -0
  181. data/templates/cordova_android/framework/src/org/apache/cordova/ExifHelper.java +165 -0
  182. data/templates/cordova_android/framework/src/org/apache/cordova/FileTransfer.java +458 -0
  183. data/templates/cordova_android/framework/src/org/apache/cordova/FileUploadResult.java +63 -0
  184. data/templates/cordova_android/framework/src/org/apache/cordova/FileUtils.java +1048 -0
  185. data/templates/cordova_android/framework/src/org/apache/cordova/GeoBroker.java +165 -0
  186. data/templates/cordova_android/framework/src/org/apache/cordova/GeoListener.java +133 -0
  187. data/templates/cordova_android/framework/src/org/apache/cordova/GpsListener.java +163 -0
  188. data/templates/cordova_android/framework/src/org/apache/cordova/HttpHandler.java +80 -0
  189. data/templates/cordova_android/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java +104 -0
  190. data/templates/cordova_android/framework/src/org/apache/cordova/NetworkListener.java +153 -0
  191. data/templates/cordova_android/framework/src/org/apache/cordova/NetworkManager.java +248 -0
  192. data/templates/cordova_android/framework/src/org/apache/cordova/Notification.java +366 -0
  193. data/templates/cordova_android/framework/src/org/apache/cordova/PreferenceNode.java +34 -0
  194. data/templates/cordova_android/framework/src/org/apache/cordova/PreferenceSet.java +62 -0
  195. data/templates/cordova_android/framework/src/org/apache/cordova/StandAlone.java +35 -0
  196. data/templates/cordova_android/framework/src/org/apache/cordova/Storage.java +239 -0
  197. data/templates/cordova_android/framework/src/org/apache/cordova/TempListener.java +112 -0
  198. data/templates/cordova_android/framework/src/org/apache/cordova/api/CordovaInterface.java +145 -0
  199. data/templates/cordova_android/framework/src/org/apache/cordova/api/IPlugin.java +116 -0
  200. data/templates/cordova_android/framework/src/org/apache/cordova/api/LOG.java +234 -0
  201. data/templates/cordova_android/framework/src/org/apache/cordova/api/Plugin.java +210 -0
  202. data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginManager.java +359 -0
  203. data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginResult.java +119 -0
  204. data/templates/cordova_android/framework/src/org/apache/cordova/file/EncodingException.java +28 -0
  205. data/templates/cordova_android/framework/src/org/apache/cordova/file/FileExistsException.java +28 -0
  206. data/templates/cordova_android/framework/src/org/apache/cordova/file/InvalidModificationException.java +29 -0
  207. data/templates/cordova_android/framework/src/org/apache/cordova/file/NoModificationAllowedException.java +28 -0
  208. data/templates/cordova_android/framework/src/org/apache/cordova/file/TypeMismatchException.java +29 -0
  209. data/templates/cordova_android/framework/test/org/apache/cordova/PreferenceNodeTest.java +53 -0
  210. data/templates/cordova_android/framework/test/org/apache/cordova/PreferenceSetTest.java +73 -0
  211. metadata +279 -0
@@ -0,0 +1,133 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+
20
+ if (!Cordova.hasResource("notification")) {
21
+ Cordova.addResource("notification");
22
+
23
+ /**
24
+ * This class provides access to notifications on the device.
25
+ * @constructor
26
+ */
27
+ var Notification = function() {
28
+ };
29
+
30
+ /**
31
+ * Open a native alert dialog, with a customizable title and button text.
32
+ *
33
+ * @param {String} message Message to print in the body of the alert
34
+ * @param {Function} completeCallback The callback that is called when user clicks on a button.
35
+ * @param {String} title Title of the alert dialog (default: Alert)
36
+ * @param {String} buttonLabel Label of the close button (default: OK)
37
+ */
38
+ Notification.prototype.alert = function(message, completeCallback, title, buttonLabel) {
39
+ var _title = (title || "Alert");
40
+ var _buttonLabel = (buttonLabel || "OK");
41
+ Cordova.exec(completeCallback, null, "Notification", "alert", [message,_title,_buttonLabel]);
42
+ };
43
+
44
+ /**
45
+ * Open a native confirm dialog, with a customizable title and button text.
46
+ * The result that the user selects is returned to the result callback.
47
+ *
48
+ * @param {String} message Message to print in the body of the alert
49
+ * @param {Function} resultCallback The callback that is called when user clicks on a button.
50
+ * @param {String} title Title of the alert dialog (default: Confirm)
51
+ * @param {String} buttonLabels Comma separated list of the labels of the buttons (default: 'OK,Cancel')
52
+ */
53
+ Notification.prototype.confirm = function(message, resultCallback, title, buttonLabels) {
54
+ var _title = (title || "Confirm");
55
+ var _buttonLabels = (buttonLabels || "OK,Cancel");
56
+ Cordova.exec(resultCallback, null, "Notification", "confirm", [message,_title,_buttonLabels]);
57
+ };
58
+
59
+ /**
60
+ * Start spinning the activity indicator on the statusbar
61
+ */
62
+ Notification.prototype.activityStart = function() {
63
+ Cordova.exec(null, null, "Notification", "activityStart", ["Busy","Please wait..."]);
64
+ };
65
+
66
+ /**
67
+ * Stop spinning the activity indicator on the statusbar, if it's currently spinning
68
+ */
69
+ Notification.prototype.activityStop = function() {
70
+ Cordova.exec(null, null, "Notification", "activityStop", []);
71
+ };
72
+
73
+ /**
74
+ * Display a progress dialog with progress bar that goes from 0 to 100.
75
+ *
76
+ * @param {String} title Title of the progress dialog.
77
+ * @param {String} message Message to display in the dialog.
78
+ */
79
+ Notification.prototype.progressStart = function(title, message) {
80
+ Cordova.exec(null, null, "Notification", "progressStart", [title, message]);
81
+ };
82
+
83
+ /**
84
+ * Set the progress dialog value.
85
+ *
86
+ * @param {Number} value 0-100
87
+ */
88
+ Notification.prototype.progressValue = function(value) {
89
+ Cordova.exec(null, null, "Notification", "progressValue", [value]);
90
+ };
91
+
92
+ /**
93
+ * Close the progress dialog.
94
+ */
95
+ Notification.prototype.progressStop = function() {
96
+ Cordova.exec(null, null, "Notification", "progressStop", []);
97
+ };
98
+
99
+ /**
100
+ * Causes the device to blink a status LED.
101
+ *
102
+ * @param {Integer} count The number of blinks.
103
+ * @param {String} colour The colour of the light.
104
+ */
105
+ Notification.prototype.blink = function(count, colour) {
106
+ // NOT IMPLEMENTED
107
+ };
108
+
109
+ /**
110
+ * Causes the device to vibrate.
111
+ *
112
+ * @param {Integer} mills The number of milliseconds to vibrate for.
113
+ */
114
+ Notification.prototype.vibrate = function(mills) {
115
+ Cordova.exec(null, null, "Notification", "vibrate", [mills]);
116
+ };
117
+
118
+ /**
119
+ * Causes the device to beep.
120
+ * On Android, the default notification ringtone is played "count" times.
121
+ *
122
+ * @param {Integer} count The number of beeps.
123
+ */
124
+ Notification.prototype.beep = function(count) {
125
+ Cordova.exec(null, null, "Notification", "beep", [count]);
126
+ };
127
+
128
+ Cordova.addConstructor(function() {
129
+ if (typeof navigator.notification === "undefined") {
130
+ navigator.notification = new Notification();
131
+ }
132
+ });
133
+ }
@@ -0,0 +1,100 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+
20
+ if (!Cordova.hasResource("position")) {
21
+ Cordova.addResource("position");
22
+
23
+ /**
24
+ * This class contains position information.
25
+ * @param {Object} lat
26
+ * @param {Object} lng
27
+ * @param {Object} acc
28
+ * @param {Object} alt
29
+ * @param {Object} altacc
30
+ * @param {Object} head
31
+ * @param {Object} vel
32
+ * @constructor
33
+ */
34
+ var Position = function(coords, timestamp) {
35
+ this.coords = coords;
36
+ this.timestamp = (timestamp !== 'undefined') ? timestamp : new Date().getTime();
37
+ };
38
+
39
+ /** @constructor */
40
+ var Coordinates = function(lat, lng, alt, acc, head, vel, altacc) {
41
+ /**
42
+ * The latitude of the position.
43
+ */
44
+ this.latitude = lat;
45
+ /**
46
+ * The longitude of the position,
47
+ */
48
+ this.longitude = lng;
49
+ /**
50
+ * The accuracy of the position.
51
+ */
52
+ this.accuracy = acc;
53
+ /**
54
+ * The altitude of the position.
55
+ */
56
+ this.altitude = alt;
57
+ /**
58
+ * The direction the device is moving at the position.
59
+ */
60
+ this.heading = head;
61
+ /**
62
+ * The velocity with which the device is moving at the position.
63
+ */
64
+ this.speed = vel;
65
+ /**
66
+ * The altitude accuracy of the position.
67
+ */
68
+ this.altitudeAccuracy = (altacc !== 'undefined') ? altacc : null;
69
+ };
70
+
71
+ /**
72
+ * This class specifies the options for requesting position data.
73
+ * @constructor
74
+ */
75
+ var PositionOptions = function() {
76
+ /**
77
+ * Specifies the desired position accuracy.
78
+ */
79
+ this.enableHighAccuracy = true;
80
+ /**
81
+ * The timeout after which if position data cannot be obtained the errorCallback
82
+ * is called.
83
+ */
84
+ this.timeout = 10000;
85
+ };
86
+
87
+ /**
88
+ * This class contains information about any GSP errors.
89
+ * @constructor
90
+ */
91
+ var PositionError = function() {
92
+ this.code = null;
93
+ this.message = "";
94
+ };
95
+
96
+ PositionError.UNKNOWN_ERROR = 0;
97
+ PositionError.PERMISSION_DENIED = 1;
98
+ PositionError.POSITION_UNAVAILABLE = 2;
99
+ PositionError.TIMEOUT = 3;
100
+ }
@@ -0,0 +1,439 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+
20
+ /*
21
+ * This is purely for the Android 1.5/1.6 HTML 5 Storage
22
+ * I was hoping that Android 2.0 would deprecate this, but given the fact that
23
+ * most manufacturers ship with Android 1.5 and do not do OTA Updates, this is required
24
+ */
25
+
26
+ if (!Cordova.hasResource("storage")) {
27
+ Cordova.addResource("storage");
28
+
29
+ /**
30
+ * SQL result set object
31
+ * PRIVATE METHOD
32
+ * @constructor
33
+ */
34
+ var DroidDB_Rows = function() {
35
+ this.resultSet = []; // results array
36
+ this.length = 0; // number of rows
37
+ };
38
+
39
+ /**
40
+ * Get item from SQL result set
41
+ *
42
+ * @param row The row number to return
43
+ * @return The row object
44
+ */
45
+ DroidDB_Rows.prototype.item = function(row) {
46
+ return this.resultSet[row];
47
+ };
48
+
49
+ /**
50
+ * SQL result set that is returned to user.
51
+ * PRIVATE METHOD
52
+ * @constructor
53
+ */
54
+ var DroidDB_Result = function() {
55
+ this.rows = new DroidDB_Rows();
56
+ };
57
+
58
+ /**
59
+ * Storage object that is called by native code when performing queries.
60
+ * PRIVATE METHOD
61
+ * @constructor
62
+ */
63
+ var DroidDB = function() {
64
+ this.queryQueue = {};
65
+ };
66
+
67
+ /**
68
+ * Callback from native code when query is complete.
69
+ * PRIVATE METHOD
70
+ *
71
+ * @param id Query id
72
+ */
73
+ DroidDB.prototype.completeQuery = function(id, data) {
74
+ var query = this.queryQueue[id];
75
+ if (query) {
76
+ try {
77
+ delete this.queryQueue[id];
78
+
79
+ // Get transaction
80
+ var tx = query.tx;
81
+
82
+ // If transaction hasn't failed
83
+ // Note: We ignore all query results if previous query
84
+ // in the same transaction failed.
85
+ if (tx && tx.queryList[id]) {
86
+
87
+ // Save query results
88
+ var r = new DroidDB_Result();
89
+ r.rows.resultSet = data;
90
+ r.rows.length = data.length;
91
+ try {
92
+ if (typeof query.successCallback === 'function') {
93
+ query.successCallback(query.tx, r);
94
+ }
95
+ } catch (ex) {
96
+ console.log("executeSql error calling user success callback: "+ex);
97
+ }
98
+
99
+ tx.queryComplete(id);
100
+ }
101
+ } catch (e) {
102
+ console.log("executeSql error: "+e);
103
+ }
104
+ }
105
+ };
106
+
107
+ /**
108
+ * Callback from native code when query fails
109
+ * PRIVATE METHOD
110
+ *
111
+ * @param reason Error message
112
+ * @param id Query id
113
+ */
114
+ DroidDB.prototype.fail = function(reason, id) {
115
+ var query = this.queryQueue[id];
116
+ if (query) {
117
+ try {
118
+ delete this.queryQueue[id];
119
+
120
+ // Get transaction
121
+ var tx = query.tx;
122
+
123
+ // If transaction hasn't failed
124
+ // Note: We ignore all query results if previous query
125
+ // in the same transaction failed.
126
+ if (tx && tx.queryList[id]) {
127
+ tx.queryList = {};
128
+
129
+ try {
130
+ if (typeof query.errorCallback === 'function') {
131
+ query.errorCallback(query.tx, reason);
132
+ }
133
+ } catch (ex) {
134
+ console.log("executeSql error calling user error callback: "+ex);
135
+ }
136
+
137
+ tx.queryFailed(id, reason);
138
+ }
139
+
140
+ } catch (e) {
141
+ console.log("executeSql error: "+e);
142
+ }
143
+ }
144
+ };
145
+
146
+ /**
147
+ * SQL query object
148
+ * PRIVATE METHOD
149
+ *
150
+ * @constructor
151
+ * @param tx The transaction object that this query belongs to
152
+ */
153
+ var DroidDB_Query = function(tx) {
154
+
155
+ // Set the id of the query
156
+ this.id = Cordova.createUUID();
157
+
158
+ // Add this query to the queue
159
+ droiddb.queryQueue[this.id] = this;
160
+
161
+ // Init result
162
+ this.resultSet = [];
163
+
164
+ // Set transaction that this query belongs to
165
+ this.tx = tx;
166
+
167
+ // Add this query to transaction list
168
+ this.tx.queryList[this.id] = this;
169
+
170
+ // Callbacks
171
+ this.successCallback = null;
172
+ this.errorCallback = null;
173
+
174
+ };
175
+
176
+ /**
177
+ * Transaction object
178
+ * PRIVATE METHOD
179
+ * @constructor
180
+ */
181
+ var DroidDB_Tx = function() {
182
+
183
+ // Set the id of the transaction
184
+ this.id = Cordova.createUUID();
185
+
186
+ // Callbacks
187
+ this.successCallback = null;
188
+ this.errorCallback = null;
189
+
190
+ // Query list
191
+ this.queryList = {};
192
+ };
193
+
194
+ /**
195
+ * Mark query in transaction as complete.
196
+ * If all queries are complete, call the user's transaction success callback.
197
+ *
198
+ * @param id Query id
199
+ */
200
+ DroidDB_Tx.prototype.queryComplete = function(id) {
201
+ delete this.queryList[id];
202
+
203
+ // If no more outstanding queries, then fire transaction success
204
+ if (this.successCallback) {
205
+ var count = 0;
206
+ var i;
207
+ for (i in this.queryList) {
208
+ if (this.queryList.hasOwnProperty(i)) {
209
+ count++;
210
+ }
211
+ }
212
+ if (count === 0) {
213
+ try {
214
+ this.successCallback();
215
+ } catch(e) {
216
+ console.log("Transaction error calling user success callback: " + e);
217
+ }
218
+ }
219
+ }
220
+ };
221
+
222
+ /**
223
+ * Mark query in transaction as failed.
224
+ *
225
+ * @param id Query id
226
+ * @param reason Error message
227
+ */
228
+ DroidDB_Tx.prototype.queryFailed = function(id, reason) {
229
+
230
+ // The sql queries in this transaction have already been run, since
231
+ // we really don't have a real transaction implemented in native code.
232
+ // However, the user callbacks for the remaining sql queries in transaction
233
+ // will not be called.
234
+ this.queryList = {};
235
+
236
+ if (this.errorCallback) {
237
+ try {
238
+ this.errorCallback(reason);
239
+ } catch(e) {
240
+ console.log("Transaction error calling user error callback: " + e);
241
+ }
242
+ }
243
+ };
244
+
245
+ /**
246
+ * Execute SQL statement
247
+ *
248
+ * @param sql SQL statement to execute
249
+ * @param params Statement parameters
250
+ * @param successCallback Success callback
251
+ * @param errorCallback Error callback
252
+ */
253
+ DroidDB_Tx.prototype.executeSql = function(sql, params, successCallback, errorCallback) {
254
+
255
+ // Init params array
256
+ if (typeof params === 'undefined') {
257
+ params = [];
258
+ }
259
+
260
+ // Create query and add to queue
261
+ var query = new DroidDB_Query(this);
262
+ droiddb.queryQueue[query.id] = query;
263
+
264
+ // Save callbacks
265
+ query.successCallback = successCallback;
266
+ query.errorCallback = errorCallback;
267
+
268
+ // Call native code
269
+ Cordova.exec(null, null, "Storage", "executeSql", [sql, params, query.id]);
270
+ };
271
+
272
+ var DatabaseShell = function() {
273
+ };
274
+
275
+ /**
276
+ * Start a transaction.
277
+ * Does not support rollback in event of failure.
278
+ *
279
+ * @param process {Function} The transaction function
280
+ * @param successCallback {Function}
281
+ * @param errorCallback {Function}
282
+ */
283
+ DatabaseShell.prototype.transaction = function(process, errorCallback, successCallback) {
284
+ var tx = new DroidDB_Tx();
285
+ tx.successCallback = successCallback;
286
+ tx.errorCallback = errorCallback;
287
+ try {
288
+ process(tx);
289
+ } catch (e) {
290
+ console.log("Transaction error: "+e);
291
+ if (tx.errorCallback) {
292
+ try {
293
+ tx.errorCallback(e);
294
+ } catch (ex) {
295
+ console.log("Transaction error calling user error callback: "+e);
296
+ }
297
+ }
298
+ }
299
+ };
300
+
301
+ /**
302
+ * Open database
303
+ *
304
+ * @param name Database name
305
+ * @param version Database version
306
+ * @param display_name Database display name
307
+ * @param size Database size in bytes
308
+ * @return Database object
309
+ */
310
+ var DroidDB_openDatabase = function(name, version, display_name, size) {
311
+ Cordova.exec(null, null, "Storage", "openDatabase", [name, version, display_name, size]);
312
+ var db = new DatabaseShell();
313
+ return db;
314
+ };
315
+
316
+ /**
317
+ * For browsers with no localStorage we emulate it with SQLite. Follows the w3c api.
318
+ * TODO: Do similar for sessionStorage.
319
+ */
320
+
321
+ /**
322
+ * @constructor
323
+ */
324
+ var CupcakeLocalStorage = function() {
325
+ try {
326
+
327
+ this.db = openDatabase('localStorage', '1.0', 'localStorage', 2621440);
328
+ var storage = {};
329
+ this.length = 0;
330
+ function setLength (length) {
331
+ this.length = length;
332
+ localStorage.length = length;
333
+ }
334
+ this.db.transaction(
335
+ function (transaction) {
336
+ var i;
337
+ transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
338
+ transaction.executeSql('SELECT * FROM storage', [], function(tx, result) {
339
+ for(var i = 0; i < result.rows.length; i++) {
340
+ storage[result.rows.item(i)['id']] = result.rows.item(i)['body'];
341
+ }
342
+ setLength(result.rows.length);
343
+ Cordova.initializationComplete("cupcakeStorage");
344
+ });
345
+
346
+ },
347
+ function (err) {
348
+ alert(err.message);
349
+ }
350
+ );
351
+ this.setItem = function(key, val) {
352
+ if (typeof(storage[key])=='undefined') {
353
+ this.length++;
354
+ }
355
+ storage[key] = val;
356
+ this.db.transaction(
357
+ function (transaction) {
358
+ transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
359
+ transaction.executeSql('REPLACE INTO storage (id, body) values(?,?)', [key,val]);
360
+ }
361
+ );
362
+ };
363
+ this.getItem = function(key) {
364
+ return storage[key];
365
+ };
366
+ this.removeItem = function(key) {
367
+ delete storage[key];
368
+ this.length--;
369
+ this.db.transaction(
370
+ function (transaction) {
371
+ transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
372
+ transaction.executeSql('DELETE FROM storage where id=?', [key]);
373
+ }
374
+ );
375
+ };
376
+ this.clear = function() {
377
+ storage = {};
378
+ this.length = 0;
379
+ this.db.transaction(
380
+ function (transaction) {
381
+ transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
382
+ transaction.executeSql('DELETE FROM storage', []);
383
+ }
384
+ );
385
+ };
386
+ this.key = function(index) {
387
+ var i = 0;
388
+ for (var j in storage) {
389
+ if (i==index) {
390
+ return j;
391
+ } else {
392
+ i++;
393
+ }
394
+ }
395
+ return null;
396
+ };
397
+
398
+ } catch(e) {
399
+ alert("Database error "+e+".");
400
+ return;
401
+ }
402
+ };
403
+
404
+ Cordova.addConstructor(function() {
405
+ var setupDroidDB = function() {
406
+ navigator.openDatabase = window.openDatabase = DroidDB_openDatabase;
407
+ window.droiddb = new DroidDB();
408
+ }
409
+ if (typeof window.openDatabase === "undefined") {
410
+ setupDroidDB();
411
+ } else {
412
+ window.openDatabase_orig = window.openDatabase;
413
+ window.openDatabase = function(name, version, desc, size){
414
+ // Some versions of Android will throw a SECURITY_ERR so we need
415
+ // to catch the exception and seutp our own DB handling.
416
+ var db = null;
417
+ try {
418
+ db = window.openDatabase_orig(name, version, desc, size);
419
+ }
420
+ catch (ex) {
421
+ db = null;
422
+ }
423
+
424
+ if (db == null) {
425
+ setupDroidDB();
426
+ return DroidDB_openDatabase(name, version, desc, size);
427
+ }
428
+ else {
429
+ return db;
430
+ }
431
+ };
432
+ }
433
+
434
+ if ((typeof window.localStorage == "undefined") || (window.localStorage == null)) {
435
+ navigator.localStorage = window.localStorage = new CupcakeLocalStorage();
436
+ Cordova.waitForInitialization("cupcakeStorage");
437
+ }
438
+ });
439
+ }
@@ -0,0 +1,27 @@
1
+ <!--
2
+ Licensed to the Apache Software Foundation (ASF) under one
3
+ or more contributor license agreements. See the NOTICE file
4
+ distributed with this work for additional information
5
+ regarding copyright ownership. The ASF licenses this file
6
+ to you under the Apache License, Version 2.0 (the
7
+ "License"); you may not use this file except in compliance
8
+ with the License. You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing,
13
+ software distributed under the License is distributed on an
14
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ KIND, either express or implied. See the License for the
16
+ specific language governing permissions and limitations
17
+ under the License.
18
+ -->
19
+ <html>
20
+ <head>
21
+ <title></title>
22
+ <script src="cordova-1.5.0.js"></script>
23
+ </head>
24
+ <body>
25
+
26
+ </body>
27
+ </html>