diff options
Diffstat (limited to 'StoneIsland/platforms/ios/www/cordova-js-src')
6 files changed, 248 insertions, 274 deletions
diff --git a/StoneIsland/platforms/ios/www/cordova-js-src/exec.js b/StoneIsland/platforms/ios/www/cordova-js-src/exec.js index 3fb7fa19..466220d8 100644 --- a/StoneIsland/platforms/ios/www/cordova-js-src/exec.js +++ b/StoneIsland/platforms/ios/www/cordova-js-src/exec.js @@ -19,30 +19,24 @@ * */ -/*global require, module, atob, document */ - /** - * Creates a gap bridge iframe used to notify the native code about queued + * Creates the exec bridge used to notify the native code of * commands. */ -var cordova = require('cordova'), - utils = require('cordova/utils'), - base64 = require('cordova/base64'), - execIframe, - commandQueue = [], // Contains pending JS->Native messages. - isInContextOfEvalJs = 0, - failSafeTimerId = 0; +var cordova = require('cordova'); +var utils = require('cordova/utils'); +var base64 = require('cordova/base64'); -function massageArgsJsToNative(args) { - if (!args || utils.typeName(args) != 'Array') { +function massageArgsJsToNative (args) { + if (!args || utils.typeName(args) !== 'Array') { return args; } var ret = []; - args.forEach(function(arg, i) { - if (utils.typeName(arg) == 'ArrayBuffer') { + args.forEach(function (arg, i) { + if (utils.typeName(arg) === 'ArrayBuffer') { ret.push({ - 'CDVType': 'ArrayBuffer', - 'data': base64.fromArrayBuffer(arg) + CDVType: 'ArrayBuffer', + data: base64.fromArrayBuffer(arg) }); } else { ret.push(arg); @@ -51,29 +45,29 @@ function massageArgsJsToNative(args) { return ret; } -function massageMessageNativeToJs(message) { - if (message.CDVType == 'ArrayBuffer') { - var stringToArrayBuffer = function(str) { +function massageMessageNativeToJs (message) { + if (message.CDVType === 'ArrayBuffer') { + var stringToArrayBuffer = function (str) { var ret = new Uint8Array(str.length); for (var i = 0; i < str.length; i++) { ret[i] = str.charCodeAt(i); } return ret.buffer; }; - var base64ToArrayBuffer = function(b64) { - return stringToArrayBuffer(atob(b64)); + var base64ToArrayBuffer = function (b64) { + return stringToArrayBuffer(atob(b64)); // eslint-disable-line no-undef }; message = base64ToArrayBuffer(message.data); } return message; } -function convertMessageToArgsNativeToJs(message) { +function convertMessageToArgsNativeToJs (message) { var args = []; - if (!message || !message.hasOwnProperty('CDVType')) { + if (!message || !Object.prototype.hasOwnProperty.call(message, 'CDVType')) { args.push(message); - } else if (message.CDVType == 'MultiPart') { - message.messages.forEach(function(e) { + } else if (message.CDVType === 'MultiPart') { + message.messages.forEach(function (e) { args.push(massageMessageNativeToJs(e)); }); } else { @@ -82,8 +76,7 @@ function convertMessageToArgsNativeToJs(message) { return args; } -function iOSExec() { - +var iOSExec = function () { var successCallback, failCallback, service, action, actionArgs; var callbackId = null; if (typeof arguments[0] !== 'string') { @@ -100,9 +93,8 @@ function iOSExec() { // an invalid callbackId and passes it even if no callbacks were given. callbackId = 'INVALID'; } else { - throw new Error('The old format of this exec call has been removed (deprecated since 2.1). Change to: ' + - 'cordova.exec(null, null, \'Service\', \'action\', [ arg1, arg2 ]);' - ); + throw new Error('The old format of this exec call has been removed (deprecated since 2.1). Change to: ' + // eslint-disable-line + 'cordova.exec(null, null, \'Service\', \'action\', [ arg1, arg2 ]);'); } // If actionArgs is not provided, default to an empty array @@ -113,149 +105,54 @@ function iOSExec() { if (successCallback || failCallback) { callbackId = service + cordova.callbackId++; cordova.callbacks[callbackId] = - {success:successCallback, fail:failCallback}; + { success: successCallback, fail: failCallback }; } actionArgs = massageArgsJsToNative(actionArgs); - var command = [callbackId, service, action, actionArgs]; - - // Stringify and queue the command. We stringify to command now to - // effectively clone the command arguments in case they are mutated before - // the command is executed. - commandQueue.push(JSON.stringify(command)); - - // If we're in the context of a stringByEvaluatingJavaScriptFromString call, - // then the queue will be flushed when it returns; no need for a poke. - // Also, if there is already a command in the queue, then we've already - // poked the native side, so there is no reason to do so again. - if (!isInContextOfEvalJs && commandQueue.length == 1) { - pokeNative(); - } -} - -// CB-10530 -function proxyChanged() { - var cexec = cordovaExec(); - - return (execProxy !== cexec && // proxy objects are different - iOSExec !== cexec // proxy object is not the current iOSExec - ); -} - -// CB-10106 -function handleBridgeChange() { - if (proxyChanged()) { - var commandString = commandQueue.shift(); - while(commandString) { - var command = JSON.parse(commandString); - var callbackId = command[0]; - var service = command[1]; - var action = command[2]; - var actionArgs = command[3]; - var callbacks = cordova.callbacks[callbackId] || {}; - - execProxy(callbacks.success, callbacks.fail, service, action, actionArgs); - - commandString = commandQueue.shift(); - }; - return true; - } - - return false; -} - -function pokeNative() { - // CB-5488 - Don't attempt to create iframe before document.body is available. - if (!document.body) { - setTimeout(pokeNative); - return; - } - - // Check if they've removed it from the DOM, and put it back if so. - if (execIframe && execIframe.contentWindow) { - execIframe.contentWindow.location = 'gap://ready'; - } else { - execIframe = document.createElement('iframe'); - execIframe.style.display = 'none'; - execIframe.src = 'gap://ready'; - document.body.appendChild(execIframe); - } - // Use a timer to protect against iframe being unloaded during the poke (CB-7735). - // This makes the bridge ~ 7% slower, but works around the poke getting lost - // when the iframe is removed from the DOM. - // An onunload listener could be used in the case where the iframe has just been - // created, but since unload events fire only once, it doesn't work in the normal - // case of iframe reuse (where unload will have already fired due to the attempted - // navigation of the page). - failSafeTimerId = setTimeout(function() { - if (commandQueue.length) { - // CB-10106 - flush the queue on bridge change - if (!handleBridgeChange()) { - pokeNative(); - } - } - }, 50); // Making this > 0 improves performance (marginally) in the normal case (where it doesn't fire). -} - -iOSExec.nativeFetchMessages = function() { - // Stop listing for window detatch once native side confirms poke. - if (failSafeTimerId) { - clearTimeout(failSafeTimerId); - failSafeTimerId = 0; - } - // Each entry in commandQueue is a JSON string already. - if (!commandQueue.length) { - return ''; - } - var json = '[' + commandQueue.join(',') + ']'; - commandQueue.length = 0; - return json; + // CB-10133 DataClone DOM Exception 25 guard (fast function remover) + var command = [callbackId, service, action, JSON.parse(JSON.stringify(actionArgs))]; + window.webkit.messageHandlers.cordova.postMessage(command); }; -iOSExec.nativeCallback = function(callbackId, status, message, keepCallback, debug) { - return iOSExec.nativeEvalAndFetch(function() { - var success = status === 0 || status === 1; - var args = convertMessageToArgsNativeToJs(message); - function nc2() { - cordova.callbackFromNative(callbackId, success, status, args, keepCallback); - } - setTimeout(nc2, 0); +iOSExec.nativeCallback = function (callbackId, status, message, keepCallback, debug) { + var success = status === 0 || status === 1; + var args = convertMessageToArgsNativeToJs(message); + Promise.resolve().then(function () { + cordova.callbackFromNative(callbackId, success, status, args, keepCallback); // eslint-disable-line }); }; -iOSExec.nativeEvalAndFetch = function(func) { - // This shouldn't be nested, but better to be safe. - isInContextOfEvalJs++; +// for backwards compatibility +iOSExec.nativeEvalAndFetch = function (func) { try { func(); - return iOSExec.nativeFetchMessages(); - } finally { - isInContextOfEvalJs--; + } catch (e) { + console.log(e); } }; // Proxy the exec for bridge changes. See CB-10106 -function cordovaExec() { +function cordovaExec () { var cexec = require('cordova/exec'); var cexec_valid = (typeof cexec.nativeFetchMessages === 'function') && (typeof cexec.nativeEvalAndFetch === 'function') && (typeof cexec.nativeCallback === 'function'); - return (cexec_valid && execProxy !== cexec)? cexec : iOSExec; + return (cexec_valid && execProxy !== cexec) ? cexec : iOSExec; } -function execProxy() { +function execProxy () { cordovaExec().apply(null, arguments); -}; +} -execProxy.nativeFetchMessages = function() { +execProxy.nativeFetchMessages = function () { return cordovaExec().nativeFetchMessages.apply(null, arguments); }; -execProxy.nativeEvalAndFetch = function() { +execProxy.nativeEvalAndFetch = function () { return cordovaExec().nativeEvalAndFetch.apply(null, arguments); }; -execProxy.nativeCallback = function() { +execProxy.nativeCallback = function () { return cordovaExec().nativeCallback.apply(null, arguments); }; diff --git a/StoneIsland/platforms/ios/www/cordova-js-src/platform.js b/StoneIsland/platforms/ios/www/cordova-js-src/platform.js index 2345fa5b..83868c81 100644 --- a/StoneIsland/platforms/ios/www/cordova-js-src/platform.js +++ b/StoneIsland/platforms/ios/www/cordova-js-src/platform.js @@ -26,6 +26,14 @@ module.exports = { // see the file under plugin/ios/console.js require('cordova/modulemapper').clobbers('cordova/plugin/ios/console', 'window.console'); + // Attach the wkwebkit utility to window.WkWebView + // see the file under plugin/ios/wkwebkit.js + require('cordova/modulemapper').clobbers('cordova/plugin/ios/wkwebkit', 'window.WkWebView'); + + // Attach the splashscreen utility to window.navigator.splashscreen + // see the file under plugin/ios/launchscreen.js + require('cordova/modulemapper').clobbers('cordova/plugin/ios/launchscreen', 'navigator.splashscreen'); + require('cordova/channel').onNativeReady.fire(); } }; diff --git a/StoneIsland/platforms/ios/www/cordova-js-src/plugin/ios/console.js b/StoneIsland/platforms/ios/www/cordova-js-src/plugin/ios/console.js index 6224fb44..0a4820ed 100644 --- a/StoneIsland/platforms/ios/www/cordova-js-src/plugin/ios/console.js +++ b/StoneIsland/platforms/ios/www/cordova-js-src/plugin/ios/console.js @@ -19,168 +19,168 @@ * */ -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ var logger = require('cordova/plugin/ios/logger'); -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // object that we're exporting -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ var console = module.exports; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // copy of the original console object -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ var WinConsole = window.console; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // whether to use the logger -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ var UseLogger = false; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // Timers -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ var Timers = {}; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // used for unimplemented methods -//------------------------------------------------------------------------------ -function noop() {} +// ------------------------------------------------------------------------------ +function noop () {} -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // used for unimplemented methods -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ console.useLogger = function (value) { if (arguments.length) UseLogger = !!value; if (UseLogger) { if (logger.useConsole()) { - throw new Error("console and logger are too intertwingly"); + throw new Error('console and logger are too intertwingly'); } } return UseLogger; }; -//------------------------------------------------------------------------------ -console.log = function() { +// ------------------------------------------------------------------------------ +console.log = function () { if (logger.useConsole()) return; logger.log.apply(logger, [].slice.call(arguments)); }; -//------------------------------------------------------------------------------ -console.error = function() { +// ------------------------------------------------------------------------------ +console.error = function () { if (logger.useConsole()) return; logger.error.apply(logger, [].slice.call(arguments)); }; -//------------------------------------------------------------------------------ -console.warn = function() { +// ------------------------------------------------------------------------------ +console.warn = function () { if (logger.useConsole()) return; logger.warn.apply(logger, [].slice.call(arguments)); }; -//------------------------------------------------------------------------------ -console.info = function() { +// ------------------------------------------------------------------------------ +console.info = function () { if (logger.useConsole()) return; logger.info.apply(logger, [].slice.call(arguments)); }; -//------------------------------------------------------------------------------ -console.debug = function() { +// ------------------------------------------------------------------------------ +console.debug = function () { if (logger.useConsole()) return; logger.debug.apply(logger, [].slice.call(arguments)); }; -//------------------------------------------------------------------------------ -console.assert = function(expression) { +// ------------------------------------------------------------------------------ +console.assert = function (expression) { if (expression) return; var message = logger.format.apply(logger.format, [].slice.call(arguments, 1)); - console.log("ASSERT: " + message); + console.log('ASSERT: ' + message); }; -//------------------------------------------------------------------------------ -console.clear = function() {}; +// ------------------------------------------------------------------------------ +console.clear = function () {}; -//------------------------------------------------------------------------------ -console.dir = function(object) { - console.log("%o", object); +// ------------------------------------------------------------------------------ +console.dir = function (object) { + console.log('%o', object); }; -//------------------------------------------------------------------------------ -console.dirxml = function(node) { +// ------------------------------------------------------------------------------ +console.dirxml = function (node) { console.log(node.innerHTML); }; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ console.trace = noop; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ console.group = console.log; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ console.groupCollapsed = console.log; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ console.groupEnd = noop; -//------------------------------------------------------------------------------ -console.time = function(name) { +// ------------------------------------------------------------------------------ +console.time = function (name) { Timers[name] = new Date().valueOf(); }; -//------------------------------------------------------------------------------ -console.timeEnd = function(name) { +// ------------------------------------------------------------------------------ +console.timeEnd = function (name) { var timeStart = Timers[name]; if (!timeStart) { - console.warn("unknown timer: " + name); + console.warn('unknown timer: ' + name); return; } var timeElapsed = new Date().valueOf() - timeStart; - console.log(name + ": " + timeElapsed + "ms"); + console.log(name + ': ' + timeElapsed + 'ms'); }; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ console.timeStamp = noop; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ console.profile = noop; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ console.profileEnd = noop; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ console.count = noop; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ console.exception = console.log; -//------------------------------------------------------------------------------ -console.table = function(data, columns) { - console.log("%o", data); +// ------------------------------------------------------------------------------ +console.table = function (data, columns) { + console.log('%o', data); }; -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // return a new function that calls both functions passed as args -//------------------------------------------------------------------------------ -function wrappedOrigCall(orgFunc, newFunc) { - return function() { +// ------------------------------------------------------------------------------ +function wrappedOrigCall (orgFunc, newFunc) { + return function () { var args = [].slice.call(arguments); try { orgFunc.apply(WinConsole, args); } catch (e) {} - try { newFunc.apply(console, args); } catch (e) {} + try { newFunc.apply(console, args); } catch (e) {} }; } -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // For every function that exists in the original console object, that // also exists in the new console object, wrap the new console method // with one that calls both -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ for (var key in console) { - if (typeof WinConsole[key] == "function") { + if (typeof WinConsole[key] === 'function') { console[key] = wrappedOrigCall(WinConsole[key], console[key]); } } diff --git a/StoneIsland/platforms/ios/www/cordova-js-src/plugin/ios/launchscreen.js b/StoneIsland/platforms/ios/www/cordova-js-src/plugin/ios/launchscreen.js new file mode 100644 index 00000000..24606969 --- /dev/null +++ b/StoneIsland/platforms/ios/www/cordova-js-src/plugin/ios/launchscreen.js @@ -0,0 +1,33 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + +var exec = require('cordova/exec'); + +var launchscreen = { + show: function () { + exec(null, null, 'LaunchScreen', 'show', []); + }, + hide: function () { + exec(null, null, 'LaunchScreen', 'hide', []); + } +}; + +module.exports = launchscreen; diff --git a/StoneIsland/platforms/ios/www/cordova-js-src/plugin/ios/logger.js b/StoneIsland/platforms/ios/www/cordova-js-src/plugin/ios/logger.js index 430d887d..6f59e1c8 100644 --- a/StoneIsland/platforms/ios/www/cordova-js-src/plugin/ios/logger.js +++ b/StoneIsland/platforms/ios/www/cordova-js-src/plugin/ios/logger.js @@ -19,7 +19,7 @@ * */ -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // The logger module exports the following properties/functions: // // LOG - constant for the level LOG @@ -38,16 +38,16 @@ // debug(message,...) - logs a message at level DEBUG // logLevel(level,message,...) - logs a message specified level // -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ var logger = exports; -var exec = require('cordova/exec'); +var exec = require('cordova/exec'); -var UseConsole = false; -var UseLogger = true; -var Queued = []; -var DeviceReady = false; +var UseConsole = false; +var UseLogger = true; +var Queued = []; +var DeviceReady = false; var CurrentLevel; var originalConsole = console; @@ -57,11 +57,11 @@ var originalConsole = console; */ var Levels = [ - "LOG", - "ERROR", - "WARN", - "INFO", - "DEBUG" + 'LOG', + 'ERROR', + 'WARN', + 'INFO', + 'DEBUG' ]; /* @@ -70,10 +70,10 @@ var Levels = [ */ var LevelsMap = {}; -for (var i=0; i<Levels.length; i++) { +for (var i = 0; i < Levels.length; i++) { var level = Levels[i]; LevelsMap[level] = i; - logger[level] = level; + logger[level] = level; } CurrentLevel = LevelsMap.WARN; @@ -100,7 +100,7 @@ CurrentLevel = LevelsMap.WARN; logger.level = function (value) { if (arguments.length) { if (LevelsMap[value] === null) { - throw new Error("invalid logging level: " + value); + throw new Error('invalid logging level: ' + value); } CurrentLevel = LevelsMap[value]; } @@ -118,17 +118,17 @@ logger.useConsole = function (value) { if (arguments.length) UseConsole = !!value; if (UseConsole) { - if (typeof console == "undefined") { - throw new Error("global console object is not defined"); + if (typeof console === 'undefined') { + throw new Error('global console object is not defined'); } - if (typeof console.log != "function") { - throw new Error("global console object does not have a log function"); + if (typeof console.log !== 'function') { + throw new Error('global console object does not have a log function'); } - if (typeof console.useLogger == "function") { + if (typeof console.useLogger === 'function') { if (console.useLogger()) { - throw new Error("console and logger are too intertwingly"); + throw new Error('console and logger are too intertwingly'); } } } @@ -154,7 +154,7 @@ logger.useLogger = function (value) { * Parameters passed after message are used applied to * the message with utils.format() */ -logger.log = function(message) { logWithArgs("LOG", arguments); }; +logger.log = function (message) { logWithArgs('LOG', arguments); }; /** * Logs a message at the ERROR level. @@ -162,7 +162,7 @@ logger.log = function(message) { logWithArgs("LOG", arguments); }; * Parameters passed after message are used applied to * the message with utils.format() */ -logger.error = function(message) { logWithArgs("ERROR", arguments); }; +logger.error = function (message) { logWithArgs('ERROR', arguments); }; /** * Logs a message at the WARN level. @@ -170,7 +170,7 @@ logger.error = function(message) { logWithArgs("ERROR", arguments); }; * Parameters passed after message are used applied to * the message with utils.format() */ -logger.warn = function(message) { logWithArgs("WARN", arguments); }; +logger.warn = function (message) { logWithArgs('WARN', arguments); }; /** * Logs a message at the INFO level. @@ -178,7 +178,7 @@ logger.warn = function(message) { logWithArgs("WARN", arguments); }; * Parameters passed after message are used applied to * the message with utils.format() */ -logger.info = function(message) { logWithArgs("INFO", arguments); }; +logger.info = function (message) { logWithArgs('INFO', arguments); }; /** * Logs a message at the DEBUG level. @@ -186,17 +186,17 @@ logger.info = function(message) { logWithArgs("INFO", arguments); }; * Parameters passed after message are used applied to * the message with utils.format() */ -logger.debug = function(message) { logWithArgs("DEBUG", arguments); }; +logger.debug = function (message) { logWithArgs('DEBUG', arguments); }; // log at the specified level with args -function logWithArgs(level, args) { +function logWithArgs (level, args) { args = [level].concat([].slice.call(args)); logger.logLevel.apply(logger, args); } // return the correct formatString for an object -function formatStringForMessage(message) { - return (typeof message === "string") ? "" : "%o"; +function formatStringForMessage (message) { + return (typeof message === 'string') ? '' : '%o'; } /** @@ -205,18 +205,18 @@ function formatStringForMessage(message) { * Parameters passed after message are used applied to * the message with utils.format() */ -logger.logLevel = function(level /* , ... */) { +logger.logLevel = function (level /* , ... */) { // format the message with the parameters var formatArgs = [].slice.call(arguments, 1); var fmtString = formatStringForMessage(formatArgs[0]); - if (fmtString.length > 0){ + if (fmtString.length > 0) { formatArgs.unshift(fmtString); // add formatString } - var message = logger.format.apply(logger.format, formatArgs); + var message = logger.format.apply(logger.format, formatArgs); if (LevelsMap[level] === null) { - throw new Error("invalid logging level: " + level); + throw new Error('invalid logging level: ' + level); } if (LevelsMap[level] > CurrentLevel) return; @@ -229,28 +229,27 @@ logger.logLevel = function(level /* , ... */) { // Log using the native logger if that is enabled if (UseLogger) { - exec(null, null, "Console", "logLevel", [level, message]); + exec(null, null, 'Console', 'logLevel', [level, message]); } // Log using the console if that is enabled if (UseConsole) { // make sure console is not using logger if (console.useLogger()) { - throw new Error("console and logger are too intertwingly"); + throw new Error('console and logger are too intertwingly'); } // log to the console switch (level) { - case logger.LOG: originalConsole.log(message); break; - case logger.ERROR: originalConsole.log("ERROR: " + message); break; - case logger.WARN: originalConsole.log("WARN: " + message); break; - case logger.INFO: originalConsole.log("INFO: " + message); break; - case logger.DEBUG: originalConsole.log("DEBUG: " + message); break; + case logger.LOG: originalConsole.log(message); break; + case logger.ERROR: originalConsole.log('ERROR: ' + message); break; + case logger.WARN: originalConsole.log('WARN: ' + message); break; + case logger.INFO: originalConsole.log('INFO: ' + message); break; + case logger.DEBUG: originalConsole.log('DEBUG: ' + message); break; } } }; - /** * Formats a string and arguments following it ala console.log() * @@ -259,12 +258,11 @@ logger.logLevel = function(level /* , ... */) { * for rationale, see FireBug's Console API: * http://getfirebug.com/wiki/index.php/Console_API */ -logger.format = function(formatString, args) { - return __format(arguments[0], [].slice.call(arguments,1)).join(' '); +logger.format = function (formatString, args) { + return __format(arguments[0], [].slice.call(arguments, 1)).join(' '); }; - -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ /** * Formats a string and arguments following it ala vsprintf() * @@ -279,26 +277,25 @@ logger.format = function(formatString, args) { * Returns an array containing the formatted string and any remaining * arguments. */ -function __format(formatString, args) { - if (formatString === null || formatString === undefined) return [""]; - if (arguments.length == 1) return [formatString.toString()]; +function __format (formatString, args) { + if (formatString === null || formatString === undefined) return ['']; + if (arguments.length === 1) return [formatString.toString()]; - if (typeof formatString != "string") - formatString = formatString.toString(); + if (typeof formatString !== 'string') { formatString = formatString.toString(); } var pattern = /(.*?)%(.)(.*)/; - var rest = formatString; - var result = []; + var rest = formatString; + var result = []; while (args.length) { var match = pattern.exec(rest); if (!match) break; - var arg = args.shift(); + var arg = args.shift(); rest = match[3]; result.push(match[1]); - if (match[2] == '%') { + if (match[2] === '%') { result.push('%'); args.unshift(arg); continue; @@ -314,17 +311,15 @@ function __format(formatString, args) { return remainingArgs; } -function __formatted(object, formatChar) { - +function __formatted (object, formatChar) { try { - switch(formatChar) { - case 'j': - case 'o': return JSON.stringify(object); - case 'c': return ''; + switch (formatChar) { + case 'j': + case 'o': return JSON.stringify(object); + case 'c': return ''; } - } - catch (e) { - return "error JSON.stringify()ing argument: " + e; + } catch (e) { + return 'error JSON.stringify()ing argument: ' + e; } if ((object === null) || (object === undefined)) { @@ -334,15 +329,14 @@ function __formatted(object, formatChar) { return object.toString(); } - -//------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------ // when deviceready fires, log queued messages -logger.__onDeviceReady = function() { +logger.__onDeviceReady = function () { if (DeviceReady) return; DeviceReady = true; - for (var i=0; i<Queued.length; i++) { + for (var i = 0; i < Queued.length; i++) { var messageArgs = Queued[i]; logger.logLevel(messageArgs[0], messageArgs[1]); } @@ -351,4 +345,4 @@ logger.__onDeviceReady = function() { }; // add a deviceready event to log queued messages -document.addEventListener("deviceready", logger.__onDeviceReady, false); +document.addEventListener('deviceready', logger.__onDeviceReady, false); diff --git a/StoneIsland/platforms/ios/www/cordova-js-src/plugin/ios/wkwebkit.js b/StoneIsland/platforms/ios/www/cordova-js-src/plugin/ios/wkwebkit.js new file mode 100644 index 00000000..35c819cf --- /dev/null +++ b/StoneIsland/platforms/ios/www/cordova-js-src/plugin/ios/wkwebkit.js @@ -0,0 +1,42 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + +var exec = require('cordova/exec'); + +var WkWebKit = { + allowsBackForwardNavigationGestures: function (allow) { + exec(null, null, 'CDVWebViewEngine', 'allowsBackForwardNavigationGestures', [allow]); + }, + convertFilePath: function (path) { + if (!path || !window.CDV_ASSETS_URL) { + return path; + } + if (path.startsWith('/')) { + return window.CDV_ASSETS_URL + '/_app_file_' + path; + } + if (path.startsWith('file://')) { + return window.CDV_ASSETS_URL + path.replace('file://', '/_app_file_'); + } + return path; + } +}; + +module.exports = WkWebKit; |
