Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

cordova.js 68KB

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