require('muicss');
const $ = require('jquery');
const _ = require('underscore');
const Backbone = require('backbone');

const { LocationModel } = require('./Location');
const { GreetModel, GreetView } = require('./Greet');
const { NearbyModel, NearbyView } = require('./Nearby');
const { WeatherModel, WeatherView } = require('./Weather');
const { NewsModel, NewsView } = require('./News');

var app = app || {};

(function () {
  if ('serviceWorker' in navigator)
    navigator.serviceWorker
      .register('./service-worker.js')
      .then(function() {
        console.log('Service Worker Registered');
      });

  const offline = false;
  app.eventBus = _.extend({}, Backbone.Events);

  app.locationModel = new LocationModel();

  // new TrainView({ 'model': new TrainModel(route), 'eventBus': app.eventBus });

  app.greetView = new GreetView({ 'model': new GreetModel(), 'eventBus': app.eventBus, 'location': app.locationModel });

  app.nearby = new NearbyView({ 'model': new NearbyModel(), 'eventBus': app.eventBus, 'location': app.locationModel, 'el':'#nearby' });

  app.weather = new WeatherView({ 'model': new WeatherModel(), 'eventBus': app.eventBus, 'location': app.locationModel, 'el':'#weather' });

  app.news = new NewsView({ 'model': new NewsModel(), 'eventBus': app.eventBus, 'el':'#news' });
})();
