<commit_before>const db = firebase.database();
const auth = firebase.auth();

function logout() {
  auth.signOut();
}

function haySesion() {
  auth.onAuthStateChanged(function (user) {
    //si hay un usuario
    if (user) {
      mostrarPedidos();
    }
    else {
      $(location).attr("href", "index.html");
    }
  });
}

haySesion();

function mostrarPedidos() {
  let pedidosEntradaRef = db.ref('pedidoEntrada/');
  pedidosEntradaRef.on('value', function(snapshot) {
    let pedidos = snapshot.val();
    let row="";

    for(let pedido in pedidos) {
      let estado = "";
      switch(pedidos[pedido].encabezado.estado) {
        case "Pendiente":
          estado = '  fiber_manual_record	';
          break;
        case "En proceso":
          estado = '  fiber_manual_record	';
          break;
        case "Lista":
          estado = '  fiber_manual_record	';
          break;
      }

      row += '
' +
               '' + pedido +'	' +
               '' + pedidos[pedido].encabezado.fechaCaptura + '	' +
               '' + pedidos[pedido].encabezado.tienda +'	' +
               '' + pedidos[pedido].encabezado.ruta +'	' +
               '<button type="button" class="btn btn-info btn-sm"></button>	' +
               estado +
             '
';
    }

    $('#tablaPedidos tbody').empty().append(row);
  });
}

dragula([document.getElementById('tbodyTablaPedidos'), document.getElementById('tbodyTablaPedidoPadre')]);

function generarPedidoPadre() {
  var pedidos = [];

  $("#tablaPedidoPadre tbody tr").each(function (i)
  {
    var clave;
    $(this).children("td").each(function (j)
    {
      if(j == 0) {
        clave = $(this).text();
      }
    });

    if($(this).attr('id') !="vacio"){
      let pedidoRef = db.ref('pedidoEntrada/'+clave);
      pedidoRef.once('value', function(snapshot) {
        let pedido = snapshot.val();
        pedidos.push(pedido);
      });
    }
  });

  let fechaCreacionPadre = moment().format('DD/MM/YYYY');
  let pedidoPadreRef = db.ref('pedidoPadre/');
  let datosPedidoPadre = {
    fechaCreacionPadre: fechaCreacionPadre
  }
  let key = pedidoPadreRef.push(datosPedidoPadre).getKey();

  let pedidoPadreRefKey = db.ref('pedidoPadre/'+key+'/pedidosHijos');
}
<commit_msg>Se agregó fechaRuta, ruta<commit_after>const db = firebase.database();
const auth = firebase.auth();

function logout() {
  auth.signOut();
}

function haySesion() {
  auth.onAuthStateChanged(function (user) {
    //si hay un usuario
    if (user) {
      mostrarPedidos();
    }
    else {
      $(location).attr("href", "index.html");
    }
  });
}

haySesion();

function mostrarPedidos() {
  let pedidosEntradaRef = db.ref('pedidoEntrada/');
  pedidosEntradaRef.on('value', function(snapshot) {
    let pedidos = snapshot.val();
    let row="";

    for(let pedido in pedidos) {
      let estado = "";
      switch(pedidos[pedido].encabezado.estado) {
        case "Pendiente":
          estado = '  fiber_manual_record	';
          break;
        case "En proceso":
          estado = '  fiber_manual_record	';
          break;
        case "Lista":
          estado = '  fiber_manual_record	';
          break;
      }

      row += '
' +
               '' + pedido +'	' +
               '' + pedidos[pedido].encabezado.fechaCaptura + '	' +
               '' + pedidos[pedido].encabezado.tienda +'	' +
               '' + pedidos[pedido].encabezado.ruta +'	' +
               '<button type="button" class="btn btn-info btn-sm"></button>	' +
               estado +
             '
';
    }

    $('#tablaPedidos tbody').empty().append(row);
  });
}

dragula([document.getElementById('tbodyTablaPedidos'), document.getElementById('tbodyTablaPedidoPadre')]);

function generarPedidoPadre() {
  var pedidos = [];

  $("#tablaPedidoPadre tbody tr").each(function (i)
  {
    var clave;
    $(this).children("td").each(function (j)
    {
      if(j == 0) {
        clave = $(this).text();
      }
    });

    if($(this).attr('id') !="vacio"){
      let pedidoRef = db.ref('pedidoEntrada/'+clave);
      pedidoRef.once('value', function(snapshot) {
        let pedido = snapshot.val();
        pedidos.push(pedido);
      });
    }
  });

  let fechaCreacionPadre = moment().format('DD/MM/YYYY');
  let pedidoPadreRef = db.ref('pedidoPadre/');
  let datosPedidoPadre = {
    fechaCreacionPadre: fechaCreacionPadre,
    fechaRuta: "",
    ruta: ""
  }
  let key = pedidoPadreRef.push(datosPedidoPadre).getKey();

  let pedidoPadreRefKey = db.ref('pedidoPadre/'+key+'/pedidosHijos');

  for(let pedido in pedidos) {
    pedidoPadreRefKey.push(pedidos[pedido]);
  }
}
<|endoftext|>


<commit_before>/*
 * The Tie point editor is the main class for an individual OL3 imageviewer
 */

function EventTriggerEditor(imageContainerDivName, editorCount) {
	this.planetDivName = "planetWrapper" + editorCount;
	this.divName = "imageWrapper" + editorCount;
	this.toolbarDivName = "imageToolbar" + editorCount;
	this.imageDivName = "image" + editorCount;
	this.imageNameField = "imageName" + editorCount;
	this.bannerDivName = "imgBanner" + editorCount;

	this.drawShapeButton = "drawShapeBtn" + editorCount;
	this.drawHeightSpinner = "drawHeightSpinner" + editorCount;
	this.removeButton = "removeBtn" + editorCount;

	this.editorId = editorCount;
	this.img = null;
	this.isInitializing = false;

	var divText = '
' +
			'

' +
			'

';
	$('#' + imageContainerDivName).append(divText);

	$('#' + this.bannerDivName).html('' +
		'
Includes material ©2016 Planet Labs Inc. All rights reserved.
' +
		'
DISTRIBUTION STATEMENT C: Distribution authorized to U.S. Government Agencies and their contractors (Administrative or Operational Use) Other requests for this document shall be referred to AFRL/RYAA, Wright-Patterson Air Force Base, OH 45433-7321.
');

  	this.initializeContainerSize();
  	this.bannerHeight += 5;
  	this.imageHeight -= 5;

  	this.editorState = {
  		shape : [],
  		shapeHeight : 10,
  	};

  	console.log("STARTUP: Banner height " + this.bannerHeight + " image height " + this.imageHeight);
}

EventTriggerEditor.prototype.initialize = function(selectedImageSet, img) {
	if (this.isInitialzing) {
		return;
	}
	this.editorState.selectedImageSet = selectedImageSet;
	this.editorState.imageId = img.id;
	this.isInitializing = true;
	console.log("Initializing image " + img.name + " id " + img.id + " selectedImageSet " + selectedImageSet);

  	this.initializeContainerSize();
  	console.log("Banner height " + this.bannerHeight + " image height " + this.imageHeight);
	$('#' + this.divName).css("height", this.imageHeight + "px");
	$('#' + this.imageDivName).html("");
	$('#' + this.toolbarDivName).html("");
	$('#' + this.toolbarDivName).toggle(true);
	$('#' + this.bannerDivName).toggle(true);
	$('#' + this.planetDivName).toggle(true);

	this.imgWidth = img.width;
	this.imgHeight = img.height;
	this.imgUrl = img.url;
	this.img = img;

	var imgWidth = this.imgWidth;
	var imgHeight = this.imgHeight;
	this.imgName = img.name;
	var url = this.imgUrl;
	var crossOrigin = 'anonymous';
	var that = this;
	this.selectedFeature = null;

	var imgCenter = [ imgWidth / 2, -imgHeight / 2 ];

	// Maps always need a projection, but Zoomify layers are not geo-referenced,
	// and
	// are only measured in pixels. So, we create a fake projection that the map
	// can use to properly display the layer.
	var proj = new ol.proj.Projection({
		code : 'ZOOMIFY',
		units : 'pixels',
		extent : [ 0, 0, imgWidth, imgHeight ]
	});

	//Zoomify image source
	var imgsource = new ol.source.Zoomify({
		url : url,
		size : [ imgWidth, imgHeight ],
		crossOriginKeyword : crossOrigin
	});

	//Creates the actual layer to get rendered, for tiled images
	var imgtile = new ol.layer.Tile({
		source : imgsource
	});

	//a vector of features, start with no features
	this.drawsource = new ol.source.Vector();

  //Styles for tie points
	var inactiveStyle = new ol.style.Style({
		image : new ol.style.Circle({
			radius : 5,
			stroke : new ol.style.Stroke({
				color : INACTIVE_COLOR,
				width : 2
			}),
		}),
		fill: new ol.style.Fill({
            color: 'rgba(255, 255, 255, 0.2)'
        }),
		stroke : new ol.style.Stroke({
			color : INACTIVE_COLOR,
			width : 2
		}),
	});
	var activeStyle = new ol.style.Style({
		image : new ol.style.Circle({
			radius : 5,
			stroke : new ol.style.Stroke({
				color : ACTIVE_COLOR,
				width : 2
			})
		}),
		fill: new ol.style.Fill({
            color: 'rgba(255, 255, 255, 0.2)'
        }),
		stroke : new ol.style.Stroke({
			color : ACTIVE_COLOR,
			width : 2
		}),
	});

	//Creates the actual layer to get rendered, for tiled images
	var vector = new ol.layer.Vector({
		source : that.drawsource,
		style : inactiveStyle
	});

  //This seems to handle events on the entire map, not just a feature?
	this.select = new ol.interaction.Select({
//		condition : ol.events.condition.singleClick,
//		addCondition : ol.events.condition.singleClick,
//		removeCondition : ol.events.condition.never,
//		toggleCondition : ol.events.condition.singleClick,
		style : activeStyle
	});

	this.modify = new ol.interaction.Modify({
		features : that.select.getFeatures(),
		style : activeStyle
	});

	this.modify.on('modifyend', function(e) {
		//mainViewer.completeEdit();
		console.log("Finished modifying...");
	});

	this.map = new ol.Map({
		interactions : ol.interaction.defaults().extend(
				[ that.select, that.modify ]),
		layers : [ imgtile, vector ],
		target : this.imageDivName,
		controls : [], // Disable default controls
		view : new ol.View({
			projection : proj,
			center : imgCenter,
			zoom : 1
		})
	});
	//I have NO clue what I'm doing here https://groups.google.com/forum/#!topic/ol3-dev/SEu5Js8OurU
  this.map.renderSync();
  //If I don't do this, coordinate will turn up null deep in ol because the mapping of
  //pixels to coordinates is not yet initialized. This then breaks a lot of code
  //By renderSync here, the pixel conversion code works and everything is happy.

   //This is used when adding a new point
	var drawingTool = new ol.interaction.Draw({
		source : that.drawsource,
		type : "Polygon" // can also be LineString, Polygon someday
	}); // global so we can remove it later

	drawingTool.on('drawend', function(e) {
		// make the drawn feature a candidate for
		// modification
		// that.currentAction = null;
		// that.selectedFeature = e.feature;
		// e.feature.controlPoint = that.activeControlPoint;
		// that.editorState[that.activeControlPoint.id] = {
		// 	feature : e.feature
		// };
		that.map.removeInteraction(drawingTool);
		//that.select.getFeatures().clear();
		that.map.addInteraction(that.select);
		//that.select.getFeatures().push(e.feature); // Make sure it continues to
		// 											// be selected
		// $('#' + that.addButton).prop("disabled", "disabled");
		// $('#' + that.removeButton).prop("disabled", "");
		// that.createTiePointFromFeature(e.feature);
		// mainViewer.startTiePointEdit(that, e.feature.controlPoint);
//		});
	});

  var that = this;

  // Set up the image editor toolbar buttons
	$('#' + this.toolbarDivName).append(
			'<button id="' + this.drawShapeButton + '">Draw Shape</button>');
	$('#' + this.drawShapeButton)
			.click(
					function(e) {
						console.log("start drawing shape");
						that.currentAction = "drawShape";
						that.map.removeInteraction(that.select);
						that.map.addInteraction(drawingTool);

					})
	$('#' + this.toolbarDivName).append(
			'Shape Height (in meters): <input id="' + this.drawHeightSpinner + '" value="' + this.editorState.shapeHeight + '"" size=4 max=9999 min=0 style="height:16px; width:40px;" type=number disabled></input>');
	$('#' + this.drawHeightSpinner).change(function() {
		var val = $('#' + that.drawHeightSpinner).val();
		if (!$.isNumeric(val) || val < 0 || val > 9999) {
			alert("Height must be between 0 and 9999 meters.");
			$('#' + that.drawHeightSpinner).val(that.editorState.shapeHeight);
		} else {
			that.editorState.shapeHeight = console.log("Height value is " + val);
		}
	});

	$('#' + this.toolbarDivName).append(
			'<button id="' + this.removeButton + '">Clear Drawing</button>');
	$('#' + this.removeButton)
			.click(
					function(e) {
						console.log("Clear");
						that.currentAction = "clear";

						that.drawsource.clear();
					})
}

EventTriggerEditor.prototype.blank = function() {
	this.img = null;
	this.isInitializing = false;
	$('#' + this.imageDivName).html("");
	$('#' + this.toolbarDivName).toggle(false);
	$('#' + this.planetDivName).toggle(false);
//	$('#' + this.bannerDivName).hide();
	// $('#' + this.divName).toggle(false);
}

EventTriggerEditor.prototype.show = function(width, height, scale) {
	$('#' + this.planetDivName).css("height", '100%');
	$('#' + this.planetDivName).css("width", width + '%');
	$('#' + this.bannerDivName).css("font-size", scale + '%');
	$('#' + this.planetDivName).toggle(true);
}

EventTriggerEditor.prototype.hide = function() {
	$('#' + this.planetDivName).toggle(false);
}

EventTriggerEditor.prototype.initializeContainerSize = function() {
	// $('#' + this.bannerDivName).html('' +
	// 	'
Includes material ©2016 Planet Labs Inc. All rights reserved.
' +
	// 	'
DISTRIBUTION STATEMENT C: Distribution authorized to U.S. Government Agencies and their contractors (Administrative or Operational Use) Other requests for this document shall be referred to AFRL/RYAA, Wright-Patterson Air Force Base, OH 45433-7321.
');

	var bheight = document.getElementById(this.bannerDivName).clientHeight;
	if (bheight > 0) {
		this.bannerHeight = bheight;
	}

	var cheight = $('#editorContentDiv').height();
	this.imageHeight = cheight - this.bannerHeight;
}

EventTriggerEditor.prototype.getDebugInfo = function() {
	if (this.drawsource) {
		var farray = this.drawsource.getFeatures();
		var text = this.divName + '
';
		for (var i = 0; i < farray.length; i++) {
			var points = farray[i].getGeometry().getCoordinates();
			text += "POLY " + points + '
';
		}
		return text;
	} else {
		return this.divName + ' has no drawn features.
';
	}

	if (this.map) {
		var center = this.map.getView().getCenter();
		var zoom = this.map.getView().getZoom();

		return "Center - " + center + " Zoom - "+ this.map.getView().getZoom() + "
";
	} else {
		return "No image displayed.
";
	}
}

<commit_msg>Wired up the new API to save event triggers<commit_after>/*
 * The Tie point editor is the main class for an individual OL3 imageviewer
 */

function EventTriggerEditor(imageContainerDivName, editorCount) {
	this.planetDivName = "planetWrapper" + editorCount;
	this.divName = "imageWrapper" + editorCount;
	this.toolbarDivName = "imageToolbar" + editorCount;
	this.imageDivName = "image" + editorCount;
	this.imageNameField = "imageName" + editorCount;
	this.bannerDivName = "imgBanner" + editorCount;

	this.drawShapeButton = "drawShapeBtn" + editorCount;
	this.drawHeightSpinner = "drawHeightSpinner" + editorCount;
	this.removeButton = "removeBtn" + editorCount;
	this.saveButton = "saveBtn" + editorCount;

	this.editorId = editorCount;
	this.img = null;
	this.isInitializing = false;

	var divText = '
' +
			'

' +
			'

';
	$('#' + imageContainerDivName).append(divText);

	$('#' + this.bannerDivName).html('' +
		'
Includes material ©2016 Planet Labs Inc. All rights reserved.
' +
		'
DISTRIBUTION STATEMENT C: Distribution authorized to U.S. Government Agencies and their contractors (Administrative or Operational Use) Other requests for this document shall be referred to AFRL/RYAA, Wright-Patterson Air Force Base, OH 45433-7321.
');

  	this.initializeContainerSize();
  	this.bannerHeight += 5;
  	this.imageHeight -= 5;

  	this.editorState = {
  		shape : [],
  		shapeHeight : 10,
  	};

  	console.log("STARTUP: Banner height " + this.bannerHeight + " image height " + this.imageHeight);
}

EventTriggerEditor.prototype.initialize = function(selectedImageSet, img) {
	if (this.isInitialzing) {
		return;
	}
	this.editorState.selectedImageSet = selectedImageSet;
	this.editorState.imageId = img.id;
	this.isInitializing = true;
	console.log("Initializing image " + img.name + " id " + img.id + " selectedImageSet " + selectedImageSet);

  	this.initializeContainerSize();
  	console.log("Banner height " + this.bannerHeight + " image height " + this.imageHeight);
	$('#' + this.divName).css("height", this.imageHeight + "px");
	$('#' + this.imageDivName).html("");
	$('#' + this.toolbarDivName).html("");
	$('#' + this.toolbarDivName).toggle(true);
	$('#' + this.bannerDivName).toggle(true);
	$('#' + this.planetDivName).toggle(true);

	this.imgWidth = img.width;
	this.imgHeight = img.height;
	this.imgUrl = img.url;
	this.img = img;

	var imgWidth = this.imgWidth;
	var imgHeight = this.imgHeight;
	this.imgName = img.name;
	var url = this.imgUrl;
	var crossOrigin = 'anonymous';
	var that = this;
	this.selectedFeature = null;

	var imgCenter = [ imgWidth / 2, -imgHeight / 2 ];

	// Maps always need a projection, but Zoomify layers are not geo-referenced,
	// and
	// are only measured in pixels. So, we create a fake projection that the map
	// can use to properly display the layer.
	var proj = new ol.proj.Projection({
		code : 'ZOOMIFY',
		units : 'pixels',
		extent : [ 0, 0, imgWidth, imgHeight ]
	});

	//Zoomify image source
	var imgsource = new ol.source.Zoomify({
		url : url,
		size : [ imgWidth, imgHeight ],
		crossOriginKeyword : crossOrigin
	});

	//Creates the actual layer to get rendered, for tiled images
	var imgtile = new ol.layer.Tile({
		source : imgsource
	});

	//a vector of features, start with no features
	this.drawsource = new ol.source.Vector();

  //Styles for tie points
	var inactiveStyle = new ol.style.Style({
		image : new ol.style.Circle({
			radius : 5,
			stroke : new ol.style.Stroke({
				color : INACTIVE_COLOR,
				width : 2
			}),
		}),
		fill: new ol.style.Fill({
            color: 'rgba(255, 255, 255, 0.2)'
        }),
		stroke : new ol.style.Stroke({
			color : INACTIVE_COLOR,
			width : 2
		}),
	});
	var activeStyle = new ol.style.Style({
		image : new ol.style.Circle({
			radius : 5,
			stroke : new ol.style.Stroke({
				color : ACTIVE_COLOR,
				width : 2
			})
		}),
		fill: new ol.style.Fill({
            color: 'rgba(255, 255, 255, 0.2)'
        }),
		stroke : new ol.style.Stroke({
			color : ACTIVE_COLOR,
			width : 2
		}),
	});

	//Creates the actual layer to get rendered, for tiled images
	var vector = new ol.layer.Vector({
		source : that.drawsource,
		style : inactiveStyle
	});

  //This seems to handle events on the entire map, not just a feature?
	this.select = new ol.interaction.Select({
//		condition : ol.events.condition.singleClick,
//		addCondition : ol.events.condition.singleClick,
//		removeCondition : ol.events.condition.never,
//		toggleCondition : ol.events.condition.singleClick,
		style : activeStyle
	});

	this.modify = new ol.interaction.Modify({
		features : that.select.getFeatures(),
		style : activeStyle
	});

	this.modify.on('modifyend', function(e) {
		//mainViewer.completeEdit();
		console.log("Finished modifying...");
	});

	this.map = new ol.Map({
		interactions : ol.interaction.defaults().extend(
				[ that.select, that.modify ]),
		layers : [ imgtile, vector ],
		target : this.imageDivName,
		controls : [], // Disable default controls
		view : new ol.View({
			projection : proj,
			center : imgCenter,
			zoom : 1
		})
	});
	//I have NO clue what I'm doing here https://groups.google.com/forum/#!topic/ol3-dev/SEu5Js8OurU
  this.map.renderSync();
  //If I don't do this, coordinate will turn up null deep in ol because the mapping of
  //pixels to coordinates is not yet initialized. This then breaks a lot of code
  //By renderSync here, the pixel conversion code works and everything is happy.

   //This is used when adding a new point
	var drawingTool = new ol.interaction.Draw({
		source : that.drawsource,
		type : "Polygon" // can also be LineString, Polygon someday
	}); // global so we can remove it later

	drawingTool.on('drawend', function(e) {
		console.log("Drawing ended");
		// make the drawn feature a candidate for
		// modification
		// that.currentAction = null;
		// that.selectedFeature = e.feature;
		// e.feature.controlPoint = that.activeControlPoint;
		// that.editorState[that.activeControlPoint.id] = {
		// 	feature : e.feature
		// };
		that.map.removeInteraction(drawingTool);
		//that.select.getFeatures().clear();
		that.map.addInteraction(that.select);
		//that.select.getFeatures().push(e.feature); // Make sure it continues to
		// 											// be selected
		// $('#' + that.addButton).prop("disabled", "disabled");
		// $('#' + that.removeButton).prop("disabled", "");
		// that.createTiePointFromFeature(e.feature);
		// mainViewer.startTiePointEdit(that, e.feature.controlPoint);
		//		});

		$('#' + that.drawShapeButton).toggle(false);
		$('#' + that.saveButton).toggle(true);
	});

  var that = this;

  // Set up the image editor toolbar buttons
  	$('#' + this.toolbarDivName).append(
			'<button id="' + this.saveButton + '" style="display:none">Save Shape</button>');
	$('#' + this.saveButton)
			.click(
					function(e) {
						console.log("save shape");
						that.currentAction = "saveShape";
						var saveName = prompt("Save shape as: ");
						that.saveShape(saveName);
					});
	$('#' + this.toolbarDivName).append(
			'<button id="' + this.drawShapeButton + '">Draw Shape</button>');
	$('#' + this.drawShapeButton)
			.click(
					function(e) {
						console.log("start drawing shape");
						that.currentAction = "drawShape";
						that.map.removeInteraction(that.select);
						that.map.addInteraction(drawingTool);
					})
	$('#' + this.toolbarDivName).append(
			'Shape Height (in meters): <input id="' + this.drawHeightSpinner + '" value="' + this.editorState.shapeHeight + '"" size=4 max=9999 min=0 style="height:16px; width:40px;" type=number disabled></input>');
	$('#' + this.drawHeightSpinner).change(function() {
		var val = $('#' + that.drawHeightSpinner).val();
		if (!$.isNumeric(val) || val < 0 || val > 9999) {
			alert("Height must be between 0 and 9999 meters.");
			$('#' + that.drawHeightSpinner).val(that.editorState.shapeHeight);
		} else {
			that.editorState.shapeHeight = console.log("Height value is " + val);
		}
	});

	$('#' + this.toolbarDivName).append(
			'<button id="' + this.removeButton + '">Clear Drawing</button>');
	$('#' + this.removeButton)
			.click(
					function(e) {
						console.log("Clear");
						that.currentAction = "clear";

						that.drawsource.clear();
						$('#' + that.saveButton).toggle(false);
						$('#' + that.drawShapeButton).toggle(true);
					})
}

EventTriggerEditor.prototype.blank = function() {
	this.img = null;
	this.isInitializing = false;
	$('#' + this.imageDivName).html("");
	$('#' + this.toolbarDivName).toggle(false);
	$('#' + this.planetDivName).toggle(false);
//	$('#' + this.bannerDivName).hide();
	// $('#' + this.divName).toggle(false);
}

EventTriggerEditor.prototype.show = function(width, height, scale) {
	$('#' + this.planetDivName).css("height", '100%');
	$('#' + this.planetDivName).css("width", width + '%');
	$('#' + this.bannerDivName).css("font-size", scale + '%');
	$('#' + this.planetDivName).toggle(true);
}

EventTriggerEditor.prototype.hide = function() {
	$('#' + this.planetDivName).toggle(false);
}

EventTriggerEditor.prototype.initializeContainerSize = function() {
	// $('#' + this.bannerDivName).html('' +
	// 	'
Includes material ©2016 Planet Labs Inc. All rights reserved.
' +
	// 	'
DISTRIBUTION STATEMENT C: Distribution authorized to U.S. Government Agencies and their contractors (Administrative or Operational Use) Other requests for this document shall be referred to AFRL/RYAA, Wright-Patterson Air Force Base, OH 45433-7321.
');

	var bheight = document.getElementById(this.bannerDivName).clientHeight;
	if (bheight > 0) {
		this.bannerHeight = bheight;
	}

	var cheight = $('#editorContentDiv').height();
	this.imageHeight = cheight - this.bannerHeight;
}

EventTriggerEditor.prototype.saveShape = function(name) {
	console.log("Saving shape as " + name);
	if (this.drawsource) {
		var farray = this.drawsource.getFeatures();
		for (var i = 0; i < farray.length; i++) { // should only be 1 feature for now - a single shape
			var points = farray[i].getGeometry().getCoordinates();
			this.editorState.shape = points[0];
		}

		this.editorState.shapeString = "";
		for (var i = 0; i < this.editorState.shape.length; i++) {
			var pt = this.editorState.shape[i];
			pt[1] = -1 * pt[1];
			this.editorState.shapeString += pt[0] + "," + pt[1];
			if (i < this.editorState.shape.length - 1) {
				this.editorState.shapeString += ",";
			}
		}
	}

	this.editorState.saveName = name;

	console.log("Saving shape: " + this.editorState.shape);
	var that = this;

	// ANDY HERE...
	$.ajax({
			type : "GET",
			url : "/apps/event_trigger/create_event_trigger",
			data : {
				name : that.editorState.saveName,
				image_id : that.editorState.imageId,
				image_set_id : that.editorState.selectedImageSet,
				points : that.editorState.shapeString
			},
			success : function(data) {
				console.log("Event Trigger Saved");
			},
			error : function() {
				alert("Unable to save event trigger");
			},
			dataType : 'html'
		});
}

EventTriggerEditor.prototype.getDebugInfo = function() {
	if (this.drawsource) {
		var farray = this.drawsource.getFeatures();
		var text = this.divName + '
';
		for (var i = 0; i < farray.length; i++) {
			var points = farray[i].getGeometry().getCoordinates();
			text += "POLY " + points + '
';
		}
		return text;
	} else {
		return this.divName + ' has no drawn features.
';
	}

	if (this.map) {
		var center = this.map.getView().getCenter();
		var zoom = this.map.getView().getZoom();

		return "Center - " + center + " Zoom - "+ this.map.getView().getZoom() + "
";
	} else {
		return "No image displayed.
";
	}
}

<|endoftext|>


<commit_before>var suits = ["spades", "hearts", "diamonds", "clubs"];
var players = ["own", "left", "part", "right"];
var suit_image_template = "";
var update_cnt = 1000;
var current_bidder;

function on_body_load() {
    $("body").ajaxError(ajaxErrorHandler);
    $(document.documentElement).keypress(updator)
}

function updator(event) {
    if (event.charCode == 32) {
	get_json();
    }
}

function get_json() {
    $.getJSON("update.json", function(data){$.each(data, process_update);});
}

function process_update(i, data) {
    if (data.type == "move"){
	var v = data.value;
	var allowed = v.allowed;
	if (allowed == null) {
	    allowed = "any";
	}
	process_lead(v.player, v.suit, v.rank, allowed);
    } else if (data.type == "bid") {
	var v = data.value;
	var side = v.side;
	var bid = v.bid;
	$("#bidding_area tr:last td:eq(" + side + ")").html(bid);
	if (side == 3) {
	    $("#bidding_area").append("

")
	}
    } else if (data.type == "text") {
	window.alert("text message is not supported yet!");
    } else if (data.type == "hand") {
	var v = data.value;
	var player = v.player;
	var suits = v.suits;
	$.each(suits, function(i, suit){load_suit(player, suit)});
	$(".card_" + player).bind("click", player, do_lead)

    } else if (data.type == "claim") {
	window.alert("claim is not supported yet!");
    } else if (data.type = "start.bidding") {
	kick_bidding();
    } else if (data.type = "start.play") {
	window.alert("start.play is not supported yet!")
    }
}

function load_suit(player, suit) {
    var s = suit.suit;
    var cards = suit.cards;
    var divid = "#" + player + "_" + s;
    var card_str = cards.replace(/([2-9JQKA]|10)/g, "
$1
");
    $(divid).html(card_str);
}

function process_lead(player, suit, rank, allowed) {
    var card_div_id = "#" + suit + "_" + rank;
    $(card_div_id).detach();
    var lead_div_id = "#" + player + "_lead";
    $(lead_div_id).html(img_by_suit(suit) + rank);
    var np = next_player(player);
    var np_class = ".card_" + np;
    $(".card").unbind("click");
    $(".card").addClass("default_cursor");
    if (allowed == 'any') {
	$(np_class).bind("click", np, do_lead);
	$(np_class).removeClass("default_cursor");
    } else {
	var np_suit_class = np_class + "_" + allowed;
	$(np_suit_class).bind("click", np, do_lead);
	$(np_suit_class).removeClass("default_cursor");
    }
}

function next_player(player) {
    var idx = $.inArray(player, players);
    if (idx == 3) {
	return players[0];
    } else {
	return players[idx + 1];
    }
}

function do_lead(event) {
    var player = event.data;
    var splitted_id = event.target.id.split("_");
    var suit = splitted_id[0];
    var rank = splitted_id[1];
    var url = "action.json?move/" + player + "/" + suit + "/" + rank;
    $.post(url);
}

function ajaxErrorHandler(event, xhr, opts, error) {
    // retry should be here for some requests
    window.alert("request failed");
}

function img_by_suit(suit) {
    if (suits.indexOf(suit) >= 0) {
	var c = suit.charAt(0);
	return suit_image_template.replace("{suit}", c).replace("{alt_suit}", c.toUpperCase());
    }

}

function kick_bidding() {
    $("#lead_area").addClass("hidden");
    $(".bidbox_bid,.bidbox_pass,.bidbox_dbl,.bidbox_rdbl").bind("click", do_bid).addClass("clickable");
    current_bidder = 0;
}

function do_bid(event) {
    var splitted_id = event.currentTarget.id.split("_");
    var bid = splitted_id[1];

    var url = "action.json?bid/" + players[current_bidder] + "/" + bid;
    current_bidder = (current_bidder + 1) % 4;
    $.post(url);
}<commit_msg>use apropriate pics for suits in bid<commit_after>var suits = ["spades", "hearts", "diamonds", "clubs"];
var players = ["own", "left", "part", "right"];
var suit_image_template = "";
var update_cnt = 1000;
var current_bidder;

function on_body_load() {
    $("body").ajaxError(ajaxErrorHandler);
    $(document.documentElement).keypress(updator)
}

function updator(event) {
    if (event.charCode == 32) {
	get_json();
    }
}

function get_json() {
    $.getJSON("update.json", function(data){$.each(data, process_update);});
}

function process_update(i, data) {
    if (data.type == "move"){
	var v = data.value;
	var allowed = v.allowed;
	if (allowed == null) {
	    allowed = "any";
	}
	process_lead(v.player, v.suit, v.rank, allowed);
    } else if (data.type == "bid") {
	var v = data.value;
	var side = v.side;
	var bid = v.bid;
	var c = bid[1].toLowerCase();
	var img = suit_image_template.replace("{suit}", c).replace("{alt_suit}", c.toUpperCase());
	$("#bidding_area tr:last td:eq(" + side + ")").html(bid[0] + img);
	if (side == 3) {
	    $("#bidding_area").append("

")
	}
    } else if (data.type == "text") {
	window.alert("text message is not supported yet!");
    } else if (data.type == "hand") {
	var v = data.value;
	var player = v.player;
	var suits = v.suits;
	$.each(suits, function(i, suit){load_suit(player, suit)});
	$(".card_" + player).bind("click", player, do_lead)

    } else if (data.type == "claim") {
	window.alert("claim is not supported yet!");
    } else if (data.type = "start.bidding") {
	kick_bidding();
    } else if (data.type = "start.play") {
	window.alert("start.play is not supported yet!")
    }
}

function load_suit(player, suit) {
    var s = suit.suit;
    var cards = suit.cards;
    var divid = "#" + player + "_" + s;
    var card_str = cards.replace(/([2-9JQKA]|10)/g, "
$1
");
    $(divid).html(card_str);
}

function process_lead(player, suit, rank, allowed) {
    var card_div_id = "#" + suit + "_" + rank;
    $(card_div_id).detach();
    var lead_div_id = "#" + player + "_lead";
    $(lead_div_id).html(img_by_suit(suit) + rank);
    var np = next_player(player);
    var np_class = ".card_" + np;
    $(".card").unbind("click");
    $(".card").addClass("default_cursor");
    if (allowed == 'any') {
	$(np_class).bind("click", np, do_lead);
	$(np_class).removeClass("default_cursor");
    } else {
	var np_suit_class = np_class + "_" + allowed;
	$(np_suit_class).bind("click", np, do_lead);
	$(np_suit_class).removeClass("default_cursor");
    }
}

function next_player(player) {
    var idx = $.inArray(player, players);
    if (idx == 3) {
	return players[0];
    } else {
	return players[idx + 1];
    }
}

function do_lead(event) {
    var player = event.data;
    var splitted_id = event.target.id.split("_");
    var suit = splitted_id[0];
    var rank = splitted_id[1];
    var url = "action.json?move/" + player + "/" + suit + "/" + rank;
    $.post(url);
}

function ajaxErrorHandler(event, xhr, opts, error) {
    // retry should be here for some requests
    window.alert("request failed");
}

function img_by_suit(suit) {
    if (suits.indexOf(suit) >= 0) {
	var c = suit.charAt(0);
	return suit_image_template.replace("{suit}", c).replace("{alt_suit}", c.toUpperCase());
    }

}

function kick_bidding() {
    $("#lead_area").addClass("hidden");
    $(".bidbox_bid,.bidbox_pass,.bidbox_dbl,.bidbox_rdbl").bind("click", do_bid).addClass("clickable");
    current_bidder = 0;
}

function do_bid(event) {
    var splitted_id = event.currentTarget.id.split("_");
    var bid = splitted_id[1];

    var url = "action.json?bid/" + players[current_bidder] + "/" + bid;
    current_bidder = (current_bidder + 1) % 4;
    $.post(url);
}<|endoftext|>


<commit_before>import createPreferences from "preferences/PreferenceCreator";
import {MIN_SUSTAINED_AUDIO_SECONDS, MIN_BUFFER_LENGTH_SECONDS} from "audio/frontend/buffering";
export {equalizerBands, equalizerPresets} from "audio/backend/Effects";
import {equalizerPresets} from "audio/backend/Effects";

export const EQUALIZER_MAX_GAIN = 12;
export const EQUALIZER_MIN_GAIN = -12;
export const STORAGE_KEY = `effect-preferences`;
export const CROSSFADE_MIN_DURATION = Math.max(MIN_BUFFER_LENGTH_SECONDS, 1);
export const CROSSFADE_MAX_DURATION = 5;
export const CROSSFADE_DEFAULT_DURATION = Math.min(CROSSFADE_MAX_DURATION, Math.max(CROSSFADE_MIN_DURATION, 5));
export const MIN_NOISE_SHARPENING_EFFECT_SIZE = 0;
export const MAX_NOISE_SHARPENING_EFFECT_SIZE = 2;
export const DEFAULT_NOISE_SHARPENING_EFFECT_SIZE = 0.6;
export const MIN_BASS_BOOST_EFFECT_SIZE = 0;
export const MAX_BASS_BOOST_EFFECT_SIZE = 1;
export const DEFAULT_BASS_BOOST_EFFECT_SIZE = 0.4;

export const gainValueToProgress = function(gainValue) {
    const max = Math.abs(EQUALIZER_MIN_GAIN) + Math.abs(EQUALIZER_MAX_GAIN);
    const abs = gainValue + EQUALIZER_MAX_GAIN;
    return abs / max;
};

export const progressToGainValue = function(progress) {
    const max = Math.abs(EQUALIZER_MIN_GAIN) + Math.abs(EQUALIZER_MAX_GAIN);
    const value = Math.round(progress * max);
    return value - Math.abs(EQUALIZER_MAX_GAIN);
};

export const formatFreq = function(freq) {
    if (freq < 1000) {
        return `${freq} Hz`;
    } else {
        return `${Math.round(freq / 1000)} KHz`;
    }
};

export const equalizerPresetKeys = Object.keys(equalizerPresets);

export const Preferences = createPreferences({
    methods: {
        getMatchingEqualizerPresetName() {
            const equalizer = this.getInPlaceEqualizer();
            for (let i = 0; i < equalizerPresetKeys.length; ++i) {
                const name = equalizerPresetKeys[i];
                const preset = equalizerPresets[name];
                if (this._equals(preset, equalizer)) {
                    return name;
                }
            }
            return `Custom`;
        }
    },

    preferences: {
        equalizer: {
            defaultValue: equalizerPresets.None,
            asValidValue(value) {
                if (!Array.isArray(value) || value.length !== 10) {
                    return this.defaultEqualizer;
                }

                for (let i = 0; i < value.length; ++i) {
                    value[i] = (Math.max(EQUALIZER_MIN_GAIN, Math.min(EQUALIZER_MAX_GAIN, +value[i]))) || 0;
                }

                return value;
            }
        },

        bassBoostStrength: {
            defaultValue: DEFAULT_BASS_BOOST_EFFECT_SIZE,
            asValidValue(value) {
                const ret = Math.max(MIN_BASS_BOOST_EFFECT_SIZE, Math.min(MAX_BASS_BOOST_EFFECT_SIZE, +value));
                return isFinite(ret) ? ret : this.defaultBassBoostStrength;
            }
        },

        bassBoostEnabled: {
            defaultValue: false,
            asValidValue(value) {
                return !!value;
            }
        },

        noiseSharpeningStrength: {
            defaultValue: DEFAULT_NOISE_SHARPENING_EFFECT_SIZE,
            asValidValue(value) {
                const ret = Math.max(MIN_NOISE_SHARPENING_EFFECT_SIZE, Math.min(MAX_NOISE_SHARPENING_EFFECT_SIZE, +value));
                return isFinite(ret) ? ret : this.defaultNoiseSharpeningStrength;
            }
        },

        noiseSharpeningEnabled: {
            defaultValue: true,
            asValidValue(value) {
                return !!value;
            }
        },

        shouldAlbumNotCrossfade: {
            defaultValue: true,
            asValidValue(value) {
                return !!value;
            }
        },

        crossfadeEnabled: {
            defaultValue: false,
            asValidValue(value) {
                return !!value;
            }
        },

        crossfadeDuration: {
            defaultValue: CROSSFADE_DEFAULT_DURATION,
            asValidValue(value) {
                if (!isFinite(+value)) return CROSSFADE_DEFAULT_DURATION;
                return Math.min(Math.max(CROSSFADE_MIN_DURATION, +value), CROSSFADE_MAX_DURATION);
            }
        }
    }
});
<commit_msg>disable noise sharpening by default<commit_after>import createPreferences from "preferences/PreferenceCreator";
import {MIN_SUSTAINED_AUDIO_SECONDS, MIN_BUFFER_LENGTH_SECONDS} from "audio/frontend/buffering";
export {equalizerBands, equalizerPresets} from "audio/backend/Effects";
import {equalizerPresets} from "audio/backend/Effects";

export const EQUALIZER_MAX_GAIN = 12;
export const EQUALIZER_MIN_GAIN = -12;
export const STORAGE_KEY = `effect-preferences`;
export const CROSSFADE_MIN_DURATION = Math.max(MIN_BUFFER_LENGTH_SECONDS, 1);
export const CROSSFADE_MAX_DURATION = 5;
export const CROSSFADE_DEFAULT_DURATION = Math.min(CROSSFADE_MAX_DURATION, Math.max(CROSSFADE_MIN_DURATION, 5));
export const MIN_NOISE_SHARPENING_EFFECT_SIZE = 0;
export const MAX_NOISE_SHARPENING_EFFECT_SIZE = 2;
export const DEFAULT_NOISE_SHARPENING_EFFECT_SIZE = 0.6;
export const MIN_BASS_BOOST_EFFECT_SIZE = 0;
export const MAX_BASS_BOOST_EFFECT_SIZE = 1;
export const DEFAULT_BASS_BOOST_EFFECT_SIZE = 0.4;

export const gainValueToProgress = function(gainValue) {
    const max = Math.abs(EQUALIZER_MIN_GAIN) + Math.abs(EQUALIZER_MAX_GAIN);
    const abs = gainValue + EQUALIZER_MAX_GAIN;
    return abs / max;
};

export const progressToGainValue = function(progress) {
    const max = Math.abs(EQUALIZER_MIN_GAIN) + Math.abs(EQUALIZER_MAX_GAIN);
    const value = Math.round(progress * max);
    return value - Math.abs(EQUALIZER_MAX_GAIN);
};

export const formatFreq = function(freq) {
    if (freq < 1000) {
        return `${freq} Hz`;
    } else {
        return `${Math.round(freq / 1000)} KHz`;
    }
};

export const equalizerPresetKeys = Object.keys(equalizerPresets);

export const Preferences = createPreferences({
    methods: {
        getMatchingEqualizerPresetName() {
            const equalizer = this.getInPlaceEqualizer();
            for (let i = 0; i < equalizerPresetKeys.length; ++i) {
                const name = equalizerPresetKeys[i];
                const preset = equalizerPresets[name];
                if (this._equals(preset, equalizer)) {
                    return name;
                }
            }
            return `Custom`;
        }
    },

    preferences: {
        equalizer: {
            defaultValue: equalizerPresets.None,
            asValidValue(value) {
                if (!Array.isArray(value) || value.length !== 10) {
                    return this.defaultEqualizer;
                }

                for (let i = 0; i < value.length; ++i) {
                    value[i] = (Math.max(EQUALIZER_MIN_GAIN, Math.min(EQUALIZER_MAX_GAIN, +value[i]))) || 0;
                }

                return value;
            }
        },

        bassBoostStrength: {
            defaultValue: DEFAULT_BASS_BOOST_EFFECT_SIZE,
            asValidValue(value) {
                const ret = Math.max(MIN_BASS_BOOST_EFFECT_SIZE, Math.min(MAX_BASS_BOOST_EFFECT_SIZE, +value));
                return isFinite(ret) ? ret : this.defaultBassBoostStrength;
            }
        },

        bassBoostEnabled: {
            defaultValue: false,
            asValidValue(value) {
                return !!value;
            }
        },

        noiseSharpeningStrength: {
            defaultValue: DEFAULT_NOISE_SHARPENING_EFFECT_SIZE,
            asValidValue(value) {
                const ret = Math.max(MIN_NOISE_SHARPENING_EFFECT_SIZE, Math.min(MAX_NOISE_SHARPENING_EFFECT_SIZE, +value));
                return isFinite(ret) ? ret : this.defaultNoiseSharpeningStrength;
            }
        },

        noiseSharpeningEnabled: {
            defaultValue: false,
            asValidValue(value) {
                return !!value;
            }
        },

        shouldAlbumNotCrossfade: {
            defaultValue: true,
            asValidValue(value) {
                return !!value;
            }
        },

        crossfadeEnabled: {
            defaultValue: false,
            asValidValue(value) {
                return !!value;
            }
        },

        crossfadeDuration: {
            defaultValue: CROSSFADE_DEFAULT_DURATION,
            asValidValue(value) {
                if (!isFinite(+value)) return CROSSFADE_DEFAULT_DURATION;
                return Math.min(Math.max(CROSSFADE_MIN_DURATION, +value), CROSSFADE_MAX_DURATION);
            }
        }
    }
});
<|endoftext|>


<commit_before>'use strict';

// Configuring the Articles module
angular.module('projects').run(['Menus', 'Authentication',
	function(Menus, Authentication) {
		// Set top bar menu items
		Menus.addMenuItem('topbar', 'Projects', 'projects', 'dropdown', '/projects(/create)?', false);
		Menus.addSubMenuItem('topbar', 'projects', 'Client Portal', 'projects-client', false);
		Menus.addSubMenuItem('topbar', 'projects', 'List Projects', 'projects', false);
		Menus.addSubMenuItem('topbar', 'projects', 'New Project', 'projects/create', false, false, ['admin','producer/auditions director', 'production coordinator']);
		Menus.addSubMenuItem('topbar', 'projects', 'Start A New Audition Project', 'projects/new-audition-form', false, false, ['client']);
	}
]);<commit_msg>limit projects listing access<commit_after>'use strict';

// Configuring the Articles module
angular.module('projects').run(['Menus', 'Authentication',
	function(Menus, Authentication) {
		// Set top bar menu items
		Menus.addMenuItem('topbar', 'Projects', 'projects', 'dropdown', '/projects(/create)?', false);
		Menus.addSubMenuItem('topbar', 'projects', 'Client Portal', 'projects-client', false);
		Menus.addSubMenuItem('topbar', 'projects', 'List Projects', 'projects', false, false, ['admin','producer/auditions director', 'production coordinator', 'talent director']);
		Menus.addSubMenuItem('topbar', 'projects', 'New Project', 'projects/create', false, false, ['admin','producer/auditions director', 'production coordinator']);
		Menus.addSubMenuItem('topbar', 'projects', 'Start A New Audition Project', 'projects/new-audition-form', false, false, ['client']);
	}
]);<|endoftext|>


<commit_before>Ext.define('Ext.wasp.GridPortlet', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.gridportlet',
    uses: [
        'Ext.data.ArrayStore'
    ],
    height: 300,
     myData: [
//        ['Altria Group Inc',                    83.81, 0.28,  0.34,  '9/1 12:00am'],
//        ['American Express Company',            52.55, 0.01,  0.02,  '9/1 12:00am'],
//        ['American International Group, Inc.',  64.13, 0.31,  0.49,  '9/1 12:00am'],
//        ['AT&T Inc.',                           31.61, -0.48, -1.54, '9/1 12:00am'],
//        ['Boeing Co.',                          75.43, 0.53,  0.71,  '9/1 12:00am'],
//        ['Caterpillar Inc.',                    67.27, 0.92,  1.39,  '9/1 12:00am'],
//        ['Citigroup, Inc.',                     49.37, 0.02,  0.04,  '9/1 12:00am'],
//        ['E.I. du Pont de Nemours and Company', 40.48, 0.51,  1.28,  '9/1 12:00am'],
//        ['Exxon Mobil Corp',                    68.1,  -0.43, -0.64, '9/1 12:00am'],
//        ['General Electric Company',            34.14, -0.08, -0.23, '9/1 12:00am'],
//        ['General Motors Corporation',          30.27, 1.09,  3.74,  '9/1 12:00am'],
//        ['Hewlett-Packard Co.',                 36.53, -0.03, -0.08, '9/1 12:00am'],
//        ['Honeywell Intl Inc',                  38.77, 0.05,  0.13,  '9/1 12:00am'],
//        ['Intel Corporation',                   19.88, 0.31,  1.58,  '9/1 12:00am'],
//        ['International Business Machines',     81.41, 0.44,  0.54,  '9/1 12:00am'],
//        ['Johnson & Johnson',                   64.72, 0.06,  0.09,  '9/1 12:00am'],
//        ['JP Morgan & Chase & Co',              45.73, 0.07,  0.15,  '9/1 12:00am'],
//        ['McDonald\'s Corporation',             36.76, 0.86,  2.40,  '9/1 12:00am'],
//        ['Merck & Co., Inc.',                   40.96, 0.41,  1.01,  '9/1 12:00am'],
//        ['Microsoft Corporation',               25.84, 0.14,  0.54,  '9/1 12:00am'],
//        ['Pfizer Inc',                          27.96, 0.4,   1.45,  '9/1 12:00am'],
//        ['The Coca-Cola Company',               45.07, 0.26,  0.58,  '9/1 12:00am'],
//        ['The Home Depot, Inc.',                34.64, 0.35,  1.02,  '9/1 12:00am'],
//        ['The Procter & Gamble Company',        61.91, 0.01,  0.02,  '9/1 12:00am'],
//        ['United Technologies Corporation',     63.26, 0.55,  0.88,  '9/1 12:00am'],
//        ['Verizon Communications',              35.57, 0.39,  1.11,  '9/1 12:00am'],
//        ['Wal-Mart Stores, Inc.',               45.45, 0.73,  1.63,  '9/1 12:00am']
    ],

    /**
     * Custom function used for column renderer
     * @param {Object} val
     */
    status: function(val) {
        if (val == 'COMPLETED') {
            return '' + val + '';
        } else {
            return '' + val + '';
        }
        return val;
    },

    initComponent: function(){

        var store = Ext.create('Ext.data.ArrayStore', {
            fields: [
               {name: 'plugins'},
               {name: 'description'},
               {name: 'status'}
            ],
            data: this.myData
        });

        Ext.apply(this, {
            //height: 300,
            height: this.height,
            store: store,
            stripeRows: true,
            columnLines: true,
            forceFit: true,
            columns: [{
                id       :'plugins',
                text   : 'Name',
                width    : 200,
                sortable : true,
                dataIndex: 'plugins'
            },{
                text   : 'Description',
                //width: 120,
                flex: 1,
                sortable : true,
                dataIndex: 'description'
            },{
                text   : 'Status',
                width    : 150,
                sortable : true,
                renderer : this.status,
                dataIndex: 'status'
            }]
        });

        this.callParent(arguments);
    }
});
<commit_msg>some tweaks<commit_after>Ext.define('Ext.wasp.GridPortlet', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.gridportlet',
    uses: [
        'Ext.data.ArrayStore'
    ],
    height: 300,
     myData: [
//        ['Altria Group Inc',                    83.81, 0.28,  0.34,  '9/1 12:00am'],
//        ['American Express Company',            52.55, 0.01,  0.02,  '9/1 12:00am'],
//        ['American International Group, Inc.',  64.13, 0.31,  0.49,  '9/1 12:00am'],
//        ['AT&T Inc.',                           31.61, -0.48, -1.54, '9/1 12:00am'],
//        ['Boeing Co.',                          75.43, 0.53,  0.71,  '9/1 12:00am'],
//        ['Caterpillar Inc.',                    67.27, 0.92,  1.39,  '9/1 12:00am'],
//        ['Citigroup, Inc.',                     49.37, 0.02,  0.04,  '9/1 12:00am'],
//        ['E.I. du Pont de Nemours and Company', 40.48, 0.51,  1.28,  '9/1 12:00am'],
//        ['Exxon Mobil Corp',                    68.1,  -0.43, -0.64, '9/1 12:00am'],
//        ['General Electric Company',            34.14, -0.08, -0.23, '9/1 12:00am'],
//        ['General Motors Corporation',          30.27, 1.09,  3.74,  '9/1 12:00am'],
//        ['Hewlett-Packard Co.',                 36.53, -0.03, -0.08, '9/1 12:00am'],
//        ['Honeywell Intl Inc',                  38.77, 0.05,  0.13,  '9/1 12:00am'],
//        ['Intel Corporation',                   19.88, 0.31,  1.58,  '9/1 12:00am'],
//        ['International Business Machines',     81.41, 0.44,  0.54,  '9/1 12:00am'],
//        ['Johnson & Johnson',                   64.72, 0.06,  0.09,  '9/1 12:00am'],
//        ['JP Morgan & Chase & Co',              45.73, 0.07,  0.15,  '9/1 12:00am'],
//        ['McDonald\'s Corporation',             36.76, 0.86,  2.40,  '9/1 12:00am'],
//        ['Merck & Co., Inc.',                   40.96, 0.41,  1.01,  '9/1 12:00am'],
//        ['Microsoft Corporation',               25.84, 0.14,  0.54,  '9/1 12:00am'],
//        ['Pfizer Inc',                          27.96, 0.4,   1.45,  '9/1 12:00am'],
//        ['The Coca-Cola Company',               45.07, 0.26,  0.58,  '9/1 12:00am'],
//        ['The Home Depot, Inc.',                34.64, 0.35,  1.02,  '9/1 12:00am'],
//        ['The Procter & Gamble Company',        61.91, 0.01,  0.02,  '9/1 12:00am'],
//        ['United Technologies Corporation',     63.26, 0.55,  0.88,  '9/1 12:00am'],
//        ['Verizon Communications',              35.57, 0.39,  1.11,  '9/1 12:00am'],
//        ['Wal-Mart Stores, Inc.',               45.45, 0.73,  1.63,  '9/1 12:00am']
    ],

    /**
     * Custom function used for column renderer
     * @param {Object} val
     */
    status: function(val) {
        if (val == 'COMPLETED') {
            return 'Completed';
        } else if (val == 'UNKNOWN') {
            return 'Not Invoked';
        } else {
            return 'Failed';
        }
        return val;
    },

    initComponent: function(){

        var store = Ext.create('Ext.data.ArrayStore', {
            fields: [
               {name: 'plugins'},
               {name: 'description'},
               {name: 'status'}
            ],
            data: this.myData
        });

        Ext.apply(this, {
            //height: 300,
            height: this.height,
            store: store,
            stripeRows: true,
            columnLines: true,
            forceFit: true,
            columns: [{
                id       :'plugins',
                text   : 'Name',
                width    : 200,
                sortable : true,
                dataIndex: 'plugins'
            },{
                text   : 'Description',
                //width: 120,
                flex: 1,
                sortable : true,
                dataIndex: 'description'
            },{
                text   : 'Status',
                width    : 150,
                sortable : true,
                renderer : this.status,
                dataIndex: 'status'
            }]
        });

        this.callParent(arguments);
    }
});
<|endoftext|>


<commit_before>function countdown(){
  var myTime = new Date();
  var end = new Date(2015, 7, 3);
  var count = end - myTime;
  var timeleft = new Date(count);
  var days = timeleft.getDate();
  var hours = timeleft.getUTCHours();
  var min = timeleft.getMinutes();
  var sec = timeleft.getSeconds();
  var myText = [days, hours, min, sec].join(":");
  document.getElementById('timer').innerHTML = myText;
};

function count(){
  setInterval(function() {
    var myTime = new Date();
    var end = new Date(2015, 7, 3);
    var count = end - myTime;
    var timeleft = new Date(count);
    var days = paddnum(timeleft.getDate());
    var hours = paddnum(timeleft.getUTCHours());
    var min = paddnum(timeleft.getMinutes());
    var sec = paddnum(timeleft.getSeconds());
    var myText = [days, hours, min, sec].join(":");
    var my_sentence = ["Countdown to Onsite ", myText].join("- ")
    document.getElementById('timer').innerHTML = my_sentence;
  }, 1000);
};
function paddnum(num){
  if (num.toString.length != 2){
    num = ["0", num].join('');
  }
  return num;
};
<commit_msg>Add timer2<commit_after>function countdown(){
  var myTime = new Date();
  var end = new Date(2015, 7, 3);
  var count = end - myTime;
  var timeleft = new Date(count);
  var days = timeleft.getDate();
  var hours = timeleft.getUTCHours();
  var min = timeleft.getMinutes();
  var sec = timeleft.getSeconds();
  var myText = [days, hours, min, sec].join(":");
  document.getElementById('timer').innerHTML = myText;
};

function count(){
  setInterval(function() {
    var myTime = new Date();
    var end = new Date(2015, 7, 3);
    var count = end - myTime;
    var timeleft = new Date(count);
    var days = paddnum(timeleft.getDate());
    var hours = paddnum(timeleft.getUTCHours());
    var min = paddnum(timeleft.getMinutes());
    var sec = paddnum(timeleft.getSeconds());
    var myText = [days, hours, min, sec].join(":");
    var my_sentence = ["Countdown to Onsite ", myText].join("- ")
    document.getElementById('timer').innerHTML = my_sentence;
  }, 1000);
};
function paddnum(num){
  if (num.toString.length < 2){
    num = ["0", num].join('');
  }
  return num;
};
<|endoftext|>


<commit_before>async function serverFolderContents(args) {
/*
description("Get the folder contents")
base_component_id("server_folder_contents")
load_once_from_file(true)
only_run_on_server(true)
*/
console.log(JSON.stringify(args,null,2))

    var promise = new Promise(async function(returnfn) {

        var filterFileFn = function (file) {
          return fs.statSync(args.path+'/'+file).isFile();
        }

        var nert =  fs.readdirSync(args.path);
        let rettt=[]
        for (var ty=0;ty<nert.length;ty++) {
            if (filterFileFn(nert[ty])) {
                rettt.push({name: nert[ty], type: "file"})
            } else {
                rettt.push({name: nert[ty], type: "folder"})
            }
        }
        returnfn(rettt)

    })
    var ret = await promise
console.log(JSON.stringify(ret,null,2))

    return ret
}
<commit_msg>Only show code files in the Open File dialog box<commit_after>async function serverFolderContents(args) {
/*
description("Get the folder contents")
base_component_id("server_folder_contents")
load_once_from_file(true)
only_run_on_server(true)
*/
console.log(JSON.stringify(args,null,2))

    var promise = new Promise(async function(returnfn) {

        var filterFileFn = function (file) {
          return fs.statSync(args.path+'/'+file).isFile();
        }

        var nert =  fs.readdirSync(args.path);
        let rettt=[]
        for (var ty=0;ty<nert.length;ty++) {
            if (filterFileFn(nert[ty])) {
                if ((nert[ty].indexOf(".js") != -1 ) || (nert[ty].indexOf(".pilot") != -1 )) {
                    rettt.push({name: nert[ty], type: "file"})
                }
            } else {
                rettt.push({name: nert[ty], type: "folder"})
            }
        }
        returnfn(rettt)

    })
    var ret = await promise
console.log(JSON.stringify(ret,null,2))

    return ret
}
<|endoftext|>


<commit_before>

function Card(suit, value) {
  var face;
  if(typeof value == 'number') {
    face = value.toString();
  } else {
    face = value.face;
    value = value.value;
  }

  Object.defineProperties(this, {
    value: {
      get: function() { return value; }
    },
    suit: {
      get: function() { return suit; }
    },
    face: {
      get: function() { return face; }
    },
    isAce: {
      get: function() { return face == "Ace"; }
    }
  });
}

Card.prototype.toString = function() {
  return this.face + " of " + this.suit;
};

function DealingShoe(deckCount) {
  this.deckCount = deckCount || 6;
  this.cardCount = 52 * this.deckCount;

  this.resuffle();
}

DealingShoe.prototype.resuffle = function() {
  var builder = new Array(this.cardCount);
  var suits = ["Clubs", "Hearts", "Spades", "Diamonds"];
  var faces = [2, 3, 4, 5, 6, 7, 8, 9, 10, {
    face: 'Jack',
    value: 10
  }, {
    face: 'Queen',
    value: 10,
  }, {
    face: 'King',
    value: 10
  }, {
    face: 'Ace',
    value: 11
  }];

  for(var a = 0; a < this.deckCount; ++a) {
    suits.forEach(function(suit, i) {
      faces.forEach(function(value, j) {
        builder[(a * 52) + (i * 13) + j] = new Card(suit, value);
      });
    });
  }

  var orig = builder.concat([]);

  for(var i = 0; i < 1000000; ++i) {
    var src = Math.floor(Math.random() * this.cardCount);
    var dest = Math.floor(Math.random() * this.cardCount);
    var temp = builder[dest];

    builder[dest] = builder[src];
    builder[src] = temp;
  }

  this.cards = builder;
  this.position = 0;

  var totalDistance = 0;

  orig.forEach(function(current, i) {
    var j = i + 1;
    if(j == orig.length) {
      return;
    }

    var next = orig[j];
    var currentIndex;
    var nextIndex;
    builder.forEach(function(card, bldrIndex) {
      if(card.suit == current.suit && card.face == current.face) {
        currentIndex = bldrIndex;
      } else if(card.suit == next.suit && card.face == next.face) {
        nextIndex = bldrIndex;
      }
    });

    totalDistance += Math.abs(nextIndex - currentIndex);
  });

  console.log("distance: %s", (totalDistance / (orig.length - 1)).toString());
  console.log("total: %d", totalDistance)
  console.log("length: %d", orig.length);
};

DealingShoe.prototype.next = function() {
  if(this.position == this.cards.length) {
    this.resuffle();
    return this.next();
  } else {
    var card = this.cards[this.position];
    this.position += 1;

    return card;
  }
}

function makePlayerHand(engineHand) {
  return {
    cards: engineHand.cards.concat([]),
    value: engineHand.value,
    toString: function() {
      return engineHand.toString();
    }
  };
}

function makeTable(players, dealerCards) {
  var tbl = [];
  players.forEach(function(player) {
    tbl.push(player.hand.cards.concat([]));
  });

  tbl = tbl.concat(dealerCards)

  return tbl;
}

function EngineHand() {
  var cards = [];
  var _dirty = false;
  var _value = 0;

  Object.defineProperties(this, {
    // otherHand: {
    //   get: function() { return otherHand; }
    // },
    cards: {
      get: function() { return cards; }
    },

    push: {
      get: function() {
        return function(card) {
          _dirty = true;
          cards.push(card);
        }
      }
    },

    // canSplit: {
    //   get: function() {
    //     return canSplit(cards); //, otherHand != null);
    //   }
    // },

    value: {
      get: function() {
        if(_dirty) {
          var value = 0;
          var aces = 0;
          cards.forEach(function(card) {
            if(card.isAce) {
              aces += 1;
            } else {
              value += card.value;
            }
          });

          for(var i = 0; i < aces; ++i) {
            if((value + 11) > 21) {
              value += 1;
            } else {
              value += 11;
            }
          }

          _value = value;
          _dirty = false;
        }

        return _value;
      }
    },
    isBusted: {
      get: function() {
        return this.value > 21;
      }
    },
    isBlackjack: {
      get: function() {
        return this.cards.length == 2 && this.value == 21;
      }
    }
  });
}

EngineHand.prototype.toString = function() {
  return this.cards.join(', ') + ' [' + this.value.toString() + ']';
};

function Actions() {
  Object.defineProperties(this, {
    stand: {
      get: function() {
        return 'stand';
      }
    },
    hit: {
      get: function() {
        return 'hit';
      }
    }
    // split: {
    //   get: function() {
    //     return 'split';
    //   }
    // }
  });
}

exports.Actions = Actions;
exports.DealingShoe = DealingShoe;
exports.EngineHand = EngineHand;
exports.Card = Card;
exports.makePlayerHand = makePlayerHand;
exports.makeTable = makeTable;
<commit_msg>fix ace counting for real<commit_after>

function Card(suit, value) {
  var face;
  if(typeof value == 'number') {
    face = value.toString();
  } else {
    face = value.face;
    value = value.value;
  }

  Object.defineProperties(this, {
    value: {
      get: function() { return value; }
    },
    suit: {
      get: function() { return suit; }
    },
    face: {
      get: function() { return face; }
    },
    isAce: {
      get: function() { return value == 11; } // == "Ace"; }
    }
  });
}

Card.prototype.toString = function() {
  return this.face + " of " + this.suit;
};

function DealingShoe(deckCount) {
  this.deckCount = deckCount || 6;
  this.cardCount = 52 * this.deckCount;

  this.resuffle();
}

DealingShoe.prototype.resuffle = function() {
  var builder = new Array(this.cardCount);
  var suits = ["Clubs", "Hearts", "Spades", "Diamonds"];
  var faces = [2, 3, 4, 5, 6, 7, 8, 9, 10, {
    face: 'Jack',
    value: 10
  }, {
    face: 'Queen',
    value: 10,
  }, {
    face: 'King',
    value: 10
  }, {
    face: 'Ace',
    value: 11
  }];

  for(var a = 0; a < this.deckCount; ++a) {
    suits.forEach(function(suit, i) {
      faces.forEach(function(value, j) {
        builder[(a * 52) + (i * 13) + j] = new Card(suit, value);
      });
    });
  }

  var orig = builder.concat([]);

  for(var i = 0; i < 1000000; ++i) {
    var src = Math.floor(Math.random() * this.cardCount);
    var dest = Math.floor(Math.random() * this.cardCount);
    var temp = builder[dest];

    builder[dest] = builder[src];
    builder[src] = temp;
  }

  this.cards = builder;
  this.position = 0;

  var totalDistance = 0;

  orig.forEach(function(current, i) {
    var j = i + 1;
    if(j == orig.length) {
      return;
    }

    var next = orig[j];
    var currentIndex;
    var nextIndex;
    builder.forEach(function(card, bldrIndex) {
      if(card.suit == current.suit && card.face == current.face) {
        currentIndex = bldrIndex;
      } else if(card.suit == next.suit && card.face == next.face) {
        nextIndex = bldrIndex;
      }
    });

    totalDistance += Math.abs(nextIndex - currentIndex);
  });
};

DealingShoe.prototype.next = function() {
  if(this.position == this.cards.length) {
    this.resuffle();
    return this.next();
  } else {
    var card = this.cards[this.position];
    this.position += 1;

    return card;
  }
}

function makePlayerHand(engineHand) {
  return {
    cards: engineHand.cards.concat([]),
    value: engineHand.value,
    toString: function() {
      return engineHand.toString();
    }
  };
}

function makeTable(players, dealerCards) {
  var tbl = [];
  players.forEach(function(player) {
    tbl.push(player.hand.cards.concat([]));
  });

  tbl = tbl.concat(dealerCards)

  return tbl;
}

function EngineHand() {
  var cards = [];
  var _dirty = false;
  var _value = 0;

  Object.defineProperties(this, {
    // otherHand: {
    //   get: function() { return otherHand; }
    // },
    cards: {
      get: function() { return cards; }
    },

    push: {
      get: function() {
        return function(card) {
          _dirty = true;
          cards.push(card);
        }
      }
    },

    // canSplit: {
    //   get: function() {
    //     return canSplit(cards); //, otherHand != null);
    //   }
    // },

    value: {
      get: function() {
        if(_dirty) {
          var value = 0;
          var aces = 0;
          cards.forEach(function(card) {
            if(card.isAce) {
              aces += 1;
            } else {
              value += card.value;
            }
          });

          if(aces) {
            var useAs11 = Math.floor((21 - value) / 11);
            if(useAs11 < 0) {
              useAs11 = 0;
            }

            value += (useAs11 * 11) + (aces - useAs11);
          }

          _value = value;
          _dirty = false;
        }

        return _value;
      }
    },
    isBusted: {
      get: function() {
        return this.value > 21;
      }
    },
    isBlackjack: {
      get: function() {
        return this.cards.length == 2 && this.value == 21;
      }
    }
  });
}

EngineHand.prototype.toString = function() {
  return this.cards.join(', ') + ' [' + this.value.toString() + ']';
};

function Actions() {
  Object.defineProperties(this, {
    stand: {
      get: function() {
        return 'stand';
      }
    },
    hit: {
      get: function() {
        return 'hit';
      }
    }
    // split: {
    //   get: function() {
    //     return 'split';
    //   }
    // }
  });
}

exports.Actions = Actions;
exports.DealingShoe = DealingShoe;
exports.EngineHand = EngineHand;
exports.Card = Card;
exports.makePlayerHand = makePlayerHand;
exports.makeTable = makeTable;
<|endoftext|>


<commit_before>/**
 *
 * @license
 * Copyright (C) 2016 Joseph Roque
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @author Joseph Roque
 * @file Types.js
 * @description Variable type definitions for use throughout the app.
 *
 * @flow
 */
'use strict';

//-----------------------------------------------------------------------------
//  General
//-----------------------------------------------------------------------------

export type DefaultFunction = () => any;

//-----------------------------------------------------------------------------
//  Icons
//-----------------------------------------------------------------------------

export type DefaultIcon = {
  name: string,
  class: string,
};

export type PlatformIcon = {
  ios: DefaultIcon,
  android: DefaultIcon,
};

export type IconObject =
    | DefaultIcon
    | PlatformIcon;

//-----------------------------------------------------------------------------
//  Platforms
//-----------------------------------------------------------------------------

export type PlatformString =
    | 'ios'
    | 'android';

//-----------------------------------------------------------------------------
//  Languages
//-----------------------------------------------------------------------------

export type Language =
    | 'en'
    | 'fr';

//-----------------------------------------------------------------------------
//  Location
//-----------------------------------------------------------------------------

export type LatLong = {
 latitude: number,
 longitude: number,
 latitudeDelta: number,
 longitudeDelta: number,
};

//-----------------------------------------------------------------------------
//  Tabs
//-----------------------------------------------------------------------------

export type TabItems = {
  find: any,
  schedule: any,
  discover: any,
  settings: any,
};

export type Route = {
  id: number | string,
  data: any,
};

//-----------------------------------------------------------------------------
//  Semesters
//-----------------------------------------------------------------------------

type SemesterWithDefaultName = {
  code: string,
  current: boolean,
  name: string,
};

type SemesterWithTranslatedName = {
  code: string,
  current: boolean,
  name_en: string,
  name_fr: string,
};

export type Semester =
    | SemesterWithDefaultName
    | SemesterWithTranslatedName;

//-----------------------------------------------------------------------------
//  University
//-----------------------------------------------------------------------------

type UniversityWithDefaultName = {
  lat: number,
  long: number,
  name: string,
};

type UniversityWithTranslatedNames = {
  lat: number,
  long: number,
  name_en: string,
  name_fr: string,
};

export type University =
    | UniversityWithDefaultName
    | UniversityWithTranslatedNames;

//-----------------------------------------------------------------------------
//  Buses
//-----------------------------------------------------------------------------

type BusInfoWithDefault = {
  name: string,
  link: string,
};

type BusInfoWithTranslated = {
  name_en: string,
  name_fr: string,
  link_en: string,
  link_fr: string,
};

export type BusInfo =
    | BusInfoWithDefault
    | BusInfoWithTranslated;

type BusCampusWithDefaultName = {
  name: string,
  image: ReactClass<any>,
};

type BusCampusWithTranslatedName = {
  name_en: string,
  name_fr: string,
  image: ReactClass<any>,
};

export type BusCampus =
    | BusCampusWithDefaultName
    | BusCampusWithTranslatedName;

export type DetailedRouteInfo = {
  number: number,
  sign: string,
  days: Object,
};

export type TransitStop = {
  code: string,
  id: string,
  lat: number,
  long: number,
  name: string,
  routes: Array<number | DetailedRouteInfo>,
};

type TransitCampusWithDefaultName = {
  id: string,
  lat: number,
  long: number,
  name: string,
  stops: Array<TransitStop>,
};

type TransitCampusWithTranslatedName = {
  id: string,
  lat: number,
  long: number,
  name_en: string,
  name_fr: string,
  stops: Array<TransitStop>,
};

export type TransitCampus =
    | TransitCampusWithDefaultName
    | TransitCampusWithTranslatedName;

//-----------------------------------------------------------------------------
//  Shuttle
//-----------------------------------------------------------------------------

export type ScheduleTimes = {
  days: string,
  times: Array<string>,
};

type ShuttleScheduleWithDefaultNameDefaultDirection = {
  name: string,
  direction: string,
  start_date: string,
  end_date: string,
  excluded_dates: Array<string>,
  times: Array<ScheduleTimes>,
};

type ShuttleScheduleWithTranslatedNameDefaultDirection = {
  name_en: string,
  name_fr: string,
  direction: string,
  start_date: string,
  end_date: string,
  excluded_dates: Array<string>,
  times: Array<ScheduleTimes>,
};

type ShuttleScheduleWithDefaultNameTranslatedDirection = {
  name: string,
  direction_en: string,
  direction_fr: string,
  start_date: string,
  end_date: string,
  excluded_dates: Array<string>,
  times: Array<ScheduleTimes>,
};

type ShuttleScheduleWithTranslatedNameTranslatedDirection = {
  name_en: string,
  name_fr: string,
  direction_en: string,
  direction_fr: string,
  start_date: string,
  end_date: string,
  excluded_dates: Array<string>,
  times: Array<ScheduleTimes>,
};

export type ShuttleSchedule =
    | ShuttleScheduleWithDefaultNameDefaultDirection
    | ShuttleScheduleWithDefaultNameTranslatedDirection
    | ShuttleScheduleWithTranslatedNameDefaultDirection
    | ShuttleScheduleWithTranslatedNameTranslatedDirection;

type ShuttleCampusWithDefaultName = {
  accurate: boolean,
  id: string,
  name: string,
  lat: number,
  long: number,
  schedules: Array<ShuttleSchedule>,
};

type ShuttleCampusWithTranslatedName = {
  accurate: boolean,
  id: string,
  name_en: string,
  name_fr: string,
  lat: number,
  long: number,
  schedules: Array<ShuttleSchedule>,
};

export type ShuttleCampus =
    | ShuttleCampusWithDefaultName
    | ShuttleCampusWithTranslatedName;

type ShuttleDetailsWithDefaultNameDefaultDetails = {
  details: Array<string>,
  name: string,
  icon: IconObject,
  image: ReactClass<any>,
};

type ShuttleDetailsWithTranslatedNameDefaultDetails = {
  details: Array<string>,
  name_en: string,
  name_fr: string,
  icon: IconObject,
  image: ReactClass<any>,
};

type ShuttleDetailsWithDefaultNameTranslatedDetails = {
  details_en: Array<string>,
  details_fr: Array<string>,
  name: string,
  icon: IconObject,
  image: ReactClass<any>,
};

type ShuttleDetailsWithTranslatedNameTranslatedDetails = {
  details_en: Array<string>,
  details_fr: Array<string>,
  name_en: string,
  name_fr: string,
  icon: IconObject,
  image: ReactClass<any>,
};

export type ShuttleDetails =
    | ShuttleDetailsWithDefaultNameDefaultDetails
    | ShuttleDetailsWithTranslatedNameDefaultDetails
    | ShuttleDetailsWithDefaultNameTranslatedDetails
    | ShuttleDetailsWithTranslatedNameTranslatedDetails;

//-----------------------------------------------------------------------------
//  Links
//-----------------------------------------------------------------------------

type LinkWithDefaultNameDefaultLink = {
  name: string,
  link: string,
};

type LinkWithDefaultNameTranslatedLink = {
  name: string,
  link_en: string,
  link_fr: string,
};

type LinkWithTranslatedNameDefaultLink = {
  link: string,
  name_en: string,
  name_fr: string,
};

type LinkWithTranslatedNameTranslatedLink = {
  link_en: string,
  link_fr: string,
  name_en: string,
  name_fr: string,
};

export type Link =
    | LinkWithDefaultNameDefaultLink
    | LinkWithDefaultNameTranslatedLink
    | LinkWithTranslatedNameDefaultLink
    | LinkWithTranslatedNameTranslatedLink;

type LinkCategoryWithDefaultName = {
  id: string,
  name: string,
  image?: ReactClass<any>,
  links?: Array<Link>,
  social?: Array<Link>,
  categories?: Array<LinkCategoryType>,
};

type LinkCategoryWithTranslatedName = {
  id: string,
  name_en: string,
  name_fr: string,
  image?: ReactClass<any>,
  links?: Array<Link>,
  social?: Array<Link>,
  categories?: Array<LinkCategoryType>,
};

export type LinkCategoryType =
    | LinkCategoryWithDefaultName
    | LinkCategoryWithTranslatedName;

//-----------------------------------------------------------------------------
//  Buildings
//-----------------------------------------------------------------------------

export type Facility =
    | 'atm'
    | 'food'
    | 'printer'
    | 'store'
    | 'bed'
    | 'alcohol'
    | 'laundry'
    | 'library'
    | 'parking'
    | 'mail'
    | 'pharmacy'
    | 'gym'
    | 'pool';

export type BuildingRoom = {
  name: string,
  type: number,
};

type BuildingWithDefaultName = {
  code: string,
  name: string,
  image: ReactClass<any>,
  lat: number,
  long: number,
  facilities: Array<Facility>,
  rooms: Array<BuildingRoom>,
};

type BuildingWithTranslatedName = {
  code: string,
  name_en: string,
  name_fr: string,
  image: ReactClass<any>,
  lat: number,
  long: number,
  facilities: Array<Facility>,
  rooms: Array<BuildingRoom>,
};

export type Building =
    | BuildingWithDefaultName
    | BuildingWithTranslatedName;
<commit_msg>Changing format of <any> flow modifier to fix syntax parsing in vscode<commit_after>/**
 *
 * @license
 * Copyright (C) 2016 Joseph Roque
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @author Joseph Roque
 * @file Types.js
 * @description Variable type definitions for use throughout the app.
 *
 * @flow
 */
'use strict';

//-----------------------------------------------------------------------------
//  General
//-----------------------------------------------------------------------------

export type DefaultFunction = () => any;

//-----------------------------------------------------------------------------
//  Icons
//-----------------------------------------------------------------------------

export type DefaultIcon = {
  name: string,
  class: string,
};

export type PlatformIcon = {
  ios: DefaultIcon,
  android: DefaultIcon,
};

export type IconObject =
    | DefaultIcon
    | PlatformIcon;

//-----------------------------------------------------------------------------
//  Platforms
//-----------------------------------------------------------------------------

export type PlatformString =
    | 'ios'
    | 'android';

//-----------------------------------------------------------------------------
//  Languages
//-----------------------------------------------------------------------------

export type Language =
    | 'en'
    | 'fr';

//-----------------------------------------------------------------------------
//  Location
//-----------------------------------------------------------------------------

export type LatLong = {
 latitude: number,
 longitude: number,
 latitudeDelta: number,
 longitudeDelta: number,
};

//-----------------------------------------------------------------------------
//  Tabs
//-----------------------------------------------------------------------------

export type TabItems = {
  find: any,
  schedule: any,
  discover: any,
  settings: any,
};

export type Route = {
  id: number | string,
  data: any,
};

//-----------------------------------------------------------------------------
//  Semesters
//-----------------------------------------------------------------------------

type SemesterWithDefaultName = {
  code: string,
  current: boolean,
  name: string,
};

type SemesterWithTranslatedName = {
  code: string,
  current: boolean,
  name_en: string,
  name_fr: string,
};

export type Semester =
    | SemesterWithDefaultName
    | SemesterWithTranslatedName;

//-----------------------------------------------------------------------------
//  University
//-----------------------------------------------------------------------------

type UniversityWithDefaultName = {
  lat: number,
  long: number,
  name: string,
};

type UniversityWithTranslatedNames = {
  lat: number,
  long: number,
  name_en: string,
  name_fr: string,
};

export type University =
    | UniversityWithDefaultName
    | UniversityWithTranslatedNames;

//-----------------------------------------------------------------------------
//  Buses
//-----------------------------------------------------------------------------

type BusInfoWithDefault = {
  name: string,
  link: string,
};

type BusInfoWithTranslated = {
  name_en: string,
  name_fr: string,
  link_en: string,
  link_fr: string,
};

export type BusInfo =
    | BusInfoWithDefault
    | BusInfoWithTranslated;

type BusCampusWithDefaultName = {
  name: string,
  image: ReactClass< any >,
};

type BusCampusWithTranslatedName = {
  name_en: string,
  name_fr: string,
  image: ReactClass< any >,
};

export type BusCampus =
    | BusCampusWithDefaultName
    | BusCampusWithTranslatedName;

export type DetailedRouteInfo = {
  number: number,
  sign: string,
  days: Object,
};

export type TransitStop = {
  code: string,
  id: string,
  lat: number,
  long: number,
  name: string,
  routes: Array<number | DetailedRouteInfo>,
};

type TransitCampusWithDefaultName = {
  id: string,
  lat: number,
  long: number,
  name: string,
  stops: Array< TransitStop >,
};

type TransitCampusWithTranslatedName = {
  id: string,
  lat: number,
  long: number,
  name_en: string,
  name_fr: string,
  stops: Array< TransitStop >,
};

export type TransitCampus =
    | TransitCampusWithDefaultName
    | TransitCampusWithTranslatedName;

//-----------------------------------------------------------------------------
//  Shuttle
//-----------------------------------------------------------------------------

export type ScheduleTimes = {
  days: string,
  times: Array< string >,
};

type ShuttleScheduleWithDefaultNameDefaultDirection = {
  name: string,
  direction: string,
  start_date: string,
  end_date: string,
  excluded_dates: Array< string >,
  times: Array< ScheduleTimes >,
};

type ShuttleScheduleWithTranslatedNameDefaultDirection = {
  name_en: string,
  name_fr: string,
  direction: string,
  start_date: string,
  end_date: string,
  excluded_dates: Array< string >,
  times: Array< ScheduleTimes >,
};

type ShuttleScheduleWithDefaultNameTranslatedDirection = {
  name: string,
  direction_en: string,
  direction_fr: string,
  start_date: string,
  end_date: string,
  excluded_dates: Array< string >,
  times: Array< ScheduleTimes >,
};

type ShuttleScheduleWithTranslatedNameTranslatedDirection = {
  name_en: string,
  name_fr: string,
  direction_en: string,
  direction_fr: string,
  start_date: string,
  end_date: string,
  excluded_dates: Array< string >,
  times: Array< ScheduleTimes >,
};

export type ShuttleSchedule =
    | ShuttleScheduleWithDefaultNameDefaultDirection
    | ShuttleScheduleWithDefaultNameTranslatedDirection
    | ShuttleScheduleWithTranslatedNameDefaultDirection
    | ShuttleScheduleWithTranslatedNameTranslatedDirection;

type ShuttleCampusWithDefaultName = {
  accurate: boolean,
  id: string,
  name: string,
  lat: number,
  long: number,
  schedules: Array< ShuttleSchedule >,
};

type ShuttleCampusWithTranslatedName = {
  accurate: boolean,
  id: string,
  name_en: string,
  name_fr: string,
  lat: number,
  long: number,
  schedules: Array< ShuttleSchedule >,
};

export type ShuttleCampus =
    | ShuttleCampusWithDefaultName
    | ShuttleCampusWithTranslatedName;

type ShuttleDetailsWithDefaultNameDefaultDetails = {
  details: Array< string >,
  name: string,
  icon: IconObject,
  image: ReactClass< any >,
};

type ShuttleDetailsWithTranslatedNameDefaultDetails = {
  details: Array< string >,
  name_en: string,
  name_fr: string,
  icon: IconObject,
  image: ReactClass< any >,
};

type ShuttleDetailsWithDefaultNameTranslatedDetails = {
  details_en: Array< string >,
  details_fr: Array< string >,
  name: string,
  icon: IconObject,
  image: ReactClass< any >,
};

type ShuttleDetailsWithTranslatedNameTranslatedDetails = {
  details_en: Array< string >,
  details_fr: Array< string >,
  name_en: string,
  name_fr: string,
  icon: IconObject,
  image: ReactClass< any >,
};

export type ShuttleDetails =
    | ShuttleDetailsWithDefaultNameDefaultDetails
    | ShuttleDetailsWithTranslatedNameDefaultDetails
    | ShuttleDetailsWithDefaultNameTranslatedDetails
    | ShuttleDetailsWithTranslatedNameTranslatedDetails;

//-----------------------------------------------------------------------------
//  Links
//-----------------------------------------------------------------------------

type LinkWithDefaultNameDefaultLink = {
  name: string,
  link: string,
};

type LinkWithDefaultNameTranslatedLink = {
  name: string,
  link_en: string,
  link_fr: string,
};

type LinkWithTranslatedNameDefaultLink = {
  link: string,
  name_en: string,
  name_fr: string,
};

type LinkWithTranslatedNameTranslatedLink = {
  link_en: string,
  link_fr: string,
  name_en: string,
  name_fr: string,
};

export type Link =
    | LinkWithDefaultNameDefaultLink
    | LinkWithDefaultNameTranslatedLink
    | LinkWithTranslatedNameDefaultLink
    | LinkWithTranslatedNameTranslatedLink;

type LinkCategoryWithDefaultName = {
  id: string,
  name: string,
  image?: ReactClass< any >,
  links?: Array< Link >,
  social?: Array< Link >,
  categories?: Array< LinkCategoryType >,
};

type LinkCategoryWithTranslatedName = {
  id: string,
  name_en: string,
  name_fr: string,
  image?: ReactClass< any >,
  links?: Array< Link >,
  social?: Array< Link >,
  categories?: Array< LinkCategoryType >,
};

export type LinkCategoryType =
    | LinkCategoryWithDefaultName
    | LinkCategoryWithTranslatedName;

//-----------------------------------------------------------------------------
//  Buildings
//-----------------------------------------------------------------------------

export type Facility =
    | 'atm'
    | 'food'
    | 'printer'
    | 'store'
    | 'bed'
    | 'alcohol'
    | 'laundry'
    | 'library'
    | 'parking'
    | 'mail'
    | 'pharmacy'
    | 'gym'
    | 'pool';

export type BuildingRoom = {
  name: string,
  type: number,
};

type BuildingWithDefaultName = {
  code: string,
  name: string,
  image: ReactClass< any >,
  lat: number,
  long: number,
  facilities: Array< Facility >,
  rooms: Array< BuildingRoom >,
};

type BuildingWithTranslatedName = {
  code: string,
  name_en: string,
  name_fr: string,
  image: ReactClass< any >,
  lat: number,
  long: number,
  facilities: Array< Facility >,
  rooms: Array< BuildingRoom >,
};

export type Building =
    | BuildingWithDefaultName
    | BuildingWithTranslatedName;
<|endoftext|>


<commit_before>if (!RedactorPlugins) var RedactorPlugins = {};

/**
 * Handles drag&drop upload using the attachment system for Redactor.
 *
 * @author	Alexander Ebert
 * @copyright	2001-2014 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 */
RedactorPlugins.wupload = {
	_boundGlobalUploadEvents: false,
	_wUploadDropArea: { },
	_timer: null,
	_isDragging: false,
	_isFile: false,

	/**
	 * Initializes the RedactorPlugins.wupload plugin.
	 */
	init: function() {
		var $namespace = '.redactor_' + this.$source.wcfIdentify();
		$(document).on('dragover' + $namespace, $.proxy(this._dragOver, this));
		$(document).on('dragleave' + $namespace, $.proxy(this._dragLeave, this));
		$(document).on('drop' + $namespace, $.proxy(function(event) {
			event.preventDefault();

			this._revertDropArea(undefined, this.$source.wcfIdentify());
		}, this));

		if (!this._boundGlobalUploadEvents) {
			this._boundGlobalUploadEvents = true;

			$(document).on('dragend', function(event) { event.preventDefault(); });
		}

		WCF.System.Event.addListener('com.woltlab.wcf.attachment', 'autoInsert_' + this.$source.wcfIdentify(), $.proxy(this.insertPastedImageAttachment, this));
	},

	/**
	 * Handles an actively dragged object.
	 *
	 * @param	object		event
	 */
	_dragOver: function(event) {
		event = event.originalEvent;

		if (!event.dataTransfer || !event.dataTransfer.types) {
			return;
		}

		// IE and WebKit set 'Files', Firefox sets 'application/x-moz-file' for files being dragged
		// and Safari just provides 'Files' along with a huge list of other stuff
		if (event.dataTransfer.types[0] !== 'application/x-moz-file' && event.dataTransfer.types.indexOf('Files') === -1) {
			this._isFile = false;

			return;
		}

		this._isFile = true;
		event.preventDefault();

		if (!this._isDragging) {
			var $containerID = this.$source.wcfIdentify();

			if (this._wUploadDropArea[$containerID] === undefined) {
				this._wUploadDropArea[$containerID] = $('
' + WCF.Language.get('wcf.attachment.dragAndDrop.dropHere') + '
').hide().appendTo(document.body);
				this._wUploadDropArea[$containerID].on('dragover', $.proxy(this._hoverDropArea, this)).on('dragleave', $.proxy(this._revertDropArea, this)).on('drop', $.proxy(this._drop, this));
			}

			// adjust dimensions
			var $dimensions = (this.inWysiwygMode()) ? this.$editor.getDimensions('outer') : this.$source.getDimensions('outer');
			var $position = (this.inWysiwygMode()) ? this.$editor.getOffsets('offset') : this.$source.getOffsets('offset');

			this._wUploadDropArea[$containerID].css({
				height: $dimensions.height + 'px',
				left: $position.left + 'px',
				lineHeight: $dimensions.height + 'px',
				top: $position.top + 'px',
				width: $dimensions.width + 'px'
			}).show();

			this._isDragging = true;
		}

		event.preventDefault();
	},

	/**
	 * Visualizes the drop area being hovered.
	 *
	 * @param	object		event
	 */
	_hoverDropArea: function(event) {
		this._wUploadDropArea[this.$source.wcfIdentify()].addClass('active').text(WCF.Language.get('wcf.attachment.dragAndDrop.dropNow'));
	},

	/**
	 * Reverts the drop area into the initial state.
	 *
	 * @param	object		event
	 * @param	string		containerID
	 */
	_revertDropArea: function(event, containerID) {
		if (!this._isFile) {
			return;
		}

		var $containerID = containerID || this.$source.wcfIdentify();
		this._wUploadDropArea[$containerID].removeClass('active').text(WCF.Language.get('wcf.attachment.dragAndDrop.dropHere'));

		if (containerID) {
			this._wUploadDropArea[$containerID].hide();
		}
	},

	/**
	 * Handles the object no longer being dragged.
	 *
	 * This event can fires whenever an object is hovering over a different element, there is
	 * a delay of 100ms before the dragging will be checked again to prevent flicker.
	 */
	_dragLeave: function() {
		if (!this._isDragging || !this._isFile) {
			return;
		}

		if (this._timer === null) {
			var self = this;
			this._timer = new WCF.PeriodicalExecuter(function(pe) {
				pe.stop();

				if (!self._isDragging) {
					self._wUploadDropArea[self.$source.wcfIdentify()].hide();
				}
			}, 100);
		}
		else {
			this._timer.resume();
		}

		this._isDragging = false;
	},

	/**
	 * Handles the drop of the dragged object.
	 *
	 * @param	object		event
	 */
	_drop: function(event) {
		if (!this._isFile) {
			return;
		}

		event = event.originalEvent || event;

		if (event.dataTransfer && event.dataTransfer.files.length) {
			event.preventDefault();

			// reset overlay
			var $containerID = this.$source.wcfIdentify();
			this._revertDropArea(undefined, $containerID);

			for (var $i = 0; $i < event.dataTransfer.files.length; $i++) {
				var $file = event.dataTransfer.files[$i];
				if ($file.type) {
					WCF.System.Event.fireEvent('com.woltlab.wcf.redactor', 'upload_' + $containerID, { file: $file });
				}
			}
		}
	},

	/**
	 * Overwrites $.Redactor.pasteClipboardUploadMozilla() to upload files as attachments.
	 *
	 * @see		$.Redactor.pasteClipboardUploadMozilla()
	 */
	pasteClipboardUploadMozilla: function() {
		this.$editor.find('img[data-mozilla-paste-image]').each($.proxy(function(index, image) {
			var $image = $(image);
			var $src = $image.prop('src').split(',');
			var $contentType = $src[0].split(';')[0].split(':')[1];
			var $data = $src[1]; // raw base64

			var $eventData = {
				blob: WCF.base64toBlob($data, $contentType),
				uploadID: null
			};
			WCF.System.Event.fireEvent('com.woltlab.wcf.redactor', 'upload_' + this.$source.wcfIdentify(), $eventData);

			// drop image
			$image.replaceWith('');
		}, this));
	},

	/**
	 * Inserts the attachment at the placeholder location.
	 *
	 * @param	object		data
	 */
	insertPastedImageAttachment: function(data) {
		var $placeholder = this.$editor.find('span.redactor-pastedImageFromClipboard-' + data.uploadID);
		$placeholder.before(data.attachment);
		$placeholder.remove();
	}
};
<commit_msg>Safari fix breaks IE support, fixed<commit_after>if (!RedactorPlugins) var RedactorPlugins = {};

/**
 * Handles drag&drop upload using the attachment system for Redactor.
 *
 * @author	Alexander Ebert
 * @copyright	2001-2014 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 */
RedactorPlugins.wupload = {
	_boundGlobalUploadEvents: false,
	_wUploadDropArea: { },
	_timer: null,
	_isDragging: false,
	_isFile: false,

	/**
	 * Initializes the RedactorPlugins.wupload plugin.
	 */
	init: function() {
		var $namespace = '.redactor_' + this.$source.wcfIdentify();
		$(document).on('dragover' + $namespace, $.proxy(this._dragOver, this));
		$(document).on('dragleave' + $namespace, $.proxy(this._dragLeave, this));
		$(document).on('drop' + $namespace, $.proxy(function(event) {
			event.preventDefault();

			this._revertDropArea(undefined, this.$source.wcfIdentify());
		}, this));

		if (!this._boundGlobalUploadEvents) {
			this._boundGlobalUploadEvents = true;

			$(document).on('dragend', function(event) { event.preventDefault(); });
		}

		WCF.System.Event.addListener('com.woltlab.wcf.attachment', 'autoInsert_' + this.$source.wcfIdentify(), $.proxy(this.insertPastedImageAttachment, this));
	},

	/**
	 * Handles an actively dragged object.
	 *
	 * @param	object		event
	 */
	_dragOver: function(event) {
		event = event.originalEvent;

		if (!event.dataTransfer || !event.dataTransfer.types) {
			return;
		}

		// IE and WebKit set 'Files', Firefox sets 'application/x-moz-file' for files being dragged
		// and Safari just provides 'Files' along with a huge list of other stuff
		this._isFile = false;
		if (event.dataTransfer.types[0] === 'application/x-moz-file') {
			this._isFile = true;
		}
		else {
			for (var $i = 0; $i < event.dataTransfer.types.length; $i++) {
				if (event.dataTransfer.types[$i] === 'Files') {
					this._isFile = true;
					break;
				}
			}
		}

		if (!this._isFile) {
			return;
		}

		this._isFile = true;
		event.preventDefault();

		if (!this._isDragging) {
			var $containerID = this.$source.wcfIdentify();

			if (this._wUploadDropArea[$containerID] === undefined) {
				this._wUploadDropArea[$containerID] = $('
' + WCF.Language.get('wcf.attachment.dragAndDrop.dropHere') + '
').hide().appendTo(document.body);
				this._wUploadDropArea[$containerID].on('dragover', $.proxy(this._hoverDropArea, this)).on('dragleave', $.proxy(this._revertDropArea, this)).on('drop', $.proxy(this._drop, this));
			}

			// adjust dimensions
			var $dimensions = (this.inWysiwygMode()) ? this.$editor.getDimensions('outer') : this.$source.getDimensions('outer');
			var $position = (this.inWysiwygMode()) ? this.$editor.getOffsets('offset') : this.$source.getOffsets('offset');

			this._wUploadDropArea[$containerID].css({
				height: $dimensions.height + 'px',
				left: $position.left + 'px',
				lineHeight: $dimensions.height + 'px',
				top: $position.top + 'px',
				width: $dimensions.width + 'px'
			}).show();

			this._isDragging = true;
		}

		event.preventDefault();
	},

	/**
	 * Visualizes the drop area being hovered.
	 *
	 * @param	object		event
	 */
	_hoverDropArea: function(event) {
		this._wUploadDropArea[this.$source.wcfIdentify()].addClass('active').text(WCF.Language.get('wcf.attachment.dragAndDrop.dropNow'));
	},

	/**
	 * Reverts the drop area into the initial state.
	 *
	 * @param	object		event
	 * @param	string		containerID
	 */
	_revertDropArea: function(event, containerID) {
		if (!this._isFile) {
			return;
		}

		var $containerID = containerID || this.$source.wcfIdentify();
		this._wUploadDropArea[$containerID].removeClass('active').text(WCF.Language.get('wcf.attachment.dragAndDrop.dropHere'));

		if (containerID) {
			this._wUploadDropArea[$containerID].hide();
		}
	},

	/**
	 * Handles the object no longer being dragged.
	 *
	 * This event can fires whenever an object is hovering over a different element, there is
	 * a delay of 100ms before the dragging will be checked again to prevent flicker.
	 */
	_dragLeave: function() {
		if (!this._isDragging || !this._isFile) {
			return;
		}

		if (this._timer === null) {
			var self = this;
			this._timer = new WCF.PeriodicalExecuter(function(pe) {
				pe.stop();

				if (!self._isDragging) {
					self._wUploadDropArea[self.$source.wcfIdentify()].hide();
				}
			}, 100);
		}
		else {
			this._timer.resume();
		}

		this._isDragging = false;
	},

	/**
	 * Handles the drop of the dragged object.
	 *
	 * @param	object		event
	 */
	_drop: function(event) {
		if (!this._isFile) {
			return;
		}

		event = event.originalEvent || event;

		if (event.dataTransfer && event.dataTransfer.files.length) {
			event.preventDefault();

			// reset overlay
			var $containerID = this.$source.wcfIdentify();
			this._revertDropArea(undefined, $containerID);

			for (var $i = 0; $i < event.dataTransfer.files.length; $i++) {
				var $file = event.dataTransfer.files[$i];
				if ($file.type) {
					WCF.System.Event.fireEvent('com.woltlab.wcf.redactor', 'upload_' + $containerID, { file: $file });
				}
			}
		}
	},

	/**
	 * Overwrites $.Redactor.pasteClipboardUploadMozilla() to upload files as attachments.
	 *
	 * @see		$.Redactor.pasteClipboardUploadMozilla()
	 */
	pasteClipboardUploadMozilla: function() {
		this.$editor.find('img[data-mozilla-paste-image]').each($.proxy(function(index, image) {
			var $image = $(image);
			var $src = $image.prop('src').split(',');
			var $contentType = $src[0].split(';')[0].split(':')[1];
			var $data = $src[1]; // raw base64

			var $eventData = {
				blob: WCF.base64toBlob($data, $contentType),
				uploadID: null
			};
			WCF.System.Event.fireEvent('com.woltlab.wcf.redactor', 'upload_' + this.$source.wcfIdentify(), $eventData);

			// drop image
			$image.replaceWith('');
		}, this));
	},

	/**
	 * Inserts the attachment at the placeholder location.
	 *
	 * @param	object		data
	 */
	insertPastedImageAttachment: function(data) {
		var $placeholder = this.$editor.find('span.redactor-pastedImageFromClipboard-' + data.uploadID);
		$placeholder.before(data.attachment);
		$placeholder.remove();
	}
};
<|endoftext|>