mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 07:02:51 +08:00
updated cordova.js to remove dependency on network status plugin.
This commit is contained in:
parent
5ee178789f
commit
2e5b6bce55
111
framework/assets/www/cordova.js
vendored
111
framework/assets/www/cordova.js
vendored
@ -1,5 +1,5 @@
|
||||
// Platform: android
|
||||
// 2.7.0rc1-116-gf0108ae
|
||||
// 2.7.0rc1-117-g208b97a
|
||||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
@ -19,7 +19,7 @@
|
||||
under the License.
|
||||
*/
|
||||
;(function() {
|
||||
var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-116-gf0108ae';
|
||||
var CORDOVA_JS_BUILD_LABEL = '2.7.0rc1-117-g208b97a';
|
||||
// file: lib/scripts/require.js
|
||||
|
||||
var require,
|
||||
@ -731,9 +731,6 @@ channel.createSticky('onCordovaReady');
|
||||
// Event to indicate that device properties are available
|
||||
channel.createSticky('onCordovaInfoReady');
|
||||
|
||||
// Event to indicate that the connection property has been set.
|
||||
channel.createSticky('onCordovaConnectionReady');
|
||||
|
||||
// Event to indicate that all automatically loaded JS plugins are loaded and ready.
|
||||
channel.createSticky('onPluginsReady');
|
||||
|
||||
@ -751,7 +748,6 @@ channel.createSticky('onDestroy');
|
||||
|
||||
// Channels that must fire before "deviceready" is fired.
|
||||
channel.waitForInitialization('onCordovaReady');
|
||||
channel.waitForInitialization('onCordovaConnectionReady');
|
||||
channel.waitForInitialization('onDOMContentLoaded');
|
||||
|
||||
module.exports = channel;
|
||||
@ -1254,25 +1250,6 @@ module.exports = ConfigurationData;
|
||||
|
||||
});
|
||||
|
||||
// file: lib/common/plugin/Connection.js
|
||||
define("cordova/plugin/Connection", function(require, exports, module) {
|
||||
|
||||
/**
|
||||
* Network status
|
||||
*/
|
||||
module.exports = {
|
||||
UNKNOWN: "unknown",
|
||||
ETHERNET: "ethernet",
|
||||
WIFI: "wifi",
|
||||
CELL_2G: "2g",
|
||||
CELL_3G: "3g",
|
||||
CELL_4G: "4g",
|
||||
CELL:"cellular",
|
||||
NONE: "none"
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
// file: lib/common/plugin/DirectoryEntry.js
|
||||
define("cordova/plugin/DirectoryEntry", function(require, exports, module) {
|
||||
|
||||
@ -4361,90 +4338,6 @@ modulemapper.clobbers('cordova/plugin/MediaError', 'MediaError');
|
||||
|
||||
});
|
||||
|
||||
// file: lib/common/plugin/network.js
|
||||
define("cordova/plugin/network", function(require, exports, module) {
|
||||
|
||||
var exec = require('cordova/exec'),
|
||||
cordova = require('cordova'),
|
||||
channel = require('cordova/channel'),
|
||||
utils = require('cordova/utils');
|
||||
|
||||
// Link the onLine property with the Cordova-supplied network info.
|
||||
// This works because we clobber the naviagtor object with our own
|
||||
// object in bootstrap.js.
|
||||
if (typeof navigator != 'undefined') {
|
||||
utils.defineGetter(navigator, 'onLine', function() {
|
||||
return this.connection.type != 'none';
|
||||
});
|
||||
}
|
||||
|
||||
function NetworkConnection() {
|
||||
this.type = 'unknown';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get connection info
|
||||
*
|
||||
* @param {Function} successCallback The function to call when the Connection data is available
|
||||
* @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL)
|
||||
*/
|
||||
NetworkConnection.prototype.getInfo = function(successCallback, errorCallback) {
|
||||
exec(successCallback, errorCallback, "NetworkStatus", "getConnectionInfo", []);
|
||||
};
|
||||
|
||||
var me = new NetworkConnection();
|
||||
var timerId = null;
|
||||
var timeout = 500;
|
||||
|
||||
channel.onCordovaReady.subscribe(function() {
|
||||
me.getInfo(function(info) {
|
||||
me.type = info;
|
||||
if (info === "none") {
|
||||
// set a timer if still offline at the end of timer send the offline event
|
||||
timerId = setTimeout(function(){
|
||||
cordova.fireDocumentEvent("offline");
|
||||
timerId = null;
|
||||
}, timeout);
|
||||
} else {
|
||||
// If there is a current offline event pending clear it
|
||||
if (timerId !== null) {
|
||||
clearTimeout(timerId);
|
||||
timerId = null;
|
||||
}
|
||||
cordova.fireDocumentEvent("online");
|
||||
}
|
||||
|
||||
// should only fire this once
|
||||
if (channel.onCordovaConnectionReady.state !== 2) {
|
||||
channel.onCordovaConnectionReady.fire();
|
||||
}
|
||||
},
|
||||
function (e) {
|
||||
// If we can't get the network info we should still tell Cordova
|
||||
// to fire the deviceready event.
|
||||
if (channel.onCordovaConnectionReady.state !== 2) {
|
||||
channel.onCordovaConnectionReady.fire();
|
||||
}
|
||||
console.log("Error initializing Network Connection: " + e);
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = me;
|
||||
|
||||
});
|
||||
|
||||
// file: lib/common/plugin/networkstatus/symbols.js
|
||||
define("cordova/plugin/networkstatus/symbols", function(require, exports, module) {
|
||||
|
||||
|
||||
var modulemapper = require('cordova/modulemapper');
|
||||
|
||||
modulemapper.clobbers('cordova/plugin/network', 'navigator.network.connection', 'navigator.network.connection is deprecated. Use navigator.connection instead.');
|
||||
modulemapper.clobbers('cordova/plugin/network', 'navigator.connection');
|
||||
modulemapper.defaults('cordova/plugin/Connection', 'Connection');
|
||||
|
||||
});
|
||||
|
||||
// file: lib/common/plugin/requestFileSystem.js
|
||||
define("cordova/plugin/requestFileSystem", function(require, exports, module) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user