var UI = require('ui');
var Vector2 = require('vector2');
var Settings = require('settings');

var BASE_URL = 'https://timetablepush.me/';
var API_BASE_URL = BASE_URL + 'api/v1/';
var CONFIGURATION_URL = BASE_URL + 'app/config';

/*
 * App Start
 */

var viewMain = new UI.Card({
  title: 'Timetable Pusher',
  subtitle: 'Loading...'
});
viewMain.show();

/*
 * Configuration
 */

// Listen for configuration start
Settings.config(
  { 
    url: CONFIGURATION_URL,
    autoSave: true,
  },
  function(e) {
    
  },
  function(e) {
    console.log('Configuration closed');
  }
);

// Listen for configuration complete
Settings.config(
  { url: CONFIGURATION_URL },
  function(e) {
    console.log('Configuration closed');
    Settings.option('apiKey', e.apiKey);
  }
);

/*
 * Views
 */



/*
 * Error Handlers
 */
@@ -781,16 +781,806 @@
 ws%0A */%0A%0A
+var createViewSetupCard = new UI.Card(%7B%0A  title: 'Setup Required',%0A  body: 'Open this app%5C's configuration page on the Pebble watchapp.'%0A%7D);%0A%0Avar createViewHomeMenu = new UI.Menu(%7B%0A  sections: %5B%7B%0A    title: 'Timetable Pusher',%0A  %7D,%0A  %7B%0A    title: 'Add entries for',%0A    items: %5B%7B%0A      title: 'Current week'%0A    %7D,%0A    %7B%0A      title: 'Next week'%0A    %7D%5D%0A  %7D,  %0A  %7B%0A    title: 'Advanced',%0A    items: %5B%7B%0A      title: 'Delete all pins'%0A    %7D%5D,%0A  %7D%5D%0A%7D);%0A%0A/*%0A * App Ready%0A */%0A%0A// Check whether the API key is set%0APebble.addEventListener(%22ready%22, function() %7B%0A  if (typeof Settings.option('apiKey') === 'undefined') %7B%0A    var viewSetupCard = createViewSetupCard;%0A    viewSetupCard.show();%0A  %7D else %7B%0A    var viewHomeMenu = createViewHomeMenu;%0A    viewHomeMenu.show();%0A  %7D%0A  %0A  viewMain.hide();%0A%7D);
 %0A%0A/*%0A * 

Add initial watch entries