<commit_before>/*********************************************************************************
 0. GLOBALS
 *********************************************************************************/

var onError = function (err) {
  gutil.log(gutil.colors.red(err.plugin) + ': ' + gutil.colors.yellow(err.message));
  gutil.beep();
  this.emit('end');
};

/*********************************************************************************
 1. DEPENDENCIES
 *********************************************************************************/

var browserSync = require('browser-sync');              // inject code to all devices
var gulp = require('gulp');                             // gulp core
var concat = require('gulp-concat');                    // file concatenation
var debug = require('gulp-debug');                      // debug mode
var gulpif = require('gulp-if');                        // conditionals inside config
var iconfont = require('gulp-iconfont');                // icon font builder
var inject = require("gulp-inject");                    // asset injection
var jshint = require('gulp-jshint');                    // js validation
var minifyHtml = require('gulp-minify-html');           // html minification
var plumber = require('gulp-plumber');                  // disable interruptions
var rev = require('gulp-rev');                          // file revisions
var uglify = require('gulp-uglify');                    // js minification
var gutil = require('gulp-util');                       // gulp utilities
var stylish = require('jshint-stylish');                // style for jshint errors
var bowerFiles = require('main-bower-files');           // bower modules includes
var runSequence = require('run-sequence');              // tasks in sequence

/*
 gulpfile.js
 ===========
 Rather than manage one giant configuration file responsible
 for creating multiple tasks, each task has been broken out into
 its own file in gulp/tasks. Any files in that directory get
 automatically required below.
 To add a new task, simply add a new task file that directory.
 gulp/tasks/default.js specifies the default set of tasks to run
 when you run `gulp`.
 */

var requireDir = require('require-dir');

// Require all tasks in gulp/tasks, including subfolders
requireDir('./gulp/tasks', { recurse: true });

/*********************************************************************************
 2. CONFIG AND FILE DESTINATIONS (RELATIVE TO ASSETS FOLDER)
 *********************************************************************************/

var config = {                                          // set environment
  env: 'prod'
};

var target = {
  app_json: [                                           // app related files
    './bower.json',
    './package.json'
  ],
  src_index: 'src/index.html',                          // main source file
  output: 'dist',                                       // output directory
  sassDir: 'src/sass/**/*.scss',                       // all sass files
  js_lint_src: [                                        // js to lint
    'src/js/**/*.js',
    'package.json',
    'bower.json',
    'gulpfile.js',
    '.jshintrc'
  ],
  js_concat_src: [                                      // js files to concatenate
    'src/js/app.js',
    'src/js/**/*.js',
    '!src/js/**/*.spec.js'
  ],
  srcDir: 'src',
  output_js_dir: 'dist/js',                             // minified js destination
  output_js_files: 'dist/js/**/*.js',                   // minified js files
  output_css_files: 'dist/css/*.css'                    // minified css files
};

/*************************************************************************************
 4. JS LINT AND CONCAT
 *************************************************************************************/

gulp.task('js-lint', function () {
  return gulp
    .src(target.js_lint_src)                            // gather the files
    .pipe(plumber({                                     // keep running on errors
      errorHandler: onError
    }))
    .pipe(jshint())                                     // lint the files
    .pipe(jshint.reporter(stylish));                    // present the results
});

gulp.task('js-concat', function () {
  var files = bowerFiles().concat(target.js_concat_src);
  return gulp
    .src(files)                                         // gather the files
    .pipe(plumber({                                     // keep running on errors
      errorHandler: onError
    }))
    .pipe(gulpif(process.env.ENVIRONMENT_TYPE !== 'dev', uglify()))       // uglify the files
    .pipe(gulpif(process.env.ENVIRONMENT_TYPE !== 'dev', concat('app.min.js')))  // concat to one file
    .pipe(gulpif(process.env.ENVIRONMENT_TYPE !== 'dev', rev()))          // apply revision
    .pipe(gulp.dest(target.output_js_dir))              // output files
    .pipe(browserSync.reload({stream: true}));          // browser sync reload
});

/*********************************************************************************
 5. HTML COMPRESSION
 *********************************************************************************/

gulp.task('html', function () {
  var files = [target.output_css_files, target.output_js_files];
  return gulp
    .src(target.src_index)                              // gather the files
    .pipe(plumber({                                     // keep running on errors
      errorHandler: onError
    }))
    .pipe(inject(gulp.src(files, {read: false}), {      // injected files options
      ignorePath: 'dist',
      addRootSlash: false
    }))
    .pipe(gulpif(process.env.ENVIRONMENT_TYPE !== 'dev', minifyHtml({     // minify html options
      empty: true,
      spare: true,
      quotes: true
    })))
    .pipe(gulp.dest(target.output));                    // output files
});

/*********************************************************************************
 12. TASKS
 *********************************************************************************/
gulp.task('default', function () {
  runSequence(
    'purge',
    ['sass', 'js-lint', 'js-concat'],
    'karma',
    'html',
    'imagemin'
  );
});

gulp.task('dev', function () {

  // set environment
  process.env.ENVIRONMENT_TYPE = 'dev';

  runSequence(
    'purge',
    ['sass', 'js-lint', 'js-concat'],
    'karma',
    'html',
    'imagemin',
    'browserSync'
  );
  gulp.watch(target.srcDir + '/sass/**/*.scss', ['sass']);
  gulp.watch(target.js_lint_src, ['js-lint']);
  gulp.watch(target.js_concat_src, ['js-concat']);
  gulp.watch(target.src_index).on('change', browserSync.reload);
});

<commit_msg>refactor(gulp): separating `minifyHtml` task<commit_after>/*********************************************************************************
 0. GLOBALS
 *********************************************************************************/

var onError = function (err) {
  gutil.log(gutil.colors.red(err.plugin) + ': ' + gutil.colors.yellow(err.message));
  gutil.beep();
  this.emit('end');
};

/*********************************************************************************
 1. DEPENDENCIES
 *********************************************************************************/

var browserSync = require('browser-sync');              // inject code to all devices
var gulp = require('gulp');                             // gulp core
var concat = require('gulp-concat');                    // file concatenation
var debug = require('gulp-debug');                      // debug mode
var gulpif = require('gulp-if');                        // conditionals inside config
var iconfont = require('gulp-iconfont');                // icon font builder
var inject = require("gulp-inject");                    // asset injection
var jshint = require('gulp-jshint');                    // js validation
var plumber = require('gulp-plumber');                  // disable interruptions
var rev = require('gulp-rev');                          // file revisions
var uglify = require('gulp-uglify');                    // js minification
var gutil = require('gulp-util');                       // gulp utilities
var stylish = require('jshint-stylish');                // style for jshint errors
var bowerFiles = require('main-bower-files');           // bower modules includes
var runSequence = require('run-sequence');              // tasks in sequence

/*
 gulpfile.js
 ===========
 Rather than manage one giant configuration file responsible
 for creating multiple tasks, each task has been broken out into
 its own file in gulp/tasks. Any files in that directory get
 automatically required below.
 To add a new task, simply add a new task file that directory.
 gulp/tasks/default.js specifies the default set of tasks to run
 when you run `gulp`.
 */

var requireDir = require('require-dir');

// Require all tasks in gulp/tasks, including subfolders
requireDir('./gulp/tasks', { recurse: true });

/*********************************************************************************
 2. CONFIG AND FILE DESTINATIONS (RELATIVE TO ASSETS FOLDER)
 *********************************************************************************/

var config = {                                          // set environment
  env: 'prod'
};

var target = {
  app_json: [                                           // app related files
    './bower.json',
    './package.json'
  ],
  src_index: 'src/index.html',                          // main source file
  output: 'dist',                                       // output directory
  sassDir: 'src/sass/**/*.scss',                       // all sass files
  js_lint_src: [                                        // js to lint
    'src/js/**/*.js',
    'package.json',
    'bower.json',
    'gulpfile.js',
    '.jshintrc'
  ],
  js_concat_src: [                                      // js files to concatenate
    'src/js/app.js',
    'src/js/**/*.js',
    '!src/js/**/*.spec.js'
  ],
  srcDir: 'src',
  output_js_dir: 'dist/js',                             // minified js destination
  output_js_files: 'dist/js/**/*.js',                   // minified js files
  output_css_files: 'dist/css/*.css'                    // minified css files
};

/*************************************************************************************
 4. JS LINT AND CONCAT
 *************************************************************************************/

gulp.task('js-lint', function () {
  return gulp
    .src(target.js_lint_src)                            // gather the files
    .pipe(plumber({                                     // keep running on errors
      errorHandler: onError
    }))
    .pipe(jshint())                                     // lint the files
    .pipe(jshint.reporter(stylish));                    // present the results
});

gulp.task('js-concat', function () {
  var files = bowerFiles().concat(target.js_concat_src);
  return gulp
    .src(files)                                         // gather the files
    .pipe(plumber({                                     // keep running on errors
      errorHandler: onError
    }))
    .pipe(gulpif(process.env.ENVIRONMENT_TYPE !== 'dev', uglify()))       // uglify the files
    .pipe(gulpif(process.env.ENVIRONMENT_TYPE !== 'dev', concat('app.min.js')))  // concat to one file
    .pipe(gulpif(process.env.ENVIRONMENT_TYPE !== 'dev', rev()))          // apply revision
    .pipe(gulp.dest(target.output_js_dir))              // output files
    .pipe(browserSync.reload({stream: true}));          // browser sync reload
});

/*********************************************************************************
 12. TASKS
 *********************************************************************************/
gulp.task('default', function () {
  runSequence(
    'purge',
    ['sass', 'js-lint', 'js-concat'],
    'karma',
    'minifyHtml',
    'imagemin'
  );
});

gulp.task('dev', function () {

  // set environment
  process.env.ENVIRONMENT_TYPE = 'dev';

  runSequence(
    'purge',
    ['sass', 'js-lint', 'js-concat'],
    'karma',
    'minifyHtml',
    'imagemin',
    'browserSync'
  );
  gulp.watch(target.srcDir + '/sass/**/*.scss', ['sass']);
  gulp.watch(target.js_lint_src, ['js-lint']);
  gulp.watch(target.js_concat_src, ['js-concat']);
  gulp.watch(target.src_index).on('change', browserSync.reload);
});

<|endoftext|>


<commit_before>'use strict';

const _ = require('underscore');
const tap = require('tap');
const expect = require('expect.js');
const Migrator = require('../../../lib/migrator');

tap.mochaGlobals();

describe('migrator configure adapter loading', () => {
	const MockAdapter = function MockAdapter() {
		this.getTemplatePath = () => {};
	};

	MockAdapter.prototype.connect = (callback) => callback;
	MockAdapter.prototype.disconnect = (callback) => callback;
	MockAdapter.prototype.getExecutedMigrationNames = (callback) => callback;
	MockAdapter.prototype.markExecuted = (name, callback) => callback;
	MockAdapter.prototype.unmarkExecuted = (name, callback) => callback;

	it('should try migrator-related path first then CWD-related', () => {
		const paths = [];

		return Promise.resolve()
			.then(() => {
				const migratorMock = new Migrator();

				migratorMock._tryLoadModule = (path) => {
					paths.push(path);

					return paths.length === 2 ? MockAdapter : new Error('Whatever.');
				};

				return migratorMock.configure({adapter: 'X'});
			})
			.then(() => {
				expect(paths[0]).eql('X');
				expect(paths[1].substr(-2, 2)).eql('/X');
			});
	});

	it('should throw an error when both paths can not be resolved', () => {
		return Promise.resolve()
			.then(() => {
				const migratorMock = new Migrator();

				migratorMock._tryLoadModule = () => {
					throw new Error('Whatever.');
				};

				return migratorMock.configure({adapter: 'X'});
			})
			.then((result) => {
				throw new Error(`Error expected, but got result: ${result}`);
			})
			.catch((err) => {
				expect(err).ok();
				expect(err).an(Error);
				expect(err.message).equal('Whatever.');
			});
	});

	it('should promisify adapter methods', () => {
		const migratorMock = new Migrator();
		migratorMock._tryLoadModule = () => MockAdapter;
		const adapterMethodNames = [
			'connect',
			'disconnect',
			'getExecutedMigrationNames',
			'markExecuted',
			'unmarkExecuted'
		];

		return Promise.resolve()
			.then(() => migratorMock.configure())
			.then(() => {
				_(adapterMethodNames).each((adapterMethodName) => {
					const result = migratorMock.adapter[adapterMethodName]();

					expect(result).a(Promise);
				});
			});
	});
});
<commit_msg>use create adapter test util at adapter loading test<commit_after>'use strict';

const _ = require('underscore');
const tap = require('tap');
const expect = require('expect.js');
const Migrator = require('../../../lib/migrator');
const testUtils = require('../../../testUtils');

tap.mochaGlobals();

describe('migrator configure adapter loading', () => {
	let Adapter;

	before(() => {
		Adapter = function AdapterMock() {
		};

		Adapter.prototype = testUtils.createAdapter({withCallbacMethods: true});
	});

	it('should try migrator-related path first then CWD-related', () => {
		const paths = [];

		return Promise.resolve()
			.then(() => {
				const migrator = new Migrator();

				migrator._tryLoadModule = (path) => {
					paths.push(path);

					return paths.length === 2 ? Adapter : new Error('Whatever.');
				};

				return migrator.configure({adapter: 'X', loadConfig: false});
			})
			.then(() => {
				expect(paths[0]).eql('X');
				expect(paths[1].substr(-2, 2)).eql('/X');
			});
	});

	it('should throw an error when both paths can not be resolved', () => {
		return Promise.resolve()
			.then(() => {
				const migrator = new Migrator();

				migrator._tryLoadModule = () => {
					throw new Error('Whatever.');
				};

				return migrator.configure({adapter: 'X', loadConfig: false});
			})
			.then((result) => {
				throw new Error(`Error expected, but got result: ${result}`);
			})
			.catch((err) => {
				expect(err).ok();
				expect(err).an(Error);
				expect(err.message).equal('Whatever.');
			});
	});

	it('should promisify adapter methods', () => {
		const migrator = new Migrator();
		migrator._tryLoadModule = () => Adapter;
		const adapterMethodNames = [
			'connect',
			'disconnect',
			'getExecutedMigrationNames',
			'markExecuted',
			'unmarkExecuted'
		];

		return Promise.resolve()
			.then(() => migrator.configure({loadConfig: false}))
			.then(() => {
				_(adapterMethodNames).each((adapterMethodName) => {
					const result = migrator.adapter[adapterMethodName]();

					expect(result).a(Promise);
				});
			});
	});
});
<|endoftext|>


<commit_before>// required for async/await to work
import 'babel-polyfill';
import colors from 'colors';
import splitFile from 'split-file';
import del from 'delete';
import spinner from './spinner';
import Command from './command';
import logger from './logger';
import { dockerfile } from './dockerfile';
import { readFile, writeFile, isStringJson, getNodeEnv, didPassParam } from './utils';

let meteorSettingsVar;

const buildMeteorApp = async () => {
  const message = 'building meteor app';
  spinner.start(`${message} (this can take several minutes)`);
  const buildCommand = new Command(`meteor build .meteor/local/builds ${dockerfile.serverOnly} --architecture=os.linux.x86_64`);
  await buildCommand.run();
  spinner.succeed(message);
};

const createDockerfile = async () => {
  const dockerfileContents = dockerfile.getContents(didPassParam('MONGO_URL'));
  logger('creating Dockerfile');
  await writeFile('.meteor/local/builds/Dockerfile', dockerfileContents);
};

const createSupervisorFile = async () => {
  logger('creating supervisor');
  await writeFile('.meteor/local/builds/supervisord.conf', dockerfile.getSupervisor());
};

const splitBuild = async () => {
  logger('splitting bundle');
  await new Promise((resolve, reject) => {
    splitFile.splitFileBySize(`.meteor/local/builds/${dockerfile.buildzip}`, 999999, (err, names) => {
      if (err) {
        reject(err);
      }
      resolve(names);
    });
  });
};

const handleMeteorSettings = async () => {
  if (!didPassParam('METEOR_SETTINGS')) {
    const env = getNodeEnv();
    const settingsFile = `${env}.settings.json`;
    logger(`looking for meteor settings file ${settingsFile} in root of project`);
    const settingsString = await readFile(settingsFile);
    if (settingsString) {
      // settings file found
      if (!isStringJson(settingsString)) {
        throw new Error(`ERROR: ${settingsFile} file is not valid JSON`);
      } else {
        meteorSettingsVar = settingsString.replace(/[\n ]/g, '');
        logger('found settings file');
      }
    } else {
      logger('no settings file found');
    }
  }
};

const deployMeteorApp = async () => {
  const message = 'deploying build';
  let mongoUrl = '';
  if (!didPassParam('MONGO_URL')) {
    console.log(colors.yellow('WARNING: Did not pass a MONGO_URL. Bundling a NON-PRODUCTION version of MongoDB with your application. Read about the limitations here: https://git.io/vM72E')); // eslint-disable-line no-console
    mongoUrl = '-e MONGO_URL=mongodb://127.0.0.1:27017';
  }
  spinner.start(`${message} (this can take several minutes)`);
  const args = process.argv.slice(2).join(' ');
  const meteorSettingsArg = meteorSettingsVar ? `-e METEOR_SETTINGS='${meteorSettingsVar}'` : '';
  const rootUrl = !didPassParam('ROOT_URL') ? '-e ROOT_URL=http://localhost.com' : '';
  const deployCommand = new Command(`cd .meteor/local/builds && now -e PORT=3000 ${mongoUrl} ${rootUrl} ${args} ${meteorSettingsArg}`);
  const stdOut = await deployCommand.run();
  const deployedAppUrl = stdOut.out.toString();
  spinner.succeed(message);
  return deployedAppUrl;
};

const cleanup = async () => {
  logger('cleaning up');
  await del.promise(['.meteor/local/builds/*']);
};

const prepareForUpload = async () => {
  spinner.start('preparing build');
  await createDockerfile();
  if (!didPassParam('MONGO_URL')) {
    await createSupervisorFile();
  }
  await splitBuild();
  await handleMeteorSettings();
  spinner.succeed();
};

const main = async () => {
  try {
    await buildMeteorApp();
    await prepareForUpload();
    const appUrl = await deployMeteorApp();
    await cleanup();
    spinner.succeed(`meteor app deployed to ${appUrl.split(',')[0]}`);
  } catch (e) {
    spinner.fail();
    console.error(e); // eslint-disable-line no-console
    // exit node process with error
    process.exit(1);
  }
};

export default function () {
  main();
}
<commit_msg>delete original bundle after it has been split<commit_after>// required for async/await to work
import 'babel-polyfill';
import colors from 'colors';
import splitFile from 'split-file';
import del from 'delete';
import spinner from './spinner';
import Command from './command';
import logger from './logger';
import { dockerfile } from './dockerfile';
import { readFile, writeFile, isStringJson, getNodeEnv, didPassParam } from './utils';

let meteorSettingsVar;

const buildMeteorApp = async () => {
  const message = 'building meteor app';
  spinner.start(`${message} (this can take several minutes)`);
  const buildCommand = new Command(`meteor build .meteor/local/builds ${dockerfile.serverOnly} --architecture=os.linux.x86_64`);
  await buildCommand.run();
  spinner.succeed(message);
};

const createDockerfile = async () => {
  const dockerfileContents = dockerfile.getContents(didPassParam('MONGO_URL'));
  logger('creating Dockerfile');
  await writeFile('.meteor/local/builds/Dockerfile', dockerfileContents);
};

const createSupervisorFile = async () => {
  logger('creating supervisor');
  await writeFile('.meteor/local/builds/supervisord.conf', dockerfile.getSupervisor());
};

const splitBuild = async () => {
  logger('splitting bundle');
  await new Promise((resolve, reject) => {
    splitFile.splitFileBySize(`.meteor/local/builds/${dockerfile.buildzip}`, 999999, async (err, names) => {
      if (err) {
        reject(err);
      }
      // delete original bundle file so that it doesnt get uploaded to now
      await del.promise([`.meteor/local/builds/${dockerfile.buildzip}`]);
      resolve(names);
    });
  });
};

const handleMeteorSettings = async () => {
  if (!didPassParam('METEOR_SETTINGS')) {
    const env = getNodeEnv();
    const settingsFile = `${env}.settings.json`;
    logger(`looking for meteor settings file ${settingsFile} in root of project`);
    const settingsString = await readFile(settingsFile);
    if (settingsString) {
      // settings file found
      if (!isStringJson(settingsString)) {
        throw new Error(`ERROR: ${settingsFile} file is not valid JSON`);
      } else {
        meteorSettingsVar = settingsString.replace(/[\n ]/g, '');
        logger('found settings file');
      }
    } else {
      logger('no settings file found');
    }
  }
};

const deployMeteorApp = async () => {
  const message = 'deploying build';
  let mongoUrl = '';
  if (!didPassParam('MONGO_URL')) {
    console.log(colors.yellow('WARNING: Did not pass a MONGO_URL. Bundling a NON-PRODUCTION version of MongoDB with your application. Read about the limitations here: https://git.io/vM72E')); // eslint-disable-line no-console
    mongoUrl = '-e MONGO_URL=mongodb://127.0.0.1:27017';
  }
  spinner.start(`${message} (this can take several minutes)`);
  const args = process.argv.slice(2).join(' ');
  const meteorSettingsArg = meteorSettingsVar ? `-e METEOR_SETTINGS='${meteorSettingsVar}'` : '';
  const rootUrl = !didPassParam('ROOT_URL') ? '-e ROOT_URL=http://localhost.com' : '';
  const deployCommand = new Command(`cd .meteor/local/builds && now -e PORT=3000 ${mongoUrl} ${rootUrl} ${args} ${meteorSettingsArg}`);
  const stdOut = await deployCommand.run();
  const deployedAppUrl = stdOut.out.toString();
  spinner.succeed(message);
  return deployedAppUrl;
};

const cleanup = async () => {
  logger('cleaning up');
  await del.promise(['.meteor/local/builds/*']);
};

const prepareForUpload = async () => {
  spinner.start('preparing build');
  await createDockerfile();
  if (!didPassParam('MONGO_URL')) {
    await createSupervisorFile();
  }
  await splitBuild();
  await handleMeteorSettings();
  spinner.succeed();
};

const main = async () => {
  try {
    await buildMeteorApp();
    await prepareForUpload();
    const appUrl = await deployMeteorApp();
    await cleanup();
    spinner.succeed(`meteor app deployed to ${appUrl.split(',')[0]}`);
  } catch (e) {
    spinner.fail();
    console.error(e); // eslint-disable-line no-console
    // exit node process with error
    process.exit(1);
  }
};

export default function () {
  main();
}
<|endoftext|>


<commit_before>/*
 * Notes :
 * need to figure out if there is a way to continously check if
 * the alarms sets off.
 */

/**
 * Welcome to Pebble.js!
 * Test
 * This is where you write your app.
 */

// Calls in required stuff
var UI = require('ui');
var Vibe = require('ui/vibe');
var Settings = require('settings');
var date = new Date();

//var Vector2 = require('vector2');

// A for loop to make array of hours
var hours = [];
for (var i = 0; i < 24; i++) {
    hours.push(i + 1);
}

var alarms = Settings.data('alarms') || [];
var createAlarmItems = function(alarms) {
    var items = [];
    items.push({
        title: "Add New Alarm"
    });
    console.log("added new alarm");
    for (var i = 1; i < alarms.length + 1; i++) {
        try {
            items.push({
                title: alarms[i].time,
                subtitle: alarms[i].enabled
            });
            console.log(i);
        } catch (err) {
        }
    }
    console.log("Created item list");
    return items;
};

var detectTimeLoop = function() {
	for (var i = 1; i < alarms.length + 1; i++) {
        try {
            console.log("alarm " + alarms[i].hour + "h  " + alarm[i].minute + "m");
            console.log("actual " + date.getHours() + "h  " + date.getMinutes() + "m");
            if ( alarms[i].hour == date.getHours() && alarms[i].minute == date.getMinutes() ) {
                // vibrates.. add
                Vibe.vibrate('long');
            }
            console.log(i + ": I vibrated");
        } catch (err) {
        }
    }
	setTimeout(function() {
		detectTimeLoop();
	}, 1000);
};

detectTimeLoop();

/*
	Formats time from the 24-hour clock to 12-hour
*/
var formatTime = function( h, m ) {
	var hour = ( h % 12 !== 0 ? h % 12 : 12 );
    var minute = m < 10 ? "0" + m : m;
	return hour + ":" + minute + " " + ( ( h < 12 ) ? "AM" : "PM" );
}

// Sets up the alarms
var alarmItems = createAlarmItems(alarms);

/*
// Creates a loop to make an array of hours
var createHourItems = function() {
  var items = [];
  for (var i = 0; i hideurs.length; i++) {
    items.push({
      title: hours[i]
    });
  }
  return items;
};
*/

/*
var main = new UI.Menu({
   sections:[{
     items: createItems()
  }]
});

main.show();
*/

// The Splashscreen
var splashScreen = new UI.Card({
    title: 'Alarm',
    icon: 'images/menu_icon.png',
    subtitle: 'Welcome to Our App',
    body: 'This is the splash page'
    //banner (future plans)
});

// Makes a menu with New Alarms
var main = new UI.Menu({
    sections: [{
        items: alarmItems
        /*
            [{
            title: 'Add New Alarm',
            subtitle: 'New Alarm'
        }, {
            // Dr. Seuss
            title: 'One Alarm'
        }, {
            title: 'Two Alarm'
        }, {
            title: 'Red Alarm'
        }, {
            title: 'Blue Alarm'
        }]
        */
        //, createAlarmItems(alarms)
    }]
});

// Shows the spashscreen and goes to the menu after 400 ms
splashScreen.show();
setTimeout(function() {
    splashScreen.hide();
    main.show();
}, 800);

var createAlarm = function(callback) {
    alarms.push({
        time: formatTime( date.getHours(), date.getMinutes() + 2 ),
        hour: date.getHours() + 1,
        minute: (date.getMinutes() + 2),
        enabled: true
    });
    console.log("hour : " + date.getHours());
    console.log("minute : " + date.getMinutes());
    console.log("time : " + formatTime( date.getHours(), date.getMinutes() ));
    callback();
};

main.on('select', function(e) {
    console.log(e.sectionIndex);
    // If it is on the "New Alarm Option"
    if (e.itemIndex === 0) {
        // Has a random card as a placeholder
        var card = new UI.Card();
        card.title('A Card');
        card.subtitle('Is a Window');
        card.body('The simplest window type in Pebble.js.');
        card.show();

        // When click the middle button it makes an alarm
        card.on('click', 'select', function() {
            createAlarm(function() {
                alarmItems = createAlarmItems(alarms);
                console.log('Items done');
                console.log(alarmItems);
                card.hide();
                main.section(0, section = {
                    items: alarmItems
                });
                console.log("success");
            });
        });
    } else {
        // Otherwise the user selects an alarm
        // Creates the Menu for Alarm Options
        var alarmOptions = new UI.Menu({
            sections : [{
                items: [{
                    title: 'Disable'
                }, {
                    title: 'Edit'
                }, {
                    title: 'Delete'
                }]
            }]
        });
        alarmOptions.show();

        alarmOptions.on('select', function(e) {
            switch(e.itemIndex) {
                case 0:
                    // Disable or Enable the Alarm
                    if (e.item.enabled) {
                        e.item.enabled = false;
                    } else {
                        e.item.enabled = true;
                    }
                    break;
                case 1:
                    // Edit the time of the alarm
                    break;
                case 2:
                    // Deletes the alarm
                    alarms.splice(e.itemIndex, 1);
                    console.log("deleted at : " + e.itemIndex);
                    break;
                default:
                    console.log("error");
                    break;
            }
            // Update the alarms and gets rid of the option menu
            alarmItems = createAlarmItems();
            alarmOptions.hide();
            main.section(0, section = {
                items: alarmItems
            });
        });
    }
    // Choose an option to chnage alarm
});

// Code from before, I don't currently remove it for reference
/*
// Try but doesn't work
main.on('click', 'select', function(e) {
    var item = this.items(0);
    if (item.title == "Add New Alarm") {
        Vibe.vibrate('long');
        var card = new UI.Card();
        card.title('A Card');
        card.subtitle('Is a Window');
        card.body('The simplest window type in Pebble.js.');
        card.show();
    }
});
*/

/*
main.on('click', 'up', function(e) {
    var menu = new UI.Menu({
        sections: [{
            items: [{
                title: 'Pebble.js',
                icon: 'images/menu_icon.png',
                subtitle: 'Can do Menus'
            }, {
                title: 'Second Item',
                subtitle: 'Subtitle Text'
            }]
        }]
    });
    menu.on('select', function(e) {
        console.log('Selected item #' + e.itemIndex + ' of section #' + e.sectionIndex);
        console.log('The item is titled "' + e.item.title + '"');
    });
    menu.show();
});
*/

// When click middle button
/*
main.on('click', 'up', function(e) {
    //test vibrqtion and date fubction
    console.log("foo");
    if (new Date() == new Date()) {
        Vibe.vibrate('long');
    }
    var wind = new UI.Window();
    //var time = new UI.TimeText();
    // Time in Text form
    var textfield = new UI.TimeText({
        position: new Vector2(0, 50),
        size: new Vector2(144, 30),
        font: 'gothic-24-bold',
        text: '%M:%S, %a',
        textAlign: 'center'
    });
    wind.add(textfield);
    wind.show();
});
*/

/*
main.on('click', 'down', function(e) {
    var card = new UI.Card();
    card.title('A Card');
    card.subtitle('Is a Window');
    card.body('The simplest window type in Pebble.js.');
    card.show();
});
*/
<commit_msg>added check for alarms length<commit_after>/*
 * Notes :
 * need to figure out if there is a way to continously check if
 * the alarms sets off.
 */

/**
 * Welcome to Pebble.js!
 * Test
 * This is where you write your app.
 */

// Calls in required stuff
var UI = require('ui');
var Vibe = require('ui/vibe');
var Settings = require('settings');
var date = new Date();

//var Vector2 = require('vector2');

// A for loop to make array of hours
var hours = [];
for (var i = 0; i < 24; i++) {
    hours.push(i + 1);
}

var alarms = Settings.data('alarms') || [];
var createAlarmItems = function(alarms) {
    var items = [];
    items.push({
        title: "Add New Alarm"
    });
    console.log("added new alarm");
    if (alarms.length > 0)
        for (var i = 1; i < alarms.length + 1; i++) {
            try {
                items.push({
                    title: alarms[i].time,
                    subtitle: alarms[i].enabled
                });
                console.log(i);
            } catch (err) {
            }
    }
    console.log("Created item list");
    return items;
};

var detectTimeLoop = function() {
	for (var i = 1; i < alarms.length + 1; i++) {
        try {
            console.log("alarm " + alarms[i].hour + "h  " + alarm[i].minute + "m");
            console.log("actual " + date.getHours() + "h  " + date.getMinutes() + "m");
            if ( alarms[i].hour == date.getHours() && alarms[i].minute == date.getMinutes() ) {
                // vibrates.. add
                Vibe.vibrate('long');
            }
            console.log(i + ": I vibrated");
        } catch (err) {
        }
    }
	setTimeout(function() {
		detectTimeLoop();
	}, 1000);
};

detectTimeLoop();

/*
	Formats time from the 24-hour clock to 12-hour
*/
var formatTime = function( h, m ) {
	var hour = ( h % 12 !== 0 ? h % 12 : 12 );
    var minute = m < 10 ? "0" + m : m;
	return hour + ":" + minute + " " + ( ( h < 12 ) ? "AM" : "PM" );
}

// Sets up the alarms
var alarmItems = createAlarmItems(alarms);

/*
// Creates a loop to make an array of hours
var createHourItems = function() {
  var items = [];
  for (var i = 0; i hideurs.length; i++) {
    items.push({
      title: hours[i]
    });
  }
  return items;
};
*/

/*
var main = new UI.Menu({
   sections:[{
     items: createItems()
  }]
});

main.show();
*/

// The Splashscreen
var splashScreen = new UI.Card({
    title: 'Alarm',
    icon: 'images/menu_icon.png',
    subtitle: 'Welcome to Our App',
    body: 'This is the splash page'
    //banner (future plans)
});

// Makes a menu with New Alarms
var main = new UI.Menu({
    sections: [{
        items: alarmItems
        /*
            [{
            title: 'Add New Alarm',
            subtitle: 'New Alarm'
        }, {
            // Dr. Seuss
            title: 'One Alarm'
        }, {
            title: 'Two Alarm'
        }, {
            title: 'Red Alarm'
        }, {
            title: 'Blue Alarm'
        }]
        */
        //, createAlarmItems(alarms)
    }]
});

// Shows the spashscreen and goes to the menu after 400 ms
splashScreen.show();
setTimeout(function() {
    splashScreen.hide();
    main.show();
}, 800);

var createAlarm = function(callback) {
    alarms.push({
        time: formatTime( date.getHours(), date.getMinutes() + 2 ),
        hour: date.getHours() + 1,
        minute: (date.getMinutes() + 2),
        enabled: true
    });
    console.log("hour : " + date.getHours());
    console.log("minute : " + date.getMinutes());
    console.log("time : " + formatTime( date.getHours(), date.getMinutes() ));
    callback();
};

main.on('select', function(e) {
    console.log(e.sectionIndex);
    // If it is on the "New Alarm Option"
    if (e.itemIndex === 0) {
        // Has a random card as a placeholder
        var card = new UI.Card();
        card.title('A Card');
        card.subtitle('Is a Window');
        card.body('The simplest window type in Pebble.js.');
        card.show();

        // When click the middle button it makes an alarm
        card.on('click', 'select', function() {
            createAlarm(function() {
                alarmItems = createAlarmItems(alarms);
                console.log('Items done');
                console.log(alarmItems);
                card.hide();
                main.section(0, section = {
                    items: alarmItems
                });
                console.log("success");
            });
        });
    } else {
        // Otherwise the user selects an alarm
        // Creates the Menu for Alarm Options
        var alarmOptions = new UI.Menu({
            sections : [{
                items: [{
                    title: 'Disable'
                }, {
                    title: 'Edit'
                }, {
                    title: 'Delete'
                }]
            }]
        });
        alarmOptions.show();

        alarmOptions.on('select', function(e) {
            switch(e.itemIndex) {
                case 0:
                    // Disable or Enable the Alarm
                    if (e.item.enabled) {
                        e.item.enabled = false;
                    } else {
                        e.item.enabled = true;
                    }
                    break;
                case 1:
                    // Edit the time of the alarm
                    break;
                case 2:
                    // Deletes the alarm
                    alarms.splice(e.itemIndex, 1);
                    console.log("deleted at : " + e.itemIndex);
                    break;
                default:
                    console.log("error");
                    break;
            }
            // Update the alarms and gets rid of the option menu
            alarmItems = createAlarmItems();
            alarmOptions.hide();
            main.section(0, section = {
                items: alarmItems
            });
        });
    }
    // Choose an option to chnage alarm
});

// Code from before, I don't currently remove it for reference
/*
// Try but doesn't work
main.on('click', 'select', function(e) {
    var item = this.items(0);
    if (item.title == "Add New Alarm") {
        Vibe.vibrate('long');
        var card = new UI.Card();
        card.title('A Card');
        card.subtitle('Is a Window');
        card.body('The simplest window type in Pebble.js.');
        card.show();
    }
});
*/

/*
main.on('click', 'up', function(e) {
    var menu = new UI.Menu({
        sections: [{
            items: [{
                title: 'Pebble.js',
                icon: 'images/menu_icon.png',
                subtitle: 'Can do Menus'
            }, {
                title: 'Second Item',
                subtitle: 'Subtitle Text'
            }]
        }]
    });
    menu.on('select', function(e) {
        console.log('Selected item #' + e.itemIndex + ' of section #' + e.sectionIndex);
        console.log('The item is titled "' + e.item.title + '"');
    });
    menu.show();
});
*/

// When click middle button
/*
main.on('click', 'up', function(e) {
    //test vibrqtion and date fubction
    console.log("foo");
    if (new Date() == new Date()) {
        Vibe.vibrate('long');
    }
    var wind = new UI.Window();
    //var time = new UI.TimeText();
    // Time in Text form
    var textfield = new UI.TimeText({
        position: new Vector2(0, 50),
        size: new Vector2(144, 30),
        font: 'gothic-24-bold',
        text: '%M:%S, %a',
        textAlign: 'center'
    });
    wind.add(textfield);
    wind.show();
});
*/

/*
main.on('click', 'down', function(e) {
    var card = new UI.Card();
    card.title('A Card');
    card.subtitle('Is a Window');
    card.body('The simplest window type in Pebble.js.');
    card.show();
});
*/
<|endoftext|>


<commit_before>$(function() {
    $("#menu-toggle").click(function(e) {
        e.preventDefault()
        $("#wrapper").toggleClass("toggled")
    })

    var timer
    $(window).on('mousemove', function() {
        $('.navbar').addClass('show')
        $('.panel-wrapper, .panel-primary').addClass('down')
        try {
            clearTimeout(timer)
        } catch (e) {}
        timer = setTimeout(function() {
            $('.navbar').removeClass('show')
            $('.panel-wrapper, .panel-primary').removeClass('down')
        }, 3000)
    })
})
<commit_msg>Fix navbar anim to mouseover<commit_after>$(function() {
    // toggle sidebar
    $("#menu-toggle").click(function(e) {
        e.preventDefault()
        $("#wrapper").toggleClass("toggled")
    })

    // navbar hidden-show
    var timer
    $('#nav-wrapper').on('mouseover', function() {
        $('.navbar').addClass('show')
        $('.panel-wrapper, .panel-primary').addClass('down')
        try {
            clearTimeout(timer)
        } catch (e) {}
        timer = setTimeout(function() {
            $('.navbar').removeClass('show')
            $('.panel-wrapper, .panel-primary').removeClass('down')
        }, 2000)
    })
})

<|endoftext|>


<commit_before>"use strict";

let body_parser = require("body-parser");
let cookie_parser = require("cookie-parser");
let express = require("express");
let events = require("./events");
let PriorityQueue = require("./collections").PriorityQueue;
let ServiceManager = require("./service-manager").ServiceManager;
let ModuleManager = require("./module-manager").ModuleManager;
let Router = require("./router").Router;
let HttpEventDecorator = require("./util").HttpEventDecorator;

console.lo

class Config {
  constructor(config) {
    this.config = config;
  }

  get(key, default_value) {
    let parts = key.split(".");
    let last = parts.pop();
    let root = this.config;
    parts.forEach(key => {
      root = root[key] || {};
    });
    return root[last];
  }
}

class Request {
  constructor(req) {
    Object.defineProperty(this, "meta", {
      value: Object.create(null),
    });
    this.meta.req = req;
  }

  get _raw() {
    return this.meta.req;
  }

  get method() {
    return this._raw.method;
  }

  get host() {
    return this._raw.hostname;
  }

  get path() {
    return this._raw.path;
  }

  get session() {
    return this._raw.session;
  }

  get query() {
    return this._raw.query;
  }

  get body() {
    return this._raw.body;
  }
}

class Response {
  constructor(res) {
    Object.defineProperty(this, "meta", {
      value: Object.create(null),
    });
    this.meta.res = res;
  }

  /**
   * redirect(url)
   * redirect(status, url)
   */
  redirect(status, url) {
    this._raw.redirect.apply(this._raw, arguments);
  }

  get _raw() {
    return this.meta.res;
  }

  get data() {
    return this.meta.data;
  }

  set data(data) {
    this.meta.data = data;
  }
}

class HttpEvent {
  constructor(request, response) {
    this.request = request;
    this.response = response;

    /**
     * Storage for internal per request data.
     */
    this.locals = {};
  }

  /**
   * Data that will be returned as response.
   */
  get data() {
    return this.response.data;
  }

  set data(data) {
    this.response.data = data;
  }
}

class RouteEvent extends HttpEventDecorator {
  constructor(http_event, route_match) {
    super(http_event);
    this.routeMatch = route_match;
  }

  get path() {
    return this.routeMatch.route.path;
  }

  get params() {
    return this.routeMatch.params;
  }

  get route() {
    return this.routeMatch.route;
  }
}

class App {
  constructor(config) {
    this.config = new Config(config);
    this.events = new events.AsyncEventManager;

    this.sharedEvents = new events.SharedEventManager(true);

    this.services = new ServiceManager;
    this.services.register("event.manager", this.sharedEvents);
    this.services.register("app", this);
    this.services.register("config", this.config);

    this.modules = new ModuleManager(this.services);
    this.services.register("module.manager", this.modules);

    this.middleware = new PriorityQueue;
    this.router = new Router;
    this.services.register("router", this.router);
    this.services.register("param.converter", this.router.converter);

    this.sharedEvents.addEmitter("app", this.events);
    this.sharedEvents.addEmitter("modules", this.modules.events);

    this.events.on("ready", () => {
      this.use(1000, event => this.onRequest(event));
      this.use(5000, event => this.onResponse(event));
    });

    this.events.on("bootstrap", () => {
      try {
        this.modules.discover(__dirname + "/modules", this.config.get("system.modules.enabled"));
      } catch (error) {
        console.error("app.bootstrap:", error.stack);
      }
    });

    this.events.on("request", event => {
      return this.router.match(event.request.path, event.request.method, event.request.host).then(match => {
        let route_event = new RouteEvent(event, match);
        return this.events.emit("route", route_event).catch(error => console.error(error.stack));
      }, error => {
        console.log("NO MATCH");
        return Promise.reject(new Error("No handler for route"));
      });
    });

    this.events.on("route", event => {
      return event.routeMatch.callback(event).then(result => {
        event.data = result;
        return result;
      }, error => {
        console.error("app.exec", error.stack);
      });
    });
  }

  use(weight, path, callback) {
    let _callback = arguments[arguments.length - 1];
    let _weight = typeof arguments[0] == "number" ? weight : 0;
    let _path = "";

    if (arguments.length > 1) {
      let pi = arguments.length - 2;
      if (typeof arguments[pi] == "string") {
        _path = arguments[pi];
      }
    }

    this.middleware.insert([_path, _callback].filter(x => x), _weight);
    return this;
  }

  start() {
    if (this.baseApp) {
      throw new Error("App already running!");
    }
    this.baseApp = express();
    this.baseApp.use(express.static("public"));
    this.baseApp.use(cookie_parser());
    this.baseApp.use(body_parser.urlencoded({extended: false}));

    return this.events.emit("bootstrap", {app: this})
      .then(() => this.events.emit("ready", {app: this}))
      .then(() => {
        this.baseApp.use((req, res, next) => this.onRequestBegin(req, res, next));

        let config = this.config.server || {};
        let port = config.port || 8000;
        let address = config.address || "localhost";

        return new Promise((resolve, reject) => {
          this.server = this.baseApp.listen(port, address, () => {
            // this.middleware.forEach(pair => this.baseApp.use(pair[0]));
            this.events.emit("listen", {app: this, server: this.server}).then(resolve);
          });
        });
      }).catch(error => {
        console.error("app.start", error.stack);
      });
    return this;
  }

  onRequestBegin(req, res, done) {
    let middleware = this.middleware.slice();
    let event = new HttpEvent(new Request(req), new Response(res));
    let next = () => {
      if (middleware.length) {
        let callback = middleware.shift()[0][0];
        let promise = callback(event);
        promise ? promise.then(next) : next();
      } else {
        done();
      }
    };
    next();
  }

  onRequest(event) {
    return this.events.emit("request", event);
  }

  onResponse(event) {
    return this.events.emit("response", event).then(() => {
      event.response._raw.send(event.response.data);
    });
  }
}

module.exports = function(config) {
  return new App(config || {});
};
<commit_msg>Fix reading server configs<commit_after>"use strict";

let body_parser = require("body-parser");
let cookie_parser = require("cookie-parser");
let express = require("express");
let events = require("./events");
let PriorityQueue = require("./collections").PriorityQueue;
let ServiceManager = require("./service-manager").ServiceManager;
let ModuleManager = require("./module-manager").ModuleManager;
let Router = require("./router").Router;
let HttpEventDecorator = require("./util").HttpEventDecorator;

console.lo

class Config {
  constructor(config) {
    this.config = config;
  }

  get(key, default_value) {
    let parts = key.split(".");
    let last = parts.pop();
    let root = this.config;
    parts.forEach(key => {
      root = root[key] || {};
    });
    return root[last];
  }
}

class Request {
  constructor(req) {
    Object.defineProperty(this, "meta", {
      value: Object.create(null),
    });
    this.meta.req = req;
  }

  get _raw() {
    return this.meta.req;
  }

  get method() {
    return this._raw.method;
  }

  get host() {
    return this._raw.hostname;
  }

  get path() {
    return this._raw.path;
  }

  get session() {
    return this._raw.session;
  }

  get query() {
    return this._raw.query;
  }

  get body() {
    return this._raw.body;
  }
}

class Response {
  constructor(res) {
    Object.defineProperty(this, "meta", {
      value: Object.create(null),
    });
    this.meta.res = res;
  }

  /**
   * redirect(url)
   * redirect(status, url)
   */
  redirect(status, url) {
    this._raw.redirect.apply(this._raw, arguments);
  }

  get _raw() {
    return this.meta.res;
  }

  get data() {
    return this.meta.data;
  }

  set data(data) {
    this.meta.data = data;
  }
}

class HttpEvent {
  constructor(request, response) {
    this.request = request;
    this.response = response;

    /**
     * Storage for internal per request data.
     */
    this.locals = {};
  }

  /**
   * Data that will be returned as response.
   */
  get data() {
    return this.response.data;
  }

  set data(data) {
    this.response.data = data;
  }
}

class RouteEvent extends HttpEventDecorator {
  constructor(http_event, route_match) {
    super(http_event);
    this.routeMatch = route_match;
  }

  get path() {
    return this.routeMatch.route.path;
  }

  get params() {
    return this.routeMatch.params;
  }

  get route() {
    return this.routeMatch.route;
  }
}

class App {
  constructor(config) {
    this.config = new Config(config);
    this.events = new events.AsyncEventManager;

    this.sharedEvents = new events.SharedEventManager(true);

    this.services = new ServiceManager;
    this.services.register("event.manager", this.sharedEvents);
    this.services.register("app", this);
    this.services.register("config", this.config);

    this.modules = new ModuleManager(this.services);
    this.services.register("module.manager", this.modules);

    this.middleware = new PriorityQueue;
    this.router = new Router;
    this.services.register("router", this.router);
    this.services.register("param.converter", this.router.converter);

    this.sharedEvents.addEmitter("app", this.events);
    this.sharedEvents.addEmitter("modules", this.modules.events);

    this.events.on("ready", () => {
      this.use(1000, event => this.onRequest(event));
      this.use(5000, event => this.onResponse(event));
    });

    this.events.on("bootstrap", () => {
      try {
        this.modules.discover(__dirname + "/modules", this.config.get("system.modules.enabled"));
      } catch (error) {
        console.error("app.bootstrap:", error.stack);
      }
    });

    this.events.on("request", event => {
      return this.router.match(event.request.path, event.request.method, event.request.host).then(match => {
        let route_event = new RouteEvent(event, match);
        return this.events.emit("route", route_event).catch(error => console.error(error.stack));
      }, error => {
        console.log("NO MATCH");
        return Promise.reject(new Error("No handler for route"));
      });
    });

    this.events.on("route", event => {
      return event.routeMatch.callback(event).then(result => {
        event.data = result;
        return result;
      }, error => {
        console.error("app.exec", error.stack);
      });
    });
  }

  use(weight, path, callback) {
    let _callback = arguments[arguments.length - 1];
    let _weight = typeof arguments[0] == "number" ? weight : 0;
    let _path = "";

    if (arguments.length > 1) {
      let pi = arguments.length - 2;
      if (typeof arguments[pi] == "string") {
        _path = arguments[pi];
      }
    }

    this.middleware.insert([_path, _callback].filter(x => x), _weight);
    return this;
  }

  start() {
    if (this.baseApp) {
      throw new Error("App already running!");
    }
    this.baseApp = express();
    this.baseApp.use(express.static("public"));
    this.baseApp.use(cookie_parser());
    this.baseApp.use(body_parser.urlencoded({extended: false}));

    return this.events.emit("bootstrap", {app: this})
      .then(() => this.events.emit("ready", {app: this}))
      .then(() => {
        this.baseApp.use((req, res, next) => this.onRequestBegin(req, res, next));

        let address = this.config.get("server.address", "localhost");
        let port = this.config.get("server.port", 8000);

        return new Promise((resolve, reject) => {
          this.server = this.baseApp.listen(port, address, () => {
            this.events.emit("listen", {app: this, server: this.server}).then(resolve);
          });
        });
      }).catch(error => console.error("app.start", error.stack));
    return this;
  }

  onRequestBegin(req, res, done) {
    let middleware = this.middleware.slice();
    let event = new HttpEvent(new Request(req), new Response(res));
    let next = () => {
      if (middleware.length) {
        let callback = middleware.shift()[0][0];
        let promise = callback(event);
        promise ? promise.then(next, error => console.error(error.stack)) : next();
      } else {
        done();
      }
    };
    next();
  }

  onRequest(event) {
    return this.events.emit("request", event);
  }

  onResponse(event) {
    return this.events.emit("response", event).then(() => {
      event.response._raw.send(event.response.data);
    });
  }
}

module.exports = function(config) {
  return new App(config || {});
};
<|endoftext|>


<commit_before>var markers = [
	{pos: new google.maps.LatLng(42.727425,    -73.678631),   label: "Academy Hall"},
	{pos: new google.maps.LatLng(42.73064179,  -73.67553949), label: "Admissions"},
	{pos: new google.maps.LatLng(42.73285234,  -73.67817342), label: "Alumni House"},
	{pos: new google.maps.LatLng(42.72841146,  -73.67661238), label: "Alumni Sports Center"},
	{pos: new google.maps.LatLng(42.730165,    -73.68254542), label: "Amos Eaton Hall"},
	{pos: new google.maps.LatLng(42.72912865,  -73.67406964), label: "Barton Hall"},
	{pos: new google.maps.LatLng(42.73288387,  -73.67737412), label: "Beman Firehouse"},
	{pos: new google.maps.LatLng(42.73213126,  -73.68087173), label: "Blaw-Knox 1 & 2"},
	{pos: new google.maps.LatLng(42.73115405,  -73.68588746), label: "Blitman Commons"},
	{pos: new google.maps.LatLng(42.73123286,  -73.68175685), label: "Boiler House, Sage"},
	{pos: new google.maps.LatLng(42.73265139,  -73.68024409), label: "Boiler House, 11th"},
	{pos: new google.maps.LatLng(42.72871489,  -73.67347956), label: "Bray Hall"},
	{pos: new google.maps.LatLng(42.73512192,  -73.66381824), label: "Bryckwyck"},
	{pos: new google.maps.LatLng(42.73209974,  -73.67141962), label: "2144 Burdett Ave"},
	{pos: new google.maps.LatLng(42.73101261,  -73.67124045), label: "Burdett Ave Residence Hall"},
	{pos: new google.maps.LatLng(42.73045701,  -73.68319398), label: "Carnegie Building"},
	{pos: new google.maps.LatLng(42.72888829,  -73.67484158), label: "Cary Hall"},
	{pos: new google.maps.LatLng(42.72824558,  -73.67840463), label: "Biotech (CBIS)"},
	{pos: new google.maps.LatLng(42.729289,    -73.678676),   label: "Low Center (CII)"},
	{pos: new google.maps.LatLng(42.73175693,  -73.67229939), label: "Chapel"},
	{pos: new google.maps.LatLng(42.72816321,  -73.68121505), label: "Cogswell Laboratory"},
	{pos: new google.maps.LatLng(42.73704904,  -73.66976202), label: "Colonie Apartments"},
	{pos: new google.maps.LatLng(42.72825898,  -73.67426062), label: "Commons Dining Hall"},
	{pos: new google.maps.LatLng(42.72836844,  -73.67320919), label: "Crockett Hall"},
	{pos: new google.maps.LatLng(42.72948208,  -73.67905909), label: "Darrin Communications Center (DCC)"},
	{pos: new google.maps.LatLng(42.72743263,  -73.67403799), label: "Davison Hall"},
	{pos: new google.maps.LatLng(42.731344,    -73.67919213), label: "E Complex"},
	{pos: new google.maps.LatLng(42.73228102,  -73.66744941), label: "East Campus Athletic Village Arena (ECAV)"},
	{pos: new google.maps.LatLng(42.73314316,  -73.66759801), label: "East Campus Athletic Village Stadium"},
	{pos: new google.maps.LatLng(42.72828813,  -73.68179655), label: "Empire State Hall"},
	{pos: new google.maps.LatLng(42.72957948,  -73.68034065), label: "Jonsson Engineering Center"},
	{pos: new google.maps.LatLng(42.72886313,  -73.68382645), label: "EMPAC"},
	{pos: new google.maps.LatLng(42.73208957,  -73.66946912), label: "Field House, Houston"},
	{pos: new google.maps.LatLng(42.7293383,   -73.68253845), label: "Folsom Library"},
	{pos: new google.maps.LatLng(42.73265356,  -73.67587289), label: "Graduate Education"},
	{pos: new google.maps.LatLng(42.7300248,   -73.68118501), label: "Greene Building"},
	{pos: new google.maps.LatLng(42.72881618,  -73.66798747), label: "Greenhouses and Grounds Barn"},
	{pos: new google.maps.LatLng(42.73078266,  -73.67884934), label: "‘87 Gymnasium"},
	{pos: new google.maps.LatLng(42.73258834,  -73.67920339), label: "H Building"},
	{pos: new google.maps.LatLng(42.72855726,  -73.67522836), label: "Hall Hall"},
	{pos: new google.maps.LatLng(42.7331518,   -73.67991686), label: "J Building"},
	{pos: new google.maps.LatLng(42.72683127,  -73.67836654), label: "Java++ Cafe"},
	{pos: new google.maps.LatLng(42.73008028,  -73.68189633), label: "Lally Hall"},
	{pos: new google.maps.LatLng(42.73251742,  -73.66183877), label: "LINAC Facility (Gaerttner Laboratory)"},
	{pos: new google.maps.LatLng(42.73060239,  -73.68428081), label: "Louis Rubin Memorial Approach"},
	{pos: new google.maps.LatLng(42.72842328,  -73.68269563), label: "Materials Research Center"},
	{pos: new google.maps.LatLng(42.72876217,  -73.67665529), label: "Mueller Center"},
	{pos: new google.maps.LatLng(42.72761152,  -73.67349029), label: "Nason Hall"},
	{pos: new google.maps.LatLng(42.73246422,  -73.68288875), label: "41 Ninth Street"},
	{pos: new google.maps.LatLng(42.73135895,  -73.67983639), label: "North Hall"},
	{pos: new google.maps.LatLng(42.72742237,  -73.67506206), label: "Nugent Hall"},
	{pos: new google.maps.LatLng(42.72779673,  -73.68164957), label: "Parking Garage (Faculty/Staff)"},
	{pos: new google.maps.LatLng(42.73682404,  -73.66372168), label: "Patroon Manor"},
	{pos: new google.maps.LatLng(42.73289963,  -73.67691278), label: "2021 Peoples Avenue"},
	{pos: new google.maps.LatLng(42.73122104,  -73.6832723),  label: "Pittsburgh Building"},
	{pos: new google.maps.LatLng(42.72919957,  -73.67766462), label: "Playhouse"},
	{pos: new google.maps.LatLng(42.72213379,  -73.67940724), label: "Polytechnic Residence Commons"},
	{pos: new google.maps.LatLng(42.72930203,  -73.67700934), label: "Public Safety"},
	{pos: new google.maps.LatLng(42.730117,    -73.677650),   label: "Quadrangle"},
	{pos: new google.maps.LatLng(42.73425115,  -73.66319865), label: "Radio Club W2SZ"},
	{pos: new google.maps.LatLng(42.73086878,  -73.66814142), label: "RAHP A Site"},
	{pos: new google.maps.LatLng(42.7347555,   -73.66485089), label: "RAHP B Site"},
	{pos: new google.maps.LatLng(42.72995146,  -73.6766113),  label: "Rensselaer Union"},
	{pos: new google.maps.LatLng(42.73090663,  -73.67973983), label: "Ricketts Building"},
	{pos: new google.maps.LatLng(42.7279142,   -73.67712736), label: "Robison Swimming Pool"},
	{pos: new google.maps.LatLng(42.72721952,  -73.68056461), label: "RPI Ambulance"},
	{pos: new google.maps.LatLng(42.72978673,  -73.67822599), label: "Russell Sage Dining Hall"},
	{pos: new google.maps.LatLng(42.73084199,  -73.68153101), label: "Russell Sage Laboratory"},
	{pos: new google.maps.LatLng(42.72886741,  -73.68036586), label: "Hirsch Observatory"},
	{pos: new google.maps.LatLng(42.73126243,  -73.6664452),  label: "Seismograph Laboratory"},
	{pos: new google.maps.LatLng(42.73280037,  -73.68102193), label: "Service Building"},
	{pos: new google.maps.LatLng(42.72702598,  -73.67464042), label: "Sharp Hall"},
	{pos: new google.maps.LatLng(42.73436308,  -73.66426456), label: "Rousseau Apartments"},
	{pos: new google.maps.LatLng(42.73395329,  -73.66452205), label: "Williams Apartments"},
	{pos: new google.maps.LatLng(42.73355612,  -73.6648525),  label: "Wiltsie Apartments"},
	{pos: new google.maps.LatLng(42.73315263,  -73.66512716), label: "McGiffert Apartments"},
	{pos: new google.maps.LatLng(42.73361601,  -73.66560352), label: "Thompson Apartments"},
	{pos: new google.maps.LatLng(42.72909716,  -73.6685164),  label: "133 Sunset Terrace"},
	{pos: new google.maps.LatLng(42.73056381,  -73.66693282), label: "200 Sunset Terrace"},
	{pos: new google.maps.LatLng(42.73101145,  -73.68046725), label: "Troy Building"},
	{pos: new google.maps.LatLng(42.72922799,  -73.6817826),  label: "Voorhees Computing Center (VCC)"},
	{pos: new google.maps.LatLng(42.73084831,  -73.68251216), label: "Walker Laboratory"},
	{pos: new google.maps.LatLng(42.72793311,  -73.67546439), label: "Warren Hall"},
	{pos: new google.maps.LatLng(42.73169707,  -73.68312478), label: "West Hall"},
	{pos: new google.maps.LatLng(42.73091057,  -73.68427706), label: "Winslow Building"},
];<commit_msg>Fixed Peoples Avenue marker<commit_after>var markers = [
	{pos: new google.maps.LatLng(42.727425,    -73.678631),   label: "Academy Hall"},
	{pos: new google.maps.LatLng(42.73064179,  -73.67553949), label: "Admissions"},
	{pos: new google.maps.LatLng(42.73285234,  -73.67817342), label: "Alumni House"},
	{pos: new google.maps.LatLng(42.72841146,  -73.67661238), label: "Alumni Sports Center"},
	{pos: new google.maps.LatLng(42.730165,    -73.68254542), label: "Amos Eaton Hall"},
	{pos: new google.maps.LatLng(42.72912865,  -73.67406964), label: "Barton Hall"},
	{pos: new google.maps.LatLng(42.73288387,  -73.67737412), label: "Beman Firehouse"},
	{pos: new google.maps.LatLng(42.73213126,  -73.68087173), label: "Blaw-Knox 1 & 2"},
	{pos: new google.maps.LatLng(42.73115405,  -73.68588746), label: "Blitman Commons"},
	{pos: new google.maps.LatLng(42.73123286,  -73.68175685), label: "Boiler House, Sage"},
	{pos: new google.maps.LatLng(42.73265139,  -73.68024409), label: "Boiler House, 11th"},
	{pos: new google.maps.LatLng(42.72871489,  -73.67347956), label: "Bray Hall"},
	{pos: new google.maps.LatLng(42.73512192,  -73.66381824), label: "Bryckwyck"},
	{pos: new google.maps.LatLng(42.73209974,  -73.67141962), label: "2144 Burdett Ave"},
	{pos: new google.maps.LatLng(42.73101261,  -73.67124045), label: "Burdett Ave Residence Hall"},
	{pos: new google.maps.LatLng(42.73045701,  -73.68319398), label: "Carnegie Building"},
	{pos: new google.maps.LatLng(42.72888829,  -73.67484158), label: "Cary Hall"},
	{pos: new google.maps.LatLng(42.72824558,  -73.67840463), label: "Biotech (CBIS)"},
	{pos: new google.maps.LatLng(42.729289,    -73.678676),   label: "Low Center (CII)"},
	{pos: new google.maps.LatLng(42.73175693,  -73.67229939), label: "Chapel"},
	{pos: new google.maps.LatLng(42.72816321,  -73.68121505), label: "Cogswell Laboratory"},
	{pos: new google.maps.LatLng(42.73704904,  -73.66976202), label: "Colonie Apartments"},
	{pos: new google.maps.LatLng(42.72825898,  -73.67426062), label: "Commons Dining Hall"},
	{pos: new google.maps.LatLng(42.72836844,  -73.67320919), label: "Crockett Hall"},
	{pos: new google.maps.LatLng(42.72948208,  -73.67905909), label: "Darrin Communications Center (DCC)"},
	{pos: new google.maps.LatLng(42.72743263,  -73.67403799), label: "Davison Hall"},
	{pos: new google.maps.LatLng(42.731344,    -73.67919213), label: "E Complex"},
	{pos: new google.maps.LatLng(42.73228102,  -73.66744941), label: "East Campus Athletic Village Arena (ECAV)"},
	{pos: new google.maps.LatLng(42.73314316,  -73.66759801), label: "East Campus Athletic Village Stadium"},
	{pos: new google.maps.LatLng(42.72828813,  -73.68179655), label: "Empire State Hall"},
	{pos: new google.maps.LatLng(42.72957948,  -73.68034065), label: "Jonsson Engineering Center"},
	{pos: new google.maps.LatLng(42.72886313,  -73.68382645), label: "EMPAC"},
	{pos: new google.maps.LatLng(42.73208957,  -73.66946912), label: "Field House, Houston"},
	{pos: new google.maps.LatLng(42.7293383,   -73.68253845), label: "Folsom Library"},
	{pos: new google.maps.LatLng(42.73265356,  -73.67587289), label: "Graduate Education"},
	{pos: new google.maps.LatLng(42.7300248,   -73.68118501), label: "Greene Building"},
	{pos: new google.maps.LatLng(42.72881618,  -73.66798747), label: "Greenhouses and Grounds Barn"},
	{pos: new google.maps.LatLng(42.73078266,  -73.67884934), label: "‘87 Gymnasium"},
	{pos: new google.maps.LatLng(42.73258834,  -73.67920339), label: "H Building"},
	{pos: new google.maps.LatLng(42.72855726,  -73.67522836), label: "Hall Hall"},
	{pos: new google.maps.LatLng(42.7331518,   -73.67991686), label: "J Building"},
	{pos: new google.maps.LatLng(42.72683127,  -73.67836654), label: "Java++ Cafe"},
	{pos: new google.maps.LatLng(42.73008028,  -73.68189633), label: "Lally Hall"},
	{pos: new google.maps.LatLng(42.73251742,  -73.66183877), label: "LINAC Facility (Gaerttner Laboratory)"},
	{pos: new google.maps.LatLng(42.73060239,  -73.68428081), label: "Louis Rubin Memorial Approach"},
	{pos: new google.maps.LatLng(42.72842328,  -73.68269563), label: "Materials Research Center"},
	{pos: new google.maps.LatLng(42.72876217,  -73.67665529), label: "Mueller Center"},
	{pos: new google.maps.LatLng(42.72761152,  -73.67349029), label: "Nason Hall"},
	{pos: new google.maps.LatLng(42.73246422,  -73.68288875), label: "41 Ninth Street"},
	{pos: new google.maps.LatLng(42.73135895,  -73.67983639), label: "North Hall"},
	{pos: new google.maps.LatLng(42.72742237,  -73.67506206), label: "Nugent Hall"},
	{pos: new google.maps.LatLng(42.72779673,  -73.68164957), label: "Parking Garage (Faculty/Staff)"},
	{pos: new google.maps.LatLng(42.73682404,  -73.66372168), label: "Patroon Manor"},
	{pos: new google.maps.LatLng(42.73299003,  -73.67691278), label: "2021 Peoples Avenue"},
	{pos: new google.maps.LatLng(42.73122104,  -73.6832723),  label: "Pittsburgh Building"},
	{pos: new google.maps.LatLng(42.72919957,  -73.67766462), label: "Playhouse"},
	{pos: new google.maps.LatLng(42.72213379,  -73.67940724), label: "Polytechnic Residence Commons"},
	{pos: new google.maps.LatLng(42.72930203,  -73.67700934), label: "Public Safety"},
	{pos: new google.maps.LatLng(42.730117,    -73.677650),   label: "Quadrangle"},
	{pos: new google.maps.LatLng(42.73425115,  -73.66319865), label: "Radio Club W2SZ"},
	{pos: new google.maps.LatLng(42.73086878,  -73.66814142), label: "RAHP A Site"},
	{pos: new google.maps.LatLng(42.7347555,   -73.66485089), label: "RAHP B Site"},
	{pos: new google.maps.LatLng(42.72995146,  -73.6766113),  label: "Rensselaer Union"},
	{pos: new google.maps.LatLng(42.73090663,  -73.67973983), label: "Ricketts Building"},
	{pos: new google.maps.LatLng(42.7279142,   -73.67712736), label: "Robison Swimming Pool"},
	{pos: new google.maps.LatLng(42.72721952,  -73.68056461), label: "RPI Ambulance"},
	{pos: new google.maps.LatLng(42.72978673,  -73.67822599), label: "Russell Sage Dining Hall"},
	{pos: new google.maps.LatLng(42.73084199,  -73.68153101), label: "Russell Sage Laboratory"},
	{pos: new google.maps.LatLng(42.72886741,  -73.68036586), label: "Hirsch Observatory"},
	{pos: new google.maps.LatLng(42.73126243,  -73.6664452),  label: "Seismograph Laboratory"},
	{pos: new google.maps.LatLng(42.73280037,  -73.68102193), label: "Service Building"},
	{pos: new google.maps.LatLng(42.72702598,  -73.67464042), label: "Sharp Hall"},
	{pos: new google.maps.LatLng(42.73436308,  -73.66426456), label: "Rousseau Apartments"},
	{pos: new google.maps.LatLng(42.73395329,  -73.66452205), label: "Williams Apartments"},
	{pos: new google.maps.LatLng(42.73355612,  -73.6648525),  label: "Wiltsie Apartments"},
	{pos: new google.maps.LatLng(42.73315263,  -73.66512716), label: "McGiffert Apartments"},
	{pos: new google.maps.LatLng(42.73361601,  -73.66560352), label: "Thompson Apartments"},
	{pos: new google.maps.LatLng(42.72909716,  -73.6685164),  label: "133 Sunset Terrace"},
	{pos: new google.maps.LatLng(42.73056381,  -73.66693282), label: "200 Sunset Terrace"},
	{pos: new google.maps.LatLng(42.73101145,  -73.68046725), label: "Troy Building"},
	{pos: new google.maps.LatLng(42.72922799,  -73.6817826),  label: "Voorhees Computing Center (VCC)"},
	{pos: new google.maps.LatLng(42.73084831,  -73.68251216), label: "Walker Laboratory"},
	{pos: new google.maps.LatLng(42.72793311,  -73.67546439), label: "Warren Hall"},
	{pos: new google.maps.LatLng(42.73169707,  -73.68312478), label: "West Hall"},
	{pos: new google.maps.LatLng(42.73091057,  -73.68427706), label: "Winslow Building"},
];
<|endoftext|>


<commit_before>(function () {
  'use strict';

  angular
    .module('app')
    .config(config);

  function config($urlRouterProvider, $stateProvider) {
    // Declare Login and Main Menu States for WEB
    $stateProvider
      .state('app', {
        'url': '/app',
        'abstract': true,
        'templateUrl': 'app/menu/menu.web.html',
        'controller': 'MenuController as vm',
        'resolve': {
          'prepMenu': prepMenu
        }
      });

    // Declare Main Menu and Child Content States
    var states = [
      {'state': 'about', 'url': 'about', 'template': 'about/about', 'controller': 'About', 'view': 'menuContent'},
      {'state': 'description', 'url': 'description', 'template': 'project/description/description', 'controller': 'Description', 'view': 'menuContent'},
      {'state': 'image-basemaps.image-basemap', 'url': ':imagebasemapId', 'template': 'maps/image-basemap/image-basemap', 'controller': 'ImageBasemap', 'view': 'image-basemap-view'},
      {'state': 'image-basemaps', 'url': 'image-basemaps', 'template': 'maps/image-basemaps/image-basemaps', 'controller': 'ImageBasemaps', 'view': 'menuContent'},
      {'state': 'images', 'url': 'images', 'template': 'attributes/images/images', 'controller': 'Images', 'view': 'menuContent'},
      {'state': 'manage-project', 'url': 'manage-project', 'template': 'project/manage/manage-project', 'controller': 'ManageProject', 'view': 'menuContent'},
      {'state': 'map', 'url': 'map', 'template': 'maps/map/map', 'controller': 'Map', 'view': 'menuContent'},
      {'state': 'misc', 'url': 'misc', 'template': 'misc/misc', 'controller': 'Misc', 'view': 'menuContent'},
      {'state': 'other-maps', 'url': 'other-maps', 'template': 'maps/other-maps/other-maps', 'controller': 'OtherMaps', 'view': 'menuContent'},
      {'state': 'preferences', 'url': 'preferences', 'template': 'project/preferences/preferences', 'controller': 'Preferences', 'view': 'menuContent'},
      {'state': 'relationships.relationship', 'url': ':relationship_id', 'template': 'relationship/relationship', 'controller': 'Relationship', 'view': 'relationship-view@app.relationships'},
      {'state': 'relationships', 'url': 'relationships', 'template': 'relationships/relationships', 'controller': 'Relationships', 'view': 'menuContent'},
      {'state': 'samples', 'url': 'samples', 'template': 'attributes/samples/samples', 'controller': 'Samples', 'view': 'menuContent'},
      {'state': 'strat-section', 'url': 'strat-sections/:stratSectionId', 'template': 'maps/strat-section/strat-section', 'controller': 'StratSection', 'view': 'menuContent'},
      //{'state': 'strat-sections.strat-section', 'url': ':stratSectionId', 'template': 'maps/strat-section/strat-section', 'controller': 'StratSection', 'view': 'strat-section-view'},
      {'state': 'strat-sections', 'url': 'strat-sections', 'template': 'maps/strat-sections/strat-sections', 'controller': 'StratSections', 'view': 'menuContent'},
      {'state': 'thin-section', 'url': 'thin-sections/:thinSectionId', 'template': 'maps/thin-section/thin-section', 'controller': 'ThinSection', 'view': 'menuContent'},
      //{'state': 'thin-sections.thin-section', 'url': ':thinSectionId', 'template': 'maps/thin-section/thin-section', 'controller': 'StratSection', 'view': 'thin-section-view'},
      {'state': 'thin-sections', 'url': 'thin-sections', 'template': 'maps/thin-sections/thin-sections', 'controller': 'ThinSections', 'view': 'menuContent'},
      {'state': 'tags.tag', 'url': ':tag_id', 'template': 'tag/tag', 'controller': 'Tag', 'view': 'tag-view@app.tags'},
      {'state': 'tags', 'url': 'tags', 'template': 'tags/tags', 'controller': 'Tags', 'view': 'menuContent'},
      {'state': 'tools', 'url': 'tools', 'template': 'project/tools/tools', 'controller': 'Tools', 'view': 'menuContent'},
      {'state': 'user', 'url': 'user', 'template': 'user/user', 'controller': 'User', 'view': 'menuContent'},
      // For WEB only
      {'state': 'login', 'url': 'login', 'template': 'login/login', 'controller': 'Login', 'view': 'menuContent'}
    ];
    _.each(states, function (state) {
      var viewKey = state.view;
      var view = {};
      view[viewKey] = {
        'templateUrl': 'app/' + state.template + '.web.html',   // Added .web for WEB
        'controller': state.controller + 'Controller as vm'
      };
      $stateProvider.state('app.' + state.state, {
        'cache': false,
        'url': '/' + state.url,
        'views': view
      });
    });

    // Declare Spot Tab State
    $stateProvider.state('app.spotTab', {
        'cache': false,
        'url': '/spotTab',
        'views': {
          'menuContent': {
            'templateUrl': 'app/spots/spots.web.html',
            'controller': 'SpotsController as vm'
          },
          'spot-data@app.spotTab': {
            'templateUrl': 'app/spot/spot/spot.web.html',
            'controller': 'SpotController as vm'
          }
        },
        'onExit': function ($log, SpotFactory) {
          if (!SpotFactory.getKeepSpotSelected()) {
            $log.log('Exiting Spots State. Clearing current Spot ...');
            SpotFactory.clearCurrentSpot();
          }
          else SpotFactory.setKeepSpotSelected(false);
        }
      });

    // Declare Spot Tab Childview States
    var spotTabStates = [
      {'state': '_3dstructures', 'template': '3d-structures/3dstructures-tab', 'controller': '_3DStructures'},
      {'state': 'experimental', 'template': 'micro/experimental/experimental-tab', 'controller': 'Experimental'},
      {'state': 'experimental-results', 'template': 'micro/experimental-results/experimental-results-tab', 'controller': 'ExperimentalResults'},
      {'state': 'experimental-set-up', 'template': 'micro/experimental-set-up/experimental-set-up-tab', 'controller': 'ExperimentalSetUp'},
      {'state': 'fabrics', 'template': 'fabrics/fabrics-tab', 'controller': 'Fabrics'},
      {'state': 'data', 'template': 'data/data-tab', 'controller': 'Data'},
      {'state': 'images', 'template': 'images/images-tab', 'controller': 'Images'},
      {'state': 'nesting', 'template': 'nesting/nesting-tab', 'controller': 'Nesting'},
      {'state': 'notes', 'template': 'notes/notes-tab', 'controller': 'Notes'},
      {'state': 'orientations', 'template': 'orientations/orientations-tab', 'controller': 'Orientations'},
      {'state': 'other-features', 'template': 'other-features/other-features-tab', 'controller': 'OtherFeatures'},
      {'state': 'relationships', 'template': 'relationships/relationships-tab', 'controller': 'Relationships'},
      {'state': 'samples', 'template': 'samples/samples-tab', 'controller': 'Samples'},
      {'state': 'spot', 'template': 'spot-tab/spot-tab', 'controller': 'Spot'},
      {'state': 'sed-bedding', 'template': 'sed/bedding/bedding-tab', 'controller': 'SedBedding'},
      {'state': 'sed-diagenesis', 'template': 'sed/diagenesis/diagenesis-tab', 'controller': 'SedDiagenesis'},
      {'state': 'sed-fossils', 'template': 'sed/fossils/fossils-tab', 'controller': 'SedFossils'},
      {'state': 'sed-interpretations', 'template': 'sed/interpretations/interpretations-tab', 'controller': 'SedInterpretations'},
      {'state': 'sed-interval', 'template': 'sed/interval/interval-tab', 'controller': 'SedInterval'},
      {'state': 'sed-lithologies', 'template': 'sed/lithologies/lithologies-tab', 'controller': 'SedLithologies'},
      {'state': 'sed-structures', 'template': 'sed/structures/structures-tab', 'controller': 'SedStructures'},
      {'state': 'strat-section', 'template': 'sed/strat-section/strat-section-tab', 'controller': 'StratSection'},
      {'state': 'petrology', 'template': 'petrology/petrology-tab', 'controller': 'Petrology'},
      {'state': 'tags', 'template': 'tags/tags-tab', 'controller': 'Tags'}
    ];
    _.each(spotTabStates, function (spotTabState) {
      $stateProvider.state('app.spotTab.' + spotTabState.state, {
        'cache': false,
        'url': '/:spotId/' + spotTabState.state,
        'views': {
          'spottab-childview': {
            'templateUrl': 'app/spot/' + spotTabState.template + '.web.html',   // Added .web for WEB
            'controller': spotTabState.controller + 'TabController as vmChild'
          }
        }
      });
    });

    // If none of the above states are matched, use this as the fallback
    $urlRouterProvider.otherwise('/app/map');
  }

  function prepMenu($ionicLoading, LocalStorageFactory, DataModelsFactory, ProjectFactory, RemoteServerFactory, SpotFactory,
                    UserFactory, OtherMapsFactory, AutoLoginFactory) {
    $ionicLoading.show({'template': '<ion-spinner></ion-spinner>
Loading Data Models...'});
    return DataModelsFactory.loadDataModels().then(function () {
      $ionicLoading.show({'template': '<ion-spinner></ion-spinner>
Loaded Data Models
Loading Database...'});
      return LocalStorageFactory.setupLocalforage().then(function () {
        $ionicLoading.show({'template': '<ion-spinner></ion-spinner>
Loaded Data Models
Loaded Database
Loading User...'});
        //return AutoLoginFactory.autoLogin().then(function () {
          $ionicLoading.show({'template': '<ion-spinner></ion-spinner>
Loaded Data Models
Loaded Database
Loaded User
Loading Project...'});
          return UserFactory.loadUser().then(function () {
            $ionicLoading.show({'template': '<ion-spinner></ion-spinner>
Automatically logged in...'});
            return ProjectFactory.prepProject().then(function () {
              $ionicLoading.show({'template': '<ion-spinner></ion-spinner>
Loaded Data Models
Loaded Database
Loaded User
Loaded Project
Loading Spots...'});
              return SpotFactory.loadSpots().then(function () {
                $ionicLoading.hide();
                return RemoteServerFactory.loadDbUrl().then(function () {
                  return OtherMapsFactory.loadOtherMaps();
                });
              });
            });
          });
        //});
      });
    });
  }
}());
<commit_msg>Turned auto-login back on<commit_after>(function () {
  'use strict';

  angular
    .module('app')
    .config(config);

  function config($urlRouterProvider, $stateProvider) {
    // Declare Login and Main Menu States for WEB
    $stateProvider
      .state('app', {
        'url': '/app',
        'abstract': true,
        'templateUrl': 'app/menu/menu.web.html',
        'controller': 'MenuController as vm',
        'resolve': {
          'prepMenu': prepMenu
        }
      });

    // Declare Main Menu and Child Content States
    var states = [
      {'state': 'about', 'url': 'about', 'template': 'about/about', 'controller': 'About', 'view': 'menuContent'},
      {'state': 'description', 'url': 'description', 'template': 'project/description/description', 'controller': 'Description', 'view': 'menuContent'},
      {'state': 'image-basemaps.image-basemap', 'url': ':imagebasemapId', 'template': 'maps/image-basemap/image-basemap', 'controller': 'ImageBasemap', 'view': 'image-basemap-view'},
      {'state': 'image-basemaps', 'url': 'image-basemaps', 'template': 'maps/image-basemaps/image-basemaps', 'controller': 'ImageBasemaps', 'view': 'menuContent'},
      {'state': 'images', 'url': 'images', 'template': 'attributes/images/images', 'controller': 'Images', 'view': 'menuContent'},
      {'state': 'manage-project', 'url': 'manage-project', 'template': 'project/manage/manage-project', 'controller': 'ManageProject', 'view': 'menuContent'},
      {'state': 'map', 'url': 'map', 'template': 'maps/map/map', 'controller': 'Map', 'view': 'menuContent'},
      {'state': 'misc', 'url': 'misc', 'template': 'misc/misc', 'controller': 'Misc', 'view': 'menuContent'},
      {'state': 'other-maps', 'url': 'other-maps', 'template': 'maps/other-maps/other-maps', 'controller': 'OtherMaps', 'view': 'menuContent'},
      {'state': 'preferences', 'url': 'preferences', 'template': 'project/preferences/preferences', 'controller': 'Preferences', 'view': 'menuContent'},
      {'state': 'relationships.relationship', 'url': ':relationship_id', 'template': 'relationship/relationship', 'controller': 'Relationship', 'view': 'relationship-view@app.relationships'},
      {'state': 'relationships', 'url': 'relationships', 'template': 'relationships/relationships', 'controller': 'Relationships', 'view': 'menuContent'},
      {'state': 'samples', 'url': 'samples', 'template': 'attributes/samples/samples', 'controller': 'Samples', 'view': 'menuContent'},
      {'state': 'strat-section', 'url': 'strat-sections/:stratSectionId', 'template': 'maps/strat-section/strat-section', 'controller': 'StratSection', 'view': 'menuContent'},
      //{'state': 'strat-sections.strat-section', 'url': ':stratSectionId', 'template': 'maps/strat-section/strat-section', 'controller': 'StratSection', 'view': 'strat-section-view'},
      {'state': 'strat-sections', 'url': 'strat-sections', 'template': 'maps/strat-sections/strat-sections', 'controller': 'StratSections', 'view': 'menuContent'},
      {'state': 'thin-section', 'url': 'thin-sections/:thinSectionId', 'template': 'maps/thin-section/thin-section', 'controller': 'ThinSection', 'view': 'menuContent'},
      //{'state': 'thin-sections.thin-section', 'url': ':thinSectionId', 'template': 'maps/thin-section/thin-section', 'controller': 'StratSection', 'view': 'thin-section-view'},
      {'state': 'thin-sections', 'url': 'thin-sections', 'template': 'maps/thin-sections/thin-sections', 'controller': 'ThinSections', 'view': 'menuContent'},
      {'state': 'tags.tag', 'url': ':tag_id', 'template': 'tag/tag', 'controller': 'Tag', 'view': 'tag-view@app.tags'},
      {'state': 'tags', 'url': 'tags', 'template': 'tags/tags', 'controller': 'Tags', 'view': 'menuContent'},
      {'state': 'tools', 'url': 'tools', 'template': 'project/tools/tools', 'controller': 'Tools', 'view': 'menuContent'},
      {'state': 'user', 'url': 'user', 'template': 'user/user', 'controller': 'User', 'view': 'menuContent'},
      // For WEB only
      {'state': 'login', 'url': 'login', 'template': 'login/login', 'controller': 'Login', 'view': 'menuContent'}
    ];
    _.each(states, function (state) {
      var viewKey = state.view;
      var view = {};
      view[viewKey] = {
        'templateUrl': 'app/' + state.template + '.web.html',   // Added .web for WEB
        'controller': state.controller + 'Controller as vm'
      };
      $stateProvider.state('app.' + state.state, {
        'cache': false,
        'url': '/' + state.url,
        'views': view
      });
    });

    // Declare Spot Tab State
    $stateProvider.state('app.spotTab', {
        'cache': false,
        'url': '/spotTab',
        'views': {
          'menuContent': {
            'templateUrl': 'app/spots/spots.web.html',
            'controller': 'SpotsController as vm'
          },
          'spot-data@app.spotTab': {
            'templateUrl': 'app/spot/spot/spot.web.html',
            'controller': 'SpotController as vm'
          }
        },
        'onExit': function ($log, SpotFactory) {
          if (!SpotFactory.getKeepSpotSelected()) {
            $log.log('Exiting Spots State. Clearing current Spot ...');
            SpotFactory.clearCurrentSpot();
          }
          else SpotFactory.setKeepSpotSelected(false);
        }
      });

    // Declare Spot Tab Childview States
    var spotTabStates = [
      {'state': '_3dstructures', 'template': '3d-structures/3dstructures-tab', 'controller': '_3DStructures'},
      {'state': 'experimental', 'template': 'micro/experimental/experimental-tab', 'controller': 'Experimental'},
      {'state': 'experimental-results', 'template': 'micro/experimental-results/experimental-results-tab', 'controller': 'ExperimentalResults'},
      {'state': 'experimental-set-up', 'template': 'micro/experimental-set-up/experimental-set-up-tab', 'controller': 'ExperimentalSetUp'},
      {'state': 'fabrics', 'template': 'fabrics/fabrics-tab', 'controller': 'Fabrics'},
      {'state': 'data', 'template': 'data/data-tab', 'controller': 'Data'},
      {'state': 'images', 'template': 'images/images-tab', 'controller': 'Images'},
      {'state': 'nesting', 'template': 'nesting/nesting-tab', 'controller': 'Nesting'},
      {'state': 'notes', 'template': 'notes/notes-tab', 'controller': 'Notes'},
      {'state': 'orientations', 'template': 'orientations/orientations-tab', 'controller': 'Orientations'},
      {'state': 'other-features', 'template': 'other-features/other-features-tab', 'controller': 'OtherFeatures'},
      {'state': 'relationships', 'template': 'relationships/relationships-tab', 'controller': 'Relationships'},
      {'state': 'samples', 'template': 'samples/samples-tab', 'controller': 'Samples'},
      {'state': 'spot', 'template': 'spot-tab/spot-tab', 'controller': 'Spot'},
      {'state': 'sed-bedding', 'template': 'sed/bedding/bedding-tab', 'controller': 'SedBedding'},
      {'state': 'sed-diagenesis', 'template': 'sed/diagenesis/diagenesis-tab', 'controller': 'SedDiagenesis'},
      {'state': 'sed-fossils', 'template': 'sed/fossils/fossils-tab', 'controller': 'SedFossils'},
      {'state': 'sed-interpretations', 'template': 'sed/interpretations/interpretations-tab', 'controller': 'SedInterpretations'},
      {'state': 'sed-interval', 'template': 'sed/interval/interval-tab', 'controller': 'SedInterval'},
      {'state': 'sed-lithologies', 'template': 'sed/lithologies/lithologies-tab', 'controller': 'SedLithologies'},
      {'state': 'sed-structures', 'template': 'sed/structures/structures-tab', 'controller': 'SedStructures'},
      {'state': 'strat-section', 'template': 'sed/strat-section/strat-section-tab', 'controller': 'StratSection'},
      {'state': 'petrology', 'template': 'petrology/petrology-tab', 'controller': 'Petrology'},
      {'state': 'tags', 'template': 'tags/tags-tab', 'controller': 'Tags'}
    ];
    _.each(spotTabStates, function (spotTabState) {
      $stateProvider.state('app.spotTab.' + spotTabState.state, {
        'cache': false,
        'url': '/:spotId/' + spotTabState.state,
        'views': {
          'spottab-childview': {
            'templateUrl': 'app/spot/' + spotTabState.template + '.web.html',   // Added .web for WEB
            'controller': spotTabState.controller + 'TabController as vmChild'
          }
        }
      });
    });

    // If none of the above states are matched, use this as the fallback
    $urlRouterProvider.otherwise('/app/map');
  }

  function prepMenu($ionicLoading, LocalStorageFactory, DataModelsFactory, ProjectFactory, RemoteServerFactory, SpotFactory,
                    UserFactory, OtherMapsFactory, AutoLoginFactory) {
    $ionicLoading.show({'template': '<ion-spinner></ion-spinner>
Loading Data Models...'});
    return DataModelsFactory.loadDataModels().then(function () {
      $ionicLoading.show({'template': '<ion-spinner></ion-spinner>
Loaded Data Models
Loading Database...'});
      return LocalStorageFactory.setupLocalforage().then(function () {
        $ionicLoading.show({'template': '<ion-spinner></ion-spinner>
Loaded Data Models
Loaded Database
Loading User...'});
        return AutoLoginFactory.autoLogin().then(function () {
          $ionicLoading.show({'template': '<ion-spinner></ion-spinner>
Loaded Data Models
Loaded Database
Loaded User
Loading Project...'});
          return UserFactory.loadUser().then(function () {
            $ionicLoading.show({'template': '<ion-spinner></ion-spinner>
Automatically logged in...'});
            return ProjectFactory.prepProject().then(function () {
              $ionicLoading.show({'template': '<ion-spinner></ion-spinner>
Loaded Data Models
Loaded Database
Loaded User
Loaded Project
Loading Spots...'});
              return SpotFactory.loadSpots().then(function () {
                $ionicLoading.hide();
                return RemoteServerFactory.loadDbUrl().then(function () {
                  return OtherMapsFactory.loadOtherMaps();
                });
              });
            });
          });
        });
      });
    });
  }
}());
<|endoftext|>


<commit_before>var fs          =   require('fs');
var sourceJS    =   [];
var jsFiles     =   fs.readdirSync('./static/js');
var jsIgnore    =   ['mustache.js', 'topojson.js'];
var i           =   jsFiles.length;

while(i--) {
    if(jsFiles[i].indexOf('.js') > -1 && jsFiles[i].indexOf('.min') === -1 && jsIgnore.indexOf(jsFiles[i]) === -1) {
        sourceJS.push('static/js/' + jsFiles[i]);
    }
}

sourceJS.push('Gruntfile.js');

module.exports  =   function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        sass: {
            dist: {
                files: {
                    'static/css/screen.css': 'static/sass/screen.scss',
                    'static/css/find-your-rep.css': 'static/sass/find-your-rep.scss'
                }
            },
            options: {
                loadPath: [
                    'bower_components/bourbon/dist',
                    'bower_components/css-smart-grid/sass'
                ],
                sourcemap: true,
                style: 'compressed'
            }
        },
        jshint: {
            files: sourceJS,
            jshintrc: '.jshintrc'
        },
        uglify: {
            options: {
                sourceMap: true
            },
            dist: {
                files: {
                    'static/js/core.min.js': ['bower_components/topojson/topojson.js', 'static/js/core.js'],
                    'static/js/ocd-divisions.min.js': ['static/js/ocd-divisions.js'],
                    'static/js/find-your-rep.min.js': ['static/js/mustache.js', 'static/js/ocd-divisions.js', 'static/js/find-your-rep.js'],
                    'static/js/calendar.min.js': ['static/js/mustache.js', 'static/js/calendar.js']
                }
            }
        },
        'json-minify': {
            build: {
                files: 'boundary-files/*.json'
            }
        },
        copy: {
            css: {
                files: [
                    {expand: true, src: ['static/css/*'], dest: '_site/', filter: 'isFile'}
                ]
            },
            images: {
                files: [
                    {expand: true, src: ['static/img/*'], dest: '_site/'}
                ]
            }
        },
        watch: {
            css: {
                files: 'static/sass/*.scss',
                tasks: ['sass', 'copy:css']
            },
            js: {
                files: sourceJS,
                tasks: ['newer:jshint', 'newer:uglify']
            },
            html: {
                files: [
                            '**/*.html',
                            '**/*.md',
                            '**/*.markdown',
                            '**/*.txt',
                            '!_site/**/*.html',
                            '!**/node_modules/**',
                            '!**/bower_components/**'
                        ],
                tasks: ['jekyll']
            },
            json: {
                files: ['boundary-files/*.json'],
                tasks: ['json-minify']
            },
            images: {
                files: ['static/img/**'],
                tasks: ['copy:images']
            }
        },
        connect: {
            server: {
                options: {
                    livereload: true,
                    base: '_site/',
                    port: 4000
                }
            }
        },
        jekyll: {
            options: {
                src: '<%= app %>'
            },
            dist: {
                options: {
                    config: '_config.yml'
                }
            }
        }
    });
    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-json-minify');
    grunt.loadNpmTasks('grunt-jekyll');
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-newer');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.registerTask('default', [
        'jekyll',
        'connect:server',
        'watch'
    ]);
    grunt.registerTask('build', [
        'sass',
        'jshint',
        'uglify',
        'json-minify',
        'jekyll'
    ]);
};
<commit_msg>copy js files when they're updated<commit_after>var fs          =   require('fs');
var sourceJS    =   [];
var jsFiles     =   fs.readdirSync('./static/js');
var jsIgnore    =   ['mustache.js', 'topojson.js'];
var i           =   jsFiles.length;

while(i--) {
    if(jsFiles[i].indexOf('.js') > -1 && jsFiles[i].indexOf('.min') === -1 && jsIgnore.indexOf(jsFiles[i]) === -1) {
        sourceJS.push('static/js/' + jsFiles[i]);
    }
}

sourceJS.push('Gruntfile.js');

module.exports  =   function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        sass: {
            dist: {
                files: {
                    'static/css/screen.css': 'static/sass/screen.scss',
                    'static/css/find-your-rep.css': 'static/sass/find-your-rep.scss'
                }
            },
            options: {
                loadPath: [
                    'bower_components/bourbon/dist',
                    'bower_components/css-smart-grid/sass'
                ],
                sourcemap: true,
                style: 'compressed'
            }
        },
        jshint: {
            files: sourceJS,
            jshintrc: '.jshintrc'
        },
        uglify: {
            options: {
                sourceMap: true
            },
            dist: {
                files: {
                    'static/js/core.min.js': ['bower_components/topojson/topojson.js', 'static/js/core.js'],
                    'static/js/ocd-divisions.min.js': ['static/js/ocd-divisions.js'],
                    'static/js/find-your-rep.min.js': ['static/js/mustache.js', 'static/js/ocd-divisions.js', 'static/js/find-your-rep.js'],
                    'static/js/calendar.min.js': ['static/js/mustache.js', 'static/js/calendar.js']
                }
            }
        },
        'json-minify': {
            build: {
                files: 'boundary-files/*.json'
            }
        },
        copy: {
            css: {
                files: [
                    {expand: true, src: ['static/css/*'], dest: '_site/', filter: 'isFile'}
                ]
            },
            js: {
                files: [
                    {expand: true, src: ['static/js/*.min.js', 'static/js/*.map'], dest: '_site', filter: 'isFile'}
                ]
            },
            images: {
                files: [
                    {expand: true, src: ['static/img/*'], dest: '_site/'}
                ]
            }
        },
        watch: {
            css: {
                files: 'static/sass/*.scss',
                tasks: ['sass', 'copy:css']
            },
            js: {
                files: sourceJS,
                tasks: ['newer:jshint', 'newer:uglify', 'copy:js']
            },
            html: {
                files: [
                            '**/*.html',
                            '**/*.md',
                            '**/*.markdown',
                            '**/*.txt',
                            '!_site/**/*.html',
                            '!**/node_modules/**',
                            '!**/bower_components/**'
                        ],
                tasks: ['jekyll']
            },
            json: {
                files: ['boundary-files/*.json'],
                tasks: ['json-minify']
            },
            images: {
                files: ['static/img/**'],
                tasks: ['copy:images']
            }
        },
        connect: {
            server: {
                options: {
                    livereload: true,
                    base: '_site/',
                    port: 4000
                }
            }
        },
        jekyll: {
            options: {
                src: '<%= app %>'
            },
            dist: {
                options: {
                    config: '_config.yml'
                }
            }
        }
    });
    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-json-minify');
    grunt.loadNpmTasks('grunt-jekyll');
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-newer');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.registerTask('default', [
        'jekyll',
        'connect:server',
        'watch'
    ]);
    grunt.registerTask('build', [
        'sass',
        'jshint',
        'uglify',
        'json-minify',
        'jekyll'
    ]);
};
<|endoftext|>