<commit_before>import 'dart:html';
import 'dart:async';
import 'dart:convert' show JSON;

void main() {
  
  var view = new DoorStateView();
  
  var statePresenter = new DoorStatePresenter.attachToView( view );
  statePresenter.refresh();
  
  var authLocationPresenter = new AuthLocationPresenter.attachToView( view );
  statePresenter.position = authLocationPresenter;
  authLocationPresenter.startLocationListener();

}

class DoorStateView {
  var state =  querySelector('#status');
  ButtonElement stop   =  querySelector("#stop");
  ButtonElement refresh=  querySelector('#refresh');
  ButtonElement open   =  querySelector('#open');
  ButtonElement logout =  querySelector('#logout');
  ButtonElement close  =  querySelector('#close');
  var spinner=  querySelector('#spinner');
  good() =>  state.classes.remove('red');
  bad()  =>  state.classes.add('red');
  inProgress() => spinner.classes.remove('hidden');
  finished() => spinner.classes.add('hidden');
  canOpen() {
    open.disabled = false;
    open.classes.remove('red');
  }
  cannotOpen() {
    open.disabled = true;
    open.classes.add('red');
  }
}

class HasPosition {
  Geoposition position;
  get coords => position.coords;
}

String posUrlParams(HasPosition position) {
  if( position == null ) return '';
  return 'lat=${position.coords.latitude}&lng=${position.coords.longitude}';
}

class AuthLocationPresenter implements HasPosition {
  DoorStateView _view;
  
  Geoposition position;
  get coords => position.coords;
  
  AuthLocationPresenter.attachToView(this._view);
  
  startLocationListener() {
    _view.cannotOpen();
    window.navigator.geolocation.watchPosition().listen((Geoposition position) {
      this.position = position;
      print('Position = ${position.coords.latitude},${position.coords.longitude}');<commit_msg>added todo<commit_after>import 'dart:html';
import 'dart:async';
import 'dart:convert' show JSON;

void main() {
  
  var view = new DoorStateView();
  
  var statePresenter = new DoorStatePresenter.attachToView( view );
  statePresenter.refresh();
  
  var authLocationPresenter = new AuthLocationPresenter.attachToView( view );
  statePresenter.position = authLocationPresenter;
  authLocationPresenter.startLocationListener();

}

class DoorStateView {
  var state =  querySelector('#status');
  ButtonElement stop   =  querySelector("#stop");
  ButtonElement refresh=  querySelector('#refresh');
  ButtonElement open   =  querySelector('#open');
  ButtonElement logout =  querySelector('#logout');
  ButtonElement close  =  querySelector('#close');
  var spinner=  querySelector('#spinner');
  good() =>  state.classes.remove('red');
  bad()  =>  state.classes.add('red');
  inProgress() => spinner.classes.remove('hidden');
  finished() => spinner.classes.add('hidden');
  canOpen() {
    open.disabled = false;
    open.classes.remove('red');
  }
  cannotOpen() {
    open.disabled = true;
    open.classes.add('red');
  }
}

class HasPosition {
  Geoposition position;
  get coords => position.coords;
}

String posUrlParams(HasPosition position) {
  if( position == null ) return '';
  return 'lat=${position.coords.latitude}&lng=${position.coords.longitude}';
}

class AuthLocationPresenter implements HasPosition {
  DoorStateView _view;
  
  Geoposition position;
  get coords => position.coords;
  
  AuthLocationPresenter.attachToView(this._view);
  
  startLocationListener() {
    _view.cannotOpen();
    window.navigator.geolocation.watchPosition().listen((Geoposition position) {
      //TODO: Probably only worth doing this if moving more than 1/2 mile?
      this.position = position;
      print('Position = ${position.coords.latitude},${position.coords.longitude}');
{'fraction_non_alphanumeric': 0.13641274986493787, 'fraction_numerical': 0.0005402485143165856, 'mean_word_length': 4.705701078582434, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '4095069', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1111, 'n_words': 218}