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

cordova.js 64KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935
  1. // Platform: android
  2. // 74fdba8b327b2a13b4366dd141b52def96d4cb56
  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 = '8.1.0';
  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)) { // 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: ../cordova-android/cordova-js-src/android/nativeapiprovider.js
  297. define("cordova/android/nativeapiprovider", function(require, exports, module) {
  298. /**
  299. * Exports the ExposedJsApi.java object if available, otherwise exports the PromptBasedNativeApi.
  300. */
  301. var nativeApi = this._cordovaNative || require('cordova/android/promptbasednativeapi');
  302. var currentApi = nativeApi;
  303. module.exports = {
  304. get: function() { return currentApi; },
  305. setPreferPrompt: function(value) {
  306. currentApi = value ? require('cordova/android/promptbasednativeapi') : nativeApi;
  307. },
  308. // Used only by tests.
  309. set: function(value) {
  310. currentApi = value;
  311. }
  312. };
  313. });
  314. // file: ../cordova-android/cordova-js-src/android/promptbasednativeapi.js
  315. define("cordova/android/promptbasednativeapi", function(require, exports, module) {
  316. /**
  317. * Implements the API of ExposedJsApi.java, but uses prompt() to communicate.
  318. * This is used pre-JellyBean, where addJavascriptInterface() is disabled.
  319. */
  320. module.exports = {
  321. exec: function(bridgeSecret, service, action, callbackId, argsJson) {
  322. return prompt(argsJson, 'gap:'+JSON.stringify([bridgeSecret, service, action, callbackId]));
  323. },
  324. setNativeToJsBridgeMode: function(bridgeSecret, value) {
  325. prompt(value, 'gap_bridge_mode:' + bridgeSecret);
  326. },
  327. retrieveJsMessages: function(bridgeSecret, fromOnlineEvent) {
  328. return prompt(+fromOnlineEvent, 'gap_poll:' + bridgeSecret);
  329. }
  330. };
  331. });
  332. // file: src/common/argscheck.js
  333. define("cordova/argscheck", function(require, exports, module) {
  334. var utils = require('cordova/utils');
  335. var moduleExports = module.exports;
  336. var typeMap = {
  337. 'A': 'Array',
  338. 'D': 'Date',
  339. 'N': 'Number',
  340. 'S': 'String',
  341. 'F': 'Function',
  342. 'O': 'Object'
  343. };
  344. function extractParamName (callee, argIndex) {
  345. return (/\(\s*([^)]*?)\s*\)/).exec(callee)[1].split(/\s*,\s*/)[argIndex];
  346. }
  347. /**
  348. * Checks the given arguments' types and throws if they are not as expected.
  349. *
  350. * `spec` is a string where each character stands for the required type of the
  351. * argument at the same position. In other words: the character at `spec[i]`
  352. * specifies the required type for `args[i]`. The characters in `spec` are the
  353. * first letter of the required type's name. The supported types are:
  354. *
  355. * Array, Date, Number, String, Function, Object
  356. *
  357. * Lowercase characters specify arguments that must not be `null` or `undefined`
  358. * while uppercase characters allow those values to be passed.
  359. *
  360. * Finally, `*` can be used to allow any type at the corresponding position.
  361. *
  362. * @example
  363. * function foo (arr, opts) {
  364. * // require `arr` to be an Array and `opts` an Object, null or undefined
  365. * checkArgs('aO', 'my.package.foo', arguments);
  366. * // ...
  367. * }
  368. * @param {String} spec - the type specification for `args` as described above
  369. * @param {String} functionName - full name of the callee.
  370. * Used in the error message
  371. * @param {Array|arguments} args - the arguments to be checked against `spec`
  372. * @param {Function} [opt_callee=args.callee] - the recipient of `args`.
  373. * Used to extract parameter names for the error message
  374. * @throws {TypeError} if args do not satisfy spec
  375. */
  376. function checkArgs (spec, functionName, args, opt_callee) {
  377. if (!moduleExports.enableChecks) {
  378. return;
  379. }
  380. var errMsg = null;
  381. var typeName;
  382. for (var i = 0; i < spec.length; ++i) {
  383. var c = spec.charAt(i);
  384. var cUpper = c.toUpperCase();
  385. var arg = args[i];
  386. // Asterix means allow anything.
  387. if (c === '*') {
  388. continue;
  389. }
  390. typeName = utils.typeName(arg);
  391. if ((arg === null || arg === undefined) && c === cUpper) {
  392. continue;
  393. }
  394. if (typeName !== typeMap[cUpper]) {
  395. errMsg = 'Expected ' + typeMap[cUpper];
  396. break;
  397. }
  398. }
  399. if (errMsg) {
  400. errMsg += ', but got ' + typeName + '.';
  401. errMsg = 'Wrong type for parameter "' + extractParamName(opt_callee || args.callee, i) + '" of ' + functionName + ': ' + errMsg;
  402. // Don't log when running unit tests.
  403. if (typeof jasmine === 'undefined') {
  404. console.error(errMsg);
  405. }
  406. throw TypeError(errMsg);
  407. }
  408. }
  409. function getValue (value, defaultValue) {
  410. return value === undefined ? defaultValue : value;
  411. }
  412. moduleExports.checkArgs = checkArgs;
  413. moduleExports.getValue = getValue;
  414. moduleExports.enableChecks = true;
  415. });
  416. // file: src/common/base64.js
  417. define("cordova/base64", function(require, exports, module) {
  418. var base64 = exports;
  419. base64.fromArrayBuffer = function (arrayBuffer) {
  420. var array = new Uint8Array(arrayBuffer);
  421. return uint8ToBase64(array);
  422. };
  423. base64.toArrayBuffer = function (str) {
  424. var decodedStr = typeof atob !== 'undefined' ? atob(str) : Buffer.from(str, 'base64').toString('binary'); // eslint-disable-line no-undef
  425. var arrayBuffer = new ArrayBuffer(decodedStr.length);
  426. var array = new Uint8Array(arrayBuffer);
  427. for (var i = 0, len = decodedStr.length; i < len; i++) {
  428. array[i] = decodedStr.charCodeAt(i);
  429. }
  430. return arrayBuffer;
  431. };
  432. // ------------------------------------------------------------------------------
  433. /* This code is based on the performance tests at http://jsperf.com/b64tests
  434. * This 12-bit-at-a-time algorithm was the best performing version on all
  435. * platforms tested.
  436. */
  437. var b64_6bit = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  438. var b64_12bit;
  439. var b64_12bitTable = function () {
  440. b64_12bit = [];
  441. for (var i = 0; i < 64; i++) {
  442. for (var j = 0; j < 64; j++) {
  443. b64_12bit[i * 64 + j] = b64_6bit[i] + b64_6bit[j];
  444. }
  445. }
  446. b64_12bitTable = function () { return b64_12bit; };
  447. return b64_12bit;
  448. };
  449. function uint8ToBase64 (rawData) {
  450. var numBytes = rawData.byteLength;
  451. var output = '';
  452. var segment;
  453. var table = b64_12bitTable();
  454. for (var i = 0; i < numBytes - 2; i += 3) {
  455. segment = (rawData[i] << 16) + (rawData[i + 1] << 8) + rawData[i + 2];
  456. output += table[segment >> 12];
  457. output += table[segment & 0xfff];
  458. }
  459. if (numBytes - i === 2) {
  460. segment = (rawData[i] << 16) + (rawData[i + 1] << 8);
  461. output += table[segment >> 12];
  462. output += b64_6bit[(segment & 0xfff) >> 6];
  463. output += '=';
  464. } else if (numBytes - i === 1) {
  465. segment = (rawData[i] << 16);
  466. output += table[segment >> 12];
  467. output += '==';
  468. }
  469. return output;
  470. }
  471. });
  472. // file: src/common/builder.js
  473. define("cordova/builder", function(require, exports, module) {
  474. var utils = require('cordova/utils');
  475. function each (objects, func, context) {
  476. for (var prop in objects) {
  477. if (objects.hasOwnProperty(prop)) {
  478. func.apply(context, [objects[prop], prop]);
  479. }
  480. }
  481. }
  482. function clobber (obj, key, value) {
  483. exports.replaceHookForTesting(obj, key);
  484. var needsProperty = false;
  485. try {
  486. obj[key] = value;
  487. } catch (e) {
  488. needsProperty = true;
  489. }
  490. // Getters can only be overridden by getters.
  491. if (needsProperty || obj[key] !== value) {
  492. utils.defineGetter(obj, key, function () {
  493. return value;
  494. });
  495. }
  496. }
  497. function assignOrWrapInDeprecateGetter (obj, key, value, message) {
  498. if (message) {
  499. utils.defineGetter(obj, key, function () {
  500. console.log(message);
  501. delete obj[key];
  502. clobber(obj, key, value);
  503. return value;
  504. });
  505. } else {
  506. clobber(obj, key, value);
  507. }
  508. }
  509. function include (parent, objects, clobber, merge) {
  510. each(objects, function (obj, key) {
  511. try {
  512. var result = obj.path ? require(obj.path) : {};
  513. if (clobber) {
  514. // Clobber if it doesn't exist.
  515. if (typeof parent[key] === 'undefined') {
  516. assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
  517. } else if (typeof obj.path !== 'undefined') {
  518. // If merging, merge properties onto parent, otherwise, clobber.
  519. if (merge) {
  520. recursiveMerge(parent[key], result);
  521. } else {
  522. assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
  523. }
  524. }
  525. result = parent[key];
  526. } else {
  527. // Overwrite if not currently defined.
  528. if (typeof parent[key] === 'undefined') {
  529. assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
  530. } else {
  531. // Set result to what already exists, so we can build children into it if they exist.
  532. result = parent[key];
  533. }
  534. }
  535. if (obj.children) {
  536. include(result, obj.children, clobber, merge);
  537. }
  538. } catch (e) {
  539. utils.alert('Exception building Cordova JS globals: ' + e + ' for key "' + key + '"');
  540. }
  541. });
  542. }
  543. /**
  544. * Merge properties from one object onto another recursively. Properties from
  545. * the src object will overwrite existing target property.
  546. *
  547. * @param target Object to merge properties into.
  548. * @param src Object to merge properties from.
  549. */
  550. function recursiveMerge (target, src) {
  551. for (var prop in src) {
  552. if (src.hasOwnProperty(prop)) {
  553. if (target.prototype && target.prototype.constructor === target) {
  554. // If the target object is a constructor override off prototype.
  555. clobber(target.prototype, prop, src[prop]);
  556. } else {
  557. if (typeof src[prop] === 'object' && typeof target[prop] === 'object') {
  558. recursiveMerge(target[prop], src[prop]);
  559. } else {
  560. clobber(target, prop, src[prop]);
  561. }
  562. }
  563. }
  564. }
  565. }
  566. exports.buildIntoButDoNotClobber = function (objects, target) {
  567. include(target, objects, false, false);
  568. };
  569. exports.buildIntoAndClobber = function (objects, target) {
  570. include(target, objects, true, false);
  571. };
  572. exports.buildIntoAndMerge = function (objects, target) {
  573. include(target, objects, true, true);
  574. };
  575. exports.recursiveMerge = recursiveMerge;
  576. exports.assignOrWrapInDeprecateGetter = assignOrWrapInDeprecateGetter;
  577. exports.replaceHookForTesting = function () {};
  578. });
  579. // file: src/common/channel.js
  580. define("cordova/channel", function(require, exports, module) {
  581. var utils = require('cordova/utils');
  582. var nextGuid = 1;
  583. /**
  584. * Custom pub-sub "channel" that can have functions subscribed to it
  585. * This object is used to define and control firing of events for
  586. * cordova initialization, as well as for custom events thereafter.
  587. *
  588. * The order of events during page load and Cordova startup is as follows:
  589. *
  590. * onDOMContentLoaded* Internal event that is received when the web page is loaded and parsed.
  591. * onNativeReady* Internal event that indicates the Cordova native side is ready.
  592. * onCordovaReady* Internal event fired when all Cordova JavaScript objects have been created.
  593. * onDeviceReady* User event fired to indicate that Cordova is ready
  594. * onResume User event fired to indicate a start/resume lifecycle event
  595. * onPause User event fired to indicate a pause lifecycle event
  596. *
  597. * The events marked with an * are sticky. Once they have fired, they will stay in the fired state.
  598. * All listeners that subscribe after the event is fired will be executed right away.
  599. *
  600. * The only Cordova events that user code should register for are:
  601. * deviceready Cordova native code is initialized and Cordova APIs can be called from JavaScript
  602. * pause App has moved to background
  603. * resume App has returned to foreground
  604. *
  605. * Listeners can be registered as:
  606. * document.addEventListener("deviceready", myDeviceReadyListener, false);
  607. * document.addEventListener("resume", myResumeListener, false);
  608. * document.addEventListener("pause", myPauseListener, false);
  609. *
  610. * The DOM lifecycle events should be used for saving and restoring state
  611. * window.onload
  612. * window.onunload
  613. *
  614. */
  615. /**
  616. * Channel
  617. * @constructor
  618. * @param type String the channel name
  619. */
  620. var Channel = function (type, sticky) {
  621. this.type = type;
  622. // Map of guid -> function.
  623. this.handlers = {};
  624. // 0 = Non-sticky, 1 = Sticky non-fired, 2 = Sticky fired.
  625. this.state = sticky ? 1 : 0;
  626. // Used in sticky mode to remember args passed to fire().
  627. this.fireArgs = null;
  628. // Used by onHasSubscribersChange to know if there are any listeners.
  629. this.numHandlers = 0;
  630. // Function that is called when the first listener is subscribed, or when
  631. // the last listener is unsubscribed.
  632. this.onHasSubscribersChange = null;
  633. };
  634. var channel = {
  635. /**
  636. * Calls the provided function only after all of the channels specified
  637. * have been fired. All channels must be sticky channels.
  638. */
  639. join: function (h, c) {
  640. var len = c.length;
  641. var i = len;
  642. var f = function () {
  643. if (!(--i)) h();
  644. };
  645. for (var j = 0; j < len; j++) {
  646. if (c[j].state === 0) {
  647. throw Error('Can only use join with sticky channels.');
  648. }
  649. c[j].subscribe(f);
  650. }
  651. if (!len) h();
  652. },
  653. /* eslint-disable no-return-assign */
  654. create: function (type) {
  655. return channel[type] = new Channel(type, false);
  656. },
  657. createSticky: function (type) {
  658. return channel[type] = new Channel(type, true);
  659. },
  660. /* eslint-enable no-return-assign */
  661. /**
  662. * cordova Channels that must fire before "deviceready" is fired.
  663. */
  664. deviceReadyChannelsArray: [],
  665. deviceReadyChannelsMap: {},
  666. /**
  667. * Indicate that a feature needs to be initialized before it is ready to be used.
  668. * This holds up Cordova's "deviceready" event until the feature has been initialized
  669. * and Cordova.initComplete(feature) is called.
  670. *
  671. * @param feature {String} The unique feature name
  672. */
  673. waitForInitialization: function (feature) {
  674. if (feature) {
  675. var c = channel[feature] || this.createSticky(feature);
  676. this.deviceReadyChannelsMap[feature] = c;
  677. this.deviceReadyChannelsArray.push(c);
  678. }
  679. },
  680. /**
  681. * Indicate that initialization code has completed and the feature is ready to be used.
  682. *
  683. * @param feature {String} The unique feature name
  684. */
  685. initializationComplete: function (feature) {
  686. var c = this.deviceReadyChannelsMap[feature];
  687. if (c) {
  688. c.fire();
  689. }
  690. }
  691. };
  692. function checkSubscriptionArgument (argument) {
  693. if (typeof argument !== 'function' && typeof argument.handleEvent !== 'function') {
  694. throw new Error(
  695. 'Must provide a function or an EventListener object ' +
  696. 'implementing the handleEvent interface.'
  697. );
  698. }
  699. }
  700. /**
  701. * Subscribes the given function to the channel. Any time that
  702. * Channel.fire is called so too will the function.
  703. * Optionally specify an execution context for the function
  704. * and a guid that can be used to stop subscribing to the channel.
  705. * Returns the guid.
  706. */
  707. Channel.prototype.subscribe = function (eventListenerOrFunction, eventListener) {
  708. checkSubscriptionArgument(eventListenerOrFunction);
  709. var handleEvent, guid;
  710. if (eventListenerOrFunction && typeof eventListenerOrFunction === 'object') {
  711. // Received an EventListener object implementing the handleEvent interface
  712. handleEvent = eventListenerOrFunction.handleEvent;
  713. eventListener = eventListenerOrFunction;
  714. } else {
  715. // Received a function to handle event
  716. handleEvent = eventListenerOrFunction;
  717. }
  718. if (this.state === 2) {
  719. handleEvent.apply(eventListener || this, this.fireArgs);
  720. return;
  721. }
  722. guid = eventListenerOrFunction.observer_guid;
  723. if (typeof eventListener === 'object') {
  724. handleEvent = utils.close(eventListener, handleEvent);
  725. }
  726. if (!guid) {
  727. // First time any channel has seen this subscriber
  728. guid = '' + nextGuid++;
  729. }
  730. handleEvent.observer_guid = guid;
  731. eventListenerOrFunction.observer_guid = guid;
  732. // Don't add the same handler more than once.
  733. if (!this.handlers[guid]) {
  734. this.handlers[guid] = handleEvent;
  735. this.numHandlers++;
  736. if (this.numHandlers === 1) {
  737. this.onHasSubscribersChange && this.onHasSubscribersChange();
  738. }
  739. }
  740. };
  741. /**
  742. * Unsubscribes the function with the given guid from the channel.
  743. */
  744. Channel.prototype.unsubscribe = function (eventListenerOrFunction) {
  745. checkSubscriptionArgument(eventListenerOrFunction);
  746. var handleEvent, guid, handler;
  747. if (eventListenerOrFunction && typeof eventListenerOrFunction === 'object') {
  748. // Received an EventListener object implementing the handleEvent interface
  749. handleEvent = eventListenerOrFunction.handleEvent;
  750. } else {
  751. // Received a function to handle event
  752. handleEvent = eventListenerOrFunction;
  753. }
  754. guid = handleEvent.observer_guid;
  755. handler = this.handlers[guid];
  756. if (handler) {
  757. delete this.handlers[guid];
  758. this.numHandlers--;
  759. if (this.numHandlers === 0) {
  760. this.onHasSubscribersChange && this.onHasSubscribersChange();
  761. }
  762. }
  763. };
  764. /**
  765. * Calls all functions subscribed to this channel.
  766. */
  767. Channel.prototype.fire = function (e) {
  768. var fail = false; // eslint-disable-line no-unused-vars
  769. var fireArgs = Array.prototype.slice.call(arguments);
  770. // Apply stickiness.
  771. if (this.state === 1) {
  772. this.state = 2;
  773. this.fireArgs = fireArgs;
  774. }
  775. if (this.numHandlers) {
  776. // Copy the values first so that it is safe to modify it from within
  777. // callbacks.
  778. var toCall = [];
  779. for (var item in this.handlers) {
  780. toCall.push(this.handlers[item]);
  781. }
  782. for (var i = 0; i < toCall.length; ++i) {
  783. toCall[i].apply(this, fireArgs);
  784. }
  785. if (this.state === 2 && this.numHandlers) {
  786. this.numHandlers = 0;
  787. this.handlers = {};
  788. this.onHasSubscribersChange && this.onHasSubscribersChange();
  789. }
  790. }
  791. };
  792. // defining them here so they are ready super fast!
  793. // DOM event that is received when the web page is loaded and parsed.
  794. channel.createSticky('onDOMContentLoaded');
  795. // Event to indicate the Cordova native side is ready.
  796. channel.createSticky('onNativeReady');
  797. // Event to indicate that all Cordova JavaScript objects have been created
  798. // and it's time to run plugin constructors.
  799. channel.createSticky('onCordovaReady');
  800. // Event to indicate that all automatically loaded JS plugins are loaded and ready.
  801. // FIXME remove this
  802. channel.createSticky('onPluginsReady');
  803. // Event to indicate that Cordova is ready
  804. channel.createSticky('onDeviceReady');
  805. // Event to indicate a resume lifecycle event
  806. channel.create('onResume');
  807. // Event to indicate a pause lifecycle event
  808. channel.create('onPause');
  809. // Channels that must fire before "deviceready" is fired.
  810. channel.waitForInitialization('onCordovaReady');
  811. channel.waitForInitialization('onDOMContentLoaded');
  812. module.exports = channel;
  813. });
  814. // file: ../cordova-android/cordova-js-src/exec.js
  815. define("cordova/exec", function(require, exports, module) {
  816. /**
  817. * Execute a cordova command. It is up to the native side whether this action
  818. * is synchronous or asynchronous. The native side can return:
  819. * Synchronous: PluginResult object as a JSON string
  820. * Asynchronous: Empty string ""
  821. * If async, the native side will cordova.callbackSuccess or cordova.callbackError,
  822. * depending upon the result of the action.
  823. *
  824. * @param {Function} success The success callback
  825. * @param {Function} fail The fail callback
  826. * @param {String} service The name of the service to use
  827. * @param {String} action Action to be run in cordova
  828. * @param {String[]} [args] Zero or more arguments to pass to the method
  829. */
  830. var cordova = require('cordova'),
  831. nativeApiProvider = require('cordova/android/nativeapiprovider'),
  832. utils = require('cordova/utils'),
  833. base64 = require('cordova/base64'),
  834. channel = require('cordova/channel'),
  835. jsToNativeModes = {
  836. PROMPT: 0,
  837. JS_OBJECT: 1
  838. },
  839. nativeToJsModes = {
  840. // Polls for messages using the JS->Native bridge.
  841. POLLING: 0,
  842. // For LOAD_URL to be viable, it would need to have a work-around for
  843. // the bug where the soft-keyboard gets dismissed when a message is sent.
  844. LOAD_URL: 1,
  845. // For the ONLINE_EVENT to be viable, it would need to intercept all event
  846. // listeners (both through addEventListener and window.ononline) as well
  847. // as set the navigator property itself.
  848. ONLINE_EVENT: 2,
  849. EVAL_BRIDGE: 3
  850. },
  851. jsToNativeBridgeMode, // Set lazily.
  852. nativeToJsBridgeMode = nativeToJsModes.EVAL_BRIDGE,
  853. pollEnabled = false,
  854. bridgeSecret = -1;
  855. var messagesFromNative = [];
  856. var isProcessing = false;
  857. var resolvedPromise = typeof Promise == 'undefined' ? null : Promise.resolve();
  858. var nextTick = resolvedPromise ? function(fn) { resolvedPromise.then(fn); } : function(fn) { setTimeout(fn); };
  859. function androidExec(success, fail, service, action, args) {
  860. if (bridgeSecret < 0) {
  861. // If we ever catch this firing, we'll need to queue up exec()s
  862. // and fire them once we get a secret. For now, I don't think
  863. // it's possible for exec() to be called since plugins are parsed but
  864. // not run until until after onNativeReady.
  865. throw new Error('exec() called without bridgeSecret');
  866. }
  867. // Set default bridge modes if they have not already been set.
  868. // By default, we use the failsafe, since addJavascriptInterface breaks too often
  869. if (jsToNativeBridgeMode === undefined) {
  870. androidExec.setJsToNativeBridgeMode(jsToNativeModes.JS_OBJECT);
  871. }
  872. // If args is not provided, default to an empty array
  873. args = args || [];
  874. // Process any ArrayBuffers in the args into a string.
  875. for (var i = 0; i < args.length; i++) {
  876. if (utils.typeName(args[i]) == 'ArrayBuffer') {
  877. args[i] = base64.fromArrayBuffer(args[i]);
  878. }
  879. }
  880. var callbackId = service + cordova.callbackId++,
  881. argsJson = JSON.stringify(args);
  882. if (success || fail) {
  883. cordova.callbacks[callbackId] = {success:success, fail:fail};
  884. }
  885. var msgs = nativeApiProvider.get().exec(bridgeSecret, service, action, callbackId, argsJson);
  886. // If argsJson was received by Java as null, try again with the PROMPT bridge mode.
  887. // This happens in rare circumstances, such as when certain Unicode characters are passed over the bridge on a Galaxy S2. See CB-2666.
  888. if (jsToNativeBridgeMode == jsToNativeModes.JS_OBJECT && msgs === "@Null arguments.") {
  889. androidExec.setJsToNativeBridgeMode(jsToNativeModes.PROMPT);
  890. androidExec(success, fail, service, action, args);
  891. androidExec.setJsToNativeBridgeMode(jsToNativeModes.JS_OBJECT);
  892. } else if (msgs) {
  893. messagesFromNative.push(msgs);
  894. // Always process async to avoid exceptions messing up stack.
  895. nextTick(processMessages);
  896. }
  897. }
  898. androidExec.init = function() {
  899. bridgeSecret = +prompt('', 'gap_init:' + nativeToJsBridgeMode);
  900. channel.onNativeReady.fire();
  901. };
  902. function pollOnceFromOnlineEvent() {
  903. pollOnce(true);
  904. }
  905. function pollOnce(opt_fromOnlineEvent) {
  906. if (bridgeSecret < 0) {
  907. // This can happen when the NativeToJsMessageQueue resets the online state on page transitions.
  908. // We know there's nothing to retrieve, so no need to poll.
  909. return;
  910. }
  911. var msgs = nativeApiProvider.get().retrieveJsMessages(bridgeSecret, !!opt_fromOnlineEvent);
  912. if (msgs) {
  913. messagesFromNative.push(msgs);
  914. // Process sync since we know we're already top-of-stack.
  915. processMessages();
  916. }
  917. }
  918. function pollingTimerFunc() {
  919. if (pollEnabled) {
  920. pollOnce();
  921. setTimeout(pollingTimerFunc, 50);
  922. }
  923. }
  924. function hookOnlineApis() {
  925. function proxyEvent(e) {
  926. cordova.fireWindowEvent(e.type);
  927. }
  928. // The network module takes care of firing online and offline events.
  929. // It currently fires them only on document though, so we bridge them
  930. // to window here (while first listening for exec()-releated online/offline
  931. // events).
  932. window.addEventListener('online', pollOnceFromOnlineEvent, false);
  933. window.addEventListener('offline', pollOnceFromOnlineEvent, false);
  934. cordova.addWindowEventHandler('online');
  935. cordova.addWindowEventHandler('offline');
  936. document.addEventListener('online', proxyEvent, false);
  937. document.addEventListener('offline', proxyEvent, false);
  938. }
  939. hookOnlineApis();
  940. androidExec.jsToNativeModes = jsToNativeModes;
  941. androidExec.nativeToJsModes = nativeToJsModes;
  942. androidExec.setJsToNativeBridgeMode = function(mode) {
  943. if (mode == jsToNativeModes.JS_OBJECT && !window._cordovaNative) {
  944. mode = jsToNativeModes.PROMPT;
  945. }
  946. nativeApiProvider.setPreferPrompt(mode == jsToNativeModes.PROMPT);
  947. jsToNativeBridgeMode = mode;
  948. };
  949. androidExec.setNativeToJsBridgeMode = function(mode) {
  950. if (mode == nativeToJsBridgeMode) {
  951. return;
  952. }
  953. if (nativeToJsBridgeMode == nativeToJsModes.POLLING) {
  954. pollEnabled = false;
  955. }
  956. nativeToJsBridgeMode = mode;
  957. // Tell the native side to switch modes.
  958. // Otherwise, it will be set by androidExec.init()
  959. if (bridgeSecret >= 0) {
  960. nativeApiProvider.get().setNativeToJsBridgeMode(bridgeSecret, mode);
  961. }
  962. if (mode == nativeToJsModes.POLLING) {
  963. pollEnabled = true;
  964. setTimeout(pollingTimerFunc, 1);
  965. }
  966. };
  967. function buildPayload(payload, message) {
  968. var payloadKind = message.charAt(0);
  969. if (payloadKind == 's') {
  970. payload.push(message.slice(1));
  971. } else if (payloadKind == 't') {
  972. payload.push(true);
  973. } else if (payloadKind == 'f') {
  974. payload.push(false);
  975. } else if (payloadKind == 'N') {
  976. payload.push(null);
  977. } else if (payloadKind == 'n') {
  978. payload.push(+message.slice(1));
  979. } else if (payloadKind == 'A') {
  980. var data = message.slice(1);
  981. payload.push(base64.toArrayBuffer(data));
  982. } else if (payloadKind == 'S') {
  983. payload.push(window.atob(message.slice(1)));
  984. } else if (payloadKind == 'M') {
  985. var multipartMessages = message.slice(1);
  986. while (multipartMessages !== "") {
  987. var spaceIdx = multipartMessages.indexOf(' ');
  988. var msgLen = +multipartMessages.slice(0, spaceIdx);
  989. var multipartMessage = multipartMessages.substr(spaceIdx + 1, msgLen);
  990. multipartMessages = multipartMessages.slice(spaceIdx + msgLen + 1);
  991. buildPayload(payload, multipartMessage);
  992. }
  993. } else {
  994. payload.push(JSON.parse(message));
  995. }
  996. }
  997. // Processes a single message, as encoded by NativeToJsMessageQueue.java.
  998. function processMessage(message) {
  999. var firstChar = message.charAt(0);
  1000. if (firstChar == 'J') {
  1001. // This is deprecated on the .java side. It doesn't work with CSP enabled.
  1002. eval(message.slice(1));
  1003. } else if (firstChar == 'S' || firstChar == 'F') {
  1004. var success = firstChar == 'S';
  1005. var keepCallback = message.charAt(1) == '1';
  1006. var spaceIdx = message.indexOf(' ', 2);
  1007. var status = +message.slice(2, spaceIdx);
  1008. var nextSpaceIdx = message.indexOf(' ', spaceIdx + 1);
  1009. var callbackId = message.slice(spaceIdx + 1, nextSpaceIdx);
  1010. var payloadMessage = message.slice(nextSpaceIdx + 1);
  1011. var payload = [];
  1012. buildPayload(payload, payloadMessage);
  1013. cordova.callbackFromNative(callbackId, success, status, payload, keepCallback);
  1014. } else {
  1015. console.log("processMessage failed: invalid message: " + JSON.stringify(message));
  1016. }
  1017. }
  1018. function processMessages() {
  1019. // Check for the reentrant case.
  1020. if (isProcessing) {
  1021. return;
  1022. }
  1023. if (messagesFromNative.length === 0) {
  1024. return;
  1025. }
  1026. isProcessing = true;
  1027. try {
  1028. var msg = popMessageFromQueue();
  1029. // The Java side can send a * message to indicate that it
  1030. // still has messages waiting to be retrieved.
  1031. if (msg == '*' && messagesFromNative.length === 0) {
  1032. nextTick(pollOnce);
  1033. return;
  1034. }
  1035. processMessage(msg);
  1036. } finally {
  1037. isProcessing = false;
  1038. if (messagesFromNative.length > 0) {
  1039. nextTick(processMessages);
  1040. }
  1041. }
  1042. }
  1043. function popMessageFromQueue() {
  1044. var messageBatch = messagesFromNative.shift();
  1045. if (messageBatch == '*') {
  1046. return '*';
  1047. }
  1048. var spaceIdx = messageBatch.indexOf(' ');
  1049. var msgLen = +messageBatch.slice(0, spaceIdx);
  1050. var message = messageBatch.substr(spaceIdx + 1, msgLen);
  1051. messageBatch = messageBatch.slice(spaceIdx + msgLen + 1);
  1052. if (messageBatch) {
  1053. messagesFromNative.unshift(messageBatch);
  1054. }
  1055. return message;
  1056. }
  1057. module.exports = androidExec;
  1058. });
  1059. // file: src/common/exec/proxy.js
  1060. define("cordova/exec/proxy", function(require, exports, module) {
  1061. // internal map of proxy function
  1062. var CommandProxyMap = {};
  1063. module.exports = {
  1064. // example: cordova.commandProxy.add("Accelerometer",{getCurrentAcceleration: function(successCallback, errorCallback, options) {...},...);
  1065. add: function (id, proxyObj) {
  1066. console.log('adding proxy for ' + id);
  1067. CommandProxyMap[id] = proxyObj;
  1068. return proxyObj;
  1069. },
  1070. // cordova.commandProxy.remove("Accelerometer");
  1071. remove: function (id) {
  1072. var proxy = CommandProxyMap[id];
  1073. delete CommandProxyMap[id];
  1074. CommandProxyMap[id] = null;
  1075. return proxy;
  1076. },
  1077. get: function (service, action) {
  1078. return (CommandProxyMap[service] ? CommandProxyMap[service][action] : null);
  1079. }
  1080. };
  1081. });
  1082. // file: src/common/init.js
  1083. define("cordova/init", function(require, exports, module) {
  1084. var channel = require('cordova/channel');
  1085. var cordova = require('cordova');
  1086. var modulemapper = require('cordova/modulemapper');
  1087. var platform = require('cordova/platform');
  1088. var pluginloader = require('cordova/pluginloader');
  1089. var utils = require('cordova/utils');
  1090. var platformInitChannelsArray = [channel.onNativeReady, channel.onPluginsReady];
  1091. function logUnfiredChannels (arr) {
  1092. for (var i = 0; i < arr.length; ++i) {
  1093. if (arr[i].state !== 2) {
  1094. console.log('Channel not fired: ' + arr[i].type);
  1095. }
  1096. }
  1097. }
  1098. window.setTimeout(function () {
  1099. if (channel.onDeviceReady.state !== 2) {
  1100. console.log('deviceready has not fired after 5 seconds.');
  1101. logUnfiredChannels(platformInitChannelsArray);
  1102. logUnfiredChannels(channel.deviceReadyChannelsArray);
  1103. }
  1104. }, 5000);
  1105. // Replace navigator before any modules are required(), to ensure it happens as soon as possible.
  1106. // We replace it so that properties that can't be clobbered can instead be overridden.
  1107. function replaceNavigator (origNavigator) {
  1108. var CordovaNavigator = function () {};
  1109. CordovaNavigator.prototype = origNavigator;
  1110. var newNavigator = new CordovaNavigator();
  1111. // This work-around really only applies to new APIs that are newer than Function.bind.
  1112. // Without it, APIs such as getGamepads() break.
  1113. if (CordovaNavigator.bind) {
  1114. for (var key in origNavigator) {
  1115. if (typeof origNavigator[key] === 'function') {
  1116. newNavigator[key] = origNavigator[key].bind(origNavigator);
  1117. } else {
  1118. (function (k) {
  1119. utils.defineGetterSetter(newNavigator, key, function () {
  1120. return origNavigator[k];
  1121. });
  1122. })(key);
  1123. }
  1124. }
  1125. }
  1126. return newNavigator;
  1127. }
  1128. if (window.navigator) {
  1129. window.navigator = replaceNavigator(window.navigator);
  1130. }
  1131. if (!window.console) {
  1132. window.console = {
  1133. log: function () {}
  1134. };
  1135. }
  1136. if (!window.console.warn) {
  1137. window.console.warn = function (msg) {
  1138. this.log('warn: ' + msg);
  1139. };
  1140. }
  1141. // Register pause, resume and deviceready channels as events on document.
  1142. channel.onPause = cordova.addDocumentEventHandler('pause');
  1143. channel.onResume = cordova.addDocumentEventHandler('resume');
  1144. channel.onActivated = cordova.addDocumentEventHandler('activated');
  1145. channel.onDeviceReady = cordova.addStickyDocumentEventHandler('deviceready');
  1146. // Listen for DOMContentLoaded and notify our channel subscribers.
  1147. if (document.readyState === 'complete' || document.readyState === 'interactive') {
  1148. channel.onDOMContentLoaded.fire();
  1149. } else {
  1150. document.addEventListener('DOMContentLoaded', function () {
  1151. channel.onDOMContentLoaded.fire();
  1152. }, false);
  1153. }
  1154. // _nativeReady is global variable that the native side can set
  1155. // to signify that the native code is ready. It is a global since
  1156. // it may be called before any cordova JS is ready.
  1157. if (window._nativeReady) {
  1158. channel.onNativeReady.fire();
  1159. }
  1160. modulemapper.clobbers('cordova', 'cordova');
  1161. modulemapper.clobbers('cordova/exec', 'cordova.exec');
  1162. modulemapper.clobbers('cordova/exec', 'Cordova.exec');
  1163. // Call the platform-specific initialization.
  1164. platform.bootstrap && platform.bootstrap();
  1165. // Wrap in a setTimeout to support the use-case of having plugin JS appended to cordova.js.
  1166. // The delay allows the attached modules to be defined before the plugin loader looks for them.
  1167. setTimeout(function () {
  1168. pluginloader.load(function () {
  1169. channel.onPluginsReady.fire();
  1170. });
  1171. }, 0);
  1172. /**
  1173. * Create all cordova objects once native side is ready.
  1174. */
  1175. channel.join(function () {
  1176. modulemapper.mapModules(window);
  1177. platform.initialize && platform.initialize();
  1178. // Fire event to notify that all objects are created
  1179. channel.onCordovaReady.fire();
  1180. // Fire onDeviceReady event once page has fully loaded, all
  1181. // constructors have run and cordova info has been received from native
  1182. // side.
  1183. channel.join(function () {
  1184. require('cordova').fireDocumentEvent('deviceready');
  1185. }, channel.deviceReadyChannelsArray);
  1186. }, platformInitChannelsArray);
  1187. });
  1188. // file: src/common/modulemapper.js
  1189. define("cordova/modulemapper", function(require, exports, module) {
  1190. var builder = require('cordova/builder');
  1191. var moduleMap = define.moduleMap; // eslint-disable-line no-undef
  1192. var symbolList;
  1193. var deprecationMap;
  1194. exports.reset = function () {
  1195. symbolList = [];
  1196. deprecationMap = {};
  1197. };
  1198. function addEntry (strategy, moduleName, symbolPath, opt_deprecationMessage) {
  1199. if (!(moduleName in moduleMap)) {
  1200. throw new Error('Module ' + moduleName + ' does not exist.');
  1201. }
  1202. symbolList.push(strategy, moduleName, symbolPath);
  1203. if (opt_deprecationMessage) {
  1204. deprecationMap[symbolPath] = opt_deprecationMessage;
  1205. }
  1206. }
  1207. // Note: Android 2.3 does have Function.bind().
  1208. exports.clobbers = function (moduleName, symbolPath, opt_deprecationMessage) {
  1209. addEntry('c', moduleName, symbolPath, opt_deprecationMessage);
  1210. };
  1211. exports.merges = function (moduleName, symbolPath, opt_deprecationMessage) {
  1212. addEntry('m', moduleName, symbolPath, opt_deprecationMessage);
  1213. };
  1214. exports.defaults = function (moduleName, symbolPath, opt_deprecationMessage) {
  1215. addEntry('d', moduleName, symbolPath, opt_deprecationMessage);
  1216. };
  1217. exports.runs = function (moduleName) {
  1218. addEntry('r', moduleName, null);
  1219. };
  1220. function prepareNamespace (symbolPath, context) {
  1221. if (!symbolPath) {
  1222. return context;
  1223. }
  1224. var parts = symbolPath.split('.');
  1225. var cur = context;
  1226. for (var i = 0, part; part = parts[i]; ++i) { // eslint-disable-line no-cond-assign
  1227. cur = cur[part] = cur[part] || {};
  1228. }
  1229. return cur;
  1230. }
  1231. exports.mapModules = function (context) {
  1232. var origSymbols = {};
  1233. context.CDV_origSymbols = origSymbols;
  1234. for (var i = 0, len = symbolList.length; i < len; i += 3) {
  1235. var strategy = symbolList[i];
  1236. var moduleName = symbolList[i + 1];
  1237. var module = require(moduleName);
  1238. // <runs/>
  1239. if (strategy === 'r') {
  1240. continue;
  1241. }
  1242. var symbolPath = symbolList[i + 2];
  1243. var lastDot = symbolPath.lastIndexOf('.');
  1244. var namespace = symbolPath.substr(0, lastDot);
  1245. var lastName = symbolPath.substr(lastDot + 1);
  1246. var deprecationMsg = symbolPath in deprecationMap ? 'Access made to deprecated symbol: ' + symbolPath + '. ' + deprecationMsg : null;
  1247. var parentObj = prepareNamespace(namespace, context);
  1248. var target = parentObj[lastName];
  1249. if (strategy === 'm' && target) {
  1250. builder.recursiveMerge(target, module);
  1251. } else if ((strategy === 'd' && !target) || (strategy !== 'd')) {
  1252. if (!(symbolPath in origSymbols)) {
  1253. origSymbols[symbolPath] = target;
  1254. }
  1255. builder.assignOrWrapInDeprecateGetter(parentObj, lastName, module, deprecationMsg);
  1256. }
  1257. }
  1258. };
  1259. exports.getOriginalSymbol = function (context, symbolPath) {
  1260. var origSymbols = context.CDV_origSymbols;
  1261. if (origSymbols && (symbolPath in origSymbols)) {
  1262. return origSymbols[symbolPath];
  1263. }
  1264. var parts = symbolPath.split('.');
  1265. var obj = context;
  1266. for (var i = 0; i < parts.length; ++i) {
  1267. obj = obj && obj[parts[i]];
  1268. }
  1269. return obj;
  1270. };
  1271. exports.reset();
  1272. });
  1273. // file: ../cordova-android/cordova-js-src/platform.js
  1274. define("cordova/platform", function(require, exports, module) {
  1275. // The last resume event that was received that had the result of a plugin call.
  1276. var lastResumeEvent = null;
  1277. module.exports = {
  1278. id: 'android',
  1279. bootstrap: function() {
  1280. var channel = require('cordova/channel'),
  1281. cordova = require('cordova'),
  1282. exec = require('cordova/exec'),
  1283. modulemapper = require('cordova/modulemapper');
  1284. // Get the shared secret needed to use the bridge.
  1285. exec.init();
  1286. // TODO: Extract this as a proper plugin.
  1287. modulemapper.clobbers('cordova/plugin/android/app', 'navigator.app');
  1288. var APP_PLUGIN_NAME = Number(cordova.platformVersion.split('.')[0]) >= 4 ? 'CoreAndroid' : 'App';
  1289. // Inject a listener for the backbutton on the document.
  1290. var backButtonChannel = cordova.addDocumentEventHandler('backbutton');
  1291. backButtonChannel.onHasSubscribersChange = function() {
  1292. // If we just attached the first handler or detached the last handler,
  1293. // let native know we need to override the back button.
  1294. exec(null, null, APP_PLUGIN_NAME, "overrideBackbutton", [this.numHandlers == 1]);
  1295. };
  1296. // Add hardware MENU and SEARCH button handlers
  1297. cordova.addDocumentEventHandler('menubutton');
  1298. cordova.addDocumentEventHandler('searchbutton');
  1299. function bindButtonChannel(buttonName) {
  1300. // generic button bind used for volumeup/volumedown buttons
  1301. var volumeButtonChannel = cordova.addDocumentEventHandler(buttonName + 'button');
  1302. volumeButtonChannel.onHasSubscribersChange = function() {
  1303. exec(null, null, APP_PLUGIN_NAME, "overrideButton", [buttonName, this.numHandlers == 1]);
  1304. };
  1305. }
  1306. // Inject a listener for the volume buttons on the document.
  1307. bindButtonChannel('volumeup');
  1308. bindButtonChannel('volumedown');
  1309. // The resume event is not "sticky", but it is possible that the event
  1310. // will contain the result of a plugin call. We need to ensure that the
  1311. // plugin result is delivered even after the event is fired (CB-10498)
  1312. var cordovaAddEventListener = document.addEventListener;
  1313. document.addEventListener = function(evt, handler, capture) {
  1314. cordovaAddEventListener(evt, handler, capture);
  1315. if (evt === 'resume' && lastResumeEvent) {
  1316. handler(lastResumeEvent);
  1317. }
  1318. };
  1319. // Let native code know we are all done on the JS side.
  1320. // Native code will then un-hide the WebView.
  1321. channel.onCordovaReady.subscribe(function() {
  1322. exec(onMessageFromNative, null, APP_PLUGIN_NAME, 'messageChannel', []);
  1323. exec(null, null, APP_PLUGIN_NAME, "show", []);
  1324. });
  1325. }
  1326. };
  1327. function onMessageFromNative(msg) {
  1328. var cordova = require('cordova');
  1329. var action = msg.action;
  1330. switch (action)
  1331. {
  1332. // Button events
  1333. case 'backbutton':
  1334. case 'menubutton':
  1335. case 'searchbutton':
  1336. // App life cycle events
  1337. case 'pause':
  1338. // Volume events
  1339. case 'volumedownbutton':
  1340. case 'volumeupbutton':
  1341. cordova.fireDocumentEvent(action);
  1342. break;
  1343. case 'resume':
  1344. if(arguments.length > 1 && msg.pendingResult) {
  1345. if(arguments.length === 2) {
  1346. msg.pendingResult.result = arguments[1];
  1347. } else {
  1348. // The plugin returned a multipart message
  1349. var res = [];
  1350. for(var i = 1; i < arguments.length; i++) {
  1351. res.push(arguments[i]);
  1352. }
  1353. msg.pendingResult.result = res;
  1354. }
  1355. // Save the plugin result so that it can be delivered to the js
  1356. // even if they miss the initial firing of the event
  1357. lastResumeEvent = msg;
  1358. }
  1359. cordova.fireDocumentEvent(action, msg);
  1360. break;
  1361. default:
  1362. throw new Error('Unknown event action ' + action);
  1363. }
  1364. }
  1365. });
  1366. // file: ../cordova-android/cordova-js-src/plugin/android/app.js
  1367. define("cordova/plugin/android/app", function(require, exports, module) {
  1368. var exec = require('cordova/exec');
  1369. var APP_PLUGIN_NAME = Number(require('cordova').platformVersion.split('.')[0]) >= 4 ? 'CoreAndroid' : 'App';
  1370. module.exports = {
  1371. /**
  1372. * Clear the resource cache.
  1373. */
  1374. clearCache:function() {
  1375. exec(null, null, APP_PLUGIN_NAME, "clearCache", []);
  1376. },
  1377. /**
  1378. * Load the url into the webview or into new browser instance.
  1379. *
  1380. * @param url The URL to load
  1381. * @param props Properties that can be passed in to the activity:
  1382. * wait: int => wait msec before loading URL
  1383. * loadingDialog: "Title,Message" => display a native loading dialog
  1384. * loadUrlTimeoutValue: int => time in msec to wait before triggering a timeout error
  1385. * clearHistory: boolean => clear webview history (default=false)
  1386. * openExternal: boolean => open in a new browser (default=false)
  1387. *
  1388. * Example:
  1389. * navigator.app.loadUrl("http://server/myapp/index.html", {wait:2000, loadingDialog:"Wait,Loading App", loadUrlTimeoutValue: 60000});
  1390. */
  1391. loadUrl:function(url, props) {
  1392. exec(null, null, APP_PLUGIN_NAME, "loadUrl", [url, props]);
  1393. },
  1394. /**
  1395. * Cancel loadUrl that is waiting to be loaded.
  1396. */
  1397. cancelLoadUrl:function() {
  1398. exec(null, null, APP_PLUGIN_NAME, "cancelLoadUrl", []);
  1399. },
  1400. /**
  1401. * Clear web history in this web view.
  1402. * Instead of BACK button loading the previous web page, it will exit the app.
  1403. */
  1404. clearHistory:function() {
  1405. exec(null, null, APP_PLUGIN_NAME, "clearHistory", []);
  1406. },
  1407. /**
  1408. * Go to previous page displayed.
  1409. * This is the same as pressing the backbutton on Android device.
  1410. */
  1411. backHistory:function() {
  1412. exec(null, null, APP_PLUGIN_NAME, "backHistory", []);
  1413. },
  1414. /**
  1415. * Override the default behavior of the Android back button.
  1416. * If overridden, when the back button is pressed, the "backKeyDown" JavaScript event will be fired.
  1417. *
  1418. * Note: The user should not have to call this method. Instead, when the user
  1419. * registers for the "backbutton" event, this is automatically done.
  1420. *
  1421. * @param override T=override, F=cancel override
  1422. */
  1423. overrideBackbutton:function(override) {
  1424. exec(null, null, APP_PLUGIN_NAME, "overrideBackbutton", [override]);
  1425. },
  1426. /**
  1427. * Override the default behavior of the Android volume button.
  1428. * If overridden, when the volume button is pressed, the "volume[up|down]button"
  1429. * JavaScript event will be fired.
  1430. *
  1431. * Note: The user should not have to call this method. Instead, when the user
  1432. * registers for the "volume[up|down]button" event, this is automatically done.
  1433. *
  1434. * @param button volumeup, volumedown
  1435. * @param override T=override, F=cancel override
  1436. */
  1437. overrideButton:function(button, override) {
  1438. exec(null, null, APP_PLUGIN_NAME, "overrideButton", [button, override]);
  1439. },
  1440. /**
  1441. * Exit and terminate the application.
  1442. */
  1443. exitApp:function() {
  1444. return exec(null, null, APP_PLUGIN_NAME, "exitApp", []);
  1445. }
  1446. };
  1447. });
  1448. // file: src/common/pluginloader.js
  1449. define("cordova/pluginloader", function(require, exports, module) {
  1450. var modulemapper = require('cordova/modulemapper');
  1451. // Helper function to inject a <script> tag.
  1452. // Exported for testing.
  1453. exports.injectScript = function (url, onload, onerror) {
  1454. var script = document.createElement('script');
  1455. // onload fires even when script fails loads with an error.
  1456. script.onload = onload;
  1457. // onerror fires for malformed URLs.
  1458. script.onerror = onerror;
  1459. script.src = url;
  1460. document.head.appendChild(script);
  1461. };
  1462. function injectIfNecessary (id, url, onload, onerror) {
  1463. onerror = onerror || onload;
  1464. if (id in define.moduleMap) { // eslint-disable-line no-undef
  1465. onload();
  1466. } else {
  1467. exports.injectScript(url, function () {
  1468. if (id in define.moduleMap) { // eslint-disable-line no-undef
  1469. onload();
  1470. } else {
  1471. onerror();
  1472. }
  1473. }, onerror);
  1474. }
  1475. }
  1476. function onScriptLoadingComplete (moduleList, finishPluginLoading) {
  1477. // Loop through all the plugins and then through their clobbers and merges.
  1478. for (var i = 0, module; module = moduleList[i]; i++) { // eslint-disable-line no-cond-assign
  1479. if (module.clobbers && module.clobbers.length) {
  1480. for (var j = 0; j < module.clobbers.length; j++) {
  1481. modulemapper.clobbers(module.id, module.clobbers[j]);
  1482. }
  1483. }
  1484. if (module.merges && module.merges.length) {
  1485. for (var k = 0; k < module.merges.length; k++) {
  1486. modulemapper.merges(module.id, module.merges[k]);
  1487. }
  1488. }
  1489. // Finally, if runs is truthy we want to simply require() the module.
  1490. if (module.runs) {
  1491. modulemapper.runs(module.id);
  1492. }
  1493. }
  1494. finishPluginLoading();
  1495. }
  1496. // Handler for the cordova_plugins.js content.
  1497. // See plugman's plugin_loader.js for the details of this object.
  1498. // This function is only called if the really is a plugins array that isn't empty.
  1499. // Otherwise the onerror response handler will just call finishPluginLoading().
  1500. function handlePluginsObject (path, moduleList, finishPluginLoading) {
  1501. // Now inject the scripts.
  1502. var scriptCounter = moduleList.length;
  1503. if (!scriptCounter) {
  1504. finishPluginLoading();
  1505. return;
  1506. }
  1507. function scriptLoadedCallback () {
  1508. if (!--scriptCounter) {
  1509. onScriptLoadingComplete(moduleList, finishPluginLoading);
  1510. }
  1511. }
  1512. for (var i = 0; i < moduleList.length; i++) {
  1513. injectIfNecessary(moduleList[i].id, path + moduleList[i].file, scriptLoadedCallback);
  1514. }
  1515. }
  1516. function findCordovaPath () {
  1517. var path = null;
  1518. var scripts = document.getElementsByTagName('script');
  1519. var term = '/cordova.js';
  1520. for (var n = scripts.length - 1; n > -1; n--) {
  1521. var src = scripts[n].src.replace(/\?.*$/, ''); // Strip any query param (CB-6007).
  1522. if (src.indexOf(term) === (src.length - term.length)) {
  1523. path = src.substring(0, src.length - term.length) + '/';
  1524. break;
  1525. }
  1526. }
  1527. return path;
  1528. }
  1529. // Tries to load all plugins' js-modules.
  1530. // This is an async process, but onDeviceReady is blocked on onPluginsReady.
  1531. // onPluginsReady is fired when there are no plugins to load, or they are all done.
  1532. exports.load = function (callback) {
  1533. var pathPrefix = findCordovaPath();
  1534. if (pathPrefix === null) {
  1535. console.log('Could not find cordova.js script tag. Plugin loading may fail.');
  1536. pathPrefix = '';
  1537. }
  1538. injectIfNecessary('cordova/plugin_list', pathPrefix + 'cordova_plugins.js', function () {
  1539. var moduleList = require('cordova/plugin_list');
  1540. handlePluginsObject(pathPrefix, moduleList, callback);
  1541. }, callback);
  1542. };
  1543. });
  1544. // file: src/common/urlutil.js
  1545. define("cordova/urlutil", function(require, exports, module) {
  1546. /**
  1547. * For already absolute URLs, returns what is passed in.
  1548. * For relative URLs, converts them to absolute ones.
  1549. */
  1550. exports.makeAbsolute = function makeAbsolute (url) {
  1551. var anchorEl = document.createElement('a');
  1552. anchorEl.href = url;
  1553. return anchorEl.href;
  1554. };
  1555. });
  1556. // file: src/common/utils.js
  1557. define("cordova/utils", function(require, exports, module) {
  1558. var utils = exports;
  1559. /**
  1560. * Defines a property getter / setter for obj[key].
  1561. */
  1562. utils.defineGetterSetter = function (obj, key, getFunc, opt_setFunc) {
  1563. if (Object.defineProperty) {
  1564. var desc = {
  1565. get: getFunc,
  1566. configurable: true
  1567. };
  1568. if (opt_setFunc) {
  1569. desc.set = opt_setFunc;
  1570. }
  1571. Object.defineProperty(obj, key, desc);
  1572. } else {
  1573. obj.__defineGetter__(key, getFunc);
  1574. if (opt_setFunc) {
  1575. obj.__defineSetter__(key, opt_setFunc);
  1576. }
  1577. }
  1578. };
  1579. /**
  1580. * Defines a property getter for obj[key].
  1581. */
  1582. utils.defineGetter = utils.defineGetterSetter;
  1583. utils.arrayIndexOf = function (a, item) {
  1584. if (a.indexOf) {
  1585. return a.indexOf(item);
  1586. }
  1587. var len = a.length;
  1588. for (var i = 0; i < len; ++i) {
  1589. if (a[i] === item) {
  1590. return i;
  1591. }
  1592. }
  1593. return -1;
  1594. };
  1595. /**
  1596. * Returns whether the item was found in the array.
  1597. */
  1598. utils.arrayRemove = function (a, item) {
  1599. var index = utils.arrayIndexOf(a, item);
  1600. if (index !== -1) {
  1601. a.splice(index, 1);
  1602. }
  1603. return index !== -1;
  1604. };
  1605. utils.typeName = function (val) {
  1606. return Object.prototype.toString.call(val).slice(8, -1);
  1607. };
  1608. /**
  1609. * Returns an indication of whether the argument is an array or not
  1610. */
  1611. utils.isArray = Array.isArray ||
  1612. function (a) { return utils.typeName(a) === 'Array'; };
  1613. /**
  1614. * Returns an indication of whether the argument is a Date or not
  1615. */
  1616. utils.isDate = function (d) {
  1617. return (d instanceof Date);
  1618. };
  1619. /**
  1620. * Does a deep clone of the object.
  1621. */
  1622. utils.clone = function (obj) {
  1623. if (!obj || typeof obj === 'function' || utils.isDate(obj) || typeof obj !== 'object') {
  1624. return obj;
  1625. }
  1626. var retVal, i;
  1627. if (utils.isArray(obj)) {
  1628. retVal = [];
  1629. for (i = 0; i < obj.length; ++i) {
  1630. retVal.push(utils.clone(obj[i]));
  1631. }
  1632. return retVal;
  1633. }
  1634. retVal = {};
  1635. for (i in obj) {
  1636. // https://issues.apache.org/jira/browse/CB-11522 'unknown' type may be returned in
  1637. // custom protocol activation case on Windows Phone 8.1 causing "No such interface supported" exception
  1638. // on cloning.
  1639. if ((!(i in retVal) || retVal[i] !== obj[i]) && typeof obj[i] !== 'undefined' && typeof obj[i] !== 'unknown') { // eslint-disable-line valid-typeof
  1640. retVal[i] = utils.clone(obj[i]);
  1641. }
  1642. }
  1643. return retVal;
  1644. };
  1645. /**
  1646. * Returns a wrapped version of the function
  1647. */
  1648. utils.close = function (context, func, params) {
  1649. return function () {
  1650. var args = params || arguments;
  1651. return func.apply(context, args);
  1652. };
  1653. };
  1654. // ------------------------------------------------------------------------------
  1655. function UUIDcreatePart (length) {
  1656. var uuidpart = '';
  1657. for (var i = 0; i < length; i++) {
  1658. var uuidchar = parseInt((Math.random() * 256), 10).toString(16);
  1659. if (uuidchar.length === 1) {
  1660. uuidchar = '0' + uuidchar;
  1661. }
  1662. uuidpart += uuidchar;
  1663. }
  1664. return uuidpart;
  1665. }
  1666. /**
  1667. * Create a UUID
  1668. */
  1669. utils.createUUID = function () {
  1670. return UUIDcreatePart(4) + '-' +
  1671. UUIDcreatePart(2) + '-' +
  1672. UUIDcreatePart(2) + '-' +
  1673. UUIDcreatePart(2) + '-' +
  1674. UUIDcreatePart(6);
  1675. };
  1676. /**
  1677. * Extends a child object from a parent object using classical inheritance
  1678. * pattern.
  1679. */
  1680. utils.extend = (function () {
  1681. // proxy used to establish prototype chain
  1682. var F = function () {};
  1683. // extend Child from Parent
  1684. return function (Child, Parent) {
  1685. F.prototype = Parent.prototype;
  1686. Child.prototype = new F();
  1687. Child.__super__ = Parent.prototype;
  1688. Child.prototype.constructor = Child;
  1689. };
  1690. }());
  1691. /**
  1692. * Alerts a message in any available way: alert or console.log.
  1693. */
  1694. utils.alert = function (msg) {
  1695. if (window.alert) {
  1696. window.alert(msg);
  1697. } else if (console && console.log) {
  1698. console.log(msg);
  1699. }
  1700. };
  1701. });
  1702. window.cordova = require('cordova');
  1703. // file: src/scripts/bootstrap.js
  1704. require('cordova/init');
  1705. })();