mirror of
https://github.com/cupcakearmy/fight-of-the-mobiles.git
synced 2026-04-02 10:15:23 +00:00
cordova
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
src/cordova/platforms/ios/www/assets/Jaapokki.otf
Normal file
BIN
src/cordova/platforms/ios/www/assets/Jaapokki.otf
Normal file
Binary file not shown.
BIN
src/cordova/platforms/ios/www/assets/check.png
Normal file
BIN
src/cordova/platforms/ios/www/assets/check.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
BIN
src/cordova/platforms/ios/www/assets/sync.png
Normal file
BIN
src/cordova/platforms/ios/www/assets/sync.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.1 KiB |
129
src/cordova/platforms/ios/www/bundle.css
Normal file
129
src/cordova/platforms/ios/www/bundle.css
Normal file
@@ -0,0 +1,129 @@
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
html,
|
||||
body {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
img {
|
||||
object-fit: contain;
|
||||
}
|
||||
.spinning {
|
||||
animation: rotation 2s infinite linear;
|
||||
}
|
||||
@keyframes rotation {
|
||||
from {
|
||||
-webkit-transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
-webkit-transform: rotate(359deg);
|
||||
}
|
||||
}
|
||||
.fill {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.column {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
.center {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.abs {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.button {
|
||||
border: 1px solid #000;
|
||||
height: 45px;
|
||||
width: 180px;
|
||||
border-radius: 50px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
#app {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
font-family: 'Helvetica Neue';
|
||||
}
|
||||
#app .bg {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 0;
|
||||
background-image: linear-gradient(135deg, #6FABFF, #E4FF71);
|
||||
}
|
||||
#app .content {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 1;
|
||||
}
|
||||
.Logo {
|
||||
position: relative;
|
||||
font-family: 'Jaapokki';
|
||||
}
|
||||
.Logo .title {
|
||||
font-size: 30px;
|
||||
}
|
||||
.Logo .badge {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: absolute;
|
||||
right: -20px;
|
||||
top: -5px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
background-color: #f00;
|
||||
border-radius: 20px;
|
||||
}
|
||||
.Logo .badge div {
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Jaapokki';
|
||||
src: url(assets/Jaapokki.otf);
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Helvetiva Neue';
|
||||
font-weight: lighter;
|
||||
font-style: normal;
|
||||
src: url("assets/Helvetica Neue LT Std Light.otf") format('opentype');
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Helvetiva Neue';
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
src: url("assets/Helvetica Neue LT Std Medium.otf") format('opentype');
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Helvetiva Neue';
|
||||
font-weight: bold;
|
||||
font-style: normal;
|
||||
src: url("assets/Helvetica Neue LT Std Bold.otf") format('opentype');
|
||||
}
|
||||
|
||||
262
src/cordova/platforms/ios/www/cordova-js-src/exec.js
vendored
Normal file
262
src/cordova/platforms/ios/www/cordova-js-src/exec.js
vendored
Normal file
@@ -0,0 +1,262 @@
|
||||
/*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/*global require, module, atob, document */
|
||||
|
||||
/**
|
||||
* Creates a gap bridge iframe used to notify the native code about queued
|
||||
* commands.
|
||||
*/
|
||||
var cordova = require('cordova'),
|
||||
utils = require('cordova/utils'),
|
||||
base64 = require('cordova/base64'),
|
||||
execIframe,
|
||||
commandQueue = [], // Contains pending JS->Native messages.
|
||||
isInContextOfEvalJs = 0,
|
||||
failSafeTimerId = 0;
|
||||
|
||||
function massageArgsJsToNative(args) {
|
||||
if (!args || utils.typeName(args) != 'Array') {
|
||||
return args;
|
||||
}
|
||||
var ret = [];
|
||||
args.forEach(function(arg, i) {
|
||||
if (utils.typeName(arg) == 'ArrayBuffer') {
|
||||
ret.push({
|
||||
'CDVType': 'ArrayBuffer',
|
||||
'data': base64.fromArrayBuffer(arg)
|
||||
});
|
||||
} else {
|
||||
ret.push(arg);
|
||||
}
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
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));
|
||||
};
|
||||
message = base64ToArrayBuffer(message.data);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
function convertMessageToArgsNativeToJs(message) {
|
||||
var args = [];
|
||||
if (!message || !message.hasOwnProperty('CDVType')) {
|
||||
args.push(message);
|
||||
} else if (message.CDVType == 'MultiPart') {
|
||||
message.messages.forEach(function(e) {
|
||||
args.push(massageMessageNativeToJs(e));
|
||||
});
|
||||
} else {
|
||||
args.push(massageMessageNativeToJs(message));
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
function iOSExec() {
|
||||
|
||||
var successCallback, failCallback, service, action, actionArgs;
|
||||
var callbackId = null;
|
||||
if (typeof arguments[0] !== 'string') {
|
||||
// FORMAT ONE
|
||||
successCallback = arguments[0];
|
||||
failCallback = arguments[1];
|
||||
service = arguments[2];
|
||||
action = arguments[3];
|
||||
actionArgs = arguments[4];
|
||||
|
||||
// Since we need to maintain backwards compatibility, we have to pass
|
||||
// an invalid callbackId even if no callback was provided since plugins
|
||||
// will be expecting it. The Cordova.exec() implementation allocates
|
||||
// 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 ]);'
|
||||
);
|
||||
}
|
||||
|
||||
// If actionArgs is not provided, default to an empty array
|
||||
actionArgs = actionArgs || [];
|
||||
|
||||
// Register the callbacks and add the callbackId to the positional
|
||||
// arguments if given.
|
||||
if (successCallback || failCallback) {
|
||||
callbackId = service + cordova.callbackId++;
|
||||
cordova.callbacks[callbackId] =
|
||||
{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;
|
||||
};
|
||||
|
||||
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.nativeEvalAndFetch = function(func) {
|
||||
// This shouldn't be nested, but better to be safe.
|
||||
isInContextOfEvalJs++;
|
||||
try {
|
||||
func();
|
||||
return iOSExec.nativeFetchMessages();
|
||||
} finally {
|
||||
isInContextOfEvalJs--;
|
||||
}
|
||||
};
|
||||
|
||||
// Proxy the exec for bridge changes. See CB-10106
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
function execProxy() {
|
||||
cordovaExec().apply(null, arguments);
|
||||
};
|
||||
|
||||
execProxy.nativeFetchMessages = function() {
|
||||
return cordovaExec().nativeFetchMessages.apply(null, arguments);
|
||||
};
|
||||
|
||||
execProxy.nativeEvalAndFetch = function() {
|
||||
return cordovaExec().nativeEvalAndFetch.apply(null, arguments);
|
||||
};
|
||||
|
||||
execProxy.nativeCallback = function() {
|
||||
return cordovaExec().nativeCallback.apply(null, arguments);
|
||||
};
|
||||
|
||||
module.exports = execProxy;
|
||||
31
src/cordova/platforms/ios/www/cordova-js-src/platform.js
vendored
Normal file
31
src/cordova/platforms/ios/www/cordova-js-src/platform.js
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
id: 'ios',
|
||||
bootstrap: function () {
|
||||
// Attach the console polyfill that is iOS-only to window.console
|
||||
// see the file under plugin/ios/console.js
|
||||
require('cordova/modulemapper').clobbers('cordova/plugin/ios/console', 'window.console');
|
||||
|
||||
require('cordova/channel').onNativeReady.fire();
|
||||
}
|
||||
};
|
||||
186
src/cordova/platforms/ios/www/cordova-js-src/plugin/ios/console.js
vendored
Normal file
186
src/cordova/platforms/ios/www/cordova-js-src/plugin/ios/console.js
vendored
Normal file
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
*
|
||||
* 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 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() {}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// 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");
|
||||
}
|
||||
}
|
||||
|
||||
return UseLogger;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
console.log = function() {
|
||||
if (logger.useConsole()) return;
|
||||
logger.log.apply(logger, [].slice.call(arguments));
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
console.error = function() {
|
||||
if (logger.useConsole()) return;
|
||||
logger.error.apply(logger, [].slice.call(arguments));
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
console.warn = function() {
|
||||
if (logger.useConsole()) return;
|
||||
logger.warn.apply(logger, [].slice.call(arguments));
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
console.info = function() {
|
||||
if (logger.useConsole()) return;
|
||||
logger.info.apply(logger, [].slice.call(arguments));
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
console.debug = function() {
|
||||
if (logger.useConsole()) return;
|
||||
logger.debug.apply(logger, [].slice.call(arguments));
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
console.assert = function(expression) {
|
||||
if (expression) return;
|
||||
|
||||
var message = logger.format.apply(logger.format, [].slice.call(arguments, 1));
|
||||
console.log("ASSERT: " + message);
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
console.clear = function() {};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
console.dir = function(object) {
|
||||
console.log("%o", object);
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
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) {
|
||||
Timers[name] = new Date().valueOf();
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
console.timeEnd = function(name) {
|
||||
var timeStart = Timers[name];
|
||||
if (!timeStart) {
|
||||
console.warn("unknown timer: " + name);
|
||||
return;
|
||||
}
|
||||
|
||||
var timeElapsed = new Date().valueOf() - timeStart;
|
||||
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);
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// return a new function that calls both functions passed as args
|
||||
//------------------------------------------------------------------------------
|
||||
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) {}
|
||||
};
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// 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") {
|
||||
console[key] = wrappedOrigCall(WinConsole[key], console[key]);
|
||||
}
|
||||
}
|
||||
354
src/cordova/platforms/ios/www/cordova-js-src/plugin/ios/logger.js
vendored
Normal file
354
src/cordova/platforms/ios/www/cordova-js-src/plugin/ios/logger.js
vendored
Normal file
@@ -0,0 +1,354 @@
|
||||
/*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// The logger module exports the following properties/functions:
|
||||
//
|
||||
// LOG - constant for the level LOG
|
||||
// ERROR - constant for the level ERROR
|
||||
// WARN - constant for the level WARN
|
||||
// INFO - constant for the level INFO
|
||||
// DEBUG - constant for the level DEBUG
|
||||
// logLevel() - returns current log level
|
||||
// logLevel(value) - sets and returns a new log level
|
||||
// useConsole() - returns whether logger is using console
|
||||
// useConsole(value) - sets and returns whether logger is using console
|
||||
// log(message,...) - logs a message at level LOG
|
||||
// error(message,...) - logs a message at level ERROR
|
||||
// warn(message,...) - logs a message at level WARN
|
||||
// info(message,...) - logs a message at level INFO
|
||||
// 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 UseConsole = false;
|
||||
var UseLogger = true;
|
||||
var Queued = [];
|
||||
var DeviceReady = false;
|
||||
var CurrentLevel;
|
||||
|
||||
var originalConsole = console;
|
||||
|
||||
/**
|
||||
* Logging levels
|
||||
*/
|
||||
|
||||
var Levels = [
|
||||
"LOG",
|
||||
"ERROR",
|
||||
"WARN",
|
||||
"INFO",
|
||||
"DEBUG"
|
||||
];
|
||||
|
||||
/*
|
||||
* add the logging levels to the logger object and
|
||||
* to a separate levelsMap object for testing
|
||||
*/
|
||||
|
||||
var LevelsMap = {};
|
||||
for (var i=0; i<Levels.length; i++) {
|
||||
var level = Levels[i];
|
||||
LevelsMap[level] = i;
|
||||
logger[level] = level;
|
||||
}
|
||||
|
||||
CurrentLevel = LevelsMap.WARN;
|
||||
|
||||
/**
|
||||
* Getter/Setter for the logging level
|
||||
*
|
||||
* Returns the current logging level.
|
||||
*
|
||||
* When a value is passed, sets the logging level to that value.
|
||||
* The values should be one of the following constants:
|
||||
* logger.LOG
|
||||
* logger.ERROR
|
||||
* logger.WARN
|
||||
* logger.INFO
|
||||
* logger.DEBUG
|
||||
*
|
||||
* The value used determines which messages get printed. The logging
|
||||
* values above are in order, and only messages logged at the logging
|
||||
* level or above will actually be displayed to the user. E.g., the
|
||||
* default level is WARN, so only messages logged with LOG, ERROR, or
|
||||
* WARN will be displayed; INFO and DEBUG messages will be ignored.
|
||||
*/
|
||||
logger.level = function (value) {
|
||||
if (arguments.length) {
|
||||
if (LevelsMap[value] === null) {
|
||||
throw new Error("invalid logging level: " + value);
|
||||
}
|
||||
CurrentLevel = LevelsMap[value];
|
||||
}
|
||||
|
||||
return Levels[CurrentLevel];
|
||||
};
|
||||
|
||||
/**
|
||||
* Getter/Setter for the useConsole functionality
|
||||
*
|
||||
* When useConsole is true, the logger will log via the
|
||||
* browser 'console' object.
|
||||
*/
|
||||
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.log != "function") {
|
||||
throw new Error("global console object does not have a log function");
|
||||
}
|
||||
|
||||
if (typeof console.useLogger == "function") {
|
||||
if (console.useLogger()) {
|
||||
throw new Error("console and logger are too intertwingly");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return UseConsole;
|
||||
};
|
||||
|
||||
/**
|
||||
* Getter/Setter for the useLogger functionality
|
||||
*
|
||||
* When useLogger is true, the logger will log via the
|
||||
* native Logger plugin.
|
||||
*/
|
||||
logger.useLogger = function (value) {
|
||||
// Enforce boolean
|
||||
if (arguments.length) UseLogger = !!value;
|
||||
return UseLogger;
|
||||
};
|
||||
|
||||
/**
|
||||
* Logs a message at the LOG level.
|
||||
*
|
||||
* Parameters passed after message are used applied to
|
||||
* the message with utils.format()
|
||||
*/
|
||||
logger.log = function(message) { logWithArgs("LOG", arguments); };
|
||||
|
||||
/**
|
||||
* Logs a message at the ERROR level.
|
||||
*
|
||||
* Parameters passed after message are used applied to
|
||||
* the message with utils.format()
|
||||
*/
|
||||
logger.error = function(message) { logWithArgs("ERROR", arguments); };
|
||||
|
||||
/**
|
||||
* Logs a message at the WARN level.
|
||||
*
|
||||
* Parameters passed after message are used applied to
|
||||
* the message with utils.format()
|
||||
*/
|
||||
logger.warn = function(message) { logWithArgs("WARN", arguments); };
|
||||
|
||||
/**
|
||||
* Logs a message at the INFO level.
|
||||
*
|
||||
* Parameters passed after message are used applied to
|
||||
* the message with utils.format()
|
||||
*/
|
||||
logger.info = function(message) { logWithArgs("INFO", arguments); };
|
||||
|
||||
/**
|
||||
* Logs a message at the DEBUG level.
|
||||
*
|
||||
* Parameters passed after message are used applied to
|
||||
* the message with utils.format()
|
||||
*/
|
||||
logger.debug = function(message) { logWithArgs("DEBUG", arguments); };
|
||||
|
||||
// log at the specified level with 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";
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs a message at the specified level.
|
||||
*
|
||||
* Parameters passed after message are used applied to
|
||||
* the message with utils.format()
|
||||
*/
|
||||
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){
|
||||
formatArgs.unshift(fmtString); // add formatString
|
||||
}
|
||||
|
||||
var message = logger.format.apply(logger.format, formatArgs);
|
||||
|
||||
if (LevelsMap[level] === null) {
|
||||
throw new Error("invalid logging level: " + level);
|
||||
}
|
||||
|
||||
if (LevelsMap[level] > CurrentLevel) return;
|
||||
|
||||
// queue the message if not yet at deviceready
|
||||
if (!DeviceReady && !UseConsole) {
|
||||
Queued.push([level, message]);
|
||||
return;
|
||||
}
|
||||
|
||||
// Log using the native logger if that is enabled
|
||||
if (UseLogger) {
|
||||
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");
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Formats a string and arguments following it ala console.log()
|
||||
*
|
||||
* Any remaining arguments will be appended to the formatted string.
|
||||
*
|
||||
* 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(' ');
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/**
|
||||
* Formats a string and arguments following it ala vsprintf()
|
||||
*
|
||||
* format chars:
|
||||
* %j - format arg as JSON
|
||||
* %o - format arg as JSON
|
||||
* %c - format arg as ''
|
||||
* %% - replace with '%'
|
||||
* any other char following % will format it's
|
||||
* arg via toString().
|
||||
*
|
||||
* 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()];
|
||||
|
||||
if (typeof formatString != "string")
|
||||
formatString = formatString.toString();
|
||||
|
||||
var pattern = /(.*?)%(.)(.*)/;
|
||||
var rest = formatString;
|
||||
var result = [];
|
||||
|
||||
while (args.length) {
|
||||
var match = pattern.exec(rest);
|
||||
if (!match) break;
|
||||
|
||||
var arg = args.shift();
|
||||
rest = match[3];
|
||||
result.push(match[1]);
|
||||
|
||||
if (match[2] == '%') {
|
||||
result.push('%');
|
||||
args.unshift(arg);
|
||||
continue;
|
||||
}
|
||||
|
||||
result.push(__formatted(arg, match[2]));
|
||||
}
|
||||
|
||||
result.push(rest);
|
||||
|
||||
var remainingArgs = [].slice.call(args);
|
||||
remainingArgs.unshift(result.join(''));
|
||||
return remainingArgs;
|
||||
}
|
||||
|
||||
function __formatted(object, formatChar) {
|
||||
|
||||
try {
|
||||
switch(formatChar) {
|
||||
case 'j':
|
||||
case 'o': return JSON.stringify(object);
|
||||
case 'c': return '';
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
return "error JSON.stringify()ing argument: " + e;
|
||||
}
|
||||
|
||||
if ((object === null) || (object === undefined)) {
|
||||
return Object.prototype.toString.call(object);
|
||||
}
|
||||
|
||||
return object.toString();
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// when deviceready fires, log queued messages
|
||||
logger.__onDeviceReady = function() {
|
||||
if (DeviceReady) return;
|
||||
|
||||
DeviceReady = true;
|
||||
|
||||
for (var i=0; i<Queued.length; i++) {
|
||||
var messageArgs = Queued[i];
|
||||
logger.logLevel(messageArgs[0], messageArgs[1]);
|
||||
}
|
||||
|
||||
Queued = null;
|
||||
};
|
||||
|
||||
// add a deviceready event to log queued messages
|
||||
document.addEventListener("deviceready", logger.__onDeviceReady, false);
|
||||
2432
src/cordova/platforms/ios/www/cordova.js
vendored
Normal file
2432
src/cordova/platforms/ios/www/cordova.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
70
src/cordova/platforms/ios/www/cordova_plugins.js
vendored
Normal file
70
src/cordova/platforms/ios/www/cordova_plugins.js
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
cordova.define('cordova/plugin_list', function(require, exports, module) {
|
||||
module.exports = [
|
||||
{
|
||||
"id": "cordova-plugin-camera.Camera",
|
||||
"file": "plugins/cordova-plugin-camera/www/CameraConstants.js",
|
||||
"pluginId": "cordova-plugin-camera",
|
||||
"clobbers": [
|
||||
"Camera"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "cordova-plugin-camera.CameraPopoverOptions",
|
||||
"file": "plugins/cordova-plugin-camera/www/CameraPopoverOptions.js",
|
||||
"pluginId": "cordova-plugin-camera",
|
||||
"clobbers": [
|
||||
"CameraPopoverOptions"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "cordova-plugin-camera.camera",
|
||||
"file": "plugins/cordova-plugin-camera/www/Camera.js",
|
||||
"pluginId": "cordova-plugin-camera",
|
||||
"clobbers": [
|
||||
"navigator.camera"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "cordova-plugin-camera.CameraPopoverHandle",
|
||||
"file": "plugins/cordova-plugin-camera/www/ios/CameraPopoverHandle.js",
|
||||
"pluginId": "cordova-plugin-camera",
|
||||
"clobbers": [
|
||||
"CameraPopoverHandle"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "phonegap-plugin-barcodescanner.BarcodeScanner",
|
||||
"file": "plugins/phonegap-plugin-barcodescanner/www/barcodescanner.js",
|
||||
"pluginId": "phonegap-plugin-barcodescanner",
|
||||
"clobbers": [
|
||||
"cordova.plugins.barcodeScanner"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "phonegap-plugin-local-notification.Notification",
|
||||
"file": "plugins/phonegap-plugin-local-notification/www/notification.js",
|
||||
"pluginId": "phonegap-plugin-local-notification",
|
||||
"clobbers": [
|
||||
"Notification"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "cordova-plugin-dialogs.notification",
|
||||
"file": "plugins/cordova-plugin-dialogs/www/notification.js",
|
||||
"pluginId": "cordova-plugin-dialogs",
|
||||
"merges": [
|
||||
"navigator.notification"
|
||||
]
|
||||
}
|
||||
];
|
||||
module.exports.metadata =
|
||||
// TOP OF METADATA
|
||||
{
|
||||
"cordova-plugin-whitelist": "1.3.3",
|
||||
"cordova-plugin-camera": "4.0.3",
|
||||
"phonegap-plugin-barcodescanner": "8.0.0",
|
||||
"phonegap-plugin-local-notification": "1.0.1",
|
||||
"cordova-plugin-dialogs": "2.0.1"
|
||||
};
|
||||
// BOTTOM OF METADATA
|
||||
});
|
||||
15
src/cordova/platforms/ios/www/index.html
Normal file
15
src/cordova/platforms/ios/www/index.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>Basic Setup</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<script src="cordova.js"></script>
|
||||
<link href="bundle.css" rel="stylesheet"></head>
|
||||
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="text/javascript" src="main.js"></script></body>
|
||||
|
||||
</html>
|
||||
493
src/cordova/platforms/ios/www/main.js
vendored
Normal file
493
src/cordova/platforms/ios/www/main.js
vendored
Normal file
File diff suppressed because one or more lines are too long
188
src/cordova/platforms/ios/www/plugins/cordova-plugin-camera/www/Camera.js
vendored
Normal file
188
src/cordova/platforms/ios/www/plugins/cordova-plugin-camera/www/Camera.js
vendored
Normal file
@@ -0,0 +1,188 @@
|
||||
cordova.define("cordova-plugin-camera.camera", function(require, exports, module) {
|
||||
/*
|
||||
*
|
||||
* 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 argscheck = require('cordova/argscheck');
|
||||
var exec = require('cordova/exec');
|
||||
var Camera = require('./Camera');
|
||||
// XXX: commented out
|
||||
// CameraPopoverHandle = require('./CameraPopoverHandle');
|
||||
|
||||
/**
|
||||
* @namespace navigator
|
||||
*/
|
||||
|
||||
/**
|
||||
* @exports camera
|
||||
*/
|
||||
var cameraExport = {};
|
||||
|
||||
// Tack on the Camera Constants to the base camera plugin.
|
||||
for (var key in Camera) {
|
||||
cameraExport[key] = Camera[key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function that provides an error message.
|
||||
* @callback module:camera.onError
|
||||
* @param {string} message - The message is provided by the device's native code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Callback function that provides the image data.
|
||||
* @callback module:camera.onSuccess
|
||||
* @param {string} imageData - Base64 encoding of the image data, _or_ the image file URI, depending on [`cameraOptions`]{@link module:camera.CameraOptions} in effect.
|
||||
* @example
|
||||
* // Show image
|
||||
* //
|
||||
* function cameraCallback(imageData) {
|
||||
* var image = document.getElementById('myImage');
|
||||
* image.src = "data:image/jpeg;base64," + imageData;
|
||||
* }
|
||||
*/
|
||||
|
||||
/**
|
||||
* Optional parameters to customize the camera settings.
|
||||
* * [Quirks](#CameraOptions-quirks)
|
||||
* @typedef module:camera.CameraOptions
|
||||
* @type {Object}
|
||||
* @property {number} [quality=50] - Quality of the saved image, expressed as a range of 0-100, where 100 is typically full resolution with no loss from file compression. (Note that information about the camera's resolution is unavailable.)
|
||||
* @property {module:Camera.DestinationType} [destinationType=FILE_URI] - Choose the format of the return value.
|
||||
* @property {module:Camera.PictureSourceType} [sourceType=CAMERA] - Set the source of the picture.
|
||||
* @property {Boolean} [allowEdit=false] - Allow simple editing of image before selection.
|
||||
* @property {module:Camera.EncodingType} [encodingType=JPEG] - Choose the returned image file's encoding.
|
||||
* @property {number} [targetWidth] - Width in pixels to scale image. Must be used with `targetHeight`. Aspect ratio remains constant.
|
||||
* @property {number} [targetHeight] - Height in pixels to scale image. Must be used with `targetWidth`. Aspect ratio remains constant.
|
||||
* @property {module:Camera.MediaType} [mediaType=PICTURE] - Set the type of media to select from. Only works when `PictureSourceType` is `PHOTOLIBRARY` or `SAVEDPHOTOALBUM`.
|
||||
* @property {Boolean} [correctOrientation] - Rotate the image to correct for the orientation of the device during capture.
|
||||
* @property {Boolean} [saveToPhotoAlbum] - Save the image to the photo album on the device after capture.
|
||||
* @property {module:CameraPopoverOptions} [popoverOptions] - iOS-only options that specify popover location in iPad.
|
||||
* @property {module:Camera.Direction} [cameraDirection=BACK] - Choose the camera to use (front- or back-facing).
|
||||
*/
|
||||
|
||||
/**
|
||||
* @description Takes a photo using the camera, or retrieves a photo from the device's
|
||||
* image gallery. The image is passed to the success callback as a
|
||||
* Base64-encoded `String`, or as the URI for the image file.
|
||||
*
|
||||
* The `camera.getPicture` function opens the device's default camera
|
||||
* application that allows users to snap pictures by default - this behavior occurs,
|
||||
* when `Camera.sourceType` equals [`Camera.PictureSourceType.CAMERA`]{@link module:Camera.PictureSourceType}.
|
||||
* Once the user snaps the photo, the camera application closes and the application is restored.
|
||||
*
|
||||
* If `Camera.sourceType` is `Camera.PictureSourceType.PHOTOLIBRARY` or
|
||||
* `Camera.PictureSourceType.SAVEDPHOTOALBUM`, then a dialog displays
|
||||
* that allows users to select an existing image.
|
||||
*
|
||||
* The return value is sent to the [`cameraSuccess`]{@link module:camera.onSuccess} callback function, in
|
||||
* one of the following formats, depending on the specified
|
||||
* `cameraOptions`:
|
||||
*
|
||||
* - A `String` containing the Base64-encoded photo image.
|
||||
* - A `String` representing the image file location on local storage (default).
|
||||
*
|
||||
* You can do whatever you want with the encoded image or URI, for
|
||||
* example:
|
||||
*
|
||||
* - Render the image in an `<img>` tag, as in the example below
|
||||
* - Save the data locally (`LocalStorage`, [Lawnchair](http://brianleroux.github.com/lawnchair/), etc.)
|
||||
* - Post the data to a remote server
|
||||
*
|
||||
* __NOTE__: Photo resolution on newer devices is quite good. Photos
|
||||
* selected from the device's gallery are not downscaled to a lower
|
||||
* quality, even if a `quality` parameter is specified. To avoid common
|
||||
* memory problems, set `Camera.destinationType` to `FILE_URI` rather
|
||||
* than `DATA_URL`.
|
||||
*
|
||||
* __Supported Platforms__
|
||||
*
|
||||
* - Android
|
||||
* - BlackBerry
|
||||
* - Browser
|
||||
* - Firefox
|
||||
* - FireOS
|
||||
* - iOS
|
||||
* - Windows
|
||||
* - WP8
|
||||
* - Ubuntu
|
||||
*
|
||||
* More examples [here](#camera-getPicture-examples). Quirks [here](#camera-getPicture-quirks).
|
||||
*
|
||||
* @example
|
||||
* navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions);
|
||||
* @param {module:camera.onSuccess} successCallback
|
||||
* @param {module:camera.onError} errorCallback
|
||||
* @param {module:camera.CameraOptions} options CameraOptions
|
||||
*/
|
||||
cameraExport.getPicture = function (successCallback, errorCallback, options) {
|
||||
argscheck.checkArgs('fFO', 'Camera.getPicture', arguments);
|
||||
options = options || {};
|
||||
var getValue = argscheck.getValue;
|
||||
|
||||
var quality = getValue(options.quality, 50);
|
||||
var destinationType = getValue(options.destinationType, Camera.DestinationType.FILE_URI);
|
||||
var sourceType = getValue(options.sourceType, Camera.PictureSourceType.CAMERA);
|
||||
var targetWidth = getValue(options.targetWidth, -1);
|
||||
var targetHeight = getValue(options.targetHeight, -1);
|
||||
var encodingType = getValue(options.encodingType, Camera.EncodingType.JPEG);
|
||||
var mediaType = getValue(options.mediaType, Camera.MediaType.PICTURE);
|
||||
var allowEdit = !!options.allowEdit;
|
||||
var correctOrientation = !!options.correctOrientation;
|
||||
var saveToPhotoAlbum = !!options.saveToPhotoAlbum;
|
||||
var popoverOptions = getValue(options.popoverOptions, null);
|
||||
var cameraDirection = getValue(options.cameraDirection, Camera.Direction.BACK);
|
||||
|
||||
var args = [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType,
|
||||
mediaType, allowEdit, correctOrientation, saveToPhotoAlbum, popoverOptions, cameraDirection];
|
||||
|
||||
exec(successCallback, errorCallback, 'Camera', 'takePicture', args);
|
||||
// XXX: commented out
|
||||
// return new CameraPopoverHandle();
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes intermediate image files that are kept in temporary storage
|
||||
* after calling [`camera.getPicture`]{@link module:camera.getPicture}. Applies only when the value of
|
||||
* `Camera.sourceType` equals `Camera.PictureSourceType.CAMERA` and the
|
||||
* `Camera.destinationType` equals `Camera.DestinationType.FILE_URI`.
|
||||
*
|
||||
* __Supported Platforms__
|
||||
*
|
||||
* - iOS
|
||||
*
|
||||
* @example
|
||||
* navigator.camera.cleanup(onSuccess, onFail);
|
||||
*
|
||||
* function onSuccess() {
|
||||
* console.log("Camera cleanup success.")
|
||||
* }
|
||||
*
|
||||
* function onFail(message) {
|
||||
* alert('Failed because: ' + message);
|
||||
* }
|
||||
*/
|
||||
cameraExport.cleanup = function (successCallback, errorCallback) {
|
||||
exec(successCallback, errorCallback, 'Camera', 'cleanup', []);
|
||||
};
|
||||
|
||||
module.exports = cameraExport;
|
||||
|
||||
});
|
||||
104
src/cordova/platforms/ios/www/plugins/cordova-plugin-camera/www/CameraConstants.js
vendored
Normal file
104
src/cordova/platforms/ios/www/plugins/cordova-plugin-camera/www/CameraConstants.js
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
cordova.define("cordova-plugin-camera.Camera", function(require, exports, module) {
|
||||
/*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @module Camera
|
||||
*/
|
||||
module.exports = {
|
||||
/**
|
||||
* @description
|
||||
* Defines the output format of `Camera.getPicture` call.
|
||||
* _Note:_ On iOS passing `DestinationType.NATIVE_URI` along with
|
||||
* `PictureSourceType.PHOTOLIBRARY` or `PictureSourceType.SAVEDPHOTOALBUM` will
|
||||
* disable any image modifications (resize, quality change, cropping, etc.) due
|
||||
* to implementation specific.
|
||||
*
|
||||
* @enum {number}
|
||||
*/
|
||||
DestinationType: {
|
||||
/** Return base64 encoded string. DATA_URL can be very memory intensive and cause app crashes or out of memory errors. Use FILE_URI or NATIVE_URI if possible */
|
||||
DATA_URL: 0,
|
||||
/** Return file uri (content://media/external/images/media/2 for Android) */
|
||||
FILE_URI: 1,
|
||||
/** Return native uri (eg. asset-library://... for iOS) */
|
||||
NATIVE_URI: 2
|
||||
},
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
EncodingType: {
|
||||
/** Return JPEG encoded image */
|
||||
JPEG: 0,
|
||||
/** Return PNG encoded image */
|
||||
PNG: 1
|
||||
},
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
MediaType: {
|
||||
/** Allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType */
|
||||
PICTURE: 0,
|
||||
/** Allow selection of video only, ONLY RETURNS URL */
|
||||
VIDEO: 1,
|
||||
/** Allow selection from all media types */
|
||||
ALLMEDIA: 2
|
||||
},
|
||||
/**
|
||||
* @description
|
||||
* Defines the output format of `Camera.getPicture` call.
|
||||
* _Note:_ On iOS passing `PictureSourceType.PHOTOLIBRARY` or `PictureSourceType.SAVEDPHOTOALBUM`
|
||||
* along with `DestinationType.NATIVE_URI` will disable any image modifications (resize, quality
|
||||
* change, cropping, etc.) due to implementation specific.
|
||||
*
|
||||
* @enum {number}
|
||||
*/
|
||||
PictureSourceType: {
|
||||
/** Choose image from the device's photo library (same as SAVEDPHOTOALBUM for Android) */
|
||||
PHOTOLIBRARY: 0,
|
||||
/** Take picture from camera */
|
||||
CAMERA: 1,
|
||||
/** Choose image only from the device's Camera Roll album (same as PHOTOLIBRARY for Android) */
|
||||
SAVEDPHOTOALBUM: 2
|
||||
},
|
||||
/**
|
||||
* Matches iOS UIPopoverArrowDirection constants to specify arrow location on popover.
|
||||
* @enum {number}
|
||||
*/
|
||||
PopoverArrowDirection: {
|
||||
ARROW_UP: 1,
|
||||
ARROW_DOWN: 2,
|
||||
ARROW_LEFT: 4,
|
||||
ARROW_RIGHT: 8,
|
||||
ARROW_ANY: 15
|
||||
},
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Direction: {
|
||||
/** Use the back-facing camera */
|
||||
BACK: 0,
|
||||
/** Use the front-facing camera */
|
||||
FRONT: 1
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
55
src/cordova/platforms/ios/www/plugins/cordova-plugin-camera/www/CameraPopoverOptions.js
vendored
Normal file
55
src/cordova/platforms/ios/www/plugins/cordova-plugin-camera/www/CameraPopoverOptions.js
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
cordova.define("cordova-plugin-camera.CameraPopoverOptions", function(require, exports, module) {
|
||||
/*
|
||||
*
|
||||
* 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 Camera = require('./Camera');
|
||||
|
||||
/**
|
||||
* @namespace navigator
|
||||
*/
|
||||
|
||||
/**
|
||||
* iOS-only parameters that specify the anchor element location and arrow
|
||||
* direction of the popover when selecting images from an iPad's library
|
||||
* or album.
|
||||
* Note that the size of the popover may change to adjust to the
|
||||
* direction of the arrow and orientation of the screen. Make sure to
|
||||
* account for orientation changes when specifying the anchor element
|
||||
* location.
|
||||
* @module CameraPopoverOptions
|
||||
* @param {Number} [x=0] - x pixel coordinate of screen element onto which to anchor the popover.
|
||||
* @param {Number} [y=32] - y pixel coordinate of screen element onto which to anchor the popover.
|
||||
* @param {Number} [width=320] - width, in pixels, of the screen element onto which to anchor the popover.
|
||||
* @param {Number} [height=480] - height, in pixels, of the screen element onto which to anchor the popover.
|
||||
* @param {module:Camera.PopoverArrowDirection} [arrowDir=ARROW_ANY] - Direction the arrow on the popover should point.
|
||||
*/
|
||||
var CameraPopoverOptions = function (x, y, width, height, arrowDir) {
|
||||
// information of rectangle that popover should be anchored to
|
||||
this.x = x || 0;
|
||||
this.y = y || 32;
|
||||
this.width = width || 320;
|
||||
this.height = height || 480;
|
||||
this.arrowDir = arrowDir || Camera.PopoverArrowDirection.ARROW_ANY;
|
||||
};
|
||||
|
||||
module.exports = CameraPopoverOptions;
|
||||
|
||||
});
|
||||
69
src/cordova/platforms/ios/www/plugins/cordova-plugin-camera/www/ios/CameraPopoverHandle.js
vendored
Normal file
69
src/cordova/platforms/ios/www/plugins/cordova-plugin-camera/www/ios/CameraPopoverHandle.js
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
cordova.define("cordova-plugin-camera.CameraPopoverHandle", function(require, exports, module) {
|
||||
/*
|
||||
*
|
||||
* 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');
|
||||
|
||||
/**
|
||||
* @namespace navigator
|
||||
*/
|
||||
|
||||
/**
|
||||
* A handle to an image picker popover.
|
||||
*
|
||||
* __Supported Platforms__
|
||||
*
|
||||
* - iOS
|
||||
*
|
||||
* @example
|
||||
* navigator.camera.getPicture(onSuccess, onFail,
|
||||
* {
|
||||
* destinationType: Camera.DestinationType.FILE_URI,
|
||||
* sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
|
||||
* popoverOptions: new CameraPopoverOptions(300, 300, 100, 100, Camera.PopoverArrowDirection.ARROW_ANY)
|
||||
* });
|
||||
*
|
||||
* // Reposition the popover if the orientation changes.
|
||||
* window.onorientationchange = function() {
|
||||
* var cameraPopoverHandle = new CameraPopoverHandle();
|
||||
* var cameraPopoverOptions = new CameraPopoverOptions(0, 0, 100, 100, Camera.PopoverArrowDirection.ARROW_ANY);
|
||||
* cameraPopoverHandle.setPosition(cameraPopoverOptions);
|
||||
* }
|
||||
* @module CameraPopoverHandle
|
||||
*/
|
||||
var CameraPopoverHandle = function () {
|
||||
/**
|
||||
* Can be used to reposition the image selection dialog,
|
||||
* for example, when the device orientation changes.
|
||||
* @memberof CameraPopoverHandle
|
||||
* @instance
|
||||
* @method setPosition
|
||||
* @param {module:CameraPopoverOptions} popoverOptions
|
||||
*/
|
||||
this.setPosition = function (popoverOptions) {
|
||||
var args = [ popoverOptions ];
|
||||
exec(null, null, 'Camera', 'repositionPopover', args);
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = CameraPopoverHandle;
|
||||
|
||||
});
|
||||
133
src/cordova/platforms/ios/www/plugins/cordova-plugin-dialogs/www/notification.js
vendored
Normal file
133
src/cordova/platforms/ios/www/plugins/cordova-plugin-dialogs/www/notification.js
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
cordova.define("cordova-plugin-dialogs.notification", function(require, exports, module) {
|
||||
/*
|
||||
*
|
||||
* 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 platform = require('cordova/platform');
|
||||
|
||||
/**
|
||||
* Provides access to notifications on the device.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
|
||||
/**
|
||||
* Open a native alert dialog, with a customizable title and button text.
|
||||
*
|
||||
* @param {String} message Message to print in the body of the alert
|
||||
* @param {Function} completeCallback The callback that is called when user clicks on a button.
|
||||
* @param {String} title Title of the alert dialog (default: Alert)
|
||||
* @param {String} buttonLabel Label of the close button (default: OK)
|
||||
*/
|
||||
alert: function (message, completeCallback, title, buttonLabel) {
|
||||
var _message = (typeof message === 'string' ? message : JSON.stringify(message));
|
||||
var _title = (typeof title === 'string' ? title : 'Alert');
|
||||
var _buttonLabel = (buttonLabel && typeof buttonLabel === 'string' ? buttonLabel : 'OK');
|
||||
exec(completeCallback, null, 'Notification', 'alert', [_message, _title, _buttonLabel]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Open a native confirm dialog, with a customizable title and button text.
|
||||
* The result that the user selects is returned to the result callback.
|
||||
*
|
||||
* @param {String} message Message to print in the body of the alert
|
||||
* @param {Function} resultCallback The callback that is called when user clicks on a button.
|
||||
* @param {String} title Title of the alert dialog (default: Confirm)
|
||||
* @param {Array} buttonLabels Array of the labels of the buttons (default: ['OK', 'Cancel'])
|
||||
*/
|
||||
confirm: function (message, resultCallback, title, buttonLabels) {
|
||||
var _message = (typeof message === 'string' ? message : JSON.stringify(message));
|
||||
var _title = (typeof title === 'string' ? title : 'Confirm');
|
||||
var _buttonLabels = (buttonLabels || ['OK', 'Cancel']);
|
||||
|
||||
// Strings are deprecated!
|
||||
if (typeof _buttonLabels === 'string') {
|
||||
console.log('Notification.confirm(string, function, string, string) is deprecated. Use Notification.confirm(string, function, string, array).');
|
||||
}
|
||||
|
||||
_buttonLabels = convertButtonLabels(_buttonLabels);
|
||||
|
||||
exec(resultCallback, null, 'Notification', 'confirm', [_message, _title, _buttonLabels]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Open a native prompt dialog, with a customizable title and button text.
|
||||
* The following results are returned to the result callback:
|
||||
* buttonIndex Index number of the button selected.
|
||||
* input1 The text entered in the prompt dialog box.
|
||||
*
|
||||
* @param {String} message Dialog message to display (default: "Prompt message")
|
||||
* @param {Function} resultCallback The callback that is called when user clicks on a button.
|
||||
* @param {String} title Title of the dialog (default: "Prompt")
|
||||
* @param {Array} buttonLabels Array of strings for the button labels (default: ["OK","Cancel"])
|
||||
* @param {String} defaultText Textbox input value (default: empty string)
|
||||
*/
|
||||
prompt: function (message, resultCallback, title, buttonLabels, defaultText) {
|
||||
var _message = (typeof message === 'string' ? message : JSON.stringify(message));
|
||||
var _title = (typeof title === 'string' ? title : 'Prompt');
|
||||
var _buttonLabels = (buttonLabels || ['OK', 'Cancel']);
|
||||
|
||||
// Strings are deprecated!
|
||||
if (typeof _buttonLabels === 'string') {
|
||||
console.log('Notification.prompt(string, function, string, string) is deprecated. Use Notification.confirm(string, function, string, array).');
|
||||
}
|
||||
|
||||
_buttonLabels = convertButtonLabels(_buttonLabels);
|
||||
|
||||
var _defaultText = (defaultText || '');
|
||||
exec(resultCallback, null, 'Notification', 'prompt', [_message, _title, _buttonLabels, _defaultText]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Causes the device to beep.
|
||||
* On Android, the default notification ringtone is played "count" times.
|
||||
*
|
||||
* @param {Integer} count The number of beeps.
|
||||
*/
|
||||
beep: function (count) {
|
||||
var defaultedCount = count || 1;
|
||||
exec(null, null, 'Notification', 'beep', [ defaultedCount ]);
|
||||
}
|
||||
};
|
||||
|
||||
function convertButtonLabels (buttonLabels) {
|
||||
|
||||
// Some platforms take an array of button label names.
|
||||
// Other platforms take a comma separated list.
|
||||
// For compatibility, we convert to the desired type based on the platform.
|
||||
if (platform.id === 'amazon-fireos' || platform.id === 'android' || platform.id === 'ios' ||
|
||||
platform.id === 'windowsphone' || platform.id === 'firefoxos' || platform.id === 'ubuntu' ||
|
||||
platform.id === 'windows8' || platform.id === 'windows') {
|
||||
|
||||
if (typeof buttonLabels === 'string') {
|
||||
buttonLabels = buttonLabels.split(','); // not crazy about changing the var type here
|
||||
}
|
||||
} else {
|
||||
if (Array.isArray(buttonLabels)) {
|
||||
var buttonLabelArray = buttonLabels;
|
||||
buttonLabels = buttonLabelArray.toString();
|
||||
}
|
||||
}
|
||||
|
||||
return buttonLabels;
|
||||
}
|
||||
|
||||
});
|
||||
159
src/cordova/platforms/ios/www/plugins/phonegap-plugin-barcodescanner/www/barcodescanner.js
vendored
Normal file
159
src/cordova/platforms/ios/www/plugins/phonegap-plugin-barcodescanner/www/barcodescanner.js
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
cordova.define("phonegap-plugin-barcodescanner.BarcodeScanner", function(require, exports, module) {
|
||||
/**
|
||||
* cordova is available under the MIT License (2008).
|
||||
* See http://opensource.org/licenses/alphabetical for full text.
|
||||
*
|
||||
* Copyright (c) Matt Kane 2010
|
||||
* Copyright (c) 2011, IBM Corporation
|
||||
* Copyright (c) 2012-2017, Adobe Systems
|
||||
*/
|
||||
|
||||
|
||||
var exec = cordova.require("cordova/exec");
|
||||
|
||||
var scanInProgress = false;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @returns {BarcodeScanner}
|
||||
*/
|
||||
function BarcodeScanner() {
|
||||
|
||||
/**
|
||||
* Encoding constants.
|
||||
*
|
||||
* @type Object
|
||||
*/
|
||||
this.Encode = {
|
||||
TEXT_TYPE: "TEXT_TYPE",
|
||||
EMAIL_TYPE: "EMAIL_TYPE",
|
||||
PHONE_TYPE: "PHONE_TYPE",
|
||||
SMS_TYPE: "SMS_TYPE"
|
||||
// CONTACT_TYPE: "CONTACT_TYPE", // TODO: not implemented, requires passing a Bundle class from Javascript to Java
|
||||
// LOCATION_TYPE: "LOCATION_TYPE" // TODO: not implemented, requires passing a Bundle class from Javascript to Java
|
||||
};
|
||||
|
||||
/**
|
||||
* Barcode format constants, defined in ZXing library.
|
||||
*
|
||||
* @type Object
|
||||
*/
|
||||
this.format = {
|
||||
"all_1D": 61918,
|
||||
"aztec": 1,
|
||||
"codabar": 2,
|
||||
"code_128": 16,
|
||||
"code_39": 4,
|
||||
"code_93": 8,
|
||||
"data_MATRIX": 32,
|
||||
"ean_13": 128,
|
||||
"ean_8": 64,
|
||||
"itf": 256,
|
||||
"maxicode": 512,
|
||||
"msi": 131072,
|
||||
"pdf_417": 1024,
|
||||
"plessey": 262144,
|
||||
"qr_CODE": 2048,
|
||||
"rss_14": 4096,
|
||||
"rss_EXPANDED": 8192,
|
||||
"upc_A": 16384,
|
||||
"upc_E": 32768,
|
||||
"upc_EAN_EXTENSION": 65536
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Read code from scanner.
|
||||
*
|
||||
* @param {Function} successCallback This function will recieve a result object: {
|
||||
* text : '12345-mock', // The code that was scanned.
|
||||
* format : 'FORMAT_NAME', // Code format.
|
||||
* cancelled : true/false, // Was canceled.
|
||||
* }
|
||||
* @param {Function} errorCallback
|
||||
* @param config
|
||||
*/
|
||||
BarcodeScanner.prototype.scan = function (successCallback, errorCallback, config) {
|
||||
|
||||
if (config instanceof Array) {
|
||||
// do nothing
|
||||
} else {
|
||||
if (typeof(config) === 'object') {
|
||||
// string spaces between formats, ZXing does not like that
|
||||
if (config.formats) {
|
||||
config.formats = config.formats.replace(/\s+/g, '');
|
||||
}
|
||||
config = [ config ];
|
||||
} else {
|
||||
config = [];
|
||||
}
|
||||
}
|
||||
|
||||
if (errorCallback == null) {
|
||||
errorCallback = function () {
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof errorCallback != "function") {
|
||||
console.log("BarcodeScanner.scan failure: failure parameter not a function");
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof successCallback != "function") {
|
||||
console.log("BarcodeScanner.scan failure: success callback parameter must be a function");
|
||||
return;
|
||||
}
|
||||
|
||||
if (scanInProgress) {
|
||||
errorCallback('Scan is already in progress');
|
||||
return;
|
||||
}
|
||||
|
||||
scanInProgress = true;
|
||||
|
||||
exec(
|
||||
function(result) {
|
||||
scanInProgress = false;
|
||||
// work around bug in ZXing library
|
||||
if (result.format === 'UPC_A' && result.text.length === 13) {
|
||||
result.text = result.text.substring(1);
|
||||
}
|
||||
successCallback(result);
|
||||
},
|
||||
function(error) {
|
||||
scanInProgress = false;
|
||||
errorCallback(error);
|
||||
},
|
||||
'BarcodeScanner',
|
||||
'scan',
|
||||
config
|
||||
);
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
BarcodeScanner.prototype.encode = function (type, data, successCallback, errorCallback, options) {
|
||||
if (errorCallback == null) {
|
||||
errorCallback = function () {
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof errorCallback != "function") {
|
||||
console.log("BarcodeScanner.encode failure: failure parameter not a function");
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof successCallback != "function") {
|
||||
console.log("BarcodeScanner.encode failure: success callback parameter must be a function");
|
||||
return;
|
||||
}
|
||||
|
||||
exec(successCallback, errorCallback, 'BarcodeScanner', 'encode', [
|
||||
{"type": type, "data": data, "options": options}
|
||||
]);
|
||||
};
|
||||
|
||||
var barcodeScanner = new BarcodeScanner();
|
||||
module.exports = barcodeScanner;
|
||||
|
||||
});
|
||||
108
src/cordova/platforms/ios/www/plugins/phonegap-plugin-local-notification/www/notification.js
vendored
Normal file
108
src/cordova/platforms/ios/www/plugins/phonegap-plugin-local-notification/www/notification.js
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
cordova.define("phonegap-plugin-local-notification.Notification", function(require, exports, module) {
|
||||
/* global cordova:false */
|
||||
/* globals window */
|
||||
|
||||
var argscheck = cordova.require('cordova/argscheck'),
|
||||
exec = cordova.require('cordova/exec'),
|
||||
utils = cordova.require('cordova/utils');
|
||||
|
||||
/**
|
||||
* @description A global object that lets you interact with the Notification API.
|
||||
* @global
|
||||
* @param {!string} title of the local notification.
|
||||
* @param {?Options} options An object containing optional property/value pairs.
|
||||
*/
|
||||
var Notification = function(title, options) {
|
||||
// require title parameter
|
||||
if (typeof title === 'undefined') {
|
||||
throw new Error('The title argument is required.');
|
||||
}
|
||||
|
||||
options = options || {};
|
||||
var getValue = argscheck.getValue;
|
||||
|
||||
this.permission = 'granted';
|
||||
this.title = getValue(title, '');
|
||||
this.dir = getValue(options.dir, 'auto');
|
||||
this.lang = getValue(options.lang, '');
|
||||
this.body = getValue(options.body, '');
|
||||
this.tag = getValue(options.tag, '');
|
||||
this.icon = getValue(options.icon, '');
|
||||
this.onclick = function() {};
|
||||
this.onshow = function() {};
|
||||
this.onerror = function() {};
|
||||
this.onclose = function() {};
|
||||
|
||||
// triggered on click, show, error and close
|
||||
var that = this;
|
||||
var success = function(result) {
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (result === 'show') {
|
||||
that.onshow();
|
||||
} else if (result === 'click') {
|
||||
that.onclick();
|
||||
}
|
||||
};
|
||||
|
||||
var failure = function() {
|
||||
that.onerror();
|
||||
};
|
||||
|
||||
exec(success, failure, 'LocalNotifications', 'show', [this.title, this.dir, this.lang, this.body, this.tag, this.icon]);
|
||||
};
|
||||
|
||||
/**
|
||||
* @description requests permission from the user to show a local notification.
|
||||
* @function requestPermission
|
||||
* @memberof Notification
|
||||
* @param {!callback} callback - See type definition.
|
||||
*/
|
||||
Notification.requestPermission = function(callback) {
|
||||
if (!callback) { callback = function() {}; }
|
||||
|
||||
if (typeof callback !== 'function') {
|
||||
console.log('Notification.requestPermission failure: callback parameter not a function');
|
||||
return;
|
||||
}
|
||||
|
||||
exec(callback, function() {
|
||||
console.log('requestPermission error');
|
||||
}, 'LocalNotifications', 'requestPermission', []);
|
||||
};
|
||||
|
||||
/**
|
||||
* @description closes an open notification.
|
||||
* @function close
|
||||
* @memberof Notification
|
||||
*/
|
||||
Notification.prototype.close = function() {
|
||||
var that = this;
|
||||
exec(function() {
|
||||
that.onclose();
|
||||
}, function() {
|
||||
that.onerror();
|
||||
}, 'LocalNotifications', 'close', [this.tag]);
|
||||
};
|
||||
|
||||
/**
|
||||
* @description A callback to be used when the requestPermission method returns a value.
|
||||
*
|
||||
* @callback callback
|
||||
* @param {string} permission - one of "default", "denied" or "granted"
|
||||
*/
|
||||
|
||||
/*
|
||||
* @typedef {Object} Options - An object for configuring Notification behavior.
|
||||
* @property {string} [dir='auto'] - Sets the direction of the notification. One of "auto", "ltr" or "rtl"
|
||||
* @property {string} [lang=''] - Sets the language of the notification
|
||||
* @property {string} [body=''] - Sets the body of the notification
|
||||
* @property {string} [tag=''] - Sets the identifying tag of the notification
|
||||
* @property {string} [icon=''] - Sets the icon of the notification
|
||||
*/
|
||||
|
||||
module.exports = Notification;
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user