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,924 @@
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 (typeof Cordova === "undefined") {
21
+
22
+ /**
23
+ * The order of events during page load and Cordova startup is as follows:
24
+ *
25
+ * onDOMContentLoaded Internal event that is received when the web page is loaded and parsed.
26
+ * window.onload Body onload event.
27
+ * onNativeReady Internal event that indicates the Cordova native side is ready.
28
+ * onCordovaInit Internal event that kicks off creation of all Cordova JavaScript objects (runs constructors).
29
+ * onCordovaReady Internal event fired when all Cordova JavaScript objects have been created
30
+ * onCordovaInfoReady Internal event fired when device properties are available
31
+ * onDeviceReady User event fired to indicate that Cordova is ready
32
+ * onResume User event fired to indicate a start/resume lifecycle event
33
+ * onPause User event fired to indicate a pause lifecycle event
34
+ * onDestroy Internal event fired when app is being destroyed (User should use window.onunload event, not this one).
35
+ *
36
+ * The only Cordova events that user code should register for are:
37
+ * deviceready Cordova native code is initialized and Cordova APIs can be called from JavaScript
38
+ * pause App has moved to background
39
+ * resume App has returned to foreground
40
+ *
41
+ * Listeners can be registered as:
42
+ * document.addEventListener("deviceready", myDeviceReadyListener, false);
43
+ * document.addEventListener("resume", myResumeListener, false);
44
+ * document.addEventListener("pause", myPauseListener, false);
45
+ *
46
+ * The DOM lifecycle events should be used for saving and restoring state
47
+ * window.onload
48
+ * window.onunload
49
+ */
50
+
51
+ /**
52
+ * This represents the Cordova API itself, and provides a global namespace for accessing
53
+ * information about the state of Cordova.
54
+ * @class
55
+ */
56
+ var Cordova = {
57
+ documentEventHandler: {}, // Collection of custom document event handlers
58
+ windowEventHandler: {} // Collection of custom window event handlers
59
+ };
60
+
61
+ /**
62
+ * List of resource files loaded by Cordova.
63
+ * This is used to ensure JS and other files are loaded only once.
64
+ */
65
+ Cordova.resources = {base: true};
66
+
67
+ /**
68
+ * Determine if resource has been loaded by Cordova
69
+ *
70
+ * @param name
71
+ * @return
72
+ */
73
+ Cordova.hasResource = function(name) {
74
+ return Cordova.resources[name];
75
+ };
76
+
77
+ /**
78
+ * Add a resource to list of loaded resources by Cordova
79
+ *
80
+ * @param name
81
+ */
82
+ Cordova.addResource = function(name) {
83
+ Cordova.resources[name] = true;
84
+ };
85
+
86
+ /**
87
+ * Custom pub-sub channel that can have functions subscribed to it
88
+ * @constructor
89
+ */
90
+ Cordova.Channel = function (type)
91
+ {
92
+ this.type = type;
93
+ this.handlers = {};
94
+ this.guid = 0;
95
+ this.fired = false;
96
+ this.enabled = true;
97
+ };
98
+
99
+ /**
100
+ * Subscribes the given function to the channel. Any time that
101
+ * Channel.fire is called so too will the function.
102
+ * Optionally specify an execution context for the function
103
+ * and a guid that can be used to stop subscribing to the channel.
104
+ * Returns the guid.
105
+ */
106
+ Cordova.Channel.prototype.subscribe = function(f, c, g) {
107
+ // need a function to call
108
+ if (f === null) { return; }
109
+
110
+ var func = f;
111
+ if (typeof c === "object" && typeof f === "function") { func = Cordova.close(c, f); }
112
+
113
+ g = g || func.observer_guid || f.observer_guid || this.guid++;
114
+ func.observer_guid = g;
115
+ f.observer_guid = g;
116
+ this.handlers[g] = func;
117
+ return g;
118
+ };
119
+
120
+ /**
121
+ * Like subscribe but the function is only called once and then it
122
+ * auto-unsubscribes itself.
123
+ */
124
+ Cordova.Channel.prototype.subscribeOnce = function(f, c) {
125
+ var g = null;
126
+ var _this = this;
127
+ var m = function() {
128
+ f.apply(c || null, arguments);
129
+ _this.unsubscribe(g);
130
+ };
131
+ if (this.fired) {
132
+ if (typeof c === "object" && typeof f === "function") { f = Cordova.close(c, f); }
133
+ f.apply(this, this.fireArgs);
134
+ } else {
135
+ g = this.subscribe(m);
136
+ }
137
+ return g;
138
+ };
139
+
140
+ /**
141
+ * Unsubscribes the function with the given guid from the channel.
142
+ */
143
+ Cordova.Channel.prototype.unsubscribe = function(g) {
144
+ if (typeof g === "function") { g = g.observer_guid; }
145
+ this.handlers[g] = null;
146
+ delete this.handlers[g];
147
+ };
148
+
149
+ /**
150
+ * Calls all functions subscribed to this channel.
151
+ */
152
+ Cordova.Channel.prototype.fire = function(e) {
153
+ if (this.enabled) {
154
+ var fail = false;
155
+ var item, handler, rv;
156
+ for (item in this.handlers) {
157
+ if (this.handlers.hasOwnProperty(item)) {
158
+ handler = this.handlers[item];
159
+ if (typeof handler === "function") {
160
+ rv = (handler.apply(this, arguments) === false);
161
+ fail = fail || rv;
162
+ }
163
+ }
164
+ }
165
+ this.fired = true;
166
+ this.fireArgs = arguments;
167
+ return !fail;
168
+ }
169
+ return true;
170
+ };
171
+
172
+ /**
173
+ * Calls the provided function only after all of the channels specified
174
+ * have been fired.
175
+ */
176
+ Cordova.Channel.join = function(h, c) {
177
+ var i = c.length;
178
+ var f = function() {
179
+ if (!(--i)) {
180
+ h();
181
+ }
182
+ };
183
+ var len = i;
184
+ var j;
185
+ for (j=0; j<len; j++) {
186
+ if (!c[j].fired) {
187
+ c[j].subscribeOnce(f);
188
+ }
189
+ else {
190
+ i--;
191
+ }
192
+ }
193
+ if (!i) {
194
+ h();
195
+ }
196
+ };
197
+
198
+ /**
199
+ * Add an initialization function to a queue that ensures it will run and initialize
200
+ * application constructors only once Cordova has been initialized.
201
+ * @param {Function} func The function callback you want run once Cordova is initialized
202
+ */
203
+ Cordova.addConstructor = function(func) {
204
+ Cordova.onCordovaInit.subscribeOnce(function() {
205
+ try {
206
+ func();
207
+ } catch(e) {
208
+ console.log("Failed to run constructor: " + e);
209
+ }
210
+ });
211
+ };
212
+
213
+ /**
214
+ * Plugins object
215
+ */
216
+ if (!window.plugins) {
217
+ window.plugins = {};
218
+ }
219
+
220
+ /**
221
+ * Adds a plugin object to window.plugins.
222
+ * The plugin is accessed using window.plugins.<name>
223
+ *
224
+ * @param name The plugin name
225
+ * @param obj The plugin object
226
+ */
227
+ Cordova.addPlugin = function(name, obj) {
228
+ if (!window.plugins[name]) {
229
+ window.plugins[name] = obj;
230
+ }
231
+ else {
232
+ console.log("Error: Plugin "+name+" already exists.");
233
+ }
234
+ };
235
+
236
+ /**
237
+ * onDOMContentLoaded channel is fired when the DOM content
238
+ * of the page has been parsed.
239
+ */
240
+ Cordova.onDOMContentLoaded = new Cordova.Channel('onDOMContentLoaded');
241
+
242
+ /**
243
+ * onNativeReady channel is fired when the Cordova native code
244
+ * has been initialized.
245
+ */
246
+ Cordova.onNativeReady = new Cordova.Channel('onNativeReady');
247
+
248
+ /**
249
+ * onCordovaInit channel is fired when the web page is fully loaded and
250
+ * Cordova native code has been initialized.
251
+ */
252
+ Cordova.onCordovaInit = new Cordova.Channel('onCordovaInit');
253
+
254
+ /**
255
+ * onCordovaReady channel is fired when the JS Cordova objects have been created.
256
+ */
257
+ Cordova.onCordovaReady = new Cordova.Channel('onCordovaReady');
258
+
259
+ /**
260
+ * onCordovaInfoReady channel is fired when the Cordova device properties
261
+ * has been set.
262
+ */
263
+ Cordova.onCordovaInfoReady = new Cordova.Channel('onCordovaInfoReady');
264
+
265
+ /**
266
+ * onCordovaConnectionReady channel is fired when the Cordova connection properties
267
+ * has been set.
268
+ */
269
+ Cordova.onCordovaConnectionReady = new Cordova.Channel('onCordovaConnectionReady');
270
+
271
+ /**
272
+ * onDestroy channel is fired when the Cordova native code
273
+ * is destroyed. It is used internally.
274
+ * Window.onunload should be used by the user.
275
+ */
276
+ Cordova.onDestroy = new Cordova.Channel('onDestroy');
277
+ Cordova.onDestroy.subscribeOnce(function() {
278
+ Cordova.shuttingDown = true;
279
+ });
280
+ Cordova.shuttingDown = false;
281
+
282
+ // _nativeReady is global variable that the native side can set
283
+ // to signify that the native code is ready. It is a global since
284
+ // it may be called before any Cordova JS is ready.
285
+ if (typeof _nativeReady !== 'undefined') { Cordova.onNativeReady.fire(); }
286
+
287
+ /**
288
+ * onDeviceReady is fired only after all Cordova objects are created and
289
+ * the device properties are set.
290
+ */
291
+ Cordova.onDeviceReady = new Cordova.Channel('onDeviceReady');
292
+
293
+
294
+ // Array of channels that must fire before "deviceready" is fired
295
+ Cordova.deviceReadyChannelsArray = [ Cordova.onCordovaReady, Cordova.onCordovaInfoReady, Cordova.onCordovaConnectionReady];
296
+
297
+ // Hashtable of user defined channels that must also fire before "deviceready" is fired
298
+ Cordova.deviceReadyChannelsMap = {};
299
+
300
+ /**
301
+ * Indicate that a feature needs to be initialized before it is ready to be used.
302
+ * This holds up Cordova's "deviceready" event until the feature has been initialized
303
+ * and Cordova.initComplete(feature) is called.
304
+ *
305
+ * @param feature {String} The unique feature name
306
+ */
307
+ Cordova.waitForInitialization = function(feature) {
308
+ if (feature) {
309
+ var channel = new Cordova.Channel(feature);
310
+ Cordova.deviceReadyChannelsMap[feature] = channel;
311
+ Cordova.deviceReadyChannelsArray.push(channel);
312
+ }
313
+ };
314
+
315
+ /**
316
+ * Indicate that initialization code has completed and the feature is ready to be used.
317
+ *
318
+ * @param feature {String} The unique feature name
319
+ */
320
+ Cordova.initializationComplete = function(feature) {
321
+ var channel = Cordova.deviceReadyChannelsMap[feature];
322
+ if (channel) {
323
+ channel.fire();
324
+ }
325
+ };
326
+
327
+ /**
328
+ * Create all Cordova objects once page has fully loaded and native side is ready.
329
+ */
330
+ Cordova.Channel.join(function() {
331
+
332
+ // Start listening for XHR callbacks
333
+ setTimeout(function() {
334
+ if (Cordova.UsePolling) {
335
+ Cordova.JSCallbackPolling();
336
+ }
337
+ else {
338
+ var polling = prompt("usePolling", "gap_callbackServer:");
339
+ Cordova.UsePolling = polling;
340
+ if (polling == "true") {
341
+ Cordova.UsePolling = true;
342
+ Cordova.JSCallbackPolling();
343
+ }
344
+ else {
345
+ Cordova.UsePolling = false;
346
+ Cordova.JSCallback();
347
+ }
348
+ }
349
+ }, 1);
350
+
351
+ // Run Cordova constructors
352
+ Cordova.onCordovaInit.fire();
353
+
354
+ // Fire event to notify that all objects are created
355
+ Cordova.onCordovaReady.fire();
356
+
357
+ // Fire onDeviceReady event once all constructors have run and Cordova info has been
358
+ // received from native side, and any user defined initialization channels.
359
+ Cordova.Channel.join(function() {
360
+ // Let native code know we are inited on JS side
361
+ prompt("", "gap_init:");
362
+
363
+ Cordova.onDeviceReady.fire();
364
+ }, Cordova.deviceReadyChannelsArray);
365
+
366
+ }, [ Cordova.onDOMContentLoaded, Cordova.onNativeReady ]);
367
+
368
+ // Listen for DOMContentLoaded and notify our channel subscribers
369
+ document.addEventListener('DOMContentLoaded', function() {
370
+ Cordova.onDOMContentLoaded.fire();
371
+ }, false);
372
+
373
+ // Intercept calls to document.addEventListener and watch for deviceready
374
+ Cordova.m_document_addEventListener = document.addEventListener;
375
+
376
+ // Intercept calls to window.addEventListener
377
+ Cordova.m_window_addEventListener = window.addEventListener;
378
+
379
+ /**
380
+ * Add a custom window event handler.
381
+ *
382
+ * @param {String} event The event name that callback handles
383
+ * @param {Function} callback The event handler
384
+ */
385
+ Cordova.addWindowEventHandler = function(event, callback) {
386
+ Cordova.windowEventHandler[event] = callback;
387
+ };
388
+
389
+ /**
390
+ * Add a custom document event handler.
391
+ *
392
+ * @param {String} event The event name that callback handles
393
+ * @param {Function} callback The event handler
394
+ */
395
+ Cordova.addDocumentEventHandler = function(event, callback) {
396
+ Cordova.documentEventHandler[event] = callback;
397
+ };
398
+
399
+ /**
400
+ * Intercept adding document event listeners and handle our own
401
+ *
402
+ * @param {Object} evt
403
+ * @param {Function} handler
404
+ * @param capture
405
+ */
406
+ document.addEventListener = function(evt, handler, capture) {
407
+ var e = evt.toLowerCase();
408
+ if (e === 'deviceready') {
409
+ Cordova.onDeviceReady.subscribeOnce(handler);
410
+ }
411
+ else {
412
+ // If subscribing to Android backbutton
413
+ if (e === 'backbutton') {
414
+ Cordova.exec(null, null, "App", "overrideBackbutton", [true]);
415
+ }
416
+
417
+ // If subscribing to an event that is handled by a plugin
418
+ else if (typeof Cordova.documentEventHandler[e] !== "undefined") {
419
+ if (Cordova.documentEventHandler[e](e, handler, true)) {
420
+ return; // Stop default behavior
421
+ }
422
+ }
423
+
424
+ Cordova.m_document_addEventListener.call(document, evt, handler, capture);
425
+ }
426
+ };
427
+
428
+ /**
429
+ * Intercept adding window event listeners and handle our own
430
+ *
431
+ * @param {Object} evt
432
+ * @param {Function} handler
433
+ * @param capture
434
+ */
435
+ window.addEventListener = function(evt, handler, capture) {
436
+ var e = evt.toLowerCase();
437
+
438
+ // If subscribing to an event that is handled by a plugin
439
+ if (typeof Cordova.windowEventHandler[e] !== "undefined") {
440
+ if (Cordova.windowEventHandler[e](e, handler, true)) {
441
+ return; // Stop default behavior
442
+ }
443
+ }
444
+
445
+ Cordova.m_window_addEventListener.call(window, evt, handler, capture);
446
+ };
447
+
448
+ // Intercept calls to document.removeEventListener and watch for events that
449
+ // are generated by Cordova native code
450
+ Cordova.m_document_removeEventListener = document.removeEventListener;
451
+
452
+ // Intercept calls to window.removeEventListener
453
+ Cordova.m_window_removeEventListener = window.removeEventListener;
454
+
455
+ /**
456
+ * Intercept removing document event listeners and handle our own
457
+ *
458
+ * @param {Object} evt
459
+ * @param {Function} handler
460
+ * @param capture
461
+ */
462
+ document.removeEventListener = function(evt, handler, capture) {
463
+ var e = evt.toLowerCase();
464
+
465
+ // If unsubscribing to Android backbutton
466
+ if (e === 'backbutton') {
467
+ Cordova.exec(null, null, "App", "overrideBackbutton", [false]);
468
+ }
469
+
470
+ // If unsubcribing from an event that is handled by a plugin
471
+ if (typeof Cordova.documentEventHandler[e] !== "undefined") {
472
+ if (Cordova.documentEventHandler[e](e, handler, false)) {
473
+ return; // Stop default behavior
474
+ }
475
+ }
476
+
477
+ Cordova.m_document_removeEventListener.call(document, evt, handler, capture);
478
+ };
479
+
480
+ /**
481
+ * Intercept removing window event listeners and handle our own
482
+ *
483
+ * @param {Object} evt
484
+ * @param {Function} handler
485
+ * @param capture
486
+ */
487
+ window.removeEventListener = function(evt, handler, capture) {
488
+ var e = evt.toLowerCase();
489
+
490
+ // If unsubcribing from an event that is handled by a plugin
491
+ if (typeof Cordova.windowEventHandler[e] !== "undefined") {
492
+ if (Cordova.windowEventHandler[e](e, handler, false)) {
493
+ return; // Stop default behavior
494
+ }
495
+ }
496
+
497
+ Cordova.m_window_removeEventListener.call(window, evt, handler, capture);
498
+ };
499
+
500
+ /**
501
+ * Method to fire document event
502
+ *
503
+ * @param {String} type The event type to fire
504
+ * @param {Object} data Data to send with event
505
+ */
506
+ Cordova.fireDocumentEvent = function(type, data) {
507
+ var e = document.createEvent('Events');
508
+ e.initEvent(type);
509
+ if (data) {
510
+ for (var i in data) {
511
+ e[i] = data[i];
512
+ }
513
+ }
514
+ document.dispatchEvent(e);
515
+ };
516
+
517
+ /**
518
+ * Method to fire window event
519
+ *
520
+ * @param {String} type The event type to fire
521
+ * @param {Object} data Data to send with event
522
+ */
523
+ Cordova.fireWindowEvent = function(type, data) {
524
+ var e = document.createEvent('Events');
525
+ e.initEvent(type);
526
+ if (data) {
527
+ for (var i in data) {
528
+ e[i] = data[i];
529
+ }
530
+ }
531
+ window.dispatchEvent(e);
532
+ };
533
+
534
+ /**
535
+ * Does a deep clone of the object.
536
+ *
537
+ * @param obj
538
+ * @return {Object}
539
+ */
540
+ Cordova.clone = function(obj) {
541
+ var i, retVal;
542
+ if(!obj) {
543
+ return obj;
544
+ }
545
+
546
+ if(obj instanceof Array){
547
+ retVal = [];
548
+ for(i = 0; i < obj.length; ++i){
549
+ retVal.push(Cordova.clone(obj[i]));
550
+ }
551
+ return retVal;
552
+ }
553
+
554
+ if (typeof obj === "function") {
555
+ return obj;
556
+ }
557
+
558
+ if(!(obj instanceof Object)){
559
+ return obj;
560
+ }
561
+
562
+ if (obj instanceof Date) {
563
+ return obj;
564
+ }
565
+
566
+ retVal = {};
567
+ for(i in obj){
568
+ if(!(i in retVal) || retVal[i] !== obj[i]) {
569
+ retVal[i] = Cordova.clone(obj[i]);
570
+ }
571
+ }
572
+ return retVal;
573
+ };
574
+
575
+ Cordova.callbackId = 0;
576
+ Cordova.callbacks = {};
577
+ Cordova.callbackStatus = {
578
+ NO_RESULT: 0,
579
+ OK: 1,
580
+ CLASS_NOT_FOUND_EXCEPTION: 2,
581
+ ILLEGAL_ACCESS_EXCEPTION: 3,
582
+ INSTANTIATION_EXCEPTION: 4,
583
+ MALFORMED_URL_EXCEPTION: 5,
584
+ IO_EXCEPTION: 6,
585
+ INVALID_ACTION: 7,
586
+ JSON_EXCEPTION: 8,
587
+ ERROR: 9
588
+ };
589
+
590
+
591
+ /**
592
+ * Execute a Cordova command. It is up to the native side whether this action is synch or async.
593
+ * The native side can return:
594
+ * Synchronous: PluginResult object as a JSON string
595
+ * Asynchrounous: Empty string ""
596
+ * If async, the native side will Cordova.callbackSuccess or Cordova.callbackError,
597
+ * depending upon the result of the action.
598
+ *
599
+ * @param {Function} success The success callback
600
+ * @param {Function} fail The fail callback
601
+ * @param {String} service The name of the service to use
602
+ * @param {String} action Action to be run in Cordova
603
+ * @param {Array.<String>} [args] Zero or more arguments to pass to the method
604
+ */
605
+ Cordova.exec = function(success, fail, service, action, args) {
606
+ try {
607
+ var callbackId = service + Cordova.callbackId++;
608
+ if (success || fail) {
609
+ Cordova.callbacks[callbackId] = {success:success, fail:fail};
610
+ }
611
+
612
+ var r = prompt(JSON.stringify(args), "gap:"+JSON.stringify([service, action, callbackId, true]));
613
+
614
+ // If a result was returned
615
+ if (r.length > 0) {
616
+ eval("var v="+r+";");
617
+
618
+ // If status is OK, then return value back to caller
619
+ if (v.status === Cordova.callbackStatus.OK) {
620
+
621
+ // If there is a success callback, then call it now with
622
+ // returned value
623
+ if (success) {
624
+ try {
625
+ success(v.message);
626
+ } catch (e) {
627
+ console.log("Error in success callback: " + callbackId + " = " + e);
628
+ }
629
+
630
+ // Clear callback if not expecting any more results
631
+ if (!v.keepCallback) {
632
+ delete Cordova.callbacks[callbackId];
633
+ }
634
+ }
635
+ return v.message;
636
+ }
637
+
638
+ // If no result
639
+ else if (v.status === Cordova.callbackStatus.NO_RESULT) {
640
+
641
+ // Clear callback if not expecting any more results
642
+ if (!v.keepCallback) {
643
+ delete Cordova.callbacks[callbackId];
644
+ }
645
+ }
646
+
647
+ // If error, then display error
648
+ else {
649
+ console.log("Error: Status="+v.status+" Message="+v.message);
650
+
651
+ // If there is a fail callback, then call it now with returned value
652
+ if (fail) {
653
+ try {
654
+ fail(v.message);
655
+ }
656
+ catch (e1) {
657
+ console.log("Error in error callback: "+callbackId+" = "+e1);
658
+ }
659
+
660
+ // Clear callback if not expecting any more results
661
+ if (!v.keepCallback) {
662
+ delete Cordova.callbacks[callbackId];
663
+ }
664
+ }
665
+ return null;
666
+ }
667
+ }
668
+ } catch (e2) {
669
+ console.log("Error: "+e2);
670
+ }
671
+ };
672
+
673
+ /**
674
+ * Called by native code when returning successful result from an action.
675
+ *
676
+ * @param callbackId
677
+ * @param args
678
+ */
679
+ Cordova.callbackSuccess = function(callbackId, args) {
680
+ if (Cordova.callbacks[callbackId]) {
681
+
682
+ // If result is to be sent to callback
683
+ if (args.status === Cordova.callbackStatus.OK) {
684
+ try {
685
+ if (Cordova.callbacks[callbackId].success) {
686
+ Cordova.callbacks[callbackId].success(args.message);
687
+ }
688
+ }
689
+ catch (e) {
690
+ console.log("Error in success callback: "+callbackId+" = "+e);
691
+ }
692
+ }
693
+
694
+ // Clear callback if not expecting any more results
695
+ if (!args.keepCallback) {
696
+ delete Cordova.callbacks[callbackId];
697
+ }
698
+ }
699
+ };
700
+
701
+ /**
702
+ * Called by native code when returning error result from an action.
703
+ *
704
+ * @param callbackId
705
+ * @param args
706
+ */
707
+ Cordova.callbackError = function(callbackId, args) {
708
+ if (Cordova.callbacks[callbackId]) {
709
+ try {
710
+ if (Cordova.callbacks[callbackId].fail) {
711
+ Cordova.callbacks[callbackId].fail(args.message);
712
+ }
713
+ }
714
+ catch (e) {
715
+ console.log("Error in error callback: "+callbackId+" = "+e);
716
+ }
717
+
718
+ // Clear callback if not expecting any more results
719
+ if (!args.keepCallback) {
720
+ delete Cordova.callbacks[callbackId];
721
+ }
722
+ }
723
+ };
724
+
725
+ Cordova.JSCallbackPort = null;
726
+ Cordova.JSCallbackToken = null;
727
+
728
+ /**
729
+ * This is only for Android.
730
+ *
731
+ * Internal function that uses XHR to call into Cordova Java code and retrieve
732
+ * any JavaScript code that needs to be run. This is used for callbacks from
733
+ * Java to JavaScript.
734
+ */
735
+ Cordova.JSCallback = function() {
736
+
737
+ // Exit if shutting down app
738
+ if (Cordova.shuttingDown) {
739
+ return;
740
+ }
741
+
742
+ // If polling flag was changed, start using polling from now on
743
+ if (Cordova.UsePolling) {
744
+ Cordova.JSCallbackPolling();
745
+ return;
746
+ }
747
+
748
+ var xmlhttp = new XMLHttpRequest();
749
+
750
+ // Callback function when XMLHttpRequest is ready
751
+ xmlhttp.onreadystatechange=function(){
752
+ if(xmlhttp.readyState === 4){
753
+
754
+ // Exit if shutting down app
755
+ if (Cordova.shuttingDown) {
756
+ return;
757
+ }
758
+
759
+ // If callback has JavaScript statement to execute
760
+ if (xmlhttp.status === 200) {
761
+
762
+ // Need to url decode the response
763
+ var msg = decodeURIComponent(xmlhttp.responseText);
764
+ setTimeout(function() {
765
+ try {
766
+ var t = eval(msg);
767
+ }
768
+ catch (e) {
769
+ // If we're getting an error here, seeing the message will help in debugging
770
+ console.log("JSCallback: Message from Server: " + msg);
771
+ console.log("JSCallback Error: "+e);
772
+ }
773
+ }, 1);
774
+ setTimeout(Cordova.JSCallback, 1);
775
+ }
776
+
777
+ // If callback ping (used to keep XHR request from timing out)
778
+ else if (xmlhttp.status === 404) {
779
+ setTimeout(Cordova.JSCallback, 10);
780
+ }
781
+
782
+ // If security error
783
+ else if (xmlhttp.status === 403) {
784
+ console.log("JSCallback Error: Invalid token. Stopping callbacks.");
785
+ }
786
+
787
+ // If server is stopping
788
+ else if (xmlhttp.status === 503) {
789
+ console.log("JSCallback Server Closed: Stopping callbacks.");
790
+ }
791
+
792
+ // If request wasn't GET
793
+ else if (xmlhttp.status === 400) {
794
+ console.log("JSCallback Error: Bad request. Stopping callbacks.");
795
+ }
796
+
797
+ // If error, revert to polling
798
+ else {
799
+ console.log("JSCallback Error: Request failed.");
800
+ Cordova.UsePolling = true;
801
+ Cordova.JSCallbackPolling();
802
+ }
803
+ }
804
+ };
805
+
806
+ if (Cordova.JSCallbackPort === null) {
807
+ Cordova.JSCallbackPort = prompt("getPort", "gap_callbackServer:");
808
+ }
809
+ if (Cordova.JSCallbackToken === null) {
810
+ Cordova.JSCallbackToken = prompt("getToken", "gap_callbackServer:");
811
+ }
812
+ xmlhttp.open("GET", "http://127.0.0.1:"+Cordova.JSCallbackPort+"/"+Cordova.JSCallbackToken , true);
813
+ xmlhttp.send();
814
+ };
815
+
816
+ /**
817
+ * The polling period to use with JSCallbackPolling.
818
+ * This can be changed by the application. The default is 50ms.
819
+ */
820
+ Cordova.JSCallbackPollingPeriod = 50;
821
+
822
+ /**
823
+ * Flag that can be set by the user to force polling to be used or force XHR to be used.
824
+ */
825
+ Cordova.UsePolling = false; // T=use polling, F=use XHR
826
+
827
+ /**
828
+ * This is only for Android.
829
+ *
830
+ * Internal function that uses polling to call into Cordova Java code and retrieve
831
+ * any JavaScript code that needs to be run. This is used for callbacks from
832
+ * Java to JavaScript.
833
+ */
834
+ Cordova.JSCallbackPolling = function() {
835
+
836
+ // Exit if shutting down app
837
+ if (Cordova.shuttingDown) {
838
+ return;
839
+ }
840
+
841
+ // If polling flag was changed, stop using polling from now on
842
+ if (!Cordova.UsePolling) {
843
+ Cordova.JSCallback();
844
+ return;
845
+ }
846
+
847
+ var msg = prompt("", "gap_poll:");
848
+ if (msg) {
849
+ setTimeout(function() {
850
+ try {
851
+ var t = eval(""+msg);
852
+ }
853
+ catch (e) {
854
+ console.log("JSCallbackPolling: Message from Server: " + msg);
855
+ console.log("JSCallbackPolling Error: "+e);
856
+ }
857
+ }, 1);
858
+ setTimeout(Cordova.JSCallbackPolling, 1);
859
+ }
860
+ else {
861
+ setTimeout(Cordova.JSCallbackPolling, Cordova.JSCallbackPollingPeriod);
862
+ }
863
+ };
864
+
865
+ /**
866
+ * Create a UUID
867
+ *
868
+ * @return {String}
869
+ */
870
+ Cordova.createUUID = function() {
871
+ return Cordova.UUIDcreatePart(4) + '-' +
872
+ Cordova.UUIDcreatePart(2) + '-' +
873
+ Cordova.UUIDcreatePart(2) + '-' +
874
+ Cordova.UUIDcreatePart(2) + '-' +
875
+ Cordova.UUIDcreatePart(6);
876
+ };
877
+
878
+ Cordova.UUIDcreatePart = function(length) {
879
+ var uuidpart = "";
880
+ var i, uuidchar;
881
+ for (i=0; i<length; i++) {
882
+ uuidchar = parseInt((Math.random() * 256),0).toString(16);
883
+ if (uuidchar.length === 1) {
884
+ uuidchar = "0" + uuidchar;
885
+ }
886
+ uuidpart += uuidchar;
887
+ }
888
+ return uuidpart;
889
+ };
890
+
891
+ Cordova.close = function(context, func, params) {
892
+ if (typeof params === 'undefined') {
893
+ return function() {
894
+ return func.apply(context, arguments);
895
+ };
896
+ } else {
897
+ return function() {
898
+ return func.apply(context, params);
899
+ };
900
+ }
901
+ };
902
+
903
+ /**
904
+ * Load a JavaScript file after page has loaded.
905
+ *
906
+ * @param {String} jsfile The url of the JavaScript file to load.
907
+ * @param {Function} successCallback The callback to call when the file has been loaded.
908
+ */
909
+ Cordova.includeJavascript = function(jsfile, successCallback) {
910
+ var id = document.getElementsByTagName("head")[0];
911
+ var el = document.createElement('script');
912
+ el.type = 'text/javascript';
913
+ if (typeof successCallback === 'function') {
914
+ el.onload = successCallback;
915
+ }
916
+ el.src = jsfile;
917
+ id.appendChild(el);
918
+ };
919
+
920
+ /**
921
+ * Legacy variable for old plugins.
922
+ */
923
+ var PhoneGap = Cordova;
924
+ }