text:
@extends('layout.default')

@section('title', $__t('Chores overview'))
@section('activeNav', 'choresoverview')
@section('viewJsName', 'choresoverview')

@push('pageStyles')
<link href="{{ $U('/node_modules/animate.css/animate.min.css?v=', true) }}{{ $version }}"
	rel="stylesheet">
@endpush

@section('content')

@yield('title')

			<button class="btn btn-outline-dark d-md-none mt-2 float-right order-1 order-md-3"
				type="button"
				data-toggle="collapse"
				data-target="#related-links">

			</button>

					{{ $__t('Journal') }}

			@if(GROCY_FEATURE_FLAG_CHORES_ASSIGNMENTS)

			@endif

					{{ $__t('Clear filter') }}

			<input type="text"
				id="search"
				class="form-control"
				placeholder="{{ $__t('Search') }}">

				 {{ $__t('Status') }}

			<select class="custom-control custom-select"
				id="status-filter">
				<option value="all">{{ $__t('All') }}</option>
				<option value="duesoon">{{ $__t('Due soon') }}</option>
				<option value="overdue">{{ $__t('Overdue') }}</option>
			</select>

	@if(GROCY_FEATURE_FLAG_CHORES_ASSIGNMENTS)

				 {{ $__t('Assignment') }}

			<select class="custom-control custom-select"
				id="user-filter">
				<option></option>
				@foreach($users as $user)
				<option data-user-id="{{ $user->id }}"
					value="xx{{ $user->id }}xx">{{ $user->display_name }}</option>
				@endforeach
			</select>

	@endif

					{{ $__t('Chore') }}
					{{ $__t('Next estimated tracking') }}
					{{ $__t('Last tracked') }}
					{{ $__t('Assigned to') }}
					Hidden status
					Hidden assigned to user id

					@include('components.userfields_thead', array(
					'userfields' => $userfields
					))

				@foreach($currentChores as $curentChoreEntry)

chore_id }}-row"
					class="@if(FindObjectInArrayByPropertyValue($chores, 'id', $curentChoreEntry->chore_id)->period_type !== \Grocy\Services\ChoresService::CHORE_PERIOD_TYPE_MANUALLY && $curentChoreEntry->next_estimated_execution_time < date('Y-m-d H:i:s')) table-danger @elseif(FindObjectInArrayByPropertyValue($chores, 'id', $curentChoreEntry->chore_id)->period_type !== \Grocy\Services\ChoresService::CHORE_PERIOD_TYPE_MANUALLY && $curentChoreEntry->next_estimated_execution_time < date('Y-m-d H:i:s', strtotime('+' . $nextXDays . ' days')))
					table-warning
					@endif">

						chore_id }}"
							data-chore-name="{{ FindObjectInArrayByPropertyValue($chores, 'id', $curentChoreEntry->chore_id)->name }}">

							<button class="btn btn-sm btn-light text-secondary"
								type="button"
								data-toggle="dropdown">

							</button>

								chore_id }}"
									type="button"
									href="#">
									{{ $__t('Chore overview') }}

								chore_id }}">
									{{ $__t('Chore journal') }}

								chore_id }}">
									{{ $__t('Edit chore') }}

								chore_id . '/grocycode?download=true') }}">
									{!! str_replace('grocycode', 'grocycode', $__t('Download %s grocycode', $__t('Chore'))) !!}

								@if(GROCY_FEATURE_FLAG_LABEL_PRINTER)
								chore_id }}"
									type="button"
									href="#">
									{!! str_replace('grocycode', 'grocycode', $__t('Print %s grocycode on label printer', $__t('Chore'))) !!}

								@endif

					chore_id }}">
						{{ FindObjectInArrayByPropertyValue($chores, 'id', $curentChoreEntry->chore_id)->name }}

						@if(FindObjectInArrayByPropertyValue($chores, 'id', $curentChoreEntry->chore_id)->period_type !== \Grocy\Services\ChoresService::CHORE_PERIOD_TYPE_MANUALLY)
						chore_id }}-next-execution-time">{{ $curentChoreEntry->next_estimated_execution_time }}
						<time id="chore-{{ $curentChoreEntry->chore_id }}-next-execution-time-timeago"
							class="timeago timeago-contextual @if($curentChoreEntry->track_date_only == 1) timeago-date-only @endif"
							datetime="{{ $curentChoreEntry->next_estimated_execution_time }}"></time>
						@else
						-
						@endif

						chore_id }}-last-tracked-time">{{ $curentChoreEntry->last_tracked_time }}
						<time id="chore-{{ $curentChoreEntry->chore_id }}-last-tracked-time-timeago"
							class="timeago timeago-contextual @if($curentChoreEntry->track_date_only == 1) timeago-date-only @endif"
							datetime="{{ $curentChoreEntry->last_tracked_time }}"></time>

						chore_id }}-next-execution-assigned-user">
							@if(!empty($curentChoreEntry->next_execution_assigned_to_user_id))
							{{ FindObjectInArrayByPropertyValue($users, 'id', $curentChoreEntry->next_execution_assigned_to_user_id)->display_name }}
							@else
							-
							@endif

					chore_id }}-due-filter-column"
						class="d-none">
						@if(FindObjectInArrayByPropertyValue($chores, 'id', $curentChoreEntry->chore_id)->period_type !== \Grocy\Services\ChoresService::CHORE_PERIOD_TYPE_MANUALLY && $curentChoreEntry->next_estimated_execution_time < date('Y-m-d
							H:i:s'))
							overdue
							@elseif(FindObjectInArrayByPropertyValue($chores, 'id'
							,
							$curentChoreEntry->chore_id)->period_type !== \Grocy\Services\ChoresService::CHORE_PERIOD_TYPE_MANUALLY && $curentChoreEntry->next_estimated_execution_time < date('Y-m-d
								H:i:s',
								strtotime('+'
								.
								$nextXDays
								. ' days'
								)))
								duesoon
								@endif

								@if(!empty($curentChoreEntry->next_execution_assigned_to_user_id))
								xx{{ $curentChoreEntry->next_execution_assigned_to_user_id }}xx

					@endif

					@include('components.userfields_tbody', array(
					'userfields' => $userfields,
					'userfieldValues' => FindAllObjectsInArrayByPropertyValue($userfieldValues, 'object_id', $curentChoreEntry->chore_id)
					))

				@endforeach

				@include('components.chorecard')

				<button type="button"
					class="btn btn-secondary"
					data-dismiss="modal">{{ $__t('Close') }}</button>

@stop


text:
void PinMuxConfig(void)
{
    //
    // Enable Peripheral Clocks
    //
    PRCMPeripheralClkEnable(PRCM_GPIOA3, PRCM_RUN_MODE_CLK);

    //
    // Configure PIN_53 for GPIO Output
    //
    PinTypeGPIO(PIN_53, PIN_MODE_0, false);
    GPIODirModeSet(GPIOA3_BASE, 0x40, GPIO_DIR_MODE_OUT);
}

redpajama_set_name: RedPajamaGithub


text:
<?php

namespace League\Flysystem\Plugin;

class ListPaths extends AbstractPlugin {

    /**
     * Get the method name.
     *
     * @return string
     */
    public function getMethod() {
        return 'listPaths';
    }

    /**
     * List all paths.
     *
     * @param string $directory
     * @param bool   $recursive
     *
     * @return array paths
     */
    public function handle($directory = '', $recursive = false) {
        $result = [];
        $contents = $this->filesystem->listContents($directory, $recursive);

        foreach ($contents as $object) {
            $result[] = $object['path'];
        }

        return $result;
    }

}


text:
package org.ripple.bouncycastle.crypto.engines;

public class AESWrapPadEngine
    extends RFC5649WrapEngine
{
    public AESWrapPadEngine()
    {
        super(new AESEngine());
    }
}


text:
/**
 * @file Sticks.cpp
 */

#include "Sticks.hpp"

using namespace time_literals;
using namespace matrix;

Sticks::Sticks(ModuleParams *parent) :
	ModuleParams(parent)
{};

bool Sticks::checkAndSetStickInputs()
{
	// Sticks are rescaled linearly and exponentially to [-1,1]
	manual_control_setpoint_s manual_control_setpoint;

	if (_manual_control_setpoint_sub.update(&manual_control_setpoint)) {
		// Linear scale
		_positions(0) = manual_control_setpoint.x; // NED x, pitch [-1,1]
		_positions(1) = manual_control_setpoint.y; // NED y, roll [-1,1]
		_positions(2) = -(manual_control_setpoint.z - 0.5f) * 2.f; // NED z, thrust resacaled from [0,1] to [-1,1]
		_positions(3) = manual_control_setpoint.r; // yaw [-1,1]

		// Exponential scale
		_positions_expo(0) = math::expo_deadzone(_positions(0), _param_mpc_xy_man_expo.get(), _param_mpc_hold_dz.get());
		_positions_expo(1) = math::expo_deadzone(_positions(1), _param_mpc_xy_man_expo.get(), _param_mpc_hold_dz.get());
		_positions_expo(2) = math::expo_deadzone(_positions(2), _param_mpc_z_man_expo.get(),  _param_mpc_hold_dz.get());
		_positions_expo(3) = math::expo_deadzone(_positions(3), _param_mpc_yaw_expo.get(),    _param_mpc_hold_dz.get());

		// valid stick inputs are required
		const bool valid_sticks = PX4_ISFINITE(_positions(0))
					  && PX4_ISFINITE(_positions(1))
					  && PX4_ISFINITE(_positions(2))
					  && PX4_ISFINITE(_positions(3));

		_input_available = valid_sticks;

	} else {
		vehicle_status_s vehicle_status;

		if (_vehicle_status_sub.update(&vehicle_status)) {
			if (vehicle_status.rc_signal_lost) {
				_input_available = false;
			}
		}
	}

	if (!_input_available) {
		// Timeout: set all sticks to zero
		_positions.zero();
		_positions_expo.zero();
	}

	return _input_available;
}

void Sticks::limitStickUnitLengthXY(Vector2f &v)
{
	const float vl = v.length();

	if (vl > 1.0f) {
		v /= vl;
	}
}

void Sticks::rotateIntoHeadingFrameXY(Vector2f &v, const float yaw, const float yaw_setpoint)
{
	Vector3f v3(v(0), v(1), 0.f);
	const float yaw_rotate = PX4_ISFINITE(yaw_setpoint) ? yaw_setpoint : yaw;
	v = Vector2f(Dcmf(Eulerf(0.0f, 0.0f, yaw_rotate)) * v3);
}


text:
package com.alamkanak.weekview;

import android.support.annotation.ColorInt;

public interface TextColorPicker {

    @ColorInt
    int getTextColor(WeekViewEvent event);

}


text:
//----------------------------------------------------------------------
//This code is developed as part of the Java CoG Kit project
//The terms of the license can be found at http://www.cogkit.org/license
//This message may not be removed or altered.
//----------------------------------------------------------------------

/*
 * Created on Feb 15, 2005
 */
package org.globus.cog.karajan.futures;

import k.rt.Future;

public interface FutureIterator extends Future {
	boolean hasAvailable();
}


text:
(function(window, undefined) {
    MOTION = function(duration, delay) {
        this._name = '';

        this._playTime = 0;
        this._time = 0;
        this._duration = (typeof duration === 'undefined') ? 0 : duration;
        this._delayTime = (typeof delay === 'undefined') ? 0 : delay;

        this._repeatTime = 0;
        this._repeatDuration = 0;

        this._reverseTime = 0;

        this._timeScale = 1;

        this._isPlaying = false;
        this._isRepeating = false;
        this._isRepeatingDelay = false;
        this._isReversing = false;
        this._isSeeking = false;

        this._hasController = false;
        this._useOnce = MOTION._useOnce;

        this._onStart = null;
        this._onEnd = null;
        this._onUpdate = null;
        this._onRepeat = null;

        MOTION._add(this);
    };

    MOTION.REVISION = '1';

    MOTION.ABSOLUTE = 'absolute';
    MOTION.RELATIVE = 'relative';

    MOTION.LINEAR = 'linear';
    MOTION.COSINE = 'cosine';
    MOTION.CUBIC = 'cubic';
    MOTION.HERMITE = 'hermite';

    MOTION._motions = [];

    MOTION._performance = (typeof window !== undefined && window.performance !== undefined && window.performance.now !== undefined) ? window.performance : Date;
    MOTION._useOnce = false;
    MOTION._time = 0;
    MOTION._valueMode = MOTION.ABSOLUTE;

    MOTION.valueMode = function(mode) {
        MOTION._valueMode = mode;
    }

    MOTION.playAll = function() {
        for (var i = 0; i < MOTION._motions.length; i++)
            MOTION._motions[i].play();
    };

    MOTION.stopAll = function() {
        for (var i = 0; i < MOTION._motions.length; i++)
            MOTION._motions[i].stop();
    };

    MOTION.resumeAll = function() {
        for (var i = 0; i < MOTION._motions.length; i++)
            MOTION._motions[i].resume();
    };

    MOTION.pauseAll = function() {
        for (var i = 0; i < MOTION._motions.length; i++)
            MOTION._motions[i].pause();
    };

    MOTION.seekAll = function(t) {
        for (var i = 0; i < MOTION._motions.length; i++)
            MOTION._motions[i].seek(t);
    };

    MOTION.repeatAll = function(duration) {
        for (var i = 0; i < MOTION._motions.length; i++)
            MOTION._motions[i].repeat(duration);
    };

    MOTION.reverseAll = function() {
        for (var i = 0; i < MOTION._motions.length; i++)
            MOTION._motions[i].reverse();
    };

    MOTION.timeScaleAll = function(t) {
        for (var i = 0; i < MOTION._motions.length; i++)
            MOTION._motions[i].timeScale(t);
    };

    MOTION.useOnce = function(useOnce) {
        MOTION._useOnce = (typeof useOnce !== 'undefined') ? useOnce : true;

        for (var i = 0; i < MOTION._motions.length; i++)
            MOTION._motions[i].useOnce(MOTION._useOnce);
    };

    MOTION._add = function(child) {
        MOTION._motions.push(child);
    };

    MOTION.remove = function(child) {
        var i = MOTION._motions.indexOf(child);
        MOTION._motions.splice(i, 1);
    };

    MOTION.removeAll = function(child) {
        MOTION._motions = [];
    };

    MOTION.update = function(time) {
        if (typeof time == 'undefined') return false;

        MOTION._time = typeof time !== undefined ? time : this._performance.now();

        for (var i = 0; i < MOTION._motions.length; i++)
            MOTION._motions[i]._update();
    };

    MOTION.autoUpdate = function() {
        _isAutoUpdating = true;

        return this;
    };

    MOTION.noAutoUpdate = function() {
        _isAutoUpdating = false;

        return this;
    };

    MOTION.time = function() {
        return MOTION._time;
    }

    MOTION.isPlaying = function() {
        for (var i = 0; i < MOTION._motions.length; i++)
            if (MOTION._motions[i].isPlaying())
                return true;

        return false;
    };

    MOTION.prototype.constructor = MOTION;

    MOTION.prototype.play = function() {
        this.dispatchStartedEvent();

        this.seek(0);
        this.resume();

        this._repeatTime = 0;

        return this;
    };

    MOTION.prototype.stop = function() {
        this.seek(1);
        this.pause();

        this._repeatTime = 0;

        this.dispatchEndedEvent();

        if (this._useOnce && !this._hasController)
            MOTION.remove(this);
        else
            return this;
    };

    MOTION.prototype.pause = function() {
        this._isPlaying = false;

        this._playTime = this._time;

        return this;
    };

    MOTION.prototype.resume = function() {
        this._isPlaying = true;

        this._playTime = MOTION._time - this._playTime;

        return this;
    };

    MOTION.prototype.seek = function(value) {
        this._isPlaying = false;
        this._isSeeking = true;

        this._playTime = (this._delayTime + this._duration) * value;

        this.setTime(this._playTime);

        this.dispatchChangedEvent();

        this._isSeeking = false;

        return this;
    };

    MOTION.prototype.repeat = function(duration) {
        this._isRepeating = true;
        this._repeatDuration = (typeof duration !== 'undefined') ? duration : 0;

        return this;
    };

    MOTION.prototype.noRepeat = function() {
        this._isRepeating = false;
        this._repeatDuration = 0;

        return this;
    };

    MOTION.prototype.reverse = function() {
        this._isReversing = true;

        return this;
    };

    MOTION.prototype.noReverse = function() {
        this._isReversing = false;

        return this;
    };

    MOTION.prototype._update = function(time) {
        if (this._isPlaying) {
            if (typeof time == 'undefined')
                this._updateTime();
            else
                this.setTime(time);

            this.dispatchChangedEvent();

            if (!this._isInsidePlayingTime(this._time) && !this._isInsideDelayingTime(this._time)) {
                this._reverseTime = (this._reverseTime === 0) ? this._duration : 0;

                if (this._isRepeating && (this._repeatDuration === 0 || this._repeatTime < this._repeatDuration)) {
                    this.seek(0);
                    this.resume();

                    this._repeatTime++;

                    if (!this._isRepeatingDelay)
                        this._delayTime = 0;

                    this.dispatchRepeatedEvent();
                } else {

                    this.stop();
                }
            }
        }
    };

    MOTION.prototype._updateTime = function() {
        this._time = (MOTION._time - this._playTime) * this._timeScale;

        if (this._isReversing && this._reverseTime !== 0)
            this._time = this._reverseTime - this._time;
    };

    MOTION.prototype.setName = function(name) {
        this._name = name;

        return this;
    };

    MOTION.prototype.name = MOTION.prototype.setName;

    MOTION.prototype.getName = function() {
        return this._name;
    };

    MOTION.prototype.setTime = function(time) {
        this._time = time * this._timeScale;

        if (this._isReversing && this._reverseTime !== 0) this._time = this._reverseTime - this._time;

        return this;
    };

    MOTION.prototype.getTime = function() {
        return (this._time < this._delayTime) ? 0 : (this._time - this._delayTime);
    };

    MOTION.prototype.time = MOTION.prototype.getTime;

    MOTION.prototype.setTimeScale = function(timeScale) {
        this._timeScale = timeScale;

        return this;
    };

    MOTION.prototype.timeScale = MOTION.prototype.setTimeScale;

    MOTION.prototype.getTimeScale = function() {
        return this._timeScale;
    };

    MOTION.prototype.getPosition = function() {
        return this.getTime() / this._duration;
    };

    MOTION.prototype.position = MOTION.prototype.getPosition;

    MOTION.prototype.setDuration = function(_duration) {
        this._duration = _duration;

        return this;
    };

    MOTION.prototype.getDuration = function() {
        return this._duration;
    };

    MOTION.prototype.duration = MOTION.prototype.getDuration;

    MOTION.prototype.getRepeatTime = function() {
        return this._repeatTime;
    };

    MOTION.prototype.repeatTime = MOTION.prototype.getRepeatTime;

    MOTION.prototype.setDelay = function(delay) {
        this._delayTime = delay;

        return this;
    };

    MOTION.prototype.delay = MOTION.prototype.setDelay;

    MOTION.prototype.noDelay = function() {
        this._delayTime = 0;

        return this;
    };

    MOTION.prototype.getDelay = function() {
        return this._delayTime;
    };

    MOTION.prototype.repeatDelay = function(duration) {
        this.repeat(duration);
        this._isRepeatingDelay = true;

        return this;
    };

    MOTION.prototype.noRepeatDelay = function() {
        this.noRepeat();
        this._isRepeatingDelay = false;

        return this;
    };

    MOTION.prototype.isDelaying = function() {
        return (this._time <= this._delayTime);
    };

    MOTION.prototype.isPlaying = function() {
        return this._isPlaying;
    };

    MOTION.prototype._isInsideDelayingTime = function(value) {
        return (value >= 0 && value < this._delayTime);
    };

    MOTION.prototype._isInsidePlayingTime = function(value) {
        return (value >= this._delayTime && value < this._delayTime + this._duration);
    };

    MOTION.prototype._isAbovePlayingTime = function(value) {
        return value >= this._delayTime + this._duration;
    };

    MOTION.prototype.useOnce = function(useOnce) {
        this._useOnce = (typeof useOnce !== 'undefined') ? useOnce : true;

        return this;
    }

    MOTION._map = function(n, start1, end1, start2, end2) {
        return ((n - start1) / (end1 - start1)) * (end2 - start2) + start2;
    };

    MOTION.prototype.onStart = function(func) {
        this._onStart = func;

        return this;
    };

    MOTION.prototype.onEnd = function(func) {
        this._onEnd = func;

        return this;
    };

    MOTION.prototype.onUpdate = function(func) {
        this._onUpdate = func;

        return this;
    };

    MOTION.prototype.onRepeat = function(func) {
        this._onRepeat = func;

        return this;
    };

    MOTION.prototype.dispatchStartedEvent = function() {
        if (this._onStart)
            this._onStart();
    };

    MOTION.prototype.dispatchEndedEvent = function() {
        if (this._onEnd)
            this._onEnd();
    };

    MOTION.prototype.dispatchChangedEvent = function() {
        if (this._onUpdate)
            this._onUpdate();
    };

    MOTION.prototype.dispatchRepeatedEvent = function() {
        if (this._onRepeat)
            this._onRepeat();
    };

    window.MOTION = MOTION;

    if (typeof Object.create != 'function') {
        Object.create = (function() {
            var Object = function() {};
            return function(prototype) {
                if (arguments.length > 1) {
                    throw Error('Second argument not supported');
                }
                if (typeof prototype != 'object') {
                    throw TypeError('Argument must be an object');
                }
                Object.prototype = prototype;
                var result = new Object();
                Object.prototype = null;
                return result;
            };
        })();
    }
})(window);;(function(MOTION, undefined) {
    MOTION.Easing = function() {};

    MOTION.Easing.Quad = function() {};
    MOTION.Easing.Quad.In = function(t) {
        return (t /= 1) * t;
    };
    MOTION.Easing.Quad.Out = function(t) {
        return -(t /= 1) * (t - 2);
    };
    MOTION.Easing.Quad.InOut = function(t) {
        if ((t /= 1 / 2) < 1) return .5 * t * t;
        return -.5 * ((--t) * (t - 2) - 1);
    };

    MOTION.Easing.Cubic = function() {};
    MOTION.Easing.Cubic.In = function(t) {
        return (t /= 1) * t * t;
    };
    MOTION.Easing.Cubic.Out = function(t) {
        return ((t = t / 1 - 1) * t * t + 1);
    };
    MOTION.Easing.Cubic.InOut = function(t) {
        if ((t /= 1 / 2) < 1) return .5 * t * t * t;
        return .5 * ((t -= 2) * t * t + 2);
    };

    MOTION.Easing.Quart = function() {};
    MOTION.Easing.Quart.In = function(t) {
        return (t /= 1) * t * t * t;
    };
    MOTION.Easing.Quart.Out = function(t) {
        return -((t = t / 1 - 1) * t * t * t - 1);
    };
    MOTION.Easing.Quart.InOut = function(t) {
        if ((t /= 1 / 2) < 1) return .5 * t * t * t * t;
        return -.5 * ((t -= 2) * t * t * t - 2);
    };

    MOTION.Easing.Quint = function() {};
    MOTION.Easing.Quint.In = function(t) {
        return (t /= 1) * t * t * t * t;
    };
    MOTION.Easing.Quint.Out = function(t) {
        return ((t = t / 1 - 1) * t * t * t * t + 1);
    };
    MOTION.Easing.Quint.InOut = function(t) {
        if ((t /= 1 / 2) < 1) return .5 * t * t * t * t * t;
        return .5 * ((t -= 2) * t * t * t * t + 2);
    };

    MOTION.Easing.Sine = function() {};
    MOTION.Easing.Sine.In = function(t) {
        return -Math.cos(t / 1 * (Math.PI / 2)) + 1;
    };
    MOTION.Easing.Sine.Out = function(t) {
        return Math.sin(t / 1 * (Math.PI / 2));
    };
    MOTION.Easing.Sine.InOut = function(t) {
        return -.5 * (Math.cos(Math.PI * t / 1) - 1);
    };

    MOTION.Easing.Expo = function() {};
    MOTION.Easing.Expo.In = function(t) {
        return (t == 0) ? 0 : Math.pow(2, 10 * (t / 1 - 1));
    };
    MOTION.Easing.Expo.Out = function(t) {
        return (t == 1) ? 1 : (-Math.pow(2, -10 * t / 1) + 1);
    };
    MOTION.Easing.Expo.InOut = function(t) {
        if (t == 0) return 0;
        if (t == 1) return 1;
        if ((t /= 1 / 2) < 1) return .5 * Math.pow(2, 10 * (t - 1));
        return .5 * (-Math.pow(2, -10 * --t) + 2);
    };

    MOTION.Easing.Circ = function() {};
    MOTION.Easing.Circ.In = function(t) {
        return -(Math.sqrt(1 - (t /= 1) * t) - 1);
    };
    MOTION.Easing.Circ.Out = function(t) {
        return Math.sqrt(1 - (t = t / 1 - 1) * t);
    };
    MOTION.Easing.Circ.InOut = function(t) {
        if ((t /= 1 / 2) < 1) return -.5 * (Math.sqrt(1 - t * t) - 1);
        return .5 * (Math.sqrt(1 - (t -= 2) * t) + 1);
    };

    MOTION.Easing.Elastic = function() {};
    MOTION.Easing.Elastic.In = function(t) {
        var s = 1.70158;
        var p = 0;
        var a = 1;
        if (t == 0) return 0;
        if ((t /= 1) == 1) return 1;
        if (!p) p = .3;
        if (a < Math.abs(1)) {
            a = 1;
            var s = p / 4;
        } else var s = p / (2 * Math.PI) * Math.asin(1 / a);
        return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * (2 * Math.PI) / p));
    };
    MOTION.Easing.Elastic.Out = function(t) {
        var s = 1.70158;
        var p = 0;
        var a = 1;
        if (t == 0) return 0;
        if ((t /= 1) == 1) return 1;
        if (!p) p = .3;
        if (a < Math.abs(1)) {
            a = 1;
            var s = p / 4;
        } else var s = p / (2 * Math.PI) * Math.asin(1 / a);
        return a * Math.pow(2, -10 * t) * Math.sin((t - s) * (2 * Math.PI) / p) + 1;
    };
    MOTION.Easing.Elastic.InOut = function(t) {
        var s = 1.70158;
        var p = 0;
        var a = 1;
        if (t == 0) return 0;
        if ((t /= 1 / 2) == 2) return 1;
        if (!p) p = (.3 * 1.5);
        if (a < Math.abs(1)) {
            a = 1;
            var s = p / 4;
        } else var s = p / (2 * Math.PI) * Math.asin(1 / a);
        if (t < 1) return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * (2 * Math.PI) / p));
        return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t - s) * (2 * Math.PI) / p) * .5 + 1;
    };

    MOTION.Easing.Back = function() {};
    MOTION.Easing.Back.In = function(t, s) {
        if (s == undefined) s = 1.70158;
        return (t /= 1) * t * ((s + 1) * t - s);
    };
    MOTION.Easing.Back.Out = function(t, s) {
        if (s == undefined) s = 1.70158;
        return ((t = t / 1 - 1) * t * ((s + 1) * t + s) + 1);
    };
    MOTION.Easing.Back.InOut = function(t, s) {
        if (s == undefined) s = 1.70158;
        if ((t /= 1 / 2) < 1) return .5 * (t * t * (((s *= (1.525)) + 1) * t - s));
        return .5 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2);
    };

    MOTION.Easing.Bounce = function() {};
    MOTION.Easing.Bounce.In = function(t) {
        return 1 - MOTION.Easing.Bounce.Out(1 - t, 0);
    };
    MOTION.Easing.Bounce.Out = function(t) {
        if ((t /= 1) < (1 / 2.75)) {
            return (7.5625 * t * t);
        } else if (t < (2 / 2.75)) {
            return (7.5625 * (t -= (1.5 / 2.75)) * t + .75);
        } else if (t < (2.5 / 2.75)) {
            return (7.5625 * (t -= (2.25 / 2.75)) * t + .9375);
        } else {
            return (7.5625 * (t -= (2.625 / 2.75)) * t + .984375);
        }
    };
    MOTION.Easing.Bounce.InOut = function(t) {
        if (t < .5) return MOTION.Easing.Bounce.In(t * 2, 0) * .5;
        return MOTION.Easing.Bounce.Out(t * 2 - 1, 0) * .5 + .5;
    };

    MOTION.Quad = MOTION.Easing.Quad;
    MOTION.Cubic = MOTION.Easing.Cubic;
    MOTION.Quart = MOTION.Easing.Quart;
    MOTION.Quint = MOTION.Easing.Quint;
    MOTION.Sine = MOTION.Easing.Sine;
    MOTION.Expo = MOTION.Easing.Expo;
    MOTION.Circ = MOTION.Easing.Circ;
    MOTION.Elastic = MOTION.Easing.Elastic;
    MOTION.Back = MOTION.Easing.Back;
    MOTION.Bounce = MOTION.Easing.Bounce;
})(MOTION);;(function(MOTION, undefined) {
    MOTION.Interoplation = function() {}

    MOTION.Interoplation.Linear = function(t, y1, y2) {
        // debugger
        if (y1 instanceof Array) {
            y2 = y1[2];
            y1 = y1[1];
        }
        return (y1 * (1 - t) + y2 * t);
    };

    // MOTION.Interoplation.Smoothstep = function(t,y1, y2) {
    //     // return (y1 * (1 - t) + y2 * t);
    //     // ((x) * (x) * (3 - 2 * (x)))
    // };

    MOTION.Interoplation.Cosine = function(t, y1, y2) {
        if (y1 instanceof Array) {
            y2 = y1[2];
            y1 = y1[1];
        }

        var t2 = (1 - PApplet.cos(t * PConstants.PI)) / 2;
        return (y1 * (1 - t2) + y2 * t2);
    };

    MOTION.Interoplation.Cubic = function(t, y0, y1, y2, y3) {
        // debugger
        if (y0 instanceof Array) {
            y1 = y0[1];
            y2 = y0[2];
            y3 = y0[3];
            y0 = y0[0];
        }

        var a0, a1, a2, a3, t2;
        t2 = t * t;
        a0 = y3 - y2 - y0 + y1;
        a1 = y0 - y1 - a0;
        a2 = y2 - y0;
        a3 = y1;
        //http://paulbourke.net/miscellaneous/interpolation/
        //     a0 = -0.5*y0 + 1.5*y1 - 1.5*y2 + 0.5*y3;
        // a1 = y0 - 2.5*y1 + 2*y2 - 0.5*y3;
        // a2 = -0.5*y0 + 0.5*y2;
        // a3 = y1;
        return (a0 * t * t2 + a1 * t2 + a2 * t + a3);
    };

    /*
     * Tension: 1 is high, 0 normal, -1 is low Bias: 0 is even, positive is
     * towards first segment, negative towards the other
     */
    MOTION.Interoplation.Hermite = function(t, y0, y1, y2, y3, tension, bias) {
        if (tension == undefined) tension = 0;
        if (bias == undefined) bias = 0;

        if (y0 instanceof Array) {
            y1 = y0[1];
            y2 = y0[2];
            y3 = y0[3];
            y0 = y0[0];
        }

        var m0, m1, t2, t3;
        var a0, a1, a2, a3;
        t2 = t * t;
        t3 = t2 * t;
        m0 = (y1 - y0) * (1 + bias) * (1 - tension) / 2;
        m0 += (y2 - y1) * (1 - bias) * (1 - tension) / 2;
        m1 = (y2 - y1) * (1 + bias) * (1 - tension) / 2;
        m1 += (y3 - y2) * (1 - bias) * (1 - tension) / 2;
        a0 = 2 * t3 - 3 * t2 + 1;
        a1 = t3 - 2 * t2 + t;
        a2 = t3 - t2;
        a3 = -2 * t3 + 3 * t2;
        return (a0 * y1 + a1 * m0 + a2 * m1 + a3 * y2);
    };

    MOTION.Interoplation.getInterpolationAt = function(t, points, interpolation) {
        if (interpolation == undefined) interpolation = MOTION.Interoplation.Hermite;

        var segmentLength = 1 / points.length
        var segmentIndex = Math.floor(MOTION._map(t, 0, 1, 0, points.length));
        var segmentT = MOTION._map(t, segmentIndex * segmentLength, (segmentIndex + 1) * segmentLength, 0, 1);

        var segmentLength = 1 / points.length
        var segmentIndex = Math.floor(MOTION._map(t, 0, 1, 0, points.length));

        var p1, p2, p3, p4;

        p2 = points[segmentIndex];
        p3 = points[segmentIndex + 1];

        if (segmentIndex == 0) {
            var segmentBegin = points[0];
            var segmentEnd = points[1];
            var segmentSlope = segmentEnd - segmentBegin;
            p1 = segmentEnd - segmentSlope;
        } else
            p1 = points[segmentIndex - 1];

        if (segmentIndex == points.length - 2) {
            var segmentBegin = points[points.length - 2];
            var segmentEnd = points[points.length - 1];
            var segmentSlope = segmentEnd - segmentBegin;
            p4 = segmentEnd + segmentSlope;
        } else
            p4 = points[segmentIndex + 2];

        return interpolation(segmentT, [p1, p2, p3, p4])
    }
})(MOTION);
;(function(MOTION, undefined) {
    MOTION.MotionController = function(motions) {
        MOTION.call(this);

        this._motions = [];
        this._valueMode = null;

        if (motions) this.addAll(motions);
    };

    MOTION.MotionController.prototype = Object.create(MOTION.prototype);
    MOTION.MotionController.prototype.constructor = MOTION.MotionController;

    MOTION.MotionController.prototype.reverse = function() {
        MOTION.prototype.reverse.call(this);

        for (var i = 0; i < this._motions.length; i++)
            this._motions[i].reverse();

        return this;
    };

    MOTION.MotionController.prototype._updateMotions = function() {
        for (var i = 0; i < this._motions.length; i++) {
            var m = this._motions[i];

            if (this._isSeeking) {
                if (m._isInsidePlayingTime(this.getTime()))
                    m.seek(MOTION._map(this.getTime(), 0, m.getDelay() + m.getDuration(), 0, 1));
                else if (m._isAbovePlayingTime(this.getTime()))
                    m.seek(1);
                else
                    m.seek(0);
            } else if (m._isInsidePlayingTime(this.getTime())) {
                if (m.isPlaying())
                    m._update(this.getTime(), false);
                else
                    m.play();
            } else if (m.isPlaying())
                m.stop();
        }
    };

    MOTION.MotionController.prototype._updateDuration = function() {
        for (var i = 0; i < this._motions.length; i++)
            this._duration = Math.max(this._duration, this._motions[i].getDelay() + this._motions[i].getDuration());
    };

    MOTION.MotionController.prototype.getPosition = function() {
        return this.getTime() / this._duration;
    };

    MOTION.MotionController.prototype.get = function(name) {
        if (typeof arguments[0] === 'number') {
            return this._motions[arguments[0]];
        } else if (typeof arguments[0] === 'string') {
            for (var j = 0; j < this._motions.length; j++)
                if (this._motions[j]._name === arguments[0])
                    return this._motions[j];
        }

        return this._motions;
    };

    MOTION.MotionController.prototype.getFirst = function() {
        return this._motions[0];
    }

    MOTION.MotionController.prototype.first = MOTION.MotionController.prototype.getFirst;

    MOTION.MotionController.prototype.getLast = function() {
        return this._motions[this._motions.length];
    }

    MOTION.MotionController.prototype.last = MOTION.MotionController.prototype.getLast;

    MOTION.MotionController.prototype.getCount = function() {
        return this._motions.length;
    };

    MOTION.MotionController.prototype.count = MOTION.MotionController.prototype.getCount;

    MOTION.MotionController.prototype.setEasing = function(easing) {
        this._easing = (typeof easing == 'undefined') ? (function(t) {
            return t;
        }) : easing;

        for (var i = 0; i < this._motions.length; i++) {
            if (this._motions[i] instanceof MOTION.Tween) {
                this._motions[i].easing(this._easing);
            }
        }

        return this;
    };

    MOTION.MotionController.prototype.easing = MOTION.MotionController.prototype.setEasing;

    MOTION.MotionController.prototype.getEasing = function() {
        return this._easing;
    };

    MOTION.MotionController.prototype.add = function(motion) {
        this.insert(motion, 0);
        return this;
    };

    MOTION.MotionController.prototype.insert = function(motion, time) {
        motion.delay(time);
        // if (this._valueMode) motion.valueMode(this._valueMode);
        motion._hasController = true;

        this._motions.push(motion);

        MOTION.remove(motion);

        this._updateDuration();

        return this;
    };

    MOTION.MotionController.prototype.remove = function(motion) {
        var i;

        if (typeof arguments[0] === 'number') {
            i = arguments[0];
        } else if (typeof arguments[0] === 'string') {
            for (var j = 0; j < this._motions.length; j++)
                if (this._motions[j]._name === arguments[0])
                    motion = this._motions[j];
        } else if (typeof arguments[0] === 'object') {
            i = this._motions.indexOf(motion);
        }

        if (i != -1) {
            this._motions.splice(i, 1);
            this._updateDuration();
        }

        return this;
    };

    MOTION.MotionController.prototype.addAll = function(motions) {
        for (var i = 0; i < motions.length; i++)
            this.add(motions[i]);

        return this;
    };

    MOTION.MotionController.prototype.removeAll = function() {
        for (var i = 0; i < this._motions.length; i++)
            this.remove(this._motions[i]);

        return this;
    };

    MOTION.MotionController.prototype.dispatchChangedEvent = function() {
        this._updateMotions();
        MOTION.prototype.dispatchChangedEvent.call(this);
    };
})(MOTION)
;(function(MOTION, undefined) {
    MOTION.Parallel = function(motions) {
        MOTION.MotionController.call(this, name, motions);
    };

    MOTION.Parallel.prototype = Object.create(MOTION.MotionController.prototype);
    MOTION.Parallel.prototype.constructor = MOTION.Parallel;

    MOTION.Parallel.prototype._updateMotions = function() {
        for (var i = 0; i < this._motions.length; i++) {
            var m = this._motions[i];

            if (this._isSeeking) {
                if (m._isInsidePlayingTime(this.getTime()))
                    m.seek(MOTION._map(this.getTime(), 0, m.getDelay() + m.getDuration(), 0, 1));
                else if (m._isAbovePlayingTime(this.getTime()))
                    m.seek(1);
                else
                    m.seek(0);
            } else if (m._isInsidePlayingTime(this.getTime())) {
                if (m.isPlaying())
                    m._update(this.getTime(), false);
                else
                    m.play();
            } else if (m.isPlaying()) {
                if (this._isReversing && i < this._motions.length - 1)
                    m.seek(1);
                else
                    for (var i = 0; i < this._motions.length; i++)
                        this._motions[i].stop();
            }
        }
    };
})(MOTION);
;(function(MOTION, undefined) {

    MOTION._properties = [];

    MOTION.Property = function(object, field, values) {
        this._object = (typeof arguments[0] == 'object') ? object : window;
        this._field = (typeof arguments[1] == 'string') ? field : arguments[0];

        this._order = MOTION._properties.filter(function(d) {
            return d._object == this._object && d._field == this._field;
        }, this).length;

        this._isArray = false;
        this._isPath = false;

        var values = (typeof arguments[1] == 'string') ? values : arguments[1];

        if (values instanceof Array) {
            //it'll either be interpolating between 2 arrays or through multiple points
            if (values.length == 2) {
                //interpolates between a start and end number or number values/properties of a custom color or vector object;
                //(window, 'x', [0,1]) or (window, 'x', [[0,0,0],[1,2,3])
                this._start = values[0];
                this._end = values[1]
                this._isArray = values[0] instanceof Array && values[1] instanceof Array;
            } else {
                if (this._object[this._field] instanceof Array) {
                    this._start = (this._object[this._field].length == 0) ? new Array(values.length) : this._object[this._field];
                    this._end = values;
                    this._isArray = true;
                } else {
                    //interpolates through an array of values as a path
                    //(window, 'x', [0,1,2,3,4])
                    this._start = values[0];
                    this._end = values
                    this._isPath = true;
                }
            }
        } else {
            //it'll either interpolating between a number or number values/properties of a custom color or vector object
            //(window, 'x', 1)
            this._start = (typeof this._object[this._field] == 'undefined') ? 0 : this._object[this._field];
            this._end = values;
        }

        MOTION._properties.push(this);
    };

    MOTION.Property.prototype.update = function(t, easing, interoplation) {
        // if ((t > 0 && t <= 1) || (t == 0 && this._order == 1)) {
        if (this._isArray) {
            var a = [];
            for (var i = 0; i < this._start.length; i++)
                a.push(MOTION.Interoplation.Linear(easing(t), this._start[i], this._end[i]));
            this._object[this._field] = a;
        } else if (this._isPath)
            this._object[this._field] = MOTION.Interoplation.getInterpolationAt(easing(t), this._end, interoplation);
        else
            this._object[this._field] = MOTION.Interoplation.Linear(easing(t), this._start, this._end);
        // } else {}
    };

    MOTION.Property.prototype.getStart = function() {
        return this._start;
    };

    MOTION.Property.prototype.setStart = function(start) {
        if (typeof start === 'undefined') {
            debugger
            if (typeof this._object[this._field] === 'undefined')
                this._start = 0;
            else
                this._start = this._object[this._field];
        } else
            this._start = start;

        return this;
    };

    MOTION.Property.prototype.start = MOTION.Property.prototype.setStart;

    MOTION.Property.prototype.getEnd = function() {
        return this._end;
    };

    MOTION.Property.prototype.setEnd = function(end) {
        this._end = end;
        return this;
    };

    MOTION.Property.prototype.end = MOTION.Property.prototype.setEnd;

    MOTION.Property.prototype.getValue = function() {
        return this._object[this._field];
    };

    MOTION.Property.prototype.value = MOTION.Property.prototype.getValue;
})(MOTION);
;(function(MOTION, undefined) {
    MOTION.Sequence = function(children) {
        MOTION.MotionController.call(this, children);

        this._current = null;
        this._currentIndex = 0;
    };

    MOTION.Sequence.prototype = Object.create(MOTION.MotionController.prototype);
    MOTION.Sequence.prototype.constructor = MOTION.Sequence;

    MOTION.Sequence.prototype.add = function(child) {
        MOTION.MotionController.prototype.insert.call(this, child, this._duration);

        return this;
    };

    MOTION.Sequence.prototype.getCurrentIndex = function() {
        return this._currentIndex;
    };

    MOTION.Sequence.prototype.currentIndex = MOTION.Sequence.prototype.getCurrentIndex;

    MOTION.Sequence.prototype.getCurrent = function() {
        return this._current;
    };

    MOTION.Sequence.prototype.current = MOTION.Sequence.prototype.getCurrent;

    MOTION.MotionController.prototype.dispatchStartedEvent = function() {
        this._current = null;
        this._currentIndex = 0;

        MOTION.prototype.dispatchStartedEvent.call(this)
    };

    MOTION.MotionController.prototype.dispatchChangedEvent = function() {
        this._updateMotions();

        if (this._isPlaying) {
            for (var i = 0; i < this._motions.length; i++) {
                var c = this._motions[i];

                if (c._isInsidePlayingTime(this._time)) {
                    this._currentIndex = i;
                    this._current = c;

                    break;
                }
            }
        }

        MOTION.prototype.dispatchChangedEvent.call(this)
    };

    MOTION.MotionController.prototype.dispatchRepeatedEvent = function() {
        this._current = null;
        this._currentIndex = 0;

        MOTION.prototype.dispatchRepeatedEvent.call(this)
    };
})(MOTION);
;(function(MOTION, undefined) {
    MOTION.Keyframe = function(time, motions) {
        MOTION.MotionController.call(this, motions)
        this.delay(time);
    };

    MOTION.Keyframe.prototype = Object.create(MOTION.MotionController.prototype);
    MOTION.Keyframe.prototype.constructor = MOTION.Keyframe;

    MOTION.Timeline = function() {
        MOTION.MotionController.call(this);
    };

    MOTION.Timeline.prototype = Object.create(MOTION.MotionController.prototype);
    MOTION.Timeline.prototype.constructor = MOTION.Timeline;

    MOTION.Timeline.prototype.play = function(time) {
        if (typeof arguments[0] == 'undefined') {
            MOTION.MotionController.prototype.play.call(this);
        } else if (typeof arguments[0] == 'number') {
            this.seek(arguments[0] / this._duration);
            this.resume();
        } else if (typeof arguments[0] == 'string') {
            for (var i = 0; i < this._motions.length; i++)
                if (this._motions[i]._name === arguments[0]) {
                    this.seek(this._motions[i] / this._duration);
                    this.resume();
                }
        } else if (typeof arguments[0] == 'object') {
            this.seek(arguments[0].getPlayTime() / this._duration);
            this.resume();
        }

        return this;
    };

    MOTION.Timeline.prototype.stop = function(time) {
        if (typeof arguments[0] == 'undefined')
            MOTION.MotionController.prototype.stop.call(this);
        else if (typeof arguments[0] == 'number') {
            this.seek(arguments[0] / this._duration);
            this.pause();
        } else if (typeof arguments[0] == 'string') {
            for (var i = 0; i < this._motions.length; i++)
                if (this._motions[i]._name === arguments[0]) {
                    this.seek(this._motions[i] / this._duration);
                    this.pause();
                }
        } else if (typeof arguments[0] == 'object') {
            this.seek(arguments[0].getPlayTime() / this._duration);
            this.pause();
        }

        return this;
    };

    MOTION.Timeline.prototype.add = function(motion, time) {
        if (motion instanceof MOTION.Keyframe) {
            if (typeof time == 'undefined')
                this.insert(motion, motion.getDelay());
            else
                this.insert(motion, time);
        } else {
            if (typeof time == 'undefined') {
                this._motions[this._motions.indexOf(c)] = c;
            } else {
                var key = time + '';

                var k = new MOTION.Keyframe(time + '');
                k.add(motion);

                this.insert(k, time);
            }
        }

        return this;
    };

    MOTION.Timeline.prototype.getCurrent = function(index) {
        var current = [];

        for (var i = 0; i < this._motions.length; i++)
            if (this._motions[i].isInsidePlayingTime(this.getTime()))
                current.push(this._motions[i]);

        if (current.length == 0)
            return null;
        else
            return current;
    };

    MOTION.Timeline.prototype.current = MOTION.Timeline.prototype.getCurrent
})(MOTION)
;(function(MOTION, undefined) {
    MOTION.Tween = function(object, property, end, duration, delay, easing) {
        this._properties = [];;

        this._easing = function(t) {
            return t;
        };
        this._interpolation = MOTION.Interoplation.Hermite;

        if (typeof arguments[0] === 'object') {
            MOTION.call(this, arguments[3], arguments[4]);
            this.addProperty(arguments[0], arguments[1], arguments[2]);

            if (typeof arguments[5] !== 'undefined')
                this.setEasing(arguments[5]);
        } else if (typeof arguments[0] === 'string') {
            MOTION.call(this, arguments[2], arguments[3]);
            this.addProperty(arguments[0], arguments[1]);

            if (typeof arguments[4] !== 'undefined')
                this.setEasing(arguments[4]);
        } else {
            MOTION.call(this, arguments[0], arguments[1]);

            if (typeof arguments[2] !== 'undefined')
                this.setEasing(arguments[2]);
        }
    };

    MOTION.Tween.prototype = Object.create(MOTION.prototype);
    MOTION.Tween.prototype.constrctor = MOTION.Tween;

    MOTION.Tween.prototype._updateProperties = function() {
        for (var i = 0; i < this._properties.length; i++)
            this._properties[i].update(this.position(), this._easing, this._interpolation);
    };

    MOTION.Tween.prototype.addProperty = function(object, property, values) {
        if (arguments[0] instanceof MOTION.Property)
            this._properties.push(arguments[0]);
        else if (typeof arguments[0] === 'object')
            this._properties.push(new MOTION.Property(object, property, values));
        else
            this._properties.push(new MOTION.Property(arguments[0], arguments[1]));

        return this;
    };

    MOTION.Tween.prototype.add = MOTION.Tween.prototype.addProperty;

    MOTION.Tween.prototype.remove = function(child) {
        var i;

        if (typeof arguments[0] === 'number') {
            i = arguments[0];
        } else if (typeof arguments[0] === 'name') {
            i = this._properties.indexOf(property);
        } else if (typeof arguments[0] === 'object') {
            for (var j = 0; j < this._properties.length; j++)
                if (this._properties[j]._field === arguments[0])
                    j = i;
        }

        if (i && i != -1)
            this._properties.splice(i, 1);

        return this;
    };

    MOTION.Tween.prototype.getProperty = function() {
        if (typeof arguments[0] === 'string') {
            for (var j = 0; j < this._properties.length; j++)
                if (this._properties[j]._field === arguments[0])
                    return this._properties[j];
        } else if (typeof arguments[0] === 'number') {
            return this._properties[arguments[0]];
        } else {
            return this._properties;
        }
    };

    MOTION.Tween.prototype.get = MOTION.Tween.prototype.getProperty;

    MOTION.Tween.prototype.getFirstProperty = function() {
        return this._properties[0];
    }

    MOTION.Tween.prototype.first = MOTION.Tween.prototype.getFirstProperty;

    MOTION.Tween.prototype.getLastProperty = function() {
        return this._properties[this._properties.length];
    }

    MOTION.Tween.prototype.last = MOTION.Tween.prototype.getLastProperty;

    MOTION.Tween.prototype.getCount = function() {
        return this._properties.length;
    };

    MOTION.Tween.prototype.count = MOTION.Tween.prototype.getCount;

    MOTION.Tween.prototype.setEasing = function(easing) {
        this._easing = easing;
        return this;
    };

    MOTION.Tween.prototype.easing = MOTION.Tween.prototype.setEasing;

    MOTION.Tween.prototype.getEasing = function() {
        return this._easing;
    };

    MOTION.Tween.prototype.noEasing = function() {
        this._easing = function(t) {
            return t;
        };
        return this;
    };

    MOTION.Tween.prototype.setInterpolation = function(inpterpolation) {
        this._interpolation = inpterpolation;
        return this;
    };

    MOTION.Tween.prototype.interpolation = MOTION.Tween.prototype.setInterpolation;

    MOTION.Tween.prototype.getInterpolation = function() {
        return this._interpolation;
    };

    MOTION.Tween.prototype.relative = function() {
        this.setValueMode(MOTION.RELATIVE);

        return this;
    };

    MOTION.Tween.prototype.absolute = function() {
        this.setValueMode(MOTION.ABSOLUTE);

        return this;
    };

    MOTION.Tween.prototype.setValueMode = function(_valueMode) {
        this._valueMode = _valueMode;

        return this;
    };

    MOTION.Tween.prototype.valueMode = MOTION.Tween.prototype.setValueMode;

    MOTION.Tween.prototype.getValueMode = function() {
        return this._valueMode;
    };

    MOTION.Tween.prototype.dispatchStartedEvent = function() {
        if (this._valueMode == MOTION.RELATIVE)
            for (var i = 0; i < this._properties.length; i++)
                this._properties[i].setStart();

        if (this._onStart)
            this._onStart(this._object);
    };

    MOTION.Tween.prototype.dispatchEndedEvent = function() {
        if (this._onEnd)
            this._onEnd(this._object);
    };

    MOTION.Tween.prototype.dispatchChangedEvent = function() {
        this._updateProperties();

        if (this._onUpdate)
            this._onUpdate(this._object);
    };

    MOTION.Tween.prototype.dispatchRepeatedEvent = function() {
        if (this._onRepeat)
            this._onRepeat(this._object);
    };
})(MOTION);


text:
//
//  THControllerCategories.h
//  Lumumba
//
//  Created by Benjamin Schüttler on 11.11.09.
//  Copyright 2011 Rogue Coding. All rights reserved.
//

#import <Cocoa/Cocoa.h>

//
// NSArray
//

@interface NSArray (THControllerCategories)
+(NSArray *)arrayForSorting:(NSString *)sortDescription;
-(NSArray *)sortedBy:(NSString *)sortDescription;

/**
 * Will return an NSIndexPath containing all NSNumber intValues
 * that are part of this array
 * a length of 0 will return nil
 */
-(NSIndexPath *)indexPath;
@end

//
// NSArrayController
//

@interface NSArrayController (THControllerCategories)
@property (nonatomic, assign) NSString *sorting;
// this is actually a fake and will simply return self.filterPredicate
-(NSPredicate *)filterWithFormat;
-(void)setFilterWithFormat:(NSString *)format,...;
@end

//
// NSTreeController
//

@interface NSTreeController (THControllerCategories)
@property (nonatomic, assign) NSString *sorting;
// this is actually a fake and will simply return self.filterPredicate
-(NSPredicate *)fetchWithFormat;
-(void)setFetchWithFormat:(NSString *)format,...;

-(id)objectAtPath:(NSIndexPath *)path;
-(NSTreeNode *)nodeAtPath:(NSIndexPath *)path;

-(NSTreeNode *)selectedAncestorOf:(NSTreeNode *)node;

-(BOOL)isPathSelected:(NSIndexPath *)path;
-(void)setSelectionIndexPath:(NSIndexPath *)path toState:(BOOL)selected;
-(void)toggleSelectionIndexPath:(NSIndexPath *)path;
-(void)addSelectionIndexDroppingChildren:(NSIndexPath *)path;

-(NSArray *)selectedNodesBelowNode:(NSTreeNode *)node;
-(NSArray *)selectedPathsBelowPath:(NSIndexPath *)path;

@end

//
// NSIndexPath
//

@interface NSIndexPath (THControllerCategories)

-(NSIndexPath *)subpathWithRange:(NSRange)range;
-(NSIndexPath *)subpathToIndex:(NSUInteger)index;
-(NSIndexPath *)subpathFromIndex:(NSUInteger)index;

-(NSIndexPath *)mostCommonPathWithPath:(NSIndexPath *)path;

-(BOOL)isAncestorOf:(NSIndexPath *)path;
-(BOOL)isDescendantOf:(NSIndexPath *)path;

-(NSString *)path;

@end

//
// NSTreeNode
//

@interface NSTreeNode (THControllerCategories)

-(NSTreeNode *)mostCommonNodeWithNode:(id)node;
-(BOOL)isAncestorOfNode:(NSTreeNode *)node;
-(BOOL)isDescendantOfNode:(NSTreeNode *)node;
-(NSArray *)lineage;
-(NSUInteger)depth;
-(NSTreeNode *)ancestorAtDepth:(NSUInteger)depth;

@end


text:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <fragment
        android:name="edu.purdue.app.map.GoogleMapFragment"
        android:id="@+id/bus_fragment_googlemapfragment"
        android:layout_width="match_parent"
        android:layout_height="500dp"
        android:layout_alignParentTop="true"
    />

    <fragment
        android:name="edu.purdue.app.bus.BusListFragment"
        android:id="@+id/bus_fragment_buslistfragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/bus_fragment_googlemapfragment"
        android:layout_alignParentBottom="true"
    />

</RelativeLayout>


text:
import argparse
import requests
from furl import furl
from bs4 import BeautifulSoup
import sys

import logging

logging.basicConfig(filename='example.log', format='%(asctime)s - %(levelname)s - %(message)s')

logger = logging.getLogger()
logger.setLevel(logging.INFO)

class Settings:
    URL = 'http://local.wordpress.dev/'
    USERNAME = 'admin'
    PASSWORD = 'password'

class WPException(Exception):
    pass

class WPAdmin:
    def _check_multisite_allowed(self, session):
        MULTISITE_URL = Settings.URL + 'wp-admin/network/'
        response = session.get(MULTISITE_URL)
        soup = BeautifulSoup(response.content.decode('utf-8'), 'html.parser')
        errors = soup.select('#error-page')

        if errors:
            #raise WPException(errors[0].text.strip())
            raise WPException(2)

    def _login(self, session):

        LOGIN_URL = Settings.URL + 'wp-login.php'
        response = session.post(LOGIN_URL, data={
                'log': Settings.USERNAME,
                'pwd': Settings.PASSWORD,
                },
            timeout=10
        )

        soup = BeautifulSoup(response.content.decode('utf-8'), 'html.parser')

        errors = soup.select('#login_error')
        if errors:
            # raise WPException('Couldn\'t authenticate. ' + errors[0].text.strip())
            raise WPException(3)

        footer_notes = soup.select('#footer-thankyou')
        if len(footer_notes) != 1 or footer_notes[0].text != 'Thank you for creating with WordPress.':
            # raise WPException('Something went wrong. Did you specify the Settings.URL correctly?')
            raise WPException(4)

        self._check_multisite_allowed(session)

        logger.info('Admin logged in.')

    def add(self, site_id):
        ADD_SITE_FORM_URL = Settings.URL + 'wp-admin/network/site-new.php'
        ADD_SITE_URL = Settings.URL + 'wp-admin/network/site-new.php?action=add-site'
        with requests.Session() as s:
            self._login(s)

            response = s.get(ADD_SITE_FORM_URL)

            soup = BeautifulSoup(response.content.decode('utf-8'), 'html.parser')
            wpnonce = soup.select('#_wpnonce_add-blog')[0]['value']

            response = s.post(ADD_SITE_URL, data={
                '_wpnonce_add-blog': wpnonce,
                'blog[domain]': site_id,
                'blog[title]': 'Generated Blog Title',
                'blog[email]': '{}@example.com'.format(site_id),
            })

            soup = BeautifulSoup(response.content.decode('utf-8'), 'html.parser')
            errors = soup.select('#error-page')

            if errors:
                # raise WPException('Couldn\'t create a new site. ' + errors[0].text.strip())
                raise WPException(5)

        logger.info('Site "{}" created.'.format(site_id))

    def _find_delete_url(self, session, site_id):
        response = session.get(Settings.URL + 'wp-admin/network/sites.php')
        soup = BeautifulSoup(response.content.decode('utf-8'), 'html.parser')

        for elem in soup.find_all('td', class_='column-blogname'):
            domain, _, site_id2 = elem.find_all('a')[0].text.partition('/')

            if site_id2 == site_id:
                break
        else:
            raise WPException(7)
            # raise WPException('Couldn\'t delete {}, delete link not found.'.format(site_id))

        return elem.find_all('span', class_='delete')[0].find_all()[0]['href']

    def delete(self, site_id):
        with requests.Session() as s:
            self._login(s)
            data = furl(self._find_delete_url(s, site_id))

            DELETE_URL = Settings.URL + '/wp-admin/network/sites.php?action=deleteblog'
            response = s.post(DELETE_URL, data={
                'action': 'deleteblog',
                'id':  data.args['id'],
                '_wpnonce': data.args['_wpnonce'],
            })

        logger.info('Site "{}" deleted.'.format(site_id))

    def generate_data(self, site_id):

        def func(session, url, data, success_message):
            response = session.post(url, data=data)

            soup = BeautifulSoup(response.content.decode('utf-8'), 'html.parser')

            success = soup.select('.demodatasuccess')
            if len(success) != 1 or success_message not in success[0].text:
                # raise WPException('Something went wrong, success message "{}" not found.'.format(success_message))
                raise WPException(6)

        with requests.Session() as s:
            self._login(s)

            GENERATE_USERS_URL = Settings.URL + site_id + '/wp-admin/ms-admin.php?page=demodata_form&create=users'
            func(s, GENERATE_USERS_URL, {
                'users': '20',
                'useremailtemplate': 'demouser[x]@local.wordpress.dev',
                'create': 'users',
                'action': 'create',
            }, 'demo users created')

            GENERATE_CATEGORIES_URL = Settings.URL + site_id + '/wp-admin/ms-admin.php?page=demodata_form&create=categories'
            func(s, GENERATE_CATEGORIES_URL, {
                'maxblogcategories': '10',
                'create': 'categories',
                'action': 'create',
            }, 'demo categories created')

            GENERATE_POSTS_URL = Settings.URL + site_id + '/wp-admin/ms-admin.php?page=demodata_form&create=posts'
            func(s, GENERATE_POSTS_URL, {
                'maxblogposts': '50',
                'maxpostlength': '10',
                'create': 'posts',
                'action': 'create',
            }, 'demo posts created')

            GENERATE_PAGES_URL = Settings.URL + site_id + '/wp-admin/ms-admin.php?page=demodata_form&create=pages'
            func(s, GENERATE_PAGES_URL, {
                'maxpages': '25',
                'maxtoppages': '5',
                'maxpageslevels': '3',
                'maxpagelength': '10',
                'create': 'pages',
                'action': 'create',
            }, 'demo pages created')

            GENERATE_COMMENTS_URL = Settings.URL + site_id + '/wp-admin/ms-admin.php?page=demodata_form&create=comments'
            func(s, GENERATE_COMMENTS_URL, {
                'maxcomments': '10',
                'create': 'comments',
                'action': 'create',
            }, 'demo comments created')

            GENERATE_LINKS_URL = Settings.URL + site_id + '/wp-admin/ms-admin.php?page=demodata_form&create=links'
            func(s, GENERATE_LINKS_URL, {
                'maxbloglinks': '25',
                'create': 'links',
                'action': 'create',
            }, 'demo links created')

        logger.info('Data for site "{}" generated.'.format(site_id))

def get_arguments():
    parser = argparse.ArgumentParser()
    parser.add_argument('-u', '--url', required=True, help='Site Address (URL)')

    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument(
        '-c', '--create',
        action='store_true',
        help='Create a new site with given URL')
    group.add_argument(
        '-d', '--delete',
        action='store_true',
        help='Delete the site with given URL')
    group.add_argument(
        '-g', '--generate_data',
        action='store_true',
        help='Generate data for the site with given URL')

    args = parser.parse_args()
    return args.url, args.create, args.delete, args.generate_data

def run(url, create, delete, generate):
    wp_admin = WPAdmin()
    try:
        if create:
            wp_admin.add(url)
        elif delete:
            wp_admin.delete(url)
        elif generate:
            wp_admin.generate_data(url)
        exit(0)
    except WPException as e:
        logger.error(e)
        print(e)
        exit(e)
    except Exception as e:
        logger.error(e, exc_info=True)
        exit(8)

if __name__ == '__main__':
    run(*get_arguments())


text:
var eventList;
var nbeText1 = "";
var nbeText2 = "";
var groupList = [];

function sizeBySeverity() {
   NV.treemap.set('sizeOption', 'cvss');
}

function sizeByCriticality() {
   NV.treemap.set('sizeOption', 'criticality');
}

function sizeByCount() {
   NV.treemap.set('sizeOption', 'value');
}

function colorBySeverity() {
   NV.treemap.set('colorOption', 'cvss');
}

function colorByCriticality() {
   NV.treemap.set('colorOption', 'criticality');
}

function colorByCount() {
   NV.treemap.set('colorOption', 'count');
}

// Sets the main Backbone data model
function setNBEData(dataset){
  NV.nessus.setData(dataset);
}

function handleGroupAdd(){
  var start = $("#ipStart").val();
  var end = $("#ipEnd").val();
  var groupName = $("#groupName").val();
  var weight = $("#defaultWeight").val();
  var newGroup = {"start":start, "end":end, "groupName":groupName, "weight":weight};
  groupList.push(newGroup);

  // notify hierarchy model of groups changes
  NV.nessus.trigger('change:groups');

  // if group added, enabled all buttons
  d3.select('#coloroptions').selectAll('button').attr('disabled', null);
  d3.select('#sizeoptions').selectAll('button').attr('disabled', null);
  // also remove title
  d3.select('#coloroptions').selectAll('button').attr('title', null);
  d3.select('#sizeoptions').selectAll('button').attr('title', null);

  updateCurrentGroupTable(); //why is this needed here?  Somehow affects table re-drawing?
}

// remove loaded data
function clearData() {
  eventList = {};
  groupList = [];

  $('#file-list').html('');
  $('#file-reset-btn').addClass('disabled');
  $('#file-continue-btn').addClass('disabled');

  $('#groups-continue-btn').addClass('disabled');

  $('#groupsTabNav').addClass('disabled');
  $('#visTabNav').addClass('disabled');
}

function dataTabActive() {
  $('#file-status-msg').html('');
  $('#file-status').alert('close');
}

function dataLoaded(fileName) {
  $('#groupsTabNav').removeClass('disabled');
  $('#visTabNav').removeClass('disabled');

  $('#file-status').css('display', 'block');
  $('#file-status').addClass('alert-success');
  $('#file-status-msg').html(' ' + fileName + ' loaded in browser.');

  $('#file-list').append('  ' + fileName);

  $('#file-reset-btn').removeClass('disabled');
  $('#file-continue-btn').removeClass('disabled');
}

function groupsTabActive(){
  if( ! eventList ) {
    updateEventList();
  }
  updateCurrentGroupTable();

  $('#visTabNav').removeClass('disabled');
  $('#groups-continue-btn').removeClass('disabled');
}

function visTabActive(){
  //in case groups tab did not set it.
  if( ! eventList ) {
    updateEventList();
    updateCurrentGroupTable();
  }

  // show tooltip intro
  $('#helpIcon').tipsy('show');
  setTimeout(function() {
    $('#helpIcon').tipsy('hide');
  }, 2500);

  NV.resize();
}

function updateEventList(){
  var nbeItems1 = "",
      nbeItems2 = "";

  nbeItems1 = vparse.parseNBEFile( nbeText1 );
  eventList = nbeItems1;
  console.log( nbeItems1 );
  if(nbeText2.trim() !== ""){
    NV.nessus.set('isChangeVis', true);
    nbeItems2 = vparse.parseNBEFile( nbeText2 );
    eventList = mergeNBEs(nbeItems1, nbeItems2);
  }
}

function updateCurrentGroupTable(){

  if( ! eventList ){ //have never seen this happen, but leaving in for now --mdi
    console.log("updateCurrentGroupTable needed to update eventList: this is unexpected.");
    updateEventList();
  }

  //build default group list
//  console.log("event list is " + JSON.stringify(eventList));
  var ips = findIPsInList(eventList);
  //console.log("have these IPs: " + JSON.stringify(ips));

  //add to the default group.
  //NOTE we are building this list of groups:ips, instead of the two seperate lists we already have, so that all machines in a group are next to each other in the table.
  groups = {};
  for( var i=0; i < ips.length; i++ ){
    var groupName = findGroupName(ips[i]);
    var weight = 1; //default
    for(var j=0; j<groupList.length; j++){
      if(groupList[j].groupName === groupName){
        weight = groupList[j].weight;
      }
    }
    var entry = {"ip": ips[i], "weight": weight};
//    console.log("found that ip " + ips[i] + " is in group " + groupName);
    if( !groups[groupName] ){
      groups[groupName] = [];
    }
    groups[groupName].push(entry);
  }

  //console.log("current group list is: " + JSON.stringify(groups) );

  //display the (default) groups and weights for all machines.
  buildTable(groups);

  //add group name to item in crossfilter
  eventList = addGroupInfoToData(groups, eventList);

  // sets the backbone data model
  setNBEData(eventList);
}

//this will be somewhat slow, O(n^2), no easy way around it.
//note this will modify nbeItems2 and not modify nbeItems1.  Can change this if needed later.
function mergeNBEs(nbeItems1, nbeItems2){

  var result = []
    , openItems = 0
    , changedItems = 0
    , found
    , i
    , j
    , item;

  function compareEntries(a, b){ //true if equal, false if not
    if(a.ip === b.ip && a.vulnid === b.vulnid && a.vulntype === b.vulntype && a.cvss === b.cvss && a.port === b.port){
      return true;
    }
    else {
      return false;
    }
  }

  //iterate through first list, find matching items in second list. mark them 'open' in result and remove from second list.
  //if no matching item is found, mark it as 'changed' in first.
  for(i=0; i<nbeItems1.length; i++){
    found = false;
    for(j=0; j<nbeItems2.length; j++){
      if( compareEntries(nbeItems1[i], nbeItems2[j]) ){
        found = true;
        item = nbeItems1[i];
        item.state = 'open';
        result.push(item);
        nbeItems2.splice(j, 1);
        openItems +=1;
        break;
      }
    }
    if(found === false){
      item = nbeItems1[i];
      item.state = 'fixed';
      result.push(item);
      changedItems +=1;
    }
  }
  console.log("open items: " + openItems);
  console.log("changed items: " + changedItems);
  console.log("new items: " + nbeItems2.length);
  //handle items remaining in second list. (append to result list, mark 'new')
  while( nbeItems2.length > 0){
    item = nbeItems2.pop();
    item.state = 'new';
    result.push(item);
  }

  return result;
}

function findIPsInList(eventList){
  var ips = {}; //making a fake set here.
  console.log(eventList[0]);
  for( var i=0; i < eventList.length; i++ ){
    ips[eventList[i].ip] = true;
  }
  ips = Object.keys(ips); //only need to keep this
  return ips;
}

function findGroupName(ip){
  var testAddr = ip.split('.');
  if( testAddr.length !== 4){
    throw "address of " + groupList[i].end + " is invalid";
  }

  function isAfter(start, test){ //after or equal will return true
    for(var i=0; i<4; i++){
      if(parseInt(start[i], 10) > parseInt(test[i], 10)){
        return false;
      }
    }
    return true;
  }

  function isBefore(end, test){ //before or equal
    return isAfter(test, end);
  }

  //grouplist contains a list of {start, end, groupName, weight}
  for(var i=0; i<groupList.length; i++){
    var start = groupList[i].start.split('.');
    if( start.length !== 4){
      throw "start address of " + groupList[i].start + " is invalid";
    }
    var end = groupList[i].end.split('.');
    if( end.length !== 4){
      throw "end address of " + groupList[i].end + " is invalid";
    }
    //console.log(groupList[i].groupName + ": isAfter(" + groupList[i].start + ", " + ip + ") returned " + isAfter(start, testAddr) );
    //console.log(groupList[i].groupName + ": isBefore(" + groupList[i].end  + ", " + ip + ") returned " + isBefore(end, testAddr) );
    if( isAfter(start, testAddr) && isBefore(end, testAddr) ){
      return groupList[i].groupName;
    }
  }
  return "none"; //not found; "none" is the default label for table.
}

function addGroupInfoToData(groups, eventList){
  var events = []
    , ips = {} //make a map of ip:{group, weight}
    , groupNames = Object.keys(groups)
    , i
    , j;
  for( j=0; j < groupNames.length; j++ ){
    var machines = groups[groupNames[j]];
    for( i=0; i < machines.length; i++ ){
      ips[machines[i].ip] = {"group": groupNames[j], "weight": machines[i].weight};
    }
  }

  for( i=0; i < eventList.length; i++ ){
    events.push(eventList[i]);
    events[i].group  = ips[eventList[i].ip].group;
    events[i].criticality = parseInt(ips[eventList[i].ip].weight, 10);
  }
  return events;
}

function buildTable(groups){
  $('#currentGroupTable').select('tbody').html("");
  var weightSelector, row;
  var groupNames = Object.keys(groups);
  for( var j=0; j < groupNames.length; j++ ){
    var machines = groups[groupNames[j]];
    for( var i=0; i < machines.length; i++ ){
      weightSelector = '<select class="weightSelect" id="weightSelect' + machines[i].ip.split('.').join('_') + '"';
      weightSelector += '><option value="1">1 (lowest)</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10 (highest)</option></select>';
      row = '
';
      row += ''+ groupNames[j] +'	'+ machines[i].ip +'	';
      row += ''+ weightSelector +'	';
      row += '
';
      $('#currentGroupTable').select('tbody').append(row);
      $('#weightSelect' + machines[i].ip.split('.').join('_') ).children().eq(machines[i].weight-1).attr("selected","selected");
      //console.log( $('#weightSelect' + machines[i]["ip"].split('.').join('_') ).select('option').eq(machines[i]["weight"]-1).html() );
    }
  }
}

//rather loosely based on these examples http://www.html5rocks.com/en/tutorials/file/dndfiles/
var handleFileSelect = function (element) {

  var holder = document.getElementById(element);

  if (typeof window.FileReader === 'undefined') {
    $('#file-status').css('display', 'block');
    $('#file-status').addClass('alert-error');
    console.log('FileReader not supported');
  }
  else {
    console.log('FileReader supported');
  }

  holder.ondragover = function () {
    this.className = 'hover';
    return false;
  };

  holder.ondragend = function () {
    this.className = '';
    return false;
  };

  holder.ondrop = function (e) {
    this.className = '';
    e.preventDefault();

    var files = e.dataTransfer.files,
        f = files[0];

    holder.loadFile(f);

    return false;
  };

  function getExtension(filename) {
    var i = filename.lastIndexOf('.');
    return (i < 0) ? '' : filename.substr(i);
  }

  var isResult2 = function(line){
    return(line.split("|")[0] === "results");
  };

  var parseNessusResult2 = function(nessStr){
    var scoreReg2 = /CVSS Base Score : (\d+\.\d+)/;

    nessStr = nessStr.replace(/\=/g, "=");
    nessStr = nessStr.replace(/\>/g, ">");
    nessStr = nessStr.replace(/\</g, "<");
    nessStr = nessStr.replace(/\&/g, "&");

    var portReg2 = /\D+ \((\d{1,7})\D+\)/;
    var splitNess = nessStr.split("|");
    var ip2 = splitNess[2];
    var code2 = parseFloat(splitNess[4]);
    var holeNote2 = splitNess[5];

    var info2 = splitNess[6].split('Synopsis :');
    var synopsis2 = info2[1].split('Description :');
    var description2 = synopsis2[1].split('Solution :');
    var solution2 = description2[1].split('Risk factor :');
    var risk_factor2 = solution2[1].split('CVSS Base Score :');
    if(solution2[1].split('CVSS Base Score :').length == 1) {
      risk_factor2 = solution2[1].split('Plugin output :');
      risk_factor2 = risk_factor2[0].substring(4, risk_factor2[0].length).split('\\n')[0];
    } else {
      risk_factor2 = risk_factor2[0].substring(4, risk_factor2[0].length).split(' /')[0];
    }
    if(scoreReg2.test(nessStr)){
      var score2 = parseFloat(scoreReg2.exec(nessStr)[1]);
    }
    else{
      var score2 = 1.0;
    }
    if(portReg2.test(nessStr)){
      var port2 = parseFloat(portReg2.exec(nessStr)[1]);
    }
    else{
      var port2 = 'notes';
    }

    return {"ip": (ip2 === undefined ? "" : ip2),
      "vulnid": (isNaN(code2) ? 0 : code2),
      "vulntype":(holeNote2 === undefined ? "" : holeNote2.indexOf('Note') !== -1 ? 'note' : 'hole'),
      "cvss": score2,
      "value": 1,
      "port":port2,
      "synopsis": synopsis2[0].substring(4, synopsis2[0].length - 4),
      "description": description2[0].substring(4, description2[0].length - 4),
      "solution": solution2[0].substring(4, solution2[0].length - 4),
      "title": "title",
      "risk_factor": risk_factor2,
      "severity": holeNote2.substring(9, holeNote2.length).toLowerCase(),
      "family": "nofamily"};
  };

  function create_nessus2(reports2) {
    var ip = '0';
    var string_report = '<NessusClientData_v2>';
    reports2.forEach(function(report) {
      if (ip == '0' || ip != report.ip) {
        if (ip != '0') {
          string_report += '</ReportHost><ReportHost name="'+ report.ip + '">';
        } else{
          string_report += '<Report><ReportHost name="'+ report.ip + '">';
          ip = report.ip;
        }
      }
      string_report += '<ReportItem';
      string_report += (report.port) ? ' port="' + report.port + '"':'';
      string_report += (report.vulnid) ? ' pluginID="' + report.vulnid + '"':'';
      string_report += '>';
      string_report += (report.cvss) ? '<cvss_base_score>' + report.cvss + '</cvss_base_score>':'';
      string_report += (report.synopsis) ? '<synopsis>' + report.synopsis + '</synopsis>':'';
      string_report += (report.description) ? '<description>' + report.description + '</description>':'';
      string_report += (report.solution) ? '<solution>' + report.solution + '</solution>':'';
      string_report += (report.risk_factor) ? '<risk_factor>' + report.risk_factor + '</risk_factor>':'';
      string_report += (report.title) ? '<title>' + report.title + '</title>':'';
      string_report += '</ReportItem>';
    });
    string_report += '</ReportHost></Report></NessusClientData_v2>';
    return string_report;
  }

  var parseNBEFile2 = function(nbe){
    var lines = nbe.split("\n");
    var currentTime = 0;
    var returnArray = new Array(2);

    for(var i = 0; i < lines.length; i++){
      if(isResult2(lines[i])){
        returnArray.push(parseNessusResult2(lines[i]));
      }
    }
    return returnArray.filter(function(){return true});//removes nulls
  };

  holder.loadFile = function(f) {
    console.log('called loadFile');

    var reader = new FileReader();

    reader.readAsText(f); //utf-8 encoding is default

    reader.onload = function (event) {
      // if this is the first file, load to nbeText1
      // if not, then any additional files are saved to nbeText2
      if ( nbeText1.trim() === '' ) {
        if(getExtension(f.name) == '.nbe') {
          console.log("V1 File Detected, Converting it to V2");
          var reports2 = parseNBEFile2(event.target.result);
          nbeText1 = create_nessus2(reports2);
        } else{
          nbeText1 = event.target.result;
        }
      }
      else {
        if(getExtension(f.name) == '.nbe') {
          console.log("V1 File Detected, Converting it to V2");
          var reports2 = parseNBEFile2(event.target.result);
          nbeText2 = create_nessus2(reports2);
        } else{
          nbeText2 = event.target.result;
        }
      }
      console.log('Loaded file: ' + f.name);

      console.log(getExtension(f.name));
      dataLoaded(f.name);
    };

    reader.onerror = function() {
      $('#file-status').css('display', 'block');
      $('#file-status').addClass('alert-error');
      $('#file-status-msg').html('could not parse file ' + f.name + ' as text');
    };

    return false;
  };

};

// load a sample data file
$( '#sampleDataLink' ).click(function() {
  var file = 'data/testNetworkOpen.nessus';
  $.get(file, function (data) {
    nbeText1 = data;
    dataLoaded('Sample file: ' + file);
  });
});

// initialization
$().ready(function () {

  // help tooltips
  $('.hierarchyHelp').tipsy({trigger: 'manual', fade: true, gravity: 'w', offset: -60});
  $('.treemapHelp').tipsy({trigger: 'manual', fade: true, gravity: 's', offset: -250});
  $('.nessusHelp').tipsy({trigger: 'manual', fade: true, gravity: 'e'});
  $('.filterHelp').tipsy({trigger: 'manual', fade: true, gravity: 's'});

  // help tooltips trigger
  $('#helpIcon').tipsy({trigger: 'manual', fade: true, gravity: 'e'});

  $('#helpIcon').on('mouseover', function(){
    $('.help').tipsy('show');
  });
  $('#helpIcon').on('mouseout', function(){
    $('.help').tipsy('hide');
  });

  // set up file drag and drop
  handleFileSelect('file-drop');

  // reset the data
  $('#file-reset-btn').click(function(event) {
    window.location.reload();
    //clearData();
  });

  // data tab events
  $('#dataTab1Link').click(function(event) {
    event.preventDefault();
    dataTabActive();
  });

  // group tab events
  $('#file-continue-btn').click(function(event) {
    $('#groupsTabLink').tab('show');
    groupsTabActive();
  });

  $('#groupsTabLink').click(function(event) {
    event.preventDefault();
    groupsTabActive();
  });

  // set up button for adding new group
  $('#addGroupBtn').click(function(event) {
    handleGroupAdd();
  });

  // vis tab events
  $('#visTabLink').on('show', function(){
    setTimeout(function() {
      visTabActive();
    }, 100);
  });

  $('#groups-continue-btn').click(function(event) {
    $('#visTabLink').tab('show');
  });

  // auto-triggers the 'show' event
  $('#visTabLink').click(function(event) {
    event.preventDefault();
  });

});