Return-Path: X-Original-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A501FDC2B for ; Mon, 3 Sep 2012 17:04:26 +0000 (UTC) Received: (qmail 33098 invoked by uid 500); 3 Sep 2012 17:04:26 -0000 Delivered-To: apmail-incubator-callback-dev-archive@incubator.apache.org Received: (qmail 33052 invoked by uid 500); 3 Sep 2012 17:04:26 -0000 Mailing-List: contact callback-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-dev@incubator.apache.org Received: (qmail 33034 invoked by uid 99); 3 Sep 2012 17:04:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Sep 2012 17:04:26 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of simon.macdonald@gmail.com designates 209.85.160.47 as permitted sender) Received: from [209.85.160.47] (HELO mail-pb0-f47.google.com) (209.85.160.47) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Sep 2012 17:04:22 +0000 Received: by pbcwy7 with SMTP id wy7so8651436pbc.6 for ; Mon, 03 Sep 2012 10:04:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=2na01BduNJtFhiK5mF6j+MdwY08bPwnroHFro3IFGgw=; b=H8dYF4dksYgp6pdc1ReqNga7aKxSymt10aNAfW2Y2Yrfr6zFNcXcSoXX54ViWmF4lh nvi7yMItRkZtPOugLokyhxZx6IKsvdEduPg3TnfDQFAbagQZZkNesQOdoG5jC4wbldDo 1c5rbidx0tPrQJZMPwN6WRszzX/Ugz3epOFy7+Kybzz7cnmbVet1tCw64hndzkSIh2L0 H7I/qmoDQuaGM128o1CHbn5srhWol8dih0OxCLuLhDrVo06b9jvGBV8HZLOGMnzbOF0v nES9mJ5OXpK4Ewy6h5+FSpI7GEiwg1+fIs1E1fqkWnrSOGyPmgl+DqeT/gSlh6UPIa1I iq8A== Received: by 10.68.227.233 with SMTP id sd9mr39302362pbc.48.1346691842048; Mon, 03 Sep 2012 10:04:02 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.2.193 with HTTP; Mon, 3 Sep 2012 10:03:40 -0700 (PDT) In-Reply-To: References: From: Simon MacDonald Date: Mon, 3 Sep 2012 13:03:40 -0400 Message-ID: Subject: Re: online events To: callback-dev@incubator.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org This looks like a good thing to add in 2.2. We should get all the other platforms to add the navigator.connection.network interface to navigator.network as well to remain consistent. Simon Mac Donald http://hi.im/simonmacdonald On Sat, Sep 1, 2012 at 11:26 AM, Andrew Grieve wrote: > Figured out a work-around for clobbering things on navigator on Android > (tested on 2.1 and 2.3): > > var newNavigator = {}; > newNavigator.__proto__ = navigator; > newNavigator.__defineGetter__('onLine', function() { > return network.type != 'none'; > }); > newNavigator.connection = {type: 'wifi'}; > window.navigator = newNavigator; > > I'll hook this up so that connection and onLine will work properly (woohoo!) > > As for events, I don't think document.body is common, but I think > window.addEventListener is quite common since it works on both mobile > safari and android browser. I'll add this to the API review list on the > wiki, but I do need to do something here in the short term since I need to > listen to the browser-fired window online/offline events to implement the > ONLINE_EVENTS exec bridge. How about just put in an android > only work-around for now: > > cordova.addWindowEventHandler('online'); > cordova.addWindowEventHandler('offline'); > function proxyEvent(e) { cordova.fireWindowEvent(e.type); } > document.addEventListener('online', proxyEvent, false); > document.addEventListener('offline', proxyEvent, false); > > > > > On Fri, Aug 31, 2012 at 4:27 PM, Filip Maj wrote: > >> My vote is to keep what we currently document (document.addEventListener) >> - for now. >> >> We should be compiling an "API Review List" on the wiki or something and >> taking notes of all these spec changes, and recommended implementation >> routes for the project. >> >> On 8/31/12 1:21 PM, "Simon MacDonald" wrote: >> >> >Yeah, specs change. Here is the one we originally implemented: >> > >> >http://www.w3.org/TR/netinfo-api/ >> > >> >sharp eyes will note they are using navigator.connection.type and we are >> >using navigator.network.connection.type. That's because the Android web >> >view would not allow us to over-ride navigator.connection. It seems to be >> >a >> >read only object. >> > >> >Simon Mac Donald >> >http://hi.im/simonmacdonald >> > >> > >> >On Fri, Aug 31, 2012 at 3:49 PM, Andrew Grieve >> wrote: >> > >> >> It looks like there is code in network.js that fire online & offline >> >>events >> >> when the network status changes. On any platform that already supports >> >> online events, the browser will fire an event, and then the network >> >>plugin >> >> will also fire an event. >> >> >> >> There is also the fact that the event is fired only on document. The >> >>spec >> >> says that listening on window should work as well (as well as >> >> document.body): http://www.whatwg.org/specs/web-apps/current-work/ >> >> >> >> I made a test page: >> >> https://dl.dropbox.com/u/6648754/webtests/online_events.html >> >> Running it on android browser shows that the only two listener methods >> >>that >> >> work are: >> >> -window.addEventListener >> >> -document.body.ononline = >> >> >> >> So, clearly it's a bit broken. I'm wondering though, if we should do >> >>some >> >> clean-up with these events. >> >> >> >> Options: >> >> >> >> 1. Live with duplicate events for browsers that support them, but also >> >>fire >> >> them on document.body and window. >> >> 2. Don't fire online/offline events from this plugin. Fire a custom >> >> "networktypechange" event >> >> 3. Intercept all event registration an window/document/body so that the >> >> browser's native events don't take effect. Have the only source of these >> >> events be the network plugin. >> >> >> >> >> >> Votes? Comments? >> >> >> >>