text:
var UI = {};

UI.Element = function () {};

UI.Element.prototype = {

	setId: function ( id ) {

		this.dom.id = id;

		return this;

	},

	setClass: function ( name ) {

		this.dom.className = name;

		return this;

	},

	setStyle: function ( style, array ) {

		for ( var i = 0; i < array.length; i ++ ) {

			this.dom.style[ style ] = array[ i ];

		}

	},

	setDisabled: function ( value ) {

		this.dom.disabled = value;

		return this;

	},

	setTextContent: function ( value ) {

		this.dom.textContent = value;

		return this;

	}

};

// properties

var properties = [ 'position', 'left', 'top', 'right', 'bottom', 'width', 'height', 'border', 'borderLeft',
'borderTop', 'borderRight', 'borderBottom', 'borderColor', 'display', 'overflow', 'margin', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'padding', 'paddingLeft', 'paddingTop', 'paddingRight', 'paddingBottom', 'color',
'backgroundColor', 'opacity', 'fontSize', 'fontWeight', 'textTransform', 'cursor' ];

properties.forEach( function ( property ) {

	var method = 'set' + property.substr( 0, 1 ).toUpperCase() + property.substr( 1, property.length );

	UI.Element.prototype[ method ] = function () {

		this.setStyle( property, arguments );
		return this;

	};

} );

// events

var events = [ 'KeyUp', 'KeyDown', 'MouseOver', 'MouseOut', 'Click', 'Change' ];

events.forEach( function ( event ) {

	var method = 'on' + event;

	UI.Element.prototype[ method ] = function ( callback ) {

		this.dom.addEventListener( event.toLowerCase(), callback.bind( this ), false );

		return this;

	};

} );

// Panel

UI.Panel = function ( dom ) {

	UI.Element.call( this );

	if ( !dom ) {
		dom = document.createElement( 'div' );
		dom.className = 'Panel';
	}
	//TODO: else both classes?

	this.dom = dom;

	return this;
};

UI.Panel.prototype = Object.create( UI.Element.prototype );

UI.Panel.prototype.add = function () {

	for ( var i = 0; i < arguments.length; i ++ ) {

		this.dom.appendChild( arguments[ i ].dom );

	}

	return this;

};

UI.Panel.prototype.remove = function () {

	for ( var i = 0; i < arguments.length; i ++ ) {

		this.dom.removeChild( arguments[ i ].dom );

	}

	return this;

};

UI.Panel.prototype.clear = function () {

	while ( this.dom.children.length ) {

		this.dom.removeChild( this.dom.lastChild );

	}

};

// Text

UI.Text = function ( text ) {

	UI.Element.call( this );

	var dom = document.createElement( 'span' );
	dom.className = 'Text';
	dom.style.cursor = 'default';
	dom.style.display = 'inline-block';
	dom.style.verticalAlign = 'middle';

	this.dom = dom;
	this.setValue( text );

	return this;

};

UI.Text.prototype = Object.create( UI.Element.prototype );

UI.Text.prototype.setValue = function ( value ) {

	if ( value !== undefined ) {

		this.dom.textContent = value;

	}

	return this;

};

// Input

UI.Input = function () {

	UI.Element.call( this );

	var scope = this;

	var dom = document.createElement( 'input' );
	dom.className = 'Input';
	dom.style.padding = '2px';
	dom.style.border = '1px solid #ccc';

	dom.addEventListener( 'keydown', function ( event ) {

		event.stopPropagation();

	}, false );

	this.dom = dom;

	return this;

};

UI.Input.prototype = Object.create( UI.Element.prototype );

UI.Input.prototype.getValue = function () {

	return this.dom.value;

};

UI.Input.prototype.setValue = function ( value ) {

	this.dom.value = value;

	return this;

};

// TextArea

UI.TextArea = function () {

	UI.Element.call( this );

	var scope = this;

	var dom = document.createElement( 'textarea' );
	dom.className = 'TextArea';
	dom.style.padding = '2px';
	dom.style.border = '1px solid #ccc';

	dom.addEventListener( 'keydown', function ( event ) {

		event.stopPropagation();

	}, false );

	this.dom = dom;

	return this;

};

UI.TextArea.prototype = Object.create( UI.Element.prototype );

UI.TextArea.prototype.getValue = function () {

	return this.dom.value;

};

UI.TextArea.prototype.setValue = function ( value ) {

	this.dom.value = value;

	return this;

};

// Select

UI.Select = function () {

	UI.Element.call( this );

	var scope = this;

	var dom = document.createElement( 'select' );
	dom.className = 'Select';
	dom.style.width = '10em';
	dom.style.height = '2em';
	dom.style.border = '0px';
	dom.style.padding = '0px';

	this.dom = dom;

	return this;

};

UI.Select.prototype = Object.create( UI.Element.prototype );

UI.Select.prototype.setMultiple = function ( boolean ) {

	this.dom.multiple = boolean;

	return this;

};

UI.Select.prototype.setOptions = function ( options ) {

	var selected = this.dom.value;

	while ( this.dom.children.length > 0 ) {

		this.dom.removeChild( this.dom.firstChild );

	}

	for ( var key in options ) {

		var option = document.createElement( 'option' );
		option.value = key;
		option.innerHTML = options[ key ];
		this.dom.appendChild( option );

	}

	this.dom.value = selected;

	return this;

};

UI.Select.prototype.getValue = function () {

	return this.dom.value;

};

UI.Select.prototype.setValue = function ( value ) {

	this.dom.value = value;

	return this;

};

// FancySelect

UI.FancySelect = function () {

	UI.Element.call( this );

	var scope = this;

	var dom = document.createElement( 'div' );
	dom.className = 'Panel FancySelect';
	dom.tabIndex = 0;	// keyup event is ignored without setting tabIndex

	// Broadcast for object selection after arrow navigation
	var changeEvent = document.createEvent('HTMLEvents');
	changeEvent.initEvent( 'change', true, true );

	// Prevent native scroll behavior
	dom.addEventListener( 'keydown', function (event) {

		switch ( event.keyCode ) {
			case 38: // up
			case 40: // down
				event.preventDefault();
				event.stopPropagation();
				break;
		}

	}, false);

	// Keybindings to support arrow navigation
	dom.addEventListener( 'keyup', function (event) {

		switch ( event.keyCode ) {
			case 38: // up
			case 40: // down
				scope.selectedIndex += ( event.keyCode == 38 ) ? -1 : 1;

				if ( scope.selectedIndex >= 0 && scope.selectedIndex < scope.options.length ) {

					// Highlight selected dom elem and scroll parent if needed
					scope.setValue( scope.options[ scope.selectedIndex ].value );

					// Invoke object/helper/mesh selection logic
					scope.dom.dispatchEvent( changeEvent );

				}

				break;
		}
	}, false);

	this.dom = dom;

	this.options = [];
	this.selectedIndex = -1;
	this.selectedValue = null;

	return this;

};

UI.FancySelect.prototype = Object.create( UI.Element.prototype );

UI.FancySelect.prototype.setOptions = function ( options ) {

	var scope = this;

	var changeEvent = document.createEvent( 'HTMLEvents' );
	changeEvent.initEvent( 'change', true, true );

	while ( scope.dom.children.length > 0 ) {

		scope.dom.removeChild( scope.dom.firstChild );

	}

	scope.options = [];

	for ( var i = 0; i < options.length; i ++ ) {

		var option = options[ i ];

		var div = document.createElement( 'div' );
		div.className = 'option';
		div.innerHTML = option.html;
		div.value = option.value;
		scope.dom.appendChild( div );

		scope.options.push( div );

		div.addEventListener( 'click', function ( event ) {

			scope.setValue( this.value );
			scope.dom.dispatchEvent( changeEvent );

		}, false );

	}

	return scope;

};

UI.FancySelect.prototype.getValue = function () {

	return this.selectedValue;

};

UI.FancySelect.prototype.setValue = function ( value ) {

	for ( var i = 0; i < this.options.length; i ++ ) {

		var element = this.options[ i ];

		if ( element.value === value ) {

			element.classList.add( 'active' );

			// scroll into view

			var y = element.offsetTop - this.dom.offsetTop;
			var bottomY = y + element.offsetHeight;
			var minScroll = bottomY - this.dom.offsetHeight;

			if ( this.dom.scrollTop > y ) {

				this.dom.scrollTop = y

			} else if ( this.dom.scrollTop < minScroll ) {

				this.dom.scrollTop = minScroll;

			}

			this.selectedIndex = i;

		} else {

			element.classList.remove( 'active' );

		}

	}

	this.selectedValue = value;

	return this;

};

// Checkbox

UI.Checkbox = function ( boolean ) {

	UI.Element.call( this );

	var scope = this;

	var dom = document.createElement( 'input' );
	dom.className = 'Checkbox';
	dom.type = 'checkbox';

	this.dom = dom;
	this.setValue( boolean );

	return this;

};

UI.Checkbox.prototype = Object.create( UI.Element.prototype );

UI.Checkbox.prototype.getValue = function () {

	return this.dom.checked;

};

UI.Checkbox.prototype.setValue = function ( value ) {

	if ( value !== undefined ) {

		this.dom.checked = value;

	}

	return this;

};

// Color

UI.Color = function () {

	UI.Element.call( this );

	var scope = this;

	var dom = document.createElement( 'input' );
	dom.className = 'Color';
	dom.style.width = '4em';
	dom.style.height = '2em';
	dom.style.border = '0px';
	dom.style.padding = '0px';
	dom.style.backgroundColor = 'transparent';

	try {

		dom.type = 'color';
		dom.value = '#ffffff';

	} catch ( exception ) {}

	this.dom = dom;

	return this;

};

UI.Color.prototype = Object.create( UI.Element.prototype );

UI.Color.prototype.getValue = function () {

	return this.dom.value;

};

UI.Color.prototype.getHexValue = function () {

	return parseInt( this.dom.value.substr( 1 ), 16 );

};

UI.Color.prototype.setValue = function ( value ) {

	this.dom.value = value;

	return this;

};

UI.Color.prototype.setHexValue = function ( hex ) {

	this.dom.value = "#" + ( '000000' + hex.toString( 16 ) ).slice( -6 );

	return this;

};

// Number

UI.Number = function ( number ) {

	UI.Element.call( this );

	var scope = this;

	var dom = document.createElement( 'input' );
	dom.className = 'Number';
	dom.value = '0.00';

	dom.addEventListener( 'keydown', function ( event ) {

		event.stopPropagation();

		if ( event.keyCode === 13 ) dom.blur();

	}, false );

	this.min = - Infinity;
	this.max = Infinity;

	this.precision = 2;
	this.step = 1;

	this.dom = dom;
	this.setValue( number );

	var changeEvent = document.createEvent( 'HTMLEvents' );
	changeEvent.initEvent( 'change', true, true );

	var distance = 0;
	var onMouseDownValue = 0;

	var pointer = new THREE.Vector2();
	var prevPointer = new THREE.Vector2();

	var onMouseDown = function ( event ) {

		event.preventDefault();

		distance = 0;

		onMouseDownValue = parseFloat( dom.value );

		prevPointer.set( event.clientX, event.clientY );

		document.addEventListener( 'mousemove', onMouseMove, false );
		document.addEventListener( 'mouseup', onMouseUp, false );

	};

	var onMouseMove = function ( event ) {

		var currentValue = dom.value;

		pointer.set( event.clientX, event.clientY );

		distance += ( pointer.x - prevPointer.x ) - ( pointer.y - prevPointer.y );

		var number = onMouseDownValue + ( distance / ( event.shiftKey ? 5 : 50 ) ) * scope.step;

		dom.value = Math.min( scope.max, Math.max( scope.min, number ) ).toFixed( scope.precision );

		if ( currentValue !== dom.value ) dom.dispatchEvent( changeEvent );

		prevPointer.set( event.clientX, event.clientY );

	};

	var onMouseUp = function ( event ) {

		document.removeEventListener( 'mousemove', onMouseMove, false );
		document.removeEventListener( 'mouseup', onMouseUp, false );

		if ( Math.abs( distance ) < 2 ) {

			dom.focus();
			dom.select();

		}

	};

	var onChange = function ( event ) {

		var number = parseFloat( dom.value );

		dom.value = isNaN( number ) === false ? number : 0;

	};

	var onFocus = function ( event ) {

		dom.style.backgroundColor = '';
		dom.style.borderColor = '#ccc';
		dom.style.cursor = '';

	};

	var onBlur = function ( event ) {

		dom.style.backgroundColor = 'transparent';
		dom.style.borderColor = 'transparent';
		dom.style.cursor = 'col-resize';

	};

	dom.addEventListener( 'mousedown', onMouseDown, false );
	dom.addEventListener( 'change', onChange, false );
	dom.addEventListener( 'focus', onFocus, false );
	dom.addEventListener( 'blur', onBlur, false );

	return this;

};

UI.Number.prototype = Object.create( UI.Element.prototype );

UI.Number.prototype.getValue = function () {

	return parseFloat( this.dom.value );

};

UI.Number.prototype.setValue = function ( value ) {

	if ( value !== undefined ) {

		this.dom.value = value.toFixed( this.precision );

	}

	return this;

};

UI.Number.prototype.setRange = function ( min, max ) {

	this.min = min;
	this.max = max;

	return this;

};

UI.Number.prototype.setPrecision = function ( precision ) {

	this.precision = precision;

	return this;

};

// Integer

UI.Integer = function ( number ) {

	UI.Element.call( this );

	var scope = this;

	var dom = document.createElement( 'input' );
	dom.className = 'Number';
	dom.value = '0.00';

	dom.addEventListener( 'keydown', function ( event ) {

		event.stopPropagation();

	}, false );

	this.min = - Infinity;
	this.max = Infinity;

	this.step = 1;

	this.dom = dom;
	this.setValue( number );

	var changeEvent = document.createEvent( 'HTMLEvents' );
	changeEvent.initEvent( 'change', true, true );

	var distance = 0;
	var onMouseDownValue = 0;

	var pointer = new THREE.Vector2();
	var prevPointer = new THREE.Vector2();

	var onMouseDown = function ( event ) {

		event.preventDefault();

		distance = 0;

		onMouseDownValue = parseFloat( dom.value );

		prevPointer.set( event.clientX, event.clientY );

		document.addEventListener( 'mousemove', onMouseMove, false );
		document.addEventListener( 'mouseup', onMouseUp, false );

	};

	var onMouseMove = function ( event ) {

		var currentValue = dom.value;

		pointer.set( event.clientX, event.clientY );

		distance += ( pointer.x - prevPointer.x ) - ( pointer.y - prevPointer.y );

		var number = onMouseDownValue + ( distance / ( event.shiftKey ? 5 : 50 ) ) * scope.step;

		dom.value = Math.min( scope.max, Math.max( scope.min, number ) ) | 0;

		if ( currentValue !== dom.value ) dom.dispatchEvent( changeEvent );

		prevPointer.set( event.clientX, event.clientY );

	};

	var onMouseUp = function ( event ) {

		document.removeEventListener( 'mousemove', onMouseMove, false );
		document.removeEventListener( 'mouseup', onMouseUp, false );

		if ( Math.abs( distance ) < 2 ) {

			dom.focus();
			dom.select();

		}

	};

	var onChange = function ( event ) {

		var number = parseInt( dom.value );

		if ( isNaN( number ) === false ) {

			dom.value = number;

		}

	};

	var onFocus = function ( event ) {

		dom.style.backgroundColor = '';
		dom.style.borderColor = '#ccc';
		dom.style.cursor = '';

	};

	var onBlur = function ( event ) {

		dom.style.backgroundColor = 'transparent';
		dom.style.borderColor = 'transparent';
		dom.style.cursor = 'col-resize';

	};

	dom.addEventListener( 'mousedown', onMouseDown, false );
	dom.addEventListener( 'change', onChange, false );
	dom.addEventListener( 'focus', onFocus, false );
	dom.addEventListener( 'blur', onBlur, false );

	return this;

};

UI.Integer.prototype = Object.create( UI.Element.prototype );

UI.Integer.prototype.getValue = function () {

	return parseInt( this.dom.value );

};

UI.Integer.prototype.setValue = function ( value ) {

	if ( value !== undefined ) {

		this.dom.value = value | 0;

	}

	return this;

};

UI.Integer.prototype.setRange = function ( min, max ) {

	this.min = min;
	this.max = max;

	return this;

};

// Break

UI.Break = function () {

	UI.Element.call( this );

	var dom = document.createElement( 'br' );
	dom.className = 'Break';

	this.dom = dom;

	return this;

};

UI.Break.prototype = Object.create( UI.Element.prototype );

// HorizontalRule

UI.HorizontalRule = function () {

	UI.Element.call( this );

	var dom = document.createElement( 'hr' );
	dom.className = 'HorizontalRule';

	this.dom = dom;

	return this;

};

UI.HorizontalRule.prototype = Object.create( UI.Element.prototype );

// Button

UI.Button = function ( value ) {

	UI.Element.call( this );

	var scope = this;

	var dom = document.createElement( 'button' );
	dom.className = 'Button';

	this.dom = dom;
	this.dom.textContent = value;

	return this;

};

UI.Button.prototype = Object.create( UI.Element.prototype );

UI.Button.prototype.setLabel = function ( value ) {

	this.dom.textContent = value;

	return this;

};

// Sound

UI.Sound = function (  ) {

	UI.Element.call( this );

	var scope = this;

	var dom = document.createElement( 'div' );
	dom.className = 'SoundDrop';

	this.dom = dom;

	this.dom.dropArea = document.createElement( 'div' );
	this.dom.dropArea.className = 'dropArea';
	this.dom.dropArea.textContent = 'Drop audio file here';

	this.dom.appendChild( this.dom.dropArea );

	var playButton = document.createElement( 'button' );
	playButton.textContent = '>';
	playButton.style.display = 'none';
	this.dom.playButton = playButton;

	this.dom.appendChild( playButton );

	this.dom._deleteSoundButton = document.createElement( 'button' );
	this.dom._deleteSoundButton.className = 'deleteButton';
	this.dom._deleteSoundButton.textContent = 'x';
	this.dom._deleteSoundButton.addEventListener( 'click', this.setValue.bind(this) );

	// Setup the dnd listeners.
	this.dom.addEventListener('dragover', this.handleDragOver.bind(this), false);
	this.dom.addEventListener('drop', this.handleFileSelect.bind(this), false);

	// create the (initially inactive) play listeners
	this._mouseListeners = {
		down: this.play.bind(this),
		up: this.stop.bind(this)
	};

	return this;

};

UI.Sound.prototype = Object.create( UI.Element.prototype );

UI.Sound.prototype.setLabel = function ( value ) {

	this.dom.textContent = value;

	return this;

};

UI.Sound.prototype.handleFileSelect = function(evt) {
	evt.stopPropagation();
	evt.preventDefault();

	var files = evt.dataTransfer.files; // FileList object.

	if (files && files[0]) {
		this.setValue( files[0] );
	}
}

UI.Sound.prototype.handleDragOver = function(evt) {
	evt.stopPropagation();
	evt.preventDefault();
	evt.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.
}

UI.Sound.prototype.getValue = function() {
	return this.sound;
};

UI.Sound.prototype.setValue = function(sound) {

	if (sound instanceof Blob) {

		// add sound
		this.sound = sound;
		editor.soundCollection.add( sound, function( buffer ) {

			var changeEvent = document.createEvent('HTMLEvents');
			changeEvent.initEvent( 'change', true, true );
			changeEvent.buffer = buffer;
			this.dom.dispatchEvent( changeEvent );

		}.bind(this) );
		this.dom.dropArea.textContent = sound.name;
		this.dom.dropArea.appendChild ( this.dom._deleteSoundButton );
		this.dom.playButton.style.display = '';
		this.dom.playButton.addEventListener( 'mousedown', this._mouseListeners.down, false );
		this.dom.playButton.addEventListener( 'mouseup', this._mouseListeners.up, false );

	} else {

		// remove sound
		this.stop();
		this.dom.playButton.style.display = 'none';
		this.dom.playButton.removeEventListener( 'mousedown', this._mouseListeners.down, false );
		this.dom.playButton.removeEventListener( 'mouseup', this._mouseListeners.up, false );
		this.dom.dropArea.textContent = 'Drop audio file here';
		this.sound = undefined;

		var changeEvent = document.createEvent('HTMLEvents');
		changeEvent.initEvent( 'change', true, true );
		this.dom.dispatchEvent( changeEvent );
	}

};

UI.Sound.prototype.play = function() {
	console.log('play');
	if (this.sound) {
		editor.soundCollection.stop(this.sound);
		editor.soundCollection.play(this.sound);
	}
}

UI.Sound.prototype.stop = function() {
	if (this.sound) {
		editor.soundCollection.stop(this.sound);
	}
}

// Events
UI.EventList = function (  ) {

	UI.Element.call( this );

	var scope = this;

	this.eventList = [];

	var dom = document.createElement( 'div' );
	dom.className = 'EventList';

	this.dom = dom;

	this.dom.eventTemplate = document.createElement( 'div' );
	this.dom.eventTemplate.innerHTML = this.createTemplate();

	this.dom.addButton = document.createElement( 'button' );
	this.dom.addButton.textContent = '+';
	this.dom.appendChild( this.dom.addButton );

	this.dom.addButton.addEventListener('click', this.add.bind(this), false);

	this.dom._changeEvent = document.createEvent('HTMLEvents');
	this.dom._changeEvent.initEvent( 'change', true, true );
	this.fireChange = function() { this.dom.dispatchEvent( this.dom._changeEvent ); }.bind( this );

	return this;

};

UI.EventList.prototype = Object.create( UI.Element.prototype );

// triggerProperties and actionProperties is where you can define your triggers and actions!
// triggerProperties are defined in editor!
//UI.EventList.prototype.triggerProperties = {
//	"Touch Fist": {
//
//	},
//	"Touch Point": {
//
//	},
//	"Touch Stroke": {
//
//	},
//	Collision: {
//
//	},
//	Appear: {
//
//	}
//};

UI.EventList.prototype.createTemplate = function () {

	this.triggerProperties = editor.getTriggerProperties();

	var triggerHTML = '\
	<select size="1" class="eventTriggerSelector">\
		<option>...</option>';

	for(var trigger in this.triggerProperties){
		triggerHTML += '<option>'+trigger+'</option>';
	}

	triggerHTML += '</select>';

	var actionHTML = '\
	<select size="1" class="eventActionSelector" style="display: none;">\
		<option>...</option>\
		<option>Toss</option>\
		<option>Play sound</option>\
		<option>Stop sounds</option>\
		<option>Change Static</option>\
		<option>Notify Listeners</option>\
		<option>Resurrect</option>\
	</select>\
	<button style="display: none;">+</button>\
	<button class="icon-del-small eventDeleteButton"></button>\
	<div class="eventProperties" style="display: none;"></div>';

	return triggerHTML + actionHTML;
};

UI.EventList.prototype.actionProperties = {
	Toss: {
		getUI: function (  ) {

			var container = new UI.Panel();
			var xPanel = new UI.Panel();
			var yPanel = new UI.Panel();
			var zPanel = new UI.Panel();
			xPanel.add( new UI.Text( 'X' ).setWidth( '90px' ) );
			xPanel.add( new UI.Number( 0 ).setRange( -1, 1 ).onChange( this.fireChange ) );
			yPanel.add( new UI.Text( 'Y' ).setWidth( '90px' ) );
			yPanel.add( new UI.Number( 0 ).setRange( -1, 1 ).onChange( this.fireChange ) );
			zPanel.add( new UI.Text( 'Z' ).setWidth( '90px' ) );
			zPanel.add( new UI.Number( 0 ).setRange( -1, 1 ).onChange( this.fireChange ) );
			container.add( xPanel );
			container.add( yPanel );
			container.add( zPanel );
			return container;

		},
		getData: function ( container, resultObject ) {

			var numbers = container.dom.querySelectorAll('input.Number');
			resultObject.x = parseFloat(numbers[0].value);
			resultObject.y = parseFloat(numbers[1].value);
			resultObject.z = parseFloat(numbers[2].value);

		},
		setData: function ( container, dataObject ) {

			var numbers = container.dom.querySelectorAll('input.Number');
			numbers[0].value = dataObject.x;
			numbers[1].value = dataObject.y;
			numbers[2].value = dataObject.z;

		}
	},
	"Play sound": {
		getUI: function ( eventNode ) {

			var self = this;
			var container = new UI.Panel();
			var sound = new UI.Sound().onChange( function( event ) {

				if ( event.buffer ) {

					/*if ( editor.config.getKey('defaultColor') == 'RMS' ) {

						editor.signals.soundAdded.dispatch( event.buffer, editor.selected.material );

					}*/

				}

				self.fireChange();

			} );

			container.add( new UI.Text( 'Sound' ).setWidth( '90px' ) );
			container.add( sound );
			eventNode._soundProperty = sound;

			return container;

		},
		getData: function ( container, resultObject, eventNode ) {

			//save the sound itself in the event list
			resultObject.sound = eventNode._soundProperty.getValue();

		},
		setData: function ( container, dataObject, eventNode ) {

			eventNode._soundProperty.setValue( dataObject.sound );

		}
	},
	"Change Static": {
		getUI: function ( eventNode ) {

			var container = new UI.Panel();

			container.add( new UI.Text( 'Action' ).setWidth( '90px' ) );
			container.add( new UI.Select().setOptions( { 0:'Set dynamic', 1:'Set static', 2:'Toggle static' } ).onChange( this.fireChange ) );

			return container;

		},
		getData: function ( container, resultObject, eventNode ) {

			var staticSelect = container.dom.querySelector('select');
			resultObject.mode = staticSelect.value;

		},
		setData: function ( container, dataObject ) {

			var staticSelect = container.dom.querySelector('select');
			staticSelect.value = dataObject.mode;

		}
	},
	"Stop sounds": { },
	"Notify Listeners":{
		getUI: function ( ) {

			var container = new UI.Panel();

			container.add( new UI.Text( 'Name' ).setWidth( '90px' ) );
			container.add( new UI.Input().onChange( this.fireChange ));
			container.add( new UI.Text( '').setClass('hiddenId').setWidth( '0px' ) );

			return container;

		},
		getData: function ( container, resultObject ) {

			var name = container.dom.querySelector('input.Input');
			resultObject.mode = name.value;

			var id = container.dom.querySelector('span.hiddenId').value;
			if(!id){
				// generate id per topic // todo generate real id
				resultObject['topicId'] = Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1) + Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
			}else{
				resultObject['topicId'] = id;
			}

		},
		setData: function ( container, dataObject ) {

			var name = container.dom.querySelector('input.Input');
			name.value = dataObject.mode;

			var id = container.dom.querySelector('span.hiddenId');
			id.value = dataObject.topicId;

		}
	},
	"Resurrect":{
		getUI: function ( ) {

			var container = new UI.Panel();

			container.add( new UI.Text( 'Delay' ).setWidth( '90px' ) );
			container.add( new UI.Number( 0.5 ).setRange(0, 10000).onChange( this.fireChange ));

			return container;

		},
		getData: function ( container, resultObject, eventNode ) {

			var delay = container.dom.querySelector('input.Number');
			resultObject.mode = delay.value;

		},
		setData: function ( container, dataObject ) {

			var delay = container.dom.querySelector('input.Number');
			delay.value = dataObject.mode;

		}
	}

};

UI.EventList.prototype.setProperties = function ( trigger, action, propertiesElement, eventNode ) {

	// empty the maybe already used property field
	propertiesElement.clear();

	if ( this.triggerProperties[ trigger ] && this.triggerProperties[ trigger ].getUI ) propertiesElement.add( this.triggerProperties[ trigger ].getUI.call( this, eventNode ) );
	if ( this.actionProperties[ action ] && this.actionProperties[ action ].getUI ) propertiesElement.add( this.actionProperties[ action ].getUI.call( this, eventNode ) );

};

UI.EventList.prototype.getValue = function ( ) {

	var eventList = [];

	// get event and action for every row, and read the data
	var events = this.eventList;

	for(var i = 0; i < events.length; ++i) {

		var event = events[ i ];

		if ( event.parentNode != this.dom ) continue;

		var trigger = event.querySelector('select').value;
		var action = event.getElementsByClassName('eventActionSelector')[0].value;
		if ( trigger != '...' && action != '...' ) {

			var data = {
				trigger: { type: trigger },
				action: { type: action }
			};

			var propertiesElement = new UI.Panel( event.getElementsByClassName('eventProperties')[0] );

				if ( this.triggerProperties[ trigger ].getData ) this.triggerProperties[ trigger ].getData( propertiesElement, data.trigger, event );
				if ( this.actionProperties[ action ].getData ) this.actionProperties[ action ].getData( propertiesElement, data.action, event );

			eventList.push( data );
		}

	}

	return eventList;

};

UI.EventList.prototype.setValue = function ( events ) {

	this.dom.eventTemplate.innerHTML = this.createTemplate();

	// first, clear all entries
	var oldRows = this.dom.parentNode.querySelectorAll( 'div.EventList > div' );
	for ( var i = 0; i < oldRows.length; i++ ) {

		this.dom.removeChild( oldRows[ i ] );

	}
	this.eventList = [];

	if ( events != undefined ) {

		var evt = document.createEvent("HTMLEvents");
		evt.initEvent("change", false, true);

		//temporarily disable the change events or they'll get fired all the time while setting default data
		var _fireChangeBackup = this.fireChange;
		this.fireChange = function() { };

		for ( var i = 0; i < events.length; i++ ) {

			var event = events[ i ];

			// take current trigger type of linked observable by id
			if(event.trigger.topicId) {
				for(var triggr in this.triggerProperties){
					if ( this.triggerProperties[triggr].topicId && this.triggerProperties[triggr].topicId == event.trigger.topicId ){
						event.trigger.type = triggr;
					}
				}
			}

			// only add the event if the linked observable still exists, otherwise it is not added to the eventlist.
			if(this.triggerProperties[event.trigger.type]){
				var row = this.add();

				var propertiesElement = new UI.Panel(row.getElementsByClassName('eventProperties')[0]);

				// set selects
				var selects = row.querySelectorAll('select');

				selects[0].value = event.trigger.type;
				selects[0].dispatchEvent(evt);
				selects[1].value = event.action.type;
				selects[1].dispatchEvent(evt);

				var eventNode = this.eventList[this.eventList.length - 1];

				// set properties
				if (this.triggerProperties[event.trigger.type].setData) this.triggerProperties[event.trigger.type].setData(propertiesElement, event.trigger, eventNode);
				if (this.actionProperties[event.action.type].setData) this.actionProperties[event.action.type].setData(propertiesElement, event.action, eventNode);
			}
		}

		// activate firing changes again
		this.fireChange = _fireChangeBackup;

	}

};

UI.EventList.prototype.setLabel = function ( value ) {

	this.dom.textContent = value;

	return this;

};

UI.EventList.prototype.add = function() {

	//properties will be attached to clone whenever necessary.
	var clone = this.dom.eventTemplate.cloneNode(true);

	this.dom.insertBefore(clone, this.dom.firstChild);

	var triggerDropdown = clone.querySelector('select');

	//first select
	triggerDropdown.addEventListener('change', function(event) {

		//get the next (hidden) select
		var actionSelect = event.target.nextSibling.nextSibling;

		if (event.target.selectedIndex == 0) {
			//selected the empty option. hide further elements.
			actionSelect.style.display = 'none';
		} else {
			actionSelect.style.display = '';
		}

	}.bind(this), false);

	//second select
	clone.getElementsByClassName('eventActionSelector')[0].addEventListener('change', function(event) {
		var actionSelect = event.target;

		if (actionSelect.selectedIndex == 0) {
			//selected the empty option. hide further elements.
			clone.querySelector('button').style.display = 'none';
		} else {
			clone.querySelector('button').style.display = '';

			this.setProperties( triggerDropdown.value, event.target.value, propertiesElement, clone );
		}

		this.fireChange();
	}.bind(this), false);

	var propertiesElement = new UI.Panel( clone.getElementsByClassName('eventProperties')[0] );

	//properties hide/show
	clone.querySelector('button').addEventListener('click', function(event) {

		//get the next (hidden) select

		if (propertiesElement.dom.style.display == 'none') {
			//selected the empty option.remove selection
			propertiesElement.dom.style.display = '';
			event.target.innerHTML = '-';
		} else {
			propertiesElement.dom.style.display = 'none';
			event.target.innerHTML = '+';
		}

	}.bind(this), false);

	clone.getElementsByClassName('eventDeleteButton')[0].addEventListener('click', function(event) {

		this.eventList.splice( this.eventList.indexOf( clone ), 1 );
		this.dom.removeChild( clone );
		this.fireChange();

	}.bind(this), false);

	this.eventList.push( clone );

	return clone;
};

// RuntimeMaterial
UI.RuntimeMaterial = function (  ) {

	UI.Element.call( this );

	var scope = this;

	this.runtimematerialList = [];

	var dom = document.createElement( 'div' );
	dom.className = 'RuntimeMaterial';

	this.dom = dom;

	this.dom.eventTemplate = document.createElement( 'div' );
	this.dom.eventTemplate.innerHTML = '\
	<select size="1">\
		<option>...</option>\
		<option>Amplitude</option>\
		<option>Time</option>\
	</select>\
	<select size="1" class="eventActionSelector" style="display: none;">\
		<option>...</option>\
		<option>Brightness</option>\
		<option>Color</option>\
		<option>Edges</option>\
	</select>\
	<button style="display: none;">+</button>\
	<button class="eventDeleteButton icon-del-small">\
	<div class="eventProperties" style="display: none;"></div>';

	this.dom.addButton = document.createElement( 'button' );
	this.dom.addButton.textContent = '+';
	this.dom.appendChild( this.dom.addButton );

	this.dom.addButton.addEventListener('click', this.add.bind(this), false);

	this.dom._changeEvent = document.createEvent('HTMLEvents');
	this.dom._changeEvent.initEvent( 'change', true, true );
	this.fireChange = function() { this.dom.dispatchEvent( this.dom._changeEvent ); }.bind( this );

	return this;

};

UI.RuntimeMaterial.prototype = Object.create( UI.Element.prototype );

// tripperProperties and actionProperties is where you can define your triggers and actions!
UI.RuntimeMaterial.prototype.triggerProperties = {
	"Amplitude": {
		getUI: function ( eventNode ) {

			var container = new UI.Panel();

			container.add( new UI.Text( 'Scale' ).setWidth( '90px' ) );
			var scale = new UI.Number(1).setRange(0,100);
			scale.setClass('amplitudeScale');
			scale.onChange( this.fireChange );
			container.add( scale );

			return container;

		},
		getData: function ( container, resultObject, eventNode ) {

			var scale = container.dom.querySelector('.amplitudeScale');
			resultObject.scale = scale.value;

		},
		setData: function ( container, dataObject ) {

			var scale = container.dom.querySelector('.amplitudeScale');
			scale.value = dataObject.scale;

		}
	},
	"Time": {
		getUI: function ( eventNode ) {

			var container = new UI.Panel();

			container.add( new UI.Text( 'Easing' ).setWidth( '90px' ) );
			var select = new UI.Select().setOptions( Object.keys(Play.Effects.prototype.easing) );
			select.setClass('timeEasing');
			select.onChange( this.fireChange );
			container.add( select );

			return container;

		},
		getData: function ( container, resultObject, eventNode ) {

			var easingSelect = container.dom.querySelector('.timeEasing');
			resultObject.easing = easingSelect.options[easingSelect.selectedIndex].text;

		},
		setData: function ( container, dataObject ) {

			var easingSelect = container.dom.querySelector('.timeEasing');
			for (var i = 0; i < easingSelect.options.length; i++) {
				if (easingSelect.options[i].text === dataObject.easing) {
					easingSelect.selectedIndex = i;
					break;
				}
			}

		}
	}
};

UI.RuntimeMaterial.prototype.actionProperties = {
	Brightness: {

	},
	"Color": {
		getUI: function ( eventNode ) {

			var container = new UI.Panel();

			container.add( new UI.Text( 'Color' ).setWidth( '90px' ) );
			var colorInput = new UI.Color();
			colorInput.setClass('colorSelect');
			colorInput.onChange( this.fireChange );
			container.add( colorInput );

			return container;

		},
		getData: function ( container, resultObject, eventNode ) {

			var colorSelect = container.dom.querySelector('.colorSelect');
			resultObject.color = colorSelect.value;

		},
		setData: function ( container, dataObject ) {

			var colorSelect = container.dom.querySelector('.colorSelect');
			colorSelect.value = dataObject.color;

		}
	},
	Edges: {

	}
};

UI.RuntimeMaterial.prototype.setProperties = function ( trigger, action, propertiesElement, eventNode ) {

	// empty the maybe already used property field
	propertiesElement.clear();

	if ( this.triggerProperties[ trigger ] && this.triggerProperties[ trigger ].getUI ) propertiesElement.add( this.triggerProperties[ trigger ].getUI.call( this, eventNode ) );
	if ( this.actionProperties[ action ] && this.actionProperties[ action ].getUI ) propertiesElement.add( this.actionProperties[ action ].getUI.call( this, eventNode ) );

};

UI.RuntimeMaterial.prototype.getValue = function ( ) {

	var runtimematerialList = [];

	// get event and action for every row, and read the data
	var runtimematerials = this.runtimematerialList;

	for(var i = 0; i < runtimematerials.length; ++i) {

		var rm = runtimematerials[ i ];
		if ( rm.parentNode != this.dom ) continue;

		var trigger = rm.querySelector('select').value;
		var action = rm.getElementsByClassName('eventActionSelector')[0].value;
		if ( trigger != '...' && action != '...' ) {

			var data = {
				trigger: { type: trigger },
				action: { type: action }
			}

			var propertiesElement = new UI.Panel( rm.getElementsByClassName('eventProperties')[0] );

			if ( this.triggerProperties[ trigger ].getData ) this.triggerProperties[ trigger ].getData( propertiesElement, data.trigger, rm );
			if ( this.actionProperties[ action ].getData ) this.actionProperties[ action ].getData( propertiesElement, data.action, rm );

			runtimematerialList.push( data );
		}

	}

	return runtimematerialList;

};

UI.RuntimeMaterial.prototype.setValue = function ( events ) {

	// first, clear all entries
	var oldRows = this.dom.parentNode.querySelectorAll( 'div.RuntimeMaterial > div' );
	for ( var i = 0; i < oldRows.length; i++ ) {

		this.dom.removeChild( oldRows[ i ] );

	}
	this.runtimematerialList = [];

	if ( events != undefined ) {

		var evt = document.createEvent("HTMLEvents");
		evt.initEvent("change", false, true);

		//temporarily disable the change events or they'll get fired all the time while setting default data
		var _fireChangeBackup = this.fireChange;
		this.fireChange = function() { };

		for ( var i = 0; i < events.length; i++ ) {

			var event = events[ i ];

			var row = this.add();

			var propertiesElement = new UI.Panel( row.getElementsByClassName('eventProperties')[0] );

			// set selects
			var selects = row.querySelectorAll('select');
			selects[0].value = event.trigger.type;
			selects[0].dispatchEvent(evt);
			selects[1].value = event.action.type;
			selects[1].dispatchEvent(evt);

			var rmNode = this.runtimematerialList[ this.runtimematerialList.length - 1 ];

			// set properties
			if ( this.triggerProperties[ event.trigger.type ].setData ) this.triggerProperties[ event.trigger.type ].setData( propertiesElement, event.trigger, rmNode );
			if ( this.actionProperties[ event.action.type ].setData ) this.actionProperties[ event.action.type ].setData( propertiesElement, event.action, rmNode );
		}

		// activate firing changes again
		this.fireChange = _fireChangeBackup;

	}

}

UI.RuntimeMaterial.prototype.setLabel = function ( value ) {

	this.dom.textContent = value;

	return this;

};

UI.RuntimeMaterial.prototype.add = function() {

	//properties will be attached to clone whenever necessary.
	var clone = this.dom.eventTemplate.cloneNode(true);

	this.dom.insertBefore(clone,this.dom.firstChild);

	var triggerDropdown = clone.querySelector('select');
	var actionDropdown = clone.getElementsByClassName('eventActionSelector')[0];

	//first select
	triggerDropdown.addEventListener('change', function(event) {

		//get the next (hidden) select
		var actionSelect = event.target.nextSibling.nextSibling;

		if (event.target.selectedIndex == 0) {
			//selected the empty option. hide further elements.
			actionSelect.style.display = 'none';
		} else {
			actionSelect.style.display = '';

			this.setProperties( triggerDropdown.value, actionDropdown.value, propertiesElement, clone );
		}

	}.bind(this), false);

	//second select
	actionDropdown.addEventListener('change', function(event) {
		var actionSelect = event.target;

		if (actionSelect.selectedIndex == 0) {
			//selected the empty option. hide further elements.
			clone.querySelector('button').style.display = 'none';
		} else {
			clone.querySelector('button').style.display = '';

			this.setProperties( triggerDropdown.value, event.target.value, propertiesElement, clone );
		}

		this.fireChange();
	}.bind(this), false);

	var propertiesElement = new UI.Panel( clone.getElementsByClassName('eventProperties')[0] );

	//properties hide/show
	clone.querySelector('button').addEventListener('click', function(event) {

		//get the next (hidden) select

		if (propertiesElement.dom.style.display == 'none') {
			//selected the empty option.remove selection
			propertiesElement.dom.style.display = '';
			event.target.innerHTML = '-';
		} else {
			propertiesElement.dom.style.display = 'none';
			event.target.innerHTML = '+';
		}

	}.bind(this), false);

	clone.getElementsByClassName('eventDeleteButton')[0].addEventListener('click', function(event) {

		this.runtimematerialList.splice( this.runtimematerialList.indexOf( clone ), 1 );
		this.dom.removeChild( clone );
		this.fireChange();

	}.bind(this), false);

	this.runtimematerialList.push( clone );

	return clone;
};

// Behaviors
UI.Behavior = function ( name ) {

	UI.Element.call( this );

	var scope = this;

	this.dom = document.createElement( 'div' );
	this.dom.className = 'Behavior';

	this.dom._changeEvent = document.createEvent('HTMLEvents');
	this.dom._changeEvent.initEvent( 'change', true, true );
	this.fireChange = function() { this.dom.dispatchEvent( this.dom._changeEvent ); }.bind( this );

	this.dom.appendChild( new UI.Text( name ).setWidth( '90px' ).dom );

	this.dom.behaviorCheckbox = new UI.Checkbox( false ).setWidth( '50px' );
	this.dom.behaviorCheckbox.onChange( this.fireChange );
	this.dom.appendChild( this.dom.behaviorCheckbox.dom );

	this.dom.addButton = document.createElement( 'button' );
	this.dom.addButton.textContent = '+';
	this.dom.addButton.style.display = 'none';
	this.dom.addButton.addEventListener('click', this.toggleProperties.bind( this ), false);
	this.dom.appendChild( this.dom.addButton );

	this.dom.behaviorProperties = document.createElement( 'div' );
	this.dom.behaviorProperties.className = 'behaviorProperties';
	this.dom.behaviorProperties.style.display = 'none';
	this.dom.appendChild( this.dom.behaviorProperties );

	return this;

};

UI.Behavior.prototype = Object.create( UI.Element.prototype );

UI.Behavior.prototype.toggleProperties = function (  ) {

	//get the next (hidden) select
	if (this.dom.behaviorProperties.style.display == 'none') {
		//selected the empty option.remove selection
		this.dom.behaviorProperties.style.display = '';
		this.dom.addButton.innerHTML = '-';
	} else {
		this.dom.behaviorProperties.style.display = 'none';
		this.dom.addButton.innerHTML = '+';
	}

};

UI.Behavior.prototype.getValue = function (  ) {

	return this.dom.behaviorCheckbox.getValue();

};

UI.Behavior.prototype.setValue = function ( value ) {

	this.dom.behaviorCheckbox.setValue( value );
	//this.fireChange();

};

UI.Behavior.prototype.getProperties = function (  ) { };
UI.Behavior.prototype.setProperties = function (  ) { };
UI.Behavior.prototype.setPropertiesDOM = function ( html ) {

	this.dom.addButton.style.display = html == undefined ? 'none' : '';

	if ( html !== undefined ) {
		if ( typeof html == 'string' ) {

			this.dom.behaviorProperties.innerHTML = html;

		} else {

			this.dom.behaviorProperties.innerHTML = '';
			this.dom.behaviorProperties.appendChild( html );

		}
	}
};


text:
package org.knowm.xchange.examples.lakebtc.trade;

import java.io.IOException;

import org.knowm.xchange.Exchange;
import org.knowm.xchange.dto.marketdata.Trades;
import org.knowm.xchange.examples.lakebtc.LakeBTCExamplesUtils;
import org.knowm.xchange.lakebtc.dto.trade.LakeBTCTradeResponse;
import org.knowm.xchange.lakebtc.service.LakeBTCTradeServiceRaw;
import org.knowm.xchange.service.trade.TradeService;

public class LakeBTCTradeHistoryDemo {

  public static void main(String[] args) throws IOException {
    Exchange lakebtcExchange = LakeBTCExamplesUtils.createTestExchange();
    generic(lakebtcExchange);
    raw(lakebtcExchange);
  }

  private static void generic(Exchange lakebtcExchange) throws IOException {

    TradeService tradeService = lakebtcExchange.getTradeService();

    // Get the trade history
    Trades trades = tradeService.getTradeHistory(tradeService.createTradeHistoryParams());
    System.out.println(trades);

  }

  private static void raw(Exchange lakeBtcExchange) throws IOException {
    LakeBTCTradeServiceRaw tradeService = (LakeBTCTradeServiceRaw) lakeBtcExchange.getTradeService();

    // Get the trade history
    LakeBTCTradeResponse[] trades = tradeService.getLakeBTCTradeHistory(0);
    System.out.println(trades);

  }
}

redpajama_set_name: RedPajamaGithub


text:
/*
 * File: app/view/MainECLContainer.js
 *
 * This file was generated by Sencha Architect version 3.0.3.
 * http://www.sencha.com/products/architect/
 *
 * This file requires use of the Sencha Touch 2.3.x library, under independent license.
 * License of Sencha Architect does not include license for Sencha Touch 2.3.x. For more
 * details see http://www.sencha.com/license or contact license@sencha.com.
 *
 * This file will be auto-generated each and everytime you save your project.
 *
 * Do NOT hand edit this file.
 */

Ext.define('MyApp.view.MainECLContainer', {
    extend: 'Ext.Container',

    requires: [
        'Ext.Panel',
        'Ext.dataview.List',
        'Ext.XTemplate',
        'Ext.dataview.IndexBar',
        'Ext.Toolbar',
        'Ext.Spacer',
        'Ext.Button',
        'Ext.field.Text',
        'Ext.Img',
        'Ext.Label',
        'Ext.Map',
        'Ext.MessageBox'
    ],

    config: {
        fullscreen: true,
        id: 'MainECLContainer',
        layout: 'card',
        items: [
            {
                xtype: 'panel',
                id: 'ContactListPanel',
                itemId: 'ContactListPanel',
                ui: 'light',
                layout: 'fit',
                items: [
                    {
                        xtype: 'list',
                        id: 'ContactList',
                        itemId: 'ContactList',
                        ui: 'round',
                        hideOnMaskTap: false,
                        masked: {
                            xtype: 'loadmask',
                            message: 'Loading from Server'
                        },
                        itemTpl: [
                            '

',
                            '',
                            '
{lastname}, {firstname}
{position}
'
                        ],
                        store: 'PeopleStore',
                        grouped: true,
                        indexBar: true,
                        items: [
                            {
                                xtype: 'toolbar',
                                docked: 'bottom',
                                hidden: true,
                                id: 'ContactListActionBar',
                                items: [
                                    {
                                        xtype: 'spacer'
                                    },
                                    {
                                        xtype: 'button',
                                        id: 'SearchContactBtn',
                                        itemId: 'mybutton',
                                        iconCls: 'search',
                                        text: 'Search'
                                    },
                                    {
                                        xtype: 'spacer'
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        xtype: 'toolbar',
                        docked: 'top',
                        id: 'ContactListPanelToolbar',
                        itemId: 'ContactListPanelToolbar',
                        ui: 'light',
                        title: 'Executive Contact List',
                        items: [
                            {
                                xtype: 'spacer'
                            }
                        ]
                    },
                    {
                        xtype: 'toolbar',
                        docked: 'top',
                        hidden: true,
                        id: 'SearchBar',
                        ui: 'light',
                        items: [
                            {
                                xtype: 'textfield',
                                flex: 1,
                                itemId: 'mytextfield',
                                placeHolder: 'Contact\'s Name'
                            }
                        ]
                    }
                ]
            },
            {
                xtype: 'container',
                id: 'ContactDetailContainer',
                itemId: 'ContactDetailContainer',
                style: 'background-color: #f0f0f0',
                layout: 'fit',
                items: [
                    {
                        xtype: 'toolbar',
                        docked: 'top',
                        hidden: true,
                        id: 'ContactDetailsHeaderToolbar',
                        ui: 'light'
                    },
                    {
                        xtype: 'container',
                        id: 'ContactDetailsRootContainer',
                        scrollable: 'vertical',
                        items: [
                            {
                                xtype: 'container',
                                height: 120,
                                id: 'ContactDetailsSummaryContainer',
                                itemId: 'ContactDetailsSummaryContainer',
                                layout: {
                                    type: 'hbox',
                                    align: 'start'
                                },
                                items: [
                                    {
                                        xtype: 'image',
                                        border: 2,
                                        height: '100px',
                                        id: 'ContactImage',
                                        itemId: 'ContactImage',
                                        margin: '10px',
                                        style: 'border-color: #ccc; border-style: solid;',
                                        width: '100px',
                                        src: 'resources/images/greyman.jpg'
                                    },
                                    {
                                        xtype: 'container',
                                        id: 'ContactDetailsSummaryInfoContainer',
                                        margin: '10px',
                                        width: '100%',
                                        layout: 'vbox',
                                        items: [
                                            {
                                                xtype: 'label',
                                                html: 'Full Name',
                                                id: 'ContactDetailsFullnameLabel',
                                                itemId: 'ContactDetailsFullnameLabel'
                                            },
                                            {
                                                xtype: 'label',
                                                id: 'ContactDetailsPositionLabel',
                                                itemId: 'ContactDetailsPositionLabel'
                                            }
                                        ]
                                    }
                                ]
                            },
                            {
                                xtype: 'container',
                                height: 300,
                                id: 'ContactDetailsInfoContainer',
                                style: 'margin: 7px',
                                ui: '',
                                scrollable: false,
                                items: [
                                    {
                                        xtype: 'list',
                                        height: 400,
                                        id: 'DetailInfoActionList',
                                        itemId: 'mylist1',
                                        ui: 'round',
                                        itemTpl: [
                                            '

',
                                            '<tpl if=\'label2.length < 25\'>
{label1}
{label2}
</tpl>',
                                            '<tpl if=\'label2.length > 24\'>
{label1}
{label2}
</tpl>'
                                        ],
                                        store: 'ActionStore'
                                    },
                                    {
                                        xtype: 'container',
                                        hidden: true,
                                        id: 'DetailsLabelContainer',
                                        items: [
                                            {
                                                xtype: 'container',
                                                height: '50px',
                                                id: 'ContactDetailEmailRow',
                                                layout: 'hbox',
                                                items: [
                                                    {
                                                        xtype: 'label',
                                                        flex: 1,
                                                        centered: false,
                                                        html: 'Email',
                                                        id: 'emailtitle',
                                                        style: '',
                                                        styleHtmlCls: 'ContactDetailLabel',
                                                        styleHtmlContent: true
                                                    },
                                                    {
                                                        xtype: 'label',
                                                        flex: 2,
                                                        id: 'emaillabel',
                                                        styleHtmlCls: 'ContactDetailValueLabel',
                                                        styleHtmlContent: true
                                                    }
                                                ]
                                            },
                                            {
                                                xtype: 'container',
                                                height: '50px',
                                                id: 'ContactDetailWorkPhoneRow',
                                                layout: 'hbox',
                                                items: [
                                                    {
                                                        xtype: 'label',
                                                        flex: 1,
                                                        centered: false,
                                                        html: 'Work Phone',
                                                        id: 'WorkPhoneTitle',
                                                        styleHtmlCls: 'ContactDetailLabel',
                                                        styleHtmlContent: true
                                                    },
                                                    {
                                                        xtype: 'label',
                                                        flex: 2,
                                                        id: 'workphonelabel',
                                                        styleHtmlCls: 'ContactDetailValueLabel',
                                                        styleHtmlContent: true
                                                    }
                                                ]
                                            },
                                            {
                                                xtype: 'container',
                                                height: '50px',
                                                id: 'ContactDetailBlackBerryRow',
                                                layout: 'hbox',
                                                items: [
                                                    {
                                                        xtype: 'label',
                                                        flex: 1,
                                                        centered: false,
                                                        html: 'BlackBerry',
                                                        id: 'blackberrytitle',
                                                        styleHtmlCls: 'ContactDetailLabel',
                                                        styleHtmlContent: true
                                                    },
                                                    {
                                                        xtype: 'label',
                                                        flex: 2,
                                                        id: 'blackberrylabel',
                                                        styleHtmlCls: 'ContactDetailClickableValueLabel',
                                                        styleHtmlContent: true
                                                    }
                                                ]
                                            },
                                            {
                                                xtype: 'container',
                                                height: '50px',
                                                id: 'ContactDetailLocationRow',
                                                layout: 'hbox',
                                                items: [
                                                    {
                                                        xtype: 'label',
                                                        flex: 1,
                                                        centered: false,
                                                        html: 'Location',
                                                        id: 'locationtitle',
                                                        styleHtmlCls: 'ContactDetailLabel',
                                                        styleHtmlContent: true
                                                    },
                                                    {
                                                        xtype: 'label',
                                                        flex: 2,
                                                        id: 'locationlabel',
                                                        styleHtmlCls: 'ContactDetailValueLabel',
                                                        styleHtmlContent: true
                                                    }
                                                ]
                                            },
                                            {
                                                xtype: 'container',
                                                height: '50px',
                                                id: 'ContactDetailTwitterRow',
                                                layout: 'hbox',
                                                items: [
                                                    {
                                                        xtype: 'label',
                                                        flex: 1,
                                                        centered: false,
                                                        html: 'Twitter',
                                                        id: 'twitteridtitle',
                                                        styleHtmlCls: 'ContactDetailLabel',
                                                        styleHtmlContent: true
                                                    },
                                                    {
                                                        xtype: 'label',
                                                        flex: 2,
                                                        id: 'twitteridlabel',
                                                        styleHtmlCls: 'ContactDetailValueLabel',
                                                        styleHtmlContent: true
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        xtype: 'toolbar',
                        docked: 'bottom',
                        id: 'ContactDetailsFooterToolbar',
                        layout: {
                            type: 'hbox',
                            pack: 'end'
                        },
                        items: [
                            {
                                xtype: 'button',
                                id: 'contactdetailsbackbutton',
                                itemId: 'contactdetailsbackbutton',
                                ui: 'back',
                                text: 'Back'
                            },
                            {
                                xtype: 'spacer'
                            }
                        ]
                    }
                ]
            },
            {
                xtype: 'container',
                centered: false,
                id: 'ContactDetailsImageContainer',
                style: '',
                layout: 'card',
                modal: false,
                items: [
                    {
                        xtype: 'toolbar',
                        docked: 'bottom',
                        hidden: true,
                        id: 'ContactDetailsImageActionBar',
                        items: [
                            {
                                xtype: 'button',
                                id: 'ContactDetailsImgBack',
                                itemId: 'mybutton1',
                                ui: 'back',
                                text: 'Back'
                            }
                        ]
                    },
                    {
                        xtype: 'container',
                        centered: false,
                        id: 'ProfileImgContainer',
                        style: 'background-color: rgba(0,0,0,0.9);',
                        scrollable: false,
                        layout: {
                            type: 'vbox',
                            align: 'center',
                            pack: 'center'
                        },
                        items: [
                            {
                                xtype: 'image',
                                centered: false,
                                height: 200,
                                id: 'ContactDetalsProfileImage',
                                itemId: 'myimg1',
                                width: 200,
                                src: 'resources/images/greyman.jpg'
                            }
                        ]
                    }
                ]
            },
            {
                xtype: 'container',
                id: 'ContactDetailMapContainer',
                ui: '',
                layout: 'fit',
                items: [
                    {
                        xtype: 'map',
                        id: 'ContactMap',
                        mapOptions: {
                            zoom: 6
                        }
                    },
                    {
                        xtype: 'toolbar',
                        docked: 'bottom',
                        id: 'MapActionBar',
                        items: [
                            {
                                xtype: 'button',
                                id: 'MapActionBarBtn',
                                itemId: 'mybutton3',
                                ui: 'back',
                                text: 'Back'
                            },
                            {
                                xtype: 'spacer'
                            },
                            {
                                xtype: 'button',
                                handler: function(button, e) {
                                    if(MyApp.globals.os=="BlackBerry 10" && (MyApp.globals.packager=="Cordova" || MyApp.globals.packager=="WebWorks")){
                                        if(Ext.getCmp('ContactDetailMapContainer').location!==null){

                                            var geolocation=Ext.getCmp('ContactDetailMapContainer').location;

                                            var mapsArgs = JSON.stringify(
                                            {
                                                "center": {
                                                    "latitude": geolocation.lat,
                                                    "longitude": geolocation.lng,
                                                    "altitude": 50000
                                                }
                                            }

                                            );

                                            console.log("Map args:"+mapsArgs);

                                            blackberry.invoke.invoke({
                                                action: "bb.action.OPEN",
                                                type: "application/vnd.rim.map.action-v1",
                                                data: mapsArgs
                                            });
                                        }
                                        else{
                                            Ext.Msg.alert('Error', 'Sorry, there is valid location.', Ext.emptyFn);
                                            console.log("no geolocation data!");
                                        }
                                        return;
                                    }
                                    else if(MyApp.globals.os=="iOS" && MyApp.globals.packager=="Cordova"){
                                        window.open('http://maps.apple.com/?q='+this.query, '_system');
                                        return;
                                    }
                                    else{ // should never occur
                                        Ext.Msg.alert('Error', 'Sorry, there is no supported maps app.', Ext.emptyFn);
                                        console.log(this);
                                        return;
                                    }
                                },
                                hidden: true,
                                iconCls: 'maps',
                                text: 'Maps'
                            },
                            {
                                xtype: 'spacer'
                            }
                        ]
                    }
                ]
            }
        ],
        listeners: [
            {
                fn: 'onContactListItemTap',
                event: 'itemtap',
                delegate: '#ContactList'
            },
            {
                fn: 'onSearchContactBtnTap',
                event: 'tap',
                delegate: '#SearchContactBtn'
            },
            {
                fn: 'onMytextfieldBlur',
                event: 'blur',
                delegate: '#mytextfield'
            },
            {
                fn: 'onMytextfieldKeyup',
                event: 'keyup',
                delegate: '#mytextfield'
            },
            {
                fn: 'onContactImageTap',
                event: 'tap',
                delegate: '#ContactImage'
            },
            {
                fn: 'onDetailInfoActionListItemTap',
                event: 'itemtap',
                delegate: '#DetailInfoActionList'
            },
            {
                fn: 'onBackButtonTap',
                event: 'tap',
                delegate: '#contactdetailsbackbutton'
            },
            {
                fn: 'onContactDetailsImgBackTap',
                event: 'tap',
                delegate: '#ContactDetailsImgBack'
            },
            {
                fn: 'onContactDetalsProfileImageTap',
                event: 'tap',
                delegate: '#ContactDetalsProfileImage'
            },
            {
                fn: 'onMapActionBarBtnTap',
                event: 'tap',
                delegate: '#MapActionBarBtn'
            }
        ]
    },

    onContactListItemTap: function(dataview, index, target, record, e, eOpts) {
        // Event handler - Each item tap

        var contactlist = this.down('#ContactList');
        var contactdetailscontainer = this.down('#ContactDetailContainer');
        var contactdetailsinfocontainer = this.down('#ContactDetailsInfoContainer');
        var data = record.data;

        contactlist.fireEvent('loadAndShowDetails', contactlist, contactdetailscontainer,
        contactdetailsinfocontainer, data);

        // **** new items
        // todo: delete event listeners

        var that = this;

        contactdetailscontainer.element.on('swipe', function(e){
            if(e.direction=='right'){
                that.onBackButtonTap();
            }
        });

        this.down('#ContactListActionBar').hide();
    },

    onSearchContactBtnTap: function(button, e, eOpts) {
        var searchbar = Ext.getCmp('SearchBar');
        if(searchbar.getHidden()){
            searchbar.show(true);
        }
        if(!searchbar.getHidden()){
            searchbar.hide();
        }
    },

    onMytextfieldBlur: function(textfield, e, eOpts) {
        Ext.getCmp('SearchBar').hide();
    },

    onMytextfieldKeyup: function(textfield, e, eOpts) {
        var value = textfield.getValue();
        if (value && value.length) {
            var filter = [{
                filterFn: function(record) {
                    var firstName = record.get('firstname').toLowerCase(),
                    lastName = record.get('lastname').toLowerCase();

                    if (firstName.match(value) || lastName.match(value)) {
                        return true;
                    }
                    return false;
                }
            }];

            Ext.getStore('PeopleStore').filter(filter);
        }
        else {
            Ext.getStore('PeopleStore').clearFilter();
        }

    },

    onContactImageTap: function(image, e, eOpts) {
        that = this;

        if(image.getSrc()=='resources/images/greyman.jpg'){
            return;
        }

        var imgContainer = this.down('#ContactDetailsImageContainer');
        this.animateActiveItem(imgContainer,
        {type: 'slide'}
        );

        var imageactionbar = this.down('#ContactDetailsImageActionBar');
        imageactionbar.hide();

        imgContainer.element.on('swipe', function(e){
            if(e.direction=='right'){
                that.onContactDetailsImgBackTap();
            }
        });
        imgContainer.element.on('tap', function(e){
            if(imageactionbar.getHidden()==true){
            	imageactionbar.show(true);
            }
            else {
                imageactionbar.hide();
            }
        });

        that=this;
        Ext.Function.defer(function(){

            if(that.getActiveItem().id==imgContainer.id){
                imageactionbar.show(true);
            }
        }, 5000);

    },

    onDetailInfoActionListItemTap: function(dataview, index, target, record, e, eOpts) {
        var data=record.data;
        console.log(data.action);
        if(data.action=="email"){
            Ext.Msg.confirm('Compose Email', 'Leave this Application and Compose a new email',
            function ( answer ) {
                if ( answer == 'yes') {
                    window.location=('mailto:'+data.location);
                }
            });
        }
        else if(data.action=="call"){
            Ext.Msg.confirm('Call Phone', 'Do you want to call this phone '+data.location,
            function ( answer ) {
                if ( answer == 'yes') {
                    window.location=('tel:'+data.location);
                }
            }
            );
        }
        else if(data.action=="bbm"){
            if(MyApp.globals.os=="BlackBerry 10"){
                if(blackberry && blackberry.invoke){
                    blackberry.invoke.invoke({
                        action: 'bb.action.BBMCHAT',
                        uri: 'pin:' + data.bbmpin
                    });
                }
            }
            else{
                Ext.Msg.alert('BBM', 'This functionality will be added when the BBM API for '+MyApp.globals.os+" will be available");
            }
        }
        else if(data.action=="sms"){
            Ext.Msg.confirm('Text', 'Do you want to Text '+data.location+"?",
            function ( answer ) {
                if ( answer == 'yes') {
                    window.location=('sms:'+data.location);
                }
            }
            );
        }
        else if(data.action=="map"){
            var query = encodeURIComponent(data.location);
            console.log(MyApp.globals.os);

            if(Ext.getCmp('ContactDetailMapContainer').location!==null){
                console.log(Ext.getCmp('ContactDetailMapContainer').location);
            }

            if(MyApp.globals.os=="iOS"){
                nativeIcon = Ext.getCmp('nativeMapsIcon');
                nativeIcon.query=query;
                if(MyApp.globals.packager=="Cordova") nativeIcon.show(true);
                var contactdetailmapcontainer = Ext.getCmp('ContactDetailMapContainer');
                Ext.getCmp('ContactMap').getMap().panTo(Ext.getCmp('ContactDetailMapContainer').location);

                this.animateActiveItem(contactdetailmapcontainer, {
                    type: 'slide',
                    direction: 'left'
                });

                return;

            }
            else if(MyApp.globals.os=="BlackBerry 10" && MyApp.globals.packager=="WebWorks"){
                nativeIcon = Ext.getCmp('nativeMapsIcon');

                nativeIcon.show(true);

                var contactdetailmapcontainer = Ext.getCmp('ContactDetailMapContainer');
                Ext.getCmp('ContactMap').getMap().panTo(Ext.getCmp('ContactDetailMapContainer').location);

                this.animateActiveItem(contactdetailmapcontainer, {
                    type: 'slide',
                    direction: 'left'
                });

                return;

            }
            else{

                var contactdetailmapcontainer = Ext.getCmp('ContactDetailMapContainer');
                Ext.getCmp('ContactMap').getMap().panTo(Ext.getCmp('ContactDetailMapContainer').location);

                this.animateActiveItem(contactdetailmapcontainer, {
                    type: 'slide',
                    direction: 'left'
                });

                return;
            }
        }
        else if(data.action=="twitter"){
            var twitterAddress = data.location;
            if(twitterAddress!==null && twitterAddress.length > 1){
                window.open('http://www.twitter.com/'+twitterAddress.replace("@",""),'_system');

            }
            else{
                console.log("error: Twitter address nonexistant - "+data.location);
            }
        }
    },

    onBackButtonTap: function(button, e, eOpts) {
        var contactlistpanel = this.down('#ContactListPanel');
        Ext.getCmp('ContactListActionBar').hide();

        this.animateActiveItem(contactlistpanel, {
            type: 'slide',
            direction: 'right'
        });

        var contactimage = this.down('#ContactImage');
        contactimage.setSrc("resources/images/greyman.jpg");

        // clear listeners
        var blackberryfield = this.down("#blackberrylabel");
        blackberryfield.element.clearListeners();

        var emailfield = this.down("#emaillabel");
        emailfield.element.clearListeners();

        var phonefield = this.down("#workphonelabel");
        phonefield.element.clearListeners();

        // ContactDetailsPositionLabel
        var contactdetailspositionlabel = this.down("#ContactDetailsPositionLabel");
        contactdetailspositionlabel.setHtml("");

        var contactdetailscontainer = this.down('#ContactDetailContainer');
        contactdetailscontainer.element.clearListeners();

        var contactdetailsrootcontainer = this.down('#ContactDetailsRootContainer');

        contactdetailsrootcontainer.getScrollable().refresh();
        contactdetailsrootcontainer.getScrollable().getScroller().scrollTo(0,0, false);

    },

    onContactDetailsImgBackTap: function(button, e, eOpts) {
        var contactdetailcontainer = this.down('#ContactDetailContainer');
        this.animateActiveItem(contactdetailcontainer, {
            type: 'slide',
            direction: 'right'
        });

        var imgContainer = this.down('#ContactDetailsImageContainer');
        imgContainer.element.clearListeners();
    },

    onContactDetalsProfileImageTap: function(image, e, eOpts) {
        var imageactionbar = this.down('#ContactDetailsImageActionBar');
        imageactionbar.show(true);
    },

    onMapActionBarBtnTap: function(button, e, eOpts) {
        var contactdetailcontainer = this.down('#ContactDetailContainer');
        this.animateActiveItem(contactdetailcontainer, {
            type: 'slide',
            direction: 'right'
        });

    },

    initialize: function() {
        this.callParent();

        var storeAutoload = {
            callback: function(el, succ, resp, opts)
            {
                console.log(succ.success);
                if(succ.success===false){
                    Ext.Msg.alert(
                                "Internet Required",
                                "This app requires access to the internet. Please close this app and reopen when you have interent access"
                                );
                }
            }
        };

        var peoplestore = Ext.getStore("PeopleStore");

        peoplestore.getProxy().setUrl(appSettings.userlist_url);
        peoplestore.setAutoLoad(storeAutoload);
        //peoplestore.load();

    }

});


text:
module Arel
  module Extensions
    VERSION = '6.1.0'
  end
end


text:
package com.datamountaineer.streamreactor.connect.elastic6

import java.nio.ByteBuffer

import com.datamountaineer.streamreactor.connect.json.SimpleJsonConverter
import com.fasterxml.jackson.databind.JsonNode
import com.landoop.connect.sql.StructSql._
import com.landoop.json.sql.JacksonJson
import com.landoop.json.sql.JsonSql._
import com.landoop.sql.Field
import com.typesafe.scalalogging.StrictLogging
import org.apache.kafka.connect.data.{Schema, Struct}

import scala.util.{Failure, Success, Try}

private object TransformAndExtractPK extends StrictLogging {
  lazy val simpleJsonConverter = new SimpleJsonConverter()

  def apply(fields: Seq[Field],
            ignoredFields: Seq[Field],
            primaryKeysPaths: Seq[Vector[String]],
            schema: Schema,
            value: Any,
            withStructure: Boolean): (JsonNode, Seq[Any]) = {
    def raiseException(msg: String, t: Throwable) = throw new IllegalArgumentException(msg, t)

    if (value == null) {
      if (schema == null || !schema.isOptional) {
        raiseException("Null value is not allowed.", null)
      }
      else null
    } else {
      if (schema != null) {
        schema.`type`() match {
          case Schema.Type.BYTES =>
            //we expected to be json
            val array = value match {
              case a: Array[Byte] => a
              case b: ByteBuffer => b.array()
              case other => raiseException("Invalid payload:$other for schema Schema.BYTES.", null)
            }

            Try(JacksonJson.mapper.readTree(array)) match {
              case Failure(e) => raiseException("Invalid json.", e)
              case Success(json) =>
                Try(json.sql(fields, !withStructure)) match {
                  case Failure(e) => raiseException(s"A KCQL exception occurred. ${e.getMessage}", e)
                  case Success(jn) =>
                    (jn, primaryKeysPaths.map(PrimaryKeyExtractor.extract(json, _)))
                }
            }

          case Schema.Type.STRING =>
            //we expected to be json
            Try(JacksonJson.asJson(value.asInstanceOf[String])) match {
              case Failure(e) => raiseException("Invalid json", e)
              case Success(json) =>
                Try(json.sql(fields, !withStructure)) match {
                  case Success(jn) => (jn, primaryKeysPaths.map(PrimaryKeyExtractor.extract(json, _)))
                  case Failure(e) => raiseException(s"A KCQL exception occurred.${e.getMessage}", e)
                }
            }

          case Schema.Type.STRUCT =>
            val struct = value.asInstanceOf[Struct]
            Try(struct.sql(fields, !withStructure)) match {
              case Success(s) =>
                (simpleJsonConverter.fromConnectData(s.schema(), s), primaryKeysPaths.map(PrimaryKeyExtractor.extract(struct, _)))

              case Failure(e) => raiseException(s"A KCQL error occurred.${e.getMessage}", e)
            }

          case other => raiseException("Can't transform Schema type:$other.", null)
        }
      } else {
        //we can handle java.util.Map (this is what JsonConverter can spit out)
        value match {
          case m: java.util.Map[_, _] =>
            val map = m.asInstanceOf[java.util.Map[String, Any]]
            val jsonNode: JsonNode = JacksonJson.mapper.valueToTree(map)
            Try(jsonNode.sql(fields, !withStructure)) match {
              case Success(j) => (j, primaryKeysPaths.map(PrimaryKeyExtractor.extract(jsonNode, _)))
              case Failure(e) => raiseException(s"A KCQL exception occurred.${e.getMessage}", e)
            }
          case s: String =>
            Try(JacksonJson.asJson(value.asInstanceOf[String])) match {
              case Failure(e) => raiseException("Invalid json.", e)
              case Success(json) =>
                Try(json.sql(fields, !withStructure)) match {
                  case Success(jn) => (jn, primaryKeysPaths.map(PrimaryKeyExtractor.extract(json, _)))
                  case Failure(e) => raiseException(s"A KCQL exception occurred.${e.getMessage}", e)
                }
            }

          case b: Array[Byte] =>
            Try(JacksonJson.mapper.readTree(b)) match {
              case Failure(e) => raiseException("Invalid json.", e)
              case Success(json) =>
                Try(json.sql(fields, !withStructure)) match {
                  case Failure(e) => raiseException(s"A KCQL exception occurred. ${e.getMessage}", e)
                  case Success(jn) => (jn, primaryKeysPaths.map(PrimaryKeyExtractor.extract(json, _)))
                }
            }
          //we take it as String
          case other => raiseException(s"Value:$other is not handled!", null)
        }
      }
    }
  }
}


text:
import * as express from 'express';
var app = express();

app.engine('jade', require('jade').__express);
app.engine('html', require('ejs').renderFile);

express.static.mime.define({
	'application/fx': ['fx']
});
app.use('/static', express.static(__dirname + '/public'));

// simple logger
app.use(function(req, res, next){
    console.log('%s %s', req.method, req.url);
    next();
});

app.use(function(err: any, req: express.Request, res: express.Response, next: express.NextFunction) {
    console.error(err);
    next(err);
});

app.get('/', function(req, res){
    res.send('hello world');
});

const router = express.Router();

const pathStr : string = 'test';
const pathRE : RegExp = /test/;
const path = true? pathStr : pathRE;

router.get(path);
router.put(path)
router.post(path);
router.delete(path);
router.get(pathStr);
router.put(pathStr)
router.post(pathStr);
router.delete(pathStr);
router.get(pathRE);
router.put(pathRE)
router.post(pathRE);
router.delete(pathRE);

router.use((req, res, next) => { next(); })
router.route('/users')
    .get((req, res, next) => {
        let types: string[] = req.accepts();
        let type: string | boolean = req.accepts('json');
        type = req.accepts(['json', 'text']);
        type = req.accepts('json', 'text');

        let charsets: string[] = req.acceptsCharsets();
        let charset: string | boolean = req.acceptsCharsets('utf-8');
        charset = req.acceptsCharsets(['utf-8', 'utf-16']);
        charset = req.acceptsCharsets('utf-8', 'utf-16');

        let encodings: string[] = req.acceptsEncodings();
        let encoding: string | boolean = req.acceptsEncodings('gzip');
        encoding = req.acceptsEncodings(['gzip', 'deflate']);
        encoding = req.acceptsEncodings('gzip', 'deflate');

        let languages: string[] = req.acceptsLanguages();
        let language: string | boolean = req.acceptsLanguages('en');
        language = req.acceptsLanguages(['en', 'ja']);
        language = req.acceptsLanguages('en', 'ja');

        res.send(req.query['token']);
    });

router.get('/user/:id', function(req, res, next) {
    if (req.params.id == 0) next('route');
    else next();
}, function(req, res, next) {
    res.render('regular');
});

app.use((req, res, next) => {
    // hacky trick, router is just a handler
    router(req, res, next);
});

app.use(router);

app.listen(3000);

const next: express.NextFunction = () => {};
const nextWithArgument: express.NextFunction = (err: any) => {};


text:
// ==++==
//
//   Copyright (c) Microsoft Corporation.  All rights reserved.
//
// ==--==
// <OWNER>[....]</OWNER>
//

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Security;
using System.Security.Cryptography.X509Certificates;
using System.Security.Policy;
using System.Security.Permissions;
using Microsoft.Win32.SafeHandles;

namespace System.Security.Policy
{
    /// <summary>
    ///     Arguments to the ETW evidence generation event.  This enumeration should be kept in [....] with
    ///     the VM enumeration EvidenceType in SecurityPolicy.h.
    /// </summary>
    internal enum EvidenceTypeGenerated
    {
        AssemblySupplied,
        Gac,
        Hash,
        PermissionRequest,
        Publisher,
        Site,
        StrongName,
        Url,
        Zone
    }

    /// <summary>
    ///     Factory class which can create evidence on demand for a VM PEFile
    /// </summary>
    internal sealed class PEFileEvidenceFactory : IRuntimeEvidenceFactory
    {
        [System.Security.SecurityCritical] // auto-generated
        private SafePEFileHandle m_peFile;

        private List<EvidenceBase> m_assemblyProvidedEvidence;

        // Since all three of these evidence objects are generated from the same source data, we'll generate
        // all three when we're asked for any one of them and save them around in case we're asked for the
        // others.
        bool m_generatedLocationEvidence;
        private Site m_siteEvidence;
        private Url m_urlEvidence;
        private Zone m_zoneEvidence;

        [SecurityCritical]
        private PEFileEvidenceFactory(SafePEFileHandle peFile)
        {
            Contract.Assert(peFile != null &&
                            !peFile.IsClosed &&
                            !peFile.IsInvalid);
            m_peFile = peFile;
        }

        /// <summary>
        ///     PEFile * that we generate evidence for
        /// </summary>
        internal SafePEFileHandle PEFile
        {
            [SecurityCritical]
            get { return m_peFile; }
        }

        /// <summary>
        ///     Object the supplied evidence is for
        /// </summary>
        public IEvidenceFactory Target
        {
            // Since the CLR does not have a PEFile abstraction and this PEFile may not have an associated
            // assembly if we're early in runtime startup, there is no valid target object to return here.
            get { return null; }
        }

        /// <summary>
        ///     Generate an evidence collection the PE file.  This is called from the the VM in
        ///     SecurityDescriptor::GetEvidenceForPEFile.
        /// </summary>
        [SecurityCritical]
        private static Evidence CreateSecurityIdentity(SafePEFileHandle peFile,
                                                       Evidence hostProvidedEvidence)
        {

            PEFileEvidenceFactory evidenceFactory = new PEFileEvidenceFactory(peFile);
            Evidence evidence = new Evidence(evidenceFactory);

            // If the host (caller of Assembly.Load) provided evidence, merge it with the evidence we've just
            // created. The host evidence takes priority.
            if (hostProvidedEvidence != null)
            {
                evidence.MergeWithNoDuplicates(hostProvidedEvidence);
            }

            return evidence;
        }

        [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
        [SecurityCritical]
        [SuppressUnmanagedCodeSecurity]
        private static extern void FireEvidenceGeneratedEvent(SafePEFileHandle peFile,
                                                              EvidenceTypeGenerated type);

        /// <summary>
        ///     Fire an ETW event indicating that a piece of evidence has been generated.  Evidence that is
        ///     generated in the VM fires this event without a seperate call to this method, however
        ///     evidence types generated in the BCL, such as GacInstalled, need to call this directly.
        /// </summary>
        [SecuritySafeCritical]
        internal void FireEvidenceGeneratedEvent(EvidenceTypeGenerated type)
        {
            FireEvidenceGeneratedEvent(m_peFile, type);
        }

        [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
        [SecurityCritical]
        [SuppressUnmanagedCodeSecurity]
        private static extern void GetAssemblySuppliedEvidence(SafePEFileHandle peFile,
                                                               ObjectHandleOnStack retSerializedEvidence);

        /// <summary>
        ///     Get any evidence that was serialized into the PE File
        /// </summary>
        [SecuritySafeCritical]
        public IEnumerable<EvidenceBase> GetFactorySuppliedEvidence()
        {
            if (m_assemblyProvidedEvidence == null)
            {
                byte[] serializedEvidence = null;
                GetAssemblySuppliedEvidence(m_peFile, JitHelpers.GetObjectHandleOnStack(ref serializedEvidence));

                m_assemblyProvidedEvidence = new List<EvidenceBase>();
                if (serializedEvidence != null)
                {
                    Evidence deserializedEvidence = new Evidence();

                    // Partial trust assemblies can provide their own evidence, so make sure that we have
                    // permission to deserialize it
                    new SecurityPermission(SecurityPermissionFlag.SerializationFormatter).Assert();

                    try
                    {
                        BinaryFormatter formatter = new BinaryFormatter();
                        using (MemoryStream ms = new MemoryStream(serializedEvidence))
                        {
                            deserializedEvidence = (Evidence)formatter.Deserialize(ms);
                        }
                    }
                    catch { /* Ignore any errors deserializing */ }

                    CodeAccessPermission.RevertAssert();

                    // Enumerate the assembly evidence, ignoring any host evidence supplied.  Since we
                    // could be loading a Whidbey assembly, we need to use the old GetAssemblyEnumerator
                    // API and deal with objects instead of EvidenceBases.
                    if (deserializedEvidence != null)
                    {
                        IEnumerator enumerator = deserializedEvidence.GetAssemblyEnumerator();

                        while (enumerator.MoveNext())
                        {
                            if (enumerator.Current != null)
                            {
                                // If this is a legacy evidence object, we need to wrap it before
                                // returning it.
                                EvidenceBase currentEvidence = enumerator.Current as EvidenceBase;
                                if (currentEvidence == null)
                                {
                                    currentEvidence = new LegacyEvidenceWrapper(enumerator.Current);
                                }

                                m_assemblyProvidedEvidence.Add(currentEvidence);
                            }
                        }
                    }
                }
            }

            return m_assemblyProvidedEvidence;
        }

        [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
        [SecurityCritical]
        [SuppressUnmanagedCodeSecurity]
        private static extern void GetLocationEvidence(SafePEFileHandle peFile,
                                                       [Out] out SecurityZone zone,
                                                       StringHandleOnStack retUrl);

        [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
        [SecurityCritical]
        [SuppressUnmanagedCodeSecurity]
        private static extern void GetPublisherCertificate(SafePEFileHandle peFile,
                                                           ObjectHandleOnStack retCertificate);

        /// <summary>
        ///     Called to generate different types of evidence on demand
        /// </summary>
        public EvidenceBase GenerateEvidence(Type evidenceType)
        {
            if (evidenceType == typeof(Site))
            {
                return GenerateSiteEvidence();
            }
            else if (evidenceType == typeof(Url))
            {
                return GenerateUrlEvidence();
            }
            else if (evidenceType == typeof(Zone))
            {
                return GenerateZoneEvidence();
            }
            else if (evidenceType == typeof(Publisher))
            {
                return GeneratePublisherEvidence();
            }

            return null;
        }

        /// <summary>
        ///     Generate Site, Url, and Zone evidence for this file.
        /// </summary>
        [SecuritySafeCritical]
        private void GenerateLocationEvidence()
        {
            if (!m_generatedLocationEvidence)
            {
                SecurityZone securityZone = SecurityZone.NoZone;
                string url = null;
                GetLocationEvidence(m_peFile, out securityZone, JitHelpers.GetStringHandleOnStack(ref url));

                if (securityZone != SecurityZone.NoZone)
                {
                    m_zoneEvidence = new Zone(securityZone);
                }

                if (!String.IsNullOrEmpty(url))
                {
                    m_urlEvidence = new Url(url, true);

                    // We only create site evidence if the URL does not with file:
                    if (!url.StartsWith("file:", StringComparison.OrdinalIgnoreCase))
                    {
                        m_siteEvidence = Site.CreateFromUrl(url);
                    }
                }

                m_generatedLocationEvidence = true;
            }
        }

        /// <summary>
        ///     Generate evidence for the file's Authenticode signature
        /// </summary>
        [SecuritySafeCritical]
        private Publisher GeneratePublisherEvidence()
        {
            byte[] certificate = null;
            GetPublisherCertificate(m_peFile, JitHelpers.GetObjectHandleOnStack(ref certificate));

            if (certificate == null)
            {
                return null;
            }

            return new Publisher(new X509Certificate(certificate));
        }

        /// <summary>
        ///     Generate evidence for the site this file was loaded from
        /// </summary>
        private Site GenerateSiteEvidence()
        {
            if (m_siteEvidence == null)
            {
                GenerateLocationEvidence();
            }

            return m_siteEvidence;
        }

        /// <summary>
        ///     Generate evidence for the URL this file was loaded from
        /// </summary>
        private Url GenerateUrlEvidence()
        {
            if (m_urlEvidence == null)
            {
                GenerateLocationEvidence();
            }

            return m_urlEvidence;
        }

        /// <summary>
        ///     Generate evidence for the zone this file was loaded from
        /// </summary>
        private Zone GenerateZoneEvidence()
        {
            if (m_zoneEvidence == null)
            {
                GenerateLocationEvidence();
            }

            return m_zoneEvidence;
        }
    }
}