mirror of
https://github.com/apache/cordova-android.git
synced 2026-04-23 00:00:09 +08:00
Merge commit and fix.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// commit 55e46cecd73e06a4866f084ffa8513219ef68421
|
||||
// commit 68eebbca4a3691fed773d7599dd77c0030beabe6
|
||||
|
||||
// File generated at :: Fri May 11 2012 10:34:50 GMT-0700 (PDT)
|
||||
// File generated at :: Thu May 24 2012 09:30:21 GMT-0700 (PDT)
|
||||
|
||||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
@@ -711,6 +711,9 @@ module.exports = {
|
||||
children: {
|
||||
exec: {
|
||||
path: 'cordova/exec'
|
||||
},
|
||||
logger: {
|
||||
path: 'cordova/plugin/logger'
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1144,13 +1147,14 @@ module.exports = {
|
||||
// file: lib/common/plugin/Acceleration.js
|
||||
define("cordova/plugin/Acceleration", function(require, exports, module) {
|
||||
var Acceleration = function(x, y, z, timestamp) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.timestamp = timestamp || (new Date()).getTime();
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.timestamp = timestamp || (new Date()).getTime();
|
||||
};
|
||||
|
||||
module.exports = Acceleration;
|
||||
|
||||
});
|
||||
|
||||
// file: lib/common/plugin/Camera.js
|
||||
@@ -1169,7 +1173,7 @@ for (var key in Camera) {
|
||||
* Gets a picture from source defined by "options.sourceType", and returns the
|
||||
* image as defined by the "options.destinationType" option.
|
||||
|
||||
* The defaults are sourceType=CAMERA and destinationType=FILE_URL.
|
||||
* The defaults are sourceType=CAMERA and destinationType=FILE_URI.
|
||||
*
|
||||
* @param {Function} successCallback
|
||||
* @param {Function} errorCallback
|
||||
@@ -2115,7 +2119,7 @@ Entry.prototype.toURL = function() {
|
||||
Entry.prototype.toURI = function(mimeType) {
|
||||
console.log("DEPRECATED: Update your code to use 'toURL'");
|
||||
// fullPath attribute contains the full URI
|
||||
return this.fullPath;
|
||||
return this.toURL();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -3369,11 +3373,60 @@ define("cordova/plugin/accelerometer", function(require, exports, module) {
|
||||
* @constructor
|
||||
*/
|
||||
var utils = require("cordova/utils"),
|
||||
exec = require("cordova/exec");
|
||||
exec = require("cordova/exec"),
|
||||
Acceleration = require('cordova/plugin/Acceleration');
|
||||
|
||||
// Local singleton variables.
|
||||
// Is the accel sensor running?
|
||||
var running = false;
|
||||
|
||||
// Keeps reference to watchAcceleration calls.
|
||||
var timers = {};
|
||||
|
||||
// Array of listeners; used to keep track of when we should call start and stop.
|
||||
var listeners = [];
|
||||
|
||||
// Last returned acceleration object from native
|
||||
var accel = null;
|
||||
|
||||
// Tells native to start.
|
||||
function start() {
|
||||
exec(function(a) {
|
||||
var tempListeners = listeners.slice(0);
|
||||
accel = new Acceleration(a.x, a.y, a.z, a.timestamp);
|
||||
for (var i = 0, l = tempListeners.length; i < l; i++) {
|
||||
tempListeners[i].win(accel);
|
||||
}
|
||||
}, function(e) {
|
||||
var tempListeners = listeners.slice(0);
|
||||
for (var i = 0, l = tempListeners.length; i < l; i++) {
|
||||
tempListeners[i].fail(e);
|
||||
}
|
||||
}, "Accelerometer", "start", []);
|
||||
running = true;
|
||||
}
|
||||
|
||||
// Tells native to stop.
|
||||
function stop() {
|
||||
exec(null, null, "Accelerometer", "stop", []);
|
||||
running = false;
|
||||
}
|
||||
|
||||
// Adds a callback pair to the listeners array
|
||||
function createCallbackPair(win, fail) {
|
||||
return {win:win, fail:fail};
|
||||
}
|
||||
|
||||
// Removes a win/fail listener pair from the listeners array
|
||||
function removeListeners(l) {
|
||||
var idx = listeners.indexOf(l);
|
||||
if (idx > -1) {
|
||||
listeners.splice(idx, 1);
|
||||
if (listeners.length === 0) {
|
||||
stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var accelerometer = {
|
||||
/**
|
||||
* Asynchronously aquires the current acceleration.
|
||||
@@ -3383,21 +3436,27 @@ var accelerometer = {
|
||||
* @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
|
||||
*/
|
||||
getCurrentAcceleration: function(successCallback, errorCallback, options) {
|
||||
|
||||
// successCallback required
|
||||
if (typeof successCallback !== "function") {
|
||||
console.log("Accelerometer Error: successCallback is not a function");
|
||||
return;
|
||||
throw "getCurrentAcceleration must be called with at least a success callback function as first parameter.";
|
||||
}
|
||||
|
||||
// errorCallback optional
|
||||
if (errorCallback && (typeof errorCallback !== "function")) {
|
||||
console.log("Accelerometer Error: errorCallback is not a function");
|
||||
return;
|
||||
}
|
||||
var p;
|
||||
var win = function(a) {
|
||||
successCallback(a);
|
||||
removeListeners(p);
|
||||
};
|
||||
var fail = function(e) {
|
||||
errorCallback(e);
|
||||
removeListeners(p);
|
||||
};
|
||||
|
||||
// Get acceleration
|
||||
exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
|
||||
p = createCallbackPair(win, fail);
|
||||
listeners.push(p);
|
||||
|
||||
if (!running) {
|
||||
start();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -3409,36 +3468,38 @@ var accelerometer = {
|
||||
* @return String The watch id that must be passed to #clearWatch to stop watching.
|
||||
*/
|
||||
watchAcceleration: function(successCallback, errorCallback, options) {
|
||||
|
||||
// Default interval (10 sec)
|
||||
var frequency = (options !== undefined && options.frequency !== undefined)? options.frequency : 10000;
|
||||
var frequency = (options && options.frequency && typeof options.frequency == 'number') ? options.frequency : 10000;
|
||||
|
||||
// successCallback required
|
||||
if (typeof successCallback !== "function") {
|
||||
console.log("Accelerometer Error: successCallback is not a function");
|
||||
return;
|
||||
throw "watchAcceleration must be called with at least a success callback function as first parameter.";
|
||||
}
|
||||
|
||||
// errorCallback optional
|
||||
if (errorCallback && (typeof errorCallback !== "function")) {
|
||||
console.log("Accelerometer Error: errorCallback is not a function");
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure accelerometer timeout > frequency + 10 sec
|
||||
exec(
|
||||
function(timeout) {
|
||||
if (timeout < (frequency + 10000)) {
|
||||
exec(null, null, "Accelerometer", "setTimeout", [frequency + 10000]);
|
||||
}
|
||||
},
|
||||
function(e) { }, "Accelerometer", "getTimeout", []);
|
||||
|
||||
// Start watch timer
|
||||
// Keep reference to watch id, and report accel readings as often as defined in frequency
|
||||
var id = utils.createUUID();
|
||||
timers[id] = window.setInterval(function() {
|
||||
exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
|
||||
}, (frequency ? frequency : 1));
|
||||
|
||||
var p = createCallbackPair(function(){}, function(e) {
|
||||
errorCallback(e);
|
||||
removeListeners(p);
|
||||
});
|
||||
listeners.push(p);
|
||||
|
||||
timers[id] = {
|
||||
timer:window.setInterval(function() {
|
||||
if (accel) {
|
||||
successCallback(accel);
|
||||
}
|
||||
}, frequency),
|
||||
listeners:p
|
||||
};
|
||||
|
||||
if (running) {
|
||||
// If we're already running then immediately invoke the success callback
|
||||
successCallback(accel);
|
||||
} else {
|
||||
start();
|
||||
}
|
||||
|
||||
return id;
|
||||
},
|
||||
@@ -3449,16 +3510,17 @@ var accelerometer = {
|
||||
* @param {String} id The id of the watch returned from #watchAcceleration.
|
||||
*/
|
||||
clearWatch: function(id) {
|
||||
|
||||
// Stop javascript timer & remove from timer list
|
||||
if (id && timers[id] !== undefined) {
|
||||
window.clearInterval(timers[id]);
|
||||
if (id && timers[id]) {
|
||||
window.clearInterval(timers[id].timer);
|
||||
removeListeners(timers[id].listeners);
|
||||
delete timers[id];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = accelerometer;
|
||||
|
||||
});
|
||||
|
||||
// file: lib/android/plugin/android/app.js
|
||||
@@ -4471,6 +4533,177 @@ var exec = require('cordova/exec'),
|
||||
module.exports = compass;
|
||||
});
|
||||
|
||||
// file: lib/common/plugin/console-via-logger.js
|
||||
define("cordova/plugin/console-via-logger", function(require, exports, module) {
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
var logger = require("cordova/plugin/logger");
|
||||
var utils = require("cordova/utils");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// 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 = utils.vformat(arguments[1], [].slice.call(arguments, 2));
|
||||
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 wrapperedOrigCall(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] = wrapperedOrigCall(WinConsole[key], console[key]);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// file: lib/common/plugin/contacts.js
|
||||
define("cordova/plugin/contacts", function(require, exports, module) {
|
||||
var exec = require('cordova/exec'),
|
||||
@@ -4732,6 +4965,233 @@ module.exports = geolocation;
|
||||
|
||||
});
|
||||
|
||||
// file: lib/common/plugin/logger.js
|
||||
define("cordova/plugin/logger", function(require, exports, module) {
|
||||
//------------------------------------------------------------------------------
|
||||
// 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 utils = require('cordova/utils');
|
||||
|
||||
var UseConsole = true;
|
||||
var Queued = [];
|
||||
var DeviceReady = false;
|
||||
var CurrentLevel;
|
||||
|
||||
/**
|
||||
* 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. Eg, 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. Otherwise, it will use the
|
||||
* native Logger plugin.
|
||||
*/
|
||||
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;
|
||||
};
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs a message at the specified level.
|
||||
*
|
||||
* Parameters passed after message are used applied to
|
||||
* the message with utils.format()
|
||||
*/
|
||||
logger.logLevel = function(level, message /* , ... */) {
|
||||
// format the message with the parameters
|
||||
var formatArgs = [].slice.call(arguments, 2);
|
||||
message = utils.vformat(message, 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;
|
||||
}
|
||||
|
||||
// if not using the console, use the native logger
|
||||
if (!UseConsole) {
|
||||
exec(null, null, "Logger", "logLevel", [level, message]);
|
||||
return;
|
||||
}
|
||||
|
||||
// make sure console is not using logger
|
||||
if (console.__usingCordovaLogger) {
|
||||
throw new Error("console and logger are too intertwingly");
|
||||
}
|
||||
|
||||
// log to the console
|
||||
switch (level) {
|
||||
case logger.LOG: console.log(message); break;
|
||||
case logger.ERROR: console.log("ERROR: " + message); break;
|
||||
case logger.WARN: console.log("WARN: " + message); break;
|
||||
case logger.INFO: console.log("INFO: " + message); break;
|
||||
case logger.DEBUG: console.log("DEBUG: " + message); break;
|
||||
}
|
||||
};
|
||||
|
||||
// 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);
|
||||
|
||||
});
|
||||
|
||||
// file: lib/common/plugin/network.js
|
||||
define("cordova/plugin/network", function(require, exports, module) {
|
||||
var exec = require('cordova/exec'),
|
||||
@@ -5061,6 +5521,16 @@ utils.alert = function(msg) {
|
||||
/**
|
||||
* Formats a string and arguments following it ala sprintf()
|
||||
*
|
||||
* see utils.vformat() for more information
|
||||
*/
|
||||
utils.format = function(formatString /* ,... */) {
|
||||
var args = [].slice.call(arguments, 1);
|
||||
return utils.vformat(formatString, args);
|
||||
};
|
||||
|
||||
/**
|
||||
* Formats a string and arguments following it ala vsprintf()
|
||||
*
|
||||
* format chars:
|
||||
* %j - format arg as JSON
|
||||
* %o - format arg as JSON
|
||||
@@ -5072,14 +5542,13 @@ utils.alert = function(msg) {
|
||||
* for rationale, see FireBug's Console API:
|
||||
* http://getfirebug.com/wiki/index.php/Console_API
|
||||
*/
|
||||
utils.format = function(formatString /* ,... */) {
|
||||
utils.vformat = function(formatString, args) {
|
||||
if (formatString === null || formatString === undefined) return "";
|
||||
if (arguments.length == 1) return formatString.toString();
|
||||
|
||||
var pattern = /(.*?)%(.)(.*)/;
|
||||
var rest = formatString.toString();
|
||||
var result = [];
|
||||
var args = [].slice.call(arguments,1);
|
||||
|
||||
while (args.length) {
|
||||
var arg = args.shift();
|
||||
|
||||
Reference in New Issue
Block a user