<commit_before>$(document).ready(function(e) {
	  $("#legendToggle").click(function(){
		if ($("#legendDiv").css('display')=='none'){
		  $("#legTogText").html('MAP LEGEND ▲');
		}
		else{
		  $("#legTogText").html('MAP LEGEND ▼');
		}
		$("#legendDiv").slideToggle();
	  });
    });

var popupOpen = false,
	 j = 0,
    _storyData = [],
    selection,
    mapPoint;

var checkImg = function(obj){

	var img = new RegExp (/(?:.jpe?g|.gif|.png)/i);
	var url = new RegExp (/http/i);

	for (var prop in obj){
		if (typeof(obj[prop]) == 'string'){
			if (img.test((obj[prop])) == true && url.test((obj[prop])) == true){
				return(obj[prop]);
			}
		}
	}
};
var findTitle = function(obj){

	var udrScr = new RegExp (/"_"/i);
	var url = new RegExp (/http/i);

	var title = null;
	for (var prop in obj){
		if (typeof(obj[prop]) == 'string'){
			if (title == null && udrScr.test((obj[prop])) == false && (obj[prop]).length > 1 && url.test((obj[prop])) == false){
				title = obj[prop];
			}
		}
	}
	return (title);
};

function findLayers(layers,index){
	var csvLayers = [];
	dojo.forEach(layers,function(layer){
		if(layer.id.search("csv") == 0 && layer.visibility == true){
			dojo.forEach(layer.featureCollection.layers,function(lyr){
				csvLayers.push(lyr.layerObject);
			});
		}
		else if(layer.id.search("featColl") == 0 && layer.visibility == true){
			dojo.forEach(layer.featureCollection.layers,function(lyr){
				csvLayers.push(lyr.layerObject);
			});
		}
	});
	_csvLayers[index] = csvLayers;
	generateGraphics(index);
}

function generateGraphics(index){
	var shaded = true;
	dojo.forEach(_csvLayers[index],function(layer,i){
		if (i < 1){
			layer.hide();

			$("#story"+index).append("

");

			var sp = new esri.layers.GraphicsLayer();
			map.addLayer(sp);
			_storyPoints[index] = sp;

			if (layer.graphics[0].attributes.order){
				layer.graphics.sort(function(a,b){
					return a.attributes.order - b.attributes.order;
				});
			}

			dojo.forEach(layer.graphics,function(graphic,j){
				if (j < 99){
					if (shaded == true){
						shaded = false;
						$("#story"+index+"group"+i).append("

");
					}
					else{
						shaded = true;
						$("#story"+index+"group"+i).append("

");
					}

					$("#story"+index+"group"+i+"point"+j).data("attributes", graphic.attributes);
					$("#story"+index+"group"+i+"point"+j).data("geometry", graphic.geometry);
					$("#story"+index+"group"+i+"point"+j).data("infoWindow", layer.infoTemplate);

					var group;
					var fileChange;
					if(graphic.attributes.Color){
						if (graphic.attributes.Color.toLowerCase() == "B"){
							group = 'blue';
							fileChange = 'b';
						}
						else{
							group = 'red';
							fileChange = '';
						}
					}
					else{
						group = 'red';
						fileChange = '';
					}

					var pt = graphic.geometry;
					var attr = graphic.attributes;
					var sym = new esri.symbol.PictureMarkerSymbol("images/icons/"+group+"/NumberIcon"+fileChange+(j+1)+".png", 22, 28).setOffset(3,8);
					var info = layer.infoTemplate;

					if (graphic.attributes.order){
						$("#story"+index+"group"+i+"point"+j).append("

"+graphic.attributes.order+"

");
					}
					else{
						$("#story"+index+"group"+i+"point"+j).append("

");
					}
					/*
					else{
						$("#story"+index+"group"+i+"point"+j).append("

"+(j+1)+"

");
					}
					*/

					var image = graphic.attributes.img || checkImg(graphic.attributes);
					var ifImg = true;

					if (image != null && image != "http://www.landscope.org/_res/img/contentTypeThumbnails/articleSmall.png"){
						$("#story"+index+"group"+i+"point"+j).append("

");
					}
					else{
						ifImg = false;
					}

					var title = graphic.attributes.title || findTitle(graphic.attributes);

					$("#story"+index+"group"+i+"point"+j).data("title", title);

					if (title != null){
						$("#story"+index+"group"+i+"point"+j).append("

"+title+"

");

						var textWidth;

						if (ifImg == true){
							textWidth = (($(".storyPoint").width()) - 115);
							$("#story"+index+"group"+i+"textCon"+j).css('left',115);
						}
						else{
							textWidth = (($(".storyPoint").width()) - 35);
							$("#story"+index+"group"+i+"textCon"+j).css('left',35);
						}
						$("#story"+index+"group"+i+"textCon"+j).width(textWidth);
					}

					attr.displayTitle = title;

					sp.add(new esri.Graphic(pt,sym,attr,info));

				}

			});
		}
	});

	startUpListeners(index);

	$(".titleText").ellipsis();
}

function startUpListeners(index){
	dojo.connect(_storyPoints[index],"onMouseOver",function(){
		_maps[index].setCursor('pointer');
		event.graphic.setSymbol(event.graphic.symbol.setHeight(34).setWidth(27).setOffset(3,10));
        if (popupOpen == false){
    		$("#hoverInfo").html(event.graphic.attributes.displayTitle);
			var pt = _maps[index].toScreen(event.graphic.geometry);
			hoverInfoPos(pt.x,pt.y);
		}
	});
	dojo.connect(_storyPoints[index],"onMouseOut",function(){
		_maps[index].setCursor('default');
		event.graphic.setSymbol(event.graphic.symbol.setHeight(28).setWidth(22).setOffset(3,8));
        $("#hoverInfo").hide();
	});
	dojo.connect(_maps[index],"onClick",function(){
		popupOpen = true;
	});
	dojo.connect(_popup[index],"onHide",function(){
		popupOpen = false;
		_popup[index].clearFeatures();
        $(".storyPoint").removeClass('selection');
	});
	dojo.connect(_storyPoints[index], "onClick", function(event) {
        _popup[index].hide();
        var scrollTop = ($("#storyPoints").scrollTop());
        $("#hoverInfo").hide();
        $(".storyPoint").removeClass("selection");
        $(".storyPoint").each(function(){
            if ($(this).data("attributes") === event.graphic.attributes){
                $(this).addClass("selection");
                if($(this).position().top < 0){
                    $("#storyPoints").scrollTop(scrollTop + $(this).position().top);
                }
                else if($(this).position().top +$(this).height() > $("#storyPoints").height()){
                    $("#storyPoints").scrollTop($("#storyPoints").scrollTop() + $(this).position().top - $("#storyPoints").height() + $(this).height());
                }
            }
        });
    });
	$(".storyPoint").mouseover(function(e) {
        $(".storyPoint").removeClass('active');
		$(this).addClass('active');
        if (popupOpen == false){
    		$("#hoverInfo").html($(this).data('title'));
			var pt = _maps[index].toScreen($(this).data('geometry'));
			hoverInfoPos(pt.x,pt.y);
			var attr = $(this).data('attributes');
			dojo.forEach(_storyPoints,function (lyr,idx){
				dojo.forEach(lyr.graphics,function(graphic,ix){
					if (graphic.attributes == attr){
						graphic.setSymbol(graphic.symbol.setHeight(34).setWidth(27).setOffset(3,10));
					}
				});
			});
		}
    });
	$(".storyPoint").click(function(e) {
        popupOpen = true;
        $(".storyPoint").removeClass("selection");
        $(this).addClass("selection");
		_popup[index].show($(this).data('geometry'));
		if(_maps[j].extent.contains($(this).data('geometry')) == false){
			panMap($(this).data('geometry'));
		}
		var attr = $(this).data('attributes');
		dojo.forEach(_storyPoints,function (lyr,idx){
			dojo.forEach(lyr.graphics,function(graphic,ix){
				if (graphic.attributes == attr){
					_popup[index].setFeatures([graphic]);
				}
			});
		});
        $("#hoverInfo").hide();
    });
	$("#storyPoints").mouseout(function(e) {
        $(".storyPoint").removeClass('active');
        $("#hoverInfo").hide();
        dojo.forEach(_storyPoints,function (lyr,idx){
    		dojo.forEach(lyr.graphics,function(graphic,ix){
				graphic.setSymbol(graphic.symbol.setHeight(28).setWidth(22).setOffset(3,8));
			});
		});
    });

	$(".tab").click(function(e) {
        j = $(this).data("count");
		$(".tab").removeClass('selectedStory');
		$(this).addClass('selectedStory');
		$(".mapDiv").hide();
		$(".story").hide();
		$(".legendDiv").hide();
		$("#mapDiv"+j).show();
		$("#story"+j).show();
		$("#legendDiv"+j).show();
		dojo.byId("title").innerHTML = configOptions.title || _mapInfo[j].title || "";
        dojo.byId("subtitle").innerHTML = configOptions.subtitle|| _mapInfo[j].subtitle || "";
		dojo.byId("description").innerHTML = configOptions.description|| _mapInfo[j].description || "";
    });
}

function panMap(pt){
	var ext = _maps[j].extent;
	var height = ext.getHeight();
	var width = ext.getWidth();
	if (pt.x < ext.xmin && pt.y > ext.ymax){
		var xmin = (pt.x - (width/5));
		var xmax = (pt.x - (width/5) + width);
		var ymax = (pt.y + (height/5));
		var ymin =(pt.y + (height/5) - height);
		_maps[j].setExtent(new esri.geometry.Extent({"xmin":xmin,"ymin":ymin,"xmax":xmax,"ymax":ymax,
  "spatialReference":{"wkid":102100}}));
	}
	else if (pt.x > ext.xmax && pt.y > ext.ymax){
		var xmin = (pt.x + (width/5) - width);
		var xmax = (pt.x + (width/5));
		var ymax = (pt.y + (height/5));
		var ymin =(pt.y + (height/5) - height);
		_maps[j].setExtent(new esri.geometry.Extent({"xmin":xmin,"ymin":ymin,"xmax":xmax,"ymax":ymax,
  "spatialReference":{"wkid":102100}}));
	}
	else if (pt.x > ext.xmax && pt.y < ext.ymin){
		var xmin = (pt.x + (width/5) - width);
		var xmax = (pt.x + (width/5));
		var ymax = (pt.y - (height/5) + height);
		var ymin =(pt.y - (height/5));
		_maps[j].setExtent(new esri.geometry.Extent({"xmin":xmin,"ymin":ymin,"xmax":xmax,"ymax":ymax,
  "spatialReference":{"wkid":102100}}));
	}
	else if (pt.x < ext.xmin && pt.y < ext.ymin){
		var xmin = (pt.x - (width/5));
		var xmax = (pt.x - (width/5) + width);
		var ymax = (pt.y - (height/5) + height);
		var ymin =(pt.y - (height/5));
		_maps[j].setExtent(new esri.geometry.Extent({"xmin":xmin,"ymin":ymin,"xmax":xmax,"ymax":ymax,
  "spatialReference":{"wkid":102100}}));
	}
	else if (pt.x < ext.xmin){
		var xmin = (pt.x - (width/5));
		var xmax = (pt.x - (width/5) + width);
		var ymax = ext.ymax;
		var ymin = ext.ymin;
		_maps[j].setExtent(new esri.geometry.Extent({"xmin":xmin,"ymin":ymin,"xmax":xmax,"ymax":ymax,
  "spatialReference":{"wkid":102100}}));
	}
	else if (pt.x > ext.xmax){
		var xmin = (pt.x + (width/5) - width);
		var xmax = (pt.x + (width/5));
		var ymax = ext.ymax;
		var ymin = ext.ymin;
		_maps[j].setExtent(new esri.geometry.Extent({"xmin":xmin,"ymin":ymin,"xmax":xmax,"ymax":ymax,
  "spatialReference":{"wkid":102100}}));
	}
	else if (pt.y > ext.ymax){
		var xmin = ext.xmin;
		var xmax = ext.xmax;
		var ymax = (pt.y + (height/5));
		var ymin =(pt.y + (height/5) - height);
		_maps[j].setExtent(new esri.geometry.Extent({"xmin":xmin,"ymin":ymin,"xmax":xmax,"ymax":ymax,
  "spatialReference":{"wkid":102100}}));
	}
	else if (pt.y < ext.ymin){
		var xmin = ext.xmin;
		var xmax = ext.xmax;
		var ymax = (pt.y - (height/5) + height);
		var ymin =(pt.y - (height/5));
		_maps[j].setExtent(new esri.geometry.Extent({"xmin":xmin,"ymin":ymin,"xmax":xmax,"ymax":ymax,
  "spatialReference":{"wkid":102100}}));
	}
}

function hoverInfoPos(x,y){
    if (x <= ($("#map").width())-230){
		$("#hoverInfo").css("left",x+15);
	}
	else{
		$("#hoverInfo").css("left",x-25-($("#hoverInfo").width()));
	}
	if (y >= ($("#hoverInfo").height())+50){
		$("#hoverInfo").css("top",y-35-($("#hoverInfo").height()));
	}
	else{
		$("#hoverInfo").css("top",y-15+($("#hoverInfo").height()));
	}
	$("#hoverInfo").show();
}
<commit_msg>Fix icon color select<commit_after>$(document).ready(function(e) {
	  $("#legendToggle").click(function(){
		if ($("#legendDiv").css('display')=='none'){
		  $("#legTogText").html('MAP LEGEND ▲');
		}
		else{
		  $("#legTogText").html('MAP LEGEND ▼');
		}
		$("#legendDiv").slideToggle();
	  });
    });

var popupOpen = false,
	 j = 0,
    _storyData = [],
    selection,
    mapPoint;

var checkImg = function(obj){

	var img = new RegExp (/(?:.jpe?g|.gif|.png)/i);
	var url = new RegExp (/http/i);

	for (var prop in obj){
		if (typeof(obj[prop]) == 'string'){
			if (img.test((obj[prop])) == true && url.test((obj[prop])) == true){
				return(obj[prop]);
			}
		}
	}
};
var findTitle = function(obj){

	var udrScr = new RegExp (/"_"/i);
	var url = new RegExp (/http/i);

	var title = null;
	for (var prop in obj){
		if (typeof(obj[prop]) == 'string'){
			if (title == null && udrScr.test((obj[prop])) == false && (obj[prop]).length > 1 && url.test((obj[prop])) == false){
				title = obj[prop];
			}
		}
	}
	return (title);
};

function findLayers(layers,index){
	var csvLayers = [];
	dojo.forEach(layers,function(layer){
		if(layer.id.search("csv") == 0 && layer.visibility == true){
			dojo.forEach(layer.featureCollection.layers,function(lyr){
				csvLayers.push(lyr.layerObject);
			});
		}
		else if(layer.id.search("featColl") == 0 && layer.visibility == true){
			dojo.forEach(layer.featureCollection.layers,function(lyr){
				csvLayers.push(lyr.layerObject);
			});
		}
	});
	_csvLayers[index] = csvLayers;
	generateGraphics(index);
}

function generateGraphics(index){
	var shaded = true;
	dojo.forEach(_csvLayers[index],function(layer,i){
		if (i < 1){
			layer.hide();

			$("#story"+index).append("

");

			var sp = new esri.layers.GraphicsLayer();
			map.addLayer(sp);
			_storyPoints[index] = sp;

			if (layer.graphics[0].attributes.order){
				layer.graphics.sort(function(a,b){
					return a.attributes.order - b.attributes.order;
				});
			}

			dojo.forEach(layer.graphics,function(graphic,j){
				if (j < 99){
					if (shaded == true){
						shaded = false;
						$("#story"+index+"group"+i).append("

");
					}
					else{
						shaded = true;
						$("#story"+index+"group"+i).append("

");
					}

					$("#story"+index+"group"+i+"point"+j).data("attributes", graphic.attributes);
					$("#story"+index+"group"+i+"point"+j).data("geometry", graphic.geometry);
					$("#story"+index+"group"+i+"point"+j).data("infoWindow", layer.infoTemplate);

					var group;
					var fileChange;
					if(graphic.attributes.Color){
						if (graphic.attributes.Color.toLowerCase() == "b"){
							group = 'blue';
							fileChange = 'b';
						}
						else{
							group = 'red';
							fileChange = '';
						}
					}
					else{
						group = 'red';
						fileChange = '';
					}

					var pt = graphic.geometry;
					var attr = graphic.attributes;
					var sym = new esri.symbol.PictureMarkerSymbol("images/icons/"+group+"/NumberIcon"+fileChange+(j+1)+".png", 22, 28).setOffset(3,8);
					var info = layer.infoTemplate;

					if (graphic.attributes.order){
						$("#story"+index+"group"+i+"point"+j).append("

"+graphic.attributes.order+"

");
					}
					else{
						$("#story"+index+"group"+i+"point"+j).append("

");
					}
					/*
					else{
						$("#story"+index+"group"+i+"point"+j).append("

"+(j+1)+"

");
					}
					*/

					var image = graphic.attributes.img || checkImg(graphic.attributes);
					var ifImg = true;

					if (image != null && image != "http://www.landscope.org/_res/img/contentTypeThumbnails/articleSmall.png"){
						$("#story"+index+"group"+i+"point"+j).append("

");
					}
					else{
						ifImg = false;
					}

					var title = graphic.attributes.title || findTitle(graphic.attributes);

					$("#story"+index+"group"+i+"point"+j).data("title", title);

					if (title != null){
						$("#story"+index+"group"+i+"point"+j).append("

"+title+"

");

						var textWidth;

						if (ifImg == true){
							textWidth = (($(".storyPoint").width()) - 115);
							$("#story"+index+"group"+i+"textCon"+j).css('left',115);
						}
						else{
							textWidth = (($(".storyPoint").width()) - 35);
							$("#story"+index+"group"+i+"textCon"+j).css('left',35);
						}
						$("#story"+index+"group"+i+"textCon"+j).width(textWidth);
					}

					attr.displayTitle = title;

					sp.add(new esri.Graphic(pt,sym,attr,info));

				}

			});
		}
	});

	startUpListeners(index);

	$(".titleText").ellipsis();
}

function startUpListeners(index){
	dojo.connect(_storyPoints[index],"onMouseOver",function(){
		_maps[index].setCursor('pointer');
		event.graphic.setSymbol(event.graphic.symbol.setHeight(34).setWidth(27).setOffset(3,10));
        if (popupOpen == false){
    		$("#hoverInfo").html(event.graphic.attributes.displayTitle);
			var pt = _maps[index].toScreen(event.graphic.geometry);
			hoverInfoPos(pt.x,pt.y);
		}
	});
	dojo.connect(_storyPoints[index],"onMouseOut",function(){
		_maps[index].setCursor('default');
		event.graphic.setSymbol(event.graphic.symbol.setHeight(28).setWidth(22).setOffset(3,8));
        $("#hoverInfo").hide();
	});
	dojo.connect(_maps[index],"onClick",function(){
		popupOpen = true;
	});
	dojo.connect(_popup[index],"onHide",function(){
		popupOpen = false;
		_popup[index].clearFeatures();
        $(".storyPoint").removeClass('selection');
	});
	dojo.connect(_storyPoints[index], "onClick", function(event) {
        _popup[index].hide();
        var scrollTop = ($("#storyPoints").scrollTop());
        $("#hoverInfo").hide();
        $(".storyPoint").removeClass("selection");
        $(".storyPoint").each(function(){
            if ($(this).data("attributes") === event.graphic.attributes){
                $(this).addClass("selection");
                if($(this).position().top < 0){
                    $("#storyPoints").scrollTop(scrollTop + $(this).position().top);
                }
                else if($(this).position().top +$(this).height() > $("#storyPoints").height()){
                    $("#storyPoints").scrollTop($("#storyPoints").scrollTop() + $(this).position().top - $("#storyPoints").height() + $(this).height());
                }
            }
        });
    });
	$(".storyPoint").mouseover(function(e) {
        $(".storyPoint").removeClass('active');
		$(this).addClass('active');
        if (popupOpen == false){
    		$("#hoverInfo").html($(this).data('title'));
			var pt = _maps[index].toScreen($(this).data('geometry'));
			hoverInfoPos(pt.x,pt.y);
			var attr = $(this).data('attributes');
			dojo.forEach(_storyPoints,function (lyr,idx){
				dojo.forEach(lyr.graphics,function(graphic,ix){
					if (graphic.attributes == attr){
						graphic.setSymbol(graphic.symbol.setHeight(34).setWidth(27).setOffset(3,10));
					}
				});
			});
		}
    });
	$(".storyPoint").click(function(e) {
        popupOpen = true;
        $(".storyPoint").removeClass("selection");
        $(this).addClass("selection");
		_popup[index].show($(this).data('geometry'));
		if(_maps[j].extent.contains($(this).data('geometry')) == false){
			panMap($(this).data('geometry'));
		}
		var attr = $(this).data('attributes');
		dojo.forEach(_storyPoints,function (lyr,idx){
			dojo.forEach(lyr.graphics,function(graphic,ix){
				if (graphic.attributes == attr){
					_popup[index].setFeatures([graphic]);
				}
			});
		});
        $("#hoverInfo").hide();
    });
	$("#storyPoints").mouseout(function(e) {
        $(".storyPoint").removeClass('active');
        $("#hoverInfo").hide();
        dojo.forEach(_storyPoints,function (lyr,idx){
    		dojo.forEach(lyr.graphics,function(graphic,ix){
				graphic.setSymbol(graphic.symbol.setHeight(28).setWidth(22).setOffset(3,8));
			});
		});
    });

	$(".tab").click(function(e) {
        j = $(this).data("count");
		$(".tab").removeClass('selectedStory');
		$(this).addClass('selectedStory');
		$(".mapDiv").hide();
		$(".story").hide();
		$(".legendDiv").hide();
		$("#mapDiv"+j).show();
		$("#story"+j).show();
		$("#legendDiv"+j).show();
		dojo.byId("title").innerHTML = configOptions.title || _mapInfo[j].title || "";
        dojo.byId("subtitle").innerHTML = configOptions.subtitle|| _mapInfo[j].subtitle || "";
		dojo.byId("description").innerHTML = configOptions.description|| _mapInfo[j].description || "";
    });
}

function panMap(pt){
	var ext = _maps[j].extent;
	var height = ext.getHeight();
	var width = ext.getWidth();
	if (pt.x < ext.xmin && pt.y > ext.ymax){
		var xmin = (pt.x - (width/5));
		var xmax = (pt.x - (width/5) + width);
		var ymax = (pt.y + (height/5));
		var ymin =(pt.y + (height/5) - height);
		_maps[j].setExtent(new esri.geometry.Extent({"xmin":xmin,"ymin":ymin,"xmax":xmax,"ymax":ymax,
  "spatialReference":{"wkid":102100}}));
	}
	else if (pt.x > ext.xmax && pt.y > ext.ymax){
		var xmin = (pt.x + (width/5) - width);
		var xmax = (pt.x + (width/5));
		var ymax = (pt.y + (height/5));
		var ymin =(pt.y + (height/5) - height);
		_maps[j].setExtent(new esri.geometry.Extent({"xmin":xmin,"ymin":ymin,"xmax":xmax,"ymax":ymax,
  "spatialReference":{"wkid":102100}}));
	}
	else if (pt.x > ext.xmax && pt.y < ext.ymin){
		var xmin = (pt.x + (width/5) - width);
		var xmax = (pt.x + (width/5));
		var ymax = (pt.y - (height/5) + height);
		var ymin =(pt.y - (height/5));
		_maps[j].setExtent(new esri.geometry.Extent({"xmin":xmin,"ymin":ymin,"xmax":xmax,"ymax":ymax,
  "spatialReference":{"wkid":102100}}));
	}
	else if (pt.x < ext.xmin && pt.y < ext.ymin){
		var xmin = (pt.x - (width/5));
		var xmax = (pt.x - (width/5) + width);
		var ymax = (pt.y - (height/5) + height);
		var ymin =(pt.y - (height/5));
		_maps[j].setExtent(new esri.geometry.Extent({"xmin":xmin,"ymin":ymin,"xmax":xmax,"ymax":ymax,
  "spatialReference":{"wkid":102100}}));
	}
	else if (pt.x < ext.xmin){
		var xmin = (pt.x - (width/5));
		var xmax = (pt.x - (width/5) + width);
		var ymax = ext.ymax;
		var ymin = ext.ymin;
		_maps[j].setExtent(new esri.geometry.Extent({"xmin":xmin,"ymin":ymin,"xmax":xmax,"ymax":ymax,
  "spatialReference":{"wkid":102100}}));
	}
	else if (pt.x > ext.xmax){
		var xmin = (pt.x + (width/5) - width);
		var xmax = (pt.x + (width/5));
		var ymax = ext.ymax;
		var ymin = ext.ymin;
		_maps[j].setExtent(new esri.geometry.Extent({"xmin":xmin,"ymin":ymin,"xmax":xmax,"ymax":ymax,
  "spatialReference":{"wkid":102100}}));
	}
	else if (pt.y > ext.ymax){
		var xmin = ext.xmin;
		var xmax = ext.xmax;
		var ymax = (pt.y + (height/5));
		var ymin =(pt.y + (height/5) - height);
		_maps[j].setExtent(new esri.geometry.Extent({"xmin":xmin,"ymin":ymin,"xmax":xmax,"ymax":ymax,
  "spatialReference":{"wkid":102100}}));
	}
	else if (pt.y < ext.ymin){
		var xmin = ext.xmin;
		var xmax = ext.xmax;
		var ymax = (pt.y - (height/5) + height);
		var ymin =(pt.y - (height/5));
		_maps[j].setExtent(new esri.geometry.Extent({"xmin":xmin,"ymin":ymin,"xmax":xmax,"ymax":ymax,
  "spatialReference":{"wkid":102100}}));
	}
}

function hoverInfoPos(x,y){
    if (x <= ($("#map").width())-230){
		$("#hoverInfo").css("left",x+15);
	}
	else{
		$("#hoverInfo").css("left",x-25-($("#hoverInfo").width()));
	}
	if (y >= ($("#hoverInfo").height())+50){
		$("#hoverInfo").css("top",y-35-($("#hoverInfo").height()));
	}
	else{
		$("#hoverInfo").css("top",y-15+($("#hoverInfo").height()));
	}
	$("#hoverInfo").show();
}
<|endoftext|>


<commit_before>(function () {
  'use strict';
  /*jshint camelcase:false */
  angular
    .module('porttare.controllers')
    .controller('CartController', CartController);

  function CartController($auth,
                          $scope,
                          $state,
                          $translate,
                          $ionicPopup,
                          $ionicHistory,
                          $ionicLoading,
                          APP,
                          billingAddresses,
                          deliveryAddresses,
                          ModalService,
                          BillingAddressesService,
                          ProfileAddressesService,
                          CartService,
                          CustomerOrderDeliveryService) {
    var cartVm = this,
        performingPost = false;
    cartVm.total = 0;
    cartVm.showCheckoutModal = showCheckoutModal;
    cartVm.closeModal = closeModal;
    cartVm.runCheckout = runCheckout;
    cartVm.paymentMethods = APP.paymentMethods;
    cartVm.assignBillingAddress = assignBillingAddress;
    cartVm.assignAddress = assignAddress;
    cartVm.messages = {};
    cartVm.clearDeliveryTime = clearDeliveryTime;
    cartVm.updateOrderItem = updateOrderItem;
    cartVm.removeOrderItem = removeOrderItem;
    cartVm.chooseAnonBillingAddress = chooseAnonBillingAddress;
    cartVm.showCustomerOrderDelivery = showCustomerOrderDelivery;
    cartVm.submitCustomerOrderDelivery = submitCustomerOrderDelivery;
    cartVm.CustomerOrderDeliverySelect = CustomerOrderDeliverySelect;
    cartVm.checkoutFormAddBillingAddress = checkoutFormAddBillingAddress;
    cartVm.customerOrderDeliveryNewAddress = customerOrderDeliveryNewAddress;
    cartVm.editCustomerOrderDeliveryAddress = editCustomerOrderDeliveryAddress;
    cartVm.customerOrderDeliverySelectPickup = customerOrderDeliverySelectPickup;
    cartVm.currentCurrency = getCurrentCurrency();
    cartVm.checkoutForm = {
      forma_de_pago: 'efectivo' // only method supported ATM
    };
    cartVm.openEditModal = openEditModal;
    cartVm.slickSettings = {
      infinite: false,
      lazyLoad: 'progressive',
      responsive: [
        {
          breakpoint: 320,
          settings: {
            slidesToShow: 3
          }
        },
        {
          breakpoint: 480,
          settings: {
            slidesToShow: 4
          }
        },
        {
          breakpoint: 768,
          settings: {
            slidesToShow: 5
          }
        },
        {
          breakpoint: 992,
          settings: {
            slidesToShow: 6
          }
        }
      ]
    };

    init();

    function init() {
      cartVm.cart = $auth.user.customer_order;
      cartVm.total = calculateTotal();
      cartVm.billingAddresses = billingAddresses;
      cartVm.addresses = deliveryAddresses;
      cartVm.slickFlag = true; // https://github.com/devmark/angular-slick-carousel#slide-data
      getDeliveryMethods();
    }

    function saveNewBillingAddress(){
      if ($scope.billingAddressesVm.form.$valid) {
        BillingAddressesService.createBillingAddress(
          $scope.billingAddressesVm.billingAddress
        ).then(function success(resp){
          cartVm.billingAddresses.push(resp.customer_billing_address); //jshint ignore:line
          closeModal().then(showCheckoutModal);
        }, function(error){
          $scope.billingAddressesVm.messages = error.data.errors;
        });
      }
    }

    function saveNewAddress(){
      if (!performingPost && $scope.pfaVm.addressForm.$valid) {
        performingPost = true;
        ProfileAddressesService.createAddresses(
          $scope.pfaVm.addressFormData
        ).then(function(response){
          var newCustomerAddress = response.customer_address; //jshint ignore:line
          cartVm.addresses.push(newCustomerAddress);
          assignAddress(newCustomerAddress);
          submitCustomerOrderDelivery().then(clearCurrentOrderDelivery);
          closeModal().then(function (){
            performingPost = false;
          });
        }, function(error){
          $scope.pfaVm.messages = error.errors;
        });
      }
    }

    function updateAddress(){
      if ($scope.pfaVm.addressForm.$valid) {
        ProfileAddressesService.updateAddresses(
          $scope.pfaVm.addressFormData
        ).then(function (response){
          var newAddress = response.customer_address,
              oldAddress = cartVm.addresses.find(function (address){
            return address.id === newAddress.id;
          });
          angular.merge(oldAddress, newAddress);
          closeModal();
        }, function(error){
          $scope.pfaVm.messages = error.errors;
        });
      }
    }

    function showCheckoutModal() {
      if (needsToAddDeliveryAddress()) {
        customerOrderDeliveryNewAddress();
      } else {
        ModalService.showModal({
          parentScope: $scope,
          fromTemplateUrl: 'templates/cart/checkout.html'
        });
      }
    }

    function closeModal() {
      clearData();
      return ModalService.closeModal();
    }

    function clearData() {
      cartVm.checkoutForm = {};
      cartVm.messages = {};
      cartVm.updateErrors = {};
      cartVm.currentItem = null;
      $scope.billingAddressesVm = {};
      $scope.pfaVm = {};
    }

    function runCheckout() {
      $ionicLoading.show({
        template: '{{::("globals.loading"|translate)}}'
      });
      CartService.checkout(cartVm.checkoutForm)
        .then(function success(response) {
          nextViewIsRoot();
          $state.go('app.customerorders.show', {
            id: response.customer_order.id,
            customerOrder: response.customer_order
          }).then(function () {
              $auth.user.customer_order = null;
              $ionicPopup.alert({
                title: 'Alerta',
                template: '{{::("cart.successfullyOrder"|translate)}}'
              }).then(closeModal);
            });
        }, function error(res) {
          $ionicLoading.hide();
          if (res && res.errors) {
            cartVm.messages = res.errors;
          } else {
            var message = '{{::("globals.pleaseTryAgain"|translate)}}';
            $ionicPopup.alert({
              title: 'Error',
              template: message
            });
          }
        });
    }

    function assignBillingAddress(billingAddress) {
      selectItem(cartVm.billingAddresses, billingAddress);
      if (billingAddress) {
        cartVm.checkoutForm.anon_billing_address = null;
        cartVm.checkoutForm.customer_billing_address_id = billingAddress.id;
      }
    }

    function assignAddress(address) {
      cartVm.providerProfile.customer_order_delivery.delivery_method = 'shipping'; // jshint ignore:line
      cartVm.providerProfile.customer_order_delivery.customer_address_id = address.id;
      selectItem(cartVm.addresses, address);
    }

    function selectItem(items, item) {
      angular.forEach(items, function (elem) {
        elem.selected = false;
      });
      if (item) {
        item.selected = true;
      }
    }

    function calculateTotal() {
      var totalCents = 0,
        centValue = 0.01;

      if (cartVm.cart && cartVm.cart.provider_profiles) {
        angular.forEach(cartVm.cart.provider_profiles, function (provider) {
          totalCents = totalCents + getTotalValueItems(provider);
        });
      }
      return totalCents * centValue;
    }

    function getTotalValueItems(provider) {
      var total = 0;
      if(provider.customer_order_items) {
        angular.forEach(provider.customer_order_items, function (item) {
          total = total + (item.provider_item_precio_cents * item.cantidad);
        });
      }
      return total;
    }

    function clearDeliveryTime(){
      cartVm.providerProfile.customer_order_delivery.deliver_at = null;
    }

    function getDeliveryMethods(){
      var methodsKeys, translationMapping, translationKeys;
      methodsKeys = APP.deliveryMethods;
      translationMapping = methodsKeys.reduce(function (memo, method) {
        memo['cart.deliveryMethods.' + method] = method;
        return memo;
      }, {});
      translationKeys = Object.keys(translationMapping);
      $translate(translationKeys).then(function (translations) {
        var formattedMethods = translationKeys.map(function (translationKey) {
          return {
            value: translationMapping[translationKey],
            label: translations[translationKey]
          };
        });
        cartVm.formattedDeliveryMethods = formattedMethods;
      });
    }

    function openEditModal(item){
      cartVm.currentItem = angular.copy(item);
      // jshint ignore:start
      cartVm.counterOptions = {
        limit: 1,
        cantidad: cartVm.currentItem.cantidad,
        cartItem: cartVm.currentItem,
        providerItem: cartVm.currentItem.provider_item,
        priceCents: cartVm.currentItem.provider_item_precio_cents,
        currencyCode: cartVm.currentItem.provider_item_precio_currency,
        onChangeValue: function (data) {
          cartVm.currentItem.cantidad = data.itemsCount;
        }
      };
      // jshint ignore:end
      ModalService.showModal({
        parentScope: $scope,
        fromTemplateUrl: 'templates/cart/order-item.html',
        backdropClickToClose: true,
        focusFirstInput: false
      });
    }

    function updateOrderItem(){
      cartVm.slickFlag = false;
      CartService.updateOrderItem(cartVm.currentItem).then(function(response){
        cartVm.cart = response.customer_order; //jshint ignore:line
        cartVm.total = calculateTotal();
        cartVm.slickFlag = true;
        closeModal();
      }, function(errorResponse){
        cartVm.updateErrors = errorResponse.errors;
      });
    }

    function removeOrderItem(item){
      cartVm.slickFlag = false;
      CartService.removeOrderItem(item).then(function success(resp){
        $auth.user.customer_order=resp.data.customer_order;
        cartVm.cart=resp.data.customer_order;
        cartVm.total= calculateTotal();
        cartVm.slickFlag = true;
        $auth.user.customer_order = resp.data.customer_order; //jshint ignore:line
        $scope.$emit('update-number');
        closeModal();
        if( CartService.isCartEmpty(cartVm.cart) ){
          nextViewIsRoot();
          $state.go(APP.successState);
        }
      });
    }

    function CustomerOrderDeliverySelect(){
      angular.forEach(cartVm.addresses, function (elem) {
        if (elem.id==cartVm.providerProfile.customer_order_delivery.customer_address_id){ //jshint ignore:line
          selectItem(cartVm.addresses, elem);
          return;
        }
      });
    }

    function showCustomerOrderDelivery(providerProfile){
      cartVm.providerProfile = angular.copy(providerProfile);
      if (providerProfile.customer_order_delivery.deliver_at){ //jshint ignore:line
        cartVm.providerProfile.customer_order_delivery.deliver_at = new Date(providerProfile.customer_order_delivery.deliver_at); //jshint ignore:line
      }
      cartVm.CustomerOrderDeliverySelect();
      ModalService.showModal({
        parentScope: $scope,
        backdropClickToClose: true,
        fromTemplateUrl: 'templates/cart/customer-order-delivery-modal.html',
      });
    }

    function submitCustomerOrderDelivery() {
      $ionicLoading.show({
        template: '{{::("globals.updating"|translate)}}'
      });
      return CustomerOrderDeliveryService.updateCustomerOrderDelivery(
        cartVm.providerProfile.customer_order_delivery //jshint ignore:line
      ).then(function success(resp){
        $ionicLoading.hide().then(function(){
          $auth.user.customer_order = resp.customer_order; //jshint ignore:line
          init();
          closeModal();
        });
      }, function error(res) {
        $ionicLoading.hide();
        if (res && res.data.errors ) {
          cartVm.messages = res.data.errors;
        } else {
          var message = '{{::("globals.pleaseTryAgain"|translate)}}';
          $ionicPopup.alert({
            title: 'Error',
            template: message
          });
        }
      });
    }

    function customerOrderDeliverySelectPickup(){
      selectItem(cartVm.addresses);
      cartVm.providerProfile.customer_order_delivery.customer_address_id = null;
      cartVm.providerProfile.customer_order_delivery.delivery_method = 'pickup';
    }

    function customerOrderDeliveryNewAddress(){
      closeModal().then(function(){
        $scope.pfaVm = {
          closeModal: closeModal,
          processAddress: saveNewAddress,
          defaultInCurrentGeolocation: true
        };
        ModalService.showModal({
          parentScope: $scope,
          fromTemplateUrl: 'templates/profile/addresses/modal-form.html'
        });
      });
    }

    function nextViewIsRoot(){
      $ionicHistory.nextViewOptions({
        historyRoot: true
      });
    }

    function anyDeliveryIsShipping(){
      return cartVm.cart.provider_profiles.some(function (providerProfile){
        return providerProfile.customer_order_delivery.delivery_method === 'shipping'; // jshint ignore:line
      });
    }

    function needsToAddDeliveryAddress(){
      return cartVm.addresses.length === 0 && anyDeliveryIsShipping();
    }

    function chooseAnonBillingAddress(){
      cartVm.checkoutForm.anon_billing_address = true;
      assignBillingAddress(null);
    }

    function checkoutFormAddBillingAddress(){
      closeModal().then(function(){
        $scope.billingAddressesVm = {
          closeModal: closeModal,
          submitModal: saveNewBillingAddress
        };
        ModalService.showModal({
          parentScope: $scope,
          fromTemplateUrl: 'templates/billing-addresses/new-edit.html'
        });
      });
    }

    function clearCurrentOrderDelivery(){
      cartVm.providerProfile = null;
    }

    function editCustomerOrderDeliveryAddress(customerAddress) {
      closeModal().then(function(){
        $scope.pfaVm = {
          closeModal: closeModal,
          processAddress: updateAddress,
          addressFormData: angular.copy(customerAddress)
        };
        ModalService.showModal({
          parentScope: $scope,
          fromTemplateUrl: 'templates/profile/addresses/modal-form.html'
        });
      });
    }

    function getCurrentCurrency(){
      // jshint ignore:start
      if (cartVm.cart && cartVm.cart.subtotal_items_currency) {
        return cartVm.cart.subtotal_items_currency;
      } else {
        return $auth.user.current_place.currency_iso_code;
      }
      // jshint ignore:end
    }
  }
})();
<commit_msg>Dirección de facturación desde checkout del carrito<commit_after>(function () {
  'use strict';
  /*jshint camelcase:false */
  angular
    .module('porttare.controllers')
    .controller('CartController', CartController);

  function CartController($auth,
                          $scope,
                          $state,
                          $translate,
                          $ionicPopup,
                          $ionicHistory,
                          $ionicLoading,
                          APP,
                          billingAddresses,
                          deliveryAddresses,
                          ModalService,
                          BillingAddressesService,
                          ProfileAddressesService,
                          CartService,
                          CustomerOrderDeliveryService) {
    var cartVm = this,
        performingPost = false;
    cartVm.total = 0;
    cartVm.showCheckoutModal = showCheckoutModal;
    cartVm.closeModal = closeModal;
    cartVm.runCheckout = runCheckout;
    cartVm.paymentMethods = APP.paymentMethods;
    cartVm.assignBillingAddress = assignBillingAddress;
    cartVm.assignAddress = assignAddress;
    cartVm.messages = {};
    cartVm.clearDeliveryTime = clearDeliveryTime;
    cartVm.updateOrderItem = updateOrderItem;
    cartVm.removeOrderItem = removeOrderItem;
    cartVm.chooseAnonBillingAddress = chooseAnonBillingAddress;
    cartVm.showCustomerOrderDelivery = showCustomerOrderDelivery;
    cartVm.submitCustomerOrderDelivery = submitCustomerOrderDelivery;
    cartVm.CustomerOrderDeliverySelect = CustomerOrderDeliverySelect;
    cartVm.checkoutFormAddBillingAddress = checkoutFormAddBillingAddress;
    cartVm.customerOrderDeliveryNewAddress = customerOrderDeliveryNewAddress;
    cartVm.editCustomerOrderDeliveryAddress = editCustomerOrderDeliveryAddress;
    cartVm.customerOrderDeliverySelectPickup = customerOrderDeliverySelectPickup;
    cartVm.currentCurrency = getCurrentCurrency();
    cartVm.checkoutForm = {
      forma_de_pago: 'efectivo' // only method supported ATM
    };
    cartVm.openEditModal = openEditModal;
    cartVm.slickSettings = {
      infinite: false,
      lazyLoad: 'progressive',
      responsive: [
        {
          breakpoint: 320,
          settings: {
            slidesToShow: 3
          }
        },
        {
          breakpoint: 480,
          settings: {
            slidesToShow: 4
          }
        },
        {
          breakpoint: 768,
          settings: {
            slidesToShow: 5
          }
        },
        {
          breakpoint: 992,
          settings: {
            slidesToShow: 6
          }
        }
      ]
    };

    init();

    function init() {
      cartVm.cart = $auth.user.customer_order;
      cartVm.total = calculateTotal();
      cartVm.billingAddresses = billingAddresses;
      cartVm.addresses = deliveryAddresses;
      cartVm.slickFlag = true; // https://github.com/devmark/angular-slick-carousel#slide-data
      getDeliveryMethods();
    }

    function saveNewBillingAddress(){
      if ($scope.billingAddressesVm.form.$valid) {
        BillingAddressesService.createBillingAddress(
          $scope.billingAddressesVm.billingAddress
        ).then(function success(resp){
          cartVm.billingAddresses.push(resp.customer_billing_address); //jshint ignore:line
          closeModal().then(showCheckoutModal);
        }, function(error){
          $scope.billingAddressesVm.messages = error.data.errors;
        });
      }
    }

    function saveNewAddress(){
      if (!performingPost && $scope.pfaVm.addressForm.$valid) {
        performingPost = true;
        ProfileAddressesService.createAddresses(
          $scope.pfaVm.addressFormData
        ).then(function(response){
          var newCustomerAddress = response.customer_address; //jshint ignore:line
          cartVm.addresses.push(newCustomerAddress);
          assignAddress(newCustomerAddress);
          submitCustomerOrderDelivery().then(clearCurrentOrderDelivery);
          closeModal().then(function (){
            performingPost = false;
          });
        }, function(error){
          $scope.pfaVm.messages = error.errors;
        });
      }
    }

    function updateAddress(){
      if ($scope.pfaVm.addressForm.$valid) {
        ProfileAddressesService.updateAddresses(
          $scope.pfaVm.addressFormData
        ).then(function (response){
          var newAddress = response.customer_address,
              oldAddress = cartVm.addresses.find(function (address){
            return address.id === newAddress.id;
          });
          angular.merge(oldAddress, newAddress);
          closeModal();
        }, function(error){
          $scope.pfaVm.messages = error.errors;
        });
      }
    }

    function showCheckoutModal() {
      if (needsToAddDeliveryAddress()) {
        customerOrderDeliveryNewAddress();
      } else {
        ModalService.showModal({
          parentScope: $scope,
          fromTemplateUrl: 'templates/cart/checkout.html'
        });
      }
    }

    function closeModal() {
      clearData();
      return ModalService.closeModal();
    }

    function clearData() {
      cartVm.checkoutForm = {};
      cartVm.messages = {};
      cartVm.updateErrors = {};
      cartVm.currentItem = null;
      $scope.billingAddressesVm = {};
      $scope.pfaVm = {};
    }

    function runCheckout() {
      $ionicLoading.show({
        template: '{{::("globals.loading"|translate)}}'
      });
      CartService.checkout(cartVm.checkoutForm)
        .then(function success(response) {
          nextViewIsRoot();
          $state.go('app.customerorders.show', {
            id: response.customer_order.id,
            customerOrder: response.customer_order
          }).then(function () {
              $auth.user.customer_order = null;
              $ionicPopup.alert({
                title: 'Alerta',
                template: '{{::("cart.successfullyOrder"|translate)}}'
              }).then(closeModal);
            });
        }, function error(res) {
          $ionicLoading.hide();
          if (res && res.errors) {
            cartVm.messages = res.errors;
          } else {
            var message = '{{::("globals.pleaseTryAgain"|translate)}}';
            $ionicPopup.alert({
              title: 'Error',
              template: message
            });
          }
        });
    }

    function assignBillingAddress(billingAddress) {
      selectItem(cartVm.billingAddresses, billingAddress);
      if (billingAddress) {
        cartVm.checkoutForm.anon_billing_address = null;
        cartVm.checkoutForm.customer_billing_address_id = billingAddress.id;
      }
    }

    function assignAddress(address) {
      cartVm.providerProfile.customer_order_delivery.delivery_method = 'shipping'; // jshint ignore:line
      cartVm.providerProfile.customer_order_delivery.customer_address_id = address.id;
      selectItem(cartVm.addresses, address);
    }

    function selectItem(items, item) {
      angular.forEach(items, function (elem) {
        elem.selected = false;
      });
      if (item) {
        item.selected = true;
      }
    }

    function calculateTotal() {
      var totalCents = 0,
        centValue = 0.01;

      if (cartVm.cart && cartVm.cart.provider_profiles) {
        angular.forEach(cartVm.cart.provider_profiles, function (provider) {
          totalCents = totalCents + getTotalValueItems(provider);
        });
      }
      return totalCents * centValue;
    }

    function getTotalValueItems(provider) {
      var total = 0;
      if(provider.customer_order_items) {
        angular.forEach(provider.customer_order_items, function (item) {
          total = total + (item.provider_item_precio_cents * item.cantidad);
        });
      }
      return total;
    }

    function clearDeliveryTime(){
      cartVm.providerProfile.customer_order_delivery.deliver_at = null;
    }

    function getDeliveryMethods(){
      var methodsKeys, translationMapping, translationKeys;
      methodsKeys = APP.deliveryMethods;
      translationMapping = methodsKeys.reduce(function (memo, method) {
        memo['cart.deliveryMethods.' + method] = method;
        return memo;
      }, {});
      translationKeys = Object.keys(translationMapping);
      $translate(translationKeys).then(function (translations) {
        var formattedMethods = translationKeys.map(function (translationKey) {
          return {
            value: translationMapping[translationKey],
            label: translations[translationKey]
          };
        });
        cartVm.formattedDeliveryMethods = formattedMethods;
      });
    }

    function openEditModal(item){
      cartVm.currentItem = angular.copy(item);
      // jshint ignore:start
      cartVm.counterOptions = {
        limit: 1,
        cantidad: cartVm.currentItem.cantidad,
        cartItem: cartVm.currentItem,
        providerItem: cartVm.currentItem.provider_item,
        priceCents: cartVm.currentItem.provider_item_precio_cents,
        currencyCode: cartVm.currentItem.provider_item_precio_currency,
        onChangeValue: function (data) {
          cartVm.currentItem.cantidad = data.itemsCount;
        }
      };
      // jshint ignore:end
      ModalService.showModal({
        parentScope: $scope,
        fromTemplateUrl: 'templates/cart/order-item.html',
        backdropClickToClose: true,
        focusFirstInput: false
      });
    }

    function updateOrderItem(){
      cartVm.slickFlag = false;
      CartService.updateOrderItem(cartVm.currentItem).then(function(response){
        cartVm.cart = response.customer_order; //jshint ignore:line
        cartVm.total = calculateTotal();
        cartVm.slickFlag = true;
        closeModal();
      }, function(errorResponse){
        cartVm.updateErrors = errorResponse.errors;
      });
    }

    function removeOrderItem(item){
      cartVm.slickFlag = false;
      CartService.removeOrderItem(item).then(function success(resp){
        $auth.user.customer_order=resp.data.customer_order;
        cartVm.cart=resp.data.customer_order;
        cartVm.total= calculateTotal();
        cartVm.slickFlag = true;
        $auth.user.customer_order = resp.data.customer_order; //jshint ignore:line
        $scope.$emit('update-number');
        closeModal();
        if( CartService.isCartEmpty(cartVm.cart) ){
          nextViewIsRoot();
          $state.go(APP.successState);
        }
      });
    }

    function CustomerOrderDeliverySelect(){
      angular.forEach(cartVm.addresses, function (elem) {
        if (elem.id==cartVm.providerProfile.customer_order_delivery.customer_address_id){ //jshint ignore:line
          selectItem(cartVm.addresses, elem);
          return;
        }
      });
    }

    function showCustomerOrderDelivery(providerProfile){
      cartVm.providerProfile = angular.copy(providerProfile);
      if (providerProfile.customer_order_delivery.deliver_at){ //jshint ignore:line
        cartVm.providerProfile.customer_order_delivery.deliver_at = new Date(providerProfile.customer_order_delivery.deliver_at); //jshint ignore:line
      }
      cartVm.CustomerOrderDeliverySelect();
      ModalService.showModal({
        parentScope: $scope,
        backdropClickToClose: true,
        fromTemplateUrl: 'templates/cart/customer-order-delivery-modal.html',
      });
    }

    function submitCustomerOrderDelivery() {
      $ionicLoading.show({
        template: '{{::("globals.updating"|translate)}}'
      });
      return CustomerOrderDeliveryService.updateCustomerOrderDelivery(
        cartVm.providerProfile.customer_order_delivery //jshint ignore:line
      ).then(function success(resp){
        $ionicLoading.hide().then(function(){
          $auth.user.customer_order = resp.customer_order; //jshint ignore:line
          init();
          closeModal();
        });
      }, function error(res) {
        $ionicLoading.hide();
        if (res && res.data.errors ) {
          cartVm.messages = res.data.errors;
        } else {
          var message = '{{::("globals.pleaseTryAgain"|translate)}}';
          $ionicPopup.alert({
            title: 'Error',
            template: message
          });
        }
      });
    }

    function customerOrderDeliverySelectPickup(){
      selectItem(cartVm.addresses);
      cartVm.providerProfile.customer_order_delivery.customer_address_id = null;
      cartVm.providerProfile.customer_order_delivery.delivery_method = 'pickup';
    }

    function customerOrderDeliveryNewAddress(){
      closeModal().then(function(){
        $scope.pfaVm = {
          closeModal: closeModal,
          processAddress: saveNewAddress,
          defaultInCurrentGeolocation: true
        };
        ModalService.showModal({
          parentScope: $scope,
          fromTemplateUrl: 'templates/profile/addresses/modal-form.html'
        });
      });
    }

    function nextViewIsRoot(){
      $ionicHistory.nextViewOptions({
        historyRoot: true
      });
    }

    function anyDeliveryIsShipping(){
      return cartVm.cart.provider_profiles.some(function (providerProfile){
        return providerProfile.customer_order_delivery.delivery_method === 'shipping'; // jshint ignore:line
      });
    }

    function needsToAddDeliveryAddress(){
      return cartVm.addresses.length === 0 && anyDeliveryIsShipping();
    }

    function chooseAnonBillingAddress(){
      cartVm.checkoutForm.anon_billing_address = true;
      assignBillingAddress(null);
    }

    function checkoutFormAddBillingAddress(){
      closeModal().then(function(){
        $scope.billingAddressesVm = {
          billingAddress: initBillingAddress(),
          closeModal: closeModal,
          submitModal: saveNewBillingAddress
        };
        ModalService.showModal({
          parentScope: $scope,
          fromTemplateUrl: 'templates/billing-addresses/new-edit.html'
        });
      });
    }

    function initBillingAddress() {
      var billingAddress = {};
      billingAddress.email = $auth.user.email;
      billingAddress.ciudad = $auth.user.ciudad;
      if ($auth.user.provider_profile){ // jshint ignore:line
        billingAddress.ruc = $auth.user.provider_profile.ruc;// jshint ignore:line
        billingAddress.razon_social = $auth.user.provider_profile.razon_social;// jshint ignore:line
        billingAddress.telefono = $auth.user.provider_profile.telefono;// jshint ignore:line
      }
      return billingAddress;
    }

    function clearCurrentOrderDelivery(){
      cartVm.providerProfile = null;
    }

    function editCustomerOrderDeliveryAddress(customerAddress) {
      closeModal().then(function(){
        $scope.pfaVm = {
          closeModal: closeModal,
          processAddress: updateAddress,
          addressFormData: angular.copy(customerAddress)
        };
        ModalService.showModal({
          parentScope: $scope,
          fromTemplateUrl: 'templates/profile/addresses/modal-form.html'
        });
      });
    }

    function getCurrentCurrency(){
      // jshint ignore:start
      if (cartVm.cart && cartVm.cart.subtotal_items_currency) {
        return cartVm.cart.subtotal_items_currency;
      } else {
        return $auth.user.current_place.currency_iso_code;
      }
      // jshint ignore:end
    }
  }
})();
<|endoftext|>


<commit_before>'use strict';

angular.module('pms3App')
  .directive('marketValueChart', ['$log', function ($log) {
    return {
      templateUrl: 'views/partials/market-value-chart.html',
      restrict: 'E',
      replace: true,
      transclude: true,
      scope: {
        index: '=',
        code: '=',
        data: '='
      },
      link: function (scope, elem, attrs) {
        scope.icon = function(type) {
          switch(type) {
            case "success": return "ok-sign";
            case "warning": return "exclamation-sign";
            case "danger": return "warning-sign";
          }
        }

        var data = scope.data;

        $log.info('code for chart: ' + scope.code);

        var data1 = [];
        nv.addGraph(function() {
          var chart = nv.models.lineChart()
            .options({
              margin: {left: 100, bottom: 100},
              x: function(d,i) { return i},
              showXAxis: true,
              showYAxis: true,
              transitionDuration: 250
            }).color(d3.scale.category10().range());
          ;

          chart.xAxis
            .axisLabel("Years")
            .tickFormat(function(d) {
              var dx = data[0].values[d] && data[0].values[d].x || 0;
              //var dx = data1[d].x;
              //$log.info('d' + d + ' ' + dx);
              return dx ? d3.time.format('%m/%y')(new Date(dx)) : '';
            });

          chart.yAxis
            .axisLabel('Market value')
            .tickFormat(function(d) {
              return d;
            });

          d3.select('#chart'+scope.code+' svg')
            .datum(data)
            .call(chart);

          //TODO: Figure out a good way to do this automatically
          nv.utils.windowResize(chart.update);

          chart.dispatch.on('stateChange', function(e) { nv.log('New State:', JSON.stringify(e)); });

          return chart;
        });

      }
    };
  }]);
<commit_msg>fixed id having /<commit_after>'use strict';

angular.module('pms3App')
  .directive('marketValueChart', ['$log', function ($log) {
    return {
      templateUrl: 'views/partials/market-value-chart.html',
      restrict: 'E',
      replace: true,
      transclude: true,
      scope: {
        index: '=',
        code: '=',
        data: '='
      },
      link: function (scope, elem, attrs) {
        scope.icon = function(type) {
          switch(type) {
            case "success": return "ok-sign";
            case "warning": return "exclamation-sign";
            case "danger": return "warning-sign";
          }
        }

        var data = scope.data;
        scope.code = scope.code.replace('/','');
        $log.info('code for chart: ' + scope.code);

        var data1 = [];
        nv.addGraph(function() {
          var chart = nv.models.lineChart()
            .options({
              margin: {left: 100, bottom: 100},
              x: function(d,i) { return i},
              showXAxis: true,
              showYAxis: true,
              transitionDuration: 250
            }).color(d3.scale.category10().range());
          ;

          chart.xAxis
            .axisLabel("Years")
            .tickFormat(function(d) {
              var dx = data[0].values[d] && data[0].values[d].x || 0;
              //var dx = data1[d].x;
              //$log.info('d' + d + ' ' + dx);
              return dx ? d3.time.format('%m/%y')(new Date(dx)) : '';
            });

          chart.yAxis
            .axisLabel('Market value')
            .tickFormat(function(d) {
              return d;
            });

          d3.select('#chart'+scope.code+' svg')
            .datum(data)
            .call(chart);

          //TODO: Figure out a good way to do this automatically
          nv.utils.windowResize(chart.update);

          chart.dispatch.on('stateChange', function(e) { nv.log('New State:', JSON.stringify(e)); });

          return chart;
        });

      }
    };
  }]);
<|endoftext|>


<commit_before>$(document).ready(function(){

});

function insertInstitutionRequest(){

  var insName = document.getElementById("nombreInstitucion");
  var insMail = document.getElementById("correoInstitucion");
  var insPhone = document.getElementById("telefonoInstitucion");
  var insAddress = document.getElementById("direccionInstitucion");

  $.post("insertions.php", {
          action: "insertInstitution",
          name: insName.value,
          mail: insMail.value,
          phone: insPhone.value,
          address: insAddress.value
        },
        function(data, status){
          alert("Data: " + data + "\nStatus: " + status);
        }
  );
}
<commit_msg>Added click event in registarr<commit_after>$(document).ready(function(){

  $('#registrar').click(insertInstitutionRequest);

});

function insertInstitutionRequest(){

  var insName = document.getElementById("nombreInstitucion");
  var insMail = document.getElementById("correoInstitucion");
  var insPhone = document.getElementById("telefonoInstitucion");
  var insAddress = document.getElementById("direccionInstitucion");

  $.post("insertions.php", {
          action: "insertInstitution",
          name: insName.value,
          mail: insMail.value,
          phone: insPhone.value,
          address: insAddress.value
        },
        function(data, status){
          alert("Data: " + data + "\nStatus: " + status);
        }
  );
}
<|endoftext|>


<commit_before>(function ($) {

    var eCalendar = function (options, object) {
        // Initializing global variables
        var adDay = new Date().getDate();
        var adMonth = new Date().getMonth();
        var adYear = new Date().getFullYear();
        var dDay = adDay;
        var dMonth = adMonth;
        var dYear = adYear;
        var instance = object;

        var settings = $.extend({}, $.fn.eCalendar.defaults, options);

        function lpad(value, length, pad) {
            if (typeof pad == 'undefined') {
                pad = '0';
            }
            var p;
            for (var i = 0; i < length; i++) {
                p += pad;
            }
            return (p + value).slice(-length);
        }

        var mouseOver = function () {
            $(this).addClass('c-nav-btn-over');
        };
        var mouseLeave = function () {
            $(this).removeClass('c-nav-btn-over');
        };
        var mouseOverEvent = function () {
            $(this).addClass('c-event-over');
            var d = $(this).attr('data-event-day');
            $('div.c-event-item[data-event-day="' + d + '"]').addClass('c-event-over');
        };
        var mouseLeaveEvent = function () {
            $(this).removeClass('c-event-over')
            var d = $(this).attr('data-event-day');
            $('div.c-event-item[data-event-day="' + d + '"]').removeClass('c-event-over');
        };
        var mouseOverItem = function () {
            $(this).addClass('c-event-over');
            var d = $(this).attr('data-event-day');
            $('div.c-event[data-event-day="' + d + '"]').addClass('c-event-over');
        };
        var mouseLeaveItem = function () {
            $(this).removeClass('c-event-over')
            var d = $(this).attr('data-event-day');
            $('div.c-event[data-event-day="' + d + '"]').removeClass('c-event-over');
        };
        var nextMonth = function () {
            if (dMonth < 11) {
                dMonth++;
            } else {
                dMonth = 0;
                dYear++;
            }
            print();
        };
        var previousMonth = function () {
            if (dMonth > 0) {
                dMonth--;
            } else {
                dMonth = 11;
                dYear--;
            }
            print();
        };

        function loadEvents() {
            if (typeof settings.url != 'undefined' && settings.url != '') {
                $.ajax({url: settings.url,
                    async: false,
                    success: function (result) {
                        settings.events = result;
                    }
                });
            }
        }

        function print() {
            loadEvents();
            var dWeekDayOfMonthStart = new Date(dYear, dMonth, 1).getDay();
            var dLastDayOfMonth = new Date(dYear, dMonth + 1, 0).getDate();
            var dLastDayOfPreviousMonth = new Date(dYear, dMonth + 1, 0).getDate() - dWeekDayOfMonthStart + 1;

            var cBody = $('
').addClass('c-grid');
            var cEvents = $('
').addClass('c-event-grid');
            var cEventsBody = $('
').addClass('c-event-body');
            cEvents.append($('
').addClass('c-event-title c-pad-top').html(settings.eventTitle));
            cEvents.append(cEventsBody);
            var cNext = $('
').addClass('c-next c-grid-title c-pad-top');
            var cMonth = $('
').addClass('c-month c-grid-title c-pad-top');
            var cPrevious = $('
').addClass('c-previous c-grid-title c-pad-top');
            cPrevious.html(settings.textArrows.previous);
            cMonth.html(settings.months[dMonth] + ' ' + dYear);
            cNext.html(settings.textArrows.next);

            cPrevious.on('mouseover', mouseOver).on('mouseleave', mouseLeave).on('click', previousMonth);
            cNext.on('mouseover', mouseOver).on('mouseleave', mouseLeave).on('click', nextMonth);

            cBody.append(cPrevious);
            cBody.append(cMonth);
            cBody.append(cNext);
            for (var i = 0; i < settings.weekDays.length; i++) {
                var cWeekDay = $('
').addClass('c-week-day c-pad-top');
                cWeekDay.html(settings.weekDays[i]);
                cBody.append(cWeekDay);
            }
            var day = 1;
            var dayOfNextMonth = 1;
            for (var i = 0; i < 42; i++) {
                var cDay = $('
');
                if (i < dWeekDayOfMonthStart) {
                    cDay.addClass('c-day-previous-month c-pad-top');
                    cDay.html(dLastDayOfPreviousMonth++);
                } else if (day <= dLastDayOfMonth) {
                    cDay.addClass('c-day c-pad-top');
                    if (day == dDay && adMonth == dMonth && adYear == dYear) {
                        cDay.addClass('c-today');
                    }
                    for (var j = 0; j < settings.events.length; j++) {
                        var d = settings.events[j].datetime;
                        if (d.getDate() == day && d.getMonth() == dMonth && d.getFullYear() == dYear) {
                            cDay.addClass('c-event').attr('data-event-day', d.getDate());
                            cDay.on('mouseover', mouseOverEvent).on('mouseleave', mouseLeaveEvent);
                        }
                    }
                    cDay.html(day++);
                } else {
                    cDay.addClass('c-day-next-month c-pad-top');
                    cDay.html(dayOfNextMonth++);
                }
                cBody.append(cDay);
            }
            var eventList = $('
').addClass('c-event-list');
            for (var i = 0; i < settings.events.length; i++) {
                var d = settings.events[i].datetime;
                if (d.getMonth() == dMonth && d.getFullYear() == dYear) {
                    var date = lpad(d.getDate(), 2) + '/' + lpad(d.getMonth()+1, 2) + ' ' + lpad(d.getHours(), 2) + ':' + lpad(d.getMinutes(), 2);
                    var item = $('
').addClass('c-event-item');
                    var title = $('
').addClass('title').html(date + '  ' + settings.events[i].title + '
');
                    var description = $('
').addClass('description').html(settings.events[i].description + '
');
                    item.attr('data-event-day', d.getDate());
                    item.on('mouseover', mouseOverItem).on('mouseleave', mouseLeaveItem);
                    item.append(title).append(description);
                    eventList.append(item);
                }
            }
            $(instance).addClass('calendar');
            cEventsBody.append(eventList);
            $(instance).html(cBody).append(cEvents);
        }

        return print();
    }

    $.fn.eCalendar = function (oInit) {
        return this.each(function () {
            return eCalendar(oInit, $(this));
        });
    };

    // plugin defaults
    $.fn.eCalendar.defaults = {
        weekDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
        months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
        textArrows: {previous: '<', next: '>'},
        eventTitle: 'Events',
        url: '',
        events: [
            {title: 'Conference in Aarhus', description: 'Diophantine Approximation and Related Topics.', datetime: new Date(2015, 7, 12,12)},
            {title: 'Seminar in Göteborg',
            description: 'Marco Maculan: GIT and Diophantine Approximation (6 sem)',
            datetime: new Date(2015, 7, 24, 13)},
            {title: 'Seminar in Copenhagen KU',
            description: '31/08 - Konstantinos Tsaltas: Bianchi modular forms',
            datetime: new Date(2015, 7, 30, 16)},
            {title: 'Seminar in Copenhagen KU',
            description: 'Yuri Bilu: Special Points on Straight Lines and Hyperbolas',
            datetime: new Date(2015, 8, 4, 14)},
            {title: 'Seminar in Copenhagen KU',
            description: 'Kentaro Mitsui: Closed points on torsors',
            datetime: new Date(2015, 8, 18, 14)},
            {title: 'Ostrowski Prize 2015 in Copenhagen KU',
            description: 'Gerd Faltings and Peter Scholze',
            datetime: new Date(2015, 9, 30, 14)},
            {title: 'Seminar in Copenhagen KU',
            description: 'Amilcar Pacheco: An analogue of Brauer-Siegel for ab varieties',
            datetime: new Date(2015, 8, 22, 10)},
            {title: 'Seminar in Copenhagen KU',
            description: 'Andre Chatzistamatiou: Integrality of p-adic integrals',
            datetime: new Date(2015, 8, 25, 14)},
            {title: 'Seminar in Copenhagen KU',
            description: 'Niko Laaksonen: Lattice Point Counting in Sectors of Hyperbolic Space',
            datetime: new Date(2015, 10, 6, 14)},
            {title: 'Seminar in Copenhagen KU',
            description: 'Aftab Pande: An elementary construction of p-adic Hilbert Modular forms.',
            datetime: new Date(2015, 10, 9, 16)},
            {title: 'Seminar in Chalmers (Göteborg)',
            description: 'Per Salberger: Counting rational points on surfaces.',
            datetime: new Date(2015, 10, 12, 10)},
            {title: 'Seminar in Copenhagen KU',
            description: 'Ian Petrow: A twisted Motohashi formula.',
            datetime: new Date(2015, 10, 27, 14)},
            {title: 'Seminar in Copenhagen KU',
            description: 'Valentijn Karemaker: Local and adelic Hecke algebra isomorphisms.',
            datetime: new Date(2015, 11, 11, 14)},
            {title: 'N-cube days III',
            description: 'Day 1 at Chalmers, Göteborg',
            datetime: new Date(2015, 11, 4, 13)},
            {title: 'N-cube days III',
            description: 'Day 2 at Chalmers, Göteborg',
            datetime: new Date(2015, 11, 5, 9)},
            //Months variable is in [0,11]
        ]
    };

}(jQuery));
<commit_msg>small modifications to talks<commit_after>(function ($) {

    var eCalendar = function (options, object) {
        // Initializing global variables
        var adDay = new Date().getDate();
        var adMonth = new Date().getMonth();
        var adYear = new Date().getFullYear();
        var dDay = adDay;
        var dMonth = adMonth;
        var dYear = adYear;
        var instance = object;

        var settings = $.extend({}, $.fn.eCalendar.defaults, options);

        function lpad(value, length, pad) {
            if (typeof pad == 'undefined') {
                pad = '0';
            }
            var p;
            for (var i = 0; i < length; i++) {
                p += pad;
            }
            return (p + value).slice(-length);
        }

        var mouseOver = function () {
            $(this).addClass('c-nav-btn-over');
        };
        var mouseLeave = function () {
            $(this).removeClass('c-nav-btn-over');
        };
        var mouseOverEvent = function () {
            $(this).addClass('c-event-over');
            var d = $(this).attr('data-event-day');
            $('div.c-event-item[data-event-day="' + d + '"]').addClass('c-event-over');
        };
        var mouseLeaveEvent = function () {
            $(this).removeClass('c-event-over')
            var d = $(this).attr('data-event-day');
            $('div.c-event-item[data-event-day="' + d + '"]').removeClass('c-event-over');
        };
        var mouseOverItem = function () {
            $(this).addClass('c-event-over');
            var d = $(this).attr('data-event-day');
            $('div.c-event[data-event-day="' + d + '"]').addClass('c-event-over');
        };
        var mouseLeaveItem = function () {
            $(this).removeClass('c-event-over')
            var d = $(this).attr('data-event-day');
            $('div.c-event[data-event-day="' + d + '"]').removeClass('c-event-over');
        };
        var nextMonth = function () {
            if (dMonth < 11) {
                dMonth++;
            } else {
                dMonth = 0;
                dYear++;
            }
            print();
        };
        var previousMonth = function () {
            if (dMonth > 0) {
                dMonth--;
            } else {
                dMonth = 11;
                dYear--;
            }
            print();
        };

        function loadEvents() {
            if (typeof settings.url != 'undefined' && settings.url != '') {
                $.ajax({url: settings.url,
                    async: false,
                    success: function (result) {
                        settings.events = result;
                    }
                });
            }
        }

        function print() {
            loadEvents();
            var dWeekDayOfMonthStart = new Date(dYear, dMonth, 1).getDay();
            var dLastDayOfMonth = new Date(dYear, dMonth + 1, 0).getDate();
            var dLastDayOfPreviousMonth = new Date(dYear, dMonth + 1, 0).getDate() - dWeekDayOfMonthStart + 1;

            var cBody = $('
').addClass('c-grid');
            var cEvents = $('
').addClass('c-event-grid');
            var cEventsBody = $('
').addClass('c-event-body');
            cEvents.append($('
').addClass('c-event-title c-pad-top').html(settings.eventTitle));
            cEvents.append(cEventsBody);
            var cNext = $('
').addClass('c-next c-grid-title c-pad-top');
            var cMonth = $('
').addClass('c-month c-grid-title c-pad-top');
            var cPrevious = $('
').addClass('c-previous c-grid-title c-pad-top');
            cPrevious.html(settings.textArrows.previous);
            cMonth.html(settings.months[dMonth] + ' ' + dYear);
            cNext.html(settings.textArrows.next);

            cPrevious.on('mouseover', mouseOver).on('mouseleave', mouseLeave).on('click', previousMonth);
            cNext.on('mouseover', mouseOver).on('mouseleave', mouseLeave).on('click', nextMonth);

            cBody.append(cPrevious);
            cBody.append(cMonth);
            cBody.append(cNext);
            for (var i = 0; i < settings.weekDays.length; i++) {
                var cWeekDay = $('
').addClass('c-week-day c-pad-top');
                cWeekDay.html(settings.weekDays[i]);
                cBody.append(cWeekDay);
            }
            var day = 1;
            var dayOfNextMonth = 1;
            for (var i = 0; i < 42; i++) {
                var cDay = $('
');
                if (i < dWeekDayOfMonthStart) {
                    cDay.addClass('c-day-previous-month c-pad-top');
                    cDay.html(dLastDayOfPreviousMonth++);
                } else if (day <= dLastDayOfMonth) {
                    cDay.addClass('c-day c-pad-top');
                    if (day == dDay && adMonth == dMonth && adYear == dYear) {
                        cDay.addClass('c-today');
                    }
                    for (var j = 0; j < settings.events.length; j++) {
                        var d = settings.events[j].datetime;
                        if (d.getDate() == day && d.getMonth() == dMonth && d.getFullYear() == dYear) {
                            cDay.addClass('c-event').attr('data-event-day', d.getDate());
                            cDay.on('mouseover', mouseOverEvent).on('mouseleave', mouseLeaveEvent);
                        }
                    }
                    cDay.html(day++);
                } else {
                    cDay.addClass('c-day-next-month c-pad-top');
                    cDay.html(dayOfNextMonth++);
                }
                cBody.append(cDay);
            }
            var eventList = $('
').addClass('c-event-list');
            for (var i = 0; i < settings.events.length; i++) {
                var d = settings.events[i].datetime;
                if (d.getMonth() == dMonth && d.getFullYear() == dYear) {
                    var date = lpad(d.getDate(), 2) + '/' + lpad(d.getMonth()+1, 2) + ' ' + lpad(d.getHours(), 2) + ':' + lpad(d.getMinutes(), 2);
                    var item = $('
').addClass('c-event-item');
                    var title = $('
').addClass('title').html(date + '  ' + settings.events[i].title + '
');
                    var description = $('
').addClass('description').html(settings.events[i].description + '
');
                    item.attr('data-event-day', d.getDate());
                    item.on('mouseover', mouseOverItem).on('mouseleave', mouseLeaveItem);
                    item.append(title).append(description);
                    eventList.append(item);
                }
            }
            $(instance).addClass('calendar');
            cEventsBody.append(eventList);
            $(instance).html(cBody).append(cEvents);
        }

        return print();
    }

    $.fn.eCalendar = function (oInit) {
        return this.each(function () {
            return eCalendar(oInit, $(this));
        });
    };

    // plugin defaults
    $.fn.eCalendar.defaults = {
        weekDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
        months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
        textArrows: {previous: '<', next: '>'},
        eventTitle: 'Events',
        url: '',
        events: [
            {title: 'Conference in Aarhus', description: 'Diophantine Approximation and Related Topics.', datetime: new Date(2015, 7, 12,12)},
            {title: 'Seminar in Göteborg',
            description: 'Marco Maculan: GIT and Diophantine Approximation (6 sem)',
            datetime: new Date(2015, 7, 24, 13)},
            {title: 'Seminar in Copenhagen KU',
            description: '31/08 - Konstantinos Tsaltas: Bianchi modular forms',
            datetime: new Date(2015, 7, 30, 16)},
            {title: 'Seminar in Copenhagen KU',
            description: 'Yuri Bilu: Special Points on Straight Lines and Hyperbolas',
            datetime: new Date(2015, 8, 4, 14)},
            {title: 'Seminar in Copenhagen KU',
            description: 'Kentaro Mitsui: Closed points on torsors',
            datetime: new Date(2015, 8, 18, 14)},
            {title: 'Ostrowski Prize 2015 in Copenhagen KU',
            description: 'Gerd Faltings and Peter Scholze',
            datetime: new Date(2015, 9, 30, 14)},
            {title: 'Seminar in Copenhagen KU',
            description: 'Amilcar Pacheco: An analogue of Brauer-Siegel for ab varieties',
            datetime: new Date(2015, 8, 22, 10)},
            {title: 'Seminar in Copenhagen KU',
            description: 'Andre Chatzistamatiou: Integrality of p-adic integrals',
            datetime: new Date(2015, 8, 25, 14)},
            {title: 'Seminar in Copenhagen KU',
            description: 'Niko Laaksonen: Lattice Point Counting in Hyperbolic Space',
            datetime: new Date(2015, 10, 6, 14)},
            {title: 'Seminar in Copenhagen KU',
            description: 'Aftab Pande: A construction of p-adic Hilbert Modular forms.',
            datetime: new Date(2015, 10, 9, 16)},
            {title: 'Seminar in Chalmers (Göteborg)',
            description: 'Per Salberger: Counting rational points on cubic curves.',
            datetime: new Date(2015, 10, 12, 10)},
            {title: 'Seminar in Copenhagen KU',
            description: 'Ian Petrow: A twisted Motohashi formula.',
            datetime: new Date(2015, 10, 27, 14)},
            {title: 'Seminar in Copenhagen KU',
            description: 'Valentijn Karemaker: Local and adelic Hecke algebra isomorphisms.',
            datetime: new Date(2015, 11, 11, 14)},
            {title: 'N-cube days III',
            description: 'Day 1 at Chalmers, Göteborg',
            datetime: new Date(2015, 11, 4, 13)},
            {title: 'N-cube days III',
            description: 'Day 2 at Chalmers, Göteborg',
            datetime: new Date(2015, 11, 5, 9)},
            //Months variable is in [0,11]
        ]
    };

}(jQuery));
<|endoftext|>