mobile_template 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. data/lib/mobile_template/version.rb +1 -1
  2. data/mobile_template.gemspec +1 -1
  3. data/templates/assets/Gemfile +1 -1
  4. data/templates/assets/source/javascripts/vendor/cordova.js +2106 -1975
  5. data/templates/assets/source/javascripts/vendor/jquery.js +614 -477
  6. data/templates/assets/source/javascripts/vendor/jquery.mobile.js +519 -378
  7. data/templates/assets/source/stylesheets/vendor/jquery.mobile.css.scss +683 -502
  8. data/templates/cordova_android/VERSION +1 -1
  9. data/templates/cordova_android/bin/create +5 -1
  10. data/templates/cordova_android/bin/templates/project/cordova/create +5 -0
  11. data/templates/cordova_android/bin/templates/project/cordova/debug +1 -1
  12. data/templates/cordova_android/bin/templates/project/cordova/templates/project/AndroidManifest.xml +18 -25
  13. data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/index.html +6 -6
  14. data/templates/cordova_android/framework/assets/js/cordova.android.js +2106 -1975
  15. data/templates/cordova_android/framework/assets/www/index.html +1 -1
  16. data/templates/cordova_android/framework/build.xml +2 -42
  17. data/templates/cordova_android/framework/project.properties +1 -1
  18. data/templates/cordova_android/framework/res/drawable/splash.png +0 -0
  19. data/templates/cordova_android/framework/res/drawable-hdpi/icon.png +0 -0
  20. data/templates/cordova_android/framework/res/drawable-ldpi/icon.png +0 -0
  21. data/templates/cordova_android/framework/res/drawable-mdpi/icon.png +0 -0
  22. data/templates/cordova_android/framework/res/xml/plugins.xml +2 -1
  23. data/templates/cordova_android/framework/src/com/phonegap/api/PluginManager.java +1 -0
  24. data/templates/cordova_android/framework/src/org/apache/cordova/AudioPlayer.java +24 -16
  25. data/templates/cordova_android/framework/src/org/apache/cordova/CameraLauncher.java +35 -10
  26. data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessor.java +2 -1
  27. data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessorSdk5.java +67 -65
  28. data/templates/cordova_android/framework/src/org/apache/cordova/ContactManager.java +51 -63
  29. data/templates/cordova_android/framework/src/org/apache/cordova/CordovaChromeClient.java +3 -0
  30. data/templates/cordova_android/framework/src/org/apache/cordova/CordovaWebViewClient.java +6 -2
  31. data/templates/cordova_android/framework/src/org/apache/cordova/Device.java +108 -108
  32. data/templates/cordova_android/framework/src/org/apache/cordova/DroidGap.java +110 -77
  33. data/templates/cordova_android/framework/src/org/apache/cordova/FileTransfer.java +90 -44
  34. data/templates/cordova_android/framework/src/org/apache/cordova/FileUtils.java +20 -20
  35. data/templates/cordova_android/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java +2 -2
  36. data/templates/cordova_android/framework/src/org/apache/cordova/NetworkManager.java +7 -8
  37. data/templates/cordova_android/framework/src/org/apache/cordova/Notification.java +2 -2
  38. data/templates/cordova_android/framework/src/org/apache/cordova/SplashScreen.java +23 -0
  39. data/templates/cordova_android/framework/src/org/apache/cordova/Storage.java +3 -3
  40. data/templates/cordova_android/framework/src/org/apache/cordova/api/CordovaInterface.java +2 -0
  41. data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginEntry.java +119 -0
  42. data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginManager.java +260 -258
  43. data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginResult.java +2 -2
  44. data/templates/cordova_android/releasenotes.md +42 -0
  45. data/templates/cordova_android/test/.classpath +8 -0
  46. data/templates/cordova_android/test/.project +33 -0
  47. data/templates/cordova_android/test/AndroidManifest.xml +87 -0
  48. data/templates/cordova_android/test/README.md +23 -0
  49. data/templates/cordova_android/test/ant.properties +17 -0
  50. data/templates/cordova_android/test/assets/www/backbuttonmultipage/index.html +23 -0
  51. data/templates/cordova_android/test/assets/www/backbuttonmultipage/sample2.html +23 -0
  52. data/templates/cordova_android/test/assets/www/backbuttonmultipage/sample3.html +26 -0
  53. data/templates/cordova_android/test/assets/www/background/index.html +99 -0
  54. data/templates/cordova_android/test/assets/www/background/index2.html +98 -0
  55. data/templates/cordova_android/test/assets/www/cordova-1.6.0.js +4985 -0
  56. data/templates/cordova_android/test/assets/www/cordova.js +2 -0
  57. data/templates/cordova_android/test/assets/www/htmlnotfound/error.html +1 -0
  58. data/templates/cordova_android/test/assets/www/iframe/index.html +33 -0
  59. data/templates/cordova_android/test/assets/www/iframe/index2.html +24 -0
  60. data/templates/cordova_android/test/assets/www/index.html +47 -0
  61. data/templates/cordova_android/test/assets/www/jqmtabbackbutton/index.html +49 -0
  62. data/templates/cordova_android/test/assets/www/jqmtabbackbutton/tab1.html +29 -0
  63. data/templates/cordova_android/test/assets/www/jqmtabbackbutton/tab2.html +30 -0
  64. data/templates/cordova_android/test/assets/www/jqmtabbackbutton/tab3.html +30 -0
  65. data/templates/cordova_android/test/assets/www/lifecycle/index.html +108 -0
  66. data/templates/cordova_android/test/assets/www/lifecycle/index2.html +104 -0
  67. data/templates/cordova_android/test/assets/www/main.js +150 -0
  68. data/templates/cordova_android/test/assets/www/master.css +117 -0
  69. data/templates/cordova_android/test/assets/www/menus/index.html +29 -0
  70. data/templates/cordova_android/test/assets/www/splashscreen/index.html +22 -0
  71. data/templates/cordova_android/test/assets/www/userwebview/index.html +49 -0
  72. data/templates/cordova_android/test/assets/www/whitelist/index.html +29 -0
  73. data/templates/cordova_android/test/assets/www/whitelist/index2.html +23 -0
  74. data/templates/cordova_android/test/assets/www/xhr/index.html +48 -0
  75. data/templates/cordova_android/test/build.xml +85 -0
  76. data/templates/cordova_android/test/libs/cordova-1.6.0.jar +0 -0
  77. data/templates/cordova_android/test/project.properties +11 -0
  78. data/templates/cordova_android/{framework → test}/res/drawable/icon.png +0 -0
  79. data/templates/cordova_android/test/res/drawable/sandy.jpg +0 -0
  80. data/templates/cordova_android/test/res/drawable-hdpi/ic_launcher.png +0 -0
  81. data/templates/cordova_android/test/res/drawable-ldpi/ic_launcher.png +0 -0
  82. data/templates/cordova_android/test/res/drawable-mdpi/ic_launcher.png +0 -0
  83. data/templates/cordova_android/test/res/layout/main.xml +13 -0
  84. data/templates/cordova_android/test/res/values/strings.xml +4 -0
  85. data/templates/cordova_android/{bin/templates/project/cordova/templates/project → test}/res/xml/cordova.xml +0 -0
  86. data/templates/cordova_android/{bin/templates/project/cordova/templates/project → test}/res/xml/plugins.xml +1 -1
  87. data/templates/cordova_android/test/src/org/apache/cordova/test/ActivityPlugin.java +81 -0
  88. data/templates/cordova_android/test/src/org/apache/cordova/test/FixWebView.java +43 -0
  89. data/templates/cordova_android/test/src/org/apache/cordova/test/backbuttonmultipage.java +30 -0
  90. data/templates/cordova_android/test/src/org/apache/cordova/test/background.java +34 -0
  91. data/templates/cordova_android/test/src/org/apache/cordova/test/errorurl.java +32 -0
  92. data/templates/cordova_android/test/src/org/apache/cordova/test/htmlnotfound.java +31 -0
  93. data/templates/cordova_android/test/src/org/apache/cordova/test/iframe.java +30 -0
  94. data/templates/cordova_android/test/src/org/apache/cordova/test/jqmtabbackbutton.java +30 -0
  95. data/templates/cordova_android/test/src/org/apache/cordova/test/lifecycle.java +30 -0
  96. data/templates/cordova_android/test/src/org/apache/cordova/test/loading.java +31 -0
  97. data/templates/cordova_android/test/src/org/apache/cordova/test/menus.java +80 -0
  98. data/templates/cordova_android/test/src/org/apache/cordova/test/splashscreen.java +35 -0
  99. data/templates/cordova_android/test/src/org/apache/cordova/test/tests.java +32 -0
  100. data/templates/cordova_android/test/src/org/apache/cordova/test/timeout.java +34 -0
  101. data/templates/cordova_android/test/src/org/apache/cordova/test/userwebview.java +72 -0
  102. data/templates/cordova_android/test/src/org/apache/cordova/test/whitelist.java +51 -0
  103. data/templates/cordova_android/test/src/org/apache/cordova/test/xhr.java +30 -0
  104. metadata +83 -30
  105. data/templates/cordova_android/framework/assets/js/accelerometer.js +0 -137
  106. data/templates/cordova_android/framework/assets/js/app.js +0 -89
  107. data/templates/cordova_android/framework/assets/js/battery.js +0 -134
  108. data/templates/cordova_android/framework/assets/js/camera.js +0 -168
  109. data/templates/cordova_android/framework/assets/js/capture.js +0 -203
  110. data/templates/cordova_android/framework/assets/js/compass.js +0 -168
  111. data/templates/cordova_android/framework/assets/js/contact.js +0 -310
  112. data/templates/cordova_android/framework/assets/js/cordova.js.base +0 -924
  113. data/templates/cordova_android/framework/assets/js/crypto.js +0 -54
  114. data/templates/cordova_android/framework/assets/js/device.js +0 -83
  115. data/templates/cordova_android/framework/assets/js/file.js +0 -1082
  116. data/templates/cordova_android/framework/assets/js/filetransfer.js +0 -125
  117. data/templates/cordova_android/framework/assets/js/geolocation.js +0 -209
  118. data/templates/cordova_android/framework/assets/js/header.txt +0 -19
  119. data/templates/cordova_android/framework/assets/js/media.js +0 -233
  120. data/templates/cordova_android/framework/assets/js/network.js +0 -100
  121. data/templates/cordova_android/framework/assets/js/notification.js +0 -133
  122. data/templates/cordova_android/framework/assets/js/position.js +0 -100
  123. data/templates/cordova_android/framework/assets/js/storage.js +0 -439
@@ -0,0 +1,4985 @@
1
+ // File generated at :: Tue Apr 10 2012 08:34:16 GMT-0500 (CDT)
2
+
3
+ /*
4
+ Licensed to the Apache Software Foundation (ASF) under one
5
+ or more contributor license agreements. See the NOTICE file
6
+ distributed with this work for additional information
7
+ regarding copyright ownership. The ASF licenses this file
8
+ to you under the Apache License, Version 2.0 (the
9
+ "License"); you may not use this file except in compliance
10
+ with the License. You may obtain a copy of the License at
11
+
12
+ http://www.apache.org/licenses/LICENSE-2.0
13
+
14
+ Unless required by applicable law or agreed to in writing,
15
+ software distributed under the License is distributed on an
16
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17
+ KIND, either express or implied. See the License for the
18
+ specific language governing permissions and limitations
19
+ under the License.
20
+ */
21
+
22
+ ;(function() {
23
+
24
+ // file: lib/scripts/require.js
25
+ var require,
26
+ define;
27
+
28
+ (function () {
29
+ var modules = {};
30
+
31
+ function build(module) {
32
+ var factory = module.factory;
33
+ module.exports = {};
34
+ delete module.factory;
35
+ factory(require, module.exports, module);
36
+ return module.exports;
37
+ }
38
+
39
+ require = function (id) {
40
+ if (!modules[id]) {
41
+ throw "module " + id + " not found";
42
+ }
43
+ return modules[id].factory ? build(modules[id]) : modules[id].exports;
44
+ };
45
+
46
+ define = function (id, factory) {
47
+ if (modules[id]) {
48
+ throw "module " + id + " already defined";
49
+ }
50
+
51
+ modules[id] = {
52
+ id: id,
53
+ factory: factory
54
+ };
55
+ };
56
+
57
+ define.remove = function (id) {
58
+ delete modules[id];
59
+ };
60
+
61
+ })();
62
+
63
+ //Export for use in node
64
+ if (typeof module === "object" && typeof require === "function") {
65
+ module.exports.require = require;
66
+ module.exports.define = define;
67
+ }
68
+
69
+ // file: lib/cordova.js
70
+ define("cordova", function(require, exports, module) {
71
+ var channel = require('cordova/channel');
72
+ /**
73
+ * Intercept calls to addEventListener + removeEventListener and handle deviceready,
74
+ * resume, and pause events.
75
+ */
76
+ var m_document_addEventListener = document.addEventListener;
77
+ var m_document_removeEventListener = document.removeEventListener;
78
+ var m_window_addEventListener = window.addEventListener;
79
+ var m_window_removeEventListener = window.removeEventListener;
80
+
81
+ /**
82
+ * Houses custom event handlers to intercept on document + window event listeners.
83
+ */
84
+ var documentEventHandlers = {},
85
+ windowEventHandlers = {};
86
+
87
+ document.addEventListener = function(evt, handler, capture) {
88
+ var e = evt.toLowerCase();
89
+ if (e == 'deviceready') {
90
+ channel.onDeviceReady.subscribeOnce(handler);
91
+ } else if (e == 'resume') {
92
+ channel.onResume.subscribe(handler);
93
+ // if subscribing listener after event has already fired, invoke the handler
94
+ if (channel.onResume.fired && handler instanceof Function) {
95
+ handler();
96
+ }
97
+ } else if (e == 'pause') {
98
+ channel.onPause.subscribe(handler);
99
+ } else if (typeof documentEventHandlers[e] != 'undefined') {
100
+ documentEventHandlers[e].subscribe(handler);
101
+ } else {
102
+ m_document_addEventListener.call(document, evt, handler, capture);
103
+ }
104
+ };
105
+
106
+ window.addEventListener = function(evt, handler, capture) {
107
+ var e = evt.toLowerCase();
108
+ if (typeof windowEventHandlers[e] != 'undefined') {
109
+ windowEventHandlers[e].subscribe(handler);
110
+ } else {
111
+ m_window_addEventListener.call(window, evt, handler, capture);
112
+ }
113
+ };
114
+
115
+ document.removeEventListener = function(evt, handler, capture) {
116
+ var e = evt.toLowerCase();
117
+ // If unsubcribing from an event that is handled by a plugin
118
+ if (typeof documentEventHandlers[e] != "undefined") {
119
+ documentEventHandlers[e].unsubscribe(handler);
120
+ } else {
121
+ m_document_removeEventListener.call(document, evt, handler, capture);
122
+ }
123
+ };
124
+
125
+ window.removeEventListener = function(evt, handler, capture) {
126
+ var e = evt.toLowerCase();
127
+ // If unsubcribing from an event that is handled by a plugin
128
+ if (typeof windowEventHandlers[e] != "undefined") {
129
+ windowEventHandlers[e].unsubscribe(handler);
130
+ } else {
131
+ m_window_removeEventListener.call(window, evt, handler, capture);
132
+ }
133
+ };
134
+
135
+ function createEvent(type, data) {
136
+ var event = document.createEvent('Events');
137
+ event.initEvent(type, false, false);
138
+ if (data) {
139
+ for (var i in data) {
140
+ if (data.hasOwnProperty(i)) {
141
+ event[i] = data[i];
142
+ }
143
+ }
144
+ }
145
+ return event;
146
+ }
147
+
148
+ if(typeof window.console === "undefined")
149
+ {
150
+ window.console = {
151
+ log:function(){}
152
+ };
153
+ }
154
+
155
+ var cordova = {
156
+ define:define,
157
+ require:require,
158
+ /**
159
+ * Methods to add/remove your own addEventListener hijacking on document + window.
160
+ */
161
+ addWindowEventHandler:function(event, opts) {
162
+ return (windowEventHandlers[event] = channel.create(event, opts));
163
+ },
164
+ addDocumentEventHandler:function(event, opts) {
165
+ return (documentEventHandlers[event] = channel.create(event, opts));
166
+ },
167
+ removeWindowEventHandler:function(event) {
168
+ delete windowEventHandlers[event];
169
+ },
170
+ removeDocumentEventHandler:function(event) {
171
+ delete documentEventHandlers[event];
172
+ },
173
+ /**
174
+ * Retreive original event handlers that were replaced by Cordova
175
+ *
176
+ * @return object
177
+ */
178
+ getOriginalHandlers: function() {
179
+ return {'document': {'addEventListener': m_document_addEventListener, 'removeEventListener': m_document_removeEventListener},
180
+ 'window': {'addEventListener': m_window_addEventListener, 'removeEventListener': m_window_removeEventListener}};
181
+ },
182
+ /**
183
+ * Method to fire event from native code
184
+ */
185
+ fireDocumentEvent: function(type, data) {
186
+ var evt = createEvent(type, data);
187
+ if (typeof documentEventHandlers[type] != 'undefined') {
188
+ documentEventHandlers[type].fire(evt);
189
+ } else {
190
+ document.dispatchEvent(evt);
191
+ }
192
+ },
193
+ fireWindowEvent: function(type, data) {
194
+ var evt = createEvent(type,data);
195
+ if (typeof windowEventHandlers[type] != 'undefined') {
196
+ windowEventHandlers[type].fire(evt);
197
+ } else {
198
+ window.dispatchEvent(evt);
199
+ }
200
+ },
201
+ // TODO: this is Android only; think about how to do this better
202
+ shuttingDown:false,
203
+ UsePolling:false,
204
+ // END TODO
205
+
206
+ // TODO: iOS only
207
+ // This queue holds the currently executing command and all pending
208
+ // commands executed with cordova.exec().
209
+ commandQueue:[],
210
+ // Indicates if we're currently in the middle of flushing the command
211
+ // queue on the native side.
212
+ commandQueueFlushing:false,
213
+ // END TODO
214
+ /**
215
+ * Plugin callback mechanism.
216
+ */
217
+ callbackId: 0,
218
+ callbacks: {},
219
+ callbackStatus: {
220
+ NO_RESULT: 0,
221
+ OK: 1,
222
+ CLASS_NOT_FOUND_EXCEPTION: 2,
223
+ ILLEGAL_ACCESS_EXCEPTION: 3,
224
+ INSTANTIATION_EXCEPTION: 4,
225
+ MALFORMED_URL_EXCEPTION: 5,
226
+ IO_EXCEPTION: 6,
227
+ INVALID_ACTION: 7,
228
+ JSON_EXCEPTION: 8,
229
+ ERROR: 9
230
+ },
231
+
232
+ /**
233
+ * Called by native code when returning successful result from an action.
234
+ *
235
+ * @param callbackId
236
+ * @param args
237
+ */
238
+ callbackSuccess: function(callbackId, args) {
239
+ if (cordova.callbacks[callbackId]) {
240
+
241
+ // If result is to be sent to callback
242
+ if (args.status == cordova.callbackStatus.OK) {
243
+ try {
244
+ if (cordova.callbacks[callbackId].success) {
245
+ cordova.callbacks[callbackId].success(args.message);
246
+ }
247
+ }
248
+ catch (e) {
249
+ console.log("Error in success callback: "+callbackId+" = "+e);
250
+ }
251
+ }
252
+
253
+ // Clear callback if not expecting any more results
254
+ if (!args.keepCallback) {
255
+ delete cordova.callbacks[callbackId];
256
+ }
257
+ }
258
+ },
259
+
260
+ /**
261
+ * Called by native code when returning error result from an action.
262
+ *
263
+ * @param callbackId
264
+ * @param args
265
+ */
266
+ callbackError: function(callbackId, args) {
267
+ if (cordova.callbacks[callbackId]) {
268
+ try {
269
+ if (cordova.callbacks[callbackId].fail) {
270
+ cordova.callbacks[callbackId].fail(args.message);
271
+ }
272
+ }
273
+ catch (e) {
274
+ console.log("Error in error callback: "+callbackId+" = "+e);
275
+ }
276
+
277
+ // Clear callback if not expecting any more results
278
+ if (!args.keepCallback) {
279
+ delete cordova.callbacks[callbackId];
280
+ }
281
+ }
282
+ },
283
+ // TODO: remove in 2.0.
284
+ addPlugin: function(name, obj) {
285
+ console.log("[DEPRECATION NOTICE] window.addPlugin and window.plugins will be removed in version 2.0.");
286
+ if (!window.plugins[name]) {
287
+ window.plugins[name] = obj;
288
+ }
289
+ else {
290
+ console.log("Error: Plugin "+name+" already exists.");
291
+ }
292
+ },
293
+
294
+ addConstructor: function(func) {
295
+ channel.onCordovaReady.subscribeOnce(function() {
296
+ try {
297
+ func();
298
+ } catch(e) {
299
+ console.log("Failed to run constructor: " + e);
300
+ }
301
+ });
302
+ }
303
+ };
304
+
305
+ /**
306
+ * Legacy variable for plugin support
307
+ * TODO: remove in 2.0.
308
+ */
309
+ if (!window.PhoneGap) {
310
+ window.PhoneGap = cordova;
311
+ }
312
+
313
+ /**
314
+ * Plugins object
315
+ * TODO: remove in 2.0.
316
+ */
317
+ if (!window.plugins) {
318
+ window.plugins = {};
319
+ }
320
+
321
+ module.exports = cordova;
322
+
323
+ });
324
+
325
+ // file: lib/common/builder.js
326
+ define("cordova/builder", function(require, exports, module) {
327
+ function each(objects, func, context) {
328
+ for (var prop in objects) {
329
+ if (objects.hasOwnProperty(prop)) {
330
+ func.apply(context, [objects[prop], prop]);
331
+ }
332
+ }
333
+ }
334
+
335
+ function include(parent, objects, clobber, merge) {
336
+ each(objects, function (obj, key) {
337
+ try {
338
+ var result = obj.path ? require(obj.path) : {};
339
+
340
+ if (clobber) {
341
+ // Clobber if it doesn't exist.
342
+ if (typeof parent[key] === 'undefined') {
343
+ parent[key] = result;
344
+ } else if (typeof obj.path !== 'undefined') {
345
+ // If merging, merge properties onto parent, otherwise, clobber.
346
+ if (merge) {
347
+ recursiveMerge(parent[key], result);
348
+ } else {
349
+ parent[key] = result;
350
+ }
351
+ }
352
+ result = parent[key];
353
+ } else {
354
+ // Overwrite if not currently defined.
355
+ if (typeof parent[key] == 'undefined') {
356
+ parent[key] = result;
357
+ } else if (merge && typeof obj.path !== 'undefined') {
358
+ // If merging, merge parent onto result
359
+ recursiveMerge(result, parent[key]);
360
+ parent[key] = result;
361
+ } else {
362
+ // Set result to what already exists, so we can build children into it if they exist.
363
+ result = parent[key];
364
+ }
365
+ }
366
+
367
+ if (obj.children) {
368
+ include(result, obj.children, clobber, merge);
369
+ }
370
+ } catch(e) {
371
+ utils.alert('Exception building cordova JS globals: ' + e + ' for key "' + key + '"');
372
+ }
373
+ });
374
+ }
375
+
376
+ /**
377
+ * Merge properties from one object onto another recursively. Properties from
378
+ * the src object will overwrite existing target property.
379
+ *
380
+ * @param target Object to merge properties into.
381
+ * @param src Object to merge properties from.
382
+ */
383
+ function recursiveMerge(target, src) {
384
+ for (var prop in src) {
385
+ if (src.hasOwnProperty(prop)) {
386
+ if (typeof target.prototype !== 'undefined' && target.prototype.constructor === target) {
387
+ // If the target object is a constructor override off prototype.
388
+ target.prototype[prop] = src[prop];
389
+ } else {
390
+ target[prop] = typeof src[prop] === 'object' ? recursiveMerge(
391
+ target[prop], src[prop]) : src[prop];
392
+ }
393
+ }
394
+ }
395
+ return target;
396
+ }
397
+
398
+ module.exports = {
399
+ build: function (objects) {
400
+ return {
401
+ intoButDontClobber: function (target) {
402
+ include(target, objects, false, false);
403
+ },
404
+ intoAndClobber: function(target) {
405
+ include(target, objects, true, false);
406
+ },
407
+ intoAndMerge: function(target) {
408
+ include(target, objects, true, true);
409
+ }
410
+ };
411
+ }
412
+ };
413
+
414
+ });
415
+
416
+ // file: lib/common/channel.js
417
+ define("cordova/channel", function(require, exports, module) {
418
+ /**
419
+ * Custom pub-sub "channel" that can have functions subscribed to it
420
+ * This object is used to define and control firing of events for
421
+ * cordova initialization.
422
+ *
423
+ * The order of events during page load and Cordova startup is as follows:
424
+ *
425
+ * onDOMContentLoaded Internal event that is received when the web page is loaded and parsed.
426
+ * onNativeReady Internal event that indicates the Cordova native side is ready.
427
+ * onCordovaReady Internal event fired when all Cordova JavaScript objects have been created.
428
+ * onCordovaInfoReady Internal event fired when device properties are available.
429
+ * onCordovaConnectionReady Internal event fired when the connection property has been set.
430
+ * onDeviceReady User event fired to indicate that Cordova is ready
431
+ * onResume User event fired to indicate a start/resume lifecycle event
432
+ * onPause User event fired to indicate a pause lifecycle event
433
+ * onDestroy Internal event fired when app is being destroyed (User should use window.onunload event, not this one).
434
+ *
435
+ * The only Cordova events that user code should register for are:
436
+ * deviceready Cordova native code is initialized and Cordova APIs can be called from JavaScript
437
+ * pause App has moved to background
438
+ * resume App has returned to foreground
439
+ *
440
+ * Listeners can be registered as:
441
+ * document.addEventListener("deviceready", myDeviceReadyListener, false);
442
+ * document.addEventListener("resume", myResumeListener, false);
443
+ * document.addEventListener("pause", myPauseListener, false);
444
+ *
445
+ * The DOM lifecycle events should be used for saving and restoring state
446
+ * window.onload
447
+ * window.onunload
448
+ *
449
+ */
450
+
451
+ /**
452
+ * Channel
453
+ * @constructor
454
+ * @param type String the channel name
455
+ * @param opts Object options to pass into the channel, currently
456
+ * supports:
457
+ * onSubscribe: callback that fires when
458
+ * something subscribes to the Channel. Sets
459
+ * context to the Channel.
460
+ * onUnsubscribe: callback that fires when
461
+ * something unsubscribes to the Channel. Sets
462
+ * context to the Channel.
463
+ */
464
+ var Channel = function(type, opts) {
465
+ this.type = type;
466
+ this.handlers = {};
467
+ this.numHandlers = 0;
468
+ this.guid = 0;
469
+ this.fired = false;
470
+ this.enabled = true;
471
+ this.events = {
472
+ onSubscribe:null,
473
+ onUnsubscribe:null
474
+ };
475
+ if (opts) {
476
+ if (opts.onSubscribe) this.events.onSubscribe = opts.onSubscribe;
477
+ if (opts.onUnsubscribe) this.events.onUnsubscribe = opts.onUnsubscribe;
478
+ }
479
+ },
480
+ channel = {
481
+ /**
482
+ * Calls the provided function only after all of the channels specified
483
+ * have been fired.
484
+ */
485
+ join: function (h, c) {
486
+ var i = c.length;
487
+ var len = i;
488
+ var f = function() {
489
+ if (!(--i)) h();
490
+ };
491
+ for (var j=0; j<len; j++) {
492
+ !c[j].fired?c[j].subscribeOnce(f):i--;
493
+ }
494
+ if (!i) h();
495
+ },
496
+ create: function (type, opts) {
497
+ channel[type] = new Channel(type, opts);
498
+ return channel[type];
499
+ },
500
+
501
+ /**
502
+ * cordova Channels that must fire before "deviceready" is fired.
503
+ */
504
+ deviceReadyChannelsArray: [],
505
+ deviceReadyChannelsMap: {},
506
+
507
+ /**
508
+ * Indicate that a feature needs to be initialized before it is ready to be used.
509
+ * This holds up Cordova's "deviceready" event until the feature has been initialized
510
+ * and Cordova.initComplete(feature) is called.
511
+ *
512
+ * @param feature {String} The unique feature name
513
+ */
514
+ waitForInitialization: function(feature) {
515
+ if (feature) {
516
+ var c = null;
517
+ if (this[feature]) {
518
+ console.log("fire: using same feature for "+feature);
519
+ c = this[feature];
520
+ }
521
+ else {
522
+ console.log("fire: creating feature "+feature);
523
+ c = this.create(feature);
524
+ }
525
+ this.deviceReadyChannelsMap[feature] = c;
526
+ this.deviceReadyChannelsArray.push(c);
527
+ }
528
+ },
529
+
530
+ /**
531
+ * Indicate that initialization code has completed and the feature is ready to be used.
532
+ *
533
+ * @param feature {String} The unique feature name
534
+ */
535
+ initializationComplete: function(feature) {
536
+ var c = this.deviceReadyChannelsMap[feature];
537
+ if (c) {
538
+ c.fire();
539
+ }
540
+ }
541
+ },
542
+ utils = require('cordova/utils');
543
+
544
+ /**
545
+ * Subscribes the given function to the channel. Any time that
546
+ * Channel.fire is called so too will the function.
547
+ * Optionally specify an execution context for the function
548
+ * and a guid that can be used to stop subscribing to the channel.
549
+ * Returns the guid.
550
+ */
551
+ Channel.prototype.subscribe = function(f, c, g) {
552
+ // need a function to call
553
+ if (f === null || f === undefined) { return; }
554
+
555
+ var func = f;
556
+ if (typeof c == "object" && f instanceof Function) { func = utils.close(c, f); }
557
+
558
+ g = g || func.observer_guid || f.observer_guid || this.guid++;
559
+ func.observer_guid = g;
560
+ f.observer_guid = g;
561
+ this.handlers[g] = func;
562
+ this.numHandlers++;
563
+ if (this.events.onSubscribe) this.events.onSubscribe.call(this);
564
+ return g;
565
+ };
566
+
567
+ /**
568
+ * Like subscribe but the function is only called once and then it
569
+ * auto-unsubscribes itself.
570
+ */
571
+ Channel.prototype.subscribeOnce = function(f, c) {
572
+ // need a function to call
573
+ if (f === null || f === undefined) { return; }
574
+
575
+ var g = null;
576
+ var _this = this;
577
+ var m = function() {
578
+ f.apply(c || null, arguments);
579
+ _this.unsubscribe(g);
580
+ };
581
+ if (this.fired) {
582
+ if (typeof c == "object" && f instanceof Function) { f = utils.close(c, f); }
583
+ f.apply(this, this.fireArgs);
584
+ } else {
585
+ g = this.subscribe(m);
586
+ }
587
+ return g;
588
+ };
589
+
590
+ /**
591
+ * Unsubscribes the function with the given guid from the channel.
592
+ */
593
+ Channel.prototype.unsubscribe = function(g) {
594
+ // need a function to unsubscribe
595
+ if (g === null || g === undefined) { return; }
596
+
597
+ if (g instanceof Function) { g = g.observer_guid; }
598
+ this.handlers[g] = null;
599
+ delete this.handlers[g];
600
+ this.numHandlers--;
601
+ if (this.events.onUnsubscribe) this.events.onUnsubscribe.call(this);
602
+ };
603
+
604
+ /**
605
+ * Calls all functions subscribed to this channel.
606
+ */
607
+ Channel.prototype.fire = function(e) {
608
+ if (this.enabled) {
609
+ console.log("Channel.fire("+this.type+")");
610
+ var fail = false;
611
+ this.fired = true;
612
+ for (var item in this.handlers) {
613
+ var handler = this.handlers[item];
614
+ if (handler instanceof Function) {
615
+ var rv = (handler.apply(this, arguments)===false);
616
+ fail = fail || rv;
617
+ }
618
+ }
619
+ this.fireArgs = arguments;
620
+ return !fail;
621
+ }
622
+ return true;
623
+ };
624
+
625
+ // defining them here so they are ready super fast!
626
+ // DOM event that is received when the web page is loaded and parsed.
627
+ channel.create('onDOMContentLoaded');
628
+
629
+ // Event to indicate the Cordova native side is ready.
630
+ channel.create('onNativeReady');
631
+
632
+ // Event to indicate that all Cordova JavaScript objects have been created
633
+ // and it's time to run plugin constructors.
634
+ channel.create('onCordovaReady');
635
+
636
+ // Event to indicate that device properties are available
637
+ channel.create('onCordovaInfoReady');
638
+
639
+ // Event to indicate that the connection property has been set.
640
+ channel.create('onCordovaConnectionReady');
641
+
642
+ // Event to indicate that Cordova is ready
643
+ channel.create('onDeviceReady');
644
+
645
+ // Event to indicate a resume lifecycle event
646
+ channel.create('onResume');
647
+
648
+ // Event to indicate a pause lifecycle event
649
+ channel.create('onPause');
650
+
651
+ // Event to indicate a destroy lifecycle event
652
+ // TODO: is this correct?
653
+ channel.create('onDestroy');
654
+
655
+ // Channels that must fire before "deviceready" is fired.
656
+ channel.waitForInitialization('onCordovaReady');
657
+ channel.waitForInitialization('onCordovaInfoReady');
658
+ channel.waitForInitialization('onCordovaConnectionReady');
659
+
660
+ module.exports = channel;
661
+
662
+ });
663
+
664
+ // file: lib/common/common.js
665
+ define("cordova/common", function(require, exports, module) {
666
+ module.exports = {
667
+ objects: {
668
+ cordova: {
669
+ path: 'cordova',
670
+ children: {
671
+ exec: {
672
+ path: 'cordova/exec'
673
+ }
674
+ }
675
+ },
676
+ navigator: {
677
+ children: {
678
+ notification: {
679
+ path: 'cordova/plugin/notification'
680
+ },
681
+ accelerometer: {
682
+ path: 'cordova/plugin/accelerometer'
683
+ },
684
+ battery: {
685
+ path: 'cordova/plugin/battery'
686
+ },
687
+ camera:{
688
+ path: 'cordova/plugin/Camera'
689
+ },
690
+ compass:{
691
+ path: 'cordova/plugin/compass'
692
+ },
693
+ contacts: {
694
+ path: 'cordova/plugin/contacts'
695
+ },
696
+ device:{
697
+ children:{
698
+ capture: {
699
+ path: 'cordova/plugin/capture'
700
+ }
701
+ }
702
+ },
703
+ geolocation: {
704
+ path: 'cordova/plugin/geolocation'
705
+ },
706
+ network: {
707
+ children: {
708
+ connection: {
709
+ path: 'cordova/plugin/network'
710
+ }
711
+ }
712
+ }
713
+ }
714
+ },
715
+ Acceleration: {
716
+ path: 'cordova/plugin/Acceleration'
717
+ },
718
+ Camera:{
719
+ path: 'cordova/plugin/CameraConstants'
720
+ },
721
+ CaptureError: {
722
+ path: 'cordova/plugin/CaptureError'
723
+ },
724
+ CaptureAudioOptions:{
725
+ path: 'cordova/plugin/CaptureAudioOptions'
726
+ },
727
+ CaptureImageOptions: {
728
+ path: 'cordova/plugin/CaptureImageOptions'
729
+ },
730
+ CaptureVideoOptions: {
731
+ path: 'cordova/plugin/CaptureVideoOptions'
732
+ },
733
+ CompassHeading:{
734
+ path: 'cordova/plugin/CompassHeading'
735
+ },
736
+ CompassError:{
737
+ path: 'cordova/plugin/CompassError'
738
+ },
739
+ ConfigurationData: {
740
+ path: 'cordova/plugin/ConfigurationData'
741
+ },
742
+ Connection: {
743
+ path: 'cordova/plugin/Connection'
744
+ },
745
+ Contact: {
746
+ path: 'cordova/plugin/Contact'
747
+ },
748
+ ContactAddress: {
749
+ path: 'cordova/plugin/ContactAddress'
750
+ },
751
+ ContactError: {
752
+ path: 'cordova/plugin/ContactError'
753
+ },
754
+ ContactField: {
755
+ path: 'cordova/plugin/ContactField'
756
+ },
757
+ ContactFindOptions: {
758
+ path: 'cordova/plugin/ContactFindOptions'
759
+ },
760
+ ContactName: {
761
+ path: 'cordova/plugin/ContactName'
762
+ },
763
+ ContactOrganization: {
764
+ path: 'cordova/plugin/ContactOrganization'
765
+ },
766
+ Coordinates: {
767
+ path: 'cordova/plugin/Coordinates'
768
+ },
769
+ DirectoryEntry: {
770
+ path: 'cordova/plugin/DirectoryEntry'
771
+ },
772
+ DirectoryReader: {
773
+ path: 'cordova/plugin/DirectoryReader'
774
+ },
775
+ Entry: {
776
+ path: 'cordova/plugin/Entry'
777
+ },
778
+ File: {
779
+ path: 'cordova/plugin/File'
780
+ },
781
+ FileEntry: {
782
+ path: 'cordova/plugin/FileEntry'
783
+ },
784
+ FileError: {
785
+ path: 'cordova/plugin/FileError'
786
+ },
787
+ FileReader: {
788
+ path: 'cordova/plugin/FileReader'
789
+ },
790
+ FileSystem: {
791
+ path: 'cordova/plugin/FileSystem'
792
+ },
793
+ FileTransfer: {
794
+ path: 'cordova/plugin/FileTransfer'
795
+ },
796
+ FileTransferError: {
797
+ path: 'cordova/plugin/FileTransferError'
798
+ },
799
+ FileUploadOptions: {
800
+ path: 'cordova/plugin/FileUploadOptions'
801
+ },
802
+ FileUploadResult: {
803
+ path: 'cordova/plugin/FileUploadResult'
804
+ },
805
+ FileWriter: {
806
+ path: 'cordova/plugin/FileWriter'
807
+ },
808
+ Flags: {
809
+ path: 'cordova/plugin/Flags'
810
+ },
811
+ LocalFileSystem: {
812
+ path: 'cordova/plugin/LocalFileSystem'
813
+ },
814
+ Media: {
815
+ path: 'cordova/plugin/Media'
816
+ },
817
+ MediaError: {
818
+ path: 'cordova/plugin/MediaError'
819
+ },
820
+ MediaFile: {
821
+ path: 'cordova/plugin/MediaFile'
822
+ },
823
+ MediaFileData:{
824
+ path: 'cordova/plugin/MediaFileData'
825
+ },
826
+ Metadata:{
827
+ path: 'cordova/plugin/Metadata'
828
+ },
829
+ Position: {
830
+ path: 'cordova/plugin/Position'
831
+ },
832
+ PositionError: {
833
+ path: 'cordova/plugin/PositionError'
834
+ },
835
+ ProgressEvent: {
836
+ path: 'cordova/plugin/ProgressEvent'
837
+ },
838
+ requestFileSystem:{
839
+ path: 'cordova/plugin/requestFileSystem'
840
+ },
841
+ resolveLocalFileSystemURI:{
842
+ path: 'cordova/plugin/resolveLocalFileSystemURI'
843
+ }
844
+ }
845
+ };
846
+
847
+ });
848
+
849
+ // file: lib/android/exec.js
850
+ define("cordova/exec", function(require, exports, module) {
851
+ /**
852
+ * Execute a cordova command. It is up to the native side whether this action
853
+ * is synchronous or asynchronous. The native side can return:
854
+ * Synchronous: PluginResult object as a JSON string
855
+ * Asynchrounous: Empty string ""
856
+ * If async, the native side will cordova.callbackSuccess or cordova.callbackError,
857
+ * depending upon the result of the action.
858
+ *
859
+ * @param {Function} success The success callback
860
+ * @param {Function} fail The fail callback
861
+ * @param {String} service The name of the service to use
862
+ * @param {String} action Action to be run in cordova
863
+ * @param {String[]} [args] Zero or more arguments to pass to the method
864
+ */
865
+ var cordova = require('cordova');
866
+
867
+ module.exports = function(success, fail, service, action, args) {
868
+ try {
869
+ var callbackId = service + cordova.callbackId++;
870
+ if (success || fail) {
871
+ cordova.callbacks[callbackId] = {success:success, fail:fail};
872
+ }
873
+
874
+ var r = prompt(JSON.stringify(args), "gap:"+JSON.stringify([service, action, callbackId, true]));
875
+
876
+ // If a result was returned
877
+ if (r.length > 0) {
878
+ eval("var v="+r+";");
879
+
880
+ // If status is OK, then return value back to caller
881
+ if (v.status === cordova.callbackStatus.OK) {
882
+
883
+ // If there is a success callback, then call it now with
884
+ // returned value
885
+ if (success) {
886
+ try {
887
+ success(v.message);
888
+ } catch (e) {
889
+ console.log("Error in success callback: " + callbackId + " = " + e);
890
+ }
891
+
892
+ // Clear callback if not expecting any more results
893
+ if (!v.keepCallback) {
894
+ delete cordova.callbacks[callbackId];
895
+ }
896
+ }
897
+ return v.message;
898
+ }
899
+
900
+ // If no result
901
+ else if (v.status === cordova.callbackStatus.NO_RESULT) {
902
+ // Clear callback if not expecting any more results
903
+ if (!v.keepCallback) {
904
+ delete cordova.callbacks[callbackId];
905
+ }
906
+ }
907
+
908
+ // If error, then display error
909
+ else {
910
+ console.log("Error: Status="+v.status+" Message="+v.message);
911
+
912
+ // If there is a fail callback, then call it now with returned value
913
+ if (fail) {
914
+ try {
915
+ fail(v.message);
916
+ }
917
+ catch (e1) {
918
+ console.log("Error in error callback: "+callbackId+" = "+e1);
919
+ }
920
+
921
+ // Clear callback if not expecting any more results
922
+ if (!v.keepCallback) {
923
+ delete cordova.callbacks[callbackId];
924
+ }
925
+ }
926
+ return null;
927
+ }
928
+ }
929
+ } catch (e2) {
930
+ console.log("Error: "+e2);
931
+ }
932
+ };
933
+
934
+ });
935
+
936
+ // file: lib/android/platform.js
937
+ define("cordova/platform", function(require, exports, module) {
938
+ module.exports = {
939
+ id: "android",
940
+ initialize:function() {
941
+ var channel = require("cordova/channel"),
942
+ cordova = require('cordova'),
943
+ callback = require('cordova/plugin/android/callback'),
944
+ polling = require('cordova/plugin/android/polling'),
945
+ exec = require('cordova/exec');
946
+
947
+ channel.onDestroy.subscribe(function() {
948
+ cordova.shuttingDown = true;
949
+ });
950
+
951
+ // Start listening for XHR callbacks
952
+ // Figure out which bridge approach will work on this Android
953
+ // device: polling or XHR-based callbacks
954
+ setTimeout(function() {
955
+ if (cordova.UsePolling) {
956
+ polling();
957
+ }
958
+ else {
959
+ var isPolling = prompt("usePolling", "gap_callbackServer:");
960
+ cordova.UsePolling = isPolling;
961
+ if (isPolling == "true") {
962
+ cordova.UsePolling = true;
963
+ polling();
964
+ } else {
965
+ cordova.UsePolling = false;
966
+ callback();
967
+ }
968
+ }
969
+ }, 1);
970
+
971
+ // Inject a listener for the backbutton on the document.
972
+ var backButtonChannel = cordova.addDocumentEventHandler('backbutton', {
973
+ onSubscribe:function() {
974
+ // If we just attached the first handler, let native know we need to override the back button.
975
+ if (this.numHandlers === 1) {
976
+ exec(null, null, "App", "overrideBackbutton", [true]);
977
+ }
978
+ },
979
+ onUnsubscribe:function() {
980
+ // If we just detached the last handler, let native know we no longer override the back button.
981
+ if (this.numHandlers === 0) {
982
+ exec(null, null, "App", "overrideBackbutton", [false]);
983
+ }
984
+ }
985
+ });
986
+
987
+ // Add hardware MENU and SEARCH button handlers
988
+ cordova.addDocumentEventHandler('menubutton');
989
+ cordova.addDocumentEventHandler('searchbutton');
990
+
991
+ // Figure out if we need to shim-in localStorage and WebSQL
992
+ // support from the native side.
993
+ var storage = require('cordova/plugin/android/storage');
994
+
995
+ // First patch WebSQL if necessary
996
+ if (typeof window.openDatabase == 'undefined') {
997
+ // Not defined, create an openDatabase function for all to use!
998
+ window.openDatabase = storage.openDatabase;
999
+ } else {
1000
+ // Defined, but some Android devices will throw a SECURITY_ERR -
1001
+ // so we wrap the whole thing in a try-catch and shim in our own
1002
+ // if the device has Android bug 16175.
1003
+ var originalOpenDatabase = window.openDatabase;
1004
+ window.openDatabase = function(name, version, desc, size) {
1005
+ var db = null;
1006
+ try {
1007
+ db = originalOpenDatabase(name, version, desc, size);
1008
+ }
1009
+ catch (ex) {
1010
+ db = null;
1011
+ }
1012
+
1013
+ if (db === null) {
1014
+ return storage.openDatabase(name, version, desc, size);
1015
+ }
1016
+ else {
1017
+ return db;
1018
+ }
1019
+
1020
+ };
1021
+ }
1022
+
1023
+ // Patch localStorage if necessary
1024
+ if (typeof window.localStorage == 'undefined' || window.localStorage === null) {
1025
+ window.localStorage = new storage.CupCakeLocalStorage();
1026
+ }
1027
+
1028
+ // Let native code know we are all done on the JS side.
1029
+ // Native code will then un-hide the WebView.
1030
+ channel.join(function() {
1031
+ prompt("", "gap_init:");
1032
+ }, [channel.onCordovaReady]);
1033
+ },
1034
+ objects: {
1035
+ cordova: {
1036
+ children: {
1037
+ JSCallback:{
1038
+ path:"cordova/plugin/android/callback"
1039
+ },
1040
+ JSCallbackPolling:{
1041
+ path:"cordova/plugin/android/polling"
1042
+ }
1043
+ }
1044
+ },
1045
+ navigator: {
1046
+ children: {
1047
+ app:{
1048
+ path: "cordova/plugin/android/app"
1049
+ }
1050
+ }
1051
+ },
1052
+ device:{
1053
+ path: "cordova/plugin/android/device"
1054
+ },
1055
+ File: { // exists natively on Android WebView, override
1056
+ path: "cordova/plugin/File"
1057
+ },
1058
+ FileReader: { // exists natively on Android WebView, override
1059
+ path: "cordova/plugin/FileReader"
1060
+ },
1061
+ FileError: { //exists natively on Android WebView on Android 4.x
1062
+ path: "cordova/plugin/FileError"
1063
+ },
1064
+ MediaError: { // exists natively on Android WebView on Android 4.x
1065
+ path: "cordova/plugin/MediaError"
1066
+ }
1067
+ },
1068
+ merges: {
1069
+ navigator: {
1070
+ children: {
1071
+ notification: {
1072
+ path: 'cordova/plugin/android/notification'
1073
+ }
1074
+ }
1075
+ }
1076
+ }
1077
+ };
1078
+
1079
+ });
1080
+
1081
+ // file: lib/common/plugin/Acceleration.js
1082
+ define("cordova/plugin/Acceleration", function(require, exports, module) {
1083
+ var Acceleration = function(x, y, z, timestamp) {
1084
+ this.x = x;
1085
+ this.y = y;
1086
+ this.z = z;
1087
+ this.timestamp = timestamp || (new Date()).getTime();
1088
+ };
1089
+
1090
+ module.exports = Acceleration;
1091
+
1092
+ });
1093
+
1094
+ // file: lib/common/plugin/Camera.js
1095
+ define("cordova/plugin/Camera", function(require, exports, module) {
1096
+ var exec = require('cordova/exec'),
1097
+ Camera = require('cordova/plugin/CameraConstants');
1098
+
1099
+ var cameraExport = {};
1100
+
1101
+ // Tack on the Camera Constants to the base camera plugin.
1102
+ for (var key in Camera) {
1103
+ cameraExport[key] = Camera[key];
1104
+ }
1105
+
1106
+ /**
1107
+ * Gets a picture from source defined by "options.sourceType", and returns the
1108
+ * image as defined by the "options.destinationType" option.
1109
+
1110
+ * The defaults are sourceType=CAMERA and destinationType=FILE_URL.
1111
+ *
1112
+ * @param {Function} successCallback
1113
+ * @param {Function} errorCallback
1114
+ * @param {Object} options
1115
+ */
1116
+ cameraExport.getPicture = function(successCallback, errorCallback, options) {
1117
+ // successCallback required
1118
+ if (typeof successCallback != "function") {
1119
+ console.log("Camera Error: successCallback is not a function");
1120
+ return;
1121
+ }
1122
+
1123
+ // errorCallback optional
1124
+ if (errorCallback && (typeof errorCallback != "function")) {
1125
+ console.log("Camera Error: errorCallback is not a function");
1126
+ return;
1127
+ }
1128
+
1129
+ var quality = 50;
1130
+ if (options && typeof options.quality == "number") {
1131
+ quality = options.quality;
1132
+ } else if (options && typeof options.quality == "string") {
1133
+ var qlity = parseInt(options.quality, 10);
1134
+ if (isNaN(qlity) === false) {
1135
+ quality = qlity.valueOf();
1136
+ }
1137
+ }
1138
+
1139
+ var destinationType = Camera.DestinationType.FILE_URI;
1140
+ if (typeof options.destinationType == "number") {
1141
+ destinationType = options.destinationType;
1142
+ }
1143
+
1144
+ var sourceType = Camera.PictureSourceType.CAMERA;
1145
+ if (typeof options.sourceType == "number") {
1146
+ sourceType = options.sourceType;
1147
+ }
1148
+
1149
+ var targetWidth = -1;
1150
+ if (typeof options.targetWidth == "number") {
1151
+ targetWidth = options.targetWidth;
1152
+ } else if (typeof options.targetWidth == "string") {
1153
+ var width = parseInt(options.targetWidth, 10);
1154
+ if (isNaN(width) === false) {
1155
+ targetWidth = width.valueOf();
1156
+ }
1157
+ }
1158
+
1159
+ var targetHeight = -1;
1160
+ if (typeof options.targetHeight == "number") {
1161
+ targetHeight = options.targetHeight;
1162
+ } else if (typeof options.targetHeight == "string") {
1163
+ var height = parseInt(options.targetHeight, 10);
1164
+ if (isNaN(height) === false) {
1165
+ targetHeight = height.valueOf();
1166
+ }
1167
+ }
1168
+
1169
+ var encodingType = Camera.EncodingType.JPEG;
1170
+ if (typeof options.encodingType == "number") {
1171
+ encodingType = options.encodingType;
1172
+ }
1173
+
1174
+ var mediaType = Camera.MediaType.PICTURE;
1175
+ if (typeof options.mediaType == "number") {
1176
+ mediaType = options.mediaType;
1177
+ }
1178
+ var allowEdit = false;
1179
+ if (typeof options.allowEdit == "boolean") {
1180
+ allowEdit = options.allowEdit;
1181
+ } else if (typeof options.allowEdit == "number") {
1182
+ allowEdit = options.allowEdit <= 0 ? false : true;
1183
+ }
1184
+ var correctOrientation = false;
1185
+ if (typeof options.correctOrientation == "boolean") {
1186
+ correctOrientation = options.correctOrientation;
1187
+ } else if (typeof options.correctOrientation == "number") {
1188
+ correctOrientation = options.correctOrientation <=0 ? false : true;
1189
+ }
1190
+ var saveToPhotoAlbum = false;
1191
+ if (typeof options.saveToPhotoAlbum == "boolean") {
1192
+ saveToPhotoAlbum = options.saveToPhotoAlbum;
1193
+ } else if (typeof options.saveToPhotoAlbum == "number") {
1194
+ saveToPhotoAlbum = options.saveToPhotoAlbum <=0 ? false : true;
1195
+ }
1196
+
1197
+ exec(successCallback, errorCallback, "Camera", "takePicture", [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType, mediaType, allowEdit, correctOrientation, saveToPhotoAlbum]);
1198
+ }
1199
+
1200
+ module.exports = cameraExport;
1201
+
1202
+ });
1203
+
1204
+ // file: lib/common/plugin/CameraConstants.js
1205
+ define("cordova/plugin/CameraConstants", function(require, exports, module) {
1206
+ module.exports = {
1207
+ DestinationType:{
1208
+ DATA_URL: 0, // Return base64 encoded string
1209
+ FILE_URI: 1 // Return file uri (content://media/external/images/media/2 for Android)
1210
+ },
1211
+ EncodingType:{
1212
+ JPEG: 0, // Return JPEG encoded image
1213
+ PNG: 1 // Return PNG encoded image
1214
+ },
1215
+ MediaType:{
1216
+ PICTURE: 0, // allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType
1217
+ VIDEO: 1, // allow selection of video only, ONLY RETURNS URL
1218
+ ALLMEDIA : 2 // allow selection from all media types
1219
+ },
1220
+ PictureSourceType:{
1221
+ PHOTOLIBRARY : 0, // Choose image from picture library (same as SAVEDPHOTOALBUM for Android)
1222
+ CAMERA : 1, // Take picture from camera
1223
+ SAVEDPHOTOALBUM : 2 // Choose image from picture library (same as PHOTOLIBRARY for Android)
1224
+ }
1225
+ };
1226
+
1227
+ });
1228
+
1229
+ // file: lib/common/plugin/CaptureAudioOptions.js
1230
+ define("cordova/plugin/CaptureAudioOptions", function(require, exports, module) {
1231
+ /**
1232
+ * Encapsulates all audio capture operation configuration options.
1233
+ */
1234
+ var CaptureAudioOptions = function(){
1235
+ // Upper limit of sound clips user can record. Value must be equal or greater than 1.
1236
+ this.limit = 1;
1237
+ // Maximum duration of a single sound clip in seconds.
1238
+ this.duration = 0;
1239
+ // The selected audio mode. Must match with one of the elements in supportedAudioModes array.
1240
+ this.mode = null;
1241
+ };
1242
+
1243
+ module.exports = CaptureAudioOptions;
1244
+
1245
+ });
1246
+
1247
+ // file: lib/common/plugin/CaptureError.js
1248
+ define("cordova/plugin/CaptureError", function(require, exports, module) {
1249
+ /**
1250
+ * The CaptureError interface encapsulates all errors in the Capture API.
1251
+ */
1252
+ var CaptureError = function(c) {
1253
+ this.code = c || null;
1254
+ };
1255
+
1256
+ // Camera or microphone failed to capture image or sound.
1257
+ CaptureError.CAPTURE_INTERNAL_ERR = 0;
1258
+ // Camera application or audio capture application is currently serving other capture request.
1259
+ CaptureError.CAPTURE_APPLICATION_BUSY = 1;
1260
+ // Invalid use of the API (e.g. limit parameter has value less than one).
1261
+ CaptureError.CAPTURE_INVALID_ARGUMENT = 2;
1262
+ // User exited camera application or audio capture application before capturing anything.
1263
+ CaptureError.CAPTURE_NO_MEDIA_FILES = 3;
1264
+ // The requested capture operation is not supported.
1265
+ CaptureError.CAPTURE_NOT_SUPPORTED = 20;
1266
+
1267
+ module.exports = CaptureError;
1268
+
1269
+ });
1270
+
1271
+ // file: lib/common/plugin/CaptureImageOptions.js
1272
+ define("cordova/plugin/CaptureImageOptions", function(require, exports, module) {
1273
+ /**
1274
+ * Encapsulates all image capture operation configuration options.
1275
+ */
1276
+ var CaptureImageOptions = function(){
1277
+ // Upper limit of images user can take. Value must be equal or greater than 1.
1278
+ this.limit = 1;
1279
+ // The selected image mode. Must match with one of the elements in supportedImageModes array.
1280
+ this.mode = null;
1281
+ };
1282
+
1283
+ module.exports = CaptureImageOptions;
1284
+
1285
+ });
1286
+
1287
+ // file: lib/common/plugin/CaptureVideoOptions.js
1288
+ define("cordova/plugin/CaptureVideoOptions", function(require, exports, module) {
1289
+ /**
1290
+ * Encapsulates all video capture operation configuration options.
1291
+ */
1292
+ var CaptureVideoOptions = function(){
1293
+ // Upper limit of videos user can record. Value must be equal or greater than 1.
1294
+ this.limit = 1;
1295
+ // Maximum duration of a single video clip in seconds.
1296
+ this.duration = 0;
1297
+ // The selected video mode. Must match with one of the elements in supportedVideoModes array.
1298
+ this.mode = null;
1299
+ };
1300
+
1301
+ module.exports = CaptureVideoOptions;
1302
+
1303
+ });
1304
+
1305
+ // file: lib/common/plugin/CompassError.js
1306
+ define("cordova/plugin/CompassError", function(require, exports, module) {
1307
+ /**
1308
+ * CompassError.
1309
+ * An error code assigned by an implementation when an error has occured
1310
+ * @constructor
1311
+ */
1312
+ var CompassError = function(err) {
1313
+ this.code = (err !== undefined ? err : null);
1314
+ };
1315
+
1316
+ CompassError.COMPASS_INTERNAL_ERR = 0;
1317
+ CompassError.COMPASS_NOT_SUPPORTED = 20;
1318
+
1319
+ module.exports = CompassError;
1320
+
1321
+ });
1322
+
1323
+ // file: lib/common/plugin/CompassHeading.js
1324
+ define("cordova/plugin/CompassHeading", function(require, exports, module) {
1325
+ var CompassHeading = function(magneticHeading, trueHeading, headingAccuracy, timestamp) {
1326
+ this.magneticHeading = (magneticHeading !== undefined ? magneticHeading : null);
1327
+ this.trueHeading = (trueHeading !== undefined ? trueHeading : null);
1328
+ this.headingAccuracy = (headingAccuracy !== undefined ? headingAccuracy : null);
1329
+ this.timestamp = (timestamp !== undefined ? timestamp : new Date().getTime());
1330
+ };
1331
+
1332
+ module.exports = CompassHeading;
1333
+
1334
+ });
1335
+
1336
+ // file: lib/common/plugin/ConfigurationData.js
1337
+ define("cordova/plugin/ConfigurationData", function(require, exports, module) {
1338
+ /**
1339
+ * Encapsulates a set of parameters that the capture device supports.
1340
+ */
1341
+ function ConfigurationData() {
1342
+ // The ASCII-encoded string in lower case representing the media type.
1343
+ this.type = null;
1344
+ // The height attribute represents height of the image or video in pixels.
1345
+ // In the case of a sound clip this attribute has value 0.
1346
+ this.height = 0;
1347
+ // The width attribute represents width of the image or video in pixels.
1348
+ // In the case of a sound clip this attribute has value 0
1349
+ this.width = 0;
1350
+ }
1351
+
1352
+ module.exports = ConfigurationData;
1353
+
1354
+ });
1355
+
1356
+ // file: lib/common/plugin/Connection.js
1357
+ define("cordova/plugin/Connection", function(require, exports, module) {
1358
+ /**
1359
+ * Network status
1360
+ */
1361
+ module.exports = {
1362
+ UNKNOWN: "unknown",
1363
+ ETHERNET: "ethernet",
1364
+ WIFI: "wifi",
1365
+ CELL_2G: "2g",
1366
+ CELL_3G: "3g",
1367
+ CELL_4G: "4g",
1368
+ NONE: "none"
1369
+ };
1370
+
1371
+ });
1372
+
1373
+ // file: lib/common/plugin/Contact.js
1374
+ define("cordova/plugin/Contact", function(require, exports, module) {
1375
+ var exec = require('cordova/exec'),
1376
+ ContactError = require('cordova/plugin/ContactError'),
1377
+ utils = require('cordova/utils');
1378
+
1379
+ /**
1380
+ * Converts primitives into Complex Object
1381
+ * Currently only used for Date fields
1382
+ */
1383
+ function convertIn(contact) {
1384
+ var value = contact.birthday;
1385
+ try {
1386
+ contact.birthday = new Date(parseFloat(value));
1387
+ } catch (exception){
1388
+ console.log("Cordova Contact convertIn error: exception creating date.");
1389
+ }
1390
+ return contact;
1391
+ };
1392
+
1393
+ /**
1394
+ * Converts Complex objects into primitives
1395
+ * Only conversion at present is for Dates.
1396
+ **/
1397
+
1398
+ function convertOut(contact) {
1399
+ var value = contact.birthday;
1400
+ if (value != null) {
1401
+ // try to make it a Date object if it is not already
1402
+ if (!value instanceof Date){
1403
+ try {
1404
+ value = new Date(value);
1405
+ } catch(exception){
1406
+ value = null;
1407
+ }
1408
+ }
1409
+ if (value instanceof Date){
1410
+ value = value.valueOf(); // convert to milliseconds
1411
+ }
1412
+ contact.birthday = value;
1413
+ }
1414
+ return contact;
1415
+ };
1416
+
1417
+ /**
1418
+ * Contains information about a single contact.
1419
+ * @constructor
1420
+ * @param {DOMString} id unique identifier
1421
+ * @param {DOMString} displayName
1422
+ * @param {ContactName} name
1423
+ * @param {DOMString} nickname
1424
+ * @param {Array.<ContactField>} phoneNumbers array of phone numbers
1425
+ * @param {Array.<ContactField>} emails array of email addresses
1426
+ * @param {Array.<ContactAddress>} addresses array of addresses
1427
+ * @param {Array.<ContactField>} ims instant messaging user ids
1428
+ * @param {Array.<ContactOrganization>} organizations
1429
+ * @param {DOMString} birthday contact's birthday
1430
+ * @param {DOMString} note user notes about contact
1431
+ * @param {Array.<ContactField>} photos
1432
+ * @param {Array.<ContactField>} categories
1433
+ * @param {Array.<ContactField>} urls contact's web sites
1434
+ */
1435
+ var Contact = function (id, displayName, name, nickname, phoneNumbers, emails, addresses,
1436
+ ims, organizations, birthday, note, photos, categories, urls) {
1437
+ this.id = id || null;
1438
+ this.rawId = null;
1439
+ this.displayName = displayName || null;
1440
+ this.name = name || null; // ContactName
1441
+ this.nickname = nickname || null;
1442
+ this.phoneNumbers = phoneNumbers || null; // ContactField[]
1443
+ this.emails = emails || null; // ContactField[]
1444
+ this.addresses = addresses || null; // ContactAddress[]
1445
+ this.ims = ims || null; // ContactField[]
1446
+ this.organizations = organizations || null; // ContactOrganization[]
1447
+ this.birthday = birthday || null;
1448
+ this.note = note || null;
1449
+ this.photos = photos || null; // ContactField[]
1450
+ this.categories = categories || null; // ContactField[]
1451
+ this.urls = urls || null; // ContactField[]
1452
+ };
1453
+
1454
+ /**
1455
+ * Removes contact from device storage.
1456
+ * @param successCB success callback
1457
+ * @param errorCB error callback
1458
+ */
1459
+ Contact.prototype.remove = function(successCB, errorCB) {
1460
+ var fail = function(code) {
1461
+ errorCB(new ContactError(code));
1462
+ };
1463
+ if (this.id === null) {
1464
+ fail(ContactError.UNKNOWN_ERROR);
1465
+ }
1466
+ else {
1467
+ exec(successCB, fail, "Contacts", "remove", [this.id]);
1468
+ }
1469
+ };
1470
+
1471
+ /**
1472
+ * Creates a deep copy of this Contact.
1473
+ * With the contact ID set to null.
1474
+ * @return copy of this Contact
1475
+ */
1476
+ Contact.prototype.clone = function() {
1477
+ var clonedContact = utils.clone(this);
1478
+ var i;
1479
+ clonedContact.id = null;
1480
+ clonedContact.rawId = null;
1481
+ // Loop through and clear out any id's in phones, emails, etc.
1482
+ if (clonedContact.phoneNumbers) {
1483
+ for (i = 0; i < clonedContact.phoneNumbers.length; i++) {
1484
+ clonedContact.phoneNumbers[i].id = null;
1485
+ }
1486
+ }
1487
+ if (clonedContact.emails) {
1488
+ for (i = 0; i < clonedContact.emails.length; i++) {
1489
+ clonedContact.emails[i].id = null;
1490
+ }
1491
+ }
1492
+ if (clonedContact.addresses) {
1493
+ for (i = 0; i < clonedContact.addresses.length; i++) {
1494
+ clonedContact.addresses[i].id = null;
1495
+ }
1496
+ }
1497
+ if (clonedContact.ims) {
1498
+ for (i = 0; i < clonedContact.ims.length; i++) {
1499
+ clonedContact.ims[i].id = null;
1500
+ }
1501
+ }
1502
+ if (clonedContact.organizations) {
1503
+ for (i = 0; i < clonedContact.organizations.length; i++) {
1504
+ clonedContact.organizations[i].id = null;
1505
+ }
1506
+ }
1507
+ if (clonedContact.categories) {
1508
+ for (i = 0; i < clonedContact.categories.length; i++) {
1509
+ clonedContact.categories[i].id = null;
1510
+ }
1511
+ }
1512
+ if (clonedContact.photos) {
1513
+ for (i = 0; i < clonedContact.photos.length; i++) {
1514
+ clonedContact.photos[i].id = null;
1515
+ }
1516
+ }
1517
+ if (clonedContact.urls) {
1518
+ for (i = 0; i < clonedContact.urls.length; i++) {
1519
+ clonedContact.urls[i].id = null;
1520
+ }
1521
+ }
1522
+ return clonedContact;
1523
+ };
1524
+
1525
+ /**
1526
+ * Persists contact to device storage.
1527
+ * @param successCB success callback
1528
+ * @param errorCB error callback
1529
+ */
1530
+ Contact.prototype.save = function(successCB, errorCB) {
1531
+ var fail = function(code) {
1532
+ errorCB(new ContactError(code));
1533
+ };
1534
+ var success = function(result) {
1535
+ if (result) {
1536
+ if (typeof successCB === 'function') {
1537
+ var fullContact = require('cordova/plugin/contacts').create(result);
1538
+ successCB(convertIn(fullContact));
1539
+ }
1540
+ }
1541
+ else {
1542
+ // no Entry object returned
1543
+ fail(ContactError.UNKNOWN_ERROR);
1544
+ }
1545
+ };
1546
+ var dupContact = convertOut(utils.clone(this));
1547
+ exec(success, fail, "Contacts", "save", [dupContact]);
1548
+ };
1549
+
1550
+
1551
+ module.exports = Contact;
1552
+
1553
+ });
1554
+
1555
+ // file: lib/common/plugin/ContactAddress.js
1556
+ define("cordova/plugin/ContactAddress", function(require, exports, module) {
1557
+ /**
1558
+ * Contact address.
1559
+ * @constructor
1560
+ * @param {DOMString} id unique identifier, should only be set by native code
1561
+ * @param formatted // NOTE: not a W3C standard
1562
+ * @param streetAddress
1563
+ * @param locality
1564
+ * @param region
1565
+ * @param postalCode
1566
+ * @param country
1567
+ */
1568
+
1569
+ var ContactAddress = function(pref, type, formatted, streetAddress, locality, region, postalCode, country) {
1570
+ this.id = null;
1571
+ this.pref = (typeof pref != 'undefined' ? pref : false);
1572
+ this.type = type || null;
1573
+ this.formatted = formatted || null;
1574
+ this.streetAddress = streetAddress || null;
1575
+ this.locality = locality || null;
1576
+ this.region = region || null;
1577
+ this.postalCode = postalCode || null;
1578
+ this.country = country || null;
1579
+ };
1580
+
1581
+ module.exports = ContactAddress;
1582
+
1583
+ });
1584
+
1585
+ // file: lib/common/plugin/ContactError.js
1586
+ define("cordova/plugin/ContactError", function(require, exports, module) {
1587
+ /**
1588
+ * ContactError.
1589
+ * An error code assigned by an implementation when an error has occured
1590
+ * @constructor
1591
+ */
1592
+ var ContactError = function(err) {
1593
+ this.code = (typeof err != 'undefined' ? err : null);
1594
+ };
1595
+
1596
+ /**
1597
+ * Error codes
1598
+ */
1599
+ ContactError.UNKNOWN_ERROR = 0;
1600
+ ContactError.INVALID_ARGUMENT_ERROR = 1;
1601
+ ContactError.TIMEOUT_ERROR = 2;
1602
+ ContactError.PENDING_OPERATION_ERROR = 3;
1603
+ ContactError.IO_ERROR = 4;
1604
+ ContactError.NOT_SUPPORTED_ERROR = 5;
1605
+ ContactError.PERMISSION_DENIED_ERROR = 20;
1606
+
1607
+ module.exports = ContactError;
1608
+
1609
+ });
1610
+
1611
+ // file: lib/common/plugin/ContactField.js
1612
+ define("cordova/plugin/ContactField", function(require, exports, module) {
1613
+ /**
1614
+ * Generic contact field.
1615
+ * @constructor
1616
+ * @param {DOMString} id unique identifier, should only be set by native code // NOTE: not a W3C standard
1617
+ * @param type
1618
+ * @param value
1619
+ * @param pref
1620
+ */
1621
+ var ContactField = function(type, value, pref) {
1622
+ this.id = null;
1623
+ this.type = type || null;
1624
+ this.value = value || null;
1625
+ this.pref = (typeof pref != 'undefined' ? pref : false);
1626
+ };
1627
+
1628
+ module.exports = ContactField;
1629
+
1630
+ });
1631
+
1632
+ // file: lib/common/plugin/ContactFindOptions.js
1633
+ define("cordova/plugin/ContactFindOptions", function(require, exports, module) {
1634
+ /**
1635
+ * ContactFindOptions.
1636
+ * @constructor
1637
+ * @param filter used to match contacts against
1638
+ * @param multiple boolean used to determine if more than one contact should be returned
1639
+ */
1640
+
1641
+ var ContactFindOptions = function(filter, multiple) {
1642
+ this.filter = filter || '';
1643
+ this.multiple = (typeof multiple != 'undefined' ? multiple : false);
1644
+ };
1645
+
1646
+ module.exports = ContactFindOptions;
1647
+
1648
+ });
1649
+
1650
+ // file: lib/common/plugin/ContactName.js
1651
+ define("cordova/plugin/ContactName", function(require, exports, module) {
1652
+ /**
1653
+ * Contact name.
1654
+ * @constructor
1655
+ * @param formatted // NOTE: not part of W3C standard
1656
+ * @param familyName
1657
+ * @param givenName
1658
+ * @param middle
1659
+ * @param prefix
1660
+ * @param suffix
1661
+ */
1662
+ var ContactName = function(formatted, familyName, givenName, middle, prefix, suffix) {
1663
+ this.formatted = formatted || null;
1664
+ this.familyName = familyName || null;
1665
+ this.givenName = givenName || null;
1666
+ this.middleName = middle || null;
1667
+ this.honorificPrefix = prefix || null;
1668
+ this.honorificSuffix = suffix || null;
1669
+ };
1670
+
1671
+ module.exports = ContactName;
1672
+
1673
+ });
1674
+
1675
+ // file: lib/common/plugin/ContactOrganization.js
1676
+ define("cordova/plugin/ContactOrganization", function(require, exports, module) {
1677
+ /**
1678
+ * Contact organization.
1679
+ * @constructor
1680
+ * @param {DOMString} id unique identifier, should only be set by native code // NOTE: not a W3C standard
1681
+ * @param name
1682
+ * @param dept
1683
+ * @param title
1684
+ * @param startDate
1685
+ * @param endDate
1686
+ * @param location
1687
+ * @param desc
1688
+ */
1689
+
1690
+ var ContactOrganization = function(pref, type, name, dept, title) {
1691
+ this.id = null;
1692
+ this.pref = (typeof pref != 'undefined' ? pref : false);
1693
+ this.type = type || null;
1694
+ this.name = name || null;
1695
+ this.department = dept || null;
1696
+ this.title = title || null;
1697
+ };
1698
+
1699
+ module.exports = ContactOrganization;
1700
+
1701
+ });
1702
+
1703
+ // file: lib/common/plugin/Coordinates.js
1704
+ define("cordova/plugin/Coordinates", function(require, exports, module) {
1705
+ /**
1706
+ * This class contains position information.
1707
+ * @param {Object} lat
1708
+ * @param {Object} lng
1709
+ * @param {Object} alt
1710
+ * @param {Object} acc
1711
+ * @param {Object} head
1712
+ * @param {Object} vel
1713
+ * @param {Object} altacc
1714
+ * @constructor
1715
+ */
1716
+ var Coordinates = function(lat, lng, alt, acc, head, vel, altacc) {
1717
+ /**
1718
+ * The latitude of the position.
1719
+ */
1720
+ this.latitude = lat;
1721
+ /**
1722
+ * The longitude of the position,
1723
+ */
1724
+ this.longitude = lng;
1725
+ /**
1726
+ * The accuracy of the position.
1727
+ */
1728
+ this.accuracy = acc;
1729
+ /**
1730
+ * The altitude of the position.
1731
+ */
1732
+ this.altitude = alt;
1733
+ /**
1734
+ * The direction the device is moving at the position.
1735
+ */
1736
+ this.heading = head;
1737
+ /**
1738
+ * The velocity with which the device is moving at the position.
1739
+ */
1740
+ this.speed = vel;
1741
+ /**
1742
+ * The altitude accuracy of the position.
1743
+ */
1744
+ this.altitudeAccuracy = (altacc !== undefined) ? altacc : null;
1745
+ };
1746
+
1747
+ module.exports = Coordinates;
1748
+
1749
+ });
1750
+
1751
+ // file: lib/common/plugin/DirectoryEntry.js
1752
+ define("cordova/plugin/DirectoryEntry", function(require, exports, module) {
1753
+ var utils = require('cordova/utils'),
1754
+ exec = require('cordova/exec'),
1755
+ Entry = require('cordova/plugin/Entry'),
1756
+ DirectoryReader = require('cordova/plugin/DirectoryReader');
1757
+
1758
+ /**
1759
+ * An interface representing a directory on the file system.
1760
+ *
1761
+ * {boolean} isFile always false (readonly)
1762
+ * {boolean} isDirectory always true (readonly)
1763
+ * {DOMString} name of the directory, excluding the path leading to it (readonly)
1764
+ * {DOMString} fullPath the absolute full path to the directory (readonly)
1765
+ * {FileSystem} filesystem on which the directory resides (readonly)
1766
+ */
1767
+ var DirectoryEntry = function(name, fullPath) {
1768
+ DirectoryEntry.__super__.constructor.apply(this, [false, true, name, fullPath]);
1769
+ };
1770
+
1771
+ utils.extend(DirectoryEntry, Entry);
1772
+
1773
+ /**
1774
+ * Creates a new DirectoryReader to read entries from this directory
1775
+ */
1776
+ DirectoryEntry.prototype.createReader = function() {
1777
+ return new DirectoryReader(this.fullPath);
1778
+ };
1779
+
1780
+ /**
1781
+ * Creates or looks up a directory
1782
+ *
1783
+ * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a directory
1784
+ * @param {Flags} options to create or excluively create the directory
1785
+ * @param {Function} successCallback is called with the new entry
1786
+ * @param {Function} errorCallback is called with a FileError
1787
+ */
1788
+ DirectoryEntry.prototype.getDirectory = function(path, options, successCallback, errorCallback) {
1789
+ var win = typeof successCallback !== 'function' ? null : function(result) {
1790
+ var entry = new DirectoryEntry(result.name, result.fullPath);
1791
+ successCallback(entry);
1792
+ };
1793
+ var fail = typeof errorCallback !== 'function' ? null : function(code) {
1794
+ errorCallback(new FileError(code));
1795
+ };
1796
+ exec(win, fail, "File", "getDirectory", [this.fullPath, path, options]);
1797
+ };
1798
+
1799
+ /**
1800
+ * Deletes a directory and all of it's contents
1801
+ *
1802
+ * @param {Function} successCallback is called with no parameters
1803
+ * @param {Function} errorCallback is called with a FileError
1804
+ */
1805
+ DirectoryEntry.prototype.removeRecursively = function(successCallback, errorCallback) {
1806
+ var fail = typeof errorCallback !== 'function' ? null : function(code) {
1807
+ errorCallback(new FileError(code));
1808
+ };
1809
+ exec(successCallback, fail, "File", "removeRecursively", [this.fullPath]);
1810
+ };
1811
+
1812
+ /**
1813
+ * Creates or looks up a file
1814
+ *
1815
+ * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a file
1816
+ * @param {Flags} options to create or excluively create the file
1817
+ * @param {Function} successCallback is called with the new entry
1818
+ * @param {Function} errorCallback is called with a FileError
1819
+ */
1820
+ DirectoryEntry.prototype.getFile = function(path, options, successCallback, errorCallback) {
1821
+ var win = typeof successCallback !== 'function' ? null : function(result) {
1822
+ var FileEntry = require('cordova/plugin/FileEntry');
1823
+ var entry = new FileEntry(result.name, result.fullPath);
1824
+ successCallback(entry);
1825
+ };
1826
+ var fail = typeof errorCallback !== 'function' ? null : function(code) {
1827
+ errorCallback(new FileError(code));
1828
+ };
1829
+ exec(win, fail, "File", "getFile", [this.fullPath, path, options]);
1830
+ };
1831
+
1832
+ module.exports = DirectoryEntry;
1833
+
1834
+ });
1835
+
1836
+ // file: lib/common/plugin/DirectoryReader.js
1837
+ define("cordova/plugin/DirectoryReader", function(require, exports, module) {
1838
+ var exec = require('cordova/exec');
1839
+
1840
+ /**
1841
+ * An interface that lists the files and directories in a directory.
1842
+ */
1843
+ function DirectoryReader(path) {
1844
+ this.path = path || null;
1845
+ }
1846
+
1847
+ /**
1848
+ * Returns a list of entries from a directory.
1849
+ *
1850
+ * @param {Function} successCallback is called with a list of entries
1851
+ * @param {Function} errorCallback is called with a FileError
1852
+ */
1853
+ DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) {
1854
+ var win = typeof successCallback !== 'function' ? null : function(result) {
1855
+ var retVal = [];
1856
+ for (var i=0; i<result.length; i++) {
1857
+ var entry = null;
1858
+ if (result[i].isDirectory) {
1859
+ entry = new DirectoryEntry();
1860
+ }
1861
+ else if (result[i].isFile) {
1862
+ entry = new FileEntry();
1863
+ }
1864
+ entry.isDirectory = result[i].isDirectory;
1865
+ entry.isFile = result[i].isFile;
1866
+ entry.name = result[i].name;
1867
+ entry.fullPath = result[i].fullPath;
1868
+ retVal.push(entry);
1869
+ }
1870
+ successCallback(retVal);
1871
+ };
1872
+ var fail = typeof errorCallback !== 'function' ? null : function(code) {
1873
+ errorCallback(new FileError(code));
1874
+ };
1875
+ exec(win, fail, "File", "readEntries", [this.path]);
1876
+ };
1877
+
1878
+ module.exports = DirectoryReader;
1879
+
1880
+ });
1881
+
1882
+ // file: lib/common/plugin/Entry.js
1883
+ define("cordova/plugin/Entry", function(require, exports, module) {
1884
+ var exec = require('cordova/exec'),
1885
+ FileError = require('cordova/plugin/FileError'),
1886
+ Metadata = require('cordova/plugin/Metadata');
1887
+
1888
+ /**
1889
+ * Represents a file or directory on the local file system.
1890
+ *
1891
+ * @param isFile
1892
+ * {boolean} true if Entry is a file (readonly)
1893
+ * @param isDirectory
1894
+ * {boolean} true if Entry is a directory (readonly)
1895
+ * @param name
1896
+ * {DOMString} name of the file or directory, excluding the path
1897
+ * leading to it (readonly)
1898
+ * @param fullPath
1899
+ * {DOMString} the absolute full path to the file or directory
1900
+ * (readonly)
1901
+ */
1902
+ function Entry(isFile, isDirectory, name, fullPath, fileSystem) {
1903
+ this.isFile = (typeof isFile != 'undefined'?isFile:false);
1904
+ this.isDirectory = (typeof isDirectory != 'undefined'?isDirectory:false);
1905
+ this.name = name || '';
1906
+ this.fullPath = fullPath || '';
1907
+ this.filesystem = fileSystem || null;
1908
+ }
1909
+
1910
+ /**
1911
+ * Look up the metadata of the entry.
1912
+ *
1913
+ * @param successCallback
1914
+ * {Function} is called with a Metadata object
1915
+ * @param errorCallback
1916
+ * {Function} is called with a FileError
1917
+ */
1918
+ Entry.prototype.getMetadata = function(successCallback, errorCallback) {
1919
+ var success = typeof successCallback !== 'function' ? null : function(lastModified) {
1920
+ var metadata = new Metadata(lastModified);
1921
+ successCallback(metadata);
1922
+ };
1923
+ var fail = typeof errorCallback !== 'function' ? null : function(code) {
1924
+ errorCallback(new FileError(code));
1925
+ };
1926
+
1927
+ exec(success, fail, "File", "getMetadata", [this.fullPath]);
1928
+ };
1929
+
1930
+ /**
1931
+ * Move a file or directory to a new location.
1932
+ *
1933
+ * @param parent
1934
+ * {DirectoryEntry} the directory to which to move this entry
1935
+ * @param newName
1936
+ * {DOMString} new name of the entry, defaults to the current name
1937
+ * @param successCallback
1938
+ * {Function} called with the new DirectoryEntry object
1939
+ * @param errorCallback
1940
+ * {Function} called with a FileError
1941
+ */
1942
+ Entry.prototype.moveTo = function(parent, newName, successCallback, errorCallback) {
1943
+ var fail = function(code) {
1944
+ if (typeof errorCallback === 'function') {
1945
+ errorCallback(new FileError(code));
1946
+ }
1947
+ };
1948
+ // user must specify parent Entry
1949
+ if (!parent) {
1950
+ fail(FileError.NOT_FOUND_ERR);
1951
+ return;
1952
+ }
1953
+ // source path
1954
+ var srcPath = this.fullPath,
1955
+ // entry name
1956
+ name = newName || this.name,
1957
+ success = function(entry) {
1958
+ if (entry) {
1959
+ if (typeof successCallback === 'function') {
1960
+ // create appropriate Entry object
1961
+ var result = (entry.isDirectory) ? new (require('cordova/plugin/DirectoryEntry'))(entry.name, entry.fullPath) : new (require('cordova/plugin/FileEntry'))(entry.name, entry.fullPath);
1962
+ try {
1963
+ successCallback(result);
1964
+ }
1965
+ catch (e) {
1966
+ console.log('Error invoking callback: ' + e);
1967
+ }
1968
+ }
1969
+ }
1970
+ else {
1971
+ // no Entry object returned
1972
+ fail(FileError.NOT_FOUND_ERR);
1973
+ }
1974
+ };
1975
+
1976
+ // copy
1977
+ exec(success, fail, "File", "moveTo", [srcPath, parent.fullPath, name]);
1978
+ };
1979
+
1980
+ /**
1981
+ * Copy a directory to a different location.
1982
+ *
1983
+ * @param parent
1984
+ * {DirectoryEntry} the directory to which to copy the entry
1985
+ * @param newName
1986
+ * {DOMString} new name of the entry, defaults to the current name
1987
+ * @param successCallback
1988
+ * {Function} called with the new Entry object
1989
+ * @param errorCallback
1990
+ * {Function} called with a FileError
1991
+ */
1992
+ Entry.prototype.copyTo = function(parent, newName, successCallback, errorCallback) {
1993
+ var fail = function(code) {
1994
+ if (typeof errorCallback === 'function') {
1995
+ errorCallback(new FileError(code));
1996
+ }
1997
+ };
1998
+
1999
+ // user must specify parent Entry
2000
+ if (!parent) {
2001
+ fail(FileError.NOT_FOUND_ERR);
2002
+ return;
2003
+ }
2004
+
2005
+ // source path
2006
+ var srcPath = this.fullPath,
2007
+ // entry name
2008
+ name = newName || this.name,
2009
+ // success callback
2010
+ success = function(entry) {
2011
+ if (entry) {
2012
+ if (typeof successCallback === 'function') {
2013
+ // create appropriate Entry object
2014
+ var result = (entry.isDirectory) ? new (require('cordova/plugin/DirectoryEntry'))(entry.name, entry.fullPath) : new (require('cordova/plugin/FileEntry'))(entry.name, entry.fullPath);
2015
+ try {
2016
+ successCallback(result);
2017
+ }
2018
+ catch (e) {
2019
+ console.log('Error invoking callback: ' + e);
2020
+ }
2021
+ }
2022
+ }
2023
+ else {
2024
+ // no Entry object returned
2025
+ fail(FileError.NOT_FOUND_ERR);
2026
+ }
2027
+ };
2028
+
2029
+ // copy
2030
+ exec(success, fail, "File", "copyTo", [srcPath, parent.fullPath, name]);
2031
+ };
2032
+
2033
+ /**
2034
+ * Return a URL that can be used to identify this entry.
2035
+ */
2036
+ Entry.prototype.toURL = function() {
2037
+ // fullPath attribute contains the full URL
2038
+ return this.fullPath;
2039
+ };
2040
+
2041
+ /**
2042
+ * Returns a URI that can be used to identify this entry.
2043
+ *
2044
+ * @param {DOMString} mimeType for a FileEntry, the mime type to be used to interpret the file, when loaded through this URI.
2045
+ * @return uri
2046
+ */
2047
+ Entry.prototype.toURI = function(mimeType) {
2048
+ console.log("DEPRECATED: Update your code to use 'toURL'");
2049
+ // fullPath attribute contains the full URI
2050
+ return this.fullPath;
2051
+ };
2052
+
2053
+ /**
2054
+ * Remove a file or directory. It is an error to attempt to delete a
2055
+ * directory that is not empty. It is an error to attempt to delete a
2056
+ * root directory of a file system.
2057
+ *
2058
+ * @param successCallback {Function} called with no parameters
2059
+ * @param errorCallback {Function} called with a FileError
2060
+ */
2061
+ Entry.prototype.remove = function(successCallback, errorCallback) {
2062
+ var fail = typeof errorCallback !== 'function' ? null : function(code) {
2063
+ errorCallback(new FileError(code));
2064
+ };
2065
+ exec(successCallback, fail, "File", "remove", [this.fullPath]);
2066
+ };
2067
+
2068
+ /**
2069
+ * Look up the parent DirectoryEntry of this entry.
2070
+ *
2071
+ * @param successCallback {Function} called with the parent DirectoryEntry object
2072
+ * @param errorCallback {Function} called with a FileError
2073
+ */
2074
+ Entry.prototype.getParent = function(successCallback, errorCallback) {
2075
+ var win = typeof successCallback !== 'function' ? null : function(result) {
2076
+ var DirectoryEntry = require('cordova/plugin/DirectoryEntry');
2077
+ var entry = new DirectoryEntry(result.name, result.fullPath);
2078
+ successCallback(entry);
2079
+ };
2080
+ var fail = typeof errorCallback !== 'function' ? null : function(code) {
2081
+ errorCallback(new FileError(code));
2082
+ };
2083
+ exec(win, fail, "File", "getParent", [this.fullPath]);
2084
+ };
2085
+
2086
+ module.exports = Entry;
2087
+
2088
+ });
2089
+
2090
+ // file: lib/common/plugin/File.js
2091
+ define("cordova/plugin/File", function(require, exports, module) {
2092
+ /**
2093
+ * Constructor.
2094
+ * name {DOMString} name of the file, without path information
2095
+ * fullPath {DOMString} the full path of the file, including the name
2096
+ * type {DOMString} mime type
2097
+ * lastModifiedDate {Date} last modified date
2098
+ * size {Number} size of the file in bytes
2099
+ */
2100
+
2101
+ var File = function(name, fullPath, type, lastModifiedDate, size){
2102
+ this.name = name || '';
2103
+ this.fullPath = fullPath || null;
2104
+ this.type = type || null;
2105
+ this.lastModifiedDate = lastModifiedDate || null;
2106
+ this.size = size || 0;
2107
+ };
2108
+
2109
+ module.exports = File;
2110
+
2111
+ });
2112
+
2113
+ // file: lib/common/plugin/FileEntry.js
2114
+ define("cordova/plugin/FileEntry", function(require, exports, module) {
2115
+ var utils = require('cordova/utils'),
2116
+ exec = require('cordova/exec'),
2117
+ Entry = require('cordova/plugin/Entry'),
2118
+ FileWriter = require('cordova/plugin/FileWriter'),
2119
+ File = require('cordova/plugin/File'),
2120
+ FileError = require('cordova/plugin/FileError');
2121
+
2122
+ /**
2123
+ * An interface representing a file on the file system.
2124
+ *
2125
+ * {boolean} isFile always true (readonly)
2126
+ * {boolean} isDirectory always false (readonly)
2127
+ * {DOMString} name of the file, excluding the path leading to it (readonly)
2128
+ * {DOMString} fullPath the absolute full path to the file (readonly)
2129
+ * {FileSystem} filesystem on which the file resides (readonly)
2130
+ */
2131
+ var FileEntry = function(name, fullPath) {
2132
+ FileEntry.__super__.constructor.apply(this, [true, false, name, fullPath]);
2133
+ };
2134
+
2135
+ utils.extend(FileEntry, Entry);
2136
+
2137
+ /**
2138
+ * Creates a new FileWriter associated with the file that this FileEntry represents.
2139
+ *
2140
+ * @param {Function} successCallback is called with the new FileWriter
2141
+ * @param {Function} errorCallback is called with a FileError
2142
+ */
2143
+ FileEntry.prototype.createWriter = function(successCallback, errorCallback) {
2144
+ this.file(function(filePointer) {
2145
+ var writer = new FileWriter(filePointer);
2146
+
2147
+ if (writer.fileName === null || writer.fileName === "") {
2148
+ if (typeof errorCallback === "function") {
2149
+ errorCallback(new FileError(FileError.INVALID_STATE_ERR));
2150
+ }
2151
+ } else {
2152
+ if (typeof successCallback === "function") {
2153
+ successCallback(writer);
2154
+ }
2155
+ }
2156
+ }, errorCallback);
2157
+ };
2158
+
2159
+ /**
2160
+ * Returns a File that represents the current state of the file that this FileEntry represents.
2161
+ *
2162
+ * @param {Function} successCallback is called with the new File object
2163
+ * @param {Function} errorCallback is called with a FileError
2164
+ */
2165
+ FileEntry.prototype.file = function(successCallback, errorCallback) {
2166
+ var win = typeof successCallback !== 'function' ? null : function(f) {
2167
+ var file = new File(f.name, f.fullPath, f.type, f.lastModifiedDate, f.size);
2168
+ successCallback(file);
2169
+ };
2170
+ var fail = typeof errorCallback !== 'function' ? null : function(code) {
2171
+ errorCallback(new FileError(code));
2172
+ };
2173
+ exec(win, fail, "File", "getFileMetadata", [this.fullPath]);
2174
+ };
2175
+
2176
+
2177
+ module.exports = FileEntry;
2178
+
2179
+ });
2180
+
2181
+ // file: lib/common/plugin/FileError.js
2182
+ define("cordova/plugin/FileError", function(require, exports, module) {
2183
+ /**
2184
+ * FileError
2185
+ */
2186
+ function FileError(error) {
2187
+ this.code = error || null;
2188
+ }
2189
+
2190
+ // File error codes
2191
+ // Found in DOMException
2192
+ FileError.NOT_FOUND_ERR = 1;
2193
+ FileError.SECURITY_ERR = 2;
2194
+ FileError.ABORT_ERR = 3;
2195
+
2196
+ // Added by File API specification
2197
+ FileError.NOT_READABLE_ERR = 4;
2198
+ FileError.ENCODING_ERR = 5;
2199
+ FileError.NO_MODIFICATION_ALLOWED_ERR = 6;
2200
+ FileError.INVALID_STATE_ERR = 7;
2201
+ FileError.SYNTAX_ERR = 8;
2202
+ FileError.INVALID_MODIFICATION_ERR = 9;
2203
+ FileError.QUOTA_EXCEEDED_ERR = 10;
2204
+ FileError.TYPE_MISMATCH_ERR = 11;
2205
+ FileError.PATH_EXISTS_ERR = 12;
2206
+
2207
+ module.exports = FileError;
2208
+
2209
+ });
2210
+
2211
+ // file: lib/common/plugin/FileReader.js
2212
+ define("cordova/plugin/FileReader", function(require, exports, module) {
2213
+ var exec = require('cordova/exec'),
2214
+ FileError = require('cordova/plugin/FileError'),
2215
+ ProgressEvent = require('cordova/plugin/ProgressEvent');
2216
+
2217
+ /**
2218
+ * This class reads the mobile device file system.
2219
+ *
2220
+ * For Android:
2221
+ * The root directory is the root of the file system.
2222
+ * To read from the SD card, the file name is "sdcard/my_file.txt"
2223
+ * @constructor
2224
+ */
2225
+ var FileReader = function() {
2226
+ this.fileName = "";
2227
+
2228
+ this.readyState = 0; // FileReader.EMPTY
2229
+
2230
+ // File data
2231
+ this.result = null;
2232
+
2233
+ // Error
2234
+ this.error = null;
2235
+
2236
+ // Event handlers
2237
+ this.onloadstart = null; // When the read starts.
2238
+ this.onprogress = null; // While reading (and decoding) file or fileBlob data, and reporting partial file data (progess.loaded/progress.total)
2239
+ this.onload = null; // When the read has successfully completed.
2240
+ this.onerror = null; // When the read has failed (see errors).
2241
+ this.onloadend = null; // When the request has completed (either in success or failure).
2242
+ this.onabort = null; // When the read has been aborted. For instance, by invoking the abort() method.
2243
+ };
2244
+
2245
+ // States
2246
+ FileReader.EMPTY = 0;
2247
+ FileReader.LOADING = 1;
2248
+ FileReader.DONE = 2;
2249
+
2250
+ /**
2251
+ * Abort reading file.
2252
+ */
2253
+ FileReader.prototype.abort = function() {
2254
+ this.result = null;
2255
+
2256
+ if (this.readyState == FileReader.DONE || this.readyState == FileReader.EMPTY) {
2257
+ return;
2258
+ }
2259
+
2260
+ this.readyState = FileReader.DONE;
2261
+
2262
+ // If abort callback
2263
+ if (typeof this.onabort === 'function') {
2264
+ this.onabort(new ProgressEvent('abort', {target:this}));
2265
+ }
2266
+ // If load end callback
2267
+ if (typeof this.onloadend === 'function') {
2268
+ this.onloadend(new ProgressEvent('loadend', {target:this}));
2269
+ }
2270
+ };
2271
+
2272
+ /**
2273
+ * Read text file.
2274
+ *
2275
+ * @param file {File} File object containing file properties
2276
+ * @param encoding [Optional] (see http://www.iana.org/assignments/character-sets)
2277
+ */
2278
+ FileReader.prototype.readAsText = function(file, encoding) {
2279
+ // Figure out pathing
2280
+ this.fileName = '';
2281
+ if (typeof file.fullPath === 'undefined') {
2282
+ this.fileName = file;
2283
+ } else {
2284
+ this.fileName = file.fullPath;
2285
+ }
2286
+
2287
+ // Already loading something
2288
+ if (this.readyState == FileReader.LOADING) {
2289
+ throw new FileError(FileError.INVALID_STATE_ERR);
2290
+ }
2291
+
2292
+ // LOADING state
2293
+ this.readyState = FileReader.LOADING;
2294
+
2295
+ // If loadstart callback
2296
+ if (typeof this.onloadstart === "function") {
2297
+ this.onloadstart(new ProgressEvent("loadstart", {target:this}));
2298
+ }
2299
+
2300
+ // Default encoding is UTF-8
2301
+ var enc = encoding ? encoding : "UTF-8";
2302
+
2303
+ var me = this;
2304
+
2305
+ // Read file
2306
+ exec(
2307
+ // Success callback
2308
+ function(r) {
2309
+ // If DONE (cancelled), then don't do anything
2310
+ if (me.readyState === FileReader.DONE) {
2311
+ return;
2312
+ }
2313
+
2314
+ // Save result
2315
+ me.result = r;
2316
+
2317
+ // If onload callback
2318
+ if (typeof me.onload === "function") {
2319
+ me.onload(new ProgressEvent("load", {target:me}));
2320
+ }
2321
+
2322
+ // DONE state
2323
+ me.readyState = FileReader.DONE;
2324
+
2325
+ // If onloadend callback
2326
+ if (typeof me.onloadend === "function") {
2327
+ me.onloadend(new ProgressEvent("loadend", {target:me}));
2328
+ }
2329
+ },
2330
+ // Error callback
2331
+ function(e) {
2332
+ // If DONE (cancelled), then don't do anything
2333
+ if (me.readyState === FileReader.DONE) {
2334
+ return;
2335
+ }
2336
+
2337
+ // DONE state
2338
+ me.readyState = FileReader.DONE;
2339
+
2340
+ // null result
2341
+ me.result = null;
2342
+
2343
+ // Save error
2344
+ me.error = new FileError(e);
2345
+
2346
+ // If onerror callback
2347
+ if (typeof me.onerror === "function") {
2348
+ me.onerror(new ProgressEvent("error", {target:me}));
2349
+ }
2350
+
2351
+ // If onloadend callback
2352
+ if (typeof me.onloadend === "function") {
2353
+ me.onloadend(new ProgressEvent("loadend", {target:me}));
2354
+ }
2355
+ }, "File", "readAsText", [this.fileName, enc]);
2356
+ };
2357
+
2358
+
2359
+ /**
2360
+ * Read file and return data as a base64 encoded data url.
2361
+ * A data url is of the form:
2362
+ * data:[<mediatype>][;base64],<data>
2363
+ *
2364
+ * @param file {File} File object containing file properties
2365
+ */
2366
+ FileReader.prototype.readAsDataURL = function(file) {
2367
+ this.fileName = "";
2368
+ if (typeof file.fullPath === "undefined") {
2369
+ this.fileName = file;
2370
+ } else {
2371
+ this.fileName = file.fullPath;
2372
+ }
2373
+
2374
+ // Already loading something
2375
+ if (this.readyState == FileReader.LOADING) {
2376
+ throw new FileError(FileError.INVALID_STATE_ERR);
2377
+ }
2378
+
2379
+ // LOADING state
2380
+ this.readyState = FileReader.LOADING;
2381
+
2382
+ // If loadstart callback
2383
+ if (typeof this.onloadstart === "function") {
2384
+ this.onloadstart(new ProgressEvent("loadstart", {target:this}));
2385
+ }
2386
+
2387
+ var me = this;
2388
+
2389
+ // Read file
2390
+ exec(
2391
+ // Success callback
2392
+ function(r) {
2393
+ // If DONE (cancelled), then don't do anything
2394
+ if (me.readyState === FileReader.DONE) {
2395
+ return;
2396
+ }
2397
+
2398
+ // DONE state
2399
+ me.readyState = FileReader.DONE;
2400
+
2401
+ // Save result
2402
+ me.result = r;
2403
+
2404
+ // If onload callback
2405
+ if (typeof me.onload === "function") {
2406
+ me.onload(new ProgressEvent("load", {target:me}));
2407
+ }
2408
+
2409
+ // If onloadend callback
2410
+ if (typeof me.onloadend === "function") {
2411
+ me.onloadend(new ProgressEvent("loadend", {target:me}));
2412
+ }
2413
+ },
2414
+ // Error callback
2415
+ function(e) {
2416
+ // If DONE (cancelled), then don't do anything
2417
+ if (me.readyState === FileReader.DONE) {
2418
+ return;
2419
+ }
2420
+
2421
+ // DONE state
2422
+ me.readyState = FileReader.DONE;
2423
+
2424
+ me.result = null;
2425
+
2426
+ // Save error
2427
+ me.error = new FileError(e);
2428
+
2429
+ // If onerror callback
2430
+ if (typeof me.onerror === "function") {
2431
+ me.onerror(new ProgressEvent("error", {target:me}));
2432
+ }
2433
+
2434
+ // If onloadend callback
2435
+ if (typeof me.onloadend === "function") {
2436
+ me.onloadend(new ProgressEvent("loadend", {target:me}));
2437
+ }
2438
+ }, "File", "readAsDataURL", [this.fileName]);
2439
+ };
2440
+
2441
+ /**
2442
+ * Read file and return data as a binary data.
2443
+ *
2444
+ * @param file {File} File object containing file properties
2445
+ */
2446
+ FileReader.prototype.readAsBinaryString = function(file) {
2447
+ // TODO - Can't return binary data to browser.
2448
+ console.log('method "readAsBinaryString" is not supported at this time.');
2449
+ };
2450
+
2451
+ /**
2452
+ * Read file and return data as a binary data.
2453
+ *
2454
+ * @param file {File} File object containing file properties
2455
+ */
2456
+ FileReader.prototype.readAsArrayBuffer = function(file) {
2457
+ // TODO - Can't return binary data to browser.
2458
+ console.log('This method is not supported at this time.');
2459
+ };
2460
+
2461
+ module.exports = FileReader;
2462
+
2463
+ });
2464
+
2465
+ // file: lib/common/plugin/FileSystem.js
2466
+ define("cordova/plugin/FileSystem", function(require, exports, module) {
2467
+ var DirectoryEntry = require('cordova/plugin/DirectoryEntry');
2468
+
2469
+ /**
2470
+ * An interface representing a file system
2471
+ *
2472
+ * @constructor
2473
+ * {DOMString} name the unique name of the file system (readonly)
2474
+ * {DirectoryEntry} root directory of the file system (readonly)
2475
+ */
2476
+ var FileSystem = function(name, root) {
2477
+ this.name = name || null;
2478
+ if (root) {
2479
+ this.root = new DirectoryEntry(root.name, root.fullPath);
2480
+ }
2481
+ };
2482
+
2483
+ module.exports = FileSystem;
2484
+
2485
+ });
2486
+
2487
+ // file: lib/common/plugin/FileTransfer.js
2488
+ define("cordova/plugin/FileTransfer", function(require, exports, module) {
2489
+ var exec = require('cordova/exec');
2490
+
2491
+ /**
2492
+ * FileTransfer uploads a file to a remote server.
2493
+ * @constructor
2494
+ */
2495
+ var FileTransfer = function() {};
2496
+
2497
+ /**
2498
+ * Given an absolute file path, uploads a file on the device to a remote server
2499
+ * using a multipart HTTP request.
2500
+ * @param filePath {String} Full path of the file on the device
2501
+ * @param server {String} URL of the server to receive the file
2502
+ * @param successCallback (Function} Callback to be invoked when upload has completed
2503
+ * @param errorCallback {Function} Callback to be invoked upon error
2504
+ * @param options {FileUploadOptions} Optional parameters such as file name and mimetype
2505
+ * @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false
2506
+ */
2507
+ FileTransfer.prototype.upload = function(filePath, server, successCallback, errorCallback, options, trustAllHosts) {
2508
+ // check for options
2509
+ var fileKey = null;
2510
+ var fileName = null;
2511
+ var mimeType = null;
2512
+ var params = null;
2513
+ var chunkedMode = true;
2514
+ if (options) {
2515
+ fileKey = options.fileKey;
2516
+ fileName = options.fileName;
2517
+ mimeType = options.mimeType;
2518
+ if (options.chunkedMode !== null || typeof options.chunkedMode !== "undefined") {
2519
+ chunkedMode = options.chunkedMode;
2520
+ }
2521
+ if (options.params) {
2522
+ params = options.params;
2523
+ }
2524
+ else {
2525
+ params = {};
2526
+ }
2527
+ }
2528
+
2529
+ exec(successCallback, errorCallback, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode]);
2530
+ };
2531
+
2532
+ /**
2533
+ * Downloads a file form a given URL and saves it to the specified directory.
2534
+ * @param source {String} URL of the server to receive the file
2535
+ * @param target {String} Full path of the file on the device
2536
+ * @param successCallback (Function} Callback to be invoked when upload has completed
2537
+ * @param errorCallback {Function} Callback to be invoked upon error
2538
+ */
2539
+ FileTransfer.prototype.download = function(source, target, successCallback, errorCallback) {
2540
+ var win = function(result) {
2541
+ var entry = null;
2542
+ if (result.isDirectory) {
2543
+ entry = new DirectoryEntry();
2544
+ }
2545
+ else if (result.isFile) {
2546
+ entry = new FileEntry();
2547
+ }
2548
+ entry.isDirectory = result.isDirectory;
2549
+ entry.isFile = result.isFile;
2550
+ entry.name = result.name;
2551
+ entry.fullPath = result.fullPath;
2552
+ successCallback(entry);
2553
+ };
2554
+ exec(win, errorCallback, 'FileTransfer', 'download', [source, target]);
2555
+ };
2556
+
2557
+ module.exports = FileTransfer;
2558
+
2559
+ });
2560
+
2561
+ // file: lib/common/plugin/FileTransferError.js
2562
+ define("cordova/plugin/FileTransferError", function(require, exports, module) {
2563
+ /**
2564
+ * FileTransferError
2565
+ * @constructor
2566
+ */
2567
+ var FileTransferError = function(code) {
2568
+ this.code = code || null;
2569
+ };
2570
+
2571
+ FileTransferError.FILE_NOT_FOUND_ERR = 1;
2572
+ FileTransferError.INVALID_URL_ERR = 2;
2573
+ FileTransferError.CONNECTION_ERR = 3;
2574
+
2575
+ module.exports = FileTransferError;
2576
+
2577
+ });
2578
+
2579
+ // file: lib/common/plugin/FileUploadOptions.js
2580
+ define("cordova/plugin/FileUploadOptions", function(require, exports, module) {
2581
+ /**
2582
+ * Options to customize the HTTP request used to upload files.
2583
+ * @constructor
2584
+ * @param fileKey {String} Name of file request parameter.
2585
+ * @param fileName {String} Filename to be used by the server. Defaults to image.jpg.
2586
+ * @param mimeType {String} Mimetype of the uploaded file. Defaults to image/jpeg.
2587
+ * @param params {Object} Object with key: value params to send to the server.
2588
+ */
2589
+ var FileUploadOptions = function(fileKey, fileName, mimeType, params) {
2590
+ this.fileKey = fileKey || null;
2591
+ this.fileName = fileName || null;
2592
+ this.mimeType = mimeType || null;
2593
+ this.params = params || null;
2594
+ };
2595
+
2596
+ module.exports = FileUploadOptions;
2597
+
2598
+ });
2599
+
2600
+ // file: lib/common/plugin/FileUploadResult.js
2601
+ define("cordova/plugin/FileUploadResult", function(require, exports, module) {
2602
+ /**
2603
+ * FileUploadResult
2604
+ * @constructor
2605
+ */
2606
+ var FileUploadResult = function() {
2607
+ this.bytesSent = 0;
2608
+ this.responseCode = null;
2609
+ this.response = null;
2610
+ };
2611
+
2612
+ module.exports = FileUploadResult;
2613
+
2614
+ });
2615
+
2616
+ // file: lib/common/plugin/FileWriter.js
2617
+ define("cordova/plugin/FileWriter", function(require, exports, module) {
2618
+ var exec = require('cordova/exec'),
2619
+ FileError = require('cordova/plugin/FileError');
2620
+ ProgressEvent = require('cordova/plugin/ProgressEvent');
2621
+
2622
+ /**
2623
+ * This class writes to the mobile device file system.
2624
+ *
2625
+ * For Android:
2626
+ * The root directory is the root of the file system.
2627
+ * To write to the SD card, the file name is "sdcard/my_file.txt"
2628
+ *
2629
+ * @constructor
2630
+ * @param file {File} File object containing file properties
2631
+ * @param append if true write to the end of the file, otherwise overwrite the file
2632
+ */
2633
+ var FileWriter = function(file) {
2634
+ this.fileName = "";
2635
+ this.length = 0;
2636
+ if (file) {
2637
+ this.fileName = file.fullPath || file;
2638
+ this.length = file.size || 0;
2639
+ }
2640
+ // default is to write at the beginning of the file
2641
+ this.position = 0;
2642
+
2643
+ this.readyState = 0; // EMPTY
2644
+
2645
+ this.result = null;
2646
+
2647
+ // Error
2648
+ this.error = null;
2649
+
2650
+ // Event handlers
2651
+ this.onwritestart = null; // When writing starts
2652
+ this.onprogress = null; // While writing the file, and reporting partial file data
2653
+ this.onwrite = null; // When the write has successfully completed.
2654
+ this.onwriteend = null; // When the request has completed (either in success or failure).
2655
+ this.onabort = null; // When the write has been aborted. For instance, by invoking the abort() method.
2656
+ this.onerror = null; // When the write has failed (see errors).
2657
+ };
2658
+
2659
+ // States
2660
+ FileWriter.INIT = 0;
2661
+ FileWriter.WRITING = 1;
2662
+ FileWriter.DONE = 2;
2663
+
2664
+ /**
2665
+ * Abort writing file.
2666
+ */
2667
+ FileWriter.prototype.abort = function() {
2668
+ // check for invalid state
2669
+ if (this.readyState === FileWriter.DONE || this.readyState === FileWriter.INIT) {
2670
+ throw new FileError(FileError.INVALID_STATE_ERR);
2671
+ }
2672
+
2673
+ // set error
2674
+ this.error = new FileError(FileError.ABORT_ERR);
2675
+
2676
+ this.readyState = FileWriter.DONE;
2677
+
2678
+ // If abort callback
2679
+ if (typeof this.onabort === "function") {
2680
+ this.onabort(new ProgressEvent("abort", {"target":this}));
2681
+ }
2682
+
2683
+ // If write end callback
2684
+ if (typeof this.onwriteend === "function") {
2685
+ this.onwriteend(new ProgressEvent("writeend", {"target":this}));
2686
+ }
2687
+ };
2688
+
2689
+ /**
2690
+ * Writes data to the file
2691
+ *
2692
+ * @param text to be written
2693
+ */
2694
+ FileWriter.prototype.write = function(text) {
2695
+ // Throw an exception if we are already writing a file
2696
+ if (this.readyState === FileWriter.WRITING) {
2697
+ throw new FileError(FileError.INVALID_STATE_ERR);
2698
+ }
2699
+
2700
+ // WRITING state
2701
+ this.readyState = FileWriter.WRITING;
2702
+
2703
+ var me = this;
2704
+
2705
+ // If onwritestart callback
2706
+ if (typeof me.onwritestart === "function") {
2707
+ me.onwritestart(new ProgressEvent("writestart", {"target":me}));
2708
+ }
2709
+
2710
+ // Write file
2711
+ exec(
2712
+ // Success callback
2713
+ function(r) {
2714
+ // If DONE (cancelled), then don't do anything
2715
+ if (me.readyState === FileWriter.DONE) {
2716
+ return;
2717
+ }
2718
+
2719
+ // position always increases by bytes written because file would be extended
2720
+ me.position += r;
2721
+ // The length of the file is now where we are done writing.
2722
+
2723
+ me.length = me.position;
2724
+
2725
+ // DONE state
2726
+ me.readyState = FileWriter.DONE;
2727
+
2728
+ // If onwrite callback
2729
+ if (typeof me.onwrite === "function") {
2730
+ me.onwrite(new ProgressEvent("write", {"target":me}));
2731
+ }
2732
+
2733
+ // If onwriteend callback
2734
+ if (typeof me.onwriteend === "function") {
2735
+ me.onwriteend(new ProgressEvent("writeend", {"target":me}));
2736
+ }
2737
+ },
2738
+ // Error callback
2739
+ function(e) {
2740
+ // If DONE (cancelled), then don't do anything
2741
+ if (me.readyState === FileWriter.DONE) {
2742
+ return;
2743
+ }
2744
+
2745
+ // DONE state
2746
+ me.readyState = FileWriter.DONE;
2747
+
2748
+ // Save error
2749
+ me.error = new FileError(e);
2750
+
2751
+ // If onerror callback
2752
+ if (typeof me.onerror === "function") {
2753
+ me.onerror(new ProgressEvent("error", {"target":me}));
2754
+ }
2755
+
2756
+ // If onwriteend callback
2757
+ if (typeof me.onwriteend === "function") {
2758
+ me.onwriteend(new ProgressEvent("writeend", {"target":me}));
2759
+ }
2760
+ }, "File", "write", [this.fileName, text, this.position]);
2761
+ };
2762
+
2763
+ /**
2764
+ * Moves the file pointer to the location specified.
2765
+ *
2766
+ * If the offset is a negative number the position of the file
2767
+ * pointer is rewound. If the offset is greater than the file
2768
+ * size the position is set to the end of the file.
2769
+ *
2770
+ * @param offset is the location to move the file pointer to.
2771
+ */
2772
+ FileWriter.prototype.seek = function(offset) {
2773
+ // Throw an exception if we are already writing a file
2774
+ if (this.readyState === FileWriter.WRITING) {
2775
+ throw new FileError(FileError.INVALID_STATE_ERR);
2776
+ }
2777
+
2778
+ if (!offset) {
2779
+ return;
2780
+ }
2781
+
2782
+ // See back from end of file.
2783
+ if (offset < 0) {
2784
+ this.position = Math.max(offset + this.length, 0);
2785
+ }
2786
+ // Offset is bigger then file size so set position
2787
+ // to the end of the file.
2788
+ else if (offset > this.length) {
2789
+ this.position = this.length;
2790
+ }
2791
+ // Offset is between 0 and file size so set the position
2792
+ // to start writing.
2793
+ else {
2794
+ this.position = offset;
2795
+ }
2796
+ };
2797
+
2798
+ /**
2799
+ * Truncates the file to the size specified.
2800
+ *
2801
+ * @param size to chop the file at.
2802
+ */
2803
+ FileWriter.prototype.truncate = function(size) {
2804
+ // Throw an exception if we are already writing a file
2805
+ if (this.readyState === FileWriter.WRITING) {
2806
+ throw new FileError(FileError.INVALID_STATE_ERR);
2807
+ }
2808
+
2809
+ // WRITING state
2810
+ this.readyState = FileWriter.WRITING;
2811
+
2812
+ var me = this;
2813
+
2814
+ // If onwritestart callback
2815
+ if (typeof me.onwritestart === "function") {
2816
+ me.onwritestart(new ProgressEvent("writestart", {"target":this}));
2817
+ }
2818
+
2819
+ // Write file
2820
+ exec(
2821
+ // Success callback
2822
+ function(r) {
2823
+ // If DONE (cancelled), then don't do anything
2824
+ if (me.readyState === FileWriter.DONE) {
2825
+ return;
2826
+ }
2827
+
2828
+ // DONE state
2829
+ me.readyState = FileWriter.DONE;
2830
+
2831
+ // Update the length of the file
2832
+ me.length = r;
2833
+ me.position = Math.min(me.position, r);
2834
+
2835
+ // If onwrite callback
2836
+ if (typeof me.onwrite === "function") {
2837
+ me.onwrite(new ProgressEvent("write", {"target":me}));
2838
+ }
2839
+
2840
+ // If onwriteend callback
2841
+ if (typeof me.onwriteend === "function") {
2842
+ me.onwriteend(new ProgressEvent("writeend", {"target":me}));
2843
+ }
2844
+ },
2845
+ // Error callback
2846
+ function(e) {
2847
+ // If DONE (cancelled), then don't do anything
2848
+ if (me.readyState === FileWriter.DONE) {
2849
+ return;
2850
+ }
2851
+
2852
+ // DONE state
2853
+ me.readyState = FileWriter.DONE;
2854
+
2855
+ // Save error
2856
+ me.error = new FileError(e);
2857
+
2858
+ // If onerror callback
2859
+ if (typeof me.onerror === "function") {
2860
+ me.onerror(new ProgressEvent("error", {"target":me}));
2861
+ }
2862
+
2863
+ // If onwriteend callback
2864
+ if (typeof me.onwriteend === "function") {
2865
+ me.onwriteend(new ProgressEvent("writeend", {"target":me}));
2866
+ }
2867
+ }, "File", "truncate", [this.fileName, size]);
2868
+ };
2869
+
2870
+ module.exports = FileWriter;
2871
+
2872
+ });
2873
+
2874
+ // file: lib/common/plugin/Flags.js
2875
+ define("cordova/plugin/Flags", function(require, exports, module) {
2876
+ /**
2877
+ * Supplies arguments to methods that lookup or create files and directories.
2878
+ *
2879
+ * @param create
2880
+ * {boolean} file or directory if it doesn't exist
2881
+ * @param exclusive
2882
+ * {boolean} used with create; if true the command will fail if
2883
+ * target path exists
2884
+ */
2885
+ function Flags(create, exclusive) {
2886
+ this.create = create || false;
2887
+ this.exclusive = exclusive || false;
2888
+ }
2889
+
2890
+ module.exports = Flags;
2891
+
2892
+ });
2893
+
2894
+ // file: lib/common/plugin/LocalFileSystem.js
2895
+ define("cordova/plugin/LocalFileSystem", function(require, exports, module) {
2896
+ var exec = require('cordova/exec');
2897
+
2898
+ /**
2899
+ * Represents a local file system.
2900
+ */
2901
+ var LocalFileSystem = function() {
2902
+
2903
+ };
2904
+
2905
+ LocalFileSystem.TEMPORARY = 0; //temporary, with no guarantee of persistence
2906
+ LocalFileSystem.PERSISTENT = 1; //persistent
2907
+
2908
+ module.exports = LocalFileSystem;
2909
+
2910
+ });
2911
+
2912
+ // file: lib/common/plugin/Media.js
2913
+ define("cordova/plugin/Media", function(require, exports, module) {
2914
+ var utils = require('cordova/utils'),
2915
+ exec = require('cordova/exec');
2916
+
2917
+ var mediaObjects = {};
2918
+
2919
+ /**
2920
+ * This class provides access to the device media, interfaces to both sound and video
2921
+ *
2922
+ * @constructor
2923
+ * @param src The file name or url to play
2924
+ * @param successCallback The callback to be called when the file is done playing or recording.
2925
+ * successCallback()
2926
+ * @param errorCallback The callback to be called if there is an error.
2927
+ * errorCallback(int errorCode) - OPTIONAL
2928
+ * @param statusCallback The callback to be called when media status has changed.
2929
+ * statusCallback(int statusCode) - OPTIONAL
2930
+ */
2931
+ var Media = function(src, successCallback, errorCallback, statusCallback) {
2932
+
2933
+ // successCallback optional
2934
+ if (successCallback && (typeof successCallback !== "function")) {
2935
+ console.log("Media Error: successCallback is not a function");
2936
+ return;
2937
+ }
2938
+
2939
+ // errorCallback optional
2940
+ if (errorCallback && (typeof errorCallback !== "function")) {
2941
+ console.log("Media Error: errorCallback is not a function");
2942
+ return;
2943
+ }
2944
+
2945
+ // statusCallback optional
2946
+ if (statusCallback && (typeof statusCallback !== "function")) {
2947
+ console.log("Media Error: statusCallback is not a function");
2948
+ return;
2949
+ }
2950
+
2951
+ this.id = utils.createUUID();
2952
+ mediaObjects[this.id] = this;
2953
+ this.src = src;
2954
+ this.successCallback = successCallback;
2955
+ this.errorCallback = errorCallback;
2956
+ this.statusCallback = statusCallback;
2957
+ this._duration = -1;
2958
+ this._position = -1;
2959
+ exec(null, this.errorCallback, "Media", "create", [this.id, this.src]);
2960
+ };
2961
+
2962
+ // Media messages
2963
+ Media.MEDIA_STATE = 1;
2964
+ Media.MEDIA_DURATION = 2;
2965
+ Media.MEDIA_POSITION = 3;
2966
+ Media.MEDIA_ERROR = 9;
2967
+
2968
+ // Media states
2969
+ Media.MEDIA_NONE = 0;
2970
+ Media.MEDIA_STARTING = 1;
2971
+ Media.MEDIA_RUNNING = 2;
2972
+ Media.MEDIA_PAUSED = 3;
2973
+ Media.MEDIA_STOPPED = 4;
2974
+ Media.MEDIA_MSG = ["None", "Starting", "Running", "Paused", "Stopped"];
2975
+
2976
+ // "static" function to return existing objs.
2977
+ Media.get = function(id) {
2978
+ return mediaObjects[id];
2979
+ };
2980
+
2981
+ /**
2982
+ * Start or resume playing audio file.
2983
+ */
2984
+ Media.prototype.play = function(options) {
2985
+ exec(null, null, "Media", "startPlayingAudio", [this.id, this.src, options]);
2986
+ };
2987
+
2988
+ /**
2989
+ * Stop playing audio file.
2990
+ */
2991
+ Media.prototype.stop = function() {
2992
+ var me = this;
2993
+ exec(function() {
2994
+ me._position = 0;
2995
+ me.successCallback();
2996
+ }, this.errorCallback, "Media", "stopPlayingAudio", [this.id]);
2997
+ };
2998
+
2999
+ /**
3000
+ * Seek or jump to a new time in the track..
3001
+ */
3002
+ Media.prototype.seekTo = function(milliseconds) {
3003
+ var me = this;
3004
+ exec(function(p) {
3005
+ me._position = p;
3006
+ }, this.errorCallback, "Media", "seekToAudio", [this.id, milliseconds]);
3007
+ };
3008
+
3009
+ /**
3010
+ * Pause playing audio file.
3011
+ */
3012
+ Media.prototype.pause = function() {
3013
+ exec(null, this.errorCallback, "Media", "pausePlayingAudio", [this.id]);
3014
+ };
3015
+
3016
+ /**
3017
+ * Get duration of an audio file.
3018
+ * The duration is only set for audio that is playing, paused or stopped.
3019
+ *
3020
+ * @return duration or -1 if not known.
3021
+ */
3022
+ Media.prototype.getDuration = function() {
3023
+ return this._duration;
3024
+ };
3025
+
3026
+ /**
3027
+ * Get position of audio.
3028
+ */
3029
+ Media.prototype.getCurrentPosition = function(success, fail) {
3030
+ var me = this;
3031
+ exec(function(p) {
3032
+ me._position = p;
3033
+ success(p);
3034
+ }, fail, "Media", "getCurrentPositionAudio", [this.id]);
3035
+ };
3036
+
3037
+ /**
3038
+ * Start recording audio file.
3039
+ */
3040
+ Media.prototype.startRecord = function() {
3041
+ exec(this.successCallback, this.errorCallback, "Media", "startRecordingAudio", [this.id, this.src]);
3042
+ };
3043
+
3044
+ /**
3045
+ * Stop recording audio file.
3046
+ */
3047
+ Media.prototype.stopRecord = function() {
3048
+ exec(this.successCallback, this.errorCallback, "Media", "stopRecordingAudio", [this.id]);
3049
+ };
3050
+
3051
+ /**
3052
+ * Release the resources.
3053
+ */
3054
+ Media.prototype.release = function() {
3055
+ exec(null, this.errorCallback, "Media", "release", [this.id]);
3056
+ };
3057
+
3058
+ /**
3059
+ * Adjust the volume.
3060
+ */
3061
+ Media.prototype.setVolume = function(volume) {
3062
+ exec(null, null, "Media", "setVolume", [this.id, volume]);
3063
+ };
3064
+
3065
+ /**
3066
+ * Audio has status update.
3067
+ * PRIVATE
3068
+ *
3069
+ * @param id The media object id (string)
3070
+ * @param status The status code (int)
3071
+ * @param msg The status message (string)
3072
+ */
3073
+ Media.onStatus = function(id, msg, value) {
3074
+ var media = mediaObjects[id];
3075
+ // If state update
3076
+ if (msg === Media.MEDIA_STATE) {
3077
+ if (value === Media.MEDIA_STOPPED) {
3078
+ if (media.successCallback) {
3079
+ media.successCallback();
3080
+ }
3081
+ }
3082
+ if (media.statusCallback) {
3083
+ media.statusCallback(value);
3084
+ }
3085
+ }
3086
+ else if (msg === Media.MEDIA_DURATION) {
3087
+ media._duration = value;
3088
+ }
3089
+ else if (msg === Media.MEDIA_ERROR) {
3090
+ if (media.errorCallback) {
3091
+ // value should be a MediaError object when msg == MEDIA_ERROR
3092
+ media.errorCallback(value);
3093
+ }
3094
+ }
3095
+ else if (msg === Media.MEDIA_POSITION) {
3096
+ media._position = value;
3097
+ }
3098
+ };
3099
+
3100
+ module.exports = Media;
3101
+
3102
+ });
3103
+
3104
+ // file: lib/common/plugin/MediaError.js
3105
+ define("cordova/plugin/MediaError", function(require, exports, module) {
3106
+ /**
3107
+ * This class contains information about any Media errors.
3108
+ * @constructor
3109
+ */
3110
+ var MediaError = function(code, msg) {
3111
+ this.code = (code !== undefined ? code : null);
3112
+ this.message = msg || "";
3113
+ };
3114
+
3115
+ MediaError.MEDIA_ERR_NONE_ACTIVE = 0;
3116
+ MediaError.MEDIA_ERR_ABORTED = 1;
3117
+ MediaError.MEDIA_ERR_NETWORK = 2;
3118
+ MediaError.MEDIA_ERR_DECODE = 3;
3119
+ MediaError.MEDIA_ERR_NONE_SUPPORTED = 4;
3120
+
3121
+ module.exports = MediaError;
3122
+
3123
+ });
3124
+
3125
+ // file: lib/common/plugin/MediaFile.js
3126
+ define("cordova/plugin/MediaFile", function(require, exports, module) {
3127
+ var utils = require('cordova/utils'),
3128
+ exec = require('cordova/exec'),
3129
+ File = require('cordova/plugin/File'),
3130
+ CaptureError = require('cordova/plugin/CaptureError');
3131
+ /**
3132
+ * Represents a single file.
3133
+ *
3134
+ * name {DOMString} name of the file, without path information
3135
+ * fullPath {DOMString} the full path of the file, including the name
3136
+ * type {DOMString} mime type
3137
+ * lastModifiedDate {Date} last modified date
3138
+ * size {Number} size of the file in bytes
3139
+ */
3140
+ var MediaFile = function(name, fullPath, type, lastModifiedDate, size){
3141
+ MediaFile.__super__.constructor.apply(this, arguments);
3142
+ };
3143
+
3144
+ utils.extend(MediaFile, File);
3145
+
3146
+ /**
3147
+ * Request capture format data for a specific file and type
3148
+ *
3149
+ * @param {Function} successCB
3150
+ * @param {Function} errorCB
3151
+ */
3152
+ MediaFile.prototype.getFormatData = function(successCallback, errorCallback) {
3153
+ if (typeof this.fullPath === "undefined" || this.fullPath === null) {
3154
+ errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
3155
+ } else {
3156
+ exec(successCallback, errorCallback, "Capture", "getFormatData", [this.fullPath, this.type]);
3157
+ }
3158
+ };
3159
+
3160
+ /**
3161
+ * Casts a PluginResult message property (array of objects) to an array of MediaFile objects
3162
+ * (used in Objective-C and Android)
3163
+ *
3164
+ * @param {PluginResult} pluginResult
3165
+ */
3166
+ MediaFile.cast = function(pluginResult) {
3167
+ var mediaFiles = [];
3168
+ var i;
3169
+ for (i=0; i<pluginResult.message.length; i++) {
3170
+ var mediaFile = new MediaFile();
3171
+ mediaFile.name = pluginResult.message[i].name;
3172
+ mediaFile.fullPath = pluginResult.message[i].fullPath;
3173
+ mediaFile.type = pluginResult.message[i].type;
3174
+ mediaFile.lastModifiedDate = pluginResult.message[i].lastModifiedDate;
3175
+ mediaFile.size = pluginResult.message[i].size;
3176
+ mediaFiles.push(mediaFile);
3177
+ }
3178
+ pluginResult.message = mediaFiles;
3179
+ return pluginResult;
3180
+ };
3181
+
3182
+ module.exports = MediaFile;
3183
+
3184
+ });
3185
+
3186
+ // file: lib/common/plugin/MediaFileData.js
3187
+ define("cordova/plugin/MediaFileData", function(require, exports, module) {
3188
+ /**
3189
+ * MediaFileData encapsulates format information of a media file.
3190
+ *
3191
+ * @param {DOMString} codecs
3192
+ * @param {long} bitrate
3193
+ * @param {long} height
3194
+ * @param {long} width
3195
+ * @param {float} duration
3196
+ */
3197
+ var MediaFileData = function(codecs, bitrate, height, width, duration){
3198
+ this.codecs = codecs || null;
3199
+ this.bitrate = bitrate || 0;
3200
+ this.height = height || 0;
3201
+ this.width = width || 0;
3202
+ this.duration = duration || 0;
3203
+ };
3204
+
3205
+ module.exports = MediaFileData;
3206
+
3207
+ });
3208
+
3209
+ // file: lib/common/plugin/Metadata.js
3210
+ define("cordova/plugin/Metadata", function(require, exports, module) {
3211
+ /**
3212
+ * Information about the state of the file or directory
3213
+ *
3214
+ * {Date} modificationTime (readonly)
3215
+ */
3216
+ var Metadata = function(time) {
3217
+ this.modificationTime = (typeof time != 'undefined'?new Date(time):null);
3218
+ };
3219
+
3220
+ module.exports = Metadata;
3221
+
3222
+ });
3223
+
3224
+ // file: lib/common/plugin/Position.js
3225
+ define("cordova/plugin/Position", function(require, exports, module) {
3226
+ var Coordinates = require('cordova/plugin/Coordinates');
3227
+
3228
+ var Position = function(coords, timestamp) {
3229
+ this.coords = new Coordinates(coords.latitude, coords.longitude, coords.altitude, coords.accuracy, coords.heading, coords.velocity, coords.altitudeAccuracy);
3230
+ this.timestamp = (timestamp !== undefined) ? timestamp : new Date().getTime();
3231
+ };
3232
+
3233
+ module.exports = Position;
3234
+
3235
+ });
3236
+
3237
+ // file: lib/common/plugin/PositionError.js
3238
+ define("cordova/plugin/PositionError", function(require, exports, module) {
3239
+ /**
3240
+ * Position error object
3241
+ *
3242
+ * @constructor
3243
+ * @param code
3244
+ * @param message
3245
+ */
3246
+ var PositionError = function(code, message) {
3247
+ this.code = code || null;
3248
+ this.message = message || '';
3249
+ };
3250
+
3251
+ PositionError.PERMISSION_DENIED = 1;
3252
+ PositionError.POSITION_UNAVAILABLE = 2;
3253
+ PositionError.TIMEOUT = 3;
3254
+
3255
+ module.exports = PositionError;
3256
+
3257
+ });
3258
+
3259
+ // file: lib/common/plugin/ProgressEvent.js
3260
+ define("cordova/plugin/ProgressEvent", function(require, exports, module) {
3261
+ // If ProgressEvent exists in global context, use it already, otherwise use our own polyfill
3262
+ // Feature test: See if we can instantiate a native ProgressEvent;
3263
+ // if so, use that approach,
3264
+ // otherwise fill-in with our own implementation.
3265
+ //
3266
+ // NOTE: right now we always fill in with our own. Down the road would be nice if we can use whatever is native in the webview.
3267
+ var ProgressEvent = (function() {
3268
+ /*
3269
+ var createEvent = function(data) {
3270
+ var event = document.createEvent('Events');
3271
+ event.initEvent('ProgressEvent', false, false);
3272
+ if (data) {
3273
+ for (var i in data) {
3274
+ if (data.hasOwnProperty(i)) {
3275
+ event[i] = data[i];
3276
+ }
3277
+ }
3278
+ if (data.target) {
3279
+ // TODO: cannot call <some_custom_object>.dispatchEvent
3280
+ // need to first figure out how to implement EventTarget
3281
+ }
3282
+ }
3283
+ return event;
3284
+ };
3285
+ try {
3286
+ var ev = createEvent({type:"abort",target:document});
3287
+ return function ProgressEvent(type, data) {
3288
+ data.type = type;
3289
+ return createEvent(data);
3290
+ };
3291
+ } catch(e){
3292
+ */
3293
+ return function ProgressEvent(type, dict) {
3294
+ this.type = type;
3295
+ this.bubbles = false;
3296
+ this.cancelBubble = false;
3297
+ this.cancelable = false;
3298
+ this.lengthComputable = false;
3299
+ this.loaded = dict && dict.loaded ? dict.loaded : 0;
3300
+ this.total = dict && dict.total ? dict.total : 0;
3301
+ this.target = dict && dict.target ? dict.target : null;
3302
+ };
3303
+ //}
3304
+ })();
3305
+
3306
+ module.exports = ProgressEvent;
3307
+
3308
+ });
3309
+
3310
+ // file: lib/common/plugin/accelerometer.js
3311
+ define("cordova/plugin/accelerometer", function(require, exports, module) {
3312
+ /**
3313
+ * This class provides access to device accelerometer data.
3314
+ * @constructor
3315
+ */
3316
+ var utils = require("cordova/utils"),
3317
+ exec = require("cordova/exec");
3318
+
3319
+ // Local singleton variables.
3320
+ var timers = {};
3321
+
3322
+ var accelerometer = {
3323
+ /**
3324
+ * Asynchronously aquires the current acceleration.
3325
+ *
3326
+ * @param {Function} successCallback The function to call when the acceleration data is available
3327
+ * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
3328
+ * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
3329
+ */
3330
+ getCurrentAcceleration: function(successCallback, errorCallback, options) {
3331
+
3332
+ // successCallback required
3333
+ if (typeof successCallback !== "function") {
3334
+ console.log("Accelerometer Error: successCallback is not a function");
3335
+ return;
3336
+ }
3337
+
3338
+ // errorCallback optional
3339
+ if (errorCallback && (typeof errorCallback !== "function")) {
3340
+ console.log("Accelerometer Error: errorCallback is not a function");
3341
+ return;
3342
+ }
3343
+
3344
+ // Get acceleration
3345
+ exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
3346
+ },
3347
+
3348
+ /**
3349
+ * Asynchronously aquires the acceleration repeatedly at a given interval.
3350
+ *
3351
+ * @param {Function} successCallback The function to call each time the acceleration data is available
3352
+ * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
3353
+ * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
3354
+ * @return String The watch id that must be passed to #clearWatch to stop watching.
3355
+ */
3356
+ watchAcceleration: function(successCallback, errorCallback, options) {
3357
+
3358
+ // Default interval (10 sec)
3359
+ var frequency = (options !== undefined && options.frequency !== undefined)? options.frequency : 10000;
3360
+
3361
+ // successCallback required
3362
+ if (typeof successCallback !== "function") {
3363
+ console.log("Accelerometer Error: successCallback is not a function");
3364
+ return;
3365
+ }
3366
+
3367
+ // errorCallback optional
3368
+ if (errorCallback && (typeof errorCallback !== "function")) {
3369
+ console.log("Accelerometer Error: errorCallback is not a function");
3370
+ return;
3371
+ }
3372
+
3373
+ // Make sure accelerometer timeout > frequency + 10 sec
3374
+ exec(
3375
+ function(timeout) {
3376
+ if (timeout < (frequency + 10000)) {
3377
+ exec(null, null, "Accelerometer", "setTimeout", [frequency + 10000]);
3378
+ }
3379
+ },
3380
+ function(e) { }, "Accelerometer", "getTimeout", []);
3381
+
3382
+ // Start watch timer
3383
+ var id = utils.createUUID();
3384
+ timers[id] = window.setInterval(function() {
3385
+ exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
3386
+ }, (frequency ? frequency : 1));
3387
+
3388
+ return id;
3389
+ },
3390
+
3391
+ /**
3392
+ * Clears the specified accelerometer watch.
3393
+ *
3394
+ * @param {String} id The id of the watch returned from #watchAcceleration.
3395
+ */
3396
+ clearWatch: function(id) {
3397
+
3398
+ // Stop javascript timer & remove from timer list
3399
+ if (id && timers[id] !== undefined) {
3400
+ window.clearInterval(timers[id]);
3401
+ delete timers[id];
3402
+ }
3403
+ }
3404
+ };
3405
+
3406
+ module.exports = accelerometer;
3407
+
3408
+ });
3409
+
3410
+ // file: lib/android/plugin/android/app.js
3411
+ define("cordova/plugin/android/app", function(require, exports, module) {
3412
+ var exec = require('cordova/exec');
3413
+
3414
+ module.exports = {
3415
+ /**
3416
+ * Clear the resource cache.
3417
+ */
3418
+ clearCache:function() {
3419
+ exec(null, null, "App", "clearCache", []);
3420
+ },
3421
+
3422
+ /**
3423
+ * Load the url into the webview or into new browser instance.
3424
+ *
3425
+ * @param url The URL to load
3426
+ * @param props Properties that can be passed in to the activity:
3427
+ * wait: int => wait msec before loading URL
3428
+ * loadingDialog: "Title,Message" => display a native loading dialog
3429
+ * loadUrlTimeoutValue: int => time in msec to wait before triggering a timeout error
3430
+ * clearHistory: boolean => clear webview history (default=false)
3431
+ * openExternal: boolean => open in a new browser (default=false)
3432
+ *
3433
+ * Example:
3434
+ * navigator.app.loadUrl("http://server/myapp/index.html", {wait:2000, loadingDialog:"Wait,Loading App", loadUrlTimeoutValue: 60000});
3435
+ */
3436
+ loadUrl:function(url, props) {
3437
+ exec(null, null, "App", "loadUrl", [url, props]);
3438
+ },
3439
+
3440
+ /**
3441
+ * Cancel loadUrl that is waiting to be loaded.
3442
+ */
3443
+ cancelLoadUrl:function() {
3444
+ exec(null, null, "App", "cancelLoadUrl", []);
3445
+ },
3446
+
3447
+ /**
3448
+ * Clear web history in this web view.
3449
+ * Instead of BACK button loading the previous web page, it will exit the app.
3450
+ */
3451
+ clearHistory:function() {
3452
+ exec(null, null, "App", "clearHistory", []);
3453
+ },
3454
+
3455
+ /**
3456
+ * Go to previous page displayed.
3457
+ * This is the same as pressing the backbutton on Android device.
3458
+ */
3459
+ backHistory:function() {
3460
+ exec(null, null, "App", "backHistory", []);
3461
+ },
3462
+
3463
+ /**
3464
+ * Override the default behavior of the Android back button.
3465
+ * If overridden, when the back button is pressed, the "backKeyDown" JavaScript event will be fired.
3466
+ *
3467
+ * Note: The user should not have to call this method. Instead, when the user
3468
+ * registers for the "backbutton" event, this is automatically done.
3469
+ *
3470
+ * @param override T=override, F=cancel override
3471
+ */
3472
+ overrideBackbutton:function(override) {
3473
+ exec(null, null, "App", "overrideBackbutton", [override]);
3474
+ },
3475
+
3476
+ /**
3477
+ * Exit and terminate the application.
3478
+ */
3479
+ exitApp:function() {
3480
+ return exec(null, null, "App", "exitApp", []);
3481
+ }
3482
+ };
3483
+
3484
+ });
3485
+
3486
+ // file: lib/android/plugin/android/callback.js
3487
+ define("cordova/plugin/android/callback", function(require, exports, module) {
3488
+ var port = null,
3489
+ token = null,
3490
+ cordova = require('cordova'),
3491
+ polling = require('cordova/plugin/android/polling'),
3492
+ callback = function() {
3493
+ // Exit if shutting down app
3494
+ if (cordova.shuttingDown) {
3495
+ return;
3496
+ }
3497
+
3498
+ // If polling flag was changed, start using polling from now on
3499
+ if (cordova.UsePolling) {
3500
+ polling();
3501
+ return;
3502
+ }
3503
+
3504
+ var xmlhttp = new XMLHttpRequest();
3505
+
3506
+ // Callback function when XMLHttpRequest is ready
3507
+ xmlhttp.onreadystatechange=function(){
3508
+ if(xmlhttp.readyState === 4){
3509
+
3510
+ // Exit if shutting down app
3511
+ if (cordova.shuttingDown) {
3512
+ return;
3513
+ }
3514
+
3515
+ // If callback has JavaScript statement to execute
3516
+ if (xmlhttp.status === 200) {
3517
+
3518
+ // Need to url decode the response
3519
+ var msg = decodeURIComponent(xmlhttp.responseText);
3520
+ setTimeout(function() {
3521
+ try {
3522
+ var t = eval(msg);
3523
+ }
3524
+ catch (e) {
3525
+ // If we're getting an error here, seeing the message will help in debugging
3526
+ console.log("JSCallback: Message from Server: " + msg);
3527
+ console.log("JSCallback Error: "+e);
3528
+ }
3529
+ }, 1);
3530
+ setTimeout(callback, 1);
3531
+ }
3532
+
3533
+ // If callback ping (used to keep XHR request from timing out)
3534
+ else if (xmlhttp.status === 404) {
3535
+ setTimeout(callback, 10);
3536
+ }
3537
+
3538
+ // If security error
3539
+ else if (xmlhttp.status === 403) {
3540
+ console.log("JSCallback Error: Invalid token. Stopping callbacks.");
3541
+ }
3542
+
3543
+ // If server is stopping
3544
+ else if (xmlhttp.status === 503) {
3545
+ console.log("JSCallback Server Closed: Stopping callbacks.");
3546
+ }
3547
+
3548
+ // If request wasn't GET
3549
+ else if (xmlhttp.status === 400) {
3550
+ console.log("JSCallback Error: Bad request. Stopping callbacks.");
3551
+ }
3552
+
3553
+ // If error, revert to polling
3554
+ else {
3555
+ console.log("JSCallback Error: Request failed.");
3556
+ cordova.UsePolling = true;
3557
+ polling();
3558
+ }
3559
+ }
3560
+ };
3561
+
3562
+ if (port === null) {
3563
+ port = prompt("getPort", "gap_callbackServer:");
3564
+ }
3565
+ if (token === null) {
3566
+ token = prompt("getToken", "gap_callbackServer:");
3567
+ }
3568
+ xmlhttp.open("GET", "http://127.0.0.1:"+port+"/"+token , true);
3569
+ xmlhttp.send();
3570
+ };
3571
+
3572
+ module.exports = callback;
3573
+
3574
+ });
3575
+
3576
+ // file: lib/android/plugin/android/device.js
3577
+ define("cordova/plugin/android/device", function(require, exports, module) {
3578
+ var channel = require('cordova/channel'),
3579
+ utils = require('cordova/utils'),
3580
+ exec = require('cordova/exec');
3581
+
3582
+ /**
3583
+ * This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
3584
+ * phone, etc.
3585
+ * @constructor
3586
+ */
3587
+ function Device() {
3588
+ this.available = false;
3589
+ this.platform = null;
3590
+ this.version = null;
3591
+ this.name = null;
3592
+ this.uuid = null;
3593
+ this.cordova = null;
3594
+
3595
+ var me = this;
3596
+
3597
+ channel.onCordovaReady.subscribeOnce(function() {
3598
+ me.getInfo(function(info) {
3599
+ me.available = true;
3600
+ me.platform = info.platform;
3601
+ me.version = info.version;
3602
+ me.name = info.name;
3603
+ me.uuid = info.uuid;
3604
+ me.cordova = info.cordova;
3605
+ channel.onCordovaInfoReady.fire();
3606
+ },function(e) {
3607
+ me.available = false;
3608
+ utils.alert("[ERROR] Error initializing Cordova: " + e);
3609
+ });
3610
+ });
3611
+ }
3612
+
3613
+ /**
3614
+ * Get device info
3615
+ *
3616
+ * @param {Function} successCallback The function to call when the heading data is available
3617
+ * @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
3618
+ */
3619
+ Device.prototype.getInfo = function(successCallback, errorCallback) {
3620
+
3621
+ // successCallback required
3622
+ if (typeof successCallback !== "function") {
3623
+ console.log("Device Error: successCallback is not a function");
3624
+ return;
3625
+ }
3626
+
3627
+ // errorCallback optional
3628
+ if (errorCallback && (typeof errorCallback !== "function")) {
3629
+ console.log("Device Error: errorCallback is not a function");
3630
+ return;
3631
+ }
3632
+
3633
+ // Get info
3634
+ exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
3635
+ };
3636
+
3637
+ /*
3638
+ * DEPRECATED
3639
+ * This is only for Android.
3640
+ *
3641
+ * You must explicitly override the back button.
3642
+ */
3643
+ Device.prototype.overrideBackButton = function() {
3644
+ console.log("Device.overrideBackButton() is deprecated. Use App.overrideBackbutton(true).");
3645
+ navigator.app.overrideBackbutton(true);
3646
+ };
3647
+
3648
+ /*
3649
+ * DEPRECATED
3650
+ * This is only for Android.
3651
+ *
3652
+ * This resets the back button to the default behaviour
3653
+ */
3654
+ Device.prototype.resetBackButton = function() {
3655
+ console.log("Device.resetBackButton() is deprecated. Use App.overrideBackbutton(false).");
3656
+ navigator.app.overrideBackbutton(false);
3657
+ };
3658
+
3659
+ /*
3660
+ * DEPRECATED
3661
+ * This is only for Android.
3662
+ *
3663
+ * This terminates the activity!
3664
+ */
3665
+ Device.prototype.exitApp = function() {
3666
+ console.log("Device.exitApp() is deprecated. Use App.exitApp().");
3667
+ navigator.app.exitApp();
3668
+ };
3669
+
3670
+ module.exports = new Device();
3671
+
3672
+ });
3673
+
3674
+ // file: lib/android/plugin/android/notification.js
3675
+ define("cordova/plugin/android/notification", function(require, exports, module) {
3676
+ var exec = require('cordova/exec');
3677
+
3678
+ /**
3679
+ * Provides Android enhanced notification API.
3680
+ */
3681
+ module.exports = {
3682
+ activityStart : function(title, message) {
3683
+ // If title and message not specified then mimic Android behavior of
3684
+ // using default strings.
3685
+ if (typeof title === "undefined" && typeof message == "undefined") {
3686
+ title = "Busy";
3687
+ message = 'Please wait...';
3688
+ }
3689
+
3690
+ exec(null, null, 'Notification', 'activityStart', [ title, message ]);
3691
+ },
3692
+
3693
+ /**
3694
+ * Close an activity dialog
3695
+ */
3696
+ activityStop : function() {
3697
+ exec(null, null, 'Notification', 'activityStop', []);
3698
+ },
3699
+
3700
+ /**
3701
+ * Display a progress dialog with progress bar that goes from 0 to 100.
3702
+ *
3703
+ * @param {String}
3704
+ * title Title of the progress dialog.
3705
+ * @param {String}
3706
+ * message Message to display in the dialog.
3707
+ */
3708
+ progressStart : function(title, message) {
3709
+ exec(null, null, 'Notification', 'progressStart', [ title, message ]);
3710
+ },
3711
+
3712
+ /**
3713
+ * Close the progress dialog.
3714
+ */
3715
+ progressStop : function() {
3716
+ exec(null, null, 'Notification', 'progressStop', []);
3717
+ },
3718
+
3719
+ /**
3720
+ * Set the progress dialog value.
3721
+ *
3722
+ * @param {Number}
3723
+ * value 0-100
3724
+ */
3725
+ progressValue : function(value) {
3726
+ exec(null, null, 'Notification', 'progressValue', [ value ]);
3727
+ },
3728
+ };
3729
+ });
3730
+
3731
+ // file: lib/android/plugin/android/polling.js
3732
+ define("cordova/plugin/android/polling", function(require, exports, module) {
3733
+ var cordova = require('cordova'),
3734
+ period = 50,
3735
+ polling = function() {
3736
+ // Exit if shutting down app
3737
+ if (cordova.shuttingDown) {
3738
+ return;
3739
+ }
3740
+
3741
+ // If polling flag was changed, stop using polling from now on and switch to XHR server / callback
3742
+ if (!cordova.UsePolling) {
3743
+ require('cordova/plugin/android/callback')();
3744
+ return;
3745
+ }
3746
+
3747
+ var msg = prompt("", "gap_poll:");
3748
+ if (msg) {
3749
+ setTimeout(function() {
3750
+ try {
3751
+ var t = eval(""+msg);
3752
+ }
3753
+ catch (e) {
3754
+ console.log("JSCallbackPolling: Message from Server: " + msg);
3755
+ console.log("JSCallbackPolling Error: "+e);
3756
+ }
3757
+ }, 1);
3758
+ setTimeout(polling, 1);
3759
+ }
3760
+ else {
3761
+ setTimeout(polling, period);
3762
+ }
3763
+ };
3764
+
3765
+ module.exports = polling;
3766
+
3767
+ });
3768
+
3769
+ // file: lib/android/plugin/android/storage.js
3770
+ define("cordova/plugin/android/storage", function(require, exports, module) {
3771
+ var utils = require('cordova/utils'),
3772
+ exec = require('cordova/exec');
3773
+ channel = require('cordova/channel');
3774
+
3775
+ var queryQueue = {};
3776
+
3777
+ /**
3778
+ * SQL result set object
3779
+ * PRIVATE METHOD
3780
+ * @constructor
3781
+ */
3782
+ var DroidDB_Rows = function() {
3783
+ this.resultSet = []; // results array
3784
+ this.length = 0; // number of rows
3785
+ };
3786
+
3787
+ /**
3788
+ * Get item from SQL result set
3789
+ *
3790
+ * @param row The row number to return
3791
+ * @return The row object
3792
+ */
3793
+ DroidDB_Rows.prototype.item = function(row) {
3794
+ return this.resultSet[row];
3795
+ };
3796
+
3797
+ /**
3798
+ * SQL result set that is returned to user.
3799
+ * PRIVATE METHOD
3800
+ * @constructor
3801
+ */
3802
+ var DroidDB_Result = function() {
3803
+ this.rows = new DroidDB_Rows();
3804
+ };
3805
+
3806
+ /**
3807
+ * Callback from native code when query is complete.
3808
+ * PRIVATE METHOD
3809
+ *
3810
+ * @param id Query id
3811
+ */
3812
+ function completeQuery(id, data) {
3813
+ var query = queryQueue[id];
3814
+ if (query) {
3815
+ try {
3816
+ delete queryQueue[id];
3817
+
3818
+ // Get transaction
3819
+ var tx = query.tx;
3820
+
3821
+ // If transaction hasn't failed
3822
+ // Note: We ignore all query results if previous query
3823
+ // in the same transaction failed.
3824
+ if (tx && tx.queryList[id]) {
3825
+
3826
+ // Save query results
3827
+ var r = new DroidDB_Result();
3828
+ r.rows.resultSet = data;
3829
+ r.rows.length = data.length;
3830
+ try {
3831
+ if (typeof query.successCallback === 'function') {
3832
+ query.successCallback(query.tx, r);
3833
+ }
3834
+ } catch (ex) {
3835
+ console.log("executeSql error calling user success callback: "+ex);
3836
+ }
3837
+
3838
+ tx.queryComplete(id);
3839
+ }
3840
+ } catch (e) {
3841
+ console.log("executeSql error: "+e);
3842
+ }
3843
+ }
3844
+ }
3845
+
3846
+ /**
3847
+ * Callback from native code when query fails
3848
+ * PRIVATE METHOD
3849
+ *
3850
+ * @param reason Error message
3851
+ * @param id Query id
3852
+ */
3853
+ function failQuery(reason, id) {
3854
+ var query = queryQueue[id];
3855
+ if (query) {
3856
+ try {
3857
+ delete queryQueue[id];
3858
+
3859
+ // Get transaction
3860
+ var tx = query.tx;
3861
+
3862
+ // If transaction hasn't failed
3863
+ // Note: We ignore all query results if previous query
3864
+ // in the same transaction failed.
3865
+ if (tx && tx.queryList[id]) {
3866
+ tx.queryList = {};
3867
+
3868
+ try {
3869
+ if (typeof query.errorCallback === 'function') {
3870
+ query.errorCallback(query.tx, reason);
3871
+ }
3872
+ } catch (ex) {
3873
+ console.log("executeSql error calling user error callback: "+ex);
3874
+ }
3875
+
3876
+ tx.queryFailed(id, reason);
3877
+ }
3878
+
3879
+ } catch (e) {
3880
+ console.log("executeSql error: "+e);
3881
+ }
3882
+ }
3883
+ }
3884
+
3885
+ /**
3886
+ * SQL query object
3887
+ * PRIVATE METHOD
3888
+ *
3889
+ * @constructor
3890
+ * @param tx The transaction object that this query belongs to
3891
+ */
3892
+ var DroidDB_Query = function(tx) {
3893
+
3894
+ // Set the id of the query
3895
+ this.id = utils.createUUID();
3896
+
3897
+ // Add this query to the queue
3898
+ queryQueue[this.id] = this;
3899
+
3900
+ // Init result
3901
+ this.resultSet = [];
3902
+
3903
+ // Set transaction that this query belongs to
3904
+ this.tx = tx;
3905
+
3906
+ // Add this query to transaction list
3907
+ this.tx.queryList[this.id] = this;
3908
+
3909
+ // Callbacks
3910
+ this.successCallback = null;
3911
+ this.errorCallback = null;
3912
+
3913
+ };
3914
+
3915
+ /**
3916
+ * Transaction object
3917
+ * PRIVATE METHOD
3918
+ * @constructor
3919
+ */
3920
+ var DroidDB_Tx = function() {
3921
+
3922
+ // Set the id of the transaction
3923
+ this.id = utils.createUUID();
3924
+
3925
+ // Callbacks
3926
+ this.successCallback = null;
3927
+ this.errorCallback = null;
3928
+
3929
+ // Query list
3930
+ this.queryList = {};
3931
+ };
3932
+
3933
+ /**
3934
+ * Mark query in transaction as complete.
3935
+ * If all queries are complete, call the user's transaction success callback.
3936
+ *
3937
+ * @param id Query id
3938
+ */
3939
+ DroidDB_Tx.prototype.queryComplete = function(id) {
3940
+ delete this.queryList[id];
3941
+
3942
+ // If no more outstanding queries, then fire transaction success
3943
+ if (this.successCallback) {
3944
+ var count = 0;
3945
+ var i;
3946
+ for (i in this.queryList) {
3947
+ if (this.queryList.hasOwnProperty(i)) {
3948
+ count++;
3949
+ }
3950
+ }
3951
+ if (count === 0) {
3952
+ try {
3953
+ this.successCallback();
3954
+ } catch(e) {
3955
+ console.log("Transaction error calling user success callback: " + e);
3956
+ }
3957
+ }
3958
+ }
3959
+ };
3960
+
3961
+ /**
3962
+ * Mark query in transaction as failed.
3963
+ *
3964
+ * @param id Query id
3965
+ * @param reason Error message
3966
+ */
3967
+ DroidDB_Tx.prototype.queryFailed = function(id, reason) {
3968
+
3969
+ // The sql queries in this transaction have already been run, since
3970
+ // we really don't have a real transaction implemented in native code.
3971
+ // However, the user callbacks for the remaining sql queries in transaction
3972
+ // will not be called.
3973
+ this.queryList = {};
3974
+
3975
+ if (this.errorCallback) {
3976
+ try {
3977
+ this.errorCallback(reason);
3978
+ } catch(e) {
3979
+ console.log("Transaction error calling user error callback: " + e);
3980
+ }
3981
+ }
3982
+ };
3983
+
3984
+ /**
3985
+ * Execute SQL statement
3986
+ *
3987
+ * @param sql SQL statement to execute
3988
+ * @param params Statement parameters
3989
+ * @param successCallback Success callback
3990
+ * @param errorCallback Error callback
3991
+ */
3992
+ DroidDB_Tx.prototype.executeSql = function(sql, params, successCallback, errorCallback) {
3993
+
3994
+ // Init params array
3995
+ if (typeof params === 'undefined') {
3996
+ params = [];
3997
+ }
3998
+
3999
+ // Create query and add to queue
4000
+ var query = new DroidDB_Query(this);
4001
+ queryQueue[query.id] = query;
4002
+
4003
+ // Save callbacks
4004
+ query.successCallback = successCallback;
4005
+ query.errorCallback = errorCallback;
4006
+
4007
+ // Call native code
4008
+ exec(null, null, "Storage", "executeSql", [sql, params, query.id]);
4009
+ };
4010
+
4011
+ var DatabaseShell = function() {
4012
+ };
4013
+
4014
+ /**
4015
+ * Start a transaction.
4016
+ * Does not support rollback in event of failure.
4017
+ *
4018
+ * @param process {Function} The transaction function
4019
+ * @param successCallback {Function}
4020
+ * @param errorCallback {Function}
4021
+ */
4022
+ DatabaseShell.prototype.transaction = function(process, errorCallback, successCallback) {
4023
+ var tx = new DroidDB_Tx();
4024
+ tx.successCallback = successCallback;
4025
+ tx.errorCallback = errorCallback;
4026
+ try {
4027
+ process(tx);
4028
+ } catch (e) {
4029
+ console.log("Transaction error: "+e);
4030
+ if (tx.errorCallback) {
4031
+ try {
4032
+ tx.errorCallback(e);
4033
+ } catch (ex) {
4034
+ console.log("Transaction error calling user error callback: "+e);
4035
+ }
4036
+ }
4037
+ }
4038
+ };
4039
+
4040
+ /**
4041
+ * Open database
4042
+ *
4043
+ * @param name Database name
4044
+ * @param version Database version
4045
+ * @param display_name Database display name
4046
+ * @param size Database size in bytes
4047
+ * @return Database object
4048
+ */
4049
+ var DroidDB_openDatabase = function(name, version, display_name, size) {
4050
+ exec(null, null, "Storage", "openDatabase", [name, version, display_name, size]);
4051
+ var db = new DatabaseShell();
4052
+ return db;
4053
+ };
4054
+
4055
+ /**
4056
+ * For browsers with no localStorage we emulate it with SQLite. Follows the w3c api.
4057
+ * TODO: Do similar for sessionStorage.
4058
+ * @constructor
4059
+ */
4060
+ var CupcakeLocalStorage = function() {
4061
+ channel.waitForInitialization("cupcakeStorage");
4062
+
4063
+ try {
4064
+
4065
+ this.db = openDatabase('localStorage', '1.0', 'localStorage', 2621440);
4066
+ var storage = {};
4067
+ this.length = 0;
4068
+ function setLength (length) {
4069
+ this.length = length;
4070
+ localStorage.length = length;
4071
+ }
4072
+ this.db.transaction(
4073
+ function (transaction) {
4074
+ var i;
4075
+ transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
4076
+ transaction.executeSql('SELECT * FROM storage', [], function(tx, result) {
4077
+ for(var i = 0; i < result.rows.length; i++) {
4078
+ storage[result.rows.item(i)['id']] = result.rows.item(i)['body'];
4079
+ }
4080
+ setLength(result.rows.length);
4081
+ channel.initializationComplete("cupcakeStorage");
4082
+ });
4083
+
4084
+ },
4085
+ function (err) {
4086
+ utils.alert(err.message);
4087
+ }
4088
+ );
4089
+ this.setItem = function(key, val) {
4090
+ if (typeof(storage[key])=='undefined') {
4091
+ this.length++;
4092
+ }
4093
+ storage[key] = val;
4094
+ this.db.transaction(
4095
+ function (transaction) {
4096
+ transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
4097
+ transaction.executeSql('REPLACE INTO storage (id, body) values(?,?)', [key,val]);
4098
+ }
4099
+ );
4100
+ };
4101
+ this.getItem = function(key) {
4102
+ return storage[key];
4103
+ };
4104
+ this.removeItem = function(key) {
4105
+ delete storage[key];
4106
+ this.length--;
4107
+ this.db.transaction(
4108
+ function (transaction) {
4109
+ transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
4110
+ transaction.executeSql('DELETE FROM storage where id=?', [key]);
4111
+ }
4112
+ );
4113
+ };
4114
+ this.clear = function() {
4115
+ storage = {};
4116
+ this.length = 0;
4117
+ this.db.transaction(
4118
+ function (transaction) {
4119
+ transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
4120
+ transaction.executeSql('DELETE FROM storage', []);
4121
+ }
4122
+ );
4123
+ };
4124
+ this.key = function(index) {
4125
+ var i = 0;
4126
+ for (var j in storage) {
4127
+ if (i==index) {
4128
+ return j;
4129
+ } else {
4130
+ i++;
4131
+ }
4132
+ }
4133
+ return null;
4134
+ };
4135
+
4136
+ } catch(e) {
4137
+ utils.alert("Database error "+e+".");
4138
+ return;
4139
+ }
4140
+ };
4141
+
4142
+ module.exports = {
4143
+ openDatabase:DroidDB_openDatabase,
4144
+ CupcakeLocalStorage:CupcakeLocalStorage,
4145
+ failQuery:failQuery,
4146
+ completeQuery:completeQuery
4147
+ };
4148
+
4149
+ });
4150
+
4151
+ // file: lib/common/plugin/battery.js
4152
+ define("cordova/plugin/battery", function(require, exports, module) {
4153
+ /**
4154
+ * This class contains information about the current battery status.
4155
+ * @constructor
4156
+ */
4157
+ var cordova = require('cordova'),
4158
+ exec = require('cordova/exec');
4159
+
4160
+ function handlers() {
4161
+ return battery.channels.batterystatus.numHandlers +
4162
+ battery.channels.batterylow.numHandlers +
4163
+ battery.channels.batterycritical.numHandlers;
4164
+ }
4165
+
4166
+ var Battery = function() {
4167
+ this._level = null;
4168
+ this._isPlugged = null;
4169
+ // Create new event handlers on the window (returns a channel instance)
4170
+ var subscriptionEvents = {
4171
+ onSubscribe:this.onSubscribe,
4172
+ onUnsubscribe:this.onUnsubscribe
4173
+ };
4174
+ this.channels = {
4175
+ batterystatus:cordova.addWindowEventHandler("batterystatus", subscriptionEvents),
4176
+ batterylow:cordova.addWindowEventHandler("batterylow", subscriptionEvents),
4177
+ batterycritical:cordova.addWindowEventHandler("batterycritical", subscriptionEvents)
4178
+ };
4179
+ };
4180
+ /**
4181
+ * Event handlers for when callbacks get registered for the battery.
4182
+ * Keep track of how many handlers we have so we can start and stop the native battery listener
4183
+ * appropriately (and hopefully save on battery life!).
4184
+ */
4185
+ Battery.prototype.onSubscribe = function() {
4186
+ var me = battery;
4187
+ // If we just registered the first handler, make sure native listener is started.
4188
+ if (handlers() === 1) {
4189
+ exec(me._status, me._error, "Battery", "start", []);
4190
+ }
4191
+ };
4192
+
4193
+ Battery.prototype.onUnsubscribe = function() {
4194
+ var me = battery;
4195
+
4196
+ // If we just unregistered the last handler, make sure native listener is stopped.
4197
+ if (handlers() === 0) {
4198
+ exec(null, null, "Battery", "stop", []);
4199
+ }
4200
+ };
4201
+
4202
+ /**
4203
+ * Callback for battery status
4204
+ *
4205
+ * @param {Object} info keys: level, isPlugged
4206
+ */
4207
+ Battery.prototype._status = function(info) {
4208
+ if (info) {
4209
+ var me = battery;
4210
+ var level = info.level;
4211
+ if (me._level !== level || me._isPlugged !== info.isPlugged) {
4212
+ // Fire batterystatus event
4213
+ cordova.fireWindowEvent("batterystatus", info);
4214
+
4215
+ // Fire low battery event
4216
+ if (level === 20 || level === 5) {
4217
+ if (level === 20) {
4218
+ cordova.fireWindowEvent("batterylow", info);
4219
+ }
4220
+ else {
4221
+ cordova.fireWindowEvent("batterycritical", info);
4222
+ }
4223
+ }
4224
+ }
4225
+ me._level = level;
4226
+ me._isPlugged = info.isPlugged;
4227
+ }
4228
+ };
4229
+
4230
+ /**
4231
+ * Error callback for battery start
4232
+ */
4233
+ Battery.prototype._error = function(e) {
4234
+ console.log("Error initializing Battery: " + e);
4235
+ };
4236
+
4237
+ var battery = new Battery();
4238
+
4239
+ module.exports = battery;
4240
+
4241
+ });
4242
+
4243
+ // file: lib/common/plugin/capture.js
4244
+ define("cordova/plugin/capture", function(require, exports, module) {
4245
+ var exec = require('cordova/exec'),
4246
+ MediaFile = require('cordova/plugin/MediaFile');
4247
+
4248
+ /**
4249
+ * Launches a capture of different types.
4250
+ *
4251
+ * @param (DOMString} type
4252
+ * @param {Function} successCB
4253
+ * @param {Function} errorCB
4254
+ * @param {CaptureVideoOptions} options
4255
+ */
4256
+ function _capture(type, successCallback, errorCallback, options) {
4257
+ var win = function(pluginResult) {
4258
+ var mediaFiles = [];
4259
+ var i;
4260
+ for (i = 0; i < pluginResult.length; i++) {
4261
+ var mediaFile = new MediaFile();
4262
+ mediaFile.name = pluginResult[i].name;
4263
+ mediaFile.fullPath = pluginResult[i].fullPath;
4264
+ mediaFile.type = pluginResult[i].type;
4265
+ mediaFile.lastModifiedDate = pluginResult[i].lastModifiedDate;
4266
+ mediaFile.size = pluginResult[i].size;
4267
+ mediaFiles.push(mediaFile);
4268
+ }
4269
+ successCallback(mediaFiles);
4270
+ };
4271
+ exec(win, errorCallback, "Capture", type, [options]);
4272
+ }
4273
+ /**
4274
+ * The Capture interface exposes an interface to the camera and microphone of the hosting device.
4275
+ */
4276
+ function Capture() {
4277
+ this.supportedAudioModes = [];
4278
+ this.supportedImageModes = [];
4279
+ this.supportedVideoModes = [];
4280
+ }
4281
+
4282
+ /**
4283
+ * Launch audio recorder application for recording audio clip(s).
4284
+ *
4285
+ * @param {Function} successCB
4286
+ * @param {Function} errorCB
4287
+ * @param {CaptureAudioOptions} options
4288
+ */
4289
+ Capture.prototype.captureAudio = function(successCallback, errorCallback, options){
4290
+ _capture("captureAudio", successCallback, errorCallback, options);
4291
+ };
4292
+
4293
+ /**
4294
+ * Launch camera application for taking image(s).
4295
+ *
4296
+ * @param {Function} successCB
4297
+ * @param {Function} errorCB
4298
+ * @param {CaptureImageOptions} options
4299
+ */
4300
+ Capture.prototype.captureImage = function(successCallback, errorCallback, options){
4301
+ _capture("captureImage", successCallback, errorCallback, options);
4302
+ };
4303
+
4304
+ /**
4305
+ * Launch device camera application for recording video(s).
4306
+ *
4307
+ * @param {Function} successCB
4308
+ * @param {Function} errorCB
4309
+ * @param {CaptureVideoOptions} options
4310
+ */
4311
+ Capture.prototype.captureVideo = function(successCallback, errorCallback, options){
4312
+ _capture("captureVideo", successCallback, errorCallback, options);
4313
+ };
4314
+
4315
+
4316
+ module.exports = new Capture();
4317
+
4318
+ });
4319
+
4320
+ // file: lib/common/plugin/compass.js
4321
+ define("cordova/plugin/compass", function(require, exports, module) {
4322
+ var exec = require('cordova/exec'),
4323
+ utils = require('cordova/utils'),
4324
+ CompassHeading = require('cordova/plugin/CompassHeading'),
4325
+ CompassError = require('cordova/plugin/CompassError'),
4326
+ timers = {},
4327
+ compass = {
4328
+ /**
4329
+ * Asynchronously acquires the current heading.
4330
+ * @param {Function} successCallback The function to call when the heading
4331
+ * data is available
4332
+ * @param {Function} errorCallback The function to call when there is an error
4333
+ * getting the heading data.
4334
+ * @param {CompassOptions} options The options for getting the heading data (not used).
4335
+ */
4336
+ getCurrentHeading:function(successCallback, errorCallback, options) {
4337
+ // successCallback required
4338
+ if (typeof successCallback !== "function") {
4339
+ console.log("Compass Error: successCallback is not a function");
4340
+ return;
4341
+ }
4342
+
4343
+ // errorCallback optional
4344
+ if (errorCallback && (typeof errorCallback !== "function")) {
4345
+ console.log("Compass Error: errorCallback is not a function");
4346
+ return;
4347
+ }
4348
+
4349
+ var win = function(result) {
4350
+ var ch = new CompassHeading(result.magneticHeading, result.trueHeading, result.headingAccuracy, result.timestamp);
4351
+ successCallback(ch);
4352
+ };
4353
+ var fail = function(code) {
4354
+ var ce = new CompassError(code);
4355
+ errorCallback(ce);
4356
+ }
4357
+
4358
+ // Get heading
4359
+ exec(win, fail, "Compass", "getHeading", [options]);
4360
+ },
4361
+
4362
+ /**
4363
+ * Asynchronously acquires the heading repeatedly at a given interval.
4364
+ * @param {Function} successCallback The function to call each time the heading
4365
+ * data is available
4366
+ * @param {Function} errorCallback The function to call when there is an error
4367
+ * getting the heading data.
4368
+ * @param {HeadingOptions} options The options for getting the heading data
4369
+ * such as timeout and the frequency of the watch. For iOS, filter parameter
4370
+ * specifies to watch via a distance filter rather than time.
4371
+ */
4372
+ watchHeading:function(successCallback, errorCallback, options) {
4373
+ // Default interval (100 msec)
4374
+ var frequency = (options !== undefined && options.frequency !== undefined) ? options.frequency : 100;
4375
+ var filter = (options !== undefined && options.filter !== undefined) ? options.filter : 0;
4376
+
4377
+ // successCallback required
4378
+ if (typeof successCallback !== "function") {
4379
+ console.log("Compass Error: successCallback is not a function");
4380
+ return;
4381
+ }
4382
+
4383
+ // errorCallback optional
4384
+ if (errorCallback && (typeof errorCallback !== "function")) {
4385
+ console.log("Compass Error: errorCallback is not a function");
4386
+ return;
4387
+ }
4388
+
4389
+ var id = utils.createUUID();
4390
+ if (filter > 0) {
4391
+ // is an iOS request for watch by filter, no timer needed
4392
+ timers[id] = "iOS";
4393
+ compass.getCurrentHeading(successCallback, errorCallback, options);
4394
+ } else {
4395
+ // Start watch timer to get headings
4396
+ timers[id] = window.setInterval(function() {
4397
+ compass.getCurrentHeading(successCallback, errorCallback);
4398
+ }, frequency);
4399
+ }
4400
+
4401
+ return id;
4402
+ },
4403
+
4404
+ /**
4405
+ * Clears the specified heading watch.
4406
+ * @param {String} watchId The ID of the watch returned from #watchHeading.
4407
+ */
4408
+ clearWatch:function(id) {
4409
+ // Stop javascript timer & remove from timer list
4410
+ if (id && timers[id]) {
4411
+ if (timers[id] != "iOS") {
4412
+ clearInterval(timers[id]);
4413
+ } else {
4414
+ // is iOS watch by filter so call into device to stop
4415
+ exec(null, null, "Compass", "stopHeading", []);
4416
+ }
4417
+ delete timers[id];
4418
+ }
4419
+ }
4420
+ };
4421
+
4422
+ module.exports = compass;
4423
+
4424
+ });
4425
+
4426
+ // file: lib/common/plugin/contacts.js
4427
+ define("cordova/plugin/contacts", function(require, exports, module) {
4428
+ var exec = require('cordova/exec'),
4429
+ ContactError = require('cordova/plugin/ContactError'),
4430
+ Contact = require('cordova/plugin/Contact');
4431
+
4432
+ /**
4433
+ * Represents a group of Contacts.
4434
+ * @constructor
4435
+ */
4436
+ var contacts = {
4437
+ /**
4438
+ * Returns an array of Contacts matching the search criteria.
4439
+ * @param fields that should be searched
4440
+ * @param successCB success callback
4441
+ * @param errorCB error callback
4442
+ * @param {ContactFindOptions} options that can be applied to contact searching
4443
+ * @return array of Contacts matching search criteria
4444
+ */
4445
+ find:function(fields, successCB, errorCB, options) {
4446
+ if (!successCB) {
4447
+ throw new TypeError("You must specify a success callback for the find command.");
4448
+ }
4449
+ if (!fields || (fields instanceof Array && fields.length === 0)) {
4450
+ if (typeof errorCB === "function") {
4451
+ errorCB(new ContactError(ContactError.INVALID_ARGUMENT_ERROR));
4452
+ }
4453
+ } else {
4454
+ var win = function(result) {
4455
+ var cs = [];
4456
+ for (var i = 0, l = result.length; i < l; i++) {
4457
+ cs.push(contacts.create(result[i]));
4458
+ }
4459
+ successCB(cs);
4460
+ };
4461
+ exec(win, errorCB, "Contacts", "search", [fields, options]);
4462
+ }
4463
+ },
4464
+
4465
+ /**
4466
+ * This function creates a new contact, but it does not persist the contact
4467
+ * to device storage. To persist the contact to device storage, invoke
4468
+ * contact.save().
4469
+ * @param properties an object who's properties will be examined to create a new Contact
4470
+ * @returns new Contact object
4471
+ */
4472
+ create:function(properties) {
4473
+ var i;
4474
+ var contact = new Contact();
4475
+ for (i in properties) {
4476
+ if (typeof contact[i] !== 'undefined' && properties.hasOwnProperty(i)) {
4477
+ contact[i] = properties[i];
4478
+ }
4479
+ }
4480
+ return contact;
4481
+ }
4482
+ };
4483
+
4484
+ module.exports = contacts;
4485
+
4486
+ });
4487
+
4488
+ // file: lib/common/plugin/geolocation.js
4489
+ define("cordova/plugin/geolocation", function(require, exports, module) {
4490
+ var utils = require('cordova/utils'),
4491
+ exec = require('cordova/exec'),
4492
+ PositionError = require('cordova/plugin/PositionError'),
4493
+ Position = require('cordova/plugin/Position');
4494
+
4495
+ var timers = {}; // list of timers in use
4496
+
4497
+ // Returns default params, overrides if provided with values
4498
+ function parseParameters(options) {
4499
+ var opt = {
4500
+ maximumAge: 10000,
4501
+ enableHighAccuracy: false,
4502
+ timeout: 10000
4503
+ };
4504
+
4505
+ if (options) {
4506
+ if (options.maximumAge !== undefined) {
4507
+ opt.maximumAge = options.maximumAge;
4508
+ }
4509
+ if (options.enableHighAccuracy !== undefined) {
4510
+ opt.enableHighAccuracy = options.enableHighAccuracy;
4511
+ }
4512
+ if (options.timeout !== undefined) {
4513
+ opt.timeout = options.timeout;
4514
+ }
4515
+ }
4516
+
4517
+ return opt;
4518
+ }
4519
+
4520
+ var geolocation = {
4521
+ /**
4522
+ * Asynchronously aquires the current position.
4523
+ *
4524
+ * @param {Function} successCallback The function to call when the position data is available
4525
+ * @param {Function} errorCallback The function to call when there is an error getting the heading position. (OPTIONAL)
4526
+ * @param {PositionOptions} options The options for getting the position data. (OPTIONAL)
4527
+ */
4528
+ getCurrentPosition:function(successCallback, errorCallback, options) {
4529
+ options = parseParameters(options);
4530
+
4531
+ var win = function(p) {
4532
+ successCallback(new Position(
4533
+ {
4534
+ latitude:p.latitude,
4535
+ longitude:p.longitude,
4536
+ altitude:p.altitude,
4537
+ accuracy:p.accuracy,
4538
+ heading:p.heading,
4539
+ velocity:p.velocity,
4540
+ altitudeAccuracy:p.altitudeAccuracy
4541
+ },
4542
+ p.timestamp || new Date()
4543
+ ));
4544
+ };
4545
+ var fail = function(e) {
4546
+ errorCallback(new PositionError(e.code, e.message));
4547
+ };
4548
+
4549
+ exec(win, fail, "Geolocation", "getLocation", [options.enableHighAccuracy, options.timeout, options.maximumAge]);
4550
+ },
4551
+ /**
4552
+ * Asynchronously watches the geolocation for changes to geolocation. When a change occurs,
4553
+ * the successCallback is called with the new location.
4554
+ *
4555
+ * @param {Function} successCallback The function to call each time the location data is available
4556
+ * @param {Function} errorCallback The function to call when there is an error getting the location data. (OPTIONAL)
4557
+ * @param {PositionOptions} options The options for getting the location data such as frequency. (OPTIONAL)
4558
+ * @return String The watch id that must be passed to #clearWatch to stop watching.
4559
+ */
4560
+ watchPosition:function(successCallback, errorCallback, options) {
4561
+ options = parseParameters(options);
4562
+
4563
+ var id = utils.createUUID();
4564
+ timers[id] = window.setInterval(function() {
4565
+ geolocation.getCurrentPosition(successCallback, errorCallback, options);
4566
+ }, options.timeout);
4567
+
4568
+ return id;
4569
+ },
4570
+ /**
4571
+ * Clears the specified heading watch.
4572
+ *
4573
+ * @param {String} id The ID of the watch returned from #watchPosition
4574
+ */
4575
+ clearWatch:function(id) {
4576
+ if (id && timers[id] !== undefined) {
4577
+ window.clearInterval(timers[id]);
4578
+ delete timers[id];
4579
+ }
4580
+ }
4581
+ };
4582
+
4583
+ module.exports = geolocation;
4584
+
4585
+ });
4586
+
4587
+ // file: lib/common/plugin/network.js
4588
+ define("cordova/plugin/network", function(require, exports, module) {
4589
+ var exec = require('cordova/exec'),
4590
+ cordova = require('cordova'),
4591
+ channel = require('cordova/channel');
4592
+
4593
+ var NetworkConnection = function () {
4594
+ this.type = null;
4595
+ this._firstRun = true;
4596
+ this._timer = null;
4597
+ this.timeout = 500;
4598
+
4599
+ var me = this;
4600
+
4601
+ channel.onCordovaReady.subscribeOnce(function() {
4602
+ me.getInfo(function (info) {
4603
+ me.type = info;
4604
+ if (info === "none") {
4605
+ // set a timer if still offline at the end of timer send the offline event
4606
+ me._timer = setTimeout(function(){
4607
+ cordova.fireDocumentEvent("offline");
4608
+ me._timer = null;
4609
+ }, me.timeout);
4610
+ } else {
4611
+ // If there is a current offline event pending clear it
4612
+ if (me._timer !== null) {
4613
+ clearTimeout(me._timer);
4614
+ me._timer = null;
4615
+ }
4616
+ cordova.fireDocumentEvent("online");
4617
+ }
4618
+
4619
+ // should only fire this once
4620
+ if (me._firstRun) {
4621
+ me._firstRun = false;
4622
+ channel.onCordovaConnectionReady.fire();
4623
+ }
4624
+ },
4625
+ function (e) {
4626
+ // If we can't get the network info we should still tell Cordova
4627
+ // to fire the deviceready event.
4628
+ if (me._firstRun) {
4629
+ me._firstRun = false;
4630
+ channel.onCordovaConnectionReady.fire();
4631
+ }
4632
+ console.log("Error initializing Network Connection: " + e);
4633
+ });
4634
+ });
4635
+ };
4636
+
4637
+ /**
4638
+ * Get connection info
4639
+ *
4640
+ * @param {Function} successCallback The function to call when the Connection data is available
4641
+ * @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL)
4642
+ */
4643
+ NetworkConnection.prototype.getInfo = function (successCallback, errorCallback) {
4644
+ // Get info
4645
+ exec(successCallback, errorCallback, "NetworkStatus", "getConnectionInfo", []);
4646
+ };
4647
+
4648
+ module.exports = new NetworkConnection();
4649
+
4650
+ });
4651
+
4652
+ // file: lib/common/plugin/notification.js
4653
+ define("cordova/plugin/notification", function(require, exports, module) {
4654
+ var exec = require('cordova/exec');
4655
+
4656
+ /**
4657
+ * Provides access to notifications on the device.
4658
+ */
4659
+
4660
+ module.exports = {
4661
+
4662
+ /**
4663
+ * Open a native alert dialog, with a customizable title and button text.
4664
+ *
4665
+ * @param {String} message Message to print in the body of the alert
4666
+ * @param {Function} completeCallback The callback that is called when user clicks on a button.
4667
+ * @param {String} title Title of the alert dialog (default: Alert)
4668
+ * @param {String} buttonLabel Label of the close button (default: OK)
4669
+ */
4670
+ alert: function(message, completeCallback, title, buttonLabel) {
4671
+ var _title = (title || "Alert");
4672
+ var _buttonLabel = (buttonLabel || "OK");
4673
+ exec(completeCallback, null, "Notification", "alert", [message, _title, _buttonLabel]);
4674
+ },
4675
+
4676
+ /**
4677
+ * Open a native confirm dialog, with a customizable title and button text.
4678
+ * The result that the user selects is returned to the result callback.
4679
+ *
4680
+ * @param {String} message Message to print in the body of the alert
4681
+ * @param {Function} resultCallback The callback that is called when user clicks on a button.
4682
+ * @param {String} title Title of the alert dialog (default: Confirm)
4683
+ * @param {String} buttonLabels Comma separated list of the labels of the buttons (default: 'OK,Cancel')
4684
+ */
4685
+ confirm: function(message, resultCallback, title, buttonLabels) {
4686
+ var _title = (title || "Confirm");
4687
+ var _buttonLabels = (buttonLabels || "OK,Cancel");
4688
+ exec(resultCallback, null, "Notification", "confirm", [message, _title, _buttonLabels]);
4689
+ },
4690
+
4691
+ /**
4692
+ * Causes the device to vibrate.
4693
+ *
4694
+ * @param {Integer} mills The number of milliseconds to vibrate for.
4695
+ */
4696
+ vibrate: function(mills) {
4697
+ exec(null, null, "Notification", "vibrate", [mills]);
4698
+ },
4699
+
4700
+ /**
4701
+ * Causes the device to beep.
4702
+ * On Android, the default notification ringtone is played "count" times.
4703
+ *
4704
+ * @param {Integer} count The number of beeps.
4705
+ */
4706
+ beep: function(count) {
4707
+ exec(null, null, "Notification", "beep", [count]);
4708
+ }
4709
+ };
4710
+
4711
+ });
4712
+
4713
+ // file: lib/common/plugin/requestFileSystem.js
4714
+ define("cordova/plugin/requestFileSystem", function(require, exports, module) {
4715
+ var FileError = require('cordova/plugin/FileError'),
4716
+ FileSystem = require('cordova/plugin/FileSystem'),
4717
+ exec = require('cordova/exec');
4718
+
4719
+ /**
4720
+ * Request a file system in which to store application data.
4721
+ * @param type local file system type
4722
+ * @param size indicates how much storage space, in bytes, the application expects to need
4723
+ * @param successCallback invoked with a FileSystem object
4724
+ * @param errorCallback invoked if error occurs retrieving file system
4725
+ */
4726
+ var requestFileSystem = function(type, size, successCallback, errorCallback) {
4727
+ var fail = function(code) {
4728
+ if (typeof errorCallback === 'function') {
4729
+ errorCallback(new FileError(code));
4730
+ }
4731
+ };
4732
+
4733
+ if (type < 0 || type > 3) {
4734
+ fail(FileError.SYNTAX_ERR);
4735
+ } else {
4736
+ // if successful, return a FileSystem object
4737
+ var success = function(file_system) {
4738
+ if (file_system) {
4739
+ if (typeof successCallback === 'function') {
4740
+ // grab the name and root from the file system object
4741
+ var result = new FileSystem(file_system.name, file_system.root);
4742
+ successCallback(result);
4743
+ }
4744
+ }
4745
+ else {
4746
+ // no FileSystem object returned
4747
+ fail(FileError.NOT_FOUND_ERR);
4748
+ }
4749
+ };
4750
+ exec(success, fail, "File", "requestFileSystem", [type, size]);
4751
+ }
4752
+ };
4753
+
4754
+ module.exports = requestFileSystem;
4755
+
4756
+ });
4757
+
4758
+ // file: lib/common/plugin/resolveLocalFileSystemURI.js
4759
+ define("cordova/plugin/resolveLocalFileSystemURI", function(require, exports, module) {
4760
+ var DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
4761
+ FileEntry = require('cordova/plugin/FileEntry'),
4762
+ exec = require('cordova/exec');
4763
+
4764
+ /**
4765
+ * Look up file system Entry referred to by local URI.
4766
+ * @param {DOMString} uri URI referring to a local file or directory
4767
+ * @param successCallback invoked with Entry object corresponding to URI
4768
+ * @param errorCallback invoked if error occurs retrieving file system entry
4769
+ */
4770
+ module.exports = function(uri, successCallback, errorCallback) {
4771
+ // error callback
4772
+ var fail = function(error) {
4773
+ if (typeof errorCallback === 'function') {
4774
+ errorCallback(new FileError(error));
4775
+ }
4776
+ };
4777
+ // if successful, return either a file or directory entry
4778
+ var success = function(entry) {
4779
+ var result;
4780
+
4781
+ if (entry) {
4782
+ if (typeof successCallback === 'function') {
4783
+ // create appropriate Entry object
4784
+ result = (entry.isDirectory) ? new DirectoryEntry(entry.name, entry.fullPath) : new FileEntry(entry.name, entry.fullPath);
4785
+ try {
4786
+ successCallback(result);
4787
+ }
4788
+ catch (e) {
4789
+ console.log('Error invoking callback: ' + e);
4790
+ }
4791
+ }
4792
+ }
4793
+ else {
4794
+ // no Entry object returned
4795
+ fail(FileError.NOT_FOUND_ERR);
4796
+ }
4797
+ };
4798
+
4799
+ exec(success, fail, "File", "resolveLocalFileSystemURI", [uri]);
4800
+ };
4801
+
4802
+ });
4803
+
4804
+ // file: lib/common/utils.js
4805
+ define("cordova/utils", function(require, exports, module) {
4806
+ function UUIDcreatePart(length) {
4807
+ var uuidpart = "";
4808
+ for (var i=0; i<length; i++) {
4809
+ var uuidchar = parseInt((Math.random() * 256), 10).toString(16);
4810
+ if (uuidchar.length == 1) {
4811
+ uuidchar = "0" + uuidchar;
4812
+ }
4813
+ uuidpart += uuidchar;
4814
+ }
4815
+ return uuidpart;
4816
+ }
4817
+
4818
+ var _self = {
4819
+ /**
4820
+ * Does a deep clone of the object.
4821
+ */
4822
+ clone: function(obj) {
4823
+ if(!obj) {
4824
+ return obj;
4825
+ }
4826
+
4827
+ var retVal, i;
4828
+
4829
+ if(obj instanceof Array){
4830
+ retVal = [];
4831
+ for(i = 0; i < obj.length; ++i){
4832
+ retVal.push(_self.clone(obj[i]));
4833
+ }
4834
+ return retVal;
4835
+ }
4836
+
4837
+ if (obj instanceof Function) {
4838
+ return obj;
4839
+ }
4840
+
4841
+ if(!(obj instanceof Object)){
4842
+ return obj;
4843
+ }
4844
+
4845
+ if(obj instanceof Date){
4846
+ return obj;
4847
+ }
4848
+
4849
+ retVal = {};
4850
+ for(i in obj){
4851
+ if(!(i in retVal) || retVal[i] != obj[i]) {
4852
+ retVal[i] = _self.clone(obj[i]);
4853
+ }
4854
+ }
4855
+ return retVal;
4856
+ },
4857
+
4858
+ close: function(context, func, params) {
4859
+ if (typeof params === 'undefined') {
4860
+ return function() {
4861
+ return func.apply(context, arguments);
4862
+ };
4863
+ } else {
4864
+ return function() {
4865
+ return func.apply(context, params);
4866
+ };
4867
+ }
4868
+ },
4869
+
4870
+ /**
4871
+ * Create a UUID
4872
+ */
4873
+ createUUID: function() {
4874
+ return UUIDcreatePart(4) + '-' +
4875
+ UUIDcreatePart(2) + '-' +
4876
+ UUIDcreatePart(2) + '-' +
4877
+ UUIDcreatePart(2) + '-' +
4878
+ UUIDcreatePart(6);
4879
+ },
4880
+
4881
+ /**
4882
+ * Extends a child object from a parent object using classical inheritance
4883
+ * pattern.
4884
+ */
4885
+ extend: (function() {
4886
+ // proxy used to establish prototype chain
4887
+ var F = function() {};
4888
+ // extend Child from Parent
4889
+ return function(Child, Parent) {
4890
+ F.prototype = Parent.prototype;
4891
+ Child.prototype = new F();
4892
+ Child.__super__ = Parent.prototype;
4893
+ Child.prototype.constructor = Child;
4894
+ };
4895
+ }()),
4896
+
4897
+ /**
4898
+ * Alerts a message in any available way: alert or console.log.
4899
+ */
4900
+ alert:function(msg) {
4901
+ if (alert) {
4902
+ alert(msg);
4903
+ } else if (console && console.log) {
4904
+ console.log(msg);
4905
+ }
4906
+ }
4907
+ };
4908
+
4909
+ module.exports = _self;
4910
+
4911
+ });
4912
+
4913
+
4914
+ window.cordova = require('cordova');
4915
+
4916
+ // file: lib/scripts/bootstrap.js
4917
+ (function (context) {
4918
+ var channel = require("cordova/channel"),
4919
+ _self = {
4920
+ boot: function () {
4921
+ //---------------
4922
+ // Event handling
4923
+ //---------------
4924
+
4925
+ /**
4926
+ * Listen for DOMContentLoaded and notify our channel subscribers.
4927
+ */
4928
+ document.addEventListener('DOMContentLoaded', function() {
4929
+ channel.onDOMContentLoaded.fire();
4930
+ }, false);
4931
+ if (document.readyState == 'complete') {
4932
+ channel.onDOMContentLoaded.fire();
4933
+ }
4934
+
4935
+ /**
4936
+ * Create all cordova objects once page has fully loaded and native side is ready.
4937
+ */
4938
+ channel.join(function() {
4939
+ var builder = require('cordova/builder'),
4940
+ base = require('cordova/common'),
4941
+ platform = require('cordova/platform');
4942
+
4943
+ // Drop the common globals into the window object, but be nice and don't overwrite anything.
4944
+ builder.build(base.objects).intoButDontClobber(window);
4945
+
4946
+ // Drop the platform-specific globals into the window object
4947
+ // and clobber any existing object.
4948
+ builder.build(platform.objects).intoAndClobber(window);
4949
+
4950
+ // Merge the platform-specific overrides/enhancements into
4951
+ // the window object.
4952
+ if (typeof platform.merges !== 'undefined') {
4953
+ builder.build(platform.merges).intoAndMerge(window);
4954
+ }
4955
+
4956
+ // Call the platform-specific initialization
4957
+ platform.initialize();
4958
+
4959
+ // Fire event to notify that all objects are created
4960
+ channel.onCordovaReady.fire();
4961
+
4962
+ // Fire onDeviceReady event once all constructors have run and
4963
+ // cordova info has been received from native side.
4964
+ channel.join(function() {
4965
+ channel.onDeviceReady.fire();
4966
+ }, channel.deviceReadyChannelsArray);
4967
+
4968
+ }, [ channel.onDOMContentLoaded, channel.onNativeReady ]);
4969
+ }
4970
+ };
4971
+
4972
+ // boot up once native side is ready
4973
+ channel.onNativeReady.subscribeOnce(_self.boot);
4974
+
4975
+ // _nativeReady is global variable that the native side can set
4976
+ // to signify that the native code is ready. It is a global since
4977
+ // it may be called before any cordova JS is ready.
4978
+ if (window._nativeReady) {
4979
+ channel.onNativeReady.fire();
4980
+ }
4981
+
4982
+ }(window));
4983
+
4984
+
4985
+ })();