<commit_before>/**
 * A base class for path-finders.
 * This class *SHOULD NOT* be directly instantiated, as it does not provide
 * any path-finding algorithms or methods and is intended to be extended
 * by all the other path-finder classes.
 *
 * *Note*: The constructor does *NOT* receive any arguments for instantiation.
 *     All the parameters should be passed in in the {@code init} method.
 *     Therefore, you only need to instantiate this class once, and call
 *     the {@code init} method each time you start a new path-finding.
 * @constructor
 */
PF.BaseFinder = function() {
    this.startX = null; // avoids to be garbage collected
    this.startY = null;
    this.endX = null;
    this.endY = null;
    this.grid = null;

    this.gridHeight = null;
    this.gridWidth = null;
};

/**
 * Initiate the path-finder by providing the coordinates and the grid.
 * @param {integer} startX The x coordinate of the start position.
 * @param {integer} startY The y coordinate of the start position.
 * @param {integer} endX The x coordinate of the end position.
 * @param {integer} endY The y coordinate of the end position.
 */
PF.BaseFinder.prototype.init = function(startX, startY, endX, endY, grid) {
    this.startX = startX;
    this.startY = startY;
    this.endX = endX;
    this.endY = endY;
    this.grid = grid;

    this.gridWidth = grid.width;
    this.gridHeight = grid.height;
};

/**
 * Determine whether the given postition is inside the grid.
 * @param {integer} x The x coordinate of the position.
 * @param {integer} y The y coordinate of the position.
 * @return {boolean} Whether it is inside.
 */
PF.BaseFinder.prototype.isInsideGrid = function(x, y) {
    // delegates to grid.
    return this.grid.isInside(x, y);
};

/**
 * Set the walkable attribute of the given position on the grid.
 * @param {integer} x The x coordinate of the position.
 * @param {integer} y The y coordinate of the position.
 */
PF.BaseFinder.prototype.setWalkableAt = function(x, y, walkable) {
    // delegates to grid.
    this.grid.setWalkableAt(x, y, walkable);
};

/**
 * Determine whether the given position on the grid is walkable.
 * @param {integer} x The x coordinate of the position.
 * @param {integer} y The y coordinate of the position.
 * @return {boolean} Whether it is walkable.
 */
PF.BaseFinder.prototype.isWalkableAt = function(x, y) {
    // delegates to grid.
    return this.grid.isWalkableAt(x, y);
};

/**
 * Generic setter of the attribute at the given position.
 * @param {integer} x The x coordinate of the position.
 * @param {integer} y The y coordinate of the position.
 * @param {string} attr The name of attribute to set.
 * @param {object} value The value of attribute.
 */
PF.BaseFinder.prototype.setAttributeAt = function(x, y, attr, value) {
    // delegates to grid.
    this.grid.setAttributeAt(x, y, attr, value);
};

/**
 * Generic getter of the attribute at the given position.
 * @param {integer} x The x coordinate of the position.
 * @param {integer} y The y coordinate of the position.
 * @param {string} attr The name of attribute to get.
 * @return {object} The value of the attribute.
 */
PF.BaseFinder.prototype.getAttributeAt = function(x, y, attr) {
    // delegates to grid.
    return this.nodes[y][x][attr];
};

/**
 * The constructor of each BaseFinder instance.
 */
PF.BaseFinder.prototype.constructor = PF.BaseFinder;

/**
 * Find and return the the path.
 * *NOTE*: This method is intended to be overriden by sub-classes.
 * @return {Array.<[integer, integer]>} The path, including both start and
 *     end positions.
 */
PF.BaseFinder.prototype.findPath = function() {
    throw new Error('Not Implemented Error: ' +
        'Sub-classes must implement this method');
};
<commit_msg>fix: implementation of `getAttributeAt` in core/BaseFinder.js<commit_after>/**
 * A base class for path-finders.
 * This class *SHOULD NOT* be directly instantiated, as it does not provide
 * any path-finding algorithms or methods and is intended to be extended
 * by all the other path-finder classes.
 *
 * *Note*: The constructor does *NOT* receive any arguments for instantiation.
 *     All the parameters should be passed in in the {@code init} method.
 *     Therefore, you only need to instantiate this class once, and call
 *     the {@code init} method each time you start a new path-finding.
 * @constructor
 */
PF.BaseFinder = function() {
    this.startX = null; // avoids to be garbage collected
    this.startY = null;
    this.endX = null;
    this.endY = null;
    this.grid = null;

    this.gridHeight = null;
    this.gridWidth = null;
};

/**
 * Initiate the path-finder by providing the coordinates and the grid.
 * @param {integer} startX The x coordinate of the start position.
 * @param {integer} startY The y coordinate of the start position.
 * @param {integer} endX The x coordinate of the end position.
 * @param {integer} endY The y coordinate of the end position.
 */
PF.BaseFinder.prototype.init = function(startX, startY, endX, endY, grid) {
    this.startX = startX;
    this.startY = startY;
    this.endX = endX;
    this.endY = endY;
    this.grid = grid;

    this.gridWidth = grid.width;
    this.gridHeight = grid.height;
};

/**
 * Determine whether the given postition is inside the grid.
 * @param {integer} x The x coordinate of the position.
 * @param {integer} y The y coordinate of the position.
 * @return {boolean} Whether it is inside.
 */
PF.BaseFinder.prototype.isInsideGrid = function(x, y) {
    // delegates to grid.
    return this.grid.isInside(x, y);
};

/**
 * Set the walkable attribute of the given position on the grid.
 * @param {integer} x The x coordinate of the position.
 * @param {integer} y The y coordinate of the position.
 */
PF.BaseFinder.prototype.setWalkableAt = function(x, y, walkable) {
    // delegates to grid.
    this.grid.setWalkableAt(x, y, walkable);
};

/**
 * Determine whether the given position on the grid is walkable.
 * @param {integer} x The x coordinate of the position.
 * @param {integer} y The y coordinate of the position.
 * @return {boolean} Whether it is walkable.
 */
PF.BaseFinder.prototype.isWalkableAt = function(x, y) {
    // delegates to grid.
    return this.grid.isWalkableAt(x, y);
};

/**
 * Generic setter of the attribute at the given position.
 * @param {integer} x The x coordinate of the position.
 * @param {integer} y The y coordinate of the position.
 * @param {string} attr The name of attribute to set.
 * @param {object} value The value of attribute.
 */
PF.BaseFinder.prototype.setAttributeAt = function(x, y, attr, value) {
    // delegates to grid.
    this.grid.setAttributeAt(x, y, attr, value);
};

/**
 * Generic getter of the attribute at the given position.
 * @param {integer} x The x coordinate of the position.
 * @param {integer} y The y coordinate of the position.
 * @param {string} attr The name of attribute to get.
 * @return {object} The value of the attribute.
 */
PF.BaseFinder.prototype.getAttributeAt = function(x, y, attr) {
    // delegates to grid.
    return this.grid.getAttributeAt(x, y, attr);
};

/**
 * The constructor of each BaseFinder instance.
 */
PF.BaseFinder.prototype.constructor = PF.BaseFinder;

/**
 * Find and return the the path.
 * *NOTE*: This method is intended to be overriden by sub-classes.
 * @return {Array.<[integer, integer]>} The path, including both start and
 *     end positions.
 */
PF.BaseFinder.prototype.findPath = function() {
    throw new Error('Not Implemented Error: ' +
        'Sub-classes must implement this method');
};
<|endoftext|>


<commit_before>import React from 'react';
import { routerRedux } from 'dva/router';
import styles from './ResidentInfoTable.less';
import { Table, Button, Icon, Upload, message, Radio } from 'antd';
import InfoTable from './InfoTabel';
import { fun, modular, api, config } from '../../common';

const moduleName = '居民信息表控件(ResidentInfoTable)';
const RadioButton = Radio.Button;
const RadioGroup = Radio.Group;
const { name, sex, birthday, tel, cardDate, disease, diseaseCase, drugs, present,
  remark, operation, visit, followUp, status } = config.ritField;
const ORDER_STATUS = config.ORDER_STATUS;

/**
 * 用户信息表控件，必须提供以下几个参数
 * @name 引用它的父级控件名称
 * @userType 用户类型
 * @onSave 保存时的回调函数，
 * @onSubmit 提交时的回调函数，
 * @monitor 表格一行内有几个可编辑的单元格项
 * @disabled 控制上传excel和下载excel模板按钮是否可见
 */
export default class ResidentInfoTable extends React.Component {
  constructor( props ) {
    super( props );

    this.state = {
      ritRef: modular[ props.name ][ 'ritRef' ], // 上传excel后返回的服务器对应数据字段
      data: props.data, // 外层传进来的原始数据
      disabled: props.disabled, // 当前页面元件是否可用
      showDoctor: props.userType === config.userType.doctor ? true : false,
      showWorker: props.userType === config.userType.worker ? true : false,
      isOver: props.isOver || false, // 订单处理状态：true 已完结
      untreated: 0, // 显示在切换按钮上的数字
      treated: 0,
      orderStatus: ORDER_STATUS.untreated, // 订单状态：已处理(1)、未处理(2)
    }
  }
  // public function
  /**
   * 获取用户信息表数据
   */
  getData = () => {
    let data = this.refs.infoTable.getData();
    fun.print( data, 'data', moduleName );
    return data;
  }
  setTreated = ( untreated, treated ) => {
    this.setState( { untreated, treated } );
  }
  // private function
  /**
   * 上传失败
   */
  uploadError = () => {
    fun.showError( '导入Excel文件出错',
      '请确认您导入的是Excel文件，或者检您的Excel文件是否有异常数据导致无法导入！' );
  }
  /**
   * 上传成功
   */
  uploadSuccess = () => {
    fun.showNotification( '导入居民信息成功',
      '居民信息已全部导入，提交前请检查核对一下您导入的信息！' );
  }
  /**
   * 下载excel模版
   */
  download = () => {
    fun.print( this.refs.ifile );
    this.refs.ifile.src = modular[ this.props.name ].tpl;
  }
  /**
   * 读取excel数据
   */
  upload = ( info ) => {
    if ( !info.file ) return;
    if ( info.file.status === 'done' ) {
      let res = info.file.response;
      fun.print( res.entity, '读取Excel完成', moduleName );
      if ( res.success ) {
        this.setState( { data: res.entity.rows } );
        this.uploadSuccess();
      } else {
        this.uploadError();
      }
    }
    if ( info.file.status === 'error' ) {
      fun.showError( '上传数据错误', info );
      fun.print( info, 'failed' );
    }
  }
  /**
   * 切换已处理、未处理
   */
  handlerRadioChange = ( e ) => {
    this.setState( {
      orderStatus: e.target.value
    } );
  };

  render() {
    return (

          {/*<Button size="small" onClick={ this.getData }>打印测试数据</Button> */ }
          { this.state.showDoctor ?

              <Button size="small" disabled={ this.props.disabled } onClick={ this.download }
                icon="download">下载该表格</Button>
              <Upload action={ api.uploadExcel } onChange={ this.upload }
                data={ { itemId: this.state.ritRef } } showUploadList={ false }>
                <Button size="small" disabled={ this.props.disabled } onClick={ this.upload }
                  icon="upload">导入居民信息</Button>
              </Upload>

            : '' }
          { this.state.showWorker && !this.state.isOver ?

              <RadioGroup onChange={ this.handlerRadioChange } value={ this.state.orderStatus }
                className={ styles.treated }>
                <RadioButton value="1">待处理 ({ this.state.untreated })</RadioButton>
                <RadioButton value="2">已处理 ({ this.state.treated })</RadioButton>
              </RadioGroup>

            : '' }
          居民信息表样本

        <InfoTable {...this.props} orderStatus={ this.state.orderStatus } data={ this.state.data } ref="infoTable"
          setTreated={ ( untreated, treated ) => this.setTreated( untreated, treated ) } />

    );
  }

  componentWillReceiveProps( nextProps ) {
    this.setState( { data: nextProps.data } );
  }
  /*
    shouldComponentUpdate( nextProps, nextState ) {
      return nextProps.data !== this.state.data || nextState.data !== this.state.data
        || nextProps.disabled !== this.state.disabled;
    }*/
}<commit_msg>导入居民信息表，提交的模块信息不正确问题修复<commit_after>import React from 'react';
import { routerRedux } from 'dva/router';
import styles from './ResidentInfoTable.less';
import { Table, Button, Icon, Upload, message, Radio } from 'antd';
import InfoTable from './InfoTabel';
import { fun, modular, api, config } from '../../common';

const moduleName = '居民信息表控件(ResidentInfoTable)';
const RadioButton = Radio.Button;
const RadioGroup = Radio.Group;
const { name, sex, birthday, tel, cardDate, disease, diseaseCase, drugs, present,
  remark, operation, visit, followUp, status } = config.ritField;
const ORDER_STATUS = config.ORDER_STATUS;

/**
 * 用户信息表控件，必须提供以下几个参数
 * @name 引用它的父级控件名称
 * @userType 用户类型
 * @onSave 保存时的回调函数，
 * @onSubmit 提交时的回调函数，
 * @monitor 表格一行内有几个可编辑的单元格项
 * @disabled 控制上传excel和下载excel模板按钮是否可见
 */
export default class ResidentInfoTable extends React.Component {
  constructor( props ) {
    super( props );

    this.state = {
      ritRef: modular[ props.name ][ 'ritRef' ], // 上传excel后返回的服务器对应数据字段
      data: props.data, // 外层传进来的原始数据
      showDoctor: props.userType === config.userType.doctor ? true : false,
      showWorker: props.userType === config.userType.worker ? true : false,
      isOver: props.isOver || false, // 订单处理状态：true 已完结
      untreated: 0, // 显示在切换按钮上的数字
      treated: 0,
      orderStatus: ORDER_STATUS.untreated, // 订单状态：已处理(1)、未处理(2)
    }
  }
  // public function
  /**
   * 获取用户信息表数据
   */
  getData = () => {
    let data = this.refs.infoTable.getData();
    fun.print( data, 'data', moduleName );
    return data;
  }
  setTreated = ( untreated, treated ) => {
    this.setState( { untreated, treated } );
  }
  // private function
  /**
   * 上传失败
   */
  uploadError = () => {
    fun.showError( '导入Excel文件出错',
      '请确认您导入的是Excel文件，或者检您的Excel文件是否有异常数据导致无法导入！' );
  }
  /**
   * 上传成功
   */
  uploadSuccess = () => {
    fun.showNotification( '导入居民信息成功',
      '居民信息已全部导入，提交前请检查核对一下您导入的信息！' );
  }
  /**
   * 下载excel模版
   */
  download = () => {
    fun.print( this.refs.ifile );
    this.refs.ifile.src = modular[ this.props.name ].tpl;
  }
  /**
   * 读取excel数据
   */
  upload = ( info ) => {
    if ( !info.file ) return;
    if ( info.file.status === 'done' ) {
      let res = info.file.response;
      fun.print( res.entity, '读取Excel完成', moduleName );
      if ( res.success ) {
        this.setState( { data: res.entity.rows } );
        this.uploadSuccess();
      } else {
        this.uploadError();
      }
    }
    if ( info.file.status === 'error' ) {
      fun.showError( '上传数据错误', info );
      fun.print( info, 'failed' );
    }
  }
  /**
   * 切换已处理、未处理
   */
  handlerRadioChange = ( e ) => {
    this.setState( {
      orderStatus: e.target.value
    } );
  };

  render() {
    return (

          {/*<Button size="small" onClick={ this.getData }>打印测试数据</Button> */ }
          { this.state.showDoctor ?

              <Button size="small" disabled={ this.props.disabled } onClick={ this.download }
                icon="download">下载该表格</Button>
              <Upload action={ api.uploadExcel } onChange={ this.upload }
                data={ { itemId: this.state.ritRef } } showUploadList={ false }>
                <Button size="small" disabled={ this.props.disabled } onClick={ this.upload }
                  icon="upload">导入居民信息</Button>
              </Upload>

            : '' }
          { this.state.showWorker && !this.state.isOver ?

              <RadioGroup onChange={ this.handlerRadioChange } value={ this.state.orderStatus }
                className={ styles.treated }>
                <RadioButton value="1">待处理 ({ this.state.untreated })</RadioButton>
                <RadioButton value="2">已处理 ({ this.state.treated })</RadioButton>
              </RadioGroup>

            : '' }
          居民信息表样本

        <InfoTable {...this.props} orderStatus={ this.state.orderStatus } data={ this.state.data } ref="infoTable"
          setTreated={ ( untreated, treated ) => this.setTreated( untreated, treated ) } />

    );
  }

  componentWillReceiveProps( nextProps ) {
    this.setState( {
      data: nextProps.data,
      ritRef: modular[ nextProps.name ][ 'ritRef' ],
      isOver: nextProps.isOver || false
    } );
  }
  /*
    shouldComponentUpdate( nextProps, nextState ) {
      return nextProps.data !== this.state.data || nextState.data !== this.state.data
        || nextProps.disabled !== this.state.disabled;
    }*/
}<|endoftext|>


<commit_before>/** Called automatically by JsDoc Toolkit. */
load(JSDOC.opt.t + 'src/Symbol.js');
load(JSDOC.opt.t + 'src/Utils.js');
load(JSDOC.opt.t + 'src/Operator.js');
load(JSDOC.opt.t + 'src/Render.js');

function publish(symbolSet) {
	var renderMode = JSDOC.opt.D.renderMode;
	var templatedocs = renderMode == 'templatedocs';
	var extension = templatedocs ? '.jstl' : '.html';
	var templateDir = JSDOC.opt.t || SYS.pwd + '../templates/jsdoc/';
	var outDir = JSDOC.opt.d || SYS.pwd + '../out/jsdoc/';

	publish.conf = {  // trailing slash expected for dirs
		// Use no extensions in links for templatedocs
		ext: templatedocs ? '' : extension,
		outDir: outDir,
		templateDir: templateDir,
		staticDir: templateDir + 'static/',
		classesDir: outDir + 'classes/',
		symbolsDir: templatedocs ? 'reference/' : 'classes/',
		srcDir: 'symbols/src/',
		renderMode: renderMode,
		globalName: 'Global Scope'
	};

	Link.base = templatedocs ? '/' : '../';

	if (renderMode == 'docs') {
		// Copy over the static files
		Utils.copyDirectory(
			new java.io.File(publish.conf.staticDir),
			new java.io.File(publish.conf.outDir)
		);

		// Create the classes directory
		new java.io.File(publish.conf.classesDir).mkdir();
	} else {
		Utils.deleteFiles(new File(publish.conf.outDir));
		new java.io.File(publish.conf.classesDir).mkdirs();
	}

	// used to allow Link to check the details of things being linked to
	Link.symbolSet = symbolSet;

	// get an array version of the symbolset, useful for filtering
	var symbols = symbolSet.toArray(),
		files = JSDOC.opt.srcFiles,
		aliasSort = Utils.makeSortby('alias'),
 		classes = symbols.filter(Utils.isaClass).sort(aliasSort);

	// create a filemap in which outfiles must be to be named uniquely, ignoring case
	// Since we want lowercase links in templatedocs, we always use this
	var filemapCounts = {};
	Link.filemap = {};
	for (var i = 0, l = classes.length; i < l; i++) {
		var alias = classes[i].alias,
			lcAlias = alias.toLowerCase();

		if (!filemapCounts[lcAlias]) {
			filemapCounts[lcAlias] = 1;
		} else {
			filemapCounts[lcAlias]++;
		}
		// Use lowercase links for templatedocs
		var linkAlias = templatedocs ? lcAlias : alias;
		// Rename _global_.html to global.html
		if (linkAlias == '_global_')
			linkAlias = 'global';
		Link.filemap[alias] = filemapCounts[lcAlias] > 1
				? linkAlias + '_' + filemapCounts[lcAlias] : linkAlias;
	}

	// create each of the class pages
	for (var i = 0, l = classes.length; i < l; i++) {
		var symbol = classes[i];

		symbol.events = symbol.getEvents();   // 1 order matters
		symbol.methods = symbol.getMethods(); // 2
		for (var j = 0; j < symbol.methods.length; j++) {
			var method = symbol.methods[j];
			method.isOperator = Operator.isOperator(method);
		}

		Link.currentSymbol= symbol;
		var html = Render._class(symbol);
		var name = Link.filemap[symbol.alias] + extension;
		if (renderMode == 'docs') {
			html = Render.html({
				content: html,
				title: symbol.alias
			});
		}
		IO.saveFile(publish.conf.classesDir, name, html);
	}
	if (templatedocs) {
		IO.saveFile(publish.conf.outDir, 'packages.js', Render.indexjs());
	} else {
		IO.saveFile(publish.conf.classesDir, 'index.html', Render.index());
	}
}<commit_msg>jsdoc: Merge code for different render modes.<commit_after>/** Called automatically by JsDoc Toolkit. */
load(JSDOC.opt.t + 'src/Symbol.js');
load(JSDOC.opt.t + 'src/Utils.js');
load(JSDOC.opt.t + 'src/Operator.js');
load(JSDOC.opt.t + 'src/Render.js');

function publish(symbolSet) {
	var renderMode = JSDOC.opt.D.renderMode;
	var templatedocs = renderMode == 'templatedocs';
	var extension = templatedocs ? '.jstl' : '.html';
	var templateDir = JSDOC.opt.t || SYS.pwd + '../templates/jsdoc/';
	var outDir = JSDOC.opt.d || SYS.pwd + '../out/jsdoc/';

	publish.conf = {  // trailing slash expected for dirs
		// Use no extensions in links for templatedocs
		ext: templatedocs ? '' : extension,
		outDir: outDir,
		templateDir: templateDir,
		staticDir: templateDir + 'static/',
		classesDir: outDir + 'classes/',
		symbolsDir: templatedocs ? 'reference/' : 'classes/',
		srcDir: 'symbols/src/',
		renderMode: renderMode,
		globalName: 'Global Scope'
	};

	Link.base = templatedocs ? '/' : '../';

	if (renderMode == 'docs') {
		// Copy over the static files
		Utils.copyDirectory(
			new java.io.File(publish.conf.staticDir),
			new java.io.File(publish.conf.outDir)
		);
	} else {
		Utils.deleteFiles(new File(publish.conf.outDir));
	}
	// Create the classes directory
	new java.io.File(publish.conf.classesDir).mkdirs();

	// used to allow Link to check the details of things being linked to
	Link.symbolSet = symbolSet;

	// get an array version of the symbolset, useful for filtering
	var symbols = symbolSet.toArray(),
		files = JSDOC.opt.srcFiles,
		aliasSort = Utils.makeSortby('alias'),
 		classes = symbols.filter(Utils.isaClass).sort(aliasSort);

	// create a filemap in which outfiles must be to be named uniquely, ignoring case
	// Since we want lowercase links in templatedocs, we always use this
	var filemapCounts = {};
	Link.filemap = {};
	for (var i = 0, l = classes.length; i < l; i++) {
		var alias = classes[i].alias,
			lcAlias = alias.toLowerCase();

		if (!filemapCounts[lcAlias]) {
			filemapCounts[lcAlias] = 1;
		} else {
			filemapCounts[lcAlias]++;
		}
		// Use lowercase links for templatedocs
		var linkAlias = templatedocs ? lcAlias : alias;
		// Rename _global_.html to global.html
		if (linkAlias == '_global_')
			linkAlias = 'global';
		Link.filemap[alias] = filemapCounts[lcAlias] > 1
				? linkAlias + '_' + filemapCounts[lcAlias] : linkAlias;
	}

	// create each of the class pages
	for (var i = 0, l = classes.length; i < l; i++) {
		var symbol = classes[i];

		symbol.events = symbol.getEvents();   // 1 order matters
		symbol.methods = symbol.getMethods(); // 2
		for (var j = 0; j < symbol.methods.length; j++) {
			var method = symbol.methods[j];
			method.isOperator = Operator.isOperator(method);
		}

		Link.currentSymbol= symbol;
		var html = Render._class(symbol);
		var name = Link.filemap[symbol.alias] + extension;
		if (renderMode == 'docs') {
			html = Render.html({
				content: html,
				title: symbol.alias
			});
		}
		IO.saveFile(publish.conf.classesDir, name, html);
	}
	if (templatedocs) {
		IO.saveFile(publish.conf.outDir, 'packages.js', Render.indexjs());
	} else {
		IO.saveFile(publish.conf.classesDir, 'index.html', Render.index());
	}
}<|endoftext|>


<commit_before>'use strict';
var fs = require('fs');

module.exports = function (grunt) {

    // Report the elapsed execution time of tasks.
    require('time-grunt')(grunt);

	var COMPRESS_FOR_TESTS = true;

    // Project configuration.
    grunt.initConfig({

        // Metadata required for build.
        build: grunt.file.readYAML('build/build.yml'),
        pkg: grunt.file.readJSON('package.json'),
        meta: {
            license: '<%= _.pluck(pkg.licenses, "type").join(", ") %>',
            copyright: 'Copyright (c) 2009-<%= grunt.template.today("yyyy") %>',
            banner: '/*!\n' +
                ' * Less - <%= pkg.description %> v<%= pkg.version %>\n' +
                ' * http://lesscss.org\n' +
                ' *\n' +
                ' * <%= meta.copyright %>, <%= pkg.author.name %> <<%= pkg.author.email %>>\n' +
                ' * Licensed under the <%= meta.license %> License.\n' +
                ' *\n' +
                ' */\n\n' +
                ' /**' +
                ' * @license <%= meta.license %>\n' +
                ' */\n\n'
        },

        shell: {
            options: {stdout: true, failOnError: true},
            test: {
                command: 'node test'
            },
            benchmark: {
                command: 'node benchmark/less-benchmark.js'
            },
            "sourcemap-test": {
                command: [
                    'node bin/lessc --source-map=test/sourcemaps/maps/import-map.map test/less/import.less test/sourcemaps/import.css',
                    'node bin/lessc --source-map test/less/sourcemaps/basic.less test/sourcemaps/basic.css'
                ].join('&&')
            }
        },

        browserify: {
            browser: {
                src: ['./lib/less-browser/bootstrap.js'],
                options: {
                    exclude: ["promise"],
                    require: ["promise/polyfill.js"],
                    browserifyOptions: {
                        standalone: 'less'
                    }
                },
                dest: 'tmp/less.js'
            }
        },
        concat: {
            options: {
                stripBanners: 'all',
                banner: '<%= meta.banner %>'
            },
            browsertest: {
                src: COMPRESS_FOR_TESTS ? '<%= uglify.test.dest %>' : '<%= browserify.browser.dest %>',
                dest: 'test/browser/less.js'
            },
            dist: {
                src: '<%= browserify.browser.dest %>',
                dest: 'dist/less.js'
            },
            // Rhino
            rhino: {
                options: {
                    banner: '/* Less.js v<%= pkg.version %> RHINO | <%= meta.copyright %>, <%= pkg.author.name %> <<%= pkg.author.email %>> */\n\n',
                    footer: '' // override task-level footer
                },
                src: ['<%= build.rhino %>'],
                dest: 'dist/less-rhino.js'
            },
            // lessc for Rhino
            rhinolessc: {
                options: {
                    banner: '/* Less.js v<%= pkg.version %> RHINO | <%= meta.copyright %>, <%= pkg.author.name %> <<%= pkg.author.email %>> */\n\n',
                    footer: '' // override task-level footer
                },
                src: ['<%= build.rhinolessc %>'],
                dest: 'dist/lessc-rhino.js'
            }
        },

        uglify: {
            options: {
                banner: '<%= meta.banner %>',
                mangle: true,
	            compress: {
	                pure_getters: true
	            }
            },
            dist: {
                src: ['<%= concat.dist.dest %>'],
                dest: 'dist/less.min.js'
            },
	        test: {
		        src: '<%= browserify.browser.dest %>',
		        dest: 'tmp/less.min.js'
	        }
        },

        jshint: {
            options: {jshintrc: '.jshintrc'},
            files: {
                src: [
                    'Gruntfile.js',
                    'lib/less/**/*.js',
                    'lib/less-node/**/*.js',
                    'lib/less-browser/**/*.js',
                    'lib/less-rhino/**/*.js',
                    'bin/lessc'
                ]
            }
        },

        connect: {
            server: {
                options: {
                    port: 8081
                }
            }
        },

        jasmine: {
            options: {
                keepRunner: true,
                host: 'http://localhost:8081/',
                vendor: ['test/browser/jasmine-jsreporter.js', 'test/browser/common.js', 'test/browser/less.js'],
                template: 'test/browser/test-runner-template.tmpl'
            },
            main: {
                // src is used to build list of less files to compile
                src: ['test/less/*.less', '!test/less/javascript.less', '!test/less/urls.less', '!test/less/empty.less'],
                options: {
                    helpers: 'test/browser/runner-main-options.js',
                    specs: 'test/browser/runner-main-spec.js',
                    outfile: 'tmp/browser/test-runner-main.html'
                }
            },
            legacy: {
                src: ['test/less/legacy/*.less'],
                options: {
                    helpers: 'test/browser/runner-legacy-options.js',
                    specs: 'test/browser/runner-legacy-spec.js',
                    outfile: 'tmp/browser/test-runner-legacy.html'
                }
            },
            strictUnits: {
                src: ['test/less/strict-units/*.less'],
                options: {
                    helpers: 'test/browser/runner-strict-units-options.js',
                    specs: 'test/browser/runner-strict-units-spec.js',
                    outfile: 'tmp/browser/test-runner-strict-units.html'
                }
            },
            errors: {
                src: ['test/less/errors/*.less', '!test/less/errors/javascript-error.less'],
                options: {
                    timeout: 20000,
                    helpers: 'test/browser/runner-errors-options.js',
                    specs: 'test/browser/runner-errors-spec.js',
                    outfile: 'tmp/browser/test-runner-errors.html'
                }
            },
            noJsErrors: {
                src: ['test/less/no-js-errors/*.less'],
                options: {
                    helpers: 'test/browser/runner-no-js-errors-options.js',
                    specs: 'test/browser/runner-no-js-errors-spec.js',
                    outfile: 'tmp/browser/test-runner-no-js-errors.html'
                }
            },
            browser: {
                src: ['test/browser/less/*.less'],
                options: {
                    helpers: 'test/browser/runner-browser-options.js',
                    specs: 'test/browser/runner-browser-spec.js',
                    outfile: 'tmp/browser/test-runner-browser.html'
                }
            },
            relativeUrls: {
                src: ['test/browser/less/relative-urls/*.less'],
                options: {
                    helpers: 'test/browser/runner-relative-urls-options.js',
                    specs: 'test/browser/runner-relative-urls-spec.js',
                    outfile: 'tmp/browser/test-runner-relative-urls.html'
                }
            },
            rootpath: {
                src: ['test/browser/less/rootpath/*.less'],
                options: {
                    helpers: 'test/browser/runner-rootpath-options.js',
                    specs: 'test/browser/runner-rootpath-spec.js',
                    outfile: 'tmp/browser/test-runner-rootpath.html'
                }
            },
            rootpathRelative: {
                src: ['test/browser/less/rootpath-relative/*.less'],
                options: {
                    helpers: 'test/browser/runner-rootpath-relative-options.js',
                    specs: 'test/browser/runner-rootpath-relative-spec.js',
                    outfile: 'tmp/browser/test-runner-rootpath-relative.html'
                }
            },
            production: {
                src: ['test/browser/less/production/*.less'],
                options: {
                    helpers: 'test/browser/runner-production-options.js',
                    specs: 'test/browser/runner-production-spec.js',
                    outfile: 'tmp/browser/test-runner-production.html'
                }
            },
            modifyVars: {
                src: ['test/browser/less/modify-vars/*.less'],
                options: {
                    helpers: 'test/browser/runner-modify-vars-options.js',
                    specs: 'test/browser/runner-modify-vars-spec.js',
                    outfile: 'tmp/browser/test-runner-modify-vars.html'
                }
            },
            globalVars: {
                src: ['test/browser/less/global-vars/*.less'],
                options: {
                    helpers: 'test/browser/runner-global-vars-options.js',
                    specs: 'test/browser/runner-global-vars-spec.js',
                    outfile: 'tmp/browser/test-runner-global-vars.html'
                }
            },
            postProcessor: {
                src: ['test/browser/less/postProcessor/*.less'],
                options: {
                    helpers: 'test/browser/runner-postProcessor-options.js',
                    specs: 'test/browser/runner-postProcessor.js',
                    outfile: 'tmp/browser/test-runner-post-processor.html'
                }
            }
        },

        'saucelabs-jasmine': {
            all: {
                options: {
                    urls: ["post-processor", "global-vars", "modify-vars", "production", "rootpath-relative",
                           "rootpath", "relative-urls", "browser", "no-js-errors", "legacy", "strict-units"
                    ].map(function(testName) {
                        return "http://localhost:8081/tmp/browser/test-runner-" + testName + ".html";
                    }),
                    testname: 'Sauce Unit Test for less.js',
                    browsers: [{
                        browserName: "chrome",
                        version: '',
                        platform: 'Windows 8'
                    },
                    {
                        browserName: "firefox",
                        version: '33',
                        platform: 'Linux'
                    },
                    {
                        browserName: "iPad",
                        version: '8.0',
                        platform: 'OS X 10.9',
                        'device-orientation': 'portrait'
                    },
                    {
                        browserName: "internet explorer",
                        version: '8',
                        platform: 'Windows XP'
                    },
                    {
                        browserName: "internet explorer",
                        version: '9',
                        platform: 'Windows 7'
                    },
                    {
                        browserName: "internet explorer",
                        version: '10',
                        platform: 'Windows 7'
                    },
                    {
                        browserName: "internet explorer",
                        version: '11',
                        platform: 'Windows 8.1'
                    }],
                    sauceConfig: {
                        'record-video': process.env.TRAVIS_BRANCH !== "master",
                        'record-screenshots': process.env.TRAVIS_BRANCH !== "master",
                        'idle-timeout': 100, 'max-duration': 120,
                        build: process.env.TRAVIS_BRANCH === "master" ? process.env.TRAVIS_JOB_ID : undefined,
                        tags: [process.env.TRAVIS_BUILD_NUMBER, process.env.TRAVIS_PULL_REQUEST, process.env.TRAVIS_BRANCH]
                    },
                    throttled: 3
                }
            }
        },

        // Clean the version of less built for the tests
        clean: {
            test: ['test/browser/less.js', 'tmp'],
            "sourcemap-test": ['test/sourcemaps/*.css', 'test/sourcemaps/*.map'],
            sauce_log: ["sc_*.log"]
        }
    });

    // Load these plugins to provide the necessary tasks
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

    // Actually load this plugin's task(s).
    grunt.loadTasks('build/tasks');

    // by default, run tests
    grunt.registerTask('default', [
        'test'
    ]);

    grunt.registerTask('updateBowerJson', function () {
        var bowerJson = require('./bower.json');
        bowerJson.version = grunt.config('pkg.version');
        fs.writeFileSync('./bower.json', JSON.stringify(bowerJson, null, 2));
    });

    // Release
    grunt.registerTask('dist', [
        'browserify:browser',
        'concat:dist',
        'uglify:dist',
        'updateBowerJson'
    ]);

    // Release Rhino Version
    grunt.registerTask('rhino', [
        'browserify:rhino',
        'concat:rhino',
        'concat:rhinolessc'
    ]);

    // Create the browser version of less.js
    grunt.registerTask('browsertest-lessjs', [
        'browserify:browser',
	    'uglify:test',
        'concat:browsertest'
    ]);

    // Run all browser tests
    grunt.registerTask('browsertest', [
        'browsertest-lessjs',
        'connect',
        'jasmine'
    ]);

    // setup a web server to run the browser tests in a browser rather than phantom
    grunt.registerTask('browsertest-server', [
        'browsertest-lessjs',
        'jasmine::build',
        'connect::keepalive'
    ]);

	var previous_force_state = grunt.option("force");

	grunt.registerTask("force",function(set){
		if (set === "on") {
			grunt.option("force",true);
		}
		else if (set === "off") {
			grunt.option("force",false);
		}
		else if (set === "restore") {
			grunt.option("force",previous_force_state);
		}
	});

    grunt.registerTask('sauce', [
        'browsertest-lessjs',
        'jasmine::build',
        'connect',
        'sauce-after-setup'
    ]);

    // setup a web server to run the browser tests in a browser rather than phantom
    grunt.registerTask('sauce-after-setup', [
        'saucelabs-jasmine',
        'clean:sauce_log'
    ]);

    var testTasks = [
        'clean',
        'jshint',
        'shell:test',
        'browsertest'
    ];

    if (isNaN(Number(process.env.TRAVIS_PULL_REQUEST, 10)) &&
        Number(process.env.TRAVIS_NODE_VERSION) === 0.11 &&
        (process.env.TRAVIS_BRANCH === "master" || process.env.TRAVIS_BRANCH === "sauce")) {
        testTasks.push("force:on");
        testTasks.push("sauce-after-setup");
        testTasks.push("force:off");
    }

    // Run all tests
    grunt.registerTask('test', testTasks);

    // generate a good test environment for testing sourcemaps
    grunt.registerTask('sourcemap-test', [
        'clean:sourcemap-test',
        'shell:sourcemap-test',
        'connect::keepalive'
    ]);

    // Run benchmark
    grunt.registerTask('benchmark', [
        'shell:benchmark'
    ]);

};
<commit_msg>Clean less-bom<commit_after>'use strict';
var fs = require('fs');

module.exports = function (grunt) {

    // Report the elapsed execution time of tasks.
    require('time-grunt')(grunt);

	var COMPRESS_FOR_TESTS = true;

    // Project configuration.
    grunt.initConfig({

        // Metadata required for build.
        build: grunt.file.readYAML('build/build.yml'),
        pkg: grunt.file.readJSON('package.json'),
        meta: {
            license: '<%= _.pluck(pkg.licenses, "type").join(", ") %>',
            copyright: 'Copyright (c) 2009-<%= grunt.template.today("yyyy") %>',
            banner: '/*!\n' +
                ' * Less - <%= pkg.description %> v<%= pkg.version %>\n' +
                ' * http://lesscss.org\n' +
                ' *\n' +
                ' * <%= meta.copyright %>, <%= pkg.author.name %> <<%= pkg.author.email %>>\n' +
                ' * Licensed under the <%= meta.license %> License.\n' +
                ' *\n' +
                ' */\n\n' +
                ' /**' +
                ' * @license <%= meta.license %>\n' +
                ' */\n\n'
        },

        shell: {
            options: {stdout: true, failOnError: true},
            test: {
                command: 'node test'
            },
            benchmark: {
                command: 'node benchmark/less-benchmark.js'
            },
            "sourcemap-test": {
                command: [
                    'node bin/lessc --source-map=test/sourcemaps/maps/import-map.map test/less/import.less test/sourcemaps/import.css',
                    'node bin/lessc --source-map test/less/sourcemaps/basic.less test/sourcemaps/basic.css'
                ].join('&&')
            }
        },

        browserify: {
            browser: {
                src: ['./lib/less-browser/bootstrap.js'],
                options: {
                    exclude: ["promise"],
                    require: ["promise/polyfill.js"],
                    browserifyOptions: {
                        standalone: 'less'
                    }
                },
                dest: 'tmp/less.js'
            }
        },
        concat: {
            options: {
                stripBanners: 'all',
                banner: '<%= meta.banner %>'
            },
            browsertest: {
                src: COMPRESS_FOR_TESTS ? '<%= uglify.test.dest %>' : '<%= browserify.browser.dest %>',
                dest: 'test/browser/less.js'
            },
            dist: {
                src: '<%= browserify.browser.dest %>',
                dest: 'dist/less.js'
            },
            // Rhino
            rhino: {
                options: {
                    banner: '/* Less.js v<%= pkg.version %> RHINO | <%= meta.copyright %>, <%= pkg.author.name %> <<%= pkg.author.email %>> */\n\n',
                    footer: '' // override task-level footer
                },
                src: ['<%= build.rhino %>'],
                dest: 'dist/less-rhino.js'
            },
            // lessc for Rhino
            rhinolessc: {
                options: {
                    banner: '/* Less.js v<%= pkg.version %> RHINO | <%= meta.copyright %>, <%= pkg.author.name %> <<%= pkg.author.email %>> */\n\n',
                    footer: '' // override task-level footer
                },
                src: ['<%= build.rhinolessc %>'],
                dest: 'dist/lessc-rhino.js'
            }
        },

        uglify: {
            options: {
                banner: '<%= meta.banner %>',
                mangle: true,
	            compress: {
	                pure_getters: true
	            }
            },
            dist: {
                src: ['<%= concat.dist.dest %>'],
                dest: 'dist/less.min.js'
            },
	        test: {
		        src: '<%= browserify.browser.dest %>',
		        dest: 'tmp/less.min.js'
	        }
        },

        jshint: {
            options: {jshintrc: '.jshintrc'},
            files: {
                src: [
                    'Gruntfile.js',
                    'lib/less/**/*.js',
                    'lib/less-node/**/*.js',
                    'lib/less-browser/**/*.js',
                    'lib/less-rhino/**/*.js',
                    'bin/lessc'
                ]
            }
        },

        connect: {
            server: {
                options: {
                    port: 8081
                }
            }
        },

        jasmine: {
            options: {
                keepRunner: true,
                host: 'http://localhost:8081/',
                vendor: ['test/browser/jasmine-jsreporter.js', 'test/browser/common.js', 'test/browser/less.js'],
                template: 'test/browser/test-runner-template.tmpl'
            },
            main: {
                // src is used to build list of less files to compile
                src: ['test/less/*.less', '!test/less/javascript.less', '!test/less/urls.less', '!test/less/empty.less'],
                options: {
                    helpers: 'test/browser/runner-main-options.js',
                    specs: 'test/browser/runner-main-spec.js',
                    outfile: 'tmp/browser/test-runner-main.html'
                }
            },
            legacy: {
                src: ['test/less/legacy/*.less'],
                options: {
                    helpers: 'test/browser/runner-legacy-options.js',
                    specs: 'test/browser/runner-legacy-spec.js',
                    outfile: 'tmp/browser/test-runner-legacy.html'
                }
            },
            strictUnits: {
                src: ['test/less/strict-units/*.less'],
                options: {
                    helpers: 'test/browser/runner-strict-units-options.js',
                    specs: 'test/browser/runner-strict-units-spec.js',
                    outfile: 'tmp/browser/test-runner-strict-units.html'
                }
            },
            errors: {
                src: ['test/less/errors/*.less', '!test/less/errors/javascript-error.less'],
                options: {
                    timeout: 20000,
                    helpers: 'test/browser/runner-errors-options.js',
                    specs: 'test/browser/runner-errors-spec.js',
                    outfile: 'tmp/browser/test-runner-errors.html'
                }
            },
            noJsErrors: {
                src: ['test/less/no-js-errors/*.less'],
                options: {
                    helpers: 'test/browser/runner-no-js-errors-options.js',
                    specs: 'test/browser/runner-no-js-errors-spec.js',
                    outfile: 'tmp/browser/test-runner-no-js-errors.html'
                }
            },
            browser: {
                src: ['test/browser/less/*.less'],
                options: {
                    helpers: 'test/browser/runner-browser-options.js',
                    specs: 'test/browser/runner-browser-spec.js',
                    outfile: 'tmp/browser/test-runner-browser.html'
                }
            },
            relativeUrls: {
                src: ['test/browser/less/relative-urls/*.less'],
                options: {
                    helpers: 'test/browser/runner-relative-urls-options.js',
                    specs: 'test/browser/runner-relative-urls-spec.js',
                    outfile: 'tmp/browser/test-runner-relative-urls.html'
                }
            },
            rootpath: {
                src: ['test/browser/less/rootpath/*.less'],
                options: {
                    helpers: 'test/browser/runner-rootpath-options.js',
                    specs: 'test/browser/runner-rootpath-spec.js',
                    outfile: 'tmp/browser/test-runner-rootpath.html'
                }
            },
            rootpathRelative: {
                src: ['test/browser/less/rootpath-relative/*.less'],
                options: {
                    helpers: 'test/browser/runner-rootpath-relative-options.js',
                    specs: 'test/browser/runner-rootpath-relative-spec.js',
                    outfile: 'tmp/browser/test-runner-rootpath-relative.html'
                }
            },
            production: {
                src: ['test/browser/less/production/*.less'],
                options: {
                    helpers: 'test/browser/runner-production-options.js',
                    specs: 'test/browser/runner-production-spec.js',
                    outfile: 'tmp/browser/test-runner-production.html'
                }
            },
            modifyVars: {
                src: ['test/browser/less/modify-vars/*.less'],
                options: {
                    helpers: 'test/browser/runner-modify-vars-options.js',
                    specs: 'test/browser/runner-modify-vars-spec.js',
                    outfile: 'tmp/browser/test-runner-modify-vars.html'
                }
            },
            globalVars: {
                src: ['test/browser/less/global-vars/*.less'],
                options: {
                    helpers: 'test/browser/runner-global-vars-options.js',
                    specs: 'test/browser/runner-global-vars-spec.js',
                    outfile: 'tmp/browser/test-runner-global-vars.html'
                }
            },
            postProcessor: {
                src: ['test/browser/less/postProcessor/*.less'],
                options: {
                    helpers: 'test/browser/runner-postProcessor-options.js',
                    specs: 'test/browser/runner-postProcessor.js',
                    outfile: 'tmp/browser/test-runner-post-processor.html'
                }
            }
        },

        'saucelabs-jasmine': {
            all: {
                options: {
                    urls: ["post-processor", "global-vars", "modify-vars", "production", "rootpath-relative",
                           "rootpath", "relative-urls", "browser", "no-js-errors", "legacy", "strict-units"
                    ].map(function(testName) {
                        return "http://localhost:8081/tmp/browser/test-runner-" + testName + ".html";
                    }),
                    testname: 'Sauce Unit Test for less.js',
                    browsers: [{
                        browserName: "chrome",
                        version: '',
                        platform: 'Windows 8'
                    },
                    {
                        browserName: "firefox",
                        version: '33',
                        platform: 'Linux'
                    },
                    {
                        browserName: "iPad",
                        version: '8.0',
                        platform: 'OS X 10.9',
                        'device-orientation': 'portrait'
                    },
                    {
                        browserName: "internet explorer",
                        version: '8',
                        platform: 'Windows XP'
                    },
                    {
                        browserName: "internet explorer",
                        version: '9',
                        platform: 'Windows 7'
                    },
                    {
                        browserName: "internet explorer",
                        version: '10',
                        platform: 'Windows 7'
                    },
                    {
                        browserName: "internet explorer",
                        version: '11',
                        platform: 'Windows 8.1'
                    }],
                    sauceConfig: {
                        'record-video': process.env.TRAVIS_BRANCH !== "master",
                        'record-screenshots': process.env.TRAVIS_BRANCH !== "master",
                        'idle-timeout': 100, 'max-duration': 120,
                        build: process.env.TRAVIS_BRANCH === "master" ? process.env.TRAVIS_JOB_ID : undefined,
                        tags: [process.env.TRAVIS_BUILD_NUMBER, process.env.TRAVIS_PULL_REQUEST, process.env.TRAVIS_BRANCH]
                    },
                    throttled: 3
                }
            }
        },

        // Clean the version of less built for the tests
        clean: {
            test: ['test/browser/less.js', 'tmp', 'test/less-bom'],
            "sourcemap-test": ['test/sourcemaps/*.css', 'test/sourcemaps/*.map'],
            sauce_log: ["sc_*.log"]
        }
    });

    // Load these plugins to provide the necessary tasks
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

    // Actually load this plugin's task(s).
    grunt.loadTasks('build/tasks');

    // by default, run tests
    grunt.registerTask('default', [
        'test'
    ]);

    grunt.registerTask('updateBowerJson', function () {
        var bowerJson = require('./bower.json');
        bowerJson.version = grunt.config('pkg.version');
        fs.writeFileSync('./bower.json', JSON.stringify(bowerJson, null, 2));
    });

    // Release
    grunt.registerTask('dist', [
        'browserify:browser',
        'concat:dist',
        'uglify:dist',
        'updateBowerJson'
    ]);

    // Release Rhino Version
    grunt.registerTask('rhino', [
        'browserify:rhino',
        'concat:rhino',
        'concat:rhinolessc'
    ]);

    // Create the browser version of less.js
    grunt.registerTask('browsertest-lessjs', [
        'browserify:browser',
	    'uglify:test',
        'concat:browsertest'
    ]);

    // Run all browser tests
    grunt.registerTask('browsertest', [
        'browsertest-lessjs',
        'connect',
        'jasmine'
    ]);

    // setup a web server to run the browser tests in a browser rather than phantom
    grunt.registerTask('browsertest-server', [
        'browsertest-lessjs',
        'jasmine::build',
        'connect::keepalive'
    ]);

	var previous_force_state = grunt.option("force");

	grunt.registerTask("force",function(set){
		if (set === "on") {
			grunt.option("force",true);
		}
		else if (set === "off") {
			grunt.option("force",false);
		}
		else if (set === "restore") {
			grunt.option("force",previous_force_state);
		}
	});

    grunt.registerTask('sauce', [
        'browsertest-lessjs',
        'jasmine::build',
        'connect',
        'sauce-after-setup'
    ]);

    // setup a web server to run the browser tests in a browser rather than phantom
    grunt.registerTask('sauce-after-setup', [
        'saucelabs-jasmine',
        'clean:sauce_log'
    ]);

    var testTasks = [
        'clean',
        'jshint',
        'shell:test',
        'browsertest'
    ];

    if (isNaN(Number(process.env.TRAVIS_PULL_REQUEST, 10)) &&
        Number(process.env.TRAVIS_NODE_VERSION) === 0.11 &&
        (process.env.TRAVIS_BRANCH === "master" || process.env.TRAVIS_BRANCH === "sauce")) {
        testTasks.push("force:on");
        testTasks.push("sauce-after-setup");
        testTasks.push("force:off");
    }

    // Run all tests
    grunt.registerTask('test', testTasks);

    // generate a good test environment for testing sourcemaps
    grunt.registerTask('sourcemap-test', [
        'clean:sourcemap-test',
        'shell:sourcemap-test',
        'connect::keepalive'
    ]);

    // Run benchmark
    grunt.registerTask('benchmark', [
        'shell:benchmark'
    ]);

};
<|endoftext|>


<commit_before>'use strict';

module.exports = function (grunt) {
    // show elapsed time at the end
    require('time-grunt')(grunt);
    // load all grunt tasks
    require('load-grunt-tasks')(grunt);

    grunt.initConfig({
        // configurable paths
        directories: {
            app: 'app',
            dist: 'dist'
        },
        watch: {
            styles: {
                files: ['<%= directories.app %>/styles/{,*/}*.css'],
                tasks: ['copy:styles', 'autoprefixer']
            },
            livereload: {
                options: {
                    livereload: '<%= connect.options.livereload %>'
                },
                files: [
                    '<%= directories.app %>/*.html',
                    '.tmp/styles/{,*/}*.css',
                    '{.tmp,<%= directories.app %>}/scripts/{,*/}*.js',
                    '<%= directories.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                ]
            }
        },
        connect: {
            options: {
                port: 9000,
                livereload: 35729,
                // change this to '0.0.0.0' to access the server from outside
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    open: true,
                    base: [
                        '.tmp',
                        '<%= directories.app %>'
                    ]
                }
            },
            dist: {
                options: {
                    open: true,
                    base: '<%= directories.dist %>'
                }
            }
        },
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '.tmp',
                        '<%= directories.dist %>/*',
                        '!<%= directories.dist %>/.git*'
                    ]
                }]
            },
            server: '.tmp'
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc'
            },
            all: [
                'Gruntfile.js',
                '<%= directories.app %>/scripts/{,*/}*.js',
                '!<%= directories.app %>/scripts/vendor/*',
            ]
        },
        autoprefixer: {
            options: {
                browsers: ['last 1 version']
            },
            dist: {
                files: [{
                    expand: true,
                    cwd: '.tmp/styles/',
                    src: '{,*/}*.css',
                    dest: '.tmp/styles/'
                }]
            }
        },
        concat: {
            requirejs: {
                src: ['.tmp/require.min.js', '.tmp/requirejs/ht.js'],
                dest: '<%= directories.dist %>/scripts/ht.js'
            },
            style: {
                src: ['.tmp/styles/{,*/}*.css'],
                dest: '<%= directories.dist %>/styles/main.css'
            }
        },
        'bower-install': {
            app: {
                html: '<%= directories.app %>/index.html',
                ignorePath: '<%= directories.app %>/'
            }
        },
        uglify: {
            config: {
                files: {
                    '.tmp/require.min.js': ['<%= directories.app %>/bower_components/requirejs/require.js', '.tmp/require-config.js']
                }
            }
        },
        requirejs: {
            dist: {
                // Options: https://github.com/jrburke/r.js/blob/master/build/example.build.js
                options: {
                    baseUrl: '<%= directories.app %>/scripts',
                    dir: '.tmp/requirejs',
                    mainConfigFile: '<%= directories.app %>/scripts/requirejs-config.js',
                    modules: [
                        {
                            name: 'ZipLoader'
                        },
                        {
                            name: 'ht',
                            exclude: ['ZipLoader'],
                            insertRequire: ['ht']
                        }
                    ],
                    optimize: 'uglify2',
                    generateSourceMaps: false,
                    preserveLicenseComments: false,
                    removeCombined: true,
                    useStrict: true,
                    skipDirOptimize: true,
                    wrap: false
                }
            }
        },
        rev: {
            zip: {
                files: {
                    src: [
                        '<%= directories.dist %>/scripts/ZipLoader.js',
                    ]
                }
            },
            dist: {
                files: {
                    src: [
                        '<%= directories.dist %>/scripts/{,*/}*.js',
                        '!<%= directories.dist %>/scripts/*.ZipLoader.js',
                        '<%= directories.dist %>/styles/{,*/}*.css',
                        '<%= directories.dist %>/styles/fonts/{,*/}*.*'
                    ]
                }
            }
        },
        preprocess: {
            dist: {
                options: {
                    inline: true,
                    context: {
                        DEMO: false
                    }
                },
                src: '<%= directories.dist %>/index.html'
            },
            demo: {
                options: {
                    inline: true,
                    context: {
                        DEMO: true
                    }
                },
                src: '<%= directories.dist %>/index.html'
            }
        },
        useminPrepare: {
            options: {
                dest: '<%= directories.dist %>'
            },
            html: '<%= directories.app %>/index.html'
        },
        usemin: {
            options: {
                dirs: ['<%= directories.dist %>']
            },
            html: ['<%= directories.dist %>/{,*/}*.html'],
            css: ['<%= directories.dist %>/styles/{,*/}*.css']
        },
        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= directories.app %>/images',
                    src: '{,*/}*.{png,jpg,jpeg}',
                    dest: '<%= directories.dist %>/images'
                }]
            }
        },
        htmlmin: {
            dist: {
                options: {
                    /*removeCommentsFromCDATA: true,
                    // https://github.com/yeoman/grunt-usemin/issues/44
                    //collapseWhitespace: true,
                    collapseBooleanAttributes: true,
                    removeAttributeQuotes: true,
                    removeRedundantAttributes: true,
                    useShortDoctype: true,
                    removeEmptyAttributes: true,
                    removeOptionalTags: true*/
                },
                files: [{
                    expand: true,
                    cwd: '<%= directories.app %>',
                    src: '*.html',
                    dest: '<%= directories.dist %>'
                }]
            }
        },
        // Put files not handled in other tasks here
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= directories.app %>',
                    dest: '<%= directories.dist %>',
                    src: [
                        '*.{ico,png,txt}',
                        '.htaccess',
                        'images/{,*/}*.{webp,gif}',
                        'styles/fonts/{,*/}*.*',
                    ]
                }]
            },
            styles: {
                expand: true,
                dot: true,
                cwd: '<%= directories.app %>/styles',
                dest: '.tmp/styles/',
                src: '{,*/}*.css'
            },
            zip: {
                src: '.tmp/requirejs/ZipLoader.js',
                dest: '<%= directories.dist %>/scripts/ZipLoader.js'
            }
        },
        modernizr: {
            devFile: '<%= directories.app %>/bower_components/modernizr/modernizr.js',
            outputFile: '<%= directories.dist %>/scripts/vendor/modernizr.js',
            files: [
                '<%= directories.app %>/scripts/{,*/}*.js',
                '<%= directories.dist %>/styles/{,*/}*.css',
                '!<%= directories.app %>/scripts/vendor/*'
            ],
            uglify: true
        },
        concurrent: {
            server: [
                'copy:styles'
            ],
            dist: [
                'copy:styles',
                'imagemin',
                'htmlmin'
            ]
        },
    });

    grunt.registerTask('server', function (target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'connect:dist:keepalive']);
        } else if (target === 'demo') {
            return grunt.task.run(['demo', 'connect:dist:keepalive']);
        }

        grunt.task.run([
            'clean:server',
            'concurrent:server',
            'autoprefixer',
            'connect:livereload',
            'watch'
        ]);
    });

    grunt.registerTask('writeconfig', function () {
        var path = grunt.file.expand({cwd: grunt.config.get('directories.dist'), filter: 'isFile'}, 'scripts/*.ZipLoader.js')[0].replace(/\.[^\.]*$/, '');
        grunt.file.write('.tmp/require-config.js', 'require.config({paths:{\'ZipLoader\':\'' + path + '\'}});');
    });

    grunt.registerTask('writescripttag', function () {
        var path = grunt.file.expand({cwd: grunt.config.get('directories.dist') + '/scripts', filter: 'isFile'}, '*.ht.js')[0];
        grunt.file.write('.tmp/scripttag.html', '<script src="scripts/' + path + '"></script>');
    });

    grunt.registerTask('build', [
        'clean:dist',
        'requirejs',
        'copy:zip',
        'rev:zip',
        'writeconfig',
        'uglify:config',
        'concat:requirejs',
        'useminPrepare',
        'concurrent:dist',
        'autoprefixer',
        'concat:style',
        'modernizr',
        'cssmin',
        'copy:dist',
        'rev:dist',
        'writescripttag',
        'usemin',
        'preprocess:dist'
    ]);

    grunt.registerTask('demo', [
        'clean:dist',
        'requirejs',
        'copy:zip',
        'rev:zip',
        'writeconfig',
        'uglify:config',
        'concat:requirejs',
        'useminPrepare',
        'concurrent:dist',
        'autoprefixer',
        'concat:style',
        'modernizr',
        'cssmin',
        'copy:dist',
        'rev:dist',
        'writescripttag',
        'usemin',
        'preprocess:demo'
    ]);

    grunt.registerTask('default', [
        'jshint',
        'build'
    ]);
};
<commit_msg>fix ie7 font support<commit_after>'use strict';

module.exports = function (grunt) {
    // show elapsed time at the end
    require('time-grunt')(grunt);
    // load all grunt tasks
    require('load-grunt-tasks')(grunt);

    grunt.initConfig({
        // configurable paths
        directories: {
            app: 'app',
            dist: 'dist'
        },
        watch: {
            styles: {
                files: ['<%= directories.app %>/styles/{,*/}*.css'],
                tasks: ['copy:styles', 'autoprefixer']
            },
            livereload: {
                options: {
                    livereload: '<%= connect.options.livereload %>'
                },
                files: [
                    '<%= directories.app %>/*.html',
                    '.tmp/styles/{,*/}*.css',
                    '{.tmp,<%= directories.app %>}/scripts/{,*/}*.js',
                    '<%= directories.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                ]
            }
        },
        connect: {
            options: {
                port: 9000,
                livereload: 35729,
                // change this to '0.0.0.0' to access the server from outside
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    open: true,
                    base: [
                        '.tmp',
                        '<%= directories.app %>'
                    ]
                }
            },
            dist: {
                options: {
                    open: true,
                    base: '<%= directories.dist %>'
                }
            }
        },
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '.tmp',
                        '<%= directories.dist %>/*',
                        '!<%= directories.dist %>/.git*'
                    ]
                }]
            },
            server: '.tmp'
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc'
            },
            all: [
                'Gruntfile.js',
                '<%= directories.app %>/scripts/{,*/}*.js',
                '!<%= directories.app %>/scripts/vendor/*',
            ]
        },
        autoprefixer: {
            options: {
                browsers: ['last 1 version']
            },
            dist: {
                files: [{
                    expand: true,
                    cwd: '.tmp/styles/',
                    src: '{,*/}*.css',
                    dest: '.tmp/styles/'
                }]
            }
        },
        concat: {
            requirejs: {
                src: ['.tmp/require.min.js', '.tmp/requirejs/ht.js'],
                dest: '<%= directories.dist %>/scripts/ht.js'
            },
            style: {
                src: ['.tmp/styles/{,*/}*.css'],
                dest: '<%= directories.dist %>/styles/main.css'
            }
        },
        'bower-install': {
            app: {
                html: '<%= directories.app %>/index.html',
                ignorePath: '<%= directories.app %>/'
            }
        },
        uglify: {
            config: {
                files: {
                    '.tmp/require.min.js': ['<%= directories.app %>/bower_components/requirejs/require.js', '.tmp/require-config.js']
                }
            }
        },
        requirejs: {
            dist: {
                // Options: https://github.com/jrburke/r.js/blob/master/build/example.build.js
                options: {
                    baseUrl: '<%= directories.app %>/scripts',
                    dir: '.tmp/requirejs',
                    mainConfigFile: '<%= directories.app %>/scripts/requirejs-config.js',
                    modules: [
                        {
                            name: 'ZipLoader'
                        },
                        {
                            name: 'ht',
                            exclude: ['ZipLoader'],
                            insertRequire: ['ht']
                        }
                    ],
                    optimize: 'uglify2',
                    generateSourceMaps: false,
                    preserveLicenseComments: false,
                    removeCombined: true,
                    useStrict: true,
                    skipDirOptimize: true,
                    wrap: false
                }
            }
        },
        rev: {
            zip: {
                files: {
                    src: [
                        '<%= directories.dist %>/scripts/ZipLoader.js',
                    ]
                }
            },
            dist: {
                files: {
                    src: [
                        '<%= directories.dist %>/scripts/{,*/}*.js',
                        '!<%= directories.dist %>/scripts/*.ZipLoader.js',
                        '<%= directories.dist %>/styles/{,*/}*.css',
                        '<%= directories.dist %>/styles/fonts/{,*/}*.*'
                    ]
                }
            }
        },
        preprocess: {
            dist: {
                options: {
                    inline: true,
                    context: {
                        DEMO: false
                    }
                },
                src: '<%= directories.dist %>/index.html'
            },
            demo: {
                options: {
                    inline: true,
                    context: {
                        DEMO: true
                    }
                },
                src: '<%= directories.dist %>/index.html'
            }
        },
        useminPrepare: {
            options: {
                dest: '<%= directories.dist %>'
            },
            html: '<%= directories.app %>/index.html'
        },
        usemin: {
            options: {
                dirs: ['<%= directories.dist %>']
            },
            html: ['<%= directories.dist %>/{,*/}*.html'],
            css: ['<%= directories.dist %>/styles/{,*/}*.css']
        },
        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= directories.app %>/images',
                    src: '{,*/}*.{png,jpg,jpeg}',
                    dest: '<%= directories.dist %>/images'
                }]
            }
        },
        htmlmin: {
            dist: {
                options: {
                    /*removeCommentsFromCDATA: true,
                    // https://github.com/yeoman/grunt-usemin/issues/44
                    //collapseWhitespace: true,
                    collapseBooleanAttributes: true,
                    removeAttributeQuotes: true,
                    removeRedundantAttributes: true,
                    useShortDoctype: true,
                    removeEmptyAttributes: true,
                    removeOptionalTags: true*/
                },
                files: [{
                    expand: true,
                    cwd: '<%= directories.app %>',
                    src: '*.html',
                    dest: '<%= directories.dist %>'
                }]
            }
        },
        // Put files not handled in other tasks here
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= directories.app %>',
                    dest: '<%= directories.dist %>',
                    src: [
                        '*.{ico,png,txt}',
                        '.htaccess',
                        'images/{,*/}*.{webp,gif}',
                        'styles/fonts/{,*/}*',
                        'styles/ht-glyph-ie7.css',
                        '!styles/fonts/*.json'
                    ]
                }]
            },
            styles: {
                expand: true,
                dot: true,
                cwd: '<%= directories.app %>/styles',
                dest: '.tmp/styles/',
                src: '{,*/}*.css'
            },
            zip: {
                src: '.tmp/requirejs/ZipLoader.js',
                dest: '<%= directories.dist %>/scripts/ZipLoader.js'
            }
        },
        modernizr: {
            devFile: '<%= directories.app %>/bower_components/modernizr/modernizr.js',
            outputFile: '<%= directories.dist %>/scripts/vendor/modernizr.js',
            files: [
                '<%= directories.app %>/scripts/{,*/}*.js',
                '<%= directories.dist %>/styles/{,*/}*.css',
                '!<%= directories.app %>/scripts/vendor/*'
            ],
            uglify: true
        },
        concurrent: {
            server: [
                'copy:styles'
            ],
            dist: [
                'copy:styles',
                'imagemin',
                'htmlmin'
            ]
        },
        cssmin: {
            '<%= directories.dist %>/styles/ht-glyph-ie7.css': '<%= directories.dist %>/styles/ht-glyph-ie7.css'
        }
    });

    grunt.registerTask('server', function (target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'connect:dist:keepalive']);
        } else if (target === 'demo') {
            return grunt.task.run(['demo', 'connect:dist:keepalive']);
        }

        grunt.task.run([
            'clean:server',
            'concurrent:server',
            'autoprefixer',
            'connect:livereload',
            'watch'
        ]);
    });

    grunt.registerTask('writeconfig', function () {
        var path = grunt.file.expand({cwd: grunt.config.get('directories.dist'), filter: 'isFile'}, 'scripts/*.ZipLoader.js')[0].replace(/\.[^\.]*$/, '');
        grunt.file.write('.tmp/require-config.js', 'require.config({paths:{\'ZipLoader\':\'' + path + '\'}});');
    });

    grunt.registerTask('writescripttag', function () {
        var path = grunt.file.expand({cwd: grunt.config.get('directories.dist') + '/scripts', filter: 'isFile'}, '*.ht.js')[0];
        grunt.file.write('.tmp/scripttag.html', '<script src="scripts/' + path + '"></script>');
    });

    grunt.registerTask('build', [
        'clean:dist',
        'requirejs',
        'copy:zip',
        'rev:zip',
        'writeconfig',
        'uglify:config',
        'concat:requirejs',
        'useminPrepare',
        'concurrent:dist',
        'autoprefixer',
        'concat:style',
        'modernizr',
        'copy:dist',
        'cssmin',
        'rev:dist',
        'writescripttag',
        'usemin',
        'preprocess:dist'
    ]);

    grunt.registerTask('demo', [
        'clean:dist',
        'requirejs',
        'copy:zip',
        'rev:zip',
        'writeconfig',
        'uglify:config',
        'concat:requirejs',
        'useminPrepare',
        'concurrent:dist',
        'autoprefixer',
        'concat:style',
        'modernizr',
        'copy:dist',
        'cssmin',
        'rev:dist',
        'writescripttag',
        'usemin',
        'preprocess:demo'
    ]);

    grunt.registerTask('default', [
        'jshint',
        'build'
    ]);
};
<|endoftext|>


<commit_before>/**
 * Created by nuintun on 2015/5/5.
 */

'use strict';

var path = require('path');
var gulp = require('gulp');
var rimraf = require('del');
var transport = require('gulp-cmd');
var uglify = require('gulp-uglify');
var css = require('gulp-minify-css');
var plumber = require('gulp-plumber');
var colors = transport.colors;

// alias
var alias = {
  'jquery': 'base/jquery/1.11.2/jquery',
  'base': 'base/base/1.2.0/base',
  'class': 'base/class/1.2.0/class',
  'events': 'base/events/1.2.0/events',
  'widget': 'base/widget/1.2.0/widget',
  'template': 'base/template/3.0.3/template',
  'templatable': 'base/templatable/0.10.0/templatable',
  'iframe-shim': 'util/iframe-shim/1.1.0/iframe-shim',
  'position': 'util/position/1.1.0/position',
  'messenger': 'util/messenger/2.1.0/messenger',
  'mask': 'common/overlay/1.2.0/mask',
  'overlay': 'common/overlay/1.2.0/overlay',
  'dialog': 'common/dialog/1.5.1/dialog',
  'confirmbox': 'common/dialog/1.5.1/confirmbox'
};

var startTime = Date.now();

// complete callback
function complete(){
  var now = new Date();

  console.log(
    '  %s [%s] build complete ... %s %s',
    colors.verbose('gulp-cmd'),
    now.toLocaleString(),
    colors.input(now - startTime),
    colors.info('ms')
  );
}

// clean task
gulp.task('clean', function (callback){
  rimraf('online', callback);
});

// runtime task
gulp.task('runtime', ['clean'], function (){
  gulp.src('assets/loader/**/*.js', { base: 'assets' })
    .pipe(uglify())
    .pipe(gulp.dest('online'));

  gulp.src('assets/?(loader|images)/**/*.!(js)', { base: 'assets' })
    .pipe(gulp.dest('online'));
});

// online task
gulp.task('online', ['runtime'], function (){
  // all js
  gulp.src('assets/js/**/*.js', { base: 'assets/js' })
    .pipe(transport({
      alias: alias,
      ignore: ['jquery'],
      include: function (id){
        return id.indexOf('view') === 0 ? 'all' : 'relative';
      },
      oncsspath: function (path){
        return path.replace('assets/', 'online/')
      }
    }))
    .pipe(uglify())
    .pipe(gulp.dest('online/js'))
    .on('end', complete);

  // other file
  gulp.src('assets/js/**/*.!(js|css|json|tpl|html)')
    .pipe(gulp.dest('online/js'));

  // css
  gulp.src('assets/css/**/*.*')
    .pipe(css({ compatibility: 'ie8' }))
    .pipe(gulp.dest('online/css'));
});

// develop task
gulp.task('default', ['runtime'], function (){
  // all file
  gulp.src('assets/js/**/*.*', { base: 'assets/js' })
    .pipe(transport({
      alias: alias,
      include: 'self',
      oncsspath: function (path){
        return path.replace('assets/', 'online/')
      }
    }))
    .pipe(gulp.dest('online/js'))
    .on('end', complete);

  gulp.src('assets/css/**/*.*', { base: 'assets' })
    .pipe(gulp.dest('online'));
});

// develop watch task
gulp.task('watch', ['default'], function (){
  var base = path.join(process.cwd(), 'assets');

  // watch all file
  gulp.watch('assets/js/**/*.*', function (e){
    if (e.type === 'deleted') {
      rimraf(path.resolve('online', path.relative(base, e.path)));
    } else {
      startTime = Date.now();

      gulp.src(e.path, { base: 'assets/js' })
        .pipe(plumber())
        .pipe(transport({
          alias: alias,
          include: 'self',
          cache: false,
          oncsspath: function (path){
            return path.replace('assets/', 'online/')
          }
        }))
        .pipe(gulp.dest('online/js'))
        .on('end', complete);
    }
  });

  // watch all file
  gulp.watch('assets/?(images|loader|css)/**/*.*', function (e){
    if (e.type === 'deleted') {
      rimraf(path.resolve('online', path.relative(base, e.path)));
    } else {
      startTime = Date.now();

      gulp.src(e.path, { base: 'assets' })
        .pipe(plumber())
        .pipe(gulp.dest('online'))
        .on('end', complete);
    }
  });
});
<commit_msg>add source<commit_after>/**
 * Created by nuintun on 2015/5/5.
 */

'use strict';

var path = require('path');
var gulp = require('gulp');
var rimraf = require('del');
var transport = require('gulp-cmd');
var uglify = require('gulp-uglify');
var css = require('gulp-minify-css');
var plumber = require('gulp-plumber');
var colors = transport.colors;

// alias
var alias = {
  'jquery': 'base/jquery/1.11.2/jquery',
  'base': 'base/base/1.2.0/base',
  'class': 'base/class/1.2.0/class',
  'events': 'base/events/1.2.0/events',
  'widget': 'base/widget/1.2.0/widget',
  'template': 'base/template/3.0.3/template',
  'templatable': 'base/templatable/0.10.0/templatable',
  'iframe-shim': 'util/iframe-shim/1.1.0/iframe-shim',
  'position': 'util/position/1.1.0/position',
  'messenger': 'util/messenger/2.1.0/messenger',
  'mask': 'common/overlay/1.2.0/mask',
  'overlay': 'common/overlay/1.2.0/overlay',
  'dialog': 'common/dialog/1.5.1/dialog',
  'confirmbox': 'common/dialog/1.5.1/confirmbox'
};

var startTime = Date.now();

// complete callback
function complete(){
  var now = new Date();

  console.log(
    '  %s [%s] build complete ... +%s%s',
    colors.verbose('gulp-cmd'),
    now.toLocaleString(),
    colors.info(now - startTime),
    colors.verbose('ms')
  );
}

// clean task
gulp.task('clean', function (callback){
  rimraf('online', callback);
});

// runtime task
gulp.task('runtime', ['clean'], function (){
  gulp.src('assets/loader/**/*.js', { base: 'assets' })
    .pipe(uglify())
    .pipe(gulp.dest('online'));

  gulp.src('assets/?(loader|images)/**/*.!(js)', { base: 'assets' })
    .pipe(gulp.dest('online'));
});

// online task
gulp.task('online', ['runtime'], function (){
  // all js
  gulp.src('assets/js/**/*.js', { base: 'assets/js' })
    .pipe(transport({
      alias: alias,
      ignore: ['jquery'],
      include: function (id){
        return id.indexOf('view') === 0 ? 'all' : 'relative';
      },
      oncsspath: function (path){
        return path.replace('assets/', 'online/')
      }
    }))
    .pipe(uglify())
    .pipe(gulp.dest('online/js'))
    .on('end', complete);

  // other file
  gulp.src('assets/js/**/*.!(js|css|json|tpl|html)')
    .pipe(gulp.dest('online/js'));

  // css
  gulp.src('assets/css/**/*.*')
    .pipe(css({ compatibility: 'ie8' }))
    .pipe(gulp.dest('online/css'));
});

// develop task
gulp.task('default', ['runtime'], function (){
  // all file
  gulp.src('assets/js/**/*.*', { base: 'assets/js' })
    .pipe(transport({
      alias: alias,
      include: 'self',
      oncsspath: function (path){
        return path.replace('assets/', 'online/')
      }
    }))
    .pipe(gulp.dest('online/js'))
    .on('end', complete);

  gulp.src('assets/css/**/*.*', { base: 'assets' })
    .pipe(gulp.dest('online'));
});

// develop watch task
gulp.task('watch', ['default'], function (){
  var base = path.join(process.cwd(), 'assets');

  // watch all file
  gulp.watch('assets/js/**/*.*', function (e){
    if (e.type === 'deleted') {
      rimraf(path.resolve('online', path.relative(base, e.path)));
    } else {
      startTime = Date.now();

      gulp.src(e.path, { base: 'assets/js' })
        .pipe(plumber())
        .pipe(transport({
          alias: alias,
          include: 'self',
          cache: false,
          oncsspath: function (path){
            return path.replace('assets/', 'online/')
          }
        }))
        .pipe(gulp.dest('online/js'))
        .on('end', complete);
    }
  });

  // watch all file
  gulp.watch('assets/?(images|loader|css)/**/*.*', function (e){
    if (e.type === 'deleted') {
      rimraf(path.resolve('online', path.relative(base, e.path)));
    } else {
      startTime = Date.now();

      gulp.src(e.path, { base: 'assets' })
        .pipe(plumber())
        .pipe(gulp.dest('online'))
        .on('end', complete);
    }
  });
});
<|endoftext|>


<commit_before>
//Dependencies
var request = require('request');

var Persona = (function () {

	//configurational options
	var options = {
		method : 'GET',
		personaVerifierLink : 'https://verifier.login.persona.org/verify'
	};

	var setIdentity = function (configuration, callback) {
		options.email = configuration.email;
		verifyIdentity(function (resp) {
			callback(resp);
		});
	};

	var verifyIdentity = function (callback) {
		if (typeof options !== undefined && typeof options !== 'null') {
			request(options, function (err, res) {
				callback(resp);
			});
		}
	};

	return {
		set : setIdentity
	}

})();<commit_msg>Changed the url propert<commit_after>
//Dependencies
var request = require('request');

var Persona = (function () {

	//configurational options
	var options = {
		method : 'GET',
		url : 'https://verifier.login.persona.org/verify'
	};

	function setIdentity (configuration, callback) {
		options.email = configuration.email;
		verifyIdentity(function (resp) {
			callback(resp);
		});
	};

	function verifyIdentity (callback) {
		if (typeof options !== undefined && typeof options !== 'null') {
			request(options, function (err, res) {
				callback(resp);
			});
		}
	};

	return {
		set : setIdentity
	}

})();<|endoftext|>


<commit_before>'use strict'

/* polyfills */
import '../polyfills'

import express from 'express'
import config from '../config'
import routes from './routes'
import path from 'path'
import bodyParser from 'body-parser'
import api from './api'

const app = express()

const port = config.PORT
app.listen(port, function() {
    console.log('Our app is running on http://localhost:' + port);
});

/* webpack development */
if (config.ENV !== 'production') {
  require('../webpack/dev.config').webpackDevConfig(app)
}

// Static files
app.use(express.static(path.join(__dirname, '../static'), {
  maxAge: 86400000
}))

// Logging
app.use(require('morgan')('dev'))

// Use Jade
app.set('views', path.join(__dirname, '../client/views'))
app.set('view engine', 'jade')

// Set up route
app.use('/', routes)

// Set up api
app.use('/api', api)

/* POST parsing */
app.use(bodyParser.urlencoded({ extended: true }))
app.use(bodyParser.json())

// Handle errors
app.use((req, res, next) => {
  var err = new Error('Not Found');
  err.status = 404;
  next(err);
});

app.use((err, req, res, next) => {
  res.status(err.status || 500);
  res.render('error', {
    message: err.message,
    error: {}
  });
});

// Export App
module.exports = app
<commit_msg>Updated server index<commit_after>'use strict'

/* polyfills */
import '../polyfills'

import express from 'express'
import config from '../config'
import routes from './routes'
import path from 'path'
import bodyParser from 'body-parser'
import api from './api'

const app = express()

/* webpack development */
if (config.ENV !== 'production') {
  require('../webpack/dev.config').webpackDevConfig(app)
}

// Static files
app.use(express.static(path.join(__dirname, '../static'), {
  maxAge: 86400000
}))

// Logging
app.use(require('morgan')('dev'))

// Use Jade
app.set('views', path.join(__dirname, '../client/views'))
app.set('view engine', 'jade')

// Set up route
app.use('/', routes)

// Set up api
app.use('/api', api)

/* POST parsing */
app.use(bodyParser.urlencoded({ extended: true }))
app.use(bodyParser.json())

// Handle errors
app.use((req, res, next) => {
  var err = new Error('Not Found');
  err.status = 404;
  next(err);
});

app.use((err, req, res, next) => {
  res.status(err.status || 500);
  res.render('error', {
    message: err.message,
    error: {}
  });
});

// Export App
module.exports = app
<|endoftext|>


<commit_before>// TODO: Comments needed in this file.

// Add your team to this list when you've put an icon in /logos!
var icons = [
	1418,
	1982,
	2403,
    	2848,
    	5113,
	5115,
	 236,
	4150,
	5482,
	5859
];

var map;

function initMap() {
	map = new google.maps.Map(document.getElementById('map'), {
		center: {
			lat: 30,
			lng: 0
		},
		zoom: 2,
		disableDefaultUI: true,
		zoomControl: true,
		mapTypeControl: false,
		streetViewControl: false,
		rotateControl: false,
		fullscreenControl: true,
		styles: [{
			featureType: 'water',
			elementType: 'geometry',
			stylers: [{
				color: '#193341'
			}]
		}, {
			featureType: 'landscape',
			elementType: 'geometry',
			stylers: [{
				color: '#2c5a71'
			}]
		}, {
			featureType: 'road',
			elementType: 'geometry',
			stylers: [{
				color: '#29768a'
			}, {
				lightness: -37
			}]
		}, {
			featureType: 'poi',
			elementType: 'geometry',
			stylers: [{
				color: '#406d80'
			}]
		}, {
			featureType: 'transit',
			elementType: 'geometry',
			stylers: [{
				color: '#406d80'
			}]
		}, {
			elementType: 'labels.text.stroke',
			stylers: [{
				visibility: 'on'
			}, {
				color: '#3e606f'
			}, {
				weight: 2
			}, {
				gamma: 0.84
			}]
		}, {
			elementType: 'labels.text.fill',
			stylers: [{
				color: '#ffffff'
			}]
		}, {
			featureType: 'administrative',
			elementType: 'geometry',
			stylers: [{
				weight: 0.6
			}, {
				color: '#1a3541'
			}]
		}, {
			elementType: 'labels.icon',
			stylers: [{
				visibility: 'off'
			}]
		}, {
			featureType: 'poi.park',
			elementType: 'geometry',
			stylers: [{
				color: '#2c5a71'
			}]
		}]
	});
	for (i = 0; i < teams.length; i++) {
		createMarker(coordinates[i], teams[i]);
	}
}

function createMarker(pos, t) {
	if (pos) {
		pos = {
			lat: pos.lat + ((Math.random() / 100) * ((Math.random() >= 0.5) ? -1 : 1)),
			lng: pos.lng + ((Math.random() / 100) * ((Math.random() >= 0.5) ? -1 : 1))
		};
		var marker = new google.maps.Marker({
			position: pos,
			map: map,
			title: t + '',
			icon: (icons.indexOf(t) != -1) ? 'logos/' + t + '.png' : 'marker.png'
		});
		google.maps.event.addListener(marker, 'click', function() {
			openInfo(t, marker);
		});
		return marker;
	}
}

function openInfo(num, marker) {
	var req = new XMLHttpRequest();
	req.open('GET', 'https://www.thebluealliance.com/api/v2/team/frc' + num + '?X-TBA-App-Id=erikboesen:frcmap:v1.0');
	req.send();
	req.onreadystatechange = function() {
		if (req.readyState === 4 && req.status === 200) {
			var team = JSON.parse(req.responseText);
			var content = '
';
			content += team.website ? '' : '';
			content += 'Team ' + team.team_number;
			content += team.nickname ? ' - ' + team.nickname : '';
			content += team.website ? '
' : '
';
			content += team.motto ? '
"' + team.motto + '"
' : '';
			content += '
';
			content += '
Location: ' + team.location + '
';
			content += team.rookie_year ? '
Rookie year: ' + team.rookie_year + '
' : '';
			content += '
View on The Blue Alliance
';
			content += '
';
			try {
				var oldInfoWindow = document.getElementsByClassName('gm-style-iw')[0];
				oldInfoWindow.parentNode.parentNode.removeChild(oldInfoWindow.parentNode);
			} catch (e) {}
			var infoWindow = new google.maps.InfoWindow({
				content: content
			});
			infoWindow.open(map, marker);
		}
	};
}
<commit_msg>Added 2412 to scripts.js<commit_after>// TODO: Comments needed in this file.

// Add your team to this list when you've put an icon in /logos!
var icons = [
	1418,
	1982,
	2403,
	2412,
    	2848,
    	5113,
	5115,
	 236,
	4150,
	5482,
	5859
];

var map;

function initMap() {
	map = new google.maps.Map(document.getElementById('map'), {
		center: {
			lat: 30,
			lng: 0
		},
		zoom: 2,
		disableDefaultUI: true,
		zoomControl: true,
		mapTypeControl: false,
		streetViewControl: false,
		rotateControl: false,
		fullscreenControl: true,
		styles: [{
			featureType: 'water',
			elementType: 'geometry',
			stylers: [{
				color: '#193341'
			}]
		}, {
			featureType: 'landscape',
			elementType: 'geometry',
			stylers: [{
				color: '#2c5a71'
			}]
		}, {
			featureType: 'road',
			elementType: 'geometry',
			stylers: [{
				color: '#29768a'
			}, {
				lightness: -37
			}]
		}, {
			featureType: 'poi',
			elementType: 'geometry',
			stylers: [{
				color: '#406d80'
			}]
		}, {
			featureType: 'transit',
			elementType: 'geometry',
			stylers: [{
				color: '#406d80'
			}]
		}, {
			elementType: 'labels.text.stroke',
			stylers: [{
				visibility: 'on'
			}, {
				color: '#3e606f'
			}, {
				weight: 2
			}, {
				gamma: 0.84
			}]
		}, {
			elementType: 'labels.text.fill',
			stylers: [{
				color: '#ffffff'
			}]
		}, {
			featureType: 'administrative',
			elementType: 'geometry',
			stylers: [{
				weight: 0.6
			}, {
				color: '#1a3541'
			}]
		}, {
			elementType: 'labels.icon',
			stylers: [{
				visibility: 'off'
			}]
		}, {
			featureType: 'poi.park',
			elementType: 'geometry',
			stylers: [{
				color: '#2c5a71'
			}]
		}]
	});
	for (i = 0; i < teams.length; i++) {
		createMarker(coordinates[i], teams[i]);
	}
}

function createMarker(pos, t) {
	if (pos) {
		pos = {
			lat: pos.lat + ((Math.random() / 100) * ((Math.random() >= 0.5) ? -1 : 1)),
			lng: pos.lng + ((Math.random() / 100) * ((Math.random() >= 0.5) ? -1 : 1))
		};
		var marker = new google.maps.Marker({
			position: pos,
			map: map,
			title: t + '',
			icon: (icons.indexOf(t) != -1) ? 'logos/' + t + '.png' : 'marker.png'
		});
		google.maps.event.addListener(marker, 'click', function() {
			openInfo(t, marker);
		});
		return marker;
	}
}

function openInfo(num, marker) {
	var req = new XMLHttpRequest();
	req.open('GET', 'https://www.thebluealliance.com/api/v2/team/frc' + num + '?X-TBA-App-Id=erikboesen:frcmap:v1.0');
	req.send();
	req.onreadystatechange = function() {
		if (req.readyState === 4 && req.status === 200) {
			var team = JSON.parse(req.responseText);
			var content = '
';
			content += team.website ? '' : '';
			content += 'Team ' + team.team_number;
			content += team.nickname ? ' - ' + team.nickname : '';
			content += team.website ? '
' : '
';
			content += team.motto ? '
"' + team.motto + '"
' : '';
			content += '
';
			content += '
Location: ' + team.location + '
';
			content += team.rookie_year ? '
Rookie year: ' + team.rookie_year + '
' : '';
			content += '
View on The Blue Alliance
';
			content += '
';
			try {
				var oldInfoWindow = document.getElementsByClassName('gm-style-iw')[0];
				oldInfoWindow.parentNode.parentNode.removeChild(oldInfoWindow.parentNode);
			} catch (e) {}
			var infoWindow = new google.maps.InfoWindow({
				content: content
			});
			infoWindow.open(map, marker);
		}
	};
}
<|endoftext|>


<commit_before>/*
 * Copyright (C) 2019 - present Instructure, Inc.
 *
 * This file is part of Canvas.
 *
 * Canvas is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License as published by the Free
 * Software Foundation, version 3 of the License.
 *
 * Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License along
 * with this program. If not, see <http://www.gnu.org/licenses/>.
 */

// code in this file is stuff that needs to run on every page but that should
// not block anything else from loading. It will be loaded by webpack as an
// async chunk so it will always be loaded eventually, but not necessarily before
// any other js_bundle code runs. and by moving it into an async chunk,
// the critical code to display a page will be executed sooner

import _ from 'underscore'
import $ from 'jquery'
import updateSubnavMenuToggle from './subnav_menu/updateSubnavMenuToggle'
import preventDefault from 'compiled/fn/preventDefault'

// modules that do their own thing on every page that simply need to be required
import 'media_comments'
import 'reminders'
import 'instructure'
import 'page_views'
import 'compiled/behaviors/authenticity_token'
import 'compiled/behaviors/ujsLinks'
import 'compiled/behaviors/admin-links'
import 'compiled/behaviors/elementToggler'
import 'compiled/behaviors/ic-super-toggle'
import 'compiled/behaviors/instructure_inline_media_comment'
import 'compiled/behaviors/ping'
import 'compiled/behaviors/broken-images'
import 'LtiThumbnailLauncher'

// preventDefault so we dont change the hash
// this will make nested apps that use the hash happy
$('#skip_navigation_link').on(
  'click',
  preventDefault(() => {
    $($(this).attr('href'))
      .attr('tabindex', -1)
      .focus()
  })
)

// show and hide the courses vertical menu when the user clicks the hamburger button
// This was in the courses bundle, but it sometimes needs to work in places that don't
// load that bundle.
const WIDE_BREAKPOINT = 1200

function resetMenuItemTabIndexes() {
  // in testing this, it seems that $(document).width() returns 15px less than what it should.
  const tabIndex =
    $('body').hasClass('course-menu-expanded') || $(document).width() >= WIDE_BREAKPOINT - 15
      ? 0
      : -1
  $('#section-tabs li a').attr('tabIndex', tabIndex)
}

$(resetMenuItemTabIndexes)
$(window).on('resize', _.debounce(resetMenuItemTabIndexes, 50))
$('body').on('click', '#courseMenuToggle', () => {
  $('body').toggleClass('course-menu-expanded')
  updateSubnavMenuToggle()
  $('#left-side').css({
    display: $('body').hasClass('course-menu-expanded') ? 'block' : 'none'
  })

  resetMenuItemTabIndexes()
})
<commit_msg>fix "Skip to Content" link<commit_after>/*
 * Copyright (C) 2019 - present Instructure, Inc.
 *
 * This file is part of Canvas.
 *
 * Canvas is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License as published by the Free
 * Software Foundation, version 3 of the License.
 *
 * Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License along
 * with this program. If not, see <http://www.gnu.org/licenses/>.
 */

// code in this file is stuff that needs to run on every page but that should
// not block anything else from loading. It will be loaded by webpack as an
// async chunk so it will always be loaded eventually, but not necessarily before
// any other js_bundle code runs. and by moving it into an async chunk,
// the critical code to display a page will be executed sooner

import _ from 'underscore'
import $ from 'jquery'
import updateSubnavMenuToggle from './subnav_menu/updateSubnavMenuToggle'
import preventDefault from 'compiled/fn/preventDefault'

// modules that do their own thing on every page that simply need to be required
import 'media_comments'
import 'reminders'
import 'instructure'
import 'page_views'
import 'compiled/behaviors/authenticity_token'
import 'compiled/behaviors/ujsLinks'
import 'compiled/behaviors/admin-links'
import 'compiled/behaviors/elementToggler'
import 'compiled/behaviors/ic-super-toggle'
import 'compiled/behaviors/instructure_inline_media_comment'
import 'compiled/behaviors/ping'
import 'compiled/behaviors/broken-images'
import 'LtiThumbnailLauncher'

// preventDefault so we dont change the hash
// this will make nested apps that use the hash happy
$('#skip_navigation_link').on(
  'click',
  preventDefault(function () {
    $($(this).attr('href'))
      .attr('tabindex', -1)
      .focus()
  })
)

// show and hide the courses vertical menu when the user clicks the hamburger button
// This was in the courses bundle, but it sometimes needs to work in places that don't
// load that bundle.
const WIDE_BREAKPOINT = 1200

function resetMenuItemTabIndexes() {
  // in testing this, it seems that $(document).width() returns 15px less than what it should.
  const tabIndex =
    $('body').hasClass('course-menu-expanded') || $(document).width() >= WIDE_BREAKPOINT - 15
      ? 0
      : -1
  $('#section-tabs li a').attr('tabIndex', tabIndex)
}

$(resetMenuItemTabIndexes)
$(window).on('resize', _.debounce(resetMenuItemTabIndexes, 50))
$('body').on('click', '#courseMenuToggle', () => {
  $('body').toggleClass('course-menu-expanded')
  updateSubnavMenuToggle()
  $('#left-side').css({
    display: $('body').hasClass('course-menu-expanded') ? 'block' : 'none'
  })

  resetMenuItemTabIndexes()
})
<|endoftext|>