mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-26 20:33:07 +08:00
Updating the JS, even though it shouldn't be here. CB-290
This commit is contained in:
parent
79935d31ef
commit
adb871f9e1
@ -188,7 +188,9 @@
|
|||||||
same "printed page" as the copyright notice for easier
|
same "printed page" as the copyright notice for easier
|
||||||
identification within third-party archives.
|
identification within third-party archives.
|
||||||
|
|
||||||
Copyright [yyyy] [name of copyright owner]
|
Copyright 2011 Adobe
|
||||||
|
Copyright 2011 IBM Corporation
|
||||||
|
Copyright 2011 RIM
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@ -202,98 +204,7 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
|
|
||||||
==============================================================
|
|
||||||
This product also include the following software:
|
|
||||||
==============================================================
|
|
||||||
|
|
||||||
--------------------------------------------------------------
|
|
||||||
jasmine from GitHub
|
|
||||||
|
|
||||||
https://github.com/pivotal/jasmine
|
|
||||||
|
|
||||||
MIT-style license
|
|
||||||
|
|
||||||
license available from:
|
|
||||||
|
|
||||||
https://github.com/pivotal/jasmine/blob/master/MIT.LICENSE
|
|
||||||
|
|
||||||
-----------------------------
|
|
||||||
|
|
||||||
Copyright (c) 2008-2011 Pivotal Labs
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
a copy of this software and associated documentation files (the
|
|
||||||
"Software"), to deal in the Software without restriction, including
|
|
||||||
without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
|
||||||
included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------
|
|
||||||
commonjs tests from the commonjs organization at GitHub
|
|
||||||
|
|
||||||
https://github.com/commonjs/commonjs
|
|
||||||
|
|
||||||
MIT-style license
|
|
||||||
|
|
||||||
license available from:
|
|
||||||
|
|
||||||
https://github.com/commonjs/commonjs/blob/master/docs/license.html.markdown
|
|
||||||
|
|
||||||
contributor list available from:
|
|
||||||
|
|
||||||
https://github.com/commonjs/commonjs/blob/master/docs/contributors.html.markdown
|
|
||||||
|
|
||||||
-----------------------------
|
|
||||||
|
|
||||||
Copyright 2009 Kevin Dangoor
|
|
||||||
Copyright 2009 Ihab Awad
|
|
||||||
Copyright 2009 Ash Berlin
|
|
||||||
Copyright 2009 Aristid Breitkreuz
|
|
||||||
Copyright 2009 Kevin Dangoor
|
|
||||||
Copyright 2009 Daniel Friesen
|
|
||||||
Copyright 2009 Wes Garland
|
|
||||||
Copyright 2009 Kris Kowal
|
|
||||||
Copyright 2009 Dean Landolt
|
|
||||||
Copyright 2009 Peter Michaux
|
|
||||||
Copyright 2009 George Moschovitis
|
|
||||||
Copyright 2009 Michael O'Brien
|
|
||||||
Copyright 2009 Tom Robinson
|
|
||||||
Copyright 2009 Hannes Wallnoefer
|
|
||||||
Copyright 2009 Mike Wilson
|
|
||||||
Copyright 2009 Ondrej Zara
|
|
||||||
Copyright 2009 Chris Zumbrunn
|
|
||||||
Copyright 2009 Kris Zyp
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
var require,
|
var require,
|
||||||
@ -356,8 +267,7 @@ define('cordova/channel', function(require, exports, module) {
|
|||||||
*/
|
*/
|
||||||
var Channel = function(type, opts) {
|
var Channel = function(type, opts) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.handlers = {};
|
this.handlers = [];
|
||||||
this.numHandlers = 0;
|
|
||||||
this.guid = 0;
|
this.guid = 0;
|
||||||
this.fired = false;
|
this.fired = false;
|
||||||
this.enabled = true;
|
this.enabled = true;
|
||||||
@ -402,7 +312,7 @@ var Channel = function(type, opts) {
|
|||||||
*/
|
*/
|
||||||
Channel.prototype.subscribe = function(f, c, g) {
|
Channel.prototype.subscribe = function(f, c, g) {
|
||||||
// need a function to call
|
// need a function to call
|
||||||
if (f === null || f === undefined) { return; }
|
if (f === null) { return; }
|
||||||
|
|
||||||
var func = f;
|
var func = f;
|
||||||
if (typeof c == "object" && f instanceof Function) { func = utils.close(c, f); }
|
if (typeof c == "object" && f instanceof Function) { func = utils.close(c, f); }
|
||||||
@ -411,7 +321,6 @@ Channel.prototype.subscribe = function(f, c, g) {
|
|||||||
func.observer_guid = g;
|
func.observer_guid = g;
|
||||||
f.observer_guid = g;
|
f.observer_guid = g;
|
||||||
this.handlers[g] = func;
|
this.handlers[g] = func;
|
||||||
this.numHandlers++;
|
|
||||||
if (this.events.onSubscribe) this.events.onSubscribe.call(this);
|
if (this.events.onSubscribe) this.events.onSubscribe.call(this);
|
||||||
return g;
|
return g;
|
||||||
};
|
};
|
||||||
@ -421,9 +330,6 @@ Channel.prototype.subscribe = function(f, c, g) {
|
|||||||
* auto-unsubscribes itself.
|
* auto-unsubscribes itself.
|
||||||
*/
|
*/
|
||||||
Channel.prototype.subscribeOnce = function(f, c) {
|
Channel.prototype.subscribeOnce = function(f, c) {
|
||||||
// need a function to call
|
|
||||||
if (f === null || f === undefined) { return; }
|
|
||||||
|
|
||||||
var g = null;
|
var g = null;
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var m = function() {
|
var m = function() {
|
||||||
@ -443,13 +349,9 @@ Channel.prototype.subscribeOnce = function(f, c) {
|
|||||||
* Unsubscribes the function with the given guid from the channel.
|
* Unsubscribes the function with the given guid from the channel.
|
||||||
*/
|
*/
|
||||||
Channel.prototype.unsubscribe = function(g) {
|
Channel.prototype.unsubscribe = function(g) {
|
||||||
// need a function to unsubscribe
|
|
||||||
if (g === null || g === undefined) { return; }
|
|
||||||
|
|
||||||
if (g instanceof Function) { g = g.observer_guid; }
|
if (g instanceof Function) { g = g.observer_guid; }
|
||||||
this.handlers[g] = null;
|
this.handlers[g] = null;
|
||||||
delete this.handlers[g];
|
delete this.handlers[g];
|
||||||
this.numHandlers--;
|
|
||||||
if (this.events.onUnsubscribe) this.events.onUnsubscribe.call(this);
|
if (this.events.onUnsubscribe) this.events.onUnsubscribe.call(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -984,13 +886,13 @@ module.exports = {
|
|||||||
var backButtonChannel = cordova.addDocumentEventHandler('backbutton', {
|
var backButtonChannel = cordova.addDocumentEventHandler('backbutton', {
|
||||||
onSubscribe:function() {
|
onSubscribe:function() {
|
||||||
// If we just attached the first handler, let native know we need to override the back button.
|
// If we just attached the first handler, let native know we need to override the back button.
|
||||||
if (this.numHandlers === 1) {
|
if (this.handlers.length === 1) {
|
||||||
exec(null, null, "App", "overrideBackbutton", [true]);
|
exec(null, null, "App", "overrideBackbutton", [true]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onUnsubscribe:function() {
|
onUnsubscribe:function() {
|
||||||
// If we just detached the last handler, let native know we no longer override the back button.
|
// If we just detached the last handler, let native know we no longer override the back button.
|
||||||
if (this.numHandlers === 0) {
|
if (this.handlers.length === 0) {
|
||||||
exec(null, null, "App", "overrideBackbutton", [false]);
|
exec(null, null, "App", "overrideBackbutton", [false]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1017,7 +919,7 @@ module.exports = {
|
|||||||
} else {
|
} else {
|
||||||
// Defined, but some Android devices will throw a SECURITY_ERR -
|
// Defined, but some Android devices will throw a SECURITY_ERR -
|
||||||
// so we wrap the whole thing in a try-catch and shim in our own
|
// so we wrap the whole thing in a try-catch and shim in our own
|
||||||
// if the device has Android bug 16175.
|
// because Google broke it in the name of security.
|
||||||
var originalOpenDatabase = window.openDatabase;
|
var originalOpenDatabase = window.openDatabase;
|
||||||
window.openDatabase = function(name, version, desc, size) {
|
window.openDatabase = function(name, version, desc, size) {
|
||||||
var db = null;
|
var db = null;
|
||||||
@ -1187,7 +1089,7 @@ function include(parent, objects, clobber) {
|
|||||||
var result = obj.path ? require(obj.path) : {};
|
var result = obj.path ? require(obj.path) : {};
|
||||||
|
|
||||||
if (clobber) {
|
if (clobber) {
|
||||||
// Clobber if it doesn't exist or if an override is specified.
|
// Set the value if it doesn't exist or if an override is specified.
|
||||||
if (typeof parent[key] === 'undefined' || typeof obj.path !== 'undefined') {
|
if (typeof parent[key] === 'undefined' || typeof obj.path !== 'undefined') {
|
||||||
parent[key] = result;
|
parent[key] = result;
|
||||||
}
|
}
|
||||||
@ -1348,9 +1250,13 @@ var cordova = require('cordova'),
|
|||||||
exec = require('cordova/exec');
|
exec = require('cordova/exec');
|
||||||
|
|
||||||
function handlers() {
|
function handlers() {
|
||||||
return battery.channels.batterystatus.numHandlers +
|
var count = function (a) {
|
||||||
battery.channels.batterylow.numHandlers +
|
return a.filter(function (v) {return !!v;}).length;
|
||||||
battery.channels.batterycritical.numHandlers;
|
};
|
||||||
|
|
||||||
|
return count(module.exports.channels.batterystatus.handlers) +
|
||||||
|
count(module.exports.channels.batterylow.handlers) +
|
||||||
|
count(module.exports.channels.batterycritical.handlers);
|
||||||
}
|
}
|
||||||
|
|
||||||
var Battery = function() {
|
var Battery = function() {
|
||||||
@ -1373,7 +1279,7 @@ var Battery = function() {
|
|||||||
* appropriately (and hopefully save on battery life!).
|
* appropriately (and hopefully save on battery life!).
|
||||||
*/
|
*/
|
||||||
Battery.prototype.onSubscribe = function() {
|
Battery.prototype.onSubscribe = function() {
|
||||||
var me = battery;
|
var me = module.exports; // TODO: i dont like this reference
|
||||||
// If we just registered the first handler, make sure native listener is started.
|
// If we just registered the first handler, make sure native listener is started.
|
||||||
if (handlers() === 1) {
|
if (handlers() === 1) {
|
||||||
exec(me._status, me._error, "Battery", "start", []);
|
exec(me._status, me._error, "Battery", "start", []);
|
||||||
@ -1381,8 +1287,10 @@ Battery.prototype.onSubscribe = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Battery.prototype.onUnsubscribe = function() {
|
Battery.prototype.onUnsubscribe = function() {
|
||||||
var me = battery;
|
var me = module.exports,
|
||||||
|
empty = function (a) {
|
||||||
|
return a.filter(function (v, i) {return v && !!i;});
|
||||||
|
};
|
||||||
// If we just unregistered the last handler, make sure native listener is stopped.
|
// If we just unregistered the last handler, make sure native listener is stopped.
|
||||||
if (handlers() === 0) {
|
if (handlers() === 0) {
|
||||||
exec(null, null, "Battery", "stop", []);
|
exec(null, null, "Battery", "stop", []);
|
||||||
@ -1396,7 +1304,7 @@ Battery.prototype.onUnsubscribe = function() {
|
|||||||
*/
|
*/
|
||||||
Battery.prototype._status = function(info) {
|
Battery.prototype._status = function(info) {
|
||||||
if (info) {
|
if (info) {
|
||||||
var me = battery;
|
var me = module.exports;//TODO: can we eliminate this global ref?
|
||||||
var level = info.level;
|
var level = info.level;
|
||||||
if (me._level !== level || me._isPlugged !== info.isPlugged) {
|
if (me._level !== level || me._isPlugged !== info.isPlugged) {
|
||||||
// Fire batterystatus event
|
// Fire batterystatus event
|
||||||
@ -1424,9 +1332,7 @@ Battery.prototype._error = function(e) {
|
|||||||
console.log("Error initializing Battery: " + e);
|
console.log("Error initializing Battery: " + e);
|
||||||
};
|
};
|
||||||
|
|
||||||
var battery = new Battery();
|
module.exports = new Battery();
|
||||||
|
|
||||||
module.exports = battery;
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1547,16 +1453,16 @@ var exec = require('cordova/exec'),
|
|||||||
* @param {CaptureVideoOptions} options
|
* @param {CaptureVideoOptions} options
|
||||||
*/
|
*/
|
||||||
function _capture(type, successCallback, errorCallback, options) {
|
function _capture(type, successCallback, errorCallback, options) {
|
||||||
var win = function(result) {
|
var win = function(pluginResult) {
|
||||||
var mediaFiles = [];
|
var mediaFiles = [];
|
||||||
var i;
|
var i;
|
||||||
for (i = 0; i < pluginResult.message.length; i++) {
|
for (i = 0; i < pluginResult.length; i++) {
|
||||||
var mediaFile = new MediaFile();
|
var mediaFile = new MediaFile();
|
||||||
mediaFile.name = pluginResult.message[i].name;
|
mediaFile.name = pluginResult[i].name;
|
||||||
mediaFile.fullPath = pluginResult.message[i].fullPath;
|
mediaFile.fullPath = pluginResult[i].fullPath;
|
||||||
mediaFile.type = pluginResult.message[i].type;
|
mediaFile.type = pluginResult[i].type;
|
||||||
mediaFile.lastModifiedDate = pluginResult.message[i].lastModifiedDate;
|
mediaFile.lastModifiedDate = pluginResult[i].lastModifiedDate;
|
||||||
mediaFile.size = pluginResult.message[i].size;
|
mediaFile.size = pluginResult[i].size;
|
||||||
mediaFiles.push(mediaFile);
|
mediaFiles.push(mediaFile);
|
||||||
}
|
}
|
||||||
successCallback(mediaFiles);
|
successCallback(mediaFiles);
|
||||||
@ -2262,10 +2168,7 @@ DirectoryEntry.prototype.getDirectory = function(path, options, successCallback,
|
|||||||
* @param {Function} errorCallback is called with a FileError
|
* @param {Function} errorCallback is called with a FileError
|
||||||
*/
|
*/
|
||||||
DirectoryEntry.prototype.removeRecursively = function(successCallback, errorCallback) {
|
DirectoryEntry.prototype.removeRecursively = function(successCallback, errorCallback) {
|
||||||
var fail = function(code) {
|
exec(successCallback, errorCallback, "File", "removeRecursively", [this.fullPath]);
|
||||||
errorCallback(new FileError(code));
|
|
||||||
};
|
|
||||||
exec(successCallback, fail, "File", "removeRecursively", [this.fullPath]);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2327,10 +2230,7 @@ DirectoryReader.prototype.readEntries = function(successCallback, errorCallback)
|
|||||||
}
|
}
|
||||||
successCallback(retVal);
|
successCallback(retVal);
|
||||||
};
|
};
|
||||||
var fail = function(code) {
|
exec(win, errorCallback, "File", "readEntries", [this.fullPath]);
|
||||||
errorCallback(new FileError(code));
|
|
||||||
};
|
|
||||||
exec(win, fail, "File", "readEntries", [this.path]);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = DirectoryReader;
|
module.exports = DirectoryReader;
|
||||||
@ -2377,10 +2277,8 @@ Entry.prototype.getMetadata = function(successCallback, errorCallback) {
|
|||||||
var metadata = new Metadata(lastModified);
|
var metadata = new Metadata(lastModified);
|
||||||
successCallback(metadata);
|
successCallback(metadata);
|
||||||
};
|
};
|
||||||
var fail = function(code) {
|
|
||||||
errorCallback(new FileError(code));
|
exec(success, errorCallback, "File", "getMetadata", [this.fullPath]);
|
||||||
};
|
|
||||||
exec(success, fail, "File", "getMetadata", [this.fullPath]);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2486,21 +2384,17 @@ Entry.prototype.copyTo = function(parent, newName, successCallback, errorCallbac
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a URL that can be used to identify this entry.
|
* Return a URL that can be used to identify this entry.
|
||||||
*/
|
|
||||||
Entry.prototype.toURL = function() {
|
|
||||||
// fullPath attribute contains the full URL
|
|
||||||
return this.fullPath;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a URI that can be used to identify this entry.
|
|
||||||
*
|
*
|
||||||
* @param {DOMString} mimeType for a FileEntry, the mime type to be used to interpret the file, when loaded through this URI.
|
* @param mimeType
|
||||||
* @return uri
|
* {DOMString} for a FileEntry, the mime type to be used to
|
||||||
|
* interpret the file, when loaded through this URI.
|
||||||
|
* @param successCallback
|
||||||
|
* {Function} called with the new Entry object
|
||||||
|
* @param errorCallback
|
||||||
|
* {Function} called with a FileError
|
||||||
*/
|
*/
|
||||||
Entry.prototype.toURI = function(mimeType) {
|
Entry.prototype.toURL = function(mimeType, successCallback, errorCallback) {
|
||||||
console.log("DEPRECATED: Update your code to use 'toURL'");
|
// fullPath attribute contains the full URL
|
||||||
// fullPath attribute contains the full URI
|
|
||||||
return this.fullPath;
|
return this.fullPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2526,10 +2420,7 @@ Entry.prototype.remove = function(successCallback, errorCallback) {
|
|||||||
* @param errorCallback {Function} called with a FileError
|
* @param errorCallback {Function} called with a FileError
|
||||||
*/
|
*/
|
||||||
Entry.prototype.getParent = function(successCallback, errorCallback) {
|
Entry.prototype.getParent = function(successCallback, errorCallback) {
|
||||||
var fail = function(code) {
|
exec(successCallback, errorCallback, "File", "getParent", [this.fullPath]);
|
||||||
errorCallback(new FileError(code));
|
|
||||||
};
|
|
||||||
exec(successCallback, fail, "File", "getParent", [this.fullPath]);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = Entry;
|
module.exports = Entry;
|
||||||
@ -3417,6 +3308,11 @@ var LocalFileSystem = function() {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Non-standard function
|
||||||
|
LocalFileSystem.prototype.isFileSystemRoot = function(path) {
|
||||||
|
return exec(null, null, "File", "isFileSystemRoot", [path]);
|
||||||
|
};
|
||||||
|
|
||||||
LocalFileSystem.TEMPORARY = 0; //temporary, with no guarantee of persistence
|
LocalFileSystem.TEMPORARY = 0; //temporary, with no guarantee of persistence
|
||||||
LocalFileSystem.PERSISTENT = 1; //persistent
|
LocalFileSystem.PERSISTENT = 1; //persistent
|
||||||
|
|
||||||
@ -3462,6 +3358,12 @@ var Media = function(src, successCallback, errorCallback, statusCallback) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// statusCallback optional
|
||||||
|
if (positionCallback && (typeof positionCallback !== "function")) {
|
||||||
|
console.log("Media Error: positionCallback is not a function");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.id = utils.createUUID();
|
this.id = utils.createUUID();
|
||||||
mediaObjects[this.id] = this;
|
mediaObjects[this.id] = this;
|
||||||
this.src = src;
|
this.src = src;
|
||||||
@ -3576,40 +3478,6 @@ Media.prototype.setVolume = function(volume) {
|
|||||||
exec(null, null, "Media", "setVolume", [this.id, volume]);
|
exec(null, null, "Media", "setVolume", [this.id, volume]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Audio has status update.
|
|
||||||
* PRIVATE
|
|
||||||
*
|
|
||||||
* @param id The media object id (string)
|
|
||||||
* @param status The status code (int)
|
|
||||||
* @param msg The status message (string)
|
|
||||||
*/
|
|
||||||
Media.onStatus = function(id, msg, value) {
|
|
||||||
var media = mediaObjects[id];
|
|
||||||
// If state update
|
|
||||||
if (msg === Media.MEDIA_STATE) {
|
|
||||||
if (value === Media.MEDIA_STOPPED) {
|
|
||||||
if (media.successCallback) {
|
|
||||||
media.successCallback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (media.statusCallback) {
|
|
||||||
media.statusCallback(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (msg === Media.MEDIA_DURATION) {
|
|
||||||
media._duration = value;
|
|
||||||
}
|
|
||||||
else if (msg === Media.MEDIA_ERROR) {
|
|
||||||
if (media.errorCallback) {
|
|
||||||
media.errorCallback({"code":value});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (msg === Media.MEDIA_POSITION) {
|
|
||||||
media._position = value;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = Media;
|
module.exports = Media;
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -3737,28 +3605,15 @@ var exec = require('cordova/exec'),
|
|||||||
var NetworkConnection = function () {
|
var NetworkConnection = function () {
|
||||||
this.type = null;
|
this.type = null;
|
||||||
this._firstRun = true;
|
this._firstRun = true;
|
||||||
this._timer = null;
|
|
||||||
this.timeout = 500;
|
|
||||||
|
|
||||||
var me = this,
|
var me = this,
|
||||||
channel = require('cordova/channel');
|
channel = require('cordova/channel');
|
||||||
|
|
||||||
this.getInfo(
|
this.getInfo(
|
||||||
function (info) {
|
function (info) {
|
||||||
me.type = info;
|
me.type = info.type;
|
||||||
if (info === "none") {
|
if (typeof info.event !== "undefined") {
|
||||||
// set a timer if still offline at the end of timer send the offline event
|
cordova.fireWindowEvent(info.event);
|
||||||
me._timer = setTimeout(function(){
|
|
||||||
cordova.fireWindowEvent("offline");
|
|
||||||
me._timer = null;
|
|
||||||
}, me.timeout);
|
|
||||||
} else {
|
|
||||||
// If there is a current offline event pending clear it
|
|
||||||
if (me._timer !== null) {
|
|
||||||
clearTimeout(me._timer);
|
|
||||||
me._timer = null;
|
|
||||||
}
|
|
||||||
cordova.fireWindowEvent("online");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// should only fire this once
|
// should only fire this once
|
||||||
@ -3965,10 +3820,7 @@ var requestFileSystem = function(type, size, successCallback, errorCallback) {
|
|||||||
errorCallback(new FileError(FileError.NOT_FOUND_ERR));
|
errorCallback(new FileError(FileError.NOT_FOUND_ERR));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var fail = function(e) {
|
exec(success, errorCallback, "File", "requestFileSystem", [type, size]);
|
||||||
errorCallback(new FileError(e));
|
|
||||||
};
|
|
||||||
exec(success, fail, "File", "requestFileSystem", [type, size]);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user