<commit_before>/*!
Deck JS - deck.timekeeper
Copyright (c) 2013-2016 Rémi Emonet
Licensed under the MIT license.
https://github.com/imakewebthings/deck.js/blob/master/MIT-license.txt
*/

/*
This module provides a support for displaying current time, time from start and logging the time spent on each slide etc.
It also injects some default html for it if none is found (and styles it for the presenter/clone view).
*/

(function($, deck, undefined) {
    var $d = $(document);

    $.extend(true, $[deck].defaults, {
        selectors: {
            timekeeper: ".timekeeper", /* inject if this is not present */ // TODO inject
            timekeeperTime: ".timekeeper-time",
            timekeeperRelativeTime: ".timekeeper-relative-time",
            timekeeperLocalRelativeTime: ".timekeeper-local-relative-time",
            timekeeperLogs: ".timekeeper-logs",
            timekeeperLogsPre: ".timekeeper-logs pre",
            timekeeperLogsToggle: ".timekeeper-logs-toggle",
            timekeeperBang: ".timekeeper-bang",
            timekeeperClear: ".timekeeper-clear"
        },
        classes: {
            timekeeperNotification: "timekeeper-notification",
            timekeeperLogsVisible: "timekeeper-logs-visible"
        },
        snippets: {
            timekeeper: true
        },
        alert: {
            localStorageUnsupported: true
        },
        localStorage: {
            timekeeperArchivesMaxSize: 500*1000,
            timekeeperArchives: 'deckjs-timekeeper-archives',
            timekeeperLogs: 'deckjs-timekeeper-logs',
            timekeeperBase: 'deckjs-timekeeper-base',
            timekeeperLocalBase: 'deckjs-timekeeper-local-base'
        },
        timekeeperPeriod: 1000,
        timekeeperNotificationPeriod: 100,
        keys: {
            timekeeper: [27, 75] // escape, k (combine with SHIFT to reset the counter (when starting presenting))
        }
    });

    $d.bind('deck.init', function() {
        var opts = $[deck]('getOptions');
        var container = $[deck]('getContainer');

        // sligthly edited from
        var selectText = function(text) {
            var doc = document
            , range, selection
            ;
            if (doc.body.createTextRange) { //ms
                range = doc.body.createTextRange();
                range.moveToElementText(text);
                range.select();
            } else if (window.getSelection) { //all others
                selection = window.getSelection();
                range = doc.createRange();
                range.selectNodeContents(text);
                selection.removeAllRanges();
                selection.addRange(range);
            }
        }

        if (opts.snippets.timekeeper) {
            $('.timekeeper.auto-inserted, .timekeeper-logs.auto-inserted').remove();
            var d = function() {return $('<div/>');}
            var divTK = d().addClass("timekeeper timekeeper-logs-toggle auto-inserted");
            divTK.append(d().addClass("timekeeper-local-relative-time"));
            divTK.append(d().addClass("timekeeper-time"));
            divTK.append(d().addClass("timekeeper-relative-time"));
            divTK.append(d().addClass("timekeeper-clear"));
            divTK.append(d().addClass("timekeeper-bang"));
            divTK.appendTo(container);
            var divLog = d().addClass("timekeeper-logs auto-inserted");
            var pre = $('<pre/>').appendTo(divLog);
            divLog.append(d().addClass("button").click(function() { doBang() }).html("Bang!"));
            divLog.append(d().addClass("button").click(function() { selectText(pre.get(0)) }).html("select all"));
            divLog.append(d().addClass("button").click(function() { clearStorage() }).html("Clear").css({color:'#f44', marginLeft: '2em'}));
            divLog.append(d().addClass("button").addClass("timekeeper-logs-toggle").css({position:'float', float:'right', color:'#0f0'}).html("X"));
            divLog.appendTo(container);
        }

        if (!window.localStorage && opts.alert.localStorageUnsupported) { alert(
            "LocalStorage is unsupported in your browser, timing features are disabled (timekeeper extension).");
            return;
        }

        var pad = function(base, right) {
            var s = ""+right;
            if (s.length >= base.length) return s;
            else return base.substring(0, base.length - s.length) + s
        }
        var formatTime = function(t, daily) {
            daily = daily || false;
            var min = parseInt(t / 1000 / 60);
            var sec = parseInt(t / 1000 - 60 * min);
            if (min > 60) {
                var hours = parseInt(t / 1000 / 60 / 60);
                min = parseInt(t / 1000 / 60 - 60 * hours);
                if (daily) {
                    hours = t.getHours();
                }
                return pad("00", hours) +":"+ pad("00", min) + ":" + pad("00", sec);
            } else {
                return pad("00", min) + ":" + pad("00", sec);
            }
        }
        var formatDate = function(t) {
            var y = t.getFullYear();
            var m = t.getMonth() + 1;
            var d = t.getDate();
            return y + "-" + pad("00", m) + "-" + pad("00", d);
        }
        var clearStorage = function(what) {
            { // archive
                var currentArchives = localStorage.getItem(opts.localStorage.timekeeperArchives);
                var currentLogs = localStorage.getItem(opts.localStorage.timekeeperLogs);
                currentArchives = currentLogs + "\n\n" + currentArchives;
                currentArchives = currentArchives.substr(0, opts.localStorage.timekeeperArchivesMaxSize);
                localStorage.setItem(opts.localStorage.timekeeperArchives, currentArchives);
            }
            // clear
            localStorage.setItem(opts.localStorage.timekeeperLogs, null);
            log("CLEARED BY USER");
            localStorage.setItem(opts.localStorage.timekeeperBase, JSON.stringify(new Date()));
            $(opts.selectors.timekeeperClear).addClass(opts.classes.timekeeperNotification);
            setTimeout(function() {
                $(opts.selectors.timekeeperClear).removeClass(opts.classes.timekeeperNotification);
            }, opts.timekeeperNotificationPeriod);
        }
        var reset = function() {
            localStorage.setItem(opts.localStorage.timekeeperLocalBase, JSON.stringify(new Date()));
        }
        var getDateOrSet = function(k, or) {
            var res = localStorage.getItem(k);
            if (res == null) {
                res = JSON.stringify(or);
                localStorage.setItem(k, res);
            } else {
                res = new Date(JSON.parse(res));
            }
            return res;
        }
        var log = function(what) {
            var now = new Date();
            var dateString = formatDate(now);
            var timeString = formatTime(now, true);
            var localBase = getDateOrSet(opts.localStorage.timekeeperLocalBase, now);
            var base = getDateOrSet(opts.localStorage.timekeeperBase, now);
            var db = (now - localBase)/1000;
            var dcb = (now - base)/1000;
            var dbtime = formatTime(now - localBase);
            var dcbtime = formatTime(now - base);
            var log = dateString + " " + timeString + " " + what + " " + dcb + " " + db + " " + dcbtime + " " + dbtime;

            var data = localStorage.getItem(opts.localStorage.timekeeperLogs);
            data = log + "\n" + data;
            localStorage.setItem(opts.localStorage.timekeeperLogs, data);
            $(opts.selectors.timekeeperLogsPre).html(data);
        }

        var saveCurrent = -1;
        $(document).bind('deck.change', function(e, from, to) {
            log(from + " " + to);
            saveCurrent = to;
        });

        // Bind key event to add a marker in the logs
        var $d = $(document);
        var doBang = function() {
            log("BANG " + saveCurrent);
            $(opts.selectors.timekeeperBang).addClass(opts.classes.timekeeperNotification);
            setTimeout(function() {
                $(opts.selectors.timekeeperBang).removeClass(opts.classes.timekeeperNotification);
            }, opts.timekeeperNotificationPeriod);
            reset();
        }
        $d.unbind('keydown.logbang').bind('keydown.logbang', function(e) {
            if (e.ctrlKey) return;
            var K = opts.keys.timekeeper;
            if (e.which === K || $.inArray(e.which, K) > -1) {
                doBang();
                if (e.shiftKey) {
                    clearStorage();
                }
            }
        });
        $(opts.selectors.timekeeperLogsToggle).unbind('click.timekeeper').bind('click.timekeeper', function(e) {
            $(opts.selectors.timekeeperLogs).toggleClass(opts.classes.timekeeperLogsVisible);
        });

        // Refresh display
        var period = opts.timekeeperPeriod;
        setInterval(function() {
            var today = new Date();
            today.setMinutes(0);
            today.setHours(0);
            today.setSeconds(0);
            var now = new Date();
            $(opts.selectors.timekeeperTime).html(formatTime(now - today));
            var v = localStorage.getItem(opts.localStorage.timekeeperBase);
            if (v != null) {
                var t = now - new Date(JSON.parse(v));
                var time = formatTime(t);
                $(opts.selectors.timekeeperRelativeTime).html(time);
            }
            var v2 = localStorage.getItem(opts.localStorage.timekeeperLocalBase);
            if (v2 != null) {
                var t = now - new Date(JSON.parse(v2));
                var time = formatTime(t);
                $(opts.selectors.timekeeperLocalRelativeTime).html(time);
            }
        }, period);

    });

})(jQuery, 'deck');

<commit_msg>[timekeeper] share the log function for other extensions to contribute<commit_after>/*!
Deck JS - deck.timekeeper
Copyright (c) 2013-2016 Rémi Emonet
Licensed under the MIT license.
https://github.com/imakewebthings/deck.js/blob/master/MIT-license.txt
*/

/*
This module provides a support for displaying current time, time from start and logging the time spent on each slide etc.
It also injects some default html for it if none is found (and styles it for the presenter/clone view).
*/

(function($, deck, undefined) {
    var $d = $(document);

    $.extend(true, $[deck].defaults, {
        selectors: {
            timekeeper: ".timekeeper", /* inject if this is not present */ // TODO inject
            timekeeperTime: ".timekeeper-time",
            timekeeperRelativeTime: ".timekeeper-relative-time",
            timekeeperLocalRelativeTime: ".timekeeper-local-relative-time",
            timekeeperLogs: ".timekeeper-logs",
            timekeeperLogsPre: ".timekeeper-logs pre",
            timekeeperLogsToggle: ".timekeeper-logs-toggle",
            timekeeperBang: ".timekeeper-bang",
            timekeeperClear: ".timekeeper-clear"
        },
        classes: {
            timekeeperNotification: "timekeeper-notification",
            timekeeperLogsVisible: "timekeeper-logs-visible"
        },
        snippets: {
            timekeeper: true
        },
        alert: {
            localStorageUnsupported: true
        },
        localStorage: {
            timekeeperArchivesMaxSize: 500*1000,
            timekeeperArchives: 'deckjs-timekeeper-archives',
            timekeeperLogs: 'deckjs-timekeeper-logs',
            timekeeperBase: 'deckjs-timekeeper-base',
            timekeeperLocalBase: 'deckjs-timekeeper-local-base'
        },
        timekeeperPeriod: 1000,
        timekeeperNotificationPeriod: 100,
        keys: {
            timekeeper: [27, 75] // escape, k (combine with SHIFT to reset the counter (when starting presenting))
        }
    });

    $d.bind('deck.init', function() {
        var opts = $[deck]('getOptions');
        var container = $[deck]('getContainer');

        // sligthly edited from
        var selectText = function(text) {
            var doc = document
            , range, selection
            ;
            if (doc.body.createTextRange) { //ms
                range = doc.body.createTextRange();
                range.moveToElementText(text);
                range.select();
            } else if (window.getSelection) { //all others
                selection = window.getSelection();
                range = doc.createRange();
                range.selectNodeContents(text);
                selection.removeAllRanges();
                selection.addRange(range);
            }
        }

        if (opts.snippets.timekeeper) {
            $('.timekeeper.auto-inserted, .timekeeper-logs.auto-inserted').remove();
            var d = function() {return $('<div/>');}
            var divTK = d().addClass("timekeeper timekeeper-logs-toggle auto-inserted");
            divTK.append(d().addClass("timekeeper-local-relative-time"));
            divTK.append(d().addClass("timekeeper-time"));
            divTK.append(d().addClass("timekeeper-relative-time"));
            divTK.append(d().addClass("timekeeper-clear"));
            divTK.append(d().addClass("timekeeper-bang"));
            divTK.appendTo(container);
            var divLog = d().addClass("timekeeper-logs auto-inserted");
            var pre = $('<pre/>').appendTo(divLog);
            divLog.append(d().addClass("button").click(function() { doBang() }).html("Bang!"));
            divLog.append(d().addClass("button").click(function() { selectText(pre.get(0)) }).html("select all"));
            divLog.append(d().addClass("button").click(function() { clearStorage() }).html("Clear").css({color:'#f44', marginLeft: '2em'}));
            divLog.append(d().addClass("button").addClass("timekeeper-logs-toggle").css({position:'float', float:'right', color:'#0f0'}).html("X"));
            divLog.appendTo(container);
        }

        if (!window.localStorage && opts.alert.localStorageUnsupported) { alert(
            "LocalStorage is unsupported in your browser, timing features are disabled (timekeeper extension).");
            return;
        }

        var pad = function(base, right) {
            var s = ""+right;
            if (s.length >= base.length) return s;
            else return base.substring(0, base.length - s.length) + s
        }
        var formatTime = function(t, daily) {
            daily = daily || false;
            var min = parseInt(t / 1000 / 60);
            var sec = parseInt(t / 1000 - 60 * min);
            if (min > 60) {
                var hours = parseInt(t / 1000 / 60 / 60);
                min = parseInt(t / 1000 / 60 - 60 * hours);
                if (daily) {
                    hours = t.getHours();
                }
                return pad("00", hours) +":"+ pad("00", min) + ":" + pad("00", sec);
            } else {
                return pad("00", min) + ":" + pad("00", sec);
            }
        }
        var formatDate = function(t) {
            var y = t.getFullYear();
            var m = t.getMonth() + 1;
            var d = t.getDate();
            return y + "-" + pad("00", m) + "-" + pad("00", d);
        }
        var clearStorage = function(what) {
            { // archive
                var currentArchives = localStorage.getItem(opts.localStorage.timekeeperArchives);
                var currentLogs = localStorage.getItem(opts.localStorage.timekeeperLogs);
                currentArchives = currentLogs + "\n\n" + currentArchives;
                currentArchives = currentArchives.substr(0, opts.localStorage.timekeeperArchivesMaxSize);
                localStorage.setItem(opts.localStorage.timekeeperArchives, currentArchives);
            }
            // clear
            localStorage.setItem(opts.localStorage.timekeeperLogs, null);
            log("CLEARED BY USER");
            localStorage.setItem(opts.localStorage.timekeeperBase, JSON.stringify(new Date()));
            $(opts.selectors.timekeeperClear).addClass(opts.classes.timekeeperNotification);
            setTimeout(function() {
                $(opts.selectors.timekeeperClear).removeClass(opts.classes.timekeeperNotification);
            }, opts.timekeeperNotificationPeriod);
        }
        var reset = function() {
            localStorage.setItem(opts.localStorage.timekeeperLocalBase, JSON.stringify(new Date()));
        }
        var getDateOrSet = function(k, or) {
            var res = localStorage.getItem(k);
            if (res == null) {
                res = JSON.stringify(or);
                localStorage.setItem(k, res);
            } else {
                res = new Date(JSON.parse(res));
            }
            return res;
        }
        var log = function(what) {
            var now = new Date();
            var dateString = formatDate(now);
            var timeString = formatTime(now, true);
            var localBase = getDateOrSet(opts.localStorage.timekeeperLocalBase, now);
            var base = getDateOrSet(opts.localStorage.timekeeperBase, now);
            var db = (now - localBase)/1000;
            var dcb = (now - base)/1000;
            var dbtime = formatTime(now - localBase);
            var dcbtime = formatTime(now - base);
            var log = dateString + " " + timeString + " " + what + " " + dcb + " " + db + " " + dcbtime + " " + dbtime;

            var data = localStorage.getItem(opts.localStorage.timekeeperLogs);
            data = log + "\n" + data;
            localStorage.setItem(opts.localStorage.timekeeperLogs, data);
            $(opts.selectors.timekeeperLogsPre).html(data);
        }

        $[deck]('extend', 'addToTimekeeperLog', log);

        var saveCurrent = -1;
        $(document).bind('deck.change', function(e, from, to) {
            log(from + " " + to);
            saveCurrent = to;
        });

        // Bind key event to add a marker in the logs
        var $d = $(document);
        var doBang = function() {
            log("BANG " + saveCurrent);
            $(opts.selectors.timekeeperBang).addClass(opts.classes.timekeeperNotification);
            setTimeout(function() {
                $(opts.selectors.timekeeperBang).removeClass(opts.classes.timekeeperNotification);
            }, opts.timekeeperNotificationPeriod);
            reset();
        }
        $d.unbind('keydown.logbang').bind('keydown.logbang', function(e) {
            if (e.ctrlKey) return;
            var K = opts.keys.timekeeper;
            if (e.which === K || $.inArray(e.which, K) > -1) {
                doBang();
                if (e.shiftKey) {
                    clearStorage();
                }
            }
        });
        $(opts.selectors.timekeeperLogsToggle).unbind('click.timekeeper').bind('click.timekeeper', function(e) {
            $(opts.selectors.timekeeperLogs).toggleClass(opts.classes.timekeeperLogsVisible);
        });

        // Refresh display
        var period = opts.timekeeperPeriod;
        setInterval(function() {
            var today = new Date();
            today.setMinutes(0);
            today.setHours(0);
            today.setSeconds(0);
            var now = new Date();
            $(opts.selectors.timekeeperTime).html(formatTime(now - today));
            var v = localStorage.getItem(opts.localStorage.timekeeperBase);
            if (v != null) {
                var t = now - new Date(JSON.parse(v));
                var time = formatTime(t);
                $(opts.selectors.timekeeperRelativeTime).html(time);
            }
            var v2 = localStorage.getItem(opts.localStorage.timekeeperLocalBase);
            if (v2 != null) {
                var t = now - new Date(JSON.parse(v2));
                var time = formatTime(t);
                $(opts.selectors.timekeeperLocalRelativeTime).html(time);
            }
        }, period);

    });

})(jQuery, 'deck');

<|endoftext|>


<commit_before>const React = require('react');

const Spin = require('./Spin');

const StyleConstants = require('../constants/Style');

class Loader extends React.Component {
  render () {
    if (this.props.isLoading) {
      const styles = {
        component: {
          backgroundColor: 'rgba(255,255,255,0.9)',
          bottom: 0,
          color: '#999',
          fontFamily: StyleConstants.FontFamily,
          fontSize: '10px',
          fontWeight: 600,
          left: 0,
          letterSpacing: '1px',
          position: this.props.isRelative ? 'absolute' : 'fixed',
          right: 0,
          textAlign: 'center',
          top: 0,
          zIndex: 100
        },
        content: {
          textAlign: 'center',
          position: 'absolute',
          top: 0,
          right: 0,
          bottom: 0,
          left: 0,
          margin: 'auto',
          width: this.props.isSmall ? '30px' : '50px',
          height: this.props.isSmall ? '30px' : '50px'
        },
        circle: {
          borderRadius: '100%',
          width: this.props.isSmall ? '30px' : '50px',
          height: this.props.isSmall ? '30px' : '50px',
          borderTop: '3px solid ' + this.props.color,
          borderRight: '3px solid transparent',
          borderBottom: '3px solid transparent',
          borderLeft: '3px solid transparent'
        },
        text: {
          marginTop: '10px',
          fontSize: '10px'
        }
      };

      return (

            <Spin>

            </Spin>
            {this.props.isSmall ? (
              null
            ) : (

 {this.props.loaderText}

            )}

      );
    } else {
      return (

      );
    }
  }
}

Loader.propTypes = {
  color: React.PropTypes.string,
  isLoading: React.PropTypes.bool,
  isRelative: React.PropTypes.bool,
  isSmall: React.PropTypes.bool,
  loaderText: React.PropTypes.string
};

Loader.defaultProps = {
  color: StyleConstants.Colors.PRIMARY,
  isLoading: false,
  isRelative: false,
  isSmall: false,
  loaderText: "LOADING..."
};

module.exports = Loader;
<commit_msg>Changed string to single quotes<commit_after>const React = require('react');

const Spin = require('./Spin');

const StyleConstants = require('../constants/Style');

class Loader extends React.Component {
  render () {
    if (this.props.isLoading) {
      const styles = {
        component: {
          backgroundColor: 'rgba(255,255,255,0.9)',
          bottom: 0,
          color: '#999',
          fontFamily: StyleConstants.FontFamily,
          fontSize: '10px',
          fontWeight: 600,
          left: 0,
          letterSpacing: '1px',
          position: this.props.isRelative ? 'absolute' : 'fixed',
          right: 0,
          textAlign: 'center',
          top: 0,
          zIndex: 100
        },
        content: {
          textAlign: 'center',
          position: 'absolute',
          top: 0,
          right: 0,
          bottom: 0,
          left: 0,
          margin: 'auto',
          width: this.props.isSmall ? '30px' : '50px',
          height: this.props.isSmall ? '30px' : '50px'
        },
        circle: {
          borderRadius: '100%',
          width: this.props.isSmall ? '30px' : '50px',
          height: this.props.isSmall ? '30px' : '50px',
          borderTop: '3px solid ' + this.props.color,
          borderRight: '3px solid transparent',
          borderBottom: '3px solid transparent',
          borderLeft: '3px solid transparent'
        },
        text: {
          marginTop: '10px',
          fontSize: '10px'
        }
      };

      return (

            <Spin>

            </Spin>
            {this.props.isSmall ? (
              null
            ) : (

 {this.props.loaderText}

            )}

      );
    } else {
      return (

      );
    }
  }
}

Loader.propTypes = {
  color: React.PropTypes.string,
  isLoading: React.PropTypes.bool,
  isRelative: React.PropTypes.bool,
  isSmall: React.PropTypes.bool,
  loaderText: React.PropTypes.string
};

Loader.defaultProps = {
  color: StyleConstants.Colors.PRIMARY,
  isLoading: false,
  isRelative: false,
  isSmall: false,
  loaderText: 'LOADING...'
};

module.exports = Loader;
<|endoftext|>


<commit_before>import React from 'react';
import PropTypes from 'prop-types';

const Icon = ({ name, className, viewBox, alt, ...rest }) => {
    return (
        <>
            <svg viewBox={viewBox} className={className} role="img" focusable="false" {...rest}>
                <use xlinkHref={`#shape-${name}`} />
            </svg>
            {alt ? {alt} : null}
        </>
    );
};

Icon.propTypes = {
    alt: PropTypes.string,
    name: PropTypes.string.isRequired,
    viewBox: PropTypes.string,
    className: PropTypes.string
};

Icon.defaultProps = {
    viewBox: '0 0 16 16',
    className: 'icon-16p fill-global-grey'
};

export default Icon;
<commit_msg>Add doc for Icon component<commit_after>import React from 'react';
import PropTypes from 'prop-types';

/**
 * Component to print svg icon
 * <Icon name="label" alt="My label" />
 * @param {String} name of the svg icon present in the design-system
 * @param {String} className used on svg tag
 * @param {String} viewBox
 * @param {String} alt used by screen reader
 * @return {React.Component}
 */
const Icon = ({ name, className, viewBox, alt, ...rest }) => {
    return (
        <>
            <svg viewBox={viewBox} className={className} role="img" focusable="false" {...rest}>
                <use xlinkHref={`#shape-${name}`} />
            </svg>
            {alt ? {alt} : null}
        </>
    );
};

Icon.propTypes = {
    alt: PropTypes.string,
    name: PropTypes.string.isRequired,
    viewBox: PropTypes.string,
    className: PropTypes.string
};

Icon.defaultProps = {
    viewBox: '0 0 16 16',
    className: 'icon-16p fill-global-grey'
};

export default Icon;
<|endoftext|>


<commit_before>import Ember from 'ember';

const {
  Service,
  $,
  run: {
    bind,
    later
  }
} = Ember;

export default Service.extend({
  touches: [],

  setupClient: function() {
    let client = new Tuio.Client({
        host: "http://localhost:5000"
    });
    client.connect();

    // Tuio Cursors
    client.on('addTuioCursor', bind(this, function(cursor) {
      this.createTouchEvent("touchstart", cursor);
    }));

    client.on('updateTuioCursor', bind(this, function(cursor) {
      this.createTouchEvent('touchmove', cursor);
    }));

    client.on('removeTuioCursor', bind(this, function(cursor) {
      this.createTouchEvent('touchend', cursor);
    }));

    // Tuio Objects
    client.on('addTuioObject', bind(this, function(object) {
      this.createObjectEvent("objectadded", object);
    }));

    client.on('updateTuioObject', bind(this, function(object) {
      this.createObjectEvent('objectmoved', object);
    }));

    client.on('removeTuioObject', bind(this, function(object) {
      this.createObjectEvent('objectremoved', object);
    }));
  },

  createTouchEvent: function(eventName, cursor) {
    let touch = this.createTouch(cursor);
    let evt = document.createEvent('Event');

    evt.initEvent(eventName, true, true);
    evt.touches = this.createTouchList(touch, eventName);
    evt.targetTouches = this.getTargetTouches(touch.target);
    evt.changedTouches = [touch];

    touch.target.dispatchEvent(evt);

    // Tuio touch debug mode
    let config = this.container.lookupFactory('config:environment');

    if( config.tuioTouchDebug ) {
      this.updateDebugTouches(touch, eventName);
    }
  },

  createTouch: function(cursor) {
    const data = {
      identifier: cursor.sessionId,
      screenX: this.getScreenX(cursor.xPos),
      screenY: this.getScreenY(cursor.yPos),
      pageX: this.getPageX(cursor.xPos),
      pageY: this.getPageY(cursor.yPos),
      clientX: this.getClientX(cursor.xPos),
      clientY: this.getClientY(cursor.yPos),
      target: this.getElement(cursor)
    };

    return data;
  },

  createTouchList: function(touch, eventName) {
    let touches = this.get('touches');

    if(eventName === 'touchstart') {
      touches.push(touch);
    } else if(eventName === 'touchmove') {
      touches[_.findIndex(touches, 'identifier', touch.identifier)] = touch;
    } else if(eventName === 'touchend') {
      touches.splice(_.findIndex(touches, 'identifier',  touch.identifier), 1);
    }

    return touches;
  },

  getTargetTouches: function(element) {
    var targetTouches = [];
    for (var i = 0; i < this.touches.length; i++) {
      var touch = this.touches[i];
      if (touch.target === element) {
        targetTouches.push(touch);
      }
    }
    return targetTouches;
  },

  // Triggers objects (fiducial) events
  createObjectEvent: function(eventName, object) {
    $(this.getElement(object)).trigger({
      type: eventName,
      screenX: this.getScreenX(object.xPos),
      screenY: this.getScreenY(object.yPos),
      clientX: this.getClientX(object.xPos),
      clientY: this.getClientY(object.yPos),
      pageX: this.getPageX(object.xPos),
      pageY: this.getPageY(object.yPos),
      symbolId: object.symbolId,
      tuioObject: object
    });
  },

  // HELPER
  getElement: function(cursor) {
    return document.elementFromPoint(
      this.getPageX(cursor.xPos),
      this.getPageY(cursor.yPos)
    );
  },

  getPageX: function(point) {
    return this.getClientX(point) + $(window).scrollLeft();
  },

  getPageY: function(point) {
    return this.getClientY(point) + $(window).scrollTop();
  },

  getClientX: function(point) {
    return Math.round( point * $(window).innerWidth() );
  },

  getClientY: function(point) {
    return Math.round( point * $(window).innerHeight() );
  },

  getScreenX: function(point) {
    return Math.round( point * screen.width );
  },

  getScreenY: function(point) {
    return Math.round( point * screen.height );
  },

  // Debug
  updateDebugTouches: function(touch, eventName) {
    if(eventName === 'touchstart') {
      $('body').append('

');
    } else if(eventName === 'touchmove') {
      $('#touch'+touch.identifier).css({
        'top': touch.pageY,
        'left': touch.pageX
      });
    } else if(eventName === 'touchend') {
      $('#touch'+touch.identifier).remove();
    }
  }
});
<commit_msg>change debugTouch to translate<commit_after>import Ember from 'ember';

const {
  Service,
  $,
  run: {
    bind,
    later
  }
} = Ember;

export default Service.extend({
  touches: [],

  setupClient: function() {
    let client = new Tuio.Client({
        host: "http://localhost:5000"
    });
    client.connect();

    // Tuio Cursors
    client.on('addTuioCursor', bind(this, function(cursor) {
      this.createTouchEvent("touchstart", cursor);
    }));

    client.on('updateTuioCursor', bind(this, function(cursor) {
      this.createTouchEvent('touchmove', cursor);
    }));

    client.on('removeTuioCursor', bind(this, function(cursor) {
      this.createTouchEvent('touchend', cursor);
    }));

    // Tuio Objects
    client.on('addTuioObject', bind(this, function(object) {
      this.createObjectEvent("objectadded", object);
    }));

    client.on('updateTuioObject', bind(this, function(object) {
      this.createObjectEvent('objectmoved', object);
    }));

    client.on('removeTuioObject', bind(this, function(object) {
      this.createObjectEvent('objectremoved', object);
    }));
  },

  createTouchEvent: function(eventName, cursor) {
    let touch = this.createTouch(cursor);
    let evt = document.createEvent('Event');

    evt.initEvent(eventName, true, true);
    evt.touches = this.createTouchList(touch, eventName);
    evt.targetTouches = this.getTargetTouches(touch.target);
    evt.changedTouches = [touch];

    touch.target.dispatchEvent(evt);

    // Tuio touch debug mode
    let config = this.container.lookupFactory('config:environment');

    if( config.tuioTouchDebug ) {
      this.updateDebugTouches(touch, eventName);
    }
  },

  createTouch: function(cursor) {
    const data = {
      identifier: cursor.sessionId,
      screenX: this.getScreenX(cursor.xPos),
      screenY: this.getScreenY(cursor.yPos),
      pageX: this.getPageX(cursor.xPos),
      pageY: this.getPageY(cursor.yPos),
      clientX: this.getClientX(cursor.xPos),
      clientY: this.getClientY(cursor.yPos),
      target: this.getElement(cursor)
    };

    return data;
  },

  createTouchList: function(touch, eventName) {
    let touches = this.get('touches');

    if(eventName === 'touchstart') {
      touches.push(touch);
    } else if(eventName === 'touchmove') {
      touches[_.findIndex(touches, 'identifier', touch.identifier)] = touch;
    } else if(eventName === 'touchend') {
      touches.splice(_.findIndex(touches, 'identifier',  touch.identifier), 1);
    }

    return touches;
  },

  getTargetTouches: function(element) {
    var targetTouches = [];
    for (var i = 0; i < this.touches.length; i++) {
      var touch = this.touches[i];
      if (touch.target === element) {
        targetTouches.push(touch);
      }
    }
    return targetTouches;
  },

  // Triggers objects (fiducial) events
  createObjectEvent: function(eventName, object) {
    $(this.getElement(object)).trigger({
      type: eventName,
      screenX: this.getScreenX(object.xPos),
      screenY: this.getScreenY(object.yPos),
      clientX: this.getClientX(object.xPos),
      clientY: this.getClientY(object.yPos),
      pageX: this.getPageX(object.xPos),
      pageY: this.getPageY(object.yPos),
      symbolId: object.symbolId,
      tuioObject: object
    });
  },

  // HELPER
  getElement: function(cursor) {
    return document.elementFromPoint(
      this.getPageX(cursor.xPos),
      this.getPageY(cursor.yPos)
    );
  },

  getPageX: function(point) {
    return this.getClientX(point) + $(window).scrollLeft();
  },

  getPageY: function(point) {
    return this.getClientY(point) + $(window).scrollTop();
  },

  getClientX: function(point) {
    return Math.round( point * $(window).innerWidth() );
  },

  getClientY: function(point) {
    return Math.round( point * $(window).innerHeight() );
  },

  getScreenX: function(point) {
    return Math.round( point * screen.width );
  },

  getScreenY: function(point) {
    return Math.round( point * screen.height );
  },

  // Debug
  updateDebugTouches: function(touch, eventName) {
    if(eventName === 'touchstart') {
      $('body').append('

');
    } else if(eventName === 'touchmove') {
      $('#touch'+touch.identifier).css({
        'transform': 'translate(' + (touch.pageX - 15) + 'px, ' + (touch.pageY - 15) + 'px)'
      });
    } else if(eventName === 'touchend') {
      $('#touch'+touch.identifier).remove();
    }
  }
});
<|endoftext|>


<commit_before>
var simpleboard = require('../'),
    assert = require('assert');

// clone default board

var original = simpleboard.createBoard();
var board = original.clone();
assert.ok(board);
assert.equal(board.getWidth(), 8);
assert.equal(board.getHeight(), 8);

for (var x = 0; x < board.getWidth(); x++)
    for (var y = 0; y < board.getHeight(); y++)
        assert.equal(board.getContent(x, y), null);

// create rectangular board

var original = simpleboard.createBoard(4, 8);
var board = original.clone();
assert.ok(board);
assert.equal(board.getWidth(), 4);
assert.equal(board.getHeight(), 8);

for (var x = 0; x < board.getWidth(); x++)
    for (var y = 0; y < board.getHeight(); y++)
        assert.equal(board.getContent(x, y), null);

// create rectangular board 2

var original = simpleboard.createBoard(6, 3);
var board = original.clone();
assert.ok(board);
assert.equal(board.getWidth(), 6);
assert.equal(board.getHeight(), 3);

for (var x = 0; x < board.getWidth(); x++)
    for (var y = 0; y < board.getHeight(); y++)
        assert.equal(board.getContent(x, y), null);

// clone with content

var original = simpleboard.createBoard();
var content1 = { color: 1 };
var content2 = { color: 2 };

original.putContent(0, 0, content1);
original.putContent(1, 1, content2);

var board = original.clone();

var positions = board.getPositions();

assert.ok(positions);
assert.equal(positions.length, 2);
assert.equal(positions[0].x, 0);
assert.equal(positions[0].y, 0);
assert.equal(positions[0].content, content1);
assert.equal(positions[1].x, 1);
assert.equal(positions[1].y, 1);
assert.equal(positions[1].content, content2);
assert.deepEqual(positions, original.getPositions());

// then alter original board without chaning the cloned one

var content3 = { color: 3 };

original.putContent(2, 2, content3);

assert.equal(board.getPositions().length, 2);
assert.equal(original.getPositions().length, 3);

<commit_msg>Clone tests refactor<commit_after>
const simpleboard = require('../');
const assert = require('assert');

// clone default board

{
    const original = simpleboard.createBoard();
    const board = original.clone();
    assert.ok(board);
    assert.equal(board.getWidth(), 8);
    assert.equal(board.getHeight(), 8);

    for (let x = 0; x < board.getWidth(); x++)
        for (let y = 0; y < board.getHeight(); y++)
            assert.equal(board.getContent(x, y), null);
}

// create rectangular board

{
    const original = simpleboard.createBoard(4, 8);
    const board = original.clone();

    assert.ok(board);
    assert.equal(board.getWidth(), 4);
    assert.equal(board.getHeight(), 8);

    for (let x = 0; x < board.getWidth(); x++)
        for (let y = 0; y < board.getHeight(); y++)
            assert.equal(board.getContent(x, y), null);
}

// create rectangular board 2

{
    const original = simpleboard.createBoard(6, 3);
    const board = original.clone();

    assert.ok(board);
    assert.equal(board.getWidth(), 6);
    assert.equal(board.getHeight(), 3);

    for (let x = 0; x < board.getWidth(); x++)
        for (let y = 0; y < board.getHeight(); y++)
            assert.equal(board.getContent(x, y), null);
}

// clone with content

{
    const original = simpleboard.createBoard();
    const content1 = { color: 1 };
    const content2 = { color: 2 };

    original.putContent(0, 0, content1);
    original.putContent(1, 1, content2);

    const board = original.clone();

    const positions = board.getPositions();

    assert.ok(positions);
    assert.equal(positions.length, 2);
    assert.equal(positions[0].x, 0);
    assert.equal(positions[0].y, 0);
    assert.equal(positions[0].content, content1);
    assert.equal(positions[1].x, 1);
    assert.equal(positions[1].y, 1);
    assert.equal(positions[1].content, content2);
    assert.deepEqual(positions, original.getPositions());
}

// then alter original board without chaning the cloned one

{
    const original = simpleboard.createBoard();
    const content1 = { color: 1 };
    const content2 = { color: 2 };

    original.putContent(0, 0, content1);
    original.putContent(1, 1, content2);

    const board = original.clone();

    const content3 = { color: 3 };

    original.putContent(2, 2, content3);

    assert.equal(board.getPositions().length, 2);
    assert.equal(original.getPositions().length, 3);
}

<|endoftext|>


<commit_before>/*
 * Copyright (c) 2013 - present Adobe Systems Incorporated. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 *
 */

/* eslint-env node */

"use strict";

module.exports = function (grunt) {

    var _       = require("lodash"),
        common  = require("./lib/common")(grunt),
        build   = require("./build")(grunt),
        glob    = require("glob"),
        path    = require("path"),
        exec    = require("child_process").exec,
        _spawn  = require("child_process").spawn;

    function spawn(what, args, options, callback) {
        var child = _spawn(what, args, options);
        child.on("error", function (err) {
            return callback(err, null, err.toString());
        });
        var stdout = [];
        child.stdout.addListener("data", function (buffer) {
            stdout.push(buffer);
        });
        var stderr = [];
        child.stderr.addListener("data", function (buffer) {
            stderr.push(buffer);
        });
        var exitCode;
        child.addListener("exit", function (code) {
            exitCode = code;
        });
        child.addListener("close", function () {
            stderr = Buffer.concat(stderr);
            stdout = Buffer.concat(stdout);
            return callback(exitCode > 0 ? new Error(stderr) : null, stdout, stderr);
        });
        child.stdin.end();
    }

    function runNpmInstall(where, callback) {
        grunt.log.writeln("running npm install --production in " + where);
        exec('npm install --production', { cwd: './' + where }, function (err, stdout, stderr) {
            if (err) {
                grunt.log.error(stderr);
                return callback(stderr);
            }
            if (stdout) { grunt.log.writeln(stdout); }
            grunt.log.writeln("finished npm install --production in " + where);
            if (!stdout || true) {
                // nothing done by npm, skip electron-rebuild
                grunt.log.writeln("skipping electron-rebuild in " + where);
                return callback(null);
            }
            grunt.log.writeln("running electron-rebuild in " + where);
            var npmRebuildPath = path.resolve(
                __dirname,
                '..',
                'node_modules',
                '.bin',
                process.platform === 'win32' ? 'electron-rebuild.cmd' : 'electron-rebuild'
            );
            spawn(npmRebuildPath, [], { cwd: './' + where }, function (err, stdout, stderr) {
                if (err) {
                    if (stderr) {
                        grunt.log.error(stderr);
                    } else {
                        grunt.log.error(err);
                    }
                    grunt.log.writeln("failed electron-rebuild in " + where);
                    return callback(err);
                }
                if (stdout) { grunt.log.writeln(stdout); }
                grunt.log.writeln("finished electron-rebuild in " + where);
                callback(null);
            });
        });
    }

    grunt.registerTask("npm-install", "Install node_modules to the dist folder so it gets bundled with release", function () {
        const npmShrinkwrapJSON = grunt.file.readJSON("npm-shrinkwrap.json");
        common.writeJSON(grunt, "dist/npm-shrinkwrap.json", npmShrinkwrapJSON);

        const packageJSON = grunt.file.readJSON("package.json");
        const appJson = _.pick(packageJSON, [
            'name',
            'productName',
            'description',
            'author',
            'license',
            'homepage',
            'version',
            'apiVersion',
            'issues',
            'repository',
            'dependencies',
            'optionalDependencies'
        ]);
        common.writeJSON(grunt, "dist/package.json", appJson);

        var done = this.async();
        runNpmInstall("dist", function (err) {
            return err ? done(false) : done();
        });
    });

    grunt.registerTask("npm-install-extensions", "Install node_modules for default extensions which have package.json defined", function () {
        var doneWithTask = this.async();
        var globs = [
            "dist/www/+(extensibility|extensions|LiveDevelopment)/**/package.json"
        ];
        var result;
        var doneWithGlob = _.after(globs.length, () => {
            doneWithTask(result);
        });
        globs.forEach(g => {
            glob(g, function (err, files) {
                if (err) {
                    grunt.log.error(err);
                    result = false;
                    return doneWithGlob();
                }
                files = files.filter(function (path) {
                    return path.indexOf("node_modules") === -1;
                });
                var doneWithFile = _.after(files.length, doneWithGlob);
                files.forEach(function (file) {
                    runNpmInstall(path.dirname(file), function (err) {
                        if (err) {
                            result = false;
                        }
                        return doneWithFile();
                    });
                });
            });
        });

    });

};
<commit_msg>electron-rebuild back in<commit_after>/*
 * Copyright (c) 2013 - present Adobe Systems Incorporated. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 *
 */

/* eslint-env node */

"use strict";

module.exports = function (grunt) {

    var _       = require("lodash"),
        common  = require("./lib/common")(grunt),
        build   = require("./build")(grunt),
        glob    = require("glob"),
        path    = require("path"),
        exec    = require("child_process").exec,
        _spawn  = require("child_process").spawn;

    function spawn(what, args, options, callback) {
        var child = _spawn(what, args, options);
        child.on("error", function (err) {
            return callback(err, null, err.toString());
        });
        var stdout = [];
        child.stdout.addListener("data", function (buffer) {
            stdout.push(buffer);
        });
        var stderr = [];
        child.stderr.addListener("data", function (buffer) {
            stderr.push(buffer);
        });
        var exitCode;
        child.addListener("exit", function (code) {
            exitCode = code;
        });
        child.addListener("close", function () {
            stderr = Buffer.concat(stderr);
            stdout = Buffer.concat(stdout);
            return callback(exitCode > 0 ? new Error(stderr) : null, stdout, stderr);
        });
        child.stdin.end();
    }

    function runNpmInstall(where, callback) {
        grunt.log.writeln("running npm install --production in " + where);
        exec('npm install --production', { cwd: './' + where }, function (err, stdout, stderr) {
            if (err) {
                grunt.log.error(stderr);
                return callback(stderr);
            }
            if (stdout) { grunt.log.writeln(stdout); }
            grunt.log.writeln("finished npm install --production in " + where);
            if (!stdout) {
                // nothing done by npm, skip electron-rebuild
                grunt.log.writeln("skipping electron-rebuild in " + where);
                return callback(null);
            }
            grunt.log.writeln("running electron-rebuild in " + where);
            var npmRebuildPath = path.resolve(
                __dirname,
                '..',
                'node_modules',
                '.bin',
                process.platform === 'win32' ? 'electron-rebuild.cmd' : 'electron-rebuild'
            );
            spawn(npmRebuildPath, [], { cwd: './' + where }, function (err, stdout, stderr) {
                if (err) {
                    if (stderr) {
                        grunt.log.error(stderr);
                    } else {
                        grunt.log.error(err);
                    }
                    grunt.log.writeln("failed electron-rebuild in " + where);
                    return callback(err);
                }
                if (stdout) { grunt.log.writeln(stdout); }
                grunt.log.writeln("finished electron-rebuild in " + where);
                callback(null);
            });
        });
    }

    grunt.registerTask("npm-install", "Install node_modules to the dist folder so it gets bundled with release", function () {
        const npmShrinkwrapJSON = grunt.file.readJSON("npm-shrinkwrap.json");
        common.writeJSON(grunt, "dist/npm-shrinkwrap.json", npmShrinkwrapJSON);

        const packageJSON = grunt.file.readJSON("package.json");
        const appJson = _.pick(packageJSON, [
            'name',
            'productName',
            'description',
            'author',
            'license',
            'homepage',
            'version',
            'apiVersion',
            'issues',
            'repository',
            'dependencies',
            'optionalDependencies'
        ]);
        common.writeJSON(grunt, "dist/package.json", appJson);

        var done = this.async();
        runNpmInstall("dist", function (err) {
            return err ? done(false) : done();
        });
    });

    grunt.registerTask("npm-install-extensions", "Install node_modules for default extensions which have package.json defined", function () {
        var doneWithTask = this.async();
        var globs = [
            "dist/www/+(extensibility|extensions|LiveDevelopment)/**/package.json"
        ];
        var result;
        var doneWithGlob = _.after(globs.length, () => {
            doneWithTask(result);
        });
        globs.forEach(g => {
            glob(g, function (err, files) {
                if (err) {
                    grunt.log.error(err);
                    result = false;
                    return doneWithGlob();
                }
                files = files.filter(function (path) {
                    return path.indexOf("node_modules") === -1;
                });
                var doneWithFile = _.after(files.length, doneWithGlob);
                files.forEach(function (file) {
                    runNpmInstall(path.dirname(file), function (err) {
                        if (err) {
                            result = false;
                        }
                        return doneWithFile();
                    });
                });
            });
        });

    });

};
<|endoftext|>


<commit_before>import React, { Component } from 'react';
import Header from './Header.js';
import Button from './Button';
import hackathonImage from '../assets/peoria-hackathon.jpg';

export default class Main extends Component {
  render() {
    return (

						 View the Challenge Statement

Peoria Civic Hackathon 2017 took place in conjunction with Ignite Peoria, an event at the Peoria Civic Center that attracted thousands of visitors to interact with the City's thriving arts and tech community.

What is the 2017 Peoria Civic Hackathon?

Individuals or teams of 2-7 participants will come together to solve a local challenge. Participants will receive a Challenge Statement and access to relevant data sets. They will then utilize this data to create a website, app, or other tool that could improve the lives of people who live, work, and play in the Peoria area.

After the 10 hour hacking session, teams will demo their projects to a panel of judges who will decide which 2 teams created the best solution to the Challenge Statement. The first and runner-up team will receive cash prizes.

Agenda

Friday Night Social

The Fieldhouse Bar & Grill (The Back Room)

6-6:30 PM: Check-in, pick up a name tag, and grab a drink (if you wish)!

6:30-7 PM: Welcome from the City of Peoria and Q & A session about the Hackathon

Gather with your team or find a team if you are looking to join one. Members from the City of Peoria Innovation Team will answer questions about the hackathon.

7-8 PM: Mingle with fellow hackers!

Brainstorm with your team, welcome new team members, or just meet new people and have fun!

Saturday Civic Hackathon

Civic Center Verizon Lobby

8-8:30 AM: Check-in and Breakfast

Stop at the registration table to check-in, grab a name tag, register new team members, and find your team’s work space. Teams will also have the opportunity to move around once the Hackathon period begins.

8:30-9 AM: Opening Remarks from the City of Peoria

This will be the first time that Hackathon participants will hear the challenge statement they will be solving during the 10-hour hack. Also, a word from our sponsors.

9 AM: Registration Closes and HACKATHON BEGINS

12 PM: Lunch

5 PM: Dinner

7 PM: HACKING ENDS

At 7 PM, your project must be submitted and your team must be ready to demonstrate its functionality to the judges panel.

7-7:30 PM: Presentation of demos

Present your projects and see what other teams created!

7:30-7:45 PM: Judging Period

7:45-8:00 PM: Winners Announced and Presentation of Awards

						<Button href="/faq" styleName="goldbutton">Learn More</Button>

    );
  }
}
<commit_msg>updated to past tense<commit_after>import React, { Component } from 'react';
import Header from './Header.js';
import Button from './Button';
import hackathonImage from '../assets/peoria-hackathon.jpg';

export default class Main extends Component {
  render() {
    return (

						 View the Challenge Statement

Peoria Civic Hackathon 2017 took place in conjunction with Ignite Peoria, an event at the Peoria Civic Center that attracted thousands of visitors to interact with the City's thriving arts and tech community.

What was the 2017 Peoria Civic Hackathon?

Individuals or teams of 2-7 participants will come together to solve a local challenge. Participants will receive a Challenge Statement and access to relevant data sets. They will then utilize this data to create a website, app, or other tool that could improve the lives of people who live, work, and play in the Peoria area.

After the 10 hour hacking session, teams will demo their projects to a panel of judges who will decide which 2 teams created the best solution to the Challenge Statement. The first and runner-up team will receive cash prizes.

Agenda

Friday Night Social

The Fieldhouse Bar & Grill (The Back Room)

6-6:30 PM: Check-in, pick up a name tag, and grab a drink (if you wish)!

6:30-7 PM: Welcome from the City of Peoria and Q & A session about the Hackathon

Gather with your team or find a team if you are looking to join one. Members from the City of Peoria Innovation Team will answer questions about the hackathon.

7-8 PM: Mingle with fellow hackers!

Brainstorm with your team, welcome new team members, or just meet new people and have fun!

Saturday Civic Hackathon

Civic Center Verizon Lobby

8-8:30 AM: Check-in and Breakfast

Stop at the registration table to check-in, grab a name tag, register new team members, and find your team’s work space. Teams will also have the opportunity to move around once the Hackathon period begins.

8:30-9 AM: Opening Remarks from the City of Peoria

This will be the first time that Hackathon participants will hear the challenge statement they will be solving during the 10-hour hack. Also, a word from our sponsors.

9 AM: Registration Closes and HACKATHON BEGINS

12 PM: Lunch

5 PM: Dinner

7 PM: HACKING ENDS

At 7 PM, your project must be submitted and your team must be ready to demonstrate its functionality to the judges panel.

7-7:30 PM: Presentation of demos

Present your projects and see what other teams created!

7:30-7:45 PM: Judging Period

7:45-8:00 PM: Winners Announced and Presentation of Awards

						<Button href="/faq" styleName="goldbutton">Learn More</Button>

    );
  }
}
<|endoftext|>


<commit_before>import { PureComponent } from 'react';
import Proptypes from 'prop-types';
import { withRouter } from 'react-router';
import ReactGA from 'react-ga';
import { renderRoutes } from 'react-router-config';
import setupOneSignal from 'utils/one-signal';
import './root-styles.scss';

const { GOOGLE_ANALYTICS_ID, ONE_SIGNAL_ID, NODE_ENV } = process.env || {};

function trackPage(page) {
  ReactGA.set({ page });
  ReactGA.pageview(page);
}

let gaInitialized = false;
function handleTrack(location, prevLocation) {
  if (GOOGLE_ANALYTICS_ID) {
    if (!gaInitialized) {
      ReactGA.initialize(GOOGLE_ANALYTICS_ID);
      gaInitialized = true;
    }
    if (!prevLocation) {
      trackPage(location.pathname);
    } else {
      const page = location.pathname;
      const prevPage = prevLocation.pathname;

      if (page !== prevPage) {
        trackPage(page);
      }
    }
  }
}

class Root extends PureComponent {
  componentDidMount() {
    handleTrack(this.props.location);
    setupOneSignal({ ONE_SIGNAL_ID, env: NODE_ENV });
  }

  componentDidUpdate(prevProps) {
    handleTrack(this.props.location, prevProps.location);
  }

  render() {
    return renderRoutes(this.props.route.routes);
  }
}

Root.propTypes = {
  location: Proptypes.object.isRequired,
  route: Proptypes.object
};

export default withRouter(Root);
<commit_msg>Fix google analytics initialization<commit_after>import { PureComponent } from 'react';
import Proptypes from 'prop-types';
import { withRouter } from 'react-router';
import ReactGA from 'react-ga';
import { renderRoutes } from 'react-router-config';
import setupOneSignal from 'utils/one-signal';
import './root-styles.scss';

// Do not destructure this
const GOOGLE_ANALYTICS_ID = process.env.GOOGLE_ANALYTICS_ID;
const NODE_ENV = process.env.NODE_ENV;
const ONE_SIGNAL_ID = process.env.ONE_SIGNAL_ID;

function trackPage(page) {
  ReactGA.set({ page });
  ReactGA.pageview(page);
}

let gaInitialized = false;
function handleTrack(location, prevLocation) {
  if (GOOGLE_ANALYTICS_ID) {
    if (!gaInitialized) {
      ReactGA.initialize(GOOGLE_ANALYTICS_ID);
      gaInitialized = true;
    }
    if (!prevLocation) {
      trackPage(location.pathname);
    } else {
      const page = location.pathname;
      const prevPage = prevLocation.pathname;

      if (page !== prevPage) {
        trackPage(page);
      }
    }
  }
}

class Root extends PureComponent {
  componentDidMount() {
    handleTrack(this.props.location);
    setupOneSignal({ ONE_SIGNAL_ID, env: NODE_ENV });
  }

  componentDidUpdate(prevProps) {
    handleTrack(this.props.location, prevProps.location);
  }

  render() {
    return renderRoutes(this.props.route.routes);
  }
}

Root.propTypes = {
  location: Proptypes.object.isRequired,
  route: Proptypes.object
};

export default withRouter(Root);
<|endoftext|>


<commit_before>define([
   "underscore", "jquery", "backbone", "sockjs", "auth", "logger", "models"
], function(_, $, Backbone, SockJS, auth, logging, models) {

var logger = new logging.Logger("transport");

var Transport = function(roomId) {
    this._setState("CONNECTING");
    this.stateModels = {};

    this.sock = new SockJS(
        document.location.protocol + "//" +
        document.location.hostname +
        (document.location.port ? ":" + document.location.port : "") +
        "/sock");

    this.sock.onopen = _.bind(function() {
        this._setState("AUTHENTICATING");
        this.sock.send(JSON.stringify({
            type: "auth",
            args: {key: auth.SOCK_KEY, id: auth.USER_ID}
        }));
    }, this);

    this.sock.onmessage = _.bind(function(message) {
        var msg = JSON.parse(message.data);
        logger.debug(msg.timestamp, msg.type, msg.args);
        if (msg.timestamp) {
            this.latest = msg.timestamp;
        }
        // Handle connection negotiation, and delegate state change messages.
        switch (msg.type) {
            case "auth-ack":
                this._setState("JOINING");
                this.send("join", {id: roomId, timestamp: window.INITIAL_DATA_TIMESTAMP});
                break;
            case "auth-err":
                this._setState("AUTH-ERROR");
                break;
            case "join-ack":
                this._setState("JOINED");
                break;
            case "join-err":
                this._setState("JOIN-ERROR");
                break;
            case "state":
                this.handleStateChange(msg.args);
                break;
            case "stale-state-err":
                this._setState("STALE-STATE-ERROR");
                // Instruct clients to refresh their state (typically reloading
                // the page).
                this.trigger("close");
                this.trigger("back-up");
                break;
        }
        // Log all errors.
        if (msg.type.indexOf("-err") != -1) {
            logger.error(message);
        }
        // Trigger all messages, even if we've handled them above.
        this.trigger(msg.type, msg.args);
    }, this);

    // handle losing the connection to the server.
    //
    // Listen for `transport.on('close')` to display a notice to the user when
    // the socket connection has closed for any reason.
    //
    // Listen for `transport.on('back-up')` to take action when the server has
    // come back on line.
    this.sock.onclose = _.bind(function() {
        this._setState("CLOSED");
        this.trigger('close');
        var checkIfServerUp = _.bind(function() {
            $.ajax({
                url: document.location,
                type: "HEAD",
                cache: false,
                success: _.bind(function(msg) { this.trigger("back-up"); }, this),
                error: function(msg) { setTimeout(checkIfServerUp, 1000); }
            });
        }, this);
        // Run the first check at a random interval to hopefully spread out
        // requests to a seiged server trying to restart.
        setTimeout(checkIfServerUp, 1000 * Math.random());

    }, this);
};
_.extend(Transport.prototype, Backbone.Events, {
    _setState: function(state) {
        this.state = state;
        this.trigger("status", this.state);
        // Utility for testing; tests introspect the EVENT_JOIN_INITIALIZED value
        // to know that we have connected.
        if (state === "JOINED") {
            window._JOIN_INITIALIZED = true;
        }
    },
    registerModel: function(name, model) {
        this.stateModels[name] = model;
    },
    unregisterModel: function(name, moel) {
        delete this.stateModels[name];
    },

    // `handleStateChange' takes a set of basic operations (modeled after
    // sharejs's operations, as we might move to that eventually) to mutate the
    // state of backbone models.
    handleStateChange: function(args) {
        // 'args' should look like:
        //
        //  SET a value of a property
        //
        //  {
        //      path: ["event/1", "sessions", 3, "title"],
        //      op: "set",
        //      value: "New title"
        //  }
        //
        //  SET a value of a property with type cast:
        //  {
        //      path: ["event/1", "hoa"],
        //      op: "set",
        //      type: "Session"
        //      value: {id: 4, title: ...}
        //  }
        //
        //  SET multiple properties of a submodel:
        //  {
        //      path: ["event/1", "hoa", null],
        //      op: "set",
        //      value: {id:4, title: ...}
        //  }
        //
        //  INSERT a list member
        //  {
        //      path: ["event/1", "connectedUsers"],
        //      op: "insert",
        //      pos: 4,
        //      value: {userId: 4, displayName: ...}
        //  }
        //
        //  INSERT a model into a sub collection
        //  {
        //      path: ["event/1", "sessions"],
        //      op: "insert",
        //      pos: 4,
        //      type: "Session",
        //      value: {id: blah, etc.}
        //  }
        //
        //  REMOVE a list member
        //  {
        //      path: ["event/1", "connectedUsers"],
        //      op: "delete",
        //      pos: 4 -OR- findWhere: {..details..}
        //  }
        //
        //  REMOVE a member of a collection
        //  {
        //      path: ["event/1", "sessions"],
        //      op: "delete",
        //      pos: 4 -OR- findWhere: {..details..}
        //  }
        //

        var path = _.clone(args.path);
        var model = this.stateModels[path.shift()];
        if (!model) {
            return logger.info("Update for unknown model", args);
        }
        while (path.length > 1) {
            model = model.get(path.shift());
            if (!model) {
                return logger.info("Update for unknown model", args);
            }
        }

        var name = path.pop(); // path should now be empty.
        // The "subject" is the thing that is being mutated.
        var subject = name ? model.get(name) : model;

        // Cast the value into the appropriate type, if any.
        var value;
        if (args.type && args.value != null) {
            switch (args.type) {
                case "User":
                    value = new models.User(args.value);
                    break;
                case "Session":
                    value = new models.Session(args.value);
                    break;
                case "ChatMessage":
                    value = new models.ChatMessage(args.value);
                    break
                default:
                    logger.error("Unknown transport casting type", args.type);
                    return;
            }
        } else {
            value = args.value;
        }

        // Execute operations on the model.
        switch (args.op) {
            case "set":
                if (_.isEmpty(name)) {
                    model.set(value);
                } else {
                    model.set(name, value);
                }
                break;

            case "unset":
                if (!_.isEmpty(name)) {
                    model.unset(name);
                } else {
                    return logger.error("Cannot unset a null name");
                }
                break;

            case "insert":
                // check if this is a collection by looking for an 'add' method.
                if (subject.add) {
                    var options;
                    if (args.pos !== undefined) {
                        options = {at: args.pos}
                    }
                    subject.add(value, options);
                } else {
                    if (args.pos !== undefined) {
                        subject.splice(args.pos, 0, value);
                    } else {
                        subject.push(value);
                    }
                    model.trigger("change:" + name, model, value, {});
                    model.trigger("change", model);
                }
                break;

            case "delete":
                if (args.pos === undefined && args.findWhere === undefined && value === undefined) {
                    return logger.error("`delete` needs either 'pos', 'findWhere', or 'value'");
                }
                // check if this is a collection.
                if (subject.remove && subject.at && subject.findWhere) {
                    if (args.pos !== undefined) {
                        subject.remove(subject.at(args.pos));
                    } else if (args.findWhere !== undefined) {
                        subject.remove(subject.findWhere(args.findWhere));
                    } else if (value !== undefined) {
                        subject.remove(value);
                    }
                } else {
                    if (args.pos !== undefined) {
                        subject.splice(args.pos, 1);
                    } else if (args.findWhere !== undefined) {
                        var val = _.findWhere(subject, args.findWhere);
                        model.set(name, _.without(subject, val));
                    } else if (value !== undefined) {
                        model.set(name, _.without(subject, value));
                    }
                }
                break;
        }

    },
    send: function(type, args) {
        this.sock.send(JSON.stringify({type: type, args: args}));
    }
});

return {Transport: Transport};

});
<commit_msg>Queue messages fired pre-join<commit_after>define([
   "underscore", "jquery", "backbone", "sockjs", "auth", "logger", "models"
], function(_, $, Backbone, SockJS, auth, logging, models) {

var logger = new logging.Logger("transport");

var Transport = function(roomId) {
    this._setState("CONNECTING");
    this.stateModels = {};
    this.queue = [];

    this.sock = new SockJS(
        document.location.protocol + "//" +
        document.location.hostname +
        (document.location.port ? ":" + document.location.port : "") +
        "/sock");

    this.sock.onopen = _.bind(function() {
        this._setState("AUTHENTICATING");
        this.sock.send(JSON.stringify({
            type: "auth",
            args: {key: auth.SOCK_KEY, id: auth.USER_ID}
        }));
    }, this);

    this.sock.onmessage = _.bind(function(message) {
        var msg = JSON.parse(message.data);
        logger.debug(msg.timestamp, msg.type, msg.args);
        if (msg.timestamp) {
            this.latest = msg.timestamp;
        }
        // Handle connection negotiation, and delegate state change messages.
        switch (msg.type) {
            case "auth-ack":
                this._setState("JOINING");
                this.sock.send(JSON.stringify({
                    type: "join",
                    args: {id: roomId, timestamp: window.INITIAL_DATA_TIMESTAMP}
                }));
                break;
            case "auth-err":
                this._setState("AUTH-ERROR");
                break;
            case "join-ack":
                this._setState("JOINED");
                if (this.queue.length) {
                    logger.info("Sending queued messages now");
                    for (var i = 0; i < this.queue.length; i++) {
                        this.sock.send(this.queue[i]);
                    }
                    this.queue = [];
                }
                break;
            case "join-err":
                this._setState("JOIN-ERROR");
                break;
            case "state":
                this.handleStateChange(msg.args);
                break;
            case "stale-state-err":
                this._setState("STALE-STATE-ERROR");
                // Instruct clients to refresh their state (typically reloading
                // the page).
                this.trigger("close");
                this.trigger("back-up");
                break;
        }
        // Log all errors.
        if (msg.type.indexOf("-err") != -1) {
            logger.error(message);
        }
        // Trigger all messages, even if we've handled them above.
        this.trigger(msg.type, msg.args);
    }, this);

    // handle losing the connection to the server.
    //
    // Listen for `transport.on('close')` to display a notice to the user when
    // the socket connection has closed for any reason.
    //
    // Listen for `transport.on('back-up')` to take action when the server has
    // come back on line.
    this.sock.onclose = _.bind(function() {
        this._setState("CLOSED");
        this.trigger('close');
        var checkIfServerUp = _.bind(function() {
            $.ajax({
                url: document.location,
                type: "HEAD",
                cache: false,
                success: _.bind(function(msg) { this.trigger("back-up"); }, this),
                error: function(msg) { setTimeout(checkIfServerUp, 1000); }
            });
        }, this);
        // Run the first check at a random interval to hopefully spread out
        // requests to a seiged server trying to restart.
        setTimeout(checkIfServerUp, 1000 * Math.random());

    }, this);
};
_.extend(Transport.prototype, Backbone.Events, {
    _setState: function(state) {
        this.state = state;
        this.trigger("status", this.state);
        // Utility for testing; tests introspect the EVENT_JOIN_INITIALIZED value
        // to know that we have connected.
        if (state === "JOINED") {
            window._JOIN_INITIALIZED = true;
        }
    },
    registerModel: function(name, model) {
        this.stateModels[name] = model;
    },
    unregisterModel: function(name, moel) {
        delete this.stateModels[name];
    },

    // `handleStateChange' takes a set of basic operations (modeled after
    // sharejs's operations, as we might move to that eventually) to mutate the
    // state of backbone models.
    handleStateChange: function(args) {
        // 'args' should look like:
        //
        //  SET a value of a property
        //
        //  {
        //      path: ["event/1", "sessions", 3, "title"],
        //      op: "set",
        //      value: "New title"
        //  }
        //
        //  SET a value of a property with type cast:
        //  {
        //      path: ["event/1", "hoa"],
        //      op: "set",
        //      type: "Session"
        //      value: {id: 4, title: ...}
        //  }
        //
        //  SET multiple properties of a submodel:
        //  {
        //      path: ["event/1", "hoa", null],
        //      op: "set",
        //      value: {id:4, title: ...}
        //  }
        //
        //  INSERT a list member
        //  {
        //      path: ["event/1", "connectedUsers"],
        //      op: "insert",
        //      pos: 4,
        //      value: {userId: 4, displayName: ...}
        //  }
        //
        //  INSERT a model into a sub collection
        //  {
        //      path: ["event/1", "sessions"],
        //      op: "insert",
        //      pos: 4,
        //      type: "Session",
        //      value: {id: blah, etc.}
        //  }
        //
        //  REMOVE a list member
        //  {
        //      path: ["event/1", "connectedUsers"],
        //      op: "delete",
        //      pos: 4 -OR- findWhere: {..details..}
        //  }
        //
        //  REMOVE a member of a collection
        //  {
        //      path: ["event/1", "sessions"],
        //      op: "delete",
        //      pos: 4 -OR- findWhere: {..details..}
        //  }
        //

        var path = _.clone(args.path);
        var model = this.stateModels[path.shift()];
        if (!model) {
            return logger.info("Update for unknown model", args);
        }
        while (path.length > 1) {
            model = model.get(path.shift());
            if (!model) {
                return logger.info("Update for unknown model", args);
            }
        }

        var name = path.pop(); // path should now be empty.
        // The "subject" is the thing that is being mutated.
        var subject = name ? model.get(name) : model;

        // Cast the value into the appropriate type, if any.
        var value;
        if (args.type && args.value != null) {
            switch (args.type) {
                case "User":
                    value = new models.User(args.value);
                    break;
                case "Session":
                    value = new models.Session(args.value);
                    break;
                case "ChatMessage":
                    value = new models.ChatMessage(args.value);
                    break
                default:
                    logger.error("Unknown transport casting type", args.type);
                    return;
            }
        } else {
            value = args.value;
        }

        // Execute operations on the model.
        switch (args.op) {
            case "set":
                if (_.isEmpty(name)) {
                    model.set(value);
                } else {
                    model.set(name, value);
                }
                break;

            case "unset":
                if (!_.isEmpty(name)) {
                    model.unset(name);
                } else {
                    return logger.error("Cannot unset a null name");
                }
                break;

            case "insert":
                // check if this is a collection by looking for an 'add' method.
                if (subject.add) {
                    var options;
                    if (args.pos !== undefined) {
                        options = {at: args.pos}
                    }
                    subject.add(value, options);
                } else {
                    if (args.pos !== undefined) {
                        subject.splice(args.pos, 0, value);
                    } else {
                        subject.push(value);
                    }
                    model.trigger("change:" + name, model, value, {});
                    model.trigger("change", model);
                }
                break;

            case "delete":
                if (args.pos === undefined && args.findWhere === undefined && value === undefined) {
                    return logger.error("`delete` needs either 'pos', 'findWhere', or 'value'");
                }
                // check if this is a collection.
                if (subject.remove && subject.at && subject.findWhere) {
                    if (args.pos !== undefined) {
                        subject.remove(subject.at(args.pos));
                    } else if (args.findWhere !== undefined) {
                        subject.remove(subject.findWhere(args.findWhere));
                    } else if (value !== undefined) {
                        subject.remove(value);
                    }
                } else {
                    if (args.pos !== undefined) {
                        subject.splice(args.pos, 1);
                    } else if (args.findWhere !== undefined) {
                        var val = _.findWhere(subject, args.findWhere);
                        model.set(name, _.without(subject, val));
                    } else if (value !== undefined) {
                        model.set(name, _.without(subject, value));
                    }
                }
                break;
        }

    },
    send: function(type, args) {
        var msg = JSON.stringify({type: type, args: args});
        if (this.state !== "JOINED") {
            logger.info("Message before joined; queueing");
            this.queue.push(msg);
        } else {
            this.sock.send(msg);
        }
    }
});

return {Transport: Transport};

});
<|endoftext|>