UNPKG

78.1 kBJavaScriptView Raw
1// Platform: ios
2// 9e8e1b716252c4a08abcd31a13013b868d6f4141
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;(function() {
22var PLATFORM_VERSION_BUILD_LABEL = '4.5.5';
23// file: src/scripts/require.js
24
25/* jshint -W079 */
26/* jshint -W020 */
27
28var require;
29var define;
30
31(function () {
32 var modules = {};
33 // Stack of moduleIds currently being built.
34 var requireStack = [];
35 // Map of module ID -> index into requireStack of modules currently being built.
36 var inProgressModules = {};
37 var SEPARATOR = '.';
38
39 function build (module) {
40 var factory = module.factory;
41 var localRequire = function (id) {
42 var resultantId = id;
43 // Its a relative path, so lop off the last portion and add the id (minus "./")
44 if (id.charAt(0) === '.') {
45 resultantId = module.id.slice(0, module.id.lastIndexOf(SEPARATOR)) + SEPARATOR + id.slice(2);
46 }
47 return require(resultantId);
48 };
49 module.exports = {};
50 delete module.factory;
51 factory(localRequire, module.exports, module);
52 return module.exports;
53 }
54
55 require = function (id) {
56 if (!modules[id]) {
57 throw 'module ' + id + ' not found';
58 } else if (id in inProgressModules) {
59 var cycle = requireStack.slice(inProgressModules[id]).join('->') + '->' + id;
60 throw 'Cycle in require graph: ' + cycle;
61 }
62 if (modules[id].factory) {
63 try {
64 inProgressModules[id] = requireStack.length;
65 requireStack.push(id);
66 return build(modules[id]);
67 } finally {
68 delete inProgressModules[id];
69 requireStack.pop();
70 }
71 }
72 return modules[id].exports;
73 };
74
75 define = function (id, factory) {
76 if (modules[id]) {
77 throw 'module ' + id + ' already defined';
78 }
79
80 modules[id] = {
81 id: id,
82 factory: factory
83 };
84 };
85
86 define.remove = function (id) {
87 delete modules[id];
88 };
89
90 define.moduleMap = modules;
91})();
92
93// Export for use in node
94if (typeof module === 'object' && typeof require === 'function') {
95 module.exports.require = require;
96 module.exports.define = define;
97}
98
99// file: src/cordova.js
100define("cordova", function(require, exports, module) {
101
102// Workaround for Windows 10 in hosted environment case
103// http://www.w3.org/html/wg/drafts/html/master/browsers.html#named-access-on-the-window-object
104if (window.cordova && !(window.cordova instanceof HTMLElement)) { // eslint-disable-line no-undef
105 throw new Error('cordova already defined');
106}
107
108var channel = require('cordova/channel');
109var platform = require('cordova/platform');
110
111/**
112 * Intercept calls to addEventListener + removeEventListener and handle deviceready,
113 * resume, and pause events.
114 */
115var m_document_addEventListener = document.addEventListener;
116var m_document_removeEventListener = document.removeEventListener;
117var m_window_addEventListener = window.addEventListener;
118var m_window_removeEventListener = window.removeEventListener;
119
120/**
121 * Houses custom event handlers to intercept on document + window event listeners.
122 */
123var documentEventHandlers = {};
124var windowEventHandlers = {};
125
126document.addEventListener = function (evt, handler, capture) {
127 var e = evt.toLowerCase();
128 if (typeof documentEventHandlers[e] !== 'undefined') {
129 documentEventHandlers[e].subscribe(handler);
130 } else {
131 m_document_addEventListener.call(document, evt, handler, capture);
132 }
133};
134
135window.addEventListener = function (evt, handler, capture) {
136 var e = evt.toLowerCase();
137 if (typeof windowEventHandlers[e] !== 'undefined') {
138 windowEventHandlers[e].subscribe(handler);
139 } else {
140 m_window_addEventListener.call(window, evt, handler, capture);
141 }
142};
143
144document.removeEventListener = function (evt, handler, capture) {
145 var e = evt.toLowerCase();
146 // If unsubscribing from an event that is handled by a plugin
147 if (typeof documentEventHandlers[e] !== 'undefined') {
148 documentEventHandlers[e].unsubscribe(handler);
149 } else {
150 m_document_removeEventListener.call(document, evt, handler, capture);
151 }
152};
153
154window.removeEventListener = function (evt, handler, capture) {
155 var e = evt.toLowerCase();
156 // If unsubscribing from an event that is handled by a plugin
157 if (typeof windowEventHandlers[e] !== 'undefined') {
158 windowEventHandlers[e].unsubscribe(handler);
159 } else {
160 m_window_removeEventListener.call(window, evt, handler, capture);
161 }
162};
163
164function createEvent (type, data) {
165 var event = document.createEvent('Events');
166 event.initEvent(type, false, false);
167 if (data) {
168 for (var i in data) {
169 if (data.hasOwnProperty(i)) {
170 event[i] = data[i];
171 }
172 }
173 }
174 return event;
175}
176
177/* eslint-disable no-undef */
178var cordova = {
179 define: define,
180 require: require,
181 version: PLATFORM_VERSION_BUILD_LABEL,
182 platformVersion: PLATFORM_VERSION_BUILD_LABEL,
183 platformId: platform.id,
184
185 /* eslint-enable no-undef */
186
187 /**
188 * Methods to add/remove your own addEventListener hijacking on document + window.
189 */
190 addWindowEventHandler: function (event) {
191 return (windowEventHandlers[event] = channel.create(event));
192 },
193 addStickyDocumentEventHandler: function (event) {
194 return (documentEventHandlers[event] = channel.createSticky(event));
195 },
196 addDocumentEventHandler: function (event) {
197 return (documentEventHandlers[event] = channel.create(event));
198 },
199 removeWindowEventHandler: function (event) {
200 delete windowEventHandlers[event];
201 },
202 removeDocumentEventHandler: function (event) {
203 delete documentEventHandlers[event];
204 },
205 /**
206 * Retrieve original event handlers that were replaced by Cordova
207 *
208 * @return object
209 */
210 getOriginalHandlers: function () {
211 return {'document': {'addEventListener': m_document_addEventListener, 'removeEventListener': m_document_removeEventListener},
212 'window': {'addEventListener': m_window_addEventListener, 'removeEventListener': m_window_removeEventListener}};
213 },
214 /**
215 * Method to fire event from native code
216 * bNoDetach is required for events which cause an exception which needs to be caught in native code
217 */
218 fireDocumentEvent: function (type, data, bNoDetach) {
219 var evt = createEvent(type, data);
220 if (typeof documentEventHandlers[type] !== 'undefined') {
221 if (bNoDetach) {
222 documentEventHandlers[type].fire(evt);
223 } else {
224 setTimeout(function () {
225 // Fire deviceready on listeners that were registered before cordova.js was loaded.
226 if (type === 'deviceready') {
227 document.dispatchEvent(evt);
228 }
229 documentEventHandlers[type].fire(evt);
230 }, 0);
231 }
232 } else {
233 document.dispatchEvent(evt);
234 }
235 },
236 fireWindowEvent: function (type, data) {
237 var evt = createEvent(type, data);
238 if (typeof windowEventHandlers[type] !== 'undefined') {
239 setTimeout(function () {
240 windowEventHandlers[type].fire(evt);
241 }, 0);
242 } else {
243 window.dispatchEvent(evt);
244 }
245 },
246
247 /**
248 * Plugin callback mechanism.
249 */
250 // Randomize the starting callbackId to avoid collisions after refreshing or navigating.
251 // This way, it's very unlikely that any new callback would get the same callbackId as an old callback.
252 callbackId: Math.floor(Math.random() * 2000000000),
253 callbacks: {},
254 callbackStatus: {
255 NO_RESULT: 0,
256 OK: 1,
257 CLASS_NOT_FOUND_EXCEPTION: 2,
258 ILLEGAL_ACCESS_EXCEPTION: 3,
259 INSTANTIATION_EXCEPTION: 4,
260 MALFORMED_URL_EXCEPTION: 5,
261 IO_EXCEPTION: 6,
262 INVALID_ACTION: 7,
263 JSON_EXCEPTION: 8,
264 ERROR: 9
265 },
266
267 /**
268 * Called by native code when returning successful result from an action.
269 */
270 callbackSuccess: function (callbackId, args) {
271 cordova.callbackFromNative(callbackId, true, args.status, [args.message], args.keepCallback);
272 },
273
274 /**
275 * Called by native code when returning error result from an action.
276 */
277 callbackError: function (callbackId, args) {
278 // TODO: Deprecate callbackSuccess and callbackError in favour of callbackFromNative.
279 // Derive success from status.
280 cordova.callbackFromNative(callbackId, false, args.status, [args.message], args.keepCallback);
281 },
282
283 /**
284 * Called by native code when returning the result from an action.
285 */
286 callbackFromNative: function (callbackId, isSuccess, status, args, keepCallback) {
287 try {
288 var callback = cordova.callbacks[callbackId];
289 if (callback) {
290 if (isSuccess && status === cordova.callbackStatus.OK) {
291 callback.success && callback.success.apply(null, args);
292 } else if (!isSuccess) {
293 callback.fail && callback.fail.apply(null, args);
294 }
295 /*
296 else
297 Note, this case is intentionally not caught.
298 this can happen if isSuccess is true, but callbackStatus is NO_RESULT
299 which is used to remove a callback from the list without calling the callbacks
300 typically keepCallback is false in this case
301 */
302 // Clear callback if not expecting any more results
303 if (!keepCallback) {
304 delete cordova.callbacks[callbackId];
305 }
306 }
307 } catch (err) {
308 var msg = 'Error in ' + (isSuccess ? 'Success' : 'Error') + ' callbackId: ' + callbackId + ' : ' + err;
309 console && console.log && console.log(msg);
310 console && console.log && err.stack && console.log(err.stack);
311 cordova.fireWindowEvent('cordovacallbackerror', { 'message': msg });
312 throw err;
313 }
314 },
315 addConstructor: function (func) {
316 channel.onCordovaReady.subscribe(function () {
317 try {
318 func();
319 } catch (e) {
320 console.log('Failed to run constructor: ' + e);
321 }
322 });
323 }
324};
325
326module.exports = cordova;
327
328});
329
330// file: src/common/argscheck.js
331define("cordova/argscheck", function(require, exports, module) {
332
333var utils = require('cordova/utils');
334
335var moduleExports = module.exports;
336
337var typeMap = {
338 'A': 'Array',
339 'D': 'Date',
340 'N': 'Number',
341 'S': 'String',
342 'F': 'Function',
343 'O': 'Object'
344};
345
346function extractParamName (callee, argIndex) {
347 return (/.*?\((.*?)\)/).exec(callee)[1].split(', ')[argIndex];
348}
349
350function checkArgs (spec, functionName, args, opt_callee) {
351 if (!moduleExports.enableChecks) {
352 return;
353 }
354 var errMsg = null;
355 var typeName;
356 for (var i = 0; i < spec.length; ++i) {
357 var c = spec.charAt(i);
358 var cUpper = c.toUpperCase();
359 var arg = args[i];
360 // Asterix means allow anything.
361 if (c === '*') {
362 continue;
363 }
364 typeName = utils.typeName(arg);
365 if ((arg === null || arg === undefined) && c === cUpper) {
366 continue;
367 }
368 if (typeName !== typeMap[cUpper]) {
369 errMsg = 'Expected ' + typeMap[cUpper];
370 break;
371 }
372 }
373 if (errMsg) {
374 errMsg += ', but got ' + typeName + '.';
375 errMsg = 'Wrong type for parameter "' + extractParamName(opt_callee || args.callee, i) + '" of ' + functionName + ': ' + errMsg;
376 // Don't log when running unit tests.
377 if (typeof jasmine === 'undefined') {
378 console.error(errMsg);
379 }
380 throw TypeError(errMsg);
381 }
382}
383
384function getValue (value, defaultValue) {
385 return value === undefined ? defaultValue : value;
386}
387
388moduleExports.checkArgs = checkArgs;
389moduleExports.getValue = getValue;
390moduleExports.enableChecks = true;
391
392});
393
394// file: src/common/base64.js
395define("cordova/base64", function(require, exports, module) {
396
397var base64 = exports;
398
399base64.fromArrayBuffer = function (arrayBuffer) {
400 var array = new Uint8Array(arrayBuffer);
401 return uint8ToBase64(array);
402};
403
404base64.toArrayBuffer = function (str) {
405 var decodedStr = typeof atob !== 'undefined' ? atob(str) : Buffer.from(str, 'base64').toString('binary'); // eslint-disable-line no-undef
406 var arrayBuffer = new ArrayBuffer(decodedStr.length);
407 var array = new Uint8Array(arrayBuffer);
408 for (var i = 0, len = decodedStr.length; i < len; i++) {
409 array[i] = decodedStr.charCodeAt(i);
410 }
411 return arrayBuffer;
412};
413
414// ------------------------------------------------------------------------------
415
416/* This code is based on the performance tests at http://jsperf.com/b64tests
417 * This 12-bit-at-a-time algorithm was the best performing version on all
418 * platforms tested.
419 */
420
421var b64_6bit = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
422var b64_12bit;
423
424var b64_12bitTable = function () {
425 b64_12bit = [];
426 for (var i = 0; i < 64; i++) {
427 for (var j = 0; j < 64; j++) {
428 b64_12bit[i * 64 + j] = b64_6bit[i] + b64_6bit[j];
429 }
430 }
431 b64_12bitTable = function () { return b64_12bit; };
432 return b64_12bit;
433};
434
435function uint8ToBase64 (rawData) {
436 var numBytes = rawData.byteLength;
437 var output = '';
438 var segment;
439 var table = b64_12bitTable();
440 for (var i = 0; i < numBytes - 2; i += 3) {
441 segment = (rawData[i] << 16) + (rawData[i + 1] << 8) + rawData[i + 2];
442 output += table[segment >> 12];
443 output += table[segment & 0xfff];
444 }
445 if (numBytes - i === 2) {
446 segment = (rawData[i] << 16) + (rawData[i + 1] << 8);
447 output += table[segment >> 12];
448 output += b64_6bit[(segment & 0xfff) >> 6];
449 output += '=';
450 } else if (numBytes - i === 1) {
451 segment = (rawData[i] << 16);
452 output += table[segment >> 12];
453 output += '==';
454 }
455 return output;
456}
457
458});
459
460// file: src/common/builder.js
461define("cordova/builder", function(require, exports, module) {
462
463var utils = require('cordova/utils');
464
465function each (objects, func, context) {
466 for (var prop in objects) {
467 if (objects.hasOwnProperty(prop)) {
468 func.apply(context, [objects[prop], prop]);
469 }
470 }
471}
472
473function clobber (obj, key, value) {
474 exports.replaceHookForTesting(obj, key);
475 var needsProperty = false;
476 try {
477 obj[key] = value;
478 } catch (e) {
479 needsProperty = true;
480 }
481 // Getters can only be overridden by getters.
482 if (needsProperty || obj[key] !== value) {
483 utils.defineGetter(obj, key, function () {
484 return value;
485 });
486 }
487}
488
489function assignOrWrapInDeprecateGetter (obj, key, value, message) {
490 if (message) {
491 utils.defineGetter(obj, key, function () {
492 console.log(message);
493 delete obj[key];
494 clobber(obj, key, value);
495 return value;
496 });
497 } else {
498 clobber(obj, key, value);
499 }
500}
501
502function include (parent, objects, clobber, merge) {
503 each(objects, function (obj, key) {
504 try {
505 var result = obj.path ? require(obj.path) : {};
506
507 if (clobber) {
508 // Clobber if it doesn't exist.
509 if (typeof parent[key] === 'undefined') {
510 assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
511 } else if (typeof obj.path !== 'undefined') {
512 // If merging, merge properties onto parent, otherwise, clobber.
513 if (merge) {
514 recursiveMerge(parent[key], result);
515 } else {
516 assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
517 }
518 }
519 result = parent[key];
520 } else {
521 // Overwrite if not currently defined.
522 if (typeof parent[key] === 'undefined') {
523 assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
524 } else {
525 // Set result to what already exists, so we can build children into it if they exist.
526 result = parent[key];
527 }
528 }
529
530 if (obj.children) {
531 include(result, obj.children, clobber, merge);
532 }
533 } catch (e) {
534 utils.alert('Exception building Cordova JS globals: ' + e + ' for key "' + key + '"');
535 }
536 });
537}
538
539/**
540 * Merge properties from one object onto another recursively. Properties from
541 * the src object will overwrite existing target property.
542 *
543 * @param target Object to merge properties into.
544 * @param src Object to merge properties from.
545 */
546function recursiveMerge (target, src) {
547 for (var prop in src) {
548 if (src.hasOwnProperty(prop)) {
549 if (target.prototype && target.prototype.constructor === target) {
550 // If the target object is a constructor override off prototype.
551 clobber(target.prototype, prop, src[prop]);
552 } else {
553 if (typeof src[prop] === 'object' && typeof target[prop] === 'object') {
554 recursiveMerge(target[prop], src[prop]);
555 } else {
556 clobber(target, prop, src[prop]);
557 }
558 }
559 }
560 }
561}
562
563exports.buildIntoButDoNotClobber = function (objects, target) {
564 include(target, objects, false, false);
565};
566exports.buildIntoAndClobber = function (objects, target) {
567 include(target, objects, true, false);
568};
569exports.buildIntoAndMerge = function (objects, target) {
570 include(target, objects, true, true);
571};
572exports.recursiveMerge = recursiveMerge;
573exports.assignOrWrapInDeprecateGetter = assignOrWrapInDeprecateGetter;
574exports.replaceHookForTesting = function () {};
575
576});
577
578// file: src/common/channel.js
579define("cordova/channel", function(require, exports, module) {
580
581var utils = require('cordova/utils');
582var nextGuid = 1;
583
584/**
585 * Custom pub-sub "channel" that can have functions subscribed to it
586 * This object is used to define and control firing of events for
587 * cordova initialization, as well as for custom events thereafter.
588 *
589 * The order of events during page load and Cordova startup is as follows:
590 *
591 * onDOMContentLoaded* Internal event that is received when the web page is loaded and parsed.
592 * onNativeReady* Internal event that indicates the Cordova native side is ready.
593 * onCordovaReady* Internal event fired when all Cordova JavaScript objects have been created.
594 * onDeviceReady* User event fired to indicate that Cordova is ready
595 * onResume User event fired to indicate a start/resume lifecycle event
596 * onPause User event fired to indicate a pause lifecycle event
597 *
598 * The events marked with an * are sticky. Once they have fired, they will stay in the fired state.
599 * All listeners that subscribe after the event is fired will be executed right away.
600 *
601 * The only Cordova events that user code should register for are:
602 * deviceready Cordova native code is initialized and Cordova APIs can be called from JavaScript
603 * pause App has moved to background
604 * resume App has returned to foreground
605 *
606 * Listeners can be registered as:
607 * document.addEventListener("deviceready", myDeviceReadyListener, false);
608 * document.addEventListener("resume", myResumeListener, false);
609 * document.addEventListener("pause", myPauseListener, false);
610 *
611 * The DOM lifecycle events should be used for saving and restoring state
612 * window.onload
613 * window.onunload
614 *
615 */
616
617/**
618 * Channel
619 * @constructor
620 * @param type String the channel name
621 */
622var Channel = function (type, sticky) {
623 this.type = type;
624 // Map of guid -> function.
625 this.handlers = {};
626 // 0 = Non-sticky, 1 = Sticky non-fired, 2 = Sticky fired.
627 this.state = sticky ? 1 : 0;
628 // Used in sticky mode to remember args passed to fire().
629 this.fireArgs = null;
630 // Used by onHasSubscribersChange to know if there are any listeners.
631 this.numHandlers = 0;
632 // Function that is called when the first listener is subscribed, or when
633 // the last listener is unsubscribed.
634 this.onHasSubscribersChange = null;
635};
636var channel = {
637 /**
638 * Calls the provided function only after all of the channels specified
639 * have been fired. All channels must be sticky channels.
640 */
641 join: function (h, c) {
642 var len = c.length;
643 var i = len;
644 var f = function () {
645 if (!(--i)) h();
646 };
647 for (var j = 0; j < len; j++) {
648 if (c[j].state === 0) {
649 throw Error('Can only use join with sticky channels.');
650 }
651 c[j].subscribe(f);
652 }
653 if (!len) h();
654 },
655 /* eslint-disable no-return-assign */
656 create: function (type) {
657 return channel[type] = new Channel(type, false);
658 },
659 createSticky: function (type) {
660 return channel[type] = new Channel(type, true);
661 },
662 /* eslint-enable no-return-assign */
663 /**
664 * cordova Channels that must fire before "deviceready" is fired.
665 */
666 deviceReadyChannelsArray: [],
667 deviceReadyChannelsMap: {},
668
669 /**
670 * Indicate that a feature needs to be initialized before it is ready to be used.
671 * This holds up Cordova's "deviceready" event until the feature has been initialized
672 * and Cordova.initComplete(feature) is called.
673 *
674 * @param feature {String} The unique feature name
675 */
676 waitForInitialization: function (feature) {
677 if (feature) {
678 var c = channel[feature] || this.createSticky(feature);
679 this.deviceReadyChannelsMap[feature] = c;
680 this.deviceReadyChannelsArray.push(c);
681 }
682 },
683
684 /**
685 * Indicate that initialization code has completed and the feature is ready to be used.
686 *
687 * @param feature {String} The unique feature name
688 */
689 initializationComplete: function (feature) {
690 var c = this.deviceReadyChannelsMap[feature];
691 if (c) {
692 c.fire();
693 }
694 }
695};
696
697function checkSubscriptionArgument (argument) {
698 if (typeof argument !== 'function' && typeof argument.handleEvent !== 'function') {
699 throw new Error(
700 'Must provide a function or an EventListener object ' +
701 'implementing the handleEvent interface.'
702 );
703 }
704}
705
706/**
707 * Subscribes the given function to the channel. Any time that
708 * Channel.fire is called so too will the function.
709 * Optionally specify an execution context for the function
710 * and a guid that can be used to stop subscribing to the channel.
711 * Returns the guid.
712 */
713Channel.prototype.subscribe = function (eventListenerOrFunction, eventListener) {
714 checkSubscriptionArgument(eventListenerOrFunction);
715 var handleEvent, guid;
716
717 if (eventListenerOrFunction && typeof eventListenerOrFunction === 'object') {
718 // Received an EventListener object implementing the handleEvent interface
719 handleEvent = eventListenerOrFunction.handleEvent;
720 eventListener = eventListenerOrFunction;
721 } else {
722 // Received a function to handle event
723 handleEvent = eventListenerOrFunction;
724 }
725
726 if (this.state === 2) {
727 handleEvent.apply(eventListener || this, this.fireArgs);
728 return;
729 }
730
731 guid = eventListenerOrFunction.observer_guid;
732 if (typeof eventListener === 'object') {
733 handleEvent = utils.close(eventListener, handleEvent);
734 }
735
736 if (!guid) {
737 // First time any channel has seen this subscriber
738 guid = '' + nextGuid++;
739 }
740 handleEvent.observer_guid = guid;
741 eventListenerOrFunction.observer_guid = guid;
742
743 // Don't add the same handler more than once.
744 if (!this.handlers[guid]) {
745 this.handlers[guid] = handleEvent;
746 this.numHandlers++;
747 if (this.numHandlers === 1) {
748 this.onHasSubscribersChange && this.onHasSubscribersChange();
749 }
750 }
751};
752
753/**
754 * Unsubscribes the function with the given guid from the channel.
755 */
756Channel.prototype.unsubscribe = function (eventListenerOrFunction) {
757 checkSubscriptionArgument(eventListenerOrFunction);
758 var handleEvent, guid, handler;
759
760 if (eventListenerOrFunction && typeof eventListenerOrFunction === 'object') {
761 // Received an EventListener object implementing the handleEvent interface
762 handleEvent = eventListenerOrFunction.handleEvent;
763 } else {
764 // Received a function to handle event
765 handleEvent = eventListenerOrFunction;
766 }
767
768 guid = handleEvent.observer_guid;
769 handler = this.handlers[guid];
770 if (handler) {
771 delete this.handlers[guid];
772 this.numHandlers--;
773 if (this.numHandlers === 0) {
774 this.onHasSubscribersChange && this.onHasSubscribersChange();
775 }
776 }
777};
778
779/**
780 * Calls all functions subscribed to this channel.
781 */
782Channel.prototype.fire = function (e) {
783 var fail = false; // eslint-disable-line no-unused-vars
784 var fireArgs = Array.prototype.slice.call(arguments);
785 // Apply stickiness.
786 if (this.state === 1) {
787 this.state = 2;
788 this.fireArgs = fireArgs;
789 }
790 if (this.numHandlers) {
791 // Copy the values first so that it is safe to modify it from within
792 // callbacks.
793 var toCall = [];
794 for (var item in this.handlers) {
795 toCall.push(this.handlers[item]);
796 }
797 for (var i = 0; i < toCall.length; ++i) {
798 toCall[i].apply(this, fireArgs);
799 }
800 if (this.state === 2 && this.numHandlers) {
801 this.numHandlers = 0;
802 this.handlers = {};
803 this.onHasSubscribersChange && this.onHasSubscribersChange();
804 }
805 }
806};
807
808// defining them here so they are ready super fast!
809// DOM event that is received when the web page is loaded and parsed.
810channel.createSticky('onDOMContentLoaded');
811
812// Event to indicate the Cordova native side is ready.
813channel.createSticky('onNativeReady');
814
815// Event to indicate that all Cordova JavaScript objects have been created
816// and it's time to run plugin constructors.
817channel.createSticky('onCordovaReady');
818
819// Event to indicate that all automatically loaded JS plugins are loaded and ready.
820// FIXME remove this
821channel.createSticky('onPluginsReady');
822
823// Event to indicate that Cordova is ready
824channel.createSticky('onDeviceReady');
825
826// Event to indicate a resume lifecycle event
827channel.create('onResume');
828
829// Event to indicate a pause lifecycle event
830channel.create('onPause');
831
832// Channels that must fire before "deviceready" is fired.
833channel.waitForInitialization('onCordovaReady');
834channel.waitForInitialization('onDOMContentLoaded');
835
836module.exports = channel;
837
838});
839
840// file: /Users/brodybits/Documents/cordova/cordova-ios/cordova-js-src/exec.js
841define("cordova/exec", function(require, exports, module) {
842
843/*global require, module, atob, document */
844
845/**
846 * Creates a gap bridge iframe used to notify the native code about queued
847 * commands.
848 */
849var cordova = require('cordova'),
850 utils = require('cordova/utils'),
851 base64 = require('cordova/base64'),
852 execIframe,
853 commandQueue = [], // Contains pending JS->Native messages.
854 isInContextOfEvalJs = 0,
855 failSafeTimerId = 0;
856
857function massageArgsJsToNative(args) {
858 if (!args || utils.typeName(args) != 'Array') {
859 return args;
860 }
861 var ret = [];
862 args.forEach(function(arg, i) {
863 if (utils.typeName(arg) == 'ArrayBuffer') {
864 ret.push({
865 'CDVType': 'ArrayBuffer',
866 'data': base64.fromArrayBuffer(arg)
867 });
868 } else {
869 ret.push(arg);
870 }
871 });
872 return ret;
873}
874
875function massageMessageNativeToJs(message) {
876 if (message.CDVType == 'ArrayBuffer') {
877 var stringToArrayBuffer = function(str) {
878 var ret = new Uint8Array(str.length);
879 for (var i = 0; i < str.length; i++) {
880 ret[i] = str.charCodeAt(i);
881 }
882 return ret.buffer;
883 };
884 var base64ToArrayBuffer = function(b64) {
885 return stringToArrayBuffer(atob(b64));
886 };
887 message = base64ToArrayBuffer(message.data);
888 }
889 return message;
890}
891
892function convertMessageToArgsNativeToJs(message) {
893 var args = [];
894 if (!message || !message.hasOwnProperty('CDVType')) {
895 args.push(message);
896 } else if (message.CDVType == 'MultiPart') {
897 message.messages.forEach(function(e) {
898 args.push(massageMessageNativeToJs(e));
899 });
900 } else {
901 args.push(massageMessageNativeToJs(message));
902 }
903 return args;
904}
905
906function iOSExec() {
907
908 var successCallback, failCallback, service, action, actionArgs;
909 var callbackId = null;
910 if (typeof arguments[0] !== 'string') {
911 // FORMAT ONE
912 successCallback = arguments[0];
913 failCallback = arguments[1];
914 service = arguments[2];
915 action = arguments[3];
916 actionArgs = arguments[4];
917
918 // Since we need to maintain backwards compatibility, we have to pass
919 // an invalid callbackId even if no callback was provided since plugins
920 // will be expecting it. The Cordova.exec() implementation allocates
921 // an invalid callbackId and passes it even if no callbacks were given.
922 callbackId = 'INVALID';
923 } else {
924 throw new Error('The old format of this exec call has been removed (deprecated since 2.1). Change to: ' +
925 'cordova.exec(null, null, \'Service\', \'action\', [ arg1, arg2 ]);'
926 );
927 }
928
929 // If actionArgs is not provided, default to an empty array
930 actionArgs = actionArgs || [];
931
932 // Register the callbacks and add the callbackId to the positional
933 // arguments if given.
934 if (successCallback || failCallback) {
935 callbackId = service + cordova.callbackId++;
936 cordova.callbacks[callbackId] =
937 {success:successCallback, fail:failCallback};
938 }
939
940 actionArgs = massageArgsJsToNative(actionArgs);
941
942 var command = [callbackId, service, action, actionArgs];
943
944 // Stringify and queue the command. We stringify to command now to
945 // effectively clone the command arguments in case they are mutated before
946 // the command is executed.
947 commandQueue.push(JSON.stringify(command));
948
949 // If we're in the context of a stringByEvaluatingJavaScriptFromString call,
950 // then the queue will be flushed when it returns; no need for a poke.
951 // Also, if there is already a command in the queue, then we've already
952 // poked the native side, so there is no reason to do so again.
953 if (!isInContextOfEvalJs && commandQueue.length == 1) {
954 pokeNative();
955 }
956}
957
958// CB-10530
959function proxyChanged() {
960 var cexec = cordovaExec();
961
962 return (execProxy !== cexec && // proxy objects are different
963 iOSExec !== cexec // proxy object is not the current iOSExec
964 );
965}
966
967// CB-10106
968function handleBridgeChange() {
969 if (proxyChanged()) {
970 var commandString = commandQueue.shift();
971 while(commandString) {
972 var command = JSON.parse(commandString);
973 var callbackId = command[0];
974 var service = command[1];
975 var action = command[2];
976 var actionArgs = command[3];
977 var callbacks = cordova.callbacks[callbackId] || {};
978
979 execProxy(callbacks.success, callbacks.fail, service, action, actionArgs);
980
981 commandString = commandQueue.shift();
982 };
983 return true;
984 }
985
986 return false;
987}
988
989function pokeNative() {
990 // CB-5488 - Don't attempt to create iframe before document.body is available.
991 if (!document.body) {
992 setTimeout(pokeNative);
993 return;
994 }
995
996 // Check if they've removed it from the DOM, and put it back if so.
997 if (execIframe && execIframe.contentWindow) {
998 execIframe.contentWindow.location = 'gap://ready';
999 } else {
1000 execIframe = document.createElement('iframe');
1001 execIframe.style.display = 'none';
1002 execIframe.src = 'gap://ready';
1003 document.body.appendChild(execIframe);
1004 }
1005 // Use a timer to protect against iframe being unloaded during the poke (CB-7735).
1006 // This makes the bridge ~ 7% slower, but works around the poke getting lost
1007 // when the iframe is removed from the DOM.
1008 // An onunload listener could be used in the case where the iframe has just been
1009 // created, but since unload events fire only once, it doesn't work in the normal
1010 // case of iframe reuse (where unload will have already fired due to the attempted
1011 // navigation of the page).
1012 failSafeTimerId = setTimeout(function() {
1013 if (commandQueue.length) {
1014 // CB-10106 - flush the queue on bridge change
1015 if (!handleBridgeChange()) {
1016 pokeNative();
1017 }
1018 }
1019 }, 50); // Making this > 0 improves performance (marginally) in the normal case (where it doesn't fire).
1020}
1021
1022iOSExec.nativeFetchMessages = function() {
1023 // Stop listing for window detatch once native side confirms poke.
1024 if (failSafeTimerId) {
1025 clearTimeout(failSafeTimerId);
1026 failSafeTimerId = 0;
1027 }
1028 // Each entry in commandQueue is a JSON string already.
1029 if (!commandQueue.length) {
1030 return '';
1031 }
1032 var json = '[' + commandQueue.join(',') + ']';
1033 commandQueue.length = 0;
1034 return json;
1035};
1036
1037iOSExec.nativeCallback = function(callbackId, status, message, keepCallback, debug) {
1038 return iOSExec.nativeEvalAndFetch(function() {
1039 var success = status === 0 || status === 1;
1040 var args = convertMessageToArgsNativeToJs(message);
1041 function nc2() {
1042 cordova.callbackFromNative(callbackId, success, status, args, keepCallback);
1043 }
1044 setTimeout(nc2, 0);
1045 });
1046};
1047
1048iOSExec.nativeEvalAndFetch = function(func) {
1049 // This shouldn't be nested, but better to be safe.
1050 isInContextOfEvalJs++;
1051 try {
1052 func();
1053 return iOSExec.nativeFetchMessages();
1054 } finally {
1055 isInContextOfEvalJs--;
1056 }
1057};
1058
1059// Proxy the exec for bridge changes. See CB-10106
1060
1061function cordovaExec() {
1062 var cexec = require('cordova/exec');
1063 var cexec_valid = (typeof cexec.nativeFetchMessages === 'function') && (typeof cexec.nativeEvalAndFetch === 'function') && (typeof cexec.nativeCallback === 'function');
1064 return (cexec_valid && execProxy !== cexec)? cexec : iOSExec;
1065}
1066
1067function execProxy() {
1068 cordovaExec().apply(null, arguments);
1069};
1070
1071execProxy.nativeFetchMessages = function() {
1072 return cordovaExec().nativeFetchMessages.apply(null, arguments);
1073};
1074
1075execProxy.nativeEvalAndFetch = function() {
1076 return cordovaExec().nativeEvalAndFetch.apply(null, arguments);
1077};
1078
1079execProxy.nativeCallback = function() {
1080 return cordovaExec().nativeCallback.apply(null, arguments);
1081};
1082
1083module.exports = execProxy;
1084
1085});
1086
1087// file: src/common/exec/proxy.js
1088define("cordova/exec/proxy", function(require, exports, module) {
1089
1090// internal map of proxy function
1091var CommandProxyMap = {};
1092
1093module.exports = {
1094
1095 // example: cordova.commandProxy.add("Accelerometer",{getCurrentAcceleration: function(successCallback, errorCallback, options) {...},...);
1096 add: function (id, proxyObj) {
1097 console.log('adding proxy for ' + id);
1098 CommandProxyMap[id] = proxyObj;
1099 return proxyObj;
1100 },
1101
1102 // cordova.commandProxy.remove("Accelerometer");
1103 remove: function (id) {
1104 var proxy = CommandProxyMap[id];
1105 delete CommandProxyMap[id];
1106 CommandProxyMap[id] = null;
1107 return proxy;
1108 },
1109
1110 get: function (service, action) {
1111 return (CommandProxyMap[service] ? CommandProxyMap[service][action] : null);
1112 }
1113};
1114
1115});
1116
1117// file: src/common/init.js
1118define("cordova/init", function(require, exports, module) {
1119
1120var channel = require('cordova/channel');
1121var cordova = require('cordova');
1122var modulemapper = require('cordova/modulemapper');
1123var platform = require('cordova/platform');
1124var pluginloader = require('cordova/pluginloader');
1125var utils = require('cordova/utils');
1126
1127var platformInitChannelsArray = [channel.onNativeReady, channel.onPluginsReady];
1128
1129function logUnfiredChannels (arr) {
1130 for (var i = 0; i < arr.length; ++i) {
1131 if (arr[i].state !== 2) {
1132 console.log('Channel not fired: ' + arr[i].type);
1133 }
1134 }
1135}
1136
1137window.setTimeout(function () {
1138 if (channel.onDeviceReady.state !== 2) {
1139 console.log('deviceready has not fired after 5 seconds.');
1140 logUnfiredChannels(platformInitChannelsArray);
1141 logUnfiredChannels(channel.deviceReadyChannelsArray);
1142 }
1143}, 5000);
1144
1145// Replace navigator before any modules are required(), to ensure it happens as soon as possible.
1146// We replace it so that properties that can't be clobbered can instead be overridden.
1147function replaceNavigator (origNavigator) {
1148 var CordovaNavigator = function () {};
1149 CordovaNavigator.prototype = origNavigator;
1150 var newNavigator = new CordovaNavigator();
1151 // This work-around really only applies to new APIs that are newer than Function.bind.
1152 // Without it, APIs such as getGamepads() break.
1153 if (CordovaNavigator.bind) {
1154 for (var key in origNavigator) {
1155 if (typeof origNavigator[key] === 'function') {
1156 newNavigator[key] = origNavigator[key].bind(origNavigator);
1157 } else {
1158 (function (k) {
1159 utils.defineGetterSetter(newNavigator, key, function () {
1160 return origNavigator[k];
1161 });
1162 })(key);
1163 }
1164 }
1165 }
1166 return newNavigator;
1167}
1168
1169if (window.navigator) {
1170 window.navigator = replaceNavigator(window.navigator);
1171}
1172
1173if (!window.console) {
1174 window.console = {
1175 log: function () {}
1176 };
1177}
1178if (!window.console.warn) {
1179 window.console.warn = function (msg) {
1180 this.log('warn: ' + msg);
1181 };
1182}
1183
1184// Register pause, resume and deviceready channels as events on document.
1185channel.onPause = cordova.addDocumentEventHandler('pause');
1186channel.onResume = cordova.addDocumentEventHandler('resume');
1187channel.onActivated = cordova.addDocumentEventHandler('activated');
1188channel.onDeviceReady = cordova.addStickyDocumentEventHandler('deviceready');
1189
1190// Listen for DOMContentLoaded and notify our channel subscribers.
1191if (document.readyState === 'complete' || document.readyState === 'interactive') {
1192 channel.onDOMContentLoaded.fire();
1193} else {
1194 document.addEventListener('DOMContentLoaded', function () {
1195 channel.onDOMContentLoaded.fire();
1196 }, false);
1197}
1198
1199// _nativeReady is global variable that the native side can set
1200// to signify that the native code is ready. It is a global since
1201// it may be called before any cordova JS is ready.
1202if (window._nativeReady) {
1203 channel.onNativeReady.fire();
1204}
1205
1206modulemapper.clobbers('cordova', 'cordova');
1207modulemapper.clobbers('cordova/exec', 'cordova.exec');
1208modulemapper.clobbers('cordova/exec', 'Cordova.exec');
1209
1210// Call the platform-specific initialization.
1211platform.bootstrap && platform.bootstrap();
1212
1213// Wrap in a setTimeout to support the use-case of having plugin JS appended to cordova.js.
1214// The delay allows the attached modules to be defined before the plugin loader looks for them.
1215setTimeout(function () {
1216 pluginloader.load(function () {
1217 channel.onPluginsReady.fire();
1218 });
1219}, 0);
1220
1221/**
1222 * Create all cordova objects once native side is ready.
1223 */
1224channel.join(function () {
1225 modulemapper.mapModules(window);
1226
1227 platform.initialize && platform.initialize();
1228
1229 // Fire event to notify that all objects are created
1230 channel.onCordovaReady.fire();
1231
1232 // Fire onDeviceReady event once page has fully loaded, all
1233 // constructors have run and cordova info has been received from native
1234 // side.
1235 channel.join(function () {
1236 require('cordova').fireDocumentEvent('deviceready');
1237 }, channel.deviceReadyChannelsArray);
1238
1239}, platformInitChannelsArray);
1240
1241});
1242
1243// file: src/common/init_b.js
1244define("cordova/init_b", function(require, exports, module) {
1245
1246var channel = require('cordova/channel');
1247var cordova = require('cordova');
1248var modulemapper = require('cordova/modulemapper');
1249var platform = require('cordova/platform');
1250var pluginloader = require('cordova/pluginloader');
1251var utils = require('cordova/utils');
1252
1253var platformInitChannelsArray = [channel.onDOMContentLoaded, channel.onNativeReady, channel.onPluginsReady];
1254
1255// setting exec
1256cordova.exec = require('cordova/exec');
1257
1258function logUnfiredChannels (arr) {
1259 for (var i = 0; i < arr.length; ++i) {
1260 if (arr[i].state !== 2) {
1261 console.log('Channel not fired: ' + arr[i].type);
1262 }
1263 }
1264}
1265
1266window.setTimeout(function () {
1267 if (channel.onDeviceReady.state !== 2) {
1268 console.log('deviceready has not fired after 5 seconds.');
1269 logUnfiredChannels(platformInitChannelsArray);
1270 logUnfiredChannels(channel.deviceReadyChannelsArray);
1271 }
1272}, 5000);
1273
1274// Replace navigator before any modules are required(), to ensure it happens as soon as possible.
1275// We replace it so that properties that can't be clobbered can instead be overridden.
1276function replaceNavigator (origNavigator) {
1277 var CordovaNavigator = function () {};
1278 CordovaNavigator.prototype = origNavigator;
1279 var newNavigator = new CordovaNavigator();
1280 // This work-around really only applies to new APIs that are newer than Function.bind.
1281 // Without it, APIs such as getGamepads() break.
1282 if (CordovaNavigator.bind) {
1283 for (var key in origNavigator) {
1284 if (typeof origNavigator[key] === 'function') {
1285 newNavigator[key] = origNavigator[key].bind(origNavigator);
1286 } else {
1287 (function (k) {
1288 utils.defineGetterSetter(newNavigator, key, function () {
1289 return origNavigator[k];
1290 });
1291 })(key);
1292 }
1293 }
1294 }
1295 return newNavigator;
1296}
1297if (window.navigator) {
1298 window.navigator = replaceNavigator(window.navigator);
1299}
1300
1301if (!window.console) {
1302 window.console = {
1303 log: function () {}
1304 };
1305}
1306if (!window.console.warn) {
1307 window.console.warn = function (msg) {
1308 this.log('warn: ' + msg);
1309 };
1310}
1311
1312// Register pause, resume and deviceready channels as events on document.
1313channel.onPause = cordova.addDocumentEventHandler('pause');
1314channel.onResume = cordova.addDocumentEventHandler('resume');
1315channel.onActivated = cordova.addDocumentEventHandler('activated');
1316channel.onDeviceReady = cordova.addStickyDocumentEventHandler('deviceready');
1317
1318// Listen for DOMContentLoaded and notify our channel subscribers.
1319if (document.readyState === 'complete' || document.readyState === 'interactive') {
1320 channel.onDOMContentLoaded.fire();
1321} else {
1322 document.addEventListener('DOMContentLoaded', function () {
1323 channel.onDOMContentLoaded.fire();
1324 }, false);
1325}
1326
1327// _nativeReady is global variable that the native side can set
1328// to signify that the native code is ready. It is a global since
1329// it may be called before any cordova JS is ready.
1330if (window._nativeReady) {
1331 channel.onNativeReady.fire();
1332}
1333
1334// Call the platform-specific initialization.
1335platform.bootstrap && platform.bootstrap();
1336
1337// Wrap in a setTimeout to support the use-case of having plugin JS appended to cordova.js.
1338// The delay allows the attached modules to be defined before the plugin loader looks for them.
1339setTimeout(function () {
1340 pluginloader.load(function () {
1341 channel.onPluginsReady.fire();
1342 });
1343}, 0);
1344
1345/**
1346 * Create all cordova objects once native side is ready.
1347 */
1348channel.join(function () {
1349 modulemapper.mapModules(window);
1350
1351 platform.initialize && platform.initialize();
1352
1353 // Fire event to notify that all objects are created
1354 channel.onCordovaReady.fire();
1355
1356 // Fire onDeviceReady event once page has fully loaded, all
1357 // constructors have run and cordova info has been received from native
1358 // side.
1359 channel.join(function () {
1360 require('cordova').fireDocumentEvent('deviceready');
1361 }, channel.deviceReadyChannelsArray);
1362
1363}, platformInitChannelsArray);
1364
1365});
1366
1367// file: src/common/modulemapper.js
1368define("cordova/modulemapper", function(require, exports, module) {
1369
1370var builder = require('cordova/builder');
1371var moduleMap = define.moduleMap; // eslint-disable-line no-undef
1372var symbolList;
1373var deprecationMap;
1374
1375exports.reset = function () {
1376 symbolList = [];
1377 deprecationMap = {};
1378};
1379
1380function addEntry (strategy, moduleName, symbolPath, opt_deprecationMessage) {
1381 if (!(moduleName in moduleMap)) {
1382 throw new Error('Module ' + moduleName + ' does not exist.');
1383 }
1384 symbolList.push(strategy, moduleName, symbolPath);
1385 if (opt_deprecationMessage) {
1386 deprecationMap[symbolPath] = opt_deprecationMessage;
1387 }
1388}
1389
1390// Note: Android 2.3 does have Function.bind().
1391exports.clobbers = function (moduleName, symbolPath, opt_deprecationMessage) {
1392 addEntry('c', moduleName, symbolPath, opt_deprecationMessage);
1393};
1394
1395exports.merges = function (moduleName, symbolPath, opt_deprecationMessage) {
1396 addEntry('m', moduleName, symbolPath, opt_deprecationMessage);
1397};
1398
1399exports.defaults = function (moduleName, symbolPath, opt_deprecationMessage) {
1400 addEntry('d', moduleName, symbolPath, opt_deprecationMessage);
1401};
1402
1403exports.runs = function (moduleName) {
1404 addEntry('r', moduleName, null);
1405};
1406
1407function prepareNamespace (symbolPath, context) {
1408 if (!symbolPath) {
1409 return context;
1410 }
1411 var parts = symbolPath.split('.');
1412 var cur = context;
1413 for (var i = 0, part; part = parts[i]; ++i) { // eslint-disable-line no-cond-assign
1414 cur = cur[part] = cur[part] || {};
1415 }
1416 return cur;
1417}
1418
1419exports.mapModules = function (context) {
1420 var origSymbols = {};
1421 context.CDV_origSymbols = origSymbols;
1422 for (var i = 0, len = symbolList.length; i < len; i += 3) {
1423 var strategy = symbolList[i];
1424 var moduleName = symbolList[i + 1];
1425 var module = require(moduleName);
1426 // <runs/>
1427 if (strategy === 'r') {
1428 continue;
1429 }
1430 var symbolPath = symbolList[i + 2];
1431 var lastDot = symbolPath.lastIndexOf('.');
1432 var namespace = symbolPath.substr(0, lastDot);
1433 var lastName = symbolPath.substr(lastDot + 1);
1434
1435 var deprecationMsg = symbolPath in deprecationMap ? 'Access made to deprecated symbol: ' + symbolPath + '. ' + deprecationMsg : null;
1436 var parentObj = prepareNamespace(namespace, context);
1437 var target = parentObj[lastName];
1438
1439 if (strategy === 'm' && target) {
1440 builder.recursiveMerge(target, module);
1441 } else if ((strategy === 'd' && !target) || (strategy !== 'd')) {
1442 if (!(symbolPath in origSymbols)) {
1443 origSymbols[symbolPath] = target;
1444 }
1445 builder.assignOrWrapInDeprecateGetter(parentObj, lastName, module, deprecationMsg);
1446 }
1447 }
1448};
1449
1450exports.getOriginalSymbol = function (context, symbolPath) {
1451 var origSymbols = context.CDV_origSymbols;
1452 if (origSymbols && (symbolPath in origSymbols)) {
1453 return origSymbols[symbolPath];
1454 }
1455 var parts = symbolPath.split('.');
1456 var obj = context;
1457 for (var i = 0; i < parts.length; ++i) {
1458 obj = obj && obj[parts[i]];
1459 }
1460 return obj;
1461};
1462
1463exports.reset();
1464
1465});
1466
1467// file: src/common/modulemapper_b.js
1468define("cordova/modulemapper_b", function(require, exports, module) {
1469
1470var builder = require('cordova/builder');
1471var symbolList = [];
1472var deprecationMap;
1473
1474exports.reset = function () {
1475 symbolList = [];
1476 deprecationMap = {};
1477};
1478
1479function addEntry (strategy, moduleName, symbolPath, opt_deprecationMessage) {
1480 symbolList.push(strategy, moduleName, symbolPath);
1481 if (opt_deprecationMessage) {
1482 deprecationMap[symbolPath] = opt_deprecationMessage;
1483 }
1484}
1485
1486// Note: Android 2.3 does have Function.bind().
1487exports.clobbers = function (moduleName, symbolPath, opt_deprecationMessage) {
1488 addEntry('c', moduleName, symbolPath, opt_deprecationMessage);
1489};
1490
1491exports.merges = function (moduleName, symbolPath, opt_deprecationMessage) {
1492 addEntry('m', moduleName, symbolPath, opt_deprecationMessage);
1493};
1494
1495exports.defaults = function (moduleName, symbolPath, opt_deprecationMessage) {
1496 addEntry('d', moduleName, symbolPath, opt_deprecationMessage);
1497};
1498
1499exports.runs = function (moduleName) {
1500 addEntry('r', moduleName, null);
1501};
1502
1503function prepareNamespace (symbolPath, context) {
1504 if (!symbolPath) {
1505 return context;
1506 }
1507 var parts = symbolPath.split('.');
1508 var cur = context;
1509 for (var i = 0, part; part = parts[i]; ++i) { // eslint-disable-line no-cond-assign
1510 cur = cur[part] = cur[part] || {};
1511 }
1512 return cur;
1513}
1514
1515exports.mapModules = function (context) {
1516 var origSymbols = {};
1517 context.CDV_origSymbols = origSymbols;
1518 for (var i = 0, len = symbolList.length; i < len; i += 3) {
1519 var strategy = symbolList[i];
1520 var moduleName = symbolList[i + 1];
1521 var module = require(moduleName);
1522 // <runs/>
1523 if (strategy === 'r') {
1524 continue;
1525 }
1526 var symbolPath = symbolList[i + 2];
1527 var lastDot = symbolPath.lastIndexOf('.');
1528 var namespace = symbolPath.substr(0, lastDot);
1529 var lastName = symbolPath.substr(lastDot + 1);
1530
1531 var deprecationMsg = symbolPath in deprecationMap ? 'Access made to deprecated symbol: ' + symbolPath + '. ' + deprecationMsg : null;
1532 var parentObj = prepareNamespace(namespace, context);
1533 var target = parentObj[lastName];
1534
1535 if (strategy === 'm' && target) {
1536 builder.recursiveMerge(target, module);
1537 } else if ((strategy === 'd' && !target) || (strategy !== 'd')) {
1538 if (!(symbolPath in origSymbols)) {
1539 origSymbols[symbolPath] = target;
1540 }
1541 builder.assignOrWrapInDeprecateGetter(parentObj, lastName, module, deprecationMsg);
1542 }
1543 }
1544};
1545
1546exports.getOriginalSymbol = function (context, symbolPath) {
1547 var origSymbols = context.CDV_origSymbols;
1548 if (origSymbols && (symbolPath in origSymbols)) {
1549 return origSymbols[symbolPath];
1550 }
1551 var parts = symbolPath.split('.');
1552 var obj = context;
1553 for (var i = 0; i < parts.length; ++i) {
1554 obj = obj && obj[parts[i]];
1555 }
1556 return obj;
1557};
1558
1559exports.reset();
1560
1561});
1562
1563// file: /Users/brodybits/Documents/cordova/cordova-ios/cordova-js-src/platform.js
1564define("cordova/platform", function(require, exports, module) {
1565
1566module.exports = {
1567 id: 'ios',
1568 bootstrap: function () {
1569 // Attach the console polyfill that is iOS-only to window.console
1570 // see the file under plugin/ios/console.js
1571 require('cordova/modulemapper').clobbers('cordova/plugin/ios/console', 'window.console');
1572
1573 require('cordova/channel').onNativeReady.fire();
1574 }
1575};
1576
1577});
1578
1579// file: /Users/brodybits/Documents/cordova/cordova-ios/cordova-js-src/plugin/ios/console.js
1580define("cordova/plugin/ios/console", function(require, exports, module) {
1581
1582//------------------------------------------------------------------------------
1583
1584var logger = require('cordova/plugin/ios/logger');
1585
1586//------------------------------------------------------------------------------
1587// object that we're exporting
1588//------------------------------------------------------------------------------
1589var console = module.exports;
1590
1591//------------------------------------------------------------------------------
1592// copy of the original console object
1593//------------------------------------------------------------------------------
1594var WinConsole = window.console;
1595
1596//------------------------------------------------------------------------------
1597// whether to use the logger
1598//------------------------------------------------------------------------------
1599var UseLogger = false;
1600
1601//------------------------------------------------------------------------------
1602// Timers
1603//------------------------------------------------------------------------------
1604var Timers = {};
1605
1606//------------------------------------------------------------------------------
1607// used for unimplemented methods
1608//------------------------------------------------------------------------------
1609function noop() {}
1610
1611//------------------------------------------------------------------------------
1612// used for unimplemented methods
1613//------------------------------------------------------------------------------
1614console.useLogger = function (value) {
1615 if (arguments.length) UseLogger = !!value;
1616
1617 if (UseLogger) {
1618 if (logger.useConsole()) {
1619 throw new Error("console and logger are too intertwingly");
1620 }
1621 }
1622
1623 return UseLogger;
1624};
1625
1626//------------------------------------------------------------------------------
1627console.log = function() {
1628 if (logger.useConsole()) return;
1629 logger.log.apply(logger, [].slice.call(arguments));
1630};
1631
1632//------------------------------------------------------------------------------
1633console.error = function() {
1634 if (logger.useConsole()) return;
1635 logger.error.apply(logger, [].slice.call(arguments));
1636};
1637
1638//------------------------------------------------------------------------------
1639console.warn = function() {
1640 if (logger.useConsole()) return;
1641 logger.warn.apply(logger, [].slice.call(arguments));
1642};
1643
1644//------------------------------------------------------------------------------
1645console.info = function() {
1646 if (logger.useConsole()) return;
1647 logger.info.apply(logger, [].slice.call(arguments));
1648};
1649
1650//------------------------------------------------------------------------------
1651console.debug = function() {
1652 if (logger.useConsole()) return;
1653 logger.debug.apply(logger, [].slice.call(arguments));
1654};
1655
1656//------------------------------------------------------------------------------
1657console.assert = function(expression) {
1658 if (expression) return;
1659
1660 var message = logger.format.apply(logger.format, [].slice.call(arguments, 1));
1661 console.log("ASSERT: " + message);
1662};
1663
1664//------------------------------------------------------------------------------
1665console.clear = function() {};
1666
1667//------------------------------------------------------------------------------
1668console.dir = function(object) {
1669 console.log("%o", object);
1670};
1671
1672//------------------------------------------------------------------------------
1673console.dirxml = function(node) {
1674 console.log(node.innerHTML);
1675};
1676
1677//------------------------------------------------------------------------------
1678console.trace = noop;
1679
1680//------------------------------------------------------------------------------
1681console.group = console.log;
1682
1683//------------------------------------------------------------------------------
1684console.groupCollapsed = console.log;
1685
1686//------------------------------------------------------------------------------
1687console.groupEnd = noop;
1688
1689//------------------------------------------------------------------------------
1690console.time = function(name) {
1691 Timers[name] = new Date().valueOf();
1692};
1693
1694//------------------------------------------------------------------------------
1695console.timeEnd = function(name) {
1696 var timeStart = Timers[name];
1697 if (!timeStart) {
1698 console.warn("unknown timer: " + name);
1699 return;
1700 }
1701
1702 var timeElapsed = new Date().valueOf() - timeStart;
1703 console.log(name + ": " + timeElapsed + "ms");
1704};
1705
1706//------------------------------------------------------------------------------
1707console.timeStamp = noop;
1708
1709//------------------------------------------------------------------------------
1710console.profile = noop;
1711
1712//------------------------------------------------------------------------------
1713console.profileEnd = noop;
1714
1715//------------------------------------------------------------------------------
1716console.count = noop;
1717
1718//------------------------------------------------------------------------------
1719console.exception = console.log;
1720
1721//------------------------------------------------------------------------------
1722console.table = function(data, columns) {
1723 console.log("%o", data);
1724};
1725
1726//------------------------------------------------------------------------------
1727// return a new function that calls both functions passed as args
1728//------------------------------------------------------------------------------
1729function wrappedOrigCall(orgFunc, newFunc) {
1730 return function() {
1731 var args = [].slice.call(arguments);
1732 try { orgFunc.apply(WinConsole, args); } catch (e) {}
1733 try { newFunc.apply(console, args); } catch (e) {}
1734 };
1735}
1736
1737//------------------------------------------------------------------------------
1738// For every function that exists in the original console object, that
1739// also exists in the new console object, wrap the new console method
1740// with one that calls both
1741//------------------------------------------------------------------------------
1742for (var key in console) {
1743 if (typeof WinConsole[key] == "function") {
1744 console[key] = wrappedOrigCall(WinConsole[key], console[key]);
1745 }
1746}
1747
1748});
1749
1750// file: /Users/brodybits/Documents/cordova/cordova-ios/cordova-js-src/plugin/ios/logger.js
1751define("cordova/plugin/ios/logger", function(require, exports, module) {
1752
1753//------------------------------------------------------------------------------
1754// The logger module exports the following properties/functions:
1755//
1756// LOG - constant for the level LOG
1757// ERROR - constant for the level ERROR
1758// WARN - constant for the level WARN
1759// INFO - constant for the level INFO
1760// DEBUG - constant for the level DEBUG
1761// logLevel() - returns current log level
1762// logLevel(value) - sets and returns a new log level
1763// useConsole() - returns whether logger is using console
1764// useConsole(value) - sets and returns whether logger is using console
1765// log(message,...) - logs a message at level LOG
1766// error(message,...) - logs a message at level ERROR
1767// warn(message,...) - logs a message at level WARN
1768// info(message,...) - logs a message at level INFO
1769// debug(message,...) - logs a message at level DEBUG
1770// logLevel(level,message,...) - logs a message specified level
1771//
1772//------------------------------------------------------------------------------
1773
1774var logger = exports;
1775
1776var exec = require('cordova/exec');
1777
1778var UseConsole = false;
1779var UseLogger = true;
1780var Queued = [];
1781var DeviceReady = false;
1782var CurrentLevel;
1783
1784var originalConsole = console;
1785
1786/**
1787 * Logging levels
1788 */
1789
1790var Levels = [
1791 "LOG",
1792 "ERROR",
1793 "WARN",
1794 "INFO",
1795 "DEBUG"
1796];
1797
1798/*
1799 * add the logging levels to the logger object and
1800 * to a separate levelsMap object for testing
1801 */
1802
1803var LevelsMap = {};
1804for (var i=0; i<Levels.length; i++) {
1805 var level = Levels[i];
1806 LevelsMap[level] = i;
1807 logger[level] = level;
1808}
1809
1810CurrentLevel = LevelsMap.WARN;
1811
1812/**
1813 * Getter/Setter for the logging level
1814 *
1815 * Returns the current logging level.
1816 *
1817 * When a value is passed, sets the logging level to that value.
1818 * The values should be one of the following constants:
1819 * logger.LOG
1820 * logger.ERROR
1821 * logger.WARN
1822 * logger.INFO
1823 * logger.DEBUG
1824 *
1825 * The value used determines which messages get printed. The logging
1826 * values above are in order, and only messages logged at the logging
1827 * level or above will actually be displayed to the user. E.g., the
1828 * default level is WARN, so only messages logged with LOG, ERROR, or
1829 * WARN will be displayed; INFO and DEBUG messages will be ignored.
1830 */
1831logger.level = function (value) {
1832 if (arguments.length) {
1833 if (LevelsMap[value] === null) {
1834 throw new Error("invalid logging level: " + value);
1835 }
1836 CurrentLevel = LevelsMap[value];
1837 }
1838
1839 return Levels[CurrentLevel];
1840};
1841
1842/**
1843 * Getter/Setter for the useConsole functionality
1844 *
1845 * When useConsole is true, the logger will log via the
1846 * browser 'console' object.
1847 */
1848logger.useConsole = function (value) {
1849 if (arguments.length) UseConsole = !!value;
1850
1851 if (UseConsole) {
1852 if (typeof console == "undefined") {
1853 throw new Error("global console object is not defined");
1854 }
1855
1856 if (typeof console.log != "function") {
1857 throw new Error("global console object does not have a log function");
1858 }
1859
1860 if (typeof console.useLogger == "function") {
1861 if (console.useLogger()) {
1862 throw new Error("console and logger are too intertwingly");
1863 }
1864 }
1865 }
1866
1867 return UseConsole;
1868};
1869
1870/**
1871 * Getter/Setter for the useLogger functionality
1872 *
1873 * When useLogger is true, the logger will log via the
1874 * native Logger plugin.
1875 */
1876logger.useLogger = function (value) {
1877 // Enforce boolean
1878 if (arguments.length) UseLogger = !!value;
1879 return UseLogger;
1880};
1881
1882/**
1883 * Logs a message at the LOG level.
1884 *
1885 * Parameters passed after message are used applied to
1886 * the message with utils.format()
1887 */
1888logger.log = function(message) { logWithArgs("LOG", arguments); };
1889
1890/**
1891 * Logs a message at the ERROR level.
1892 *
1893 * Parameters passed after message are used applied to
1894 * the message with utils.format()
1895 */
1896logger.error = function(message) { logWithArgs("ERROR", arguments); };
1897
1898/**
1899 * Logs a message at the WARN level.
1900 *
1901 * Parameters passed after message are used applied to
1902 * the message with utils.format()
1903 */
1904logger.warn = function(message) { logWithArgs("WARN", arguments); };
1905
1906/**
1907 * Logs a message at the INFO level.
1908 *
1909 * Parameters passed after message are used applied to
1910 * the message with utils.format()
1911 */
1912logger.info = function(message) { logWithArgs("INFO", arguments); };
1913
1914/**
1915 * Logs a message at the DEBUG level.
1916 *
1917 * Parameters passed after message are used applied to
1918 * the message with utils.format()
1919 */
1920logger.debug = function(message) { logWithArgs("DEBUG", arguments); };
1921
1922// log at the specified level with args
1923function logWithArgs(level, args) {
1924 args = [level].concat([].slice.call(args));
1925 logger.logLevel.apply(logger, args);
1926}
1927
1928// return the correct formatString for an object
1929function formatStringForMessage(message) {
1930 return (typeof message === "string") ? "" : "%o";
1931}
1932
1933/**
1934 * Logs a message at the specified level.
1935 *
1936 * Parameters passed after message are used applied to
1937 * the message with utils.format()
1938 */
1939logger.logLevel = function(level /* , ... */) {
1940 // format the message with the parameters
1941 var formatArgs = [].slice.call(arguments, 1);
1942 var fmtString = formatStringForMessage(formatArgs[0]);
1943 if (fmtString.length > 0){
1944 formatArgs.unshift(fmtString); // add formatString
1945 }
1946
1947 var message = logger.format.apply(logger.format, formatArgs);
1948
1949 if (LevelsMap[level] === null) {
1950 throw new Error("invalid logging level: " + level);
1951 }
1952
1953 if (LevelsMap[level] > CurrentLevel) return;
1954
1955 // queue the message if not yet at deviceready
1956 if (!DeviceReady && !UseConsole) {
1957 Queued.push([level, message]);
1958 return;
1959 }
1960
1961 // Log using the native logger if that is enabled
1962 if (UseLogger) {
1963 exec(null, null, "Console", "logLevel", [level, message]);
1964 }
1965
1966 // Log using the console if that is enabled
1967 if (UseConsole) {
1968 // make sure console is not using logger
1969 if (console.useLogger()) {
1970 throw new Error("console and logger are too intertwingly");
1971 }
1972
1973 // log to the console
1974 switch (level) {
1975 case logger.LOG: originalConsole.log(message); break;
1976 case logger.ERROR: originalConsole.log("ERROR: " + message); break;
1977 case logger.WARN: originalConsole.log("WARN: " + message); break;
1978 case logger.INFO: originalConsole.log("INFO: " + message); break;
1979 case logger.DEBUG: originalConsole.log("DEBUG: " + message); break;
1980 }
1981 }
1982};
1983
1984
1985/**
1986 * Formats a string and arguments following it ala console.log()
1987 *
1988 * Any remaining arguments will be appended to the formatted string.
1989 *
1990 * for rationale, see FireBug's Console API:
1991 * http://getfirebug.com/wiki/index.php/Console_API
1992 */
1993logger.format = function(formatString, args) {
1994 return __format(arguments[0], [].slice.call(arguments,1)).join(' ');
1995};
1996
1997
1998//------------------------------------------------------------------------------
1999/**
2000 * Formats a string and arguments following it ala vsprintf()
2001 *
2002 * format chars:
2003 * %j - format arg as JSON
2004 * %o - format arg as JSON
2005 * %c - format arg as ''
2006 * %% - replace with '%'
2007 * any other char following % will format it's
2008 * arg via toString().
2009 *
2010 * Returns an array containing the formatted string and any remaining
2011 * arguments.
2012 */
2013function __format(formatString, args) {
2014 if (formatString === null || formatString === undefined) return [""];
2015 if (arguments.length == 1) return [formatString.toString()];
2016
2017 if (typeof formatString != "string")
2018 formatString = formatString.toString();
2019
2020 var pattern = /(.*?)%(.)(.*)/;
2021 var rest = formatString;
2022 var result = [];
2023
2024 while (args.length) {
2025 var match = pattern.exec(rest);
2026 if (!match) break;
2027
2028 var arg = args.shift();
2029 rest = match[3];
2030 result.push(match[1]);
2031
2032 if (match[2] == '%') {
2033 result.push('%');
2034 args.unshift(arg);
2035 continue;
2036 }
2037
2038 result.push(__formatted(arg, match[2]));
2039 }
2040
2041 result.push(rest);
2042
2043 var remainingArgs = [].slice.call(args);
2044 remainingArgs.unshift(result.join(''));
2045 return remainingArgs;
2046}
2047
2048function __formatted(object, formatChar) {
2049
2050 try {
2051 switch(formatChar) {
2052 case 'j':
2053 case 'o': return JSON.stringify(object);
2054 case 'c': return '';
2055 }
2056 }
2057 catch (e) {
2058 return "error JSON.stringify()ing argument: " + e;
2059 }
2060
2061 if ((object === null) || (object === undefined)) {
2062 return Object.prototype.toString.call(object);
2063 }
2064
2065 return object.toString();
2066}
2067
2068
2069//------------------------------------------------------------------------------
2070// when deviceready fires, log queued messages
2071logger.__onDeviceReady = function() {
2072 if (DeviceReady) return;
2073
2074 DeviceReady = true;
2075
2076 for (var i=0; i<Queued.length; i++) {
2077 var messageArgs = Queued[i];
2078 logger.logLevel(messageArgs[0], messageArgs[1]);
2079 }
2080
2081 Queued = null;
2082};
2083
2084// add a deviceready event to log queued messages
2085document.addEventListener("deviceready", logger.__onDeviceReady, false);
2086
2087});
2088
2089// file: src/common/pluginloader.js
2090define("cordova/pluginloader", function(require, exports, module) {
2091
2092var modulemapper = require('cordova/modulemapper');
2093
2094// Helper function to inject a <script> tag.
2095// Exported for testing.
2096exports.injectScript = function (url, onload, onerror) {
2097 var script = document.createElement('script');
2098 // onload fires even when script fails loads with an error.
2099 script.onload = onload;
2100 // onerror fires for malformed URLs.
2101 script.onerror = onerror;
2102 script.src = url;
2103 document.head.appendChild(script);
2104};
2105
2106function injectIfNecessary (id, url, onload, onerror) {
2107 onerror = onerror || onload;
2108 if (id in define.moduleMap) { // eslint-disable-line no-undef
2109 onload();
2110 } else {
2111 exports.injectScript(url, function () {
2112 if (id in define.moduleMap) { // eslint-disable-line no-undef
2113 onload();
2114 } else {
2115 onerror();
2116 }
2117 }, onerror);
2118 }
2119}
2120
2121function onScriptLoadingComplete (moduleList, finishPluginLoading) {
2122 // Loop through all the plugins and then through their clobbers and merges.
2123 for (var i = 0, module; module = moduleList[i]; i++) { // eslint-disable-line no-cond-assign
2124 if (module.clobbers && module.clobbers.length) {
2125 for (var j = 0; j < module.clobbers.length; j++) {
2126 modulemapper.clobbers(module.id, module.clobbers[j]);
2127 }
2128 }
2129
2130 if (module.merges && module.merges.length) {
2131 for (var k = 0; k < module.merges.length; k++) {
2132 modulemapper.merges(module.id, module.merges[k]);
2133 }
2134 }
2135
2136 // Finally, if runs is truthy we want to simply require() the module.
2137 if (module.runs) {
2138 modulemapper.runs(module.id);
2139 }
2140 }
2141
2142 finishPluginLoading();
2143}
2144
2145// Handler for the cordova_plugins.js content.
2146// See plugman's plugin_loader.js for the details of this object.
2147// This function is only called if the really is a plugins array that isn't empty.
2148// Otherwise the onerror response handler will just call finishPluginLoading().
2149function handlePluginsObject (path, moduleList, finishPluginLoading) {
2150 // Now inject the scripts.
2151 var scriptCounter = moduleList.length;
2152
2153 if (!scriptCounter) {
2154 finishPluginLoading();
2155 return;
2156 }
2157 function scriptLoadedCallback () {
2158 if (!--scriptCounter) {
2159 onScriptLoadingComplete(moduleList, finishPluginLoading);
2160 }
2161 }
2162
2163 for (var i = 0; i < moduleList.length; i++) {
2164 injectIfNecessary(moduleList[i].id, path + moduleList[i].file, scriptLoadedCallback);
2165 }
2166}
2167
2168function findCordovaPath () {
2169 var path = null;
2170 var scripts = document.getElementsByTagName('script');
2171 var term = '/cordova.js';
2172 for (var n = scripts.length - 1; n > -1; n--) {
2173 var src = scripts[n].src.replace(/\?.*$/, ''); // Strip any query param (CB-6007).
2174 if (src.indexOf(term) === (src.length - term.length)) {
2175 path = src.substring(0, src.length - term.length) + '/';
2176 break;
2177 }
2178 }
2179 return path;
2180}
2181
2182// Tries to load all plugins' js-modules.
2183// This is an async process, but onDeviceReady is blocked on onPluginsReady.
2184// onPluginsReady is fired when there are no plugins to load, or they are all done.
2185exports.load = function (callback) {
2186 var pathPrefix = findCordovaPath();
2187 if (pathPrefix === null) {
2188 console.log('Could not find cordova.js script tag. Plugin loading may fail.');
2189 pathPrefix = '';
2190 }
2191 injectIfNecessary('cordova/plugin_list', pathPrefix + 'cordova_plugins.js', function () {
2192 var moduleList = require('cordova/plugin_list');
2193 handlePluginsObject(pathPrefix, moduleList, callback);
2194 }, callback);
2195};
2196
2197});
2198
2199// file: src/common/pluginloader_b.js
2200define("cordova/pluginloader_b", function(require, exports, module) {
2201
2202var modulemapper = require('cordova/modulemapper');
2203
2204// Handler for the cordova_plugins.js content.
2205// See plugman's plugin_loader.js for the details of this object.
2206function handlePluginsObject (moduleList) {
2207 // if moduleList is not defined or empty, we've nothing to do
2208 if (!moduleList || !moduleList.length) {
2209 return;
2210 }
2211
2212 // Loop through all the modules and then through their clobbers and merges.
2213 for (var i = 0, module; module = moduleList[i]; i++) { // eslint-disable-line no-cond-assign
2214 if (module.clobbers && module.clobbers.length) {
2215 for (var j = 0; j < module.clobbers.length; j++) {
2216 modulemapper.clobbers(module.id, module.clobbers[j]);
2217 }
2218 }
2219
2220 if (module.merges && module.merges.length) {
2221 for (var k = 0; k < module.merges.length; k++) {
2222 modulemapper.merges(module.id, module.merges[k]);
2223 }
2224 }
2225
2226 // Finally, if runs is truthy we want to simply require() the module.
2227 if (module.runs) {
2228 modulemapper.runs(module.id);
2229 }
2230 }
2231}
2232
2233// Loads all plugins' js-modules. Plugin loading is syncronous in browserified bundle
2234// but the method accepts callback to be compatible with non-browserify flow.
2235// onDeviceReady is blocked on onPluginsReady. onPluginsReady is fired when there are
2236// no plugins to load, or they are all done.
2237exports.load = function (callback) {
2238 var moduleList = require('cordova/plugin_list');
2239 handlePluginsObject(moduleList);
2240
2241 callback();
2242};
2243
2244});
2245
2246// file: src/common/urlutil.js
2247define("cordova/urlutil", function(require, exports, module) {
2248
2249/**
2250 * For already absolute URLs, returns what is passed in.
2251 * For relative URLs, converts them to absolute ones.
2252 */
2253exports.makeAbsolute = function makeAbsolute (url) {
2254 var anchorEl = document.createElement('a');
2255 anchorEl.href = url;
2256 return anchorEl.href;
2257};
2258
2259});
2260
2261// file: src/common/utils.js
2262define("cordova/utils", function(require, exports, module) {
2263
2264var utils = exports;
2265
2266/**
2267 * Defines a property getter / setter for obj[key].
2268 */
2269utils.defineGetterSetter = function (obj, key, getFunc, opt_setFunc) {
2270 if (Object.defineProperty) {
2271 var desc = {
2272 get: getFunc,
2273 configurable: true
2274 };
2275 if (opt_setFunc) {
2276 desc.set = opt_setFunc;
2277 }
2278 Object.defineProperty(obj, key, desc);
2279 } else {
2280 obj.__defineGetter__(key, getFunc);
2281 if (opt_setFunc) {
2282 obj.__defineSetter__(key, opt_setFunc);
2283 }
2284 }
2285};
2286
2287/**
2288 * Defines a property getter for obj[key].
2289 */
2290utils.defineGetter = utils.defineGetterSetter;
2291
2292utils.arrayIndexOf = function (a, item) {
2293 if (a.indexOf) {
2294 return a.indexOf(item);
2295 }
2296 var len = a.length;
2297 for (var i = 0; i < len; ++i) {
2298 if (a[i] === item) {
2299 return i;
2300 }
2301 }
2302 return -1;
2303};
2304
2305/**
2306 * Returns whether the item was found in the array.
2307 */
2308utils.arrayRemove = function (a, item) {
2309 var index = utils.arrayIndexOf(a, item);
2310 if (index !== -1) {
2311 a.splice(index, 1);
2312 }
2313 return index !== -1;
2314};
2315
2316utils.typeName = function (val) {
2317 return Object.prototype.toString.call(val).slice(8, -1);
2318};
2319
2320/**
2321 * Returns an indication of whether the argument is an array or not
2322 */
2323utils.isArray = Array.isArray ||
2324 function (a) { return utils.typeName(a) === 'Array'; };
2325
2326/**
2327 * Returns an indication of whether the argument is a Date or not
2328 */
2329utils.isDate = function (d) {
2330 return (d instanceof Date);
2331};
2332
2333/**
2334 * Does a deep clone of the object.
2335 */
2336utils.clone = function (obj) {
2337 if (!obj || typeof obj === 'function' || utils.isDate(obj) || typeof obj !== 'object') {
2338 return obj;
2339 }
2340
2341 var retVal, i;
2342
2343 if (utils.isArray(obj)) {
2344 retVal = [];
2345 for (i = 0; i < obj.length; ++i) {
2346 retVal.push(utils.clone(obj[i]));
2347 }
2348 return retVal;
2349 }
2350
2351 retVal = {};
2352 for (i in obj) {
2353 // https://issues.apache.org/jira/browse/CB-11522 'unknown' type may be returned in
2354 // custom protocol activation case on Windows Phone 8.1 causing "No such interface supported" exception
2355 // on cloning.
2356 if ((!(i in retVal) || retVal[i] !== obj[i]) && typeof obj[i] !== 'undefined' && typeof obj[i] !== 'unknown') { // eslint-disable-line valid-typeof
2357 retVal[i] = utils.clone(obj[i]);
2358 }
2359 }
2360 return retVal;
2361};
2362
2363/**
2364 * Returns a wrapped version of the function
2365 */
2366utils.close = function (context, func, params) {
2367 return function () {
2368 var args = params || arguments;
2369 return func.apply(context, args);
2370 };
2371};
2372
2373// ------------------------------------------------------------------------------
2374function UUIDcreatePart (length) {
2375 var uuidpart = '';
2376 for (var i = 0; i < length; i++) {
2377 var uuidchar = parseInt((Math.random() * 256), 10).toString(16);
2378 if (uuidchar.length === 1) {
2379 uuidchar = '0' + uuidchar;
2380 }
2381 uuidpart += uuidchar;
2382 }
2383 return uuidpart;
2384}
2385
2386/**
2387 * Create a UUID
2388 */
2389utils.createUUID = function () {
2390 return UUIDcreatePart(4) + '-' +
2391 UUIDcreatePart(2) + '-' +
2392 UUIDcreatePart(2) + '-' +
2393 UUIDcreatePart(2) + '-' +
2394 UUIDcreatePart(6);
2395};
2396
2397/**
2398 * Extends a child object from a parent object using classical inheritance
2399 * pattern.
2400 */
2401utils.extend = (function () {
2402 // proxy used to establish prototype chain
2403 var F = function () {};
2404 // extend Child from Parent
2405 return function (Child, Parent) {
2406
2407 F.prototype = Parent.prototype;
2408 Child.prototype = new F();
2409 Child.__super__ = Parent.prototype;
2410 Child.prototype.constructor = Child;
2411 };
2412}());
2413
2414/**
2415 * Alerts a message in any available way: alert or console.log.
2416 */
2417utils.alert = function (msg) {
2418 if (window.alert) {
2419 window.alert(msg);
2420 } else if (console && console.log) {
2421 console.log(msg);
2422 }
2423};
2424
2425});
2426
2427window.cordova = require('cordova');
2428// file: src/scripts/bootstrap.js
2429
2430require('cordova/init');
2431
2432})();
\No newline at end of file