<commit_before>Package.describe({
  name: 'dispatch:kernel',
  version: '0.0.2',
  summary: 'Run tasks in animation frame directly and throttled',
  git: 'https://github.com/DispatchMe/meteor-kernel.git'
});

Package.onUse(function (api) {
  api.export('Kernel');

  api.versionsFrom('1.0');

  api.use([
    'tracker',
    'blaze',
    'meteor',
    'dispatch:request-animation-frame@0.0.1',
    'underscore',
  ], 'web');

  api.addFiles([
    'kernel.js',
    'meteor.js'
  ], 'web');
});
<commit_msg>Bump to version 0.0.3<commit_after>Package.describe({
  name: 'dispatch:kernel',
  version: '0.0.3',
  summary: 'Run tasks in animation frame directly and throttled',
  git: 'https://github.com/DispatchMe/meteor-kernel.git'
});

Package.onUse(function (api) {
  api.export('Kernel');

  api.versionsFrom('1.0');

  api.use([
    'tracker',
    'blaze',
    'meteor',
    'dispatch:request-animation-frame@0.0.1',
    'underscore',
  ], 'web');

  api.addFiles([
    'kernel.js',
    'meteor.js'
  ], 'web');
});
<|endoftext|>


<commit_before>import React, {PropTypes} from 'react'
import Page from 'components/Page'
import {Grid, Row, Col} from 'react-bootstrap'

import TopBar from 'components/TopBar'
import Nav from 'components/Nav'
import NoPositionBanner from 'components/NoPositionBanner'
import History from 'components/History'
import dict from 'dictionary'

import API from 'api'
import {Person, Organization} from 'models'

import dictionary from 'resources/dictionary.json'

const GENERAL_BANNER_TEXT = 'GENERAL_BANNER_TEXT'

export default class App extends Page {
	static PagePropTypes = {
		useNavigation: PropTypes.bool,
		fluidContainer: PropTypes.bool,
	}

	static propTypes = {
		children: PropTypes.element.isRequired,
	}

	static childContextTypes = {
		app: PropTypes.object,
		currentUser: PropTypes.instanceOf(Person),
//		dictionary: PropTypes.object,
	}

	getChildContext() {
		return {
			app: this,
			currentUser: this.state.currentUser,
//			dictionary: this.state.dictionary,
		}
	}

	constructor(props) {
		super(props)

		this.state = {
			currentUser: new Person(),
			settings: {},
			organizations: [],
//			dictionary: {}
		}

		this.state = this.processData(window.ANET_DATA)
	}

	componentWillReceiveProps() {
		// this is just to prevent App from refetching app settings on every
		// single page load. in the future we may wish to do something more
		// intelligent to refetch page settings
	}

	fetchData() {
		API.query(/* GraphQL */`
			person(f:me) {
				id, name, role, emailAddress, rank, status
				position {
					id, name, type, isApprover
					organization { id, shortName , allDescendantOrgs { id }}
				}
			}

			adminSettings(f:getAll) {
				key, value
			}

			organizationList(f:getTopLevelOrgs, type: ADVISOR_ORG) {
				list { id, shortName }
			}
		`).then(data => {
			data.person._loaded = true
			this.setState(this.processData(data), () => {
				// if this is a new user, redirect to the create profile page
				if (this.state.currentUser.isNewUser()) {
					History.replace('/onboarding')
				}
			})
		})

		//Fetch the dictionary.
		// @vassil dictionary.json temporarily moved to resouces. Difficulties to load from /dictionary.json when deployed as the files is moved under PUBLIC_URL
//		API.fetch('/dictonary.json').then(dictionary =>
			dict.setDictionary(dictionary)
//		)
	}

	processData(data) {
		let currentUser = new Person(data.person)
		let organizations = (data.organizationList && data.organizationList.list) || []
		organizations = Organization.fromArray(organizations)
		organizations.sort((a, b) => a.shortName.localeCompare(b.shortName))

		let settings = this.state.settings
		data.adminSettings.forEach(setting => settings[setting.key] = setting.value)
		let dictionary = this.state.dictionary

		return {currentUser, settings, organizations, dictionary}
	}

	render() {
		let pageProps = this.props.children.type.pageProps || {}
		let currentUser = this.state.currentUser

		let bannerOptions = {
			message: this.state.settings[GENERAL_BANNER_TEXT],
			statusColor: 'alert-info'
		} || {}

		return (

				<TopBar
					banner={bannerOptions}
					minimalHeader={pageProps.minimalHeader}
					location={this.props.location} />

				{currentUser && currentUser.position && currentUser.position.id === 0 && !currentUser.isNewUser() && <NoPositionBanner />}

				<Grid componentClass="section" bsClass={pageProps.fluidContainer ? 'container-fluid' : 'container'}>
					{pageProps.useNavigation === false
						? <Row><Col xs={12}>{this.props.children}</Col></Row>
						: <Row>
							<Col sm={3} className="hide-for-print">

							</Col>
							<Col sm={9} className="primary-content">
								{this.props.children}
							</Col>
						</Row>
					}
				</Grid>

		)
	}
}
<commit_msg>Remove NoPositionBanner component from app.js<commit_after>import React, {PropTypes} from 'react'
import Page from 'components/Page'
import {Grid, Row, Col} from 'react-bootstrap'

import TopBar from 'components/TopBar'
import Nav from 'components/Nav'
import History from 'components/History'
import dict from 'dictionary'

import API from 'api'
import {Person, Organization} from 'models'

import dictionary from 'resources/dictionary.json'

const GENERAL_BANNER_TEXT = 'GENERAL_BANNER_TEXT'

export default class App extends Page {
	static PagePropTypes = {
		useNavigation: PropTypes.bool,
		fluidContainer: PropTypes.bool,
	}

	static propTypes = {
		children: PropTypes.element.isRequired,
	}

	static childContextTypes = {
		app: PropTypes.object,
		currentUser: PropTypes.instanceOf(Person),
//		dictionary: PropTypes.object,
	}

	getChildContext() {
		return {
			app: this,
			currentUser: this.state.currentUser,
//			dictionary: this.state.dictionary,
		}
	}

	constructor(props) {
		super(props)

		this.state = {
			currentUser: new Person(),
			settings: {},
			organizations: [],
//			dictionary: {}
		}

		this.state = this.processData(window.ANET_DATA)
	}

	componentWillReceiveProps() {
		// this is just to prevent App from refetching app settings on every
		// single page load. in the future we may wish to do something more
		// intelligent to refetch page settings
	}

	fetchData() {
		API.query(/* GraphQL */`
			person(f:me) {
				id, name, role, emailAddress, rank, status
				position {
					id, name, type, isApprover
					organization { id, shortName , allDescendantOrgs { id }}
				}
			}

			adminSettings(f:getAll) {
				key, value
			}

			organizationList(f:getTopLevelOrgs, type: ADVISOR_ORG) {
				list { id, shortName }
			}
		`).then(data => {
			data.person._loaded = true
			this.setState(this.processData(data), () => {
				// if this is a new user, redirect to the create profile page
				if (this.state.currentUser.isNewUser()) {
					History.replace('/onboarding')
				}
			})
		})

		//Fetch the dictionary.
		// @vassil dictionary.json temporarily moved to resouces. Difficulties to load from /dictionary.json when deployed as the files is moved under PUBLIC_URL
//		API.fetch('/dictonary.json').then(dictionary =>
			dict.setDictionary(dictionary)
//		)
	}

	processData(data) {
		let currentUser = new Person(data.person)
		let organizations = (data.organizationList && data.organizationList.list) || []
		organizations = Organization.fromArray(organizations)
		organizations.sort((a, b) => a.shortName.localeCompare(b.shortName))

		let settings = this.state.settings
		data.adminSettings.forEach(setting => settings[setting.key] = setting.value)
		let dictionary = this.state.dictionary

		return {currentUser, settings, organizations, dictionary}
	}

	render() {
		let pageProps = this.props.children.type.pageProps || {}

		let bannerOptions = {
			message: this.state.settings[GENERAL_BANNER_TEXT],
			statusColor: 'alert-info'
		} || {}

		return (

				<TopBar
					banner={bannerOptions}
					minimalHeader={pageProps.minimalHeader}
					location={this.props.location} />

				<Grid componentClass="section" bsClass={pageProps.fluidContainer ? 'container-fluid' : 'container'}>
					{pageProps.useNavigation === false
						? <Row><Col xs={12}>{this.props.children}</Col></Row>
						: <Row>
							<Col sm={3} className="hide-for-print">

							</Col>
							<Col sm={9} className="primary-content">
								{this.props.children}
							</Col>
						</Row>
					}
				</Grid>

		)
	}
}
<|endoftext|>


<commit_before>var irc = require('irc');
var util = require('util');
var os = require('os');

var randomstring = require('randomstring');
var portscanner = require('portscanner');
var wget = require('wget-improved');

var netUtils = require('./lib/net-utils');
var formatUtils = require('./lib/format-utils');
var config = require('./config');

var listenMode = false
var nickName = config.nickname || 'nbot_' + randomstring.generate(4);

var bot = new irc.Client('irc.freenode.net', nickName, {
  debug: true,
  channels: config.channels
});

bot.addListener('error', function(message) {
  console.error('[x] ERROR: %s: %s', message.command, message.args.join(' '));
});

bot.addListener('message#hsnl.bots', function(from, message) {
  console.log(from + ' => #hsnl.bots: ' + message);

  if (message.match(/^\:set listen$/)) {
    listenMode = true;
    bot.say('#hsnl.bots', '<Bot in listen mode>');
  } else if (message.match(/^\:set nolisten$/)) {
    listenMode = false;
    bot.say('#hsnl.bots', '<Bot quit listen mode>');
  }

  if (message.match(/hello/i) && listenMode) {
    bot.say('#hsnl.bots', 'Hello there ' + from);

  } else if (message.match(/^\!sysinfo$/) && listenMode) {
    var totalMem = os.totalmem() / (2 << 19);
    var freeMem =  os.freemem() / (2 << 19);
    var upTime =  formatUtils.secondsToString(os.uptime());
    var cpuInfo = os.cpus()[0].model + ' x' + os.cpus().length.toString() + ' Cores';
    var osTypeArch = os.type() + ' ' + os.arch();

    var sysInfo = util.format('cpu: %s; ram: %sMB total, %sMB free; os: %s; uptime: %s.',
                              cpuInfo, totalMem, freeMem, osTypeArch, upTime);

    bot.say('#hsnl.bots', sysInfo);

  } else if (message.match(/^\!netinfo$/) && listenMode) {
    var upNetworkInterfaces = Object.keys(os.networkInterfaces()).toString();
    var netInfo = util.format('MAC address: %s; IP address: %s', netUtils.getMAC(), netUtils.getIPv4Internal());

    // bot.say('#hsnl.bots', 'About Network interfaces info.: ' + upNetworkInterfaces);

    bot.say('#hsnl.bots', netInfo);

  } else if (message.match(/^\!scan (.*?) (.*?)$/)) {
    var matched = /^\!scan (.*?) (.*?)$/.exec(message);

    // bot.say('#hsnl.bots', 'scan <IP> <port>');
    // console.log(matched);
    var port = parseInt(matched[2]);
    var ip =  matched[1];

    if (netUtils.isIPv4(ip)) {
      if (port < 65536 && port >= 0) {
        portscanner.checkPortStatus(port, ip, function(error, status) {
          // console.log(status);
          bot.say('#hsnl.bots',  ip + ':' + matched[2] + ' Port status: ' + status);
        });
      } else { bot.say('#hsnl.bots', 'Invalid port number!'); }
    } else { bot.say('#hsnl.bots', 'Invalid IP address!'); }

  } else if (message.match(/^\!download (.*?) (.*?) (.*?)$/)) {
    var matched = /^\!download (.*?) (.*?) (.*?)$/.exec(message);
    console.log(matched);

    var action = parseInt(matched[3]);
    var output =  matched[2] ;
    var url = matched[1];

    var download = wget.download(url, output);

    download.on('error', function(err) {
      console.log(err);
      bot.say('#hsnl.bots', err);
    });

    download.on('end', function(output) {
      console.log(output);
      bot.say('#hsnl.bots', output);
    });
  }

});

function changeMode(msg) {
  if (msg.match(/^\:set listen$/)) {
    bot.say('#hsnl.bots', '<Bot in listen mode>');
    return true;
  } else if (msg.match(/^\:set nolisten$/)) {
    bot.say('#hsnl.bots', '<Bot quit listen mode>');
    return false;
  }

}
<commit_msg>Remove unused function<commit_after>var irc = require('irc');
var util = require('util');
var os = require('os');

var randomstring = require('randomstring');
var portscanner = require('portscanner');
var wget = require('wget-improved');

var netUtils = require('./lib/net-utils');
var formatUtils = require('./lib/format-utils');
var config = require('./config');

var listenMode = false
var nickName = config.nickname || 'nbot_' + randomstring.generate(4);

var bot = new irc.Client('irc.freenode.net', nickName, {
  debug: true,
  channels: config.channels
});

bot.addListener('error', function(message) {
  console.error('[x] ERROR: %s: %s', message.command, message.args.join(' '));
});

bot.addListener('message#hsnl.bots', function(from, message) {
  console.log(from + ' => #hsnl.bots: ' + message);

  if (message.match(/^\:set listen$/)) {
    listenMode = true;
    bot.say('#hsnl.bots', '<Bot in listen mode>');
  } else if (message.match(/^\:set nolisten$/)) {
    listenMode = false;
    bot.say('#hsnl.bots', '<Bot quit listen mode>');
  }

  if (message.match(/hello/i) && listenMode) {
    bot.say('#hsnl.bots', 'Hello there ' + from);

  } else if (message.match(/^\!sysinfo$/) && listenMode) {
    var totalMem = os.totalmem() / (2 << 19);
    var freeMem =  os.freemem() / (2 << 19);
    var upTime =  formatUtils.secondsToString(os.uptime());
    var cpuInfo = os.cpus()[0].model + ' x' + os.cpus().length.toString() + ' Cores';
    var osTypeArch = os.type() + ' ' + os.arch();

    var sysInfo = util.format('cpu: %s; ram: %sMB total, %sMB free; os: %s; uptime: %s.',
                              cpuInfo, totalMem, freeMem, osTypeArch, upTime);

    bot.say('#hsnl.bots', sysInfo);

  } else if (message.match(/^\!netinfo$/) && listenMode) {
    var upNetworkInterfaces = Object.keys(os.networkInterfaces()).toString();
    var netInfo = util.format('MAC address: %s; IP address: %s', netUtils.getMAC(), netUtils.getIPv4Internal());

    // bot.say('#hsnl.bots', 'About Network interfaces info.: ' + upNetworkInterfaces);

    bot.say('#hsnl.bots', netInfo);

  } else if (message.match(/^\!scan (.*?) (.*?)$/)) {
    var matched = /^\!scan (.*?) (.*?)$/.exec(message);

    // bot.say('#hsnl.bots', 'scan <IP> <port>');
    // console.log(matched);
    var port = parseInt(matched[2]);
    var ip =  matched[1];

    if (netUtils.isIPv4(ip)) {
      if (port < 65536 && port >= 0) {
        portscanner.checkPortStatus(port, ip, function(error, status) {
          // console.log(status);
          bot.say('#hsnl.bots',  ip + ':' + matched[2] + ' Port status: ' + status);
        });
      } else { bot.say('#hsnl.bots', 'Invalid port number!'); }
    } else { bot.say('#hsnl.bots', 'Invalid IP address!'); }

  } else if (message.match(/^\!download (.*?) (.*?) (.*?)$/)) {
    var matched = /^\!download (.*?) (.*?) (.*?)$/.exec(message);
    console.log(matched);

    var action = parseInt(matched[3]);
    var output =  matched[2] ;
    var url = matched[1];

    var download = wget.download(url, output);

    download.on('error', function(err) {
      console.log(err);
      bot.say('#hsnl.bots', err);
    });

    download.on('end', function(output) {
      console.log(output);
      bot.say('#hsnl.bots', output);
    });
  }

});
<|endoftext|>


<commit_before>import Signal from "signals";
import { mat3, mat2x3 } from "pex-math";

let MaterialID = 0;

const tempMat2x3 = mat2x3.create();

const MATERIAL_MAPS = [
  "baseColorMap",
  "emissiveColorMap",
  "matallicMap",
  "roughnessMap",
  "metallicRoughnessMap",
  "normalMap",
  "clearCoatNormalMap",
  "occlusionMap",
  "diffuseMap",
  "specularGlossinessMap",
  "sheenColorMap",
  "clearCoatMap",
  "clearCoatRoughnessMap",
];

const PIPELINE_PROPS = [
  "depthTest",
  "depthWrite",
  "depthFunc",
  "blend",
  "blendSrcRGBFactor",
  "blendSrcAlphaFactor",
  "blendDstRGBFactor",
  "blendDstAlphaFactor",
  "cullFace",
  "cullFaceMode",
];

class Material {
  constructor(opts) {
    this.type = "Material";
    this.id = `Material_${MaterialID++}`;
    this.enabled = true;
    this.changed = new Signal();

    this._uniforms = {};

    const ctx = opts.ctx;

    this.baseColor = [1, 1, 1, 1];
    this.baseColorMap = null;

    this.useSpecularGlossinessWorkflow =
      opts.useSpecularGlossinessWorkflow || false;
    this.unlit = opts.unlit || false;
    if (opts.useSpecularGlossinessWorkflow) {
      // Specular Glossiness workflow
      this.diffuse = [1, 1, 1, 1];
      this.diffuseMap = null;
      this.specular = [1, 1, 1];
      this.glossiness = 1;
      this.specularGlossinessMap = null;
    } else if (!this.unlit) {
      // Metallic Roughness workflow
      this.metallic = 1;
      this.matallicMap = null;
      this.roughness = 1;
      this.roughnessMap = null;
      this.metallicRoughnessMap = null;
    }

    this.normalMap = null;
    this.normalScale = 1;

    this.displacementMap = null;
    this.displacement = 0;

    this.emissiveColor = null;
    this.emissiveIntensity = 1;
    this.emissiveColorMap = null;

    this.occlusionMap = null;

    this.reflectance = 0.5;
    this.clearCoat = null;
    this.clearCoatMap = null;
    this.clearCoatRoughness = null;
    this.clearCoatRoughnessMap = null;
    this.clearCoatNormalMap = null;
    this.clearCoatNormalMapScale = 1; //TODO: what's clearCoatNormalMapScale

    this.sheenColor = null;
    this.sheenColorMap = null;
    this.sheenRoughness = null;

    this.alphaMap = null;
    this.alphaTest = undefined;

    // pipeline props
    this.depthTest = true;
    this.depthWrite = true;
    this.depthFunc = ctx.DepthFunc.LessEqual;
    this.blend = false;
    this.blendSrcRGBFactor = ctx.BlendFactor.One;
    this.blendSrcAlphaFactor = ctx.BlendFactor.One;
    this.blendDstRGBFactor = ctx.BlendFactor.One;
    this.blendDstAlphaFactor = ctx.BlendFactor.One;
    this.cullFace = true;
    this.cullFaceMode = ctx.Face.Back;

    this.pointSize = 1;

    this.castShadows = false;
    this.receiveShadows = false;

    this.needsPipelineUpdate = false;

    this.set(opts);
  }

  init(entity) {
    this.entity = entity;
  }

  set(opts) {
    Object.assign(this, opts);

    const optsKeys = Object.keys(opts);

    const mapKeys = optsKeys.filter((opt) => MATERIAL_MAPS.includes(opt));
    if (mapKeys.length) {
      for (let i = 0; i < mapKeys.length; i++) {
        const map = this[mapKeys[i]];
        if (map && map.texture) {
          mat2x3.identity(tempMat2x3);
          mat2x3.translate(tempMat2x3, map.offset || [0, 0]);
          mat2x3.rotate(tempMat2x3, -map.rotation || 0);
          mat2x3.scale(tempMat2x3, map.scale || [1, 1]);

          map.texCoordTransformMatrix = mat3.fromMat2x3(
            map.texCoordTransformMatrix
              ? mat3.identity(map.texCoordTransformMatrix)
              : mat3.create(),
            tempMat2x3
          );
        }
      }
    }

    for (let pipelineProp of PIPELINE_PROPS) {
      if (opts[pipelineProp] !== undefined) {
        this.needsPipelineUpdate = true;
      }
    }

    optsKeys.forEach((prop) => this.changed.dispatch(prop));
  }
}

export default (opts = {}) => {
  //return new Material(opts);
  return {
    baseColor: [1, 1, 1, 1],
    metallic: 1,
    roughness: 1,
    depthTest: true,
    depthWrite: true,
    blend: false,
    ...opts,
  };
};
<commit_msg>feat(components/material): add default material blend and shadow values<commit_after>import Signal from "signals";
import { mat3, mat2x3 } from "pex-math";

let MaterialID = 0;

const tempMat2x3 = mat2x3.create();

const MATERIAL_MAPS = [
  "baseColorMap",
  "emissiveColorMap",
  "matallicMap",
  "roughnessMap",
  "metallicRoughnessMap",
  "normalMap",
  "clearCoatNormalMap",
  "occlusionMap",
  "diffuseMap",
  "specularGlossinessMap",
  "sheenColorMap",
  "clearCoatMap",
  "clearCoatRoughnessMap",
];

const PIPELINE_PROPS = [
  "depthTest",
  "depthWrite",
  "depthFunc",
  "blend",
  "blendSrcRGBFactor",
  "blendSrcAlphaFactor",
  "blendDstRGBFactor",
  "blendDstAlphaFactor",
  "cullFace",
  "cullFaceMode",
];

class Material {
  constructor(opts) {
    this.type = "Material";
    this.id = `Material_${MaterialID++}`;
    this.enabled = true;
    this.changed = new Signal();

    this._uniforms = {};

    const ctx = opts.ctx;

    this.baseColor = [1, 1, 1, 1];
    this.baseColorMap = null;

    this.useSpecularGlossinessWorkflow =
      opts.useSpecularGlossinessWorkflow || false;
    this.unlit = opts.unlit || false;
    if (opts.useSpecularGlossinessWorkflow) {
      // Specular Glossiness workflow
      this.diffuse = [1, 1, 1, 1];
      this.diffuseMap = null;
      this.specular = [1, 1, 1];
      this.glossiness = 1;
      this.specularGlossinessMap = null;
    } else if (!this.unlit) {
      // Metallic Roughness workflow
      this.metallic = 1;
      this.matallicMap = null;
      this.roughness = 1;
      this.roughnessMap = null;
      this.metallicRoughnessMap = null;
    }

    this.normalMap = null;
    this.normalScale = 1;

    this.displacementMap = null;
    this.displacement = 0;

    this.emissiveColor = null;
    this.emissiveIntensity = 1;
    this.emissiveColorMap = null;

    this.occlusionMap = null;

    this.reflectance = 0.5;
    this.clearCoat = null;
    this.clearCoatMap = null;
    this.clearCoatRoughness = null;
    this.clearCoatRoughnessMap = null;
    this.clearCoatNormalMap = null;
    this.clearCoatNormalMapScale = 1; //TODO: what's clearCoatNormalMapScale

    this.sheenColor = null;
    this.sheenColorMap = null;
    this.sheenRoughness = null;

    this.alphaMap = null;
    this.alphaTest = undefined;

    // pipeline props
    this.depthTest = true;
    this.depthWrite = true;
    this.depthFunc = ctx.DepthFunc.LessEqual;
    this.blend = false;
    this.blendSrcRGBFactor = ctx.BlendFactor.One;
    this.blendSrcAlphaFactor = ctx.BlendFactor.One;
    this.blendDstRGBFactor = ctx.BlendFactor.One;
    this.blendDstAlphaFactor = ctx.BlendFactor.One;
    this.cullFace = true;
    this.cullFaceMode = ctx.Face.Back;

    this.pointSize = 1;

    this.castShadows = false;
    this.receiveShadows = false;

    this.needsPipelineUpdate = false;

    this.set(opts);
  }

  init(entity) {
    this.entity = entity;
  }

  set(opts) {
    Object.assign(this, opts);

    const optsKeys = Object.keys(opts);

    const mapKeys = optsKeys.filter((opt) => MATERIAL_MAPS.includes(opt));
    if (mapKeys.length) {
      for (let i = 0; i < mapKeys.length; i++) {
        const map = this[mapKeys[i]];
        if (map && map.texture) {
          mat2x3.identity(tempMat2x3);
          mat2x3.translate(tempMat2x3, map.offset || [0, 0]);
          mat2x3.rotate(tempMat2x3, -map.rotation || 0);
          mat2x3.scale(tempMat2x3, map.scale || [1, 1]);

          map.texCoordTransformMatrix = mat3.fromMat2x3(
            map.texCoordTransformMatrix
              ? mat3.identity(map.texCoordTransformMatrix)
              : mat3.create(),
            tempMat2x3
          );
        }
      }
    }

    for (let pipelineProp of PIPELINE_PROPS) {
      if (opts[pipelineProp] !== undefined) {
        this.needsPipelineUpdate = true;
      }
    }

    optsKeys.forEach((prop) => this.changed.dispatch(prop));
  }
}

export default (opts = {}) => {
  //return new Material(opts);
  return {
    baseColor: [1, 1, 1, 1],
    emissiveColor: undefined,
    metallic: 1,
    roughness: 1,
    depthTest: true,
    depthWrite: true,
    blend: false,
    blendSrcRGBFactor: undefined,
    blendSrcAlphaFactor: undefined,
    blendDstRGBFactor: undefined,
    blendDstAlphaFactor: undefined,
    castShadows: true,
    receiveShadows: true,
    ...opts,
  };
};
<|endoftext|>


<commit_before>Monocle.Formatting = function (reader, optStyles, optScale) {
  var API = { constructor: Monocle.Formatting };
  var k = API.constants = API.constructor;
  var p = API.properties = {
    reader: reader,

    // An array of style rules that are automatically applied to every page.
    stylesheets: [],

    // A multiplier on the default font-size of each element in every
    // component. If null, the multiplier is not applied (or it is removed).
    fontScale: null
  }

  function initialize() {
    p.fontScale = optScale;
    clampStylesheets(optStyles);
    p.reader.listen('monocle:componentmodify', persistOnComponentChange);
  }

  // Clamp page frames to a set of styles that reduce Monocle breakage.
  //
  function clampStylesheets(implStyles) {
    var defCSS = k.DEFAULT_STYLE_RULES;
    if (Monocle.Browser.env.floatsIgnoreColumns) {
      defCSS.push("html#RS\\:monocle * { float: none !important; }");
    }
    p.defaultStyles = addPageStyles(defCSS, false);
    if (implStyles) {
      p.initialStyles = addPageStyles(implStyles, false);
    }
  }

  function persistOnComponentChange(evt) {
    var doc = evt.m['document'];
    doc.documentElement.id = p.reader.properties.systemId;
    adjustFontScaleForDoc(doc, p.fontScale);
    for (var i = 0; i < p.stylesheets.length; ++i) {
      if (p.stylesheets[i]) {
        addPageStylesheet(doc, i);
      }
    }
  }

  /* PAGE STYLESHEETS */

  // API for adding a new stylesheet to all components. styleRules should be
  // a string of CSS rules. restorePlace defaults to true.
  //
  // Returns a sheet index value that can be used with updatePageStyles
  // and removePageStyles.
  //
  function addPageStyles(styleRules, restorePlace) {
    return changingStylesheet(function () {
      p.stylesheets.push(styleRules);
      var sheetIndex = p.stylesheets.length - 1;

      var i = 0, cmpt = null;
      while (cmpt = p.reader.dom.find('component', i++)) {
        addPageStylesheet(cmpt.contentDocument, sheetIndex);
      }
      return sheetIndex;
    }, restorePlace);
  }

  // API for updating the styleRules in an existing page stylesheet across
  // all components. Takes a sheet index value obtained via addPageStyles.
  //
  function updatePageStyles(sheetIndex, styleRules, restorePlace) {
    return changingStylesheet(function () {
      p.stylesheets[sheetIndex] = styleRules;
      if (typeof styleRules.join == "function") {
        styleRules = styleRules.join("\n");
      }

      var i = 0, cmpt = null;
      while (cmpt = p.reader.dom.find('component', i++)) {
        var doc = cmpt.contentDocument;
        var styleTag = doc.getElementById('monStylesheet'+sheetIndex);
        if (!styleTag) {
          console.warn('No such stylesheet: ' + sheetIndex);
          return;
        }
        if (styleTag.styleSheet) {
          styleTag.styleSheet.cssText = styleRules;
        } else {
          styleTag.replaceChild(
            doc.createTextNode(styleRules),
            styleTag.firstChild
          );
        }
      }
    }, restorePlace);
  }

  // API for removing a page stylesheet from all components. Takes a sheet
  // index value obtained via addPageStyles.
  //
  function removePageStyles(sheetIndex, restorePlace) {
    return changingStylesheet(function () {
      p.stylesheets[sheetIndex] = null;
      var i = 0, cmpt = null;
      while (cmpt = p.reader.dom.find('component', i++)) {
        var doc = cmpt.contentDocument;
        var styleTag = doc.getElementById('monStylesheet'+sheetIndex);
        styleTag.parentNode.removeChild(styleTag);
      }
    }, restorePlace);
  }

  // Wraps all API-based stylesheet changes (add, update, remove) in a
  // brace of custom events (stylesheetchanging/stylesheetchange), and
  // recalculates component dimensions if specified (default to true).
  //
  function changingStylesheet(callback, restorePlace) {
    restorePlace = (restorePlace === false) ? false : true;
    if (restorePlace) {
      dispatchChanging();
    }
    var result = callback();
    if (restorePlace) {
      p.reader.recalculateDimensions(true);
      Monocle.defer(dispatchChange);
    } else {
      p.reader.recalculateDimensions(false);
    }
    return result;
  }

  function dispatchChanging() {
    p.reader.dispatchEvent("monocle:stylesheetchanging", {});
  }

  function dispatchChange() {
    p.reader.dispatchEvent("monocle:stylesheetchange", {});
  }

  // Private method for adding a stylesheet to a component. Used by
  // addPageStyles.
  //
  function addPageStylesheet(doc, sheetIndex) {
    var styleRules = p.stylesheets[sheetIndex];

    if (!styleRules) {
      return;
    }

    if (!doc || !doc.documentElement) {
      return;
    }

    var head = doc.getElementsByTagName('head')[0];
    if (!head) {
      head = doc.createElement('head');
      doc.documentElement.appendChild(head);
    }

    if (typeof styleRules.join == "function") {
      styleRules = styleRules.join("\n");
    }

    var styleTag = doc.createElement('style');
    styleTag.type = 'text/css';
    styleTag.id = "monStylesheet"+sheetIndex;
    if (styleTag.styleSheet) {
      styleTag.styleSheet.cssText = styleRules;
    } else {
      styleTag.appendChild(doc.createTextNode(styleRules));
    }

    head.appendChild(styleTag);

    return styleTag;
  }

  /* FONT SCALING */

  function setFontScale(scale, restorePlace) {
    p.fontScale = scale;
    if (restorePlace) {
      dispatchChanging();
    }
    var i = 0, cmpt = null;
    while (cmpt = p.reader.dom.find('component', i++)) {
      adjustFontScaleForDoc(cmpt.contentDocument, scale);
    }
    if (restorePlace) {
      p.reader.recalculateDimensions(true);
      dispatchChange();
    } else {
      p.reader.recalculateDimensions(false);
    }
  }

  function adjustFontScaleForDoc(doc, scale) {
    var elems = doc.getElementsByTagName('*');
    if (scale) {
      scale = parseFloat(scale);
      if (!doc.body.pfsSwept) {
        sweepElements(doc, elems);
      }

      // Iterate over each element, applying scale to the original
      // font-size. If a proportional font sizing is already applied to
      // the element, update existing cssText, otherwise append new cssText.
      //
      for (var j = 0, jj = elems.length; j < jj; ++j) {
        var newFs = fsProperty(elems[j].pfsOriginal, scale);
        if (elems[j].pfsApplied) {
          replaceFontSizeInStyle(elems[j], newFs);
        } else {
          elems[j].style.cssText += newFs;
        }
        elems[j].pfsApplied = scale;
      }
    } else if (doc.body.pfsSwept) {
      // Iterate over each element, removing proportional font-sizing flag
      // and property from cssText.
      for (var j = 0, jj = elems.length; j < jj; ++j) {
        if (elems[j].pfsApplied) {
          var oprop = elems[j].pfsOriginalProp;
          var opropDec = oprop ? 'font-size: '+oprop+' ! important;' : '';
          replaceFontSizeInStyle(elems[j], opropDec);
          elems[j].pfsApplied = null;
        }
      }

      // Establish new baselines in case classes have changed.
      sweepElements(doc, elems);
    }
  }

  function sweepElements(doc, elems) {
    // Iterate over each element, looking at its font size and storing
    // the original value against the element.
    for (var i = 0, ii = elems.length; i < ii; ++i) {
      var currStyle = doc.defaultView.getComputedStyle(elems[i], null);
      var fs = parseFloat(currStyle.getPropertyValue('font-size'));
      elems[i].pfsOriginal = fs;
      elems[i].pfsOriginalProp = elems[i].style.fontSize;
    }
    doc.body.pfsSwept = true;
  }

  function fsProperty(orig, scale) {
    return 'font-size: '+(orig*scale)+'px ! important;';
  }

  function replaceFontSizeInStyle(elem, newProp) {
    var lastFs = /font-size:[^;]/
    elem.style.cssText = elem.style.cssText.replace(lastFs, newProp);
  }

  API.addPageStyles = addPageStyles;
  API.updatePageStyles = updatePageStyles;
  API.removePageStyles = removePageStyles;
  API.setFontScale = setFontScale;

  initialize();

  return API;
}

Monocle.Formatting.DEFAULT_STYLE_RULES = [
  "html#RS\\:monocle * {" +
    "-webkit-font-smoothing: subpixel-antialiased;" +
    "text-rendering: auto !important;" +
    "word-wrap: break-word !important;" +
    "overflow: visible !important;" +
  "}",
  "html#RS\\:monocle body {" +
    "margin: 0 !important;"+
    "border: none !important;" +
    "padding: 0 !important;" +
    "width: 100% !important;" +
    "position: absolute !important;" +
    "-webkit-text-size-adjust: none;" +
  "}",
  "html#RS\\:monocle body * {" +
    "max-width: 100% !important;" +
  "}",
  "html#RS\\:monocle img, html#RS\\:monocle video, html#RS\\:monocle object {" +
    "max-height: 95% !important;" +
    "height: auto !important;" +
  "}"
]
<commit_msg>Adding SVG to elements which max-height = 95%<commit_after>Monocle.Formatting = function (reader, optStyles, optScale) {
  var API = { constructor: Monocle.Formatting };
  var k = API.constants = API.constructor;
  var p = API.properties = {
    reader: reader,

    // An array of style rules that are automatically applied to every page.
    stylesheets: [],

    // A multiplier on the default font-size of each element in every
    // component. If null, the multiplier is not applied (or it is removed).
    fontScale: null
  }

  function initialize() {
    p.fontScale = optScale;
    clampStylesheets(optStyles);
    p.reader.listen('monocle:componentmodify', persistOnComponentChange);
  }

  // Clamp page frames to a set of styles that reduce Monocle breakage.
  //
  function clampStylesheets(implStyles) {
    var defCSS = k.DEFAULT_STYLE_RULES;
    if (Monocle.Browser.env.floatsIgnoreColumns) {
      defCSS.push("html#RS\\:monocle * { float: none !important; }");
    }
    p.defaultStyles = addPageStyles(defCSS, false);
    if (implStyles) {
      p.initialStyles = addPageStyles(implStyles, false);
    }
  }

  function persistOnComponentChange(evt) {
    var doc = evt.m['document'];
    doc.documentElement.id = p.reader.properties.systemId;
    adjustFontScaleForDoc(doc, p.fontScale);
    for (var i = 0; i < p.stylesheets.length; ++i) {
      if (p.stylesheets[i]) {
        addPageStylesheet(doc, i);
      }
    }
  }

  /* PAGE STYLESHEETS */

  // API for adding a new stylesheet to all components. styleRules should be
  // a string of CSS rules. restorePlace defaults to true.
  //
  // Returns a sheet index value that can be used with updatePageStyles
  // and removePageStyles.
  //
  function addPageStyles(styleRules, restorePlace) {
    return changingStylesheet(function () {
      p.stylesheets.push(styleRules);
      var sheetIndex = p.stylesheets.length - 1;

      var i = 0, cmpt = null;
      while (cmpt = p.reader.dom.find('component', i++)) {
        addPageStylesheet(cmpt.contentDocument, sheetIndex);
      }
      return sheetIndex;
    }, restorePlace);
  }

  // API for updating the styleRules in an existing page stylesheet across
  // all components. Takes a sheet index value obtained via addPageStyles.
  //
  function updatePageStyles(sheetIndex, styleRules, restorePlace) {
    return changingStylesheet(function () {
      p.stylesheets[sheetIndex] = styleRules;
      if (typeof styleRules.join == "function") {
        styleRules = styleRules.join("\n");
      }

      var i = 0, cmpt = null;
      while (cmpt = p.reader.dom.find('component', i++)) {
        var doc = cmpt.contentDocument;
        var styleTag = doc.getElementById('monStylesheet'+sheetIndex);
        if (!styleTag) {
          console.warn('No such stylesheet: ' + sheetIndex);
          return;
        }
        if (styleTag.styleSheet) {
          styleTag.styleSheet.cssText = styleRules;
        } else {
          styleTag.replaceChild(
            doc.createTextNode(styleRules),
            styleTag.firstChild
          );
        }
      }
    }, restorePlace);
  }

  // API for removing a page stylesheet from all components. Takes a sheet
  // index value obtained via addPageStyles.
  //
  function removePageStyles(sheetIndex, restorePlace) {
    return changingStylesheet(function () {
      p.stylesheets[sheetIndex] = null;
      var i = 0, cmpt = null;
      while (cmpt = p.reader.dom.find('component', i++)) {
        var doc = cmpt.contentDocument;
        var styleTag = doc.getElementById('monStylesheet'+sheetIndex);
        styleTag.parentNode.removeChild(styleTag);
      }
    }, restorePlace);
  }

  // Wraps all API-based stylesheet changes (add, update, remove) in a
  // brace of custom events (stylesheetchanging/stylesheetchange), and
  // recalculates component dimensions if specified (default to true).
  //
  function changingStylesheet(callback, restorePlace) {
    restorePlace = (restorePlace === false) ? false : true;
    if (restorePlace) {
      dispatchChanging();
    }
    var result = callback();
    if (restorePlace) {
      p.reader.recalculateDimensions(true);
      Monocle.defer(dispatchChange);
    } else {
      p.reader.recalculateDimensions(false);
    }
    return result;
  }

  function dispatchChanging() {
    p.reader.dispatchEvent("monocle:stylesheetchanging", {});
  }

  function dispatchChange() {
    p.reader.dispatchEvent("monocle:stylesheetchange", {});
  }

  // Private method for adding a stylesheet to a component. Used by
  // addPageStyles.
  //
  function addPageStylesheet(doc, sheetIndex) {
    var styleRules = p.stylesheets[sheetIndex];

    if (!styleRules) {
      return;
    }

    if (!doc || !doc.documentElement) {
      return;
    }

    var head = doc.getElementsByTagName('head')[0];
    if (!head) {
      head = doc.createElement('head');
      doc.documentElement.appendChild(head);
    }

    if (typeof styleRules.join == "function") {
      styleRules = styleRules.join("\n");
    }

    var styleTag = doc.createElement('style');
    styleTag.type = 'text/css';
    styleTag.id = "monStylesheet"+sheetIndex;
    if (styleTag.styleSheet) {
      styleTag.styleSheet.cssText = styleRules;
    } else {
      styleTag.appendChild(doc.createTextNode(styleRules));
    }

    head.appendChild(styleTag);

    return styleTag;
  }

  /* FONT SCALING */

  function setFontScale(scale, restorePlace) {
    p.fontScale = scale;
    if (restorePlace) {
      dispatchChanging();
    }
    var i = 0, cmpt = null;
    while (cmpt = p.reader.dom.find('component', i++)) {
      adjustFontScaleForDoc(cmpt.contentDocument, scale);
    }
    if (restorePlace) {
      p.reader.recalculateDimensions(true);
      dispatchChange();
    } else {
      p.reader.recalculateDimensions(false);
    }
  }

  function adjustFontScaleForDoc(doc, scale) {
    var elems = doc.getElementsByTagName('*');
    if (scale) {
      scale = parseFloat(scale);
      if (!doc.body.pfsSwept) {
        sweepElements(doc, elems);
      }

      // Iterate over each element, applying scale to the original
      // font-size. If a proportional font sizing is already applied to
      // the element, update existing cssText, otherwise append new cssText.
      //
      for (var j = 0, jj = elems.length; j < jj; ++j) {
        var newFs = fsProperty(elems[j].pfsOriginal, scale);
        if (elems[j].pfsApplied) {
          replaceFontSizeInStyle(elems[j], newFs);
        } else {
          elems[j].style.cssText += newFs;
        }
        elems[j].pfsApplied = scale;
      }
    } else if (doc.body.pfsSwept) {
      // Iterate over each element, removing proportional font-sizing flag
      // and property from cssText.
      for (var j = 0, jj = elems.length; j < jj; ++j) {
        if (elems[j].pfsApplied) {
          var oprop = elems[j].pfsOriginalProp;
          var opropDec = oprop ? 'font-size: '+oprop+' ! important;' : '';
          replaceFontSizeInStyle(elems[j], opropDec);
          elems[j].pfsApplied = null;
        }
      }

      // Establish new baselines in case classes have changed.
      sweepElements(doc, elems);
    }
  }

  function sweepElements(doc, elems) {
    // Iterate over each element, looking at its font size and storing
    // the original value against the element.
    for (var i = 0, ii = elems.length; i < ii; ++i) {
      var currStyle = doc.defaultView.getComputedStyle(elems[i], null);
      var fs = parseFloat(currStyle.getPropertyValue('font-size'));
      elems[i].pfsOriginal = fs;
      elems[i].pfsOriginalProp = elems[i].style.fontSize;
    }
    doc.body.pfsSwept = true;
  }

  function fsProperty(orig, scale) {
    return 'font-size: '+(orig*scale)+'px ! important;';
  }

  function replaceFontSizeInStyle(elem, newProp) {
    var lastFs = /font-size:[^;]/
    elem.style.cssText = elem.style.cssText.replace(lastFs, newProp);
  }

  API.addPageStyles = addPageStyles;
  API.updatePageStyles = updatePageStyles;
  API.removePageStyles = removePageStyles;
  API.setFontScale = setFontScale;

  initialize();

  return API;
}

Monocle.Formatting.DEFAULT_STYLE_RULES = [
  "html#RS\\:monocle * {" +
    "-webkit-font-smoothing: subpixel-antialiased;" +
    "text-rendering: auto !important;" +
    "word-wrap: break-word !important;" +
    "overflow: visible !important;" +
  "}",
  "html#RS\\:monocle body {" +
    "margin: 0 !important;"+
    "border: none !important;" +
    "padding: 0 !important;" +
    "width: 100% !important;" +
    "position: absolute !important;" +
    "-webkit-text-size-adjust: none;" +
  "}",
  "html#RS\\:monocle body * {" +
    "max-width: 100% !important;" +
  "}",
  "html#RS\\:monocle img, html#RS\\:monocle video, html#RS\\:monocle object, html#RS\\:monocle svg {" +
    "max-height: 95% !important;" +
    "height: auto !important;" +
  "}"
]
<|endoftext|>


<commit_before>/**
 * Created by Ryan on 05 Mar 2015.
 */

//Define mpa layer variables
var map,BaseMap;
var BoC, NazBeth, BethEgypt, Temple, Nazareth, Bapt, Wedding, SoM, WoW, Geth, Calvary, Rez;

//Define the default map projection
var projection = ol.proj.get('EPSG:3857');

/**********************************************************/
/*             Begin location selection function          */
/**********************************************************/
function LocationSelector(location)
{
    var zoom_area = map.getView();

    switch (location)
    {
        case "BoC":
            TurnAllLayersOff();
            BoC.setVisible(true);
            zoom_area.setCenter(BoC);
            zoom_area.setZoom(13)

    }
}
/**********************************************************/
/*             End location selection function            */
/**********************************************************/

/**********************************************************/
/*             Begin layer definition function            */
/**********************************************************/
function CreateLayers() {
    BaseMap = new ol.layer.Tile({
        source: new ol.source.MapQuest({layer: 'osm'})
    });

    BoC = new ol.layer.Vector({
        source: new ol.source.KML({
            projection: projection,
            url: 'data/kml/birthofchrist.kml'
        })
    })

}
/**********************************************************/
/*             End layer definition function              */
/**********************************************************/

/**********************************************************/
/*                Begin map creation section              */
/**********************************************************/

function CreateMap() {

    //Build the layer objects for each KML file
    CreateLayers();

    //Declare the map object itself.
    map = new ol.Map({
        target: 'map',

        //Set up the layers that will be loaded in the map
        layers: [BaseMap, BoC],

        //Establish the view area. Note the reprojection from lat long (EPSG:4326) to Web Mercator (EPSG:3857)
        view: new ol.View({
            center: ol.proj.transform([35.2167, 31.7833], 'EPSG:4326', projection),
            zoom: 8
        })
    });

    //Add some useful map controls
    map.addControl(new ol.control.ScaleLine());

    //Add Popup system
    var element = document.getElementById('popup');

    var popup = new ol.Overlay({
        element: element,
        positioning: 'bottom-center',
        stopEvent: false
    });
    map.addOverlay(popup);

    return map

}

/**********************************************************/
/*                End map creation section                */
/**********************************************************/

/**********************************************************/
/*              Begin popup bubble scripting              */
/**********************************************************/

function PopUp_Bubble(evt) {

    //Add Popup system
    var element = document.getElementById('popup');

    var popup = new ol.Overlay({
        element: element,
        positioning: 'bottom-center',
        stopEvent: false
    });
    map.addOverlay(popup);

    // display popup on click

    //try to destroy it before doing anything else
    $(element).popover('destroy');

    //Try to get a feature at the point of interest
    var feature = map.forEachFeatureAtPixel(evt.pixel,
        function (feature, layer) {
            return feature;
        });

    //if we found a feature then create and show the popup.
    if (feature) {
        var geometry = feature.getGeometry();
        var coord = geometry.getCoordinates();
        popup.setPosition(coord);
        var displaycontent = ('' + feature.get('name') + '' + '
'
        + '
' + feature.get('description')
        );
        $(element).popover({
            'placement': 'top',
            'html': true,
            'content': displaycontent
        });

        $(element).popover('show');

    } else {
        $(element).popover('destroy');
    }

}

/**********************************************************/
/*               End popup bubble scripting               */
/**********************************************************/

/**********************************************************/
/*              Begin disable layers script               */
/**********************************************************/

function TurnAllLayersOff() {
    //turn all the layers in the map off
    var layers = map.getLayers().a;
    for (var i=1; i <= 16; i++) {
        layers[i].setVisible(false);
    }
}

/**********************************************************/
/*               End disable layers script                */
/**********************************************************/<commit_msg>Add UI controls<commit_after>/**
 * Created by Ryan on 05 Mar 2015.
 */

//Define mpa layer variables
var map,BaseMap;
var BoC, NazBeth, BethEgypt, Temple, Nazareth, Bapt, Wedding, SoM, WoW, Geth, Calvary, Rez;

//Define the default map projection
var projection = ol.proj.get('EPSG:3857');

/**********************************************************/
/*                Begin map creation section              */
/**********************************************************/

function CreateMap() {

    //Build the layer objects for each KML file
    CreateLayers();

    //Declare the map object itself.
    map = new ol.Map({
        target: 'map',

        //Set up the layers that will be loaded in the map
        layers: [BaseMap, BoC],

        //Establish the view area. Note the reprojection from lat long (EPSG:4326) to Web Mercator (EPSG:3857)
        view: new ol.View({
            center: ol.proj.transform([35.2167, 31.7833], 'EPSG:4326', projection),
            zoom: 8
        })
    });

    //Add some useful map controls
    map.addControl(new ol.control.ScaleLine());

    //Add Popup system
    var element = document.getElementById('popup');

    var popup = new ol.Overlay({
        element: element,
        positioning: 'bottom-center',
        stopEvent: false
    });
    map.addOverlay(popup);

    return map

}

/**********************************************************/
/*                End map creation section                */
/**********************************************************/

/**********************************************************/
/*             Begin location selection function          */
/**********************************************************/
function LocationSelector(location)
{
    var zoom_area = map.getView();

    switch (location)
    {
        case "BoC":
            TurnAllLayersOff();
            BoC.setVisible(true);
            zoom_area.setCenter(BoC);
            zoom_area.setZoom(13)

    }
}
/**********************************************************/
/*             End location selection function            */
/**********************************************************/

/**********************************************************/
/*             Begin layer definition function            */
/**********************************************************/
function CreateLayers() {
    BaseMap = new ol.layer.Tile({
        source: new ol.source.MapQuest({layer: 'osm'})
    });

    BoC = new ol.layer.Vector({
        source: new ol.source.KML({
            projection: projection,
            url: 'data/kml/birthofchrist.kml'
        })
    })

}
/**********************************************************/
/*             End layer definition function              */
/**********************************************************/

/**********************************************************/
/*              Begin popup bubble scripting              */
/**********************************************************/

function PopUp_Bubble(evt) {

    //Add Popup system
    var element = document.getElementById('popup');

    var popup = new ol.Overlay({
        element: element,
        positioning: 'bottom-center',
        stopEvent: false
    });
    map.addOverlay(popup);

    // display popup on click

    //try to destroy it before doing anything else
    $(element).popover('destroy');

    //Try to get a feature at the point of interest
    var feature = map.forEachFeatureAtPixel(evt.pixel,
        function (feature, layer) {
            return feature;
        });

    //if we found a feature then create and show the popup.
    if (feature) {
        var geometry = feature.getGeometry();
        var coord = geometry.getCoordinates();
        popup.setPosition(coord);
        var displaycontent = ('' + feature.get('name') + '' + '
'
        + '
' + feature.get('description')
        );
        $(element).popover({
            'placement': 'top',
            'html': true,
            'content': displaycontent
        });

        $(element).popover('show');

    } else {
        $(element).popover('destroy');
    }

}

/**********************************************************/
/*               End popup bubble scripting               */
/**********************************************************/

/**********************************************************/
/*              Begin disable layers script               */
/**********************************************************/

function TurnAllLayersOff() {
    //turn all the layers in the map off
    var layers = map.getLayers().a;
    for (var i=1; i <= 16; i++) {
        layers[i].setVisible(false);
    }
}

/**********************************************************/
/*               End disable layers script                */
/**********************************************************/<|endoftext|>


<commit_before>Package.describe({
  summary: "Efficient crypto operations in web workers",
  version: '0.1.2',
  git: 'https://github.com/peerlibrary/meteor-crypto.git'
});

Package.on_use(function (api) {
  api.versionsFrom('METEOR@0.9.1.1');
  api.use(['coffeescript', 'underscore', 'peerlibrary:assert@0.2.5'], ['client', 'server']);

  api.export('Crypto');

  api.add_files([
    'lib.coffee'
  ], ['client', 'server']);

  api.add_files([
    'arraybuffer.coffee',
    'client.coffee'
  ], 'client' );

  api.add_files([
    'server.coffee'
  ], 'server' );

  // We have to add digest.js in two ways, to be available
  // in a fallback worker, and in a web worker
  api.add_files([
    'digest.js/digest.js'
  ], 'client', {bare: true});

	api.add_files([
		'digest.js/digest.js',
		'assets/worker.js'
	], 'client', {isAsset: true});
});

Package.on_test(function (api) {
  api.use(['peerlibrary:crypto', 'tinytest', 'test-helpers', 'coffeescript', 'underscore', 'peerlibrary:async@0.9.0-2', 'peerlibrary:blob@0.1.2'], ['client', 'server']);

  api.add_files([
    'tests/common.coffee',
    'tests/defined.coffee'
  ], ['client', 'server']);

  api.add_files([
    'tests/client.coffee'
  ], 'client');

  api.add_files([
    'tests/server.coffee'
  ], 'server');

  api.add_files([
    'assets/test.pdf'
  ], ['client', 'server'], {isAsset: true});
});
<commit_msg>Fix package name.<commit_after>Package.describe({
  summary: "Efficient crypto operations in web workers",
  version: '0.1.2',
  name: 'peerlibrary:crypto',
  git: 'https://github.com/peerlibrary/meteor-crypto.git'
});

Package.on_use(function (api) {
  api.versionsFrom('METEOR@0.9.1.1');
  api.use(['coffeescript', 'underscore', 'peerlibrary:assert@0.2.5'], ['client', 'server']);

  api.export('Crypto');

  api.add_files([
    'lib.coffee'
  ], ['client', 'server']);

  api.add_files([
    'arraybuffer.coffee',
    'client.coffee'
  ], 'client' );

  api.add_files([
    'server.coffee'
  ], 'server' );

  // We have to add digest.js in two ways, to be available
  // in a fallback worker, and in a web worker
  api.add_files([
    'digest.js/digest.js'
  ], 'client', {bare: true});

	api.add_files([
		'digest.js/digest.js',
		'assets/worker.js'
	], 'client', {isAsset: true});
});

Package.on_test(function (api) {
  api.use(['peerlibrary:crypto', 'tinytest', 'test-helpers', 'coffeescript', 'underscore', 'peerlibrary:async@0.9.0-2', 'peerlibrary:blob@0.1.2'], ['client', 'server']);

  api.add_files([
    'tests/common.coffee',
    'tests/defined.coffee'
  ], ['client', 'server']);

  api.add_files([
    'tests/client.coffee'
  ], 'client');

  api.add_files([
    'tests/server.coffee'
  ], 'server');

  api.add_files([
    'assets/test.pdf'
  ], ['client', 'server'], {isAsset: true});
});
<|endoftext|>


<commit_before>/* Copyright 2015 Google Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

'use strict';
/* globals d3 */

var bgColors = [
  'red', 'blue', 'green', 'yellow',
];

// Returns a map of module name to number.
// 1 means the module exists in the config.
// > 1 means the module exists and is in a loaded playlist.
// Modules that are in the modules list, but not in a playlist aren't eligible
// for immediate playback, only for indefinite takeover.
function buildPlayableModuleMap(config) {
  let playableModules = {};
  config.current.modules.forEach(function(module) {
    playableModules[module.name] = 1;
  });

  let playableCollections = {};
  config.current.playlist.forEach(function(playlist) {
    if (playlist.collection === undefined) {
      playlist.modules.forEach(function(module) {
        playableModules[module.name] += 1;
      });
    } else if (playlist.collection == '__ALL__') {
      playableCollections['__ALL__'] = new Array();
      config.current.modules.forEach(function(module) {
        playableCollections['__ALL__'].push(module.name);
      });
    } else {
      playableCollections[playlist.collection] = config.current.collections[playlist.collection];
    }
  });

  for (let collection in playableCollections) {
    playableCollections[collection].forEach(function(module) {
      playableModules[module] += 1;
    });
  }
  return playableModules;
}

function fetchJson(endpoint) {
  return fetch('/api/' + endpoint, {credentials: 'same-origin'})
      .then(resp => resp.json());
}

/* exported BigBoard */
class BigBoard {
  constructor() {
    this.layout = null;
    this.clients = null;
    this.now = Infinity;
  }

  update() {
    var layoutReq = fetchJson('layout')
        .then(layout => this.layout = layout, err => {
          if (this.layout) {
            this.layout.partitions = [];
          }
        });
    var clientsReq = fetchJson('clients')
        .then(clients => this.clients = clients, err => {
          this.clients = [];
        });
    Promise.all([layoutReq, clientsReq]).then(() => this.render());

    fetchJson('errors').then(errors => this.showErrors(errors));
  }

  renderError(e) {
    var date = new Date(e.timestamp).toLocaleString();
    return `${date} ${e.origin} ${e.namespace} ${e.message}`;
  }

  showErrors(errors) {
    var items = d3.select('#errors')
        .selectAll('.line')
        .data(errors, error => error.timestamp);
    items.enter().append('div')
      .attr('class', 'line')
      .attr('title', error => error.stack)
      .text(this.renderError)
      .sort((a, b) => new Date(b.timestamp) - new Date(a.timestamp))
      .order();
    items.exit().remove();
  }

  setNow(n) {
    this.now = n;
  }

  render() {
    var wall = this.layout.wall;
    var width, height, maxSize;
    if (wall.extents.w > wall.extents.h) {
      width = window.innerWidth - 40;
      height = width * wall.extents.h / wall.extents.w;
      maxSize = width;
    } else {
      height = window.innerHeight - 40;
      width = height * wall.extents.w / wall.extents.h;
      maxSize = height;
    }

    var chart = d3.select('svg');
    chart.attr('width', width);
    chart.attr('height', height);

    var scale = d3.scale.linear()
        .domain([0, Math.max(wall.extents.w, wall.extents.h)])
        .range([0, maxSize]);
    var lineFromPoints = d3.svg.line()
        .x((pt) => scale(pt.x))
        .y((pt) => scale(pt.y));

    var clientKey = (d) => [d.rect.x, d.rect.y].join(',');
    var clients = chart.select('#clients').selectAll('.client')
        .data(this.clients, clientKey);
    var g = clients.enter().append('g').attr('class', 'client');
    g.append('rect')
        .attr('stroke', '#ccc')
        .attr('fill', 'none')
        .attr('x', (d) => scale(d.rect.x))
        .attr('y', (d) => scale(d.rect.y))
        .attr('width', (d) => scale(d.rect.w))
        .attr('height', (d) => scale(d.rect.h));
    g.append('text')
        .attr('x', (d) => scale(d.rect.x) + 5)
        .attr('y', (d) => scale(d.rect.y) + 20);
    clients.select('text')
        .text((d) => d.module);
    clients.exit().remove();

    // TODO(jacobly): not sure this is the right way to bind a single value.
    var wallGeo = chart.selectAll('.wall').data([wall]);
    wallGeo.enter().append('path')
        .attr('class', 'wall')
        .attr('stroke', 'black')
        .attr('stroke-width', '2')
        .attr('fill', 'none');
    wallGeo
        .attr('d', lineFromPoints(wall.points));

    var partitions = chart.select('#outline').selectAll('.partition')
        .data(this.layout.partitions);
    var partitionGroups = partitions.enter().append('g')
        .attr('class', 'partition');
    partitionGroups.append('path')
        .attr('fill-opacity', 0.1);
    partitionGroups.append('text')
        .attr('stroke', 'gray')
        .attr('text-anchor', 'middle')
        .attr('dominant-baseline', 'middle');
    partitions.select('path')
        .attr('d', (d) => lineFromPoints(d.geo.points))
        .attr('fill', (d, i) => bgColors[i % bgColors.length]);
    partitions.select('text')
        .text((d) => {
          var r = d.state;
          if (d.deadline !== null && d.deadline !== Infinity) {
            r += ': ' + (d.deadline - this.now).toFixed(2);
          }
          return r;
        })
        .attr('x', (d, index) => {
          var bbox = partitions.select('path')[0][index].getBBox();
          return bbox.x + bbox.width / 2;
        })
        .attr('y', (d, index) => {
          var bbox = partitions.select('path')[0][index].getBBox();
          return bbox.y + bbox.height / 2;
        });
    partitions.exit().remove();
  }
}

var board = new BigBoard();
board.update();
setInterval(() => board.update(), 5000);

requirejs(['/config.js'], function(require) {
  requirejs(['client/network/network',
             'client/util/time'], function(network, time) {
    network.openConnection();
    time.start();
    setInterval(function() {
      if (board) {
        board.setNow(time.now());
      }
    }, 100);
  });
});

fetchJson('config').then(config => {
  // Reload the current JSON configuration.
  document.forms[0].config.value = JSON.stringify(
      config.current, null, '  ');

  let modulesInPlaylist = buildPlayableModuleMap(config);

  // Draw the list of available modules in the "play immediately" section.
  let module_list = document.getElementById('module_list');
  config.current.modules.forEach(function(module) {
    let li = document.createElement("li");
    if (modulesInPlaylist[module.name] > 1) {
      let a = document.createElement("a");
      a.id = 'module_' + module.name;
      a.addEventListener('click', function() {
        fetch('/api/play?module=' + module.name, { method: 'POST' });
      });
      a.textContent = module.name;
      li.appendChild(a);
    } else {
      let m = document.createElement("span");
      m.textContent = module.name + ' (not in a playlist)';
      li.appendChild(m);
    }

    let a2 = document.createElement("a");
    a2.id = 'forever_module_' + module.name;
    a2.addEventListener('click', function() {
      let myRequest = new Request('/api/playlist', {
          method: 'POST',
          headers: {'content-type': 'application/json'},
          credentials: 'same-origin',
          body: JSON.stringify(module)});
      fetch(myRequest).then(function(res) {
        if (res.ok && res.redirected) {
          document.location = res.url;
        }
      });
    });
    a2.textContent = '(play ' + module.name + ' indefinitely)';
    li.appendChild(a2);

    module_list.appendChild(li);
  });
});
<commit_msg>Code review comments.<commit_after>/* Copyright 2015 Google Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

'use strict';
/* globals d3 */

var bgColors = [
  'red', 'blue', 'green', 'yellow',
];

// Returns a map of module name to number.
// 1 means the module exists in the config.
// > 1 means the module exists and is in a loaded playlist.
// Modules that are in the modules list, but not in a playlist aren't eligible
// for immediate playback, only for indefinite takeover.
function buildPlayableModuleMap(config) {
  let playableModules = {};
  config.current.modules.forEach(
    module => playableModules[module.name] = 1
  );

  let playableCollections = {};
  config.current.playlist.forEach(function(playlist) {
    if (playlist.collection === undefined) {
      playlist.modules.forEach(
        module => playableModules[module.name] += 1
      );
    } else if (playlist.collection == '__ALL__') {
      playableCollections['__ALL__'] = new Array();
      config.current.modules.forEach(
        module => playableCollections['__ALL__'].push(module.name)
      );
    } else {
      playableCollections[playlist.collection] = config.current.collections[playlist.collection];
    }
  });

  for (let collection in playableCollections) {
    playableCollections[collection].forEach(
      module => playableModules[module] += 1
    );
  }
  return playableModules;
}

function fetchJson(endpoint) {
  return fetch('/api/' + endpoint, {credentials: 'same-origin'})
      .then(resp => resp.json());
}

/* exported BigBoard */
class BigBoard {
  constructor() {
    this.layout = null;
    this.clients = null;
    this.now = Infinity;
  }

  update() {
    var layoutReq = fetchJson('layout')
        .then(layout => this.layout = layout, err => {
          if (this.layout) {
            this.layout.partitions = [];
          }
        });
    var clientsReq = fetchJson('clients')
        .then(clients => this.clients = clients, err => {
          this.clients = [];
        });
    Promise.all([layoutReq, clientsReq]).then(() => this.render());

    fetchJson('errors').then(errors => this.showErrors(errors));
  }

  renderError(e) {
    var date = new Date(e.timestamp).toLocaleString();
    return `${date} ${e.origin} ${e.namespace} ${e.message}`;
  }

  showErrors(errors) {
    var items = d3.select('#errors')
        .selectAll('.line')
        .data(errors, error => error.timestamp);
    items.enter().append('div')
      .attr('class', 'line')
      .attr('title', error => error.stack)
      .text(this.renderError)
      .sort((a, b) => new Date(b.timestamp) - new Date(a.timestamp))
      .order();
    items.exit().remove();
  }

  setNow(n) {
    this.now = n;
  }

  render() {
    var wall = this.layout.wall;
    var width, height, maxSize;
    if (wall.extents.w > wall.extents.h) {
      width = window.innerWidth - 40;
      height = width * wall.extents.h / wall.extents.w;
      maxSize = width;
    } else {
      height = window.innerHeight - 40;
      width = height * wall.extents.w / wall.extents.h;
      maxSize = height;
    }

    var chart = d3.select('svg');
    chart.attr('width', width);
    chart.attr('height', height);

    var scale = d3.scale.linear()
        .domain([0, Math.max(wall.extents.w, wall.extents.h)])
        .range([0, maxSize]);
    var lineFromPoints = d3.svg.line()
        .x((pt) => scale(pt.x))
        .y((pt) => scale(pt.y));

    var clientKey = (d) => [d.rect.x, d.rect.y].join(',');
    var clients = chart.select('#clients').selectAll('.client')
        .data(this.clients, clientKey);
    var g = clients.enter().append('g').attr('class', 'client');
    g.append('rect')
        .attr('stroke', '#ccc')
        .attr('fill', 'none')
        .attr('x', (d) => scale(d.rect.x))
        .attr('y', (d) => scale(d.rect.y))
        .attr('width', (d) => scale(d.rect.w))
        .attr('height', (d) => scale(d.rect.h));
    g.append('text')
        .attr('x', (d) => scale(d.rect.x) + 5)
        .attr('y', (d) => scale(d.rect.y) + 20);
    clients.select('text')
        .text((d) => d.module);
    clients.exit().remove();

    // TODO(jacobly): not sure this is the right way to bind a single value.
    var wallGeo = chart.selectAll('.wall').data([wall]);
    wallGeo.enter().append('path')
        .attr('class', 'wall')
        .attr('stroke', 'black')
        .attr('stroke-width', '2')
        .attr('fill', 'none');
    wallGeo
        .attr('d', lineFromPoints(wall.points));

    var partitions = chart.select('#outline').selectAll('.partition')
        .data(this.layout.partitions);
    var partitionGroups = partitions.enter().append('g')
        .attr('class', 'partition');
    partitionGroups.append('path')
        .attr('fill-opacity', 0.1);
    partitionGroups.append('text')
        .attr('stroke', 'gray')
        .attr('text-anchor', 'middle')
        .attr('dominant-baseline', 'middle');
    partitions.select('path')
        .attr('d', (d) => lineFromPoints(d.geo.points))
        .attr('fill', (d, i) => bgColors[i % bgColors.length]);
    partitions.select('text')
        .text((d) => {
          var r = d.state;
          if (d.deadline !== null && d.deadline !== Infinity) {
            r += ': ' + (d.deadline - this.now).toFixed(2);
          }
          return r;
        })
        .attr('x', (d, index) => {
          var bbox = partitions.select('path')[0][index].getBBox();
          return bbox.x + bbox.width / 2;
        })
        .attr('y', (d, index) => {
          var bbox = partitions.select('path')[0][index].getBBox();
          return bbox.y + bbox.height / 2;
        });
    partitions.exit().remove();
  }
}

var board = new BigBoard();
board.update();
setInterval(() => board.update(), 5000);

requirejs(['/config.js'], function(require) {
  requirejs(['client/network/network',
             'client/util/time'], function(network, time) {
    network.openConnection();
    time.start();
    setInterval(function() {
      if (board) {
        board.setNow(time.now());
      }
    }, 100);
  });
});

fetchJson('config').then(config => {
  // Reload the current JSON configuration.
  document.forms[0].config.value = JSON.stringify(
      config.current, null, '  ');

  let modulesInPlaylist = buildPlayableModuleMap(config);

  // Draw the list of available modules in the "play immediately" section.
  let module_list = document.getElementById('module_list');
  config.current.modules.forEach(function(module) {
    let li = document.createElement('li');
    if (modulesInPlaylist[module.name] > 1) {
      const a = document.createElement('a');
      a.id = 'module_' + module.name;
      a.addEventListener('click', function() {
        fetch('/api/play?module=' + module.name, { method: 'POST' });
      });
      a.textContent = module.name;
      li.appendChild(a);
    } else {
      const m = document.createElement('span');
      m.textContent = `${module.name} (not in a playlist)`;
      li.appendChild(m);
    }

    let a2 = document.createElement("a");
    a2.id = 'forever_module_' + module.name;
    a2.addEventListener('click', function() {
      let myRequest = new Request('/api/playlist', {
          method: 'POST',
          headers: {'content-type': 'application/json'},
          credentials: 'same-origin',
          body: JSON.stringify(module)});
      fetch(myRequest).then(function(res) {
        if (res.ok && res.redirected) {
          document.location = res.url;
        }
      });
    });
    a2.textContent = '(play ' + module.name + ' indefinitely)';
    li.appendChild(a2);

    module_list.appendChild(li);
  });
});
<|endoftext|>


<commit_before>/* global Package, Npm */
Package.describe({
    name: 'socialize:base-model',
    summary: 'A model for all other models to extend.',
    version: '1.1.2',
    git: 'https://github.com/copleykj/socialize-base-model.git',
});

Npm.depends({
    'mongodb-diff': '0.4.4',
});

Package.onUse(function onUse(api) {
    api.versionsFrom('1.3');

    api.use(['meteor', 'mongo', 'ecmascript']);

    api.use('cultofcoders:redis-oplog@1.2.6', { weak: true });

    api.use([
        'aldeed:collection2@3.0.0', 'aldeed:schema-index@3.0.0', 'aldeed:schema-deny@3.0.0',
        'matb33:collection-hooks@0.8.4', 'socialize:server-time@1.0.0',
    ]);

    api.imply(['meteor', 'mongo', 'ecmascript']);

    api.imply([
        'aldeed:collection2', 'aldeed:schema-index', 'aldeed:schema-deny',
        'matb33:collection-hooks', 'socialize:server-time',
    ]);

    api.mainModule('entry-meteor.js');
});

Package.onTest(function onTest(api) {
    api.use(['tinytest', 'meteor', 'mongo', 'ecmascript']);

    api.use([
        'aldeed:collection2@3.0.0', 'matb33:collection-hooks@0.8.4',
        'socialize:base-model',
    ]);

    api.mainModule('tests.js');
});
<commit_msg>remove weak dep on cultofcoders:redis-oplog<commit_after>/* global Package, Npm */
Package.describe({
    name: 'socialize:base-model',
    summary: 'A model for all other models to extend.',
    version: '1.1.2',
    git: 'https://github.com/copleykj/socialize-base-model.git',
});

Npm.depends({
    'mongodb-diff': '0.4.4',
});

Package.onUse(function onUse(api) {
    api.versionsFrom('1.3');

    api.use(['meteor', 'mongo', 'ecmascript']);

    api.use([
        'aldeed:collection2@3.0.0', 'aldeed:schema-index@3.0.0', 'aldeed:schema-deny@3.0.0',
        'matb33:collection-hooks@0.8.4', 'socialize:server-time@1.0.0',
    ]);

    api.imply(['meteor', 'mongo', 'ecmascript']);

    api.imply([
        'aldeed:collection2', 'aldeed:schema-index', 'aldeed:schema-deny',
        'matb33:collection-hooks', 'socialize:server-time',
    ]);

    api.mainModule('entry-meteor.js');
});

Package.onTest(function onTest(api) {
    api.use(['tinytest', 'meteor', 'mongo', 'ecmascript']);

    api.use([
        'aldeed:collection2@3.0.0', 'matb33:collection-hooks@0.8.4',
        'socialize:base-model',
    ]);

    api.mainModule('tests.js');
});
<|endoftext|>


<commit_before>Package.describe({
    summary: "Accounts Templates styled for Semantic UI.",
    version: "0.11.0",
    name: "useraccounts:semantic",
    git: "https://github.com/meteor-useraccounts/semantic.git",
});

Package.on_use(function(api, where) {
    api.versionsFrom("METEOR@1.0");

    api.use([
        "less",
        "templating",
    ], "client");

    api.use([
        "useraccounts:core",
    ], ["client", "server"]);

    api.imply([
        "useraccounts:core@0.11.0",
    ], ["client", "server"]);

    api.add_files([
        "lib/at_error.html",
        "lib/at_error.js",
        "lib/at_form.html",
        "lib/at_form.js",
        "lib/at_input.html",
        "lib/at_input.js",
        "lib/at_oauth.html",
        "lib/at_oauth.js",
        "lib/at_pwd_form.html",
        "lib/at_pwd_form.js",
        "lib/at_pwd_form_btn.html",
        "lib/at_pwd_form_btn.js",
        "lib/at_pwd_link.html",
        "lib/at_pwd_link.js",
        "lib/at_result.html",
        "lib/at_result.js",
        "lib/at_sep.html",
        "lib/at_sep.js",
        "lib/at_signin_link.html",
        "lib/at_signin_link.js",
        "lib/at_signup_link.html",
        "lib/at_signup_link.js",
        "lib/at_social.html",
        "lib/at_social.js",
        "lib/at_terms_link.html",
        "lib/at_terms_link.js",
        "lib/at_title.html",
        "lib/at_title.js",
        "lib/full_page_at_form.html",
        "lib/at_semantic-ui.less"
    ], ["client"]);
});

Package.on_test(function(api) {
    api.use([
        "useraccounts:semantic",
        "useraccounts:core@0.11.0",
    ]);

    api.use([
        "accounts-password",
        "tinytest",
        "test-helpers"
    ], ["client", "server"]);

    api.add_files([
        "tests/tests.js"
    ], ["client", "server"]);
});
<commit_msg>fixed package name<commit_after>Package.describe({
    summary: "Accounts Templates styled for Semantic UI.",
    version: "0.11.0",
    name: "useraccounts:semantic-ui",
    git: "https://github.com/meteor-useraccounts/semantic.git",
});

Package.on_use(function(api, where) {
    api.versionsFrom("METEOR@1.0");

    api.use([
        "less",
        "templating",
    ], "client");

    api.use([
        "useraccounts:core",
    ], ["client", "server"]);

    api.imply([
        "useraccounts:core@0.11.0",
    ], ["client", "server"]);

    api.add_files([
        "lib/at_error.html",
        "lib/at_error.js",
        "lib/at_form.html",
        "lib/at_form.js",
        "lib/at_input.html",
        "lib/at_input.js",
        "lib/at_oauth.html",
        "lib/at_oauth.js",
        "lib/at_pwd_form.html",
        "lib/at_pwd_form.js",
        "lib/at_pwd_form_btn.html",
        "lib/at_pwd_form_btn.js",
        "lib/at_pwd_link.html",
        "lib/at_pwd_link.js",
        "lib/at_result.html",
        "lib/at_result.js",
        "lib/at_sep.html",
        "lib/at_sep.js",
        "lib/at_signin_link.html",
        "lib/at_signin_link.js",
        "lib/at_signup_link.html",
        "lib/at_signup_link.js",
        "lib/at_social.html",
        "lib/at_social.js",
        "lib/at_terms_link.html",
        "lib/at_terms_link.js",
        "lib/at_title.html",
        "lib/at_title.js",
        "lib/full_page_at_form.html",
        "lib/at_semantic-ui.less"
    ], ["client"]);
});

Package.on_test(function(api) {
    api.use([
        "useraccounts:semantic",
        "useraccounts:core@0.11.0",
    ]);

    api.use([
        "accounts-password",
        "tinytest",
        "test-helpers"
    ], ["client", "server"]);

    api.add_files([
        "tests/tests.js"
    ], ["client", "server"]);
});
<|endoftext|>


<commit_before>Package.describe({
    name: "elevatedevdesign:cart",
    summary: "A simple and pluggable shopping cart.",
  	version: "0.0.1-rc.2",
    git: "https://github.com/ElevateDev/meteor-cart.git"
});

Package.on_use(function (api) {
	api.versionsFrom("METEOR@1.0.2");

  api.use([
    'aldeed:simple-schema@1.3.3',
    'underscore',
    'accounts-base',
    'peppelg:on-login-logout@1.0.0',
    'deps',
    'dburles:collection-helpers@1.0.3'
  ]);

	api.use([
    'ground:db@0.3.10',
	],
	'client');

	api.add_files('cart.js',['client','server']);

  api.export('Cart', ['client','server']);
});
<commit_msg>Bump version.<commit_after>Package.describe({
    name: "elevatedevdesign:cart",
    summary: "A simple and pluggable shopping cart.",
  	version: "0.0.1",
    git: "https://github.com/ElevateDev/meteor-cart.git"
});

Package.on_use(function (api) {
	api.versionsFrom("METEOR@1.0.2");

  api.use([
    'aldeed:simple-schema@1.3.3',
    'underscore',
    'accounts-base',
    'peppelg:on-login-logout@1.0.0',
    'deps',
    'dburles:collection-helpers@1.0.3'
  ]);

	api.use([
    'ground:db@0.3.10',
	],
	'client');

	api.add_files('cart.js',['client','server']);

  api.export('Cart', ['client','server']);
});
<|endoftext|>


<commit_before>/**
 * Copyright Greg Bowering <gerg.bowering@gmail.com> 2015 All Rights Reserved
 */
Package.describe({
  name: 'gb96:apn',
  summary: 'Apple Push Notification library node-apn wrapped for Meteor.',
  version: '1.7.4',
  git: 'https://github.com/gb96/meteor-apn.git'
});

Npm.depends({
  apn: '1.74'
});

Package.onUse(function(api) {
  api.versionsFrom('1.1.0.1');

  api.addFiles('server.js', 'server');

  // Export apn module from node-apn:
  api.export('apn', 'server');
});

// Unit tests:
Package.onTest(function(api) {
  api.use('tinytest');
  api.use('gb96:apn', 'server');
  api.addFiles('server-tests.js', 'server');
});
<commit_msg>fix dependency version<commit_after>/**
 * Copyright Greg Bowering <gerg.bowering@gmail.com> 2015 All Rights Reserved
 */
Package.describe({
  name: 'gb96:apn',
  summary: 'Apple Push Notification library node-apn wrapped for Meteor.',
  version: '1.7.4.1',
  git: 'https://github.com/gb96/meteor-apn.git'
});

Npm.depends({
  apn: '1.7.4'
});

Package.onUse(function(api) {
  api.versionsFrom('1.1.0.1');

  api.addFiles('server.js', 'server');

  // Export apn module from node-apn:
  api.export('apn', 'server');
});

// Unit tests:
Package.onTest(function(api) {
  api.use('tinytest');
  api.use('gb96:apn', 'server');
  api.addFiles('server-tests.js', 'server');
});
<|endoftext|>


<commit_before>// Meteor package definition.
Package.describe({
  name: 'aramk:routes',
  version: '0.2.1',
  summary: 'Convenient utilities for setting up routes for a Meteor app.',
  git: 'https://github.com/aramk/meteor-routes.git'
});

Package.onUse(function (api) {
  api.versionsFrom('METEOR@0.9.0');
  api.use([
    'coffeescript',
    'underscore',
    'reactive-var@1.0.5',
    'aramk:q@1.0.1',
    'iron:router@1.0.7',
    'urbanetic:utility@1.0.0'
  ], 'client');
  api.imply('iron:router');
  api.export('Routes', 'client');
  api.addFiles([
    'src/Routes.coffee'
  ], 'client');
});
<commit_msg>Revert "Migrated to urbanetic:utility."<commit_after>// Meteor package definition.
Package.describe({
  name: 'aramk:routes',
  version: '0.2.1',
  summary: 'Convenient utilities for setting up routes for a Meteor app.',
  git: 'https://github.com/aramk/meteor-routes.git'
});

Package.onUse(function (api) {
  api.versionsFrom('METEOR@0.9.0');
  api.use([
    'coffeescript',
    'underscore',
    'reactive-var@1.0.5',
    'aramk:q@1.0.1',
    'aramk:utility@0.8.3',
    'iron:router@1.0.7'
  ], 'client');
  api.imply('iron:router');
  api.export('Routes', 'client');
  api.addFiles([
    'src/Routes.coffee'
  ], 'client');
});
<|endoftext|>


<commit_before>Package.describe({
  git: 'https://github.com/zimme/meteor-collection-timestampable.git',
  name: 'zimme:collection-timestampable',
  summary: 'Add timestamps to collections',
  version: '1.0.5'
});

Package.onUse(function(api) {
  api.versionsFrom('1.0');

  api.use([
    'coffeescript',
    'underscore'
  ]);

  api.use([
    'matb33:collection-hooks@0.7.6',
    'zimme:collection-behaviours@1.0.3'
  ]);

  api.use([
    'aldeed:autoform@4.0.0 || 5.0.0',
    'aldeed:collection2@2.0.0',
    'aldeed:simple-schema@1.0.3'
  ], ['client', 'server'], {weak: true});

  api.imply('zimme:collection-behaviours');

  api.addFiles('timestampable.coffee');
});
<commit_msg>Version bump<commit_after>Package.describe({
  git: 'https://github.com/zimme/meteor-collection-timestampable.git',
  name: 'zimme:collection-timestampable',
  summary: 'Add timestamps to collections',
  version: '1.0.6'
});

Package.onUse(function(api) {
  api.versionsFrom('1.0');

  api.use([
    'coffeescript',
    'underscore'
  ]);

  api.use([
    'matb33:collection-hooks@0.7.6',
    'zimme:collection-behaviours@1.0.3'
  ]);

  api.use([
    'aldeed:autoform@4.0.0 || 5.0.0',
    'aldeed:collection2@2.0.0',
    'aldeed:simple-schema@1.0.3'
  ], ['client', 'server'], {weak: true});

  api.imply('zimme:collection-behaviours');

  api.addFiles('timestampable.coffee');
});
<|endoftext|>


<commit_before>Package.describe({
  summary: "PeerDB migrations.",
  version: '0.1.1',
  name: 'peerlibrary:peerdb-migrations',
  git: 'https://github.com/peerlibrary/meteor-peerdb-migrations.git'
});

Package.on_use(function (api) {
  api.versionsFrom('METEOR@1.0');
  api.use(['coffeescript', 'underscore', 'minimongo', 'peerlibrary:assert@0.2.5', 'logging', 'peerlibrary:util@0.2.3', 'mrt:moment@2.8.1', 'peerlibrary:directcollection@0.5.0', 'peerlibrary:peerdb@0.15.1'], 'server');
  api.add_files([
    'server.coffee'
  ], 'server');
});

Package.on_test(function (api) {
  api.use(['peerlibrary:peerdb@0.15.1', 'peerlibrary:peerdb-migrations', 'tinytest', 'test-helpers', 'coffeescript', 'insecure', 'accounts-base', 'accounts-password', 'peerlibrary:assert@0.2.5', 'underscore', 'peerlibrary:directcollection@0.5.0', 'random', 'logging'], ['client', 'server']);
  api.add_files([
    'tests_defined.js',
    'tests.coffee'
  ], ['client', 'server']);

  api.add_files([
    'tests_migrations.coffee'
  ], 'server');
});
<commit_msg>More missed dependencies for testing.<commit_after>Package.describe({
  summary: "PeerDB migrations.",
  version: '0.1.1',
  name: 'peerlibrary:peerdb-migrations',
  git: 'https://github.com/peerlibrary/meteor-peerdb-migrations.git'
});

Package.on_use(function (api) {
  api.versionsFrom('METEOR@1.0');
  api.use(['coffeescript', 'underscore', 'minimongo', 'peerlibrary:assert@0.2.5', 'logging', 'peerlibrary:util@0.2.3', 'mrt:moment@2.8.1', 'peerlibrary:directcollection@0.5.0', 'peerlibrary:peerdb@0.15.1'], 'server');
  api.add_files([
    'server.coffee'
  ], 'server');
});

Package.on_test(function (api) {
  api.use(['peerlibrary:peerdb@0.15.1', 'peerlibrary:peerdb-migrations', 'tinytest', 'test-helpers', 'coffeescript', 'insecure', 'accounts-base', 'accounts-password', 'peerlibrary:assert@0.2.5', 'underscore', 'peerlibrary:directcollection@0.5.0', 'random', 'logging', 'ejson', 'mongo'], ['client', 'server']);
  api.add_files([
    'tests_defined.js',
    'tests.coffee'
  ], ['client', 'server']);

  api.add_files([
    'tests_migrations.coffee'
  ], 'server');
});
<|endoftext|>


<commit_before>/* This Source Code Form is subject to the terms of the MIT license
 * If a copy of the MIT license was not distributed with this file, you can
 * obtain one at http://www.mozillapopcorn.org/butter-license.txt */

define( [
          "./logger",
          "./eventmanager",
          "util/lang",
          "util/time",
          "./views/trackevent-view"
        ],
        function(
          Logger,
          EventManager,
          LangUtil,
          TimeUtil,
          TrackEventView
        ){

  var __guid = 0;

  var TrackEvent = function ( options ) {

    options = options || {};

    var _this = this,
        _id = "TrackEvent" + __guid++,
        _name = options.name || _id,
        _logger = new Logger( _id ),
        _em = new EventManager( this ),
        _track,
        _type = options.type + "",
        _properties = [],
        _popcornOptions = options.popcornOptions || {
          start: 0,
          end: 1
        },
        _view = new TrackEventView( this, _type, _popcornOptions ),
        _selected = false;

    _this.popcornOptions = _popcornOptions;

    if( !_type ){
      _logger.log( "Warning: " + _id + " has no type." );
    } //if

    _popcornOptions.start = _popcornOptions.start || 0;
    _popcornOptions.start = TimeUtil.roundTime( _popcornOptions.start );
    _popcornOptions.end = _popcornOptions.end || _popcornOptions.start + 1;
    _popcornOptions.end = TimeUtil.roundTime( _popcornOptions.end );

    this.update = function( updateOptions ) {
      var failed = false;

      var oldStart = _popcornOptions.start,
          oldEnd = _popcornOptions.end;

      for ( var prop in updateOptions ) {
        if ( updateOptions.hasOwnProperty( prop ) ) {
          _popcornOptions[ prop ] = updateOptions[ prop ];
        } //if
      } //for

      if ( !isNaN( updateOptions.start ) ) {
        _popcornOptions.start = TimeUtil.roundTime( updateOptions.start );
      }
      if ( !isNaN(updateOptions.end ) ) {
        _popcornOptions.end = TimeUtil.roundTime( updateOptions.end );
      }

      if ( _popcornOptions.start >= _popcornOptions.end ){
        _popcornOptions.start = oldStart;
        _popcornOptions.end = oldEnd;
        failed = "invalidtime";
      }

      if( _track && _track._media ){
        var media = _track._media;
        if( _popcornOptions.start > media.duration ){
          _popcornOptions.start = oldStart;
          _popcornOptions.end = oldEnd;
          failed = "invalidtime";
        }
        else if( _popcornOptions.end > media.duration ){
          _popcornOptions.start = oldStart;
          _popcornOptions.end = oldEnd;
          failed = "invalidtime";
        }
        else if( _popcornOptions.start < 0 ){
          _popcornOptions.start = oldStart;
          _popcornOptions.end = oldEnd;
          failed = "invalidtime";
        }
      }
      console.log( _popcornOptions );
      _view.update( _popcornOptions );
      _this.popcornOptions = _popcornOptions;

      if( failed ){
        _em.dispatch( "trackeventupdatefailed", failed );
      }
      else{
        _em.dispatch( "trackeventupdated", _this );
      }

    }; //update

    this.moveFrameLeft = function( inc, metaKey ){
      if( !metaKey ) {
        if( _popcornOptions.start > inc ) {
          _popcornOptions.start -= inc;
          _popcornOptions.end -= inc;
        } else {
          _popcornOptions.end = _popcornOptions.end - _popcornOptions.start;
          _popcornOptions.start = 0;
        } // if
      } else if ( _popcornOptions.end - _popcornOptions.start > inc ) {
        _popcornOptions.end -= inc;
      } else {
        _popcornOptions.end = _popcornOptions.start;
      } // if
      _em.dispatch( "trackeventupdated", _this );
      _view.update( _popcornOptions );
    }; //moveFrameLeft

    this.moveFrameRight = function( inc, metaKey ){
      if( _popcornOptions.end < butter.duration - inc ) {
        _popcornOptions.end += inc;
        if( !metaKey ) {
          _popcornOptions.start += inc;
        }
      } else {
        if( !metaKey ) {
          _popcornOptions.start += butter.duration - _popcornOptions.end;
        }
        _popcornOptions.end = butter.duration;
      }
      _em.dispatch( "trackeventupdated", _this );
      _view.update( _popcornOptions );
    }; //moveFrameRight

    _view.listen( "trackeventviewupdated", function( e ){
      _popcornOptions.start = _view.start;
      _popcornOptions.end = _view.end;
      _em.dispatch( "trackeventupdated" );
    });

    Object.defineProperties( this, {
      _track: {
        enumerable: true,
        get: function(){
          return _track;
        },
        set: function( val ){
          _track = val;
          _this.update( _popcornOptions );
        }
      },
      view: {
        enumerable: true,
        configurable: false,
        get: function(){
          return _view;
        }
      },
      type: {
        enumerable: true,
        get: function(){
          return _type;
        }
      },
      name: {
        enumerable: true,
        get: function(){
          return _name;
        }
      },
      id: {
        enumerable: true,
        get: function(){
          return _id;
        }
      },
      selected: {
        enumerable: true,
        get: function(){
          return _selected;
        },
        set: function( val ){
          if( val !== _selected ){
            _selected = val;
            _view.selected = _selected;
            if( _selected ){
              _em.dispatch( "trackeventselected" );
            }
            else {
              _em.dispatch( "trackeventdeselected" );
            } //if
          } //if
        }
      },
      json: {
        enumerable: true,
        get: function(){
          return {
            id: _id,
            type: _type,
            popcornOptions: LangUtil.clone( _popcornOptions ),
            track: _track ? _track.name : undefined,
            name: _name
          };
        },
        set: function( importData ){
          _type = _popcornOptions.type = importData.type;
          if( importData.name ){
            _name = importData.name;
          }
          _popcornOptions = importData.popcornOptions;
          _this.popcornOptions = _popcornOptions;
          _view.type = _type;
          _view.update( _popcornOptions );
          _em.dispatch( "trackeventupdated", _this );
        }
      }
    }); //properties

  }; //TrackEvent

  return TrackEvent;

}); //define

<commit_msg>[t458] - review changes<commit_after>/* This Source Code Form is subject to the terms of the MIT license
 * If a copy of the MIT license was not distributed with this file, you can
 * obtain one at http://www.mozillapopcorn.org/butter-license.txt */

define( [
          "./logger",
          "./eventmanager",
          "util/lang",
          "util/time",
          "./views/trackevent-view"
        ],
        function(
          Logger,
          EventManager,
          LangUtil,
          TimeUtil,
          TrackEventView
        ){

  var __guid = 0;

  var TrackEvent = function ( options ) {

    options = options || {};

    var _this = this,
        _id = "TrackEvent" + __guid++,
        _name = options.name || _id,
        _logger = new Logger( _id ),
        _em = new EventManager( this ),
        _track,
        _type = options.type + "",
        _properties = [],
        _popcornOptions = options.popcornOptions || {
          start: 0,
          end: 1
        },
        _view = new TrackEventView( this, _type, _popcornOptions ),
        _selected = false;

    _this.popcornOptions = _popcornOptions;

    if( !_type ){
      _logger.log( "Warning: " + _id + " has no type." );
    } //if

    _popcornOptions.start = _popcornOptions.start || 0;
    _popcornOptions.start = TimeUtil.roundTime( _popcornOptions.start );
    _popcornOptions.end = _popcornOptions.end || _popcornOptions.start + 1;
    _popcornOptions.end = TimeUtil.roundTime( _popcornOptions.end );

    this.update = function( updateOptions ) {
      var failed = false;

      var oldStart = _popcornOptions.start,
          oldEnd = _popcornOptions.end;

      for ( var prop in updateOptions ) {
        if ( updateOptions.hasOwnProperty( prop ) ) {
          _popcornOptions[ prop ] = updateOptions[ prop ];
        } //if
      } //for

      if ( !isNaN( updateOptions.start ) ) {
        _popcornOptions.start = TimeUtil.roundTime( updateOptions.start );
      }
      if ( !isNaN(updateOptions.end ) ) {
        _popcornOptions.end = TimeUtil.roundTime( updateOptions.end );
      }

      if ( _popcornOptions.start >= _popcornOptions.end ){
        _popcornOptions.start = oldStart;
        _popcornOptions.end = oldEnd;
        failed = "invalidtime";
      }

      if( _track && _track._media ){
        var media = _track._media;
        if( _popcornOptions.start > media.duration ){
          _popcornOptions.start = oldStart;
          _popcornOptions.end = oldEnd;
          failed = "invalidtime";
        }
        else if( _popcornOptions.end > media.duration ){
          _popcornOptions.start = oldStart;
          _popcornOptions.end = oldEnd;
          failed = "invalidtime";
        }
        else if( _popcornOptions.start < 0 ){
          _popcornOptions.start = oldStart;
          _popcornOptions.end = oldEnd;
          failed = "invalidtime";
        }
      }

      _view.update( _popcornOptions );
      _this.popcornOptions = _popcornOptions;

      if( failed ){
        _em.dispatch( "trackeventupdatefailed", failed );
      }
      else{
        _em.dispatch( "trackeventupdated", _this );
      }

    }; //update

    this.moveFrameLeft = function( inc, metaKey ){
      if( !metaKey ) {
        if( _popcornOptions.start > inc ) {
          _popcornOptions.start -= inc;
          _popcornOptions.end -= inc;
        } else {
          _popcornOptions.end = _popcornOptions.end - _popcornOptions.start;
          _popcornOptions.start = 0;
        } // if
      } else if ( _popcornOptions.end - _popcornOptions.start > inc ) {
        _popcornOptions.end -= inc;
      } else {
        _popcornOptions.end = _popcornOptions.start;
      } // if
      _em.dispatch( "trackeventupdated", _this );
      _view.update( _popcornOptions );
    }; //moveFrameLeft

    this.moveFrameRight = function( inc, metaKey ){
      if( _popcornOptions.end < butter.duration - inc ) {
        _popcornOptions.end += inc;
        if( !metaKey ) {
          _popcornOptions.start += inc;
        }
      } else {
        if( !metaKey ) {
          _popcornOptions.start += butter.duration - _popcornOptions.end;
        }
        _popcornOptions.end = butter.duration;
      }
      _em.dispatch( "trackeventupdated", _this );
      _view.update( _popcornOptions );
    }; //moveFrameRight

    _view.listen( "trackeventviewupdated", function( e ){
      _popcornOptions.start = _view.start;
      _popcornOptions.end = _view.end;
      _em.dispatch( "trackeventupdated" );
    });

    Object.defineProperties( this, {
      _track: {
        enumerable: true,
        get: function(){
          return _track;
        },
        set: function( val ){
          _track = val;
          _this.update( _popcornOptions );
        }
      },
      view: {
        enumerable: true,
        configurable: false,
        get: function(){
          return _view;
        }
      },
      type: {
        enumerable: true,
        get: function(){
          return _type;
        }
      },
      name: {
        enumerable: true,
        get: function(){
          return _name;
        }
      },
      id: {
        enumerable: true,
        get: function(){
          return _id;
        }
      },
      selected: {
        enumerable: true,
        get: function(){
          return _selected;
        },
        set: function( val ){
          if( val !== _selected ){
            _selected = val;
            _view.selected = _selected;
            if( _selected ){
              _em.dispatch( "trackeventselected" );
            }
            else {
              _em.dispatch( "trackeventdeselected" );
            } //if
          } //if
        }
      },
      json: {
        enumerable: true,
        get: function(){
          return {
            id: _id,
            type: _type,
            popcornOptions: LangUtil.clone( _popcornOptions ),
            track: _track ? _track.name : undefined,
            name: _name
          };
        },
        set: function( importData ){
          _type = _popcornOptions.type = importData.type;
          if( importData.name ){
            _name = importData.name;
          }
          _popcornOptions = importData.popcornOptions;
          _this.popcornOptions = _popcornOptions;
          _view.type = _type;
          _view.update( _popcornOptions );
          _em.dispatch( "trackeventupdated", _this );
        }
      }
    }); //properties

  }; //TrackEvent

  return TrackEvent;

}); //define

<|endoftext|>