[
https://issues.apache.org/jira/browse/CB-842?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13286835#comment-13286835
]
Aurelien MERCIER commented on CB-842:
-------------------------------------
Tried on Nexus one HTC with Cordova 1.7 (this code include my fix to prevent
Offline method to be executed when the navigator is online):
community.js:
function onDeviceReady() {
try {
jive.profile.onDeviceReadyInit();
} catch (e1) {
console.log("ERROR in onDeviceReady");
console.log(e1);
}
document.addEventListener("offline", onOffline, false);
[...]
}
function onOffline(event) {
if (this.isOfflineAfterOfflineEvent()) {
document.removeEventListener("offline", onOffline, false);
$.mobile.activePage.simpledialog({
width: 'auto',
mode : 'bool',
prompt : 'Network Error',
subTitle: 'Your device must have a working network connection to
use this application.',
useModal: true,
buttons : {
'Close': {
click: function() {},
icon: "delete",
theme: "j"
}
}
});
}
}
function onOffline(event) {
if (this.isOfflineAfterOfflineEvent()) {
document.removeEventListener("offline", onOffline, false);
$.mobile.activePage.simpledialog({
width: 'auto',
mode : 'bool',
prompt : 'Network Error',
subTitle: 'Your device must have a working network connection to
use this application.',
useModal: true,
buttons : {
'Close': {
click: function() {},
icon: "delete",
theme: "j"
}
}
});
}
}
utils.js:
jive.mobile.util = $.extend( jive.mobile.util, {
getBaseURLForHref: function() {
return jive.mobile.nativeapp.baseurl;
},
isOfflineAfterOfflineEvent: function () { //FIXME /CB-842
var res = false;
if ((navigator.network && navigator.network.connection.type !==
Connection.NONE) ||
(navigator.onLine && typeof navigator.onLine == 'boolean' &&
navigator.onLine === false)) {
res = true;
}
return res;
}
});
> Offline event fired without special reasons
> -------------------------------------------
>
> Key: CB-842
> URL: https://issues.apache.org/jira/browse/CB-842
> Project: Apache Cordova
> Issue Type: Bug
> Components: Android
> Affects Versions: 1.7.0
> Reporter: Aurelien MERCIER
>
> The event is fired whereas I'm connected to wifi. Putting some logs in
> offline method, I see that navigator.network.connection.type is NONE and
> navigator.onLine is true.
> Ps: it seems it appears after loading a page...
> Right now I've added extra test in offline method to be sure it has been
> called whereas there is really no connection available.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira