<commit_before>package org.realityforge.gwt.online.client.html5;

import com.google.web.bindery.event.shared.EventBus;
import com.google.web.bindery.event.shared.SimpleEventBus;
import org.realityforge.gwt.online.client.OnlineIndicator;

public final class Html5OnlineIndicator
  extends OnlineIndicator
{
  public static native boolean isSupported()/*-{
    return typeof ($wnd.onLine) == "boolean";
  }-*/;

  public Html5OnlineIndicator()
  {
    this( new SimpleEventBus() );
  }

  public Html5OnlineIndicator( final EventBus eventBus )
  {
    super( eventBus );
    registerListeners0();
  }

  @Override
  public final native boolean isOnLine() /*-{
   return navigator.onLine;
  }-*/;

  private native void registerListeners0() /*-{
    var that = this;

    var onOnLine = $entry( function () {
      that.@org.realityforge.gwt.online.client.OnlineIndicator::onOnLine()();
    } );
    $wnd.addEventListener( "online", onOnLine );

    var onOffLine = $entry( function () {
      that.@org.realityforge.gwt.online.client.OnlineIndicator::onOffLine()();
    } );
    $wnd.addEventListener( "offline", onOffLine );
  }-*/;<commit_msg>Correctly detect online capability<commit_after>package org.realityforge.gwt.online.client.html5;

import com.google.web.bindery.event.shared.EventBus;
import com.google.web.bindery.event.shared.SimpleEventBus;
import org.realityforge.gwt.online.client.OnlineIndicator;

public final class Html5OnlineIndicator
  extends OnlineIndicator
{
  public static native boolean isSupported()/*-{
    return typeof (navigator.onLine) == "boolean";
  }-*/;

  public Html5OnlineIndicator()
  {
    this( new SimpleEventBus() );
  }

  public Html5OnlineIndicator( final EventBus eventBus )
  {
    super( eventBus );
    registerListeners0();
  }

  @Override
  public final native boolean isOnLine() /*-{
   return navigator.onLine;
  }-*/;

  private native void registerListeners0() /*-{
    var that = this;

    var onOnLine = $entry( function () {
      that.@org.realityforge.gwt.online.client.OnlineIndicator::onOnLine()();
    } );
    $wnd.addEventListener( "online", onOnLine );

    var onOffLine = $entry( function () {
      that.@org.realityforge.gwt.online.client.OnlineIndicator::onOffLine()();
    } );
    $wnd.addEventListener( "offline", onOffLine );
  }-*/;
{'fraction_non_alphanumeric': 0.13624567474048443, 'fraction_numerical': 0.005190311418685121, 'mean_word_length': 3.81875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5714423', 'n_tokens_mistral': 766, 'n_tokens_neox': 743, 'n_words': 137}