Repositorio del curso CCOM4030 el semestre B91 del proyecto Paz para la Mujer

cordova.js 68KB

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