Uncaught TypeError: Cannot read property 'AIA' of undefined

Asked by alexsey on 2015-04-13

Uncaught TypeError: Cannot read property 'AIA' of undefined

Question information

Language:
English Edit question
Status:
Solved
For:
Helioviewer.org Edit question
Assignee:
No assignee Edit question
Solved by:
alexsey
Solved:
2015-04-13
Last query:
2015-04-13
Last reply:
alexsey (avizard2008) said : #1

{basicParams=self.dataSources[params.observatory][params.instrument][params.detector][params.measurement];$.extend(params,basicParams);layer=new HelioviewerTileLayer(index,self._observationDate,self.tileSize,self.viewportScale,self.tileVisibilityRange,params.observatory,params.instrument,params.detector,params.measurement,params.sourceId,params.nickname,params.visible,params.opacity,params.layeringOrder);self.addLayer(layer);});},_onViewportUpdated:function(){var numLayers=Helioviewer.userSettings.get("state.tileLayers").length;this._layersLoaded+=1;if(!this._finishedLoading&&this._layersLoaded===numLayers){$(document).trigger("load-saved-roi-position");}},_updateDataSource:function(event,id,observatory,instrument,detector,measurement,sourceId,name,layeringOrder){var opacity,layer;$.each(this._layers,function(){if(this.id===id){layer=this;}});layer.name=name;layer.layeringOrder=layeringOrder;layer.domNode.css("z-index",parseInt(layer.layeringOrder,10)-10);layer.image.updateDataSource(observatory,instrument,detector,measurement,sourceId);opacity=this._computeLayerStartingOpacity(layer.layeringOrder,true);$("#opacity-slider-track-"+id).slider("value",opacity);},checkDataSource:function(obs,inst,det,meas){if(this.dataSources[obs]!==undefined){if(this.dataSources[obs][inst]!==undefined){if(this.dataSources[obs][inst][det]!==undefined){if(this.dataSources[obs][inst][det][meas]!==undefined){return true;}}}}
return false;},toURIString:function(){var str="";$.each(this._layers,function(){str+=this.uri+",";});str=str.slice(0,-1);return str;}});"use strict";var JP2Image=Class.extend({init:function(observatory,instrument,detector,measurement,sourceId,date,onChange){this.observatory=observatory;this.instrument=instrument;this.detector=detector;this.measurement=measurement;this.sourceId=sourceId;this.requestDate=date;this._onChange=onChange;this._requestImage();},_requestImage:function(){var params,dataType;params={action:'getClosestImage',sourceId:this.sourceId,date:this.requestDate.toISOString()};$.get(Helioviewer.api,params,$.proxy(this._onImageLoad,this),Helioviewer.dataType);},updateDataSource:function(observatory,instrument,detector,measurement,sourceId){this.observatory=observatory;this.instrument=instrument;this.detector=detector;this.measurement=measurement;this.sourceId=sourceId;this._requestImage();},updateTime:function(requestDate){this.requestDate=requestDate;this._requestImage();},_onImageLoad:function(result){if(this.id===result.id){return;}
$.extend(this,result);this.offsetX=parseFloat((this.refPixelX-(this.width/2)).toPrecision(8));this.offsetY=-parseFloat((this.refPixelY-(this.height/2)).toPrecision(8));this._onChange();},getLayerName:function(){return this.observatory+","+this.instrument+","+
this.detector+","+this.measurement;},getSourceId:function(){return this.sourceId;}});"use strict";var MouseCoordinates=Class.extend({enabled:true,visible:false,init:function(imageScale,showMouseCoordsWarning){this.imageScale=imageScale;this.warnMouseCoords=showMouseCoordsWarning;this.viewportContainer=$('#helioviewer-viewport').parent();this.movingContainer=$("#moving-container");this.container=$('#mouse-coords');this.sandbox=$("#sandbox");this.mouseCoords="disabled";this.mouseCoordsX=$('#mouse-coords-x');this.mouseCoordsY=$('#mouse-coords-y');this._initEventHandlers();},_initEventHandlers:function(){$(document).bind('toggle-mouse-coords',$.proxy(this.toggleMouseCoords,this));},enable:function(){this.enabled=true;},disable:function(){this.enabled=false;},updateImageScale:function(imageScale){this.imageScale=imageScale;},getRelativeCoords:function(screenx,screeny){var offset=this.viewportContainer.offset();return{x:screenx-offset.left-1,y:screeny-offset.top-1};},toggleMouseCoords:function(){if(this.mouseCoords==="disabled"){this.mouseCoords="enabled";this.container.toggle();}
else{this.container.toggle();this.mouseCoords="disabled";}
this._checkWarning();this._reassignEventHandlers();},_reassignEventHandlers:function(){if(this.mouseCoords!=="disabled"){this.mouseCoordsX.empty();this.mouseCoordsY.empty();$(document).bind('mousemove',$.proxy(this.updateMouseCoords,this));}else{$(document).unbind('mousemove',this.updateMouseCoords);}},_checkWarning:function(){if(this.warnMouseCoords===true){var warning="<b>Note:</b> Mouse-coordinates should not be used "+"for science operations!";$(document).trigger("message-console-log",[warning,{life:30000}]);Helioviewer.userSettings.set("notifications.coordinates",false);this.warnMouseCoords=false;}},updateMouseCoords:function(event){var cartesian;if(!this.enabled){return;}
cartesian=this.computeMouseCoords(event.pageX,event.pageY);this.mouseCoordsX.html("x: "+cartesian.x+" &prime;&prime;");this.mouseCoordsY.html("y: "+cartesian.y+" &prime;&prime;");},computeMouseCoords:function(screenX,screenY){var VX,negSV,SV,SM,MX,scale,x,y;VX=this.getRelativeCoords(screenX,screenY);negSV=this.sandbox.position();SV={x:-negSV.left,y:-negSV.top};SM=this.movingContainer.position();MX={x:VX.x+(SV.x-SM.left),y:VX.y+(SV.y-SM.top)};scale=this.imageScale;x=Math.round((scale*MX.x));y=-Math.round((scale*MX.y));return{x:x,y:y};}});"use strict";var HelioviewerMouseCoordinates=MouseCoordinates.extend({init:function(imageScale,rsun,showMouseCoordsWarning){this.rsun=rsun;this._super(imageScale,showMouseCoordsWarning);},toggleMouseCoords:function(){if(this.mouseCoords==="disabled"){this.mouseCoords="arcseconds";this.container.toggle();}
else if(this.mouseCoords==="arcseconds"){this.mouseCoords="polar";}
else{this.container.toggle();this.mouseCoords="disabled";}
this._checkWarning();this._reassignEventHandlers();},_reassignEventHandlers:function(){if(this.mouseCoords!=="disabled"){this.mouseCoordsX.empty();this.mouseCoordsY.empty();if(this.mouseCoords==="polar"){this.movingContainer.unbind('mousemove',this.updateMouseCoords);}
this.movingContainer.bind('mousemove',$.proxy(this.updateMouseCoords,this));this.movingContainer.trigger("mousemove");}else{this.movingContainer.unbind('mousemove',this.updateMouseCoords);}},updateMouseCoords:function(event){var cartesian,polar,r,theta;if(!this.enabled){return;}
if(typeof(event.pageX)=="undefined"){if(this.mouseCoords==="arcseconds"){this.showCartesianCoordinates("--","--");}else{this.showPolarCoordinates("--","--");}
return;}
cartesian=this.computeMouseCoords(event.pageX,event.pageY);if(this.mouseCoords==="arcseconds"){this.showCartesianCoordinates(cartesian.x,cartesian.y);}else{polar=Math.toPolarCoords(cartesian.x,cartesian.y);r=((polar.r/this.rsun)+"").substring(0,5);theta=Math.round(polar.theta);this.showPolarCoordinates(r,theta);}},showCartesianCoordinates:function(x,y){this.mouseCoordsX.html("x: "+x+" &prime;&prime;");this.mouseCoordsY.html("y: "+y+" &prime;&prime;");},showPolarCoordinates:function(r,theta){this.mouseCoordsX.html(r+" R<span style='vertical-align: sub; font-size:10px;'>&#9737;</span>");this.mouseCoordsY.html(theta+" &#176;");}});"use strict";var SandboxHelper=Class.extend({init:function(x,y){this.domNode=$("#sandbox");this.movingContainer=$("#moving-container");this.domNode.css({"left":x,"top":y});},center:function(){var top,left;left=0.5*this.domNode.width();top=0.5*this.domNode.height();this.moveContainerTo(left,top);},getCenter:function(){return{x:0.5*this.domNode.width(),y:0.5*this.domNode.height()};},updateSandbox:function(viewportCenter,desiredSandboxSize){var change,oldCenter,newCenter,newHCLeft,newHCTop,containerPos;oldCenter=this.getCenter();this.domNode.css({width:desiredSandboxSize.width+'px',height:desiredSandboxSize.height+'px',left:viewportCenter.x-(0.5*desiredSandboxSize.width)+'px',top:viewportCenter.y-(0.5*desiredSandboxSize.height)+'px'});newCenter=this.getCenter();change={x:newCenter.x-oldCenter.x,y:newCenter.y-oldCenter.y};if(Math.abs(change.x)<0.01&&Math.abs(change.y)<0.01){return;}
containerPos=this.movingContainer.position();newHCLeft=Math.max(0,Math.min(desiredSandboxSize.width,containerPos.left+change.x));newHCTop=Math.max(0,Math.min(desiredSandboxSize.height,containerPos.top+change.y));this.moveContainerTo(newHCLeft,newHCTop);},moveContainerTo:function(x,y){this.movingContainer.css({left:x,top:y});}});"use strict";var ViewportMovementHelper=Class.extend({isMoving:false,maxLayerDimensions:{width:0,height:0},mouseStartingPosition:{x:0,y:0},moveCounter:0,imageUpdateThrottle:3,tileUpdateThrottle:9,init:function(domNode,mouseCoords,offsetX,offsetY){this.domNode=$(domNode);this.sandbox=$("#sandbox");this.movingContainer=$("#moving-container");this.mouseCoords=mouseCoords;var center=this._getCenter();this.sandboxHelper=new SandboxHelper(center.x,center.y);if($.browser.msie){this._cursorCSS="url('resources/cursors/grabbing.cur'), move";}else{this._cursorCSS='move';}},centerViewport:function(){this.sandboxHelper.center();},mouseDown:function(event){this.domNode.css("cursor",this._cursorCSS);if((this.sandbox.width()===0)&&(this.sandbox.height()===0)){return;}
this.mouseStartingPosition={x:event.pageX,y:event.pageY};this._startMoving();},mouseUp:function(event){this.domNode.css("cursor","");if(this.isMoving){this._endMoving();}},mouseMove:function(event){if(!this.isMoving){return;}
this.moveCounter=this.moveCounter+1;if((this.moveCounter%this.imageUpdateThrottle)!==0){return;}
this.moveCounter=this.moveCounter%this.tileUpdateThrottle;this._moveBy(this.mouseStartingPosition.x-event.pageX,this.mouseStartingPosition.y-event.pageY);},doubleClick:function(event){var pos,center,diff;pos=this.mouseCoords.getRelativeCoords(event.pageX,event.pageY);center=this._getCenter();diff={x:(pos.x-center.x),y:(pos.y-center.y)};this._startMoving();this._moveBy(diff.x,diff.y);this._endMoving();},updateMaxLayerDimensions:function(maxDimensions){this.maxLayerDimensions=maxDimensions;this.update();},getMaxImageCoordinates:function(coordinates){var halfWidth,halfHeight,maxCoordinates;halfWidth=this.maxLayerDimensions.width/2;halfHeight=this.maxLayerDimensions.height/2;maxCoordinates={left:Math.max(coordinates.left,-halfWidth),top:Math.max(coordinates.top,-halfHeight),right:Math.min(coordinates.right,halfWidth),bottom:Math.min(coordinates.bottom,halfHeight)};return maxCoordinates;},update:function(){var center,newSize;center=this._getCenter();newSize=this._getDesiredSandboxDimensions();this.sandboxHelper.updateSandbox(center,newSize);},getViewportCoords:function(){var sb,mc,left,top,vpWidth,vpHeight;sb=this.sandbox.position();mc=this.movingContainer.position();left=-(sb.left+mc.left);top=-(sb.top+mc.top);vpWidth=this.domNode.width();vpHeight=this.domNode.height();if(vpWidth%2===1){vpWidth+=1;}
if(vpHeight%2===1){vpHeight+=1;}
return{left:left,top:top,right:vpWidth+left,bottom:vpHeight+top};},moveViewport:function(x,y){this._startMoving();this.moveCounter+=1;this.moveCounter=this.moveCounter%this.tileUpdateThrottle;this._moveBy(x,y);this._endMoving();},zoomTo:function(imageScale){var vpCoords,center,newScale,newCenter,newCoords;newScale=this.mouseCoords.imageScale/imageScale;this._scaleLayerDimensions(newScale);vpCoords=this.getViewportCoords();center={x:(vpCoords.right+vpCoords.left)/2,y:(vpCoords.bottom+vpCoords.top)/2};newCenter={x:center.x*newScale,y:center.y*newScale};this.update();newCoords=this._viewportCoordsToMovingContainerCoords(newCenter);this._moveTo(newCoords.x,newCoords.y);this.mouseCoords.updateImageScale(imageScale);},_viewportCoordsToMovingContainerCoords:function(newCenter){var sbCenter,mcCoords;sbCenter=this.sandboxHelper.getCenter();mcCoords={x:Math.max(Math.min(sbCenter.x-newCenter.x,this.sandbox.width()),0),y:Math.max(Math.min(sbCenter.y-newCenter.y,this.sandbox.height()),0)};return mcCoords;},_getDesiredSandboxDimensions:function(){var width,height;width=this.domNode.width();height=this.domNode.height();return{width:Math.max(0,this.maxLayerDimensions.width-width),height:Math.max(0,this.maxLayerDimensions.height-height)};},_getContainerPos:function(){var position=this.movingContainer.position();return{x:position.left,y:position.top};},_moveBy:function(x,y){var pos={x:Math.min(Math.max(this.startMovingPosition.x-x,0),this.sandbox.width()),y:Math.min(Math.max(this.startMovingPosition.y-y,0),this.sandbox.height())};this.sandboxHelper.moveContainerTo(pos.x,pos.y);},_moveTo:function(x,y){this.sandboxHelper.moveContainerTo(x,y);if(this.moveCounter===0){$(document).trigger("update-viewport",[true]);}},_startMoving:function(){this.isMoving=true;this.mouseCoords.disable();this.startMovingPosition=this._getContainerPos();},_endMoving:function(){this.isMoving=false;this.mouseCoords.enable();$(document).trigger("update-viewport",[true]);},_getCenter:function(){return{x:this.domNode.width()/2,y:this.domNode.height()/2};},_scaleLayerDimensions:function(scaleFactor){this.maxLayerDimensions.width*=scaleFactor;this.maxLayerDimensions.height*=scaleFactor;}});"use strict";var HelioviewerViewport=Class.extend({defaultOptions:{imageScale:1,tileSize:512,minHeight:450,prefetch:0},dimensions:{width:0,height:0},maxLayerDimensions:{width:0,height:0},maxTileLayers:6,init:function(options){$.extend(this,this.defaultOptions);$.extend(this,options);this._rsunInArcseconds=959.705;this.domNode=$(this.id);this.outerNode=$(this.container);this.mouseCoords=new HelioviewerMouseCoordinates(this.imageScale,this._rsunInArcseconds,this.warnMouseCoords);this.resize();var centerX=this.centerX/this.imageScale,centerY=this.centerY/this.imageScale;this.movementHelper=new ViewportMovementHelper(this.domNode,this.mouseCoords,centerX,centerY);this.loadDataSources();this.loadEventTypes();this._initEventHandlers();},loadDataSources:function(){var callback,dataType,tileLayerAccordion,self=this;callback=function(dataSources){self.dataSources=dataSources;$(document).trigger("datasources-initialized",[dataSources]);self._tileLayerManager=new HelioviewerTileLayerManager(self.requestDate,self.dataSources,self.tileSize,self.imageScale,self.maxTileLayers,self.tileLayers);$(document).trigger("update-viewport");};$.get(Helioviewer.api,{action:"getDataSources"},callback,Helioviewer.dataType);},loadEventTypes:function(){$(document).trigger("event-types-initialized",[this.eventTypes,this.requestDate]);this._eventLayerManager=new HelioviewerEventLayerManager(this.requestDate,this.eventTypes,this.imageScale,this.rsun,this.savedEventLayers,this.urlEventLayers);},getImageScale:function(){return parseFloat(this.imageScale.toPrecision(8));},resize:function(){var oldDimensions,width,height;oldDimensions=this.dimensions;height=Math.max(this.minHeight,$(window).height()-this._getPadHeight());this.outerNode.height(height);this.dimensions={width:this.domNode.width()+this.prefetch,height:this.domNode.height()+this.prefetch};$(document).trigger("viewport-resized");if(oldDimensions.width===0&&oldDimensions.height===0){return;}
if(!this._hasSameDimensions(this.dimensions,oldDimensions)){this.updateViewport();}},setImageScale:function(imageScale){this.imageScale=imageScale;},updateViewportRanges:function(coordinates){this._updateTileVisibilityRange(coordinates);if(typeof this._tileLayerManager!=="undefined"){this._tileLayerManager.adjustImageScale(this.imageScale);}},serialize:function(){return this._tileLayerManager.serialize();},serializeEvents:function(){return Helioviewer.userSettings.parseEventsURLString();},getVisibleLayers:function(roi){return this._tileLayerManager.getVisibleLayers(roi);},_getPadHeight:function(){if(this.domNode.hasClass("fullscreen-mode")){return 0;}
return this.marginTop+this.marginBottom;},_updateTileVisibilityRange:function(coordinates){if(typeof this._tileLayerManager!=="undefined"){this._tileLayerManager.updateTileVisibilityRange(coordinates);}},_hasSameDimensions:function(newDimensions,old){return(newDimensions.width===old.width)&&(newDimensions.height===old.height);},_initEventHandlers:function(){$(document).bind("image-scale-changed",$.proxy(this.zoomViewport,this)).bind("update-viewport",$.proxy(this.onUpdateViewport,this)).bind("load-saved-roi-position",$.proxy(this.loadROIPosition,this)).bind("move-viewport mousemove mouseup",$.proxy(this.onMouseMove,this)).bind("layer-max-dimensions-changed",$.proxy(this.updateMaxLayerDimensions,this)).bind("center-viewport",$.proxy(this.centerViewport,this));$(this.domNode).bind("mousedown",$.proxy(this.onMouseMove,this));this.domNode.dblclick($.proxy(this.doubleClick,this));$('#center-button').click($.proxy(this.centerViewport,this));$(window).resize($.proxy(this.resize,this));},onMouseMove:function(event,x,y){switch(event.type){case"mouseup":this.movementHelper.mouseUp(event);break;case"mousedown":this.movementHelper.mouseDown(event);break;case"mousemove":this.movementHelper.mouseMove(event);break;default:this.movementHelper.moveViewport(x,y);break;}},zoomViewport:function(event,imageScale){this.setImageScale(imageScale);this.movementHelper.zoomTo(imageScale);this.updateViewport();Helioviewer.userSettings.set("state.imageScale",imageScale);},onUpdateViewport:function(event,storeCoordinates){if(typeof storeCoordinates==="undefined"){storeCoordinates=false;}
this.updateViewport(storeCoordinates);},loadROIPosition:function(event){var sandbox,sbWidth,sbHeight,centerX,centerY;sandbox=$("#sandbox");sbWidth=sandbox.width();sbHeight=sandbox.height();centerX=Helioviewer.userSettings.get("state.centerX")/this.getImageScale();centerY=Helioviewer.userSettings.get("state.centerY")/this.getImageScale();$("#moving-container").css({"left":sbWidth-Math.max(0,Math.min(sbWidth,Math.round(sbWidth/2+centerX))),"top":sbHeight-Math.max(0,Math.min(sbHeight,Math.round(sbHeight/2+centerY)))});this.updateViewport();},updateViewport:function(storeCoordinates){var coordinates,imageScale,offsetX,offsetY;if(typeof storeCoordinates==="undefined"){storeCoordinates=false;}
this.movementHelper.update();coordinates=this.movementHelper.getViewportCoords();imageScale=this.getImageScale();offsetX=imageScale*((coordinates.left+coordinates.right)/2);offsetY=imageScale*((coordinates.top+coordinates.bottom)/2);if(storeCoordinates){Helioviewer.userSettings.set("state.centerX",offsetX);Helioviewer.userSettings.set("state.centerY",offsetY);}
this.updateViewportRanges(coordinates);},getRegionOfInterest:function(){return this.movementHelper.getViewportCoords();},centerViewport:function(){this.movementHelper.centerViewport();this.updateViewport();Helioviewer.userSettings.set("state.centerX",0);Helioviewer.userSettings.set("state.centerY",0);},setViewportCenter:function(x,y){this.movementHelper.moveViewport(x,y);},doubleClick:function(event){this.movementHelper.doubleClick(event);if(event.shiftKey){$("#zoomControlZoomOut").click();}else{$("#zoomControlZoomIn").click();}},updateMaxLayerDimensions:function(event,type,dimensions){this.movementHelper.updateMaxLayerDimensions(dimensions);},getViewportInformation:function(){return{coordinates:this.movementHelper.getViewportCoords(),imageScale:this.imageScale,layers:this.serialize(),time:this._tileLayerManager.getRequestDateAsISOString()};},getImageScaleInKilometersPerPixel:function(){}});"use strict";var Helioviewer={};var HelioviewerClient=Class.extend({init:function(urlSettings,serverSettings,zoomLevels){this._checkBrowser();this.serverSettings=serverSettings;Helioviewer.api=serverSettings['backEnd'];Helioviewer.dataType=serverSettings['backEnd']==="api/index.php"?"json":"jsonp";Helioviewer.userSettings=SettingsLoader.loadSettings(urlSettings,serverSettings);if(serverSettings['backEnd']==="api/index.php"){Helioviewer.root=serverSettings['rootURL'];}else{Helioviewer.root=Helioviewer.api.substr(0,Helioviewer.api.search("/api"));}},_checkBrowser:function(){$.extend($.support,{"localStorage":('localStorage'in window)&&window['localStorage']!==null,"nativeJSON":typeof(JSON)!=="undefined","video":!!document.createElement('video').canPlayType,"h264":false,"vp8":false});if($.support.video){var v=document.createElement("video");if(v.canPlayType('video/webm; codecs="vp8"')){$.support.vp8=false;}
if(v.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"')){$.support.h264=false;}}},_initViewport:function(container,date,marginTop,marginBottom){this.viewport=new HelioviewerViewport({id:'#helioviewer-viewport',container:container,requestDate:date,maxTileLayers:this.serverSettings.maxTileLayers,minImageScale:this.serverSettings.minImageScale,maxImageScale:this.serverSettings.maxImageScale,prefetch:this.serverSettings.prefetchSize,tileLayers:Helioviewer.userSettings.get('state.tileLayers'),eventLayers:Helioviewer.userSettings.get('state.eventLayers'),eventLabels:Helioviewer.userSettings.get('state.eventLabels'),imageScale:Helioviewer.userSettings.get('state.imageScale'),centerX:Helioviewer.userSettings.get('state.centerX'),centerY:Helioviewer.userSettings.get('state.centerY'),marginTop:marginTop,marginBottom:marginBottom,warnMouseCoords:Helioviewer.userSettings.get('notifications.coordinates')});},_chooseInitialImageScale:function(imageScale,increments){if($.inArray(imageScale,increments)!==-1){return imageScale;}
var diff,closestScale,bestMatch=Infinity;$.each(increments,function(i,scale){diff=Math.abs(scale-imageScale);if(diff<bestMatch){bestMatch=diff;closestScale=scale;}});Helioviewer.userSettings.set('state.imageScale',closestScale);return closestScale;}});"use strict";var ZoomControls=Class.extend({init:function(id,imageScale,increments,minImageScale,maxImageScale){this.id=id;this.imageScale=imageScale;this.increments=increments;this.minImageScale=minImageScale;this.maxImageScale=maxImageScale;this.zoomInBtn=$('#zoomControlZoomIn');this.zoomSlider=$('#zoomControlSlider');this.zoomOutBtn=$('#zoomControlZoomOut');this._initSlider();this._initEventHandlers();},_onSlide:function(v){this._setImageScale(v);},_setImageScale:function(v){$(document).trigger('image-scale-changed',[this.increments[v]]);$(document).trigger('replot-event-markers');$(document).trigger('earth-scale');},_initSlider:function(){var description,self=this;this.increments.reverse();this.zoomSlider.slider({slide:function(event,slider){self._onSlide(slider.value);},min:0,max:this.increments.length-1,orientation:'vertical',value:$.inArray(this.imageScale,this.increments)});description="Drag this handle up and down to zoom in and out of "+"the displayed image.";$("#zoomControlSlider > .ui-slider-handle").attr('title',description).qtip();},_onZoomInBtnClick:function(){var index=this.zoomSlider.slider("value")+1;if(this.increments[index]>=this.minImageScale){this.zoomSlider.slider("value",index);this._setImageScale(index);}},_onZoomOutBtnClick:function(){var index=this.zoomSlider.slider("value")-1;if(this.increments[index]<=this.maxImageScale){this.zoomSlider.slider("value",index);this._setImageScale(index);}},_onMouseWheelMove:function(e,delta){if(delta>0){this.zoomInBtn.click();}else{this.zoomOutBtn.click();}
return false;},_initEventHandlers:function(){this.zoomInBtn.click($.proxy(this._onZoomInBtnClick,this));this.zoomOutBtn.click($.proxy(this._onZoomOutBtnClick,this));$("#helioviewer-viewport").mousewheel($.proxy(this._onMouseWheelMove,this));$(document).bind("zoom-in",$.proxy(this._onZoomInBtnClick,this)).bind("zoom-out",$.proxy(this._onZoomOutBtnClick,this));}});"use strict";var ImageScale=Class.extend({init:function(){this._rsunInArcseconds=959.705;this._earthSunRadiusFraction=6367.5/695500.;this._initScale();this.display();},_initScale:function(){var earthURL='resources/images/earth.png';if($('#earth-container').length>0){$('#earth-container').remove();}
this._earthDiameterInPixels();this.scale_container=$('<div id="earth-container"></div>').appendTo("#helioviewer-viewport");this.scale_container.draggable();this.scale_container.css({'position':'absolute','bottom':'0','z-index':'999','width':'73px','height':'56px','background-color':'rgba(17,17,17,0.5)','border-top':'1px solid #333','border-right':'1px solid #333','box-shadow':'0px 0px 5px black','cursor':'move','display':'none'});this.scale_container.attr('title','Click and drag to re-position scale indicator.');$('<div style="position:relative; height:12px;"><div id="earth-button" class="minimize ui-icon ui-icon-arrow-1-sw" style="float: right; cursor:pointer;" title="Hide Scale Indicator"></div><div id="earthLabel" style="color: white; background-color: #333; text-align: center; font-size: 10px; padding: 2px 0 2px 2px;">Earth Scale</div></div>').appendTo("#earth-container");$('<div style="position:relative; width:72px; height:45px;"><img id="earthScale" src="resources/images/earth.png" style="width: '+this.earthDiameterInPixels+'px;height: '+this.earthDiameterInPixels+'px; position: absolute; left: '+(36-(this.earthDiameterInPixels/2))+'px; top: '+(23-(this.earthDiameterInPixels/2))+'px;" /></div>').appendTo("#earth-container");this.scale_button=this.scale_container.find('#earth-button');this.scale_image=this.scale_container.find('#earthScale');this.scale_label=this.scale_container.find('#earthLabel');$(document).bind("earth-scale",$.proxy(this.earthRescale,this));this.scale_container.bind("mousedown",function(){return false;});this.scale_container.bind('dblclick',function(){return false;});this.scale_container.bind('click',function(){return false;});this.scale_container.bind('drag',$.proxy(this.scaleContainerDrag,this));this.scale_container.bind('dragstop',$.proxy(this.scaleContainerDragStop,this));this.scale_button.bind('click',$.proxy(this.earthMinimize,this));},earthRescale:function(){this._earthDiameterInPixels();this.scale_image.css({'width':this.earthDiameterInPixels+'px','height':this.earthDiameterInPixels+'px','position':'absolute','left':(36-(this.earthDiameterInPixels/2))+'px','top':(23-(this.earthDiameterInPixels/2))+'px'});this.scaleContainerDragStop();},earthMinimize:function(event){Helioviewer.userSettings.set("state.scale",false);Helioviewer.userSettings.set("state.scaleType",'earth');Helioviewer.userSettings.set("state.scaleX",0);Helioviewer.userSettings.set("state.scaleY",0);this.scale_container.draggable({disabled:true});this.scale_image.hide();this.scale_label.hide();this.scale_button.attr('title','Show Scale Indicator');this.scale_container.css({'width':'10px','height':'10px','border':'1px solid #888','border-left':'0','border-bottom':'0'});this.scale_container.css({'position':'absolute','top':'auto','bottom':'0px','left':'0px'});this.scale_button.removeClass('minimize').addClass('maximize');this.scale_button.removeClass('ui-icon-arrow-1-sw').addClass('ui-icon-arrow-1-ne');this.scale_button.css({'margin':'-3px -3px 0 0'});this.scale_button.unbind();this.scale_button.bind('click',$.proxy(this.earthMaximize,this));},earthMaximize:function(){Helioviewer.userSettings.set("state.scale",true);Helioviewer.userSettings.set("state.scaleType",'earth');Helioviewer.userSettings.set("state.scaleX",0);Helioviewer.userSettings.set("state.scaleY",0);this.scale_container.draggable({disabled:false});this.scale_image.show();this.scale_label.show();this.scale_button.attr('title','Hide Scale Indicator');this.scale_container.css({'position':'absolute','top':'auto','bottom':'0px','left':'0px','width':'73px','height':'56px','border':'1px solid #333','border-left':'0','border-bottom':'0'});this.scale_button.removeClass('maximize').addClass('minimize');this.scale_button.removeClass('ui-icon-arrow-1-ne').addClass('ui-icon-arrow-1-sw');this.scale_button.css({'margin':'0'});this.scale_button.unbind();this.scale_button.bind('click',$.proxy(this.earthMinimize,this));},scaleContainerDrag:function(){this.scale_container.css({'border':'1px solid #888'});},scaleContainerDragTo:function(containerX,containerY){this.scale_container.css({'position':'absolute','top':containerY+'px','left':containerX+'px','border':'1px solid #888'});},scaleContainerDragStop:function(event){var coords;coords=new HelioviewerMouseCoordinates(Helioviewer.userSettings.get("state.imageScale"),959.705,false);coords=coords.computeMouseCoords(this.scale_container.offset().left,this.scale_container.offset().top)
if(this.scale_container.position().left<=0||this.scale_container.position().left+this.scale_container.width()>=this.scale_container.parent().width()||this.scale_container.position().top+this.scale_container.height()>=this.scale_container.parent().height()||this.scale_container.position().top<=0){this.earthMaximize();}
else{Helioviewer.userSettings.set("state.scale",true);Helioviewer.userSettings.set("state.scaleType",'earth');Helioviewer.userSettings.set("state.scaleX",coords.x);Helioviewer.userSettings.set("state.scaleY",coords.y);Helioviewer.userSettings.set("state.containerX",this.scale_container.position().left);Helioviewer.userSettings.set("state.containerY",this.scale_container.position().top);}},_earthDiameterInPixels:function(){this.imageScale=Helioviewer.userSettings.get("state.imageScale");this.earthDiameterInPixels=Math.round(2*this._earthSunRadiusFraction*(this._rsunInArcseconds/this.imageScale));},_getScaleSettings:function(){this.scale=Helioviewer.userSettings.get("state.scale");this.scaleType=Helioviewer.userSettings.get("state.scaleType");this.scaleX=Helioviewer.userSettings.get("state.scaleX");this.scaleY=Helioviewer.userSettings.get("state.scaleY");this.containerX=Helioviewer.userSettings.get("state.containerX");this.containerY=Helioviewer.userSettings.get("state.containerY");},display:function(){this._getScaleSettings();if(this.scale===false){this.earthMinimize();}
else{if(this.scaleX==0||this.scaleY==0){this.earthMaximize();}
else{this.scaleContainerDragTo(this.containerX,this.containerY);}}
$(this.scale_container).css({'display':'block'});}});"use strict";var InputValidator=Class.extend({init:function(){},checkDateString:function(value,opts){var t=Date.parseUTCDate(value);t=null;},checkInt:function(value,opts){var options={"min":-Infinity,"max":Infinity};$.extend(options,opts||{});if(isNaN(value)||value<options.min||value>options.max||(typeof value==="string"&&parseInt(value,10)!==value.toString())){throw"Unacceptable integer value specified.";}},checkFloat:function(value,opts){var options={"min":-Infinity,"max":Infinity};$.extend(options,opts||{});if(isNaN(value)||value<options.min||value>options.max){throw"Unacceptable float value specified.";}},checkTimestamp:function(value,opts){var options={"min":0,"max":Math.round(new Date().getTime()/1000)+(24*60*60)};$.extend(options,opts||{});if(value.toString().length>10){value=value/1000;}
if(isNaN(value)||value<options.min||value>options.max){throw"Unacceptable timestamp value specified.";}}});"use strict";var SettingsLoader=({loadSettings:function(urlSettings,serverSettings){var defaults=this._getDefaultSettings(serverSettings),constraints={"minImageScale":serverSettings.minImageScale,"maxImageScale":serverSettings.maxImageScale,"minMovieLength":300,"maxMovieLength":16934400};return new UserSettings(defaults,urlSettings,constraints);},_getDefaultSettings:function(serverSettings){var date=new Date(+new Date());return{options:{date:"latest",movies:{cadence:"auto",duration:86400,format:"mp4"},autorefresh:false},history:{movies:[],screenshots:[]},notifications:{coordinates:true,welcome:true},state:{centerX:0,centerY:0,date:date.getTime(),eventLayers:[],eventLabels:true,scale:true,scaleType:'earth',scaleX:0,scaleY:0,imageScale:serverSettings.defaultImageScale,tileLayers:[{observatory:'SDO',instrument:'AIA',detector:'AIA',measurement:'304',visible:true,opacity:100}],timeStep:86400},version:serverSettings.version};}});"use strict";var UserSettings=Class.extend({init:function(defaults,urlSettings,constraints){this._defaults=defaults;this._constraints=constraints;this._validator=new InputValidator();this._initStorage();this._processURLSettings(urlSettings);},get:function(key){try{return this._get(key);}catch(ex){var value=this._getDefault(key);this.set(key,value)
return value;}},_get:function(key){var lookup=key.split(".");if(lookup.length===1){return this.settings[key];}else if(lookup.length===2){return this.settings[lookup[0]][lookup[1]];}
return this.settings[lookup[0]][lookup[1]][lookup[2]];},_getDefault:function(key){var lookup=key.split(".");if(lookup.length===1){return this._defaults[key];}else if(lookup.length===2){return this._defaults[lookup[0]][lookup[1]];}
return this._defaults[lookup[0]][lookup[1]][lookup[2]];},set:function(key,value){try{this._validate(key,value);}catch(e){return;}
var lookup=key.split(".");if(lookup.length===1){this.settings[key]=value;}else if(lookup.length===2){this.settings[lookup[0]][lookup[1]]=value;}else{this.settings[lookup[0]][lookup[1]][lookup[2]]=value;}
this._save();},_save:function(){if($.support.localStorage){localStorage.setItem("settings",$.toJSON(this.settings));}
else{this.cookies.set("settings",this.settings);}},_empty:function(){if($.support.localStorage){localStorage.removeItem("settings");}else{$.cookieJar("empty");}},_exists:function(){return($.support.localStorage?(localStorage.getItem("settings")!==null):(this.cookies.toString().length>2));},_initStorage:function(){if(!$.support.localStorage){this.cookies=$.cookieJar("settings");}
if(!this._exists()){this._loadDefaults();}
else{this._loadSavedSettings();}
if(this.get('version')<this._defaults.version){this._updateSettings(this.get('version'));}},_updateSettings:function(version){var statuses,self=this;if(version<567){this._loadDefaults();}else if(version<700){statuses={"QUEUED":0,"PROCESSING":1,"FINISHED":2,"ERROR":3};$.each(this.settings.history.movies,function(i,movie){self.settings.history.movies[i].status=statuses[movie.status];});this.settings.options=this.settings.defaults;delete this.settings.defaults;this.set('version',this._defaults.version);}},_loadDefaults:function(){this._empty();if($.support.localStorage){localStorage.setItem("settings",$.toJSON(this._defaults));}
else{this.cookies.set("settings",this._defaults);}
this.settings=this._defaults;},_loadSavedSettings:function(){if($.support.localStorage){this.settings=$.evalJSON(localStorage.getItem("settings"));}
else{this.settings=this.cookies.get("settings");}},_processURLSettings:function(urlSettings){if(urlSettings.imageScale){this.set("state.imageScale",parseFloat(urlSettings.imageScale));}
if(urlSettings.centerX){this.set("state.centerX",parseFloat(urlSettings.centerX));}
if(urlSettings.centerY){this.set("state.centerY",parseFloat(urlSettings.centerY));}
if(urlSettings.imageLayers){this.set("state.tileLayers",this._parseURLStringLayers(urlSettings.imageLayers));}
if(typeof urlSettings.eventLayers!='undefined'&&urlSettings.eventLayers!=''){this.set("state.eventLayers",this._parseURLStringEvents(urlSettings.eventLayers));}
if(urlSettings.eventLabels==true){this.set("state.eventLabels",true);}
else if(typeof urlSettings.eventLabels!='undefined'&&urlSettings.eventLabels==false){this.set("state.eventLabels",false);}},_parseURLStringLayers:function(urlLayers){var layers=[],self=this;$.each(urlLayers,function(i,layerString){layers.push(parseLayerString(layerString));});return layers;},_parseURLStringEvents:function(urlEventLayers){var events=[],self=this;$.each(urlEventLayers,function(i,eventLayerString){events.push(parseEventString(eventLayerString));});return events;},parseEventsURLString:function(eventLayerArray){var eventLayerString='';if(typeof eventLayerArray=="undefined"){eventLayerArray=this.get("state.eventLayers");}
$.each(eventLayerArray,function(i,eventLayerObj){eventLayerString+="["+eventLayerObj.event_type+","
+eventLayerObj.frms.join(';')+","
+eventLayerObj.open+"],";});return eventLayerString.slice(0,-1);},_validate:function(setting,value){var self=this;switch(setting){case"state.date":this._validator.checkTimestamp(value);break;case"state.imageScale":this._validator.checkFloat(value,{"min":this._constraints.minImageScale,"max":this._constraints.maxImageScale});break;case"history.movies":$.each(value,function(i,movie){self._validator.checkDateString(movie["dateRequested"]);});break;case"history.screenshots":$.each(value,function(i,screenshot){self._validator.checkDateString(screenshot["dateRequested"]);});break;case"options.movies.duration":this._validator.checkInt(value,{"min":this._constraints.minMovieLength,"max":this._constraints.maxMovieLength});break;default:break;}}});"use strict";var LayerManager=Class.extend({init:function(){this._layers=[];this._maxLayerDimensions={width:0,height:0};},addLayer:function(layer){this._layers.push(layer);},size:function(){return this._layers.length;},indexOf:function(id){var index=-1;$.each(this._layers,function(i,item){if(item.id===id){index=i;}});return index;},updateMaxDimensions:function(event){var type=event.type.split("-")[0];this.refreshMaxDimensions(type);$(document).trigger("viewport-max-dimensions-updated");},refreshMaxDimensions:function(type){var maxLeft=0,maxTop=0,maxBottom=0,maxRight=0,old=this._maxLayerDimensions;$.each(this._layers,function(){var d=this.getDimensions();maxLeft=Math.max(maxLeft,d.left);maxTop=Math.max(maxTop,d.top);maxBottom=Math.max(maxBottom,d.bottom);maxRight=Math.max(maxRight,d.right);});this._maxLayerDimensions={width:maxLeft+maxRight,height:maxTop+maxBottom};if((this._maxLayerDimensions.width!==old.width)||(this._maxLayerDimensions.height!==old.height)){$(document).trigger("layer-max-dimensions-changed",[type,this._maxLayerDimensions]);}},getMaxDimensions:function(){return this._maxLayerDimensions;},removeLayer:function(id){var type=id.split("-")[0],index=this.indexOf(id),layer=this._layers[index];layer.domNode.remove();this._layers=$.grep(this._layers,function(e,i){return(e.id!==layer.id);});layer=null;this.refreshMaxDimensions(type);},each:function(fn){$.each(this._layers,fn);},toJSON:function(){var layers=[];$.each(this._layers,function(){layers.push(this.toJSON());});return layers;}});"use strict";var EventManager=Class.extend({init:function(eventGlossary,date){var visState,scale;this._eventLayers=[];this._events=[];this._eventMarkers=[];this._eventTypes={};this._treeContainer=$("#eventJSTree");this._jsTreeData=[];this._date=date;this._eventLabelsVis=Helioviewer.userSettings.get("state.eventLabels");this._eventGlossary=eventGlossary;scale=new ImageScale();$('<div id="event-container"></div>').appendTo("#moving-container");visState=Helioviewer.userSettings.get("state.eventLayerVisible");if(typeof visState=='undefined'){Helioviewer.userSettings.set("state.eventLayerVisible",true);visState=true;}
if(visState===false&&$("#event-container").css('display')!='none'){$('span[id^="visibilityBtn-event-layer-"]').click();}
else if(visState===true&&$("#event-container").css('display')=='none'){$('span[id^="visibilityBtn-event-layer-"]').click();}
this._queryDefaultEventTypes();this._queryEventFRMs();$(document).bind("fetch-eventFRMs",$.proxy(this._queryEventFRMs,this));$(document).bind("toggle-events",$.proxy(this._toggleEvents,this));$(document).bind('toggle-event-labels',$.proxy(this.toggleEventLabels,this));},reinit:function(date){var visState;$("#event-container").remove();$('<div id="event-container"></div>').appendTo("#moving-container");visState=Helioviewer.userSettings.get("state.eventLayerVisible");if(typeof visState=='undefined'){Helioviewer.userSettings.set("state.eventLayerVisible",true);visState=true;}
if(visState===false&&$("#event-container").css('display')!='none'){$('span[id^="visibilityBtn-event-layer-"]').click();}
else if(visState===true&&$("#event-container").css('display')=='none'){$('span[id^="visibilityBtn-event-layer-"]').click();}
this._eventLayers=[];this._events=[];this._eventMarkers=[];this._eventTypes={};this._jsTreeData=[];this._date=date;this._queryEventFRMs();},_queryDefaultEventTypes:function(){var params={"action":"getDefaultEventTypes"};$.get("api/index.php",params,$.proxy(this._parseEventFRMs,this),"json");},_queryEventFRMs:function(){if(this._events.length==0){var params={"action":"getEventFRMs","startTime":new Date(this._date.getTime()).toISOString(),"ar_filter":true};$.get("api/index.php",params,$.proxy(this._parseEventFRMs,this),"json");}},_parseEventFRMs:function(result){var self=this,domNode,eventAbbr,settings;$("#event-container").empty();self._eventTypes={};$.each(result,function(eventType,eventFRMs){eventAbbr=eventType.split('/');eventAbbr=eventAbbr[1];self._eventTypes[eventAbbr]=new EventType(eventAbbr);$.each(eventFRMs,function(frmName,eventFRM){self._eventTypes[eventAbbr]._eventFRMs[frmName]=new EventFeatureRecognitionMethod(frmName,self.eventGlossary);domNode='<div class="event-layer" id="'
+eventAbbr+'__'+frmName.replace(/ /g,'_')
+'" style="position: absolute;">';self._eventTypes[eventAbbr]._eventFRMs[frmName].setDomNode($(domNode).appendTo("#event-container"));});});this._generateTreeData(result);this._queryEvents();},_queryEvents:function(){var params;params={"action":"getEvents","startTime":new Date(this._date.getTime()).toISOString(),"eventType":'**'};$.get("api/index.php",params,$.proxy(this._parseEvents,this),"json");},_parseEvents:function(result){var eventMarker,self=this,parentDomNode,eventGlossary;eventGlossary=this._eventGlossary;$.each(this._eventMarkers,function(i,eventMarker){eventMarker.remove();});this._eventMarkers=[];this._events=result;$.each(this._events,function(i,event){if(typeof self._eventTypes[event['event_type']]!='undefined'){self._eventMarkers.push(new EventMarker(eventGlossary,self._eventTypes[event['event_type']]._eventFRMs[event['frm_name']],event,i+1));}});this._toggleEvents();},_generateTreeData:function(data){var self=this,obj,index=0,event_type_arr,type_count=0,count_str;self._jsTreeData=[];$.each(data,function(event_type,event_type_obj){event_type_arr=event_type.split('/');if(event_type_arr[0].charAt(event_type_arr[0].length-1)==" "){event_type_arr[0]=event_type_arr[0].slice(0,-1);}
switch(event_type_arr[0].charAt(event_type_arr[0].length-1)){case'x':event_type_arr[0]+='es';break;case'y':event_type_arr[0]=event_type_arr[0].slice(0,-1)+'ies';break;default:event_type_arr[0]+='s';}
obj=Object();obj['data']=event_type_arr[0];obj['attr']={'id':event_type_arr[1]};obj['state']='open';obj['children']=[];self._jsTreeData.push(obj);type_count=0;$.each(event_type_obj,function(frm_name,frm_obj){type_count+=frm_obj['count'];count_str='';if(frm_obj['count']>0){count_str=" ("+frm_obj['count']+")";}
self._jsTreeData[index].children.push({'data':frm_name+count_str,'attr':{'id':event_type_arr[1]
+'--'
+self._escapeInvalidCssChars(frm_name)}});});count_str='';if(type_count>0){count_str=" ("+type_count+")";}
obj['data']=obj['data']+count_str;index++;});if(!self._eventTree){self._eventTree=new EventTree(this._jsTreeData,this._treeContainer);}
self._eventTree.reload(this._jsTreeData);$(document).trigger('viewport-resized');},_escapeInvalidCssChars:function(selector){selector=selector.replace(/ /g,"_");selector=selector.replace(/([\+\.\(\)])/g,'\\$1');return selector;},updateRequestTime:function(){var managerStartDate,managerEndDate,eventStartDate,eventEndDate,self=this;this.reinit(new Date($("#date").val().replace(/\//g,"-")+"T"+$("#time").val()+"Z"));},addEventLayer:function(eventLayer){this._eventLayers.push(eventLayer);},size:function(){return this._eventLayers.length;},indexOf:function(id){var index=-1;$.each(this._eventLayers,function(i,item){if(item.id===id){index=i;}});return index;},each:function(fn){$.each(this._eventLayers,fn);},toJSON:function(){var eventLayers=[];$.each(this._eventLayers,function(){eventLayers.push(this.toJSON());});return eventLayers;},_toggleEvents:function(event){var newState,checkedEventTypes=[],checkedFRMs={},self=this;newState=Helioviewer.userSettings.get("state.eventLayers");$.each(newState,function(i,checkedTypeObj){checkedEventTypes.push(checkedTypeObj['event_type']);checkedFRMs[checkedTypeObj['event_type']]=[];$.each(checkedTypeObj['frms'],function(j,frmName){checkedFRMs[checkedTypeObj['event_type']].push(frmName);});});$.each(this._eventTypes,function(eventTypeName,eventTypeObj){$.each(eventTypeObj._eventFRMs,function(frmName,frmObj){if($.inArray(eventTypeName,checkedEventTypes)==-1){self._eventTypes[eventTypeName]._eventFRMs[frmName].domNode.hide();}
else{if(checkedFRMs[eventTypeName][0]=='all'||$.inArray(frmName.replace(/ /g,'_'),checkedFRMs[eventTypeName])!=-1){self._eventTypes[eventTypeName]._eventFRMs[frmName].domNode.show();}
else{self._eventTypes[eventTypeName]._eventFRMs[frmName].domNode.hide();}}});});this.eventLabels();},toggleEventLabels:function(event,labelsBtn){if(typeof labelsBtn=='undefined'){labelsBtn=$('span[id^="labelsBtn-event-layer-"]');}
if(this._eventLabelsVis){$(document).trigger('toggle-event-label-off');labelsBtn.addClass('hidden');}
else{$(document).trigger('toggle-event-label-on');labelsBtn.removeClass('hidden');}
this._eventLabelsVis=!this._eventLabelsVis;return true;},eventLabels:function(event){this._eventLabelsVis=Helioviewer.userSettings.get("state.eventLabels");if(this._eventLabelsVis){$(document).trigger('toggle-event-label-on');}
else{$(document).trigger('toggle-event-label-off');}
return true;}});"use strict";var EventType=Class.extend({init:function(name){this._name=name;this._eventFRMs={};this._queried=false;},getEventFRMs:function(){return this._eventFRMs;},getName:function(){return this._name;},addFRM:function(frm){this._eventFRMs[frm._name]=frm;},isQueried:function(startTime,endTime){var typeIsQueried=true;$.each(this._eventFRMs,function(frmName,FRM){if(!FRM.isQueried(startTime,endTime)){typeIsQueried=false;return false;}});return typeIsQueried;}});"use strict";var EventTree=Class.extend({init:function(data,container){this._container=container;this._build(data);$(document).bind("toggle-checkboxes",$.proxy(this.toggle_checkboxes,this));$(document).bind("toggle-checkboxes-to-state",$.proxy(this.toggle_checkboxes_state,this));},destroy:function(data){this._container.empty();},reload:function(newData){this.destroy();this._build(newData);},close_all:function(){this._container.jstree("close_all",null,true);},open_all:function(){this._container.jstree("open_all",null,true);},toggle_checkboxes:function(){var numChecked;numChecked=Helioviewer.userSettings.get("state.eventLayers").length;if(numChecked>0){this._container.jstree("uncheck_all",null,true);}
else{this._container.jstree("check_all",null,true);this._container.unbind("change_state.jstree",$.proxy(this._treeChangedState,this));$(document).trigger("fetch-eventFRMs");this._container.bind("change_state.jstree",$.proxy(this._treeChangedState,this));}},toggle_checkboxes_state:function(e,toState){if(toState=='off'){this._container.jstree("uncheck_all",null,true);}
else if(toState=='on'){this._container.jstree("check_all",null,true);}
else{this.toggle_checkboxes();return;}
this._container.unbind("change_state.jstree",$.proxy(this._treeChangedState,this));$(document).trigger("fetch-eventFRMs");this._container.bind("change_state.jstree",$.proxy(this._treeChangedState,this));},jstreeFunc:function(name,args){this._container.jstree(name,args);},_build:function(jsTreeData){var self=this,saved,node;this._container.jstree({"json_data":{"data":jsTreeData},"themes":{"theme":"default","dots":true,"icons":false},"plugins":["json_data","themes","ui","checkbox"],});$.each(jsTreeData,function(index,event_type){$('#'+event_type['attr'].id+' a').hover($.proxy(self.hoverOn,this),$.proxy(self.hoverOff,this));if(event_type.children.length==0){$('#'+event_type['attr'].id).css({'opacity':'0.5'});}
$.each(event_type['children'],function(j,frm){$('#'+self._escapeInvalidJQueryChars(frm['attr'].id)+' a').hover($.proxy(self.hoverOnFRM,this),$.proxy(self.hoverOffFRM,this));});});this._container.unbind("change_state.jstree",$.proxy(this._treeChangedState,this));saved=Helioviewer.userSettings.get("state.eventLayers");$.each(saved,function(i,eventLayer){if(eventLayer.frms[0]=='all'){node="#"+eventLayer.event_type;if($(node).length!=0){self.jstreeFunc("check_node",node);}}
else{$.each(eventLayer.frms,function(j,frm){node="#"+eventLayer.event_type+"--"+frm;if($(node).length!=0){self.jstreeFunc("check_node",node);}});}});this._container.bind("change_state.jstree",$.proxy(this._treeChangedState,this));$(document).trigger("change_state.jstree",this);},_escapeInvalidJQueryChars:function(selector){selector=selector.replace(/(\+)/g,'\\\\$1');selector=selector.replace(/(\.)/g,'\\\\$1');selector=selector.replace(/(\()/g,'\\\\$1');selector=selector.replace(/(\))/g,'\\\\$1');return selector;},_treeChangedState:function(event,data){var checked=[],event_types=[],index;this._container.jstree("get_checked",null,false).each(function(){var eventLayer,event_type,frm;event_type=this.id.split("--");if(event_type.length>1){frm=event_type[1];}
else{frm='all';}
event_type=event_type[0];index=$.inArray(event_type,event_types)
if(index==-1){eventLayer={'event_type':event_type,'frms':[frm],'open':1};checked.push(eventLayer);event_types.push(event_type);}
else{checked[index].frms.push(frm);}});Helioviewer.userSettings.set("state.eventLayers",checked);$(document).trigger("toggle-events");},hoverOn:function(event){var emphasisNodes,eventLayerNodes,found;emphasisNodes=$("[id^="+this['attr'].id+"__]");eventLayerNodes=$("#event-container > div.event-layer");$.each(eventLayerNodes,function(i,obj){found=false;$.each(emphasisNodes,function(j,emphObj){if($(obj)[0].id==$(emphObj)[0].id){found=true;}});if(found===false&&emphasisNodes.length>0){$(obj).css({'opacity':'0.20'});}
else{$(obj).css({'opacity':'1.00'});}});},hoverOff:function(event){$("#event-container > div.event-layer").css({'opacity':'1.0'});},hoverOnFRM:function(event){var emphasisNode,deEmphasisNodes,eventTypeAbbr,eventLayerNodes,found;eventTypeAbbr=this['attr'].id.split("--")[0];emphasisNode=$("#"+this['attr'].id.replace("--","__"));deEmphasisNodes=$("[id^="+eventTypeAbbr+"__]");eventLayerNodes=$("#event-container > div.event-layer");$.each(eventLayerNodes,function(i,obj){if($(obj)[0].id==$(emphasisNode)[0].id){$(obj).css({'opacity':'1.00'});}
else{found=false;$.each(deEmphasisNodes,function(j,deEmphObj){if($(obj)[0].id==$(deEmphObj)[0].id){found=true;}});if(found===true){$(obj).css({'opacity':'0.20'});}
else{$(obj).css({'opacity':'0.20'});}}});},hoverOffFRM:function(event){var emphasisNode,deEmphasisNodes,eventTypeAbbr,eventLayerNodes,found;eventTypeAbbr=this['attr'].id.split("--")[0];emphasisNode=$("#"+this['attr'].id.replace("--","__"));deEmphasisNodes=$("[id^="+eventTypeAbbr+"__]");eventLayerNodes=$("#event-container > div.event-layer");$.each(eventLayerNodes,function(i,obj){if($(obj)[0].id==$(emphasisNode)[0].id){$(obj).css({'opacity':'1.0'});}
else{found=false;$.each(deEmphasisNodes,function(j,deEmphObj){if($(obj)[0].id==$(deEmphObj)[0].id){found=true;}});if(found===true){$(obj).css({'opacity':'1.0'});}
else{$(obj).css({'opacity':'1.0'});}}});}});"use strict";var EventFeatureRecognitionMethod=Class.extend({init:function(name,eventGlossary){this._events=[];this._name=name;this._visible=false;this.eventGlossary=eventGlossary;},getName:function(){return this._name;},setDomNode:function(domNode){this.domNode=domNode;}});"use strict";var EventLayerManager=EventManager.extend({init:function(requestDate,defaultEventTypes,viewportScale,rsun,savedEventLayers,urlEventLayers){this._eventLayers=[];this._events=[];this._eventMarkers=[];this._treeContainer=$("#eventJSTree");this._eventTypes={};this._jsTreeData=[];if(typeof date=='undefined'){var date=requestDate;}
this._date=date;this._requestDate=requestDate;this.defaultEventTypes=defaultEventTypes;this.viewportScale=viewportScale;$(document).bind("event-layer-finished-loading",$.proxy(this.updateMaxDimensions,this)).bind("save-event-layers",$.proxy(this.save,this)).bind("add-new-event-layer",$.proxy(this.addNewLayer,this)).bind("remove-event-layer",$.proxy(this._onLayerRemove,this));},save:function(){var eventLayers=this.toJSON();Helioviewer.userSettings.set("state.eventLayers",eventLayers);},_onLayerRemove:function(event,id){this.removeLayer(id);},getRequestDateAsISOString:function(){return this._requestDate.toISOString();}});"use strict";var EventMarker=Class.extend({init:function(eventGlossary,parentFRM,event,zIndex){$.extend(this,event);this.event=event;this.behindSun=false;this.parentFRM=parentFRM;this._labelVisible=false;this._popupVisible=false;this._zIndex=zIndex;this._eventGlossary=eventGlossary;this.formatLabels();this.createRegion(0);this.createMarker(zIndex);$(document).bind("replot-event-markers",$.proxy(this.refresh,this));$(document).bind('toggle-event-label-on',$.proxy(this.toggleEventLabel,this));$(document).bind('toggle-event-label-off',$.proxy(this.toggleEventLabel,this));},createMarker:function(zIndex){var markerURL;this.eventMarkerDomNode=$('<div/>');this.eventMarkerDomNode.attr({'class':"event-marker"});this.pos={x:(this.hv_hpc_x_final/Helioviewer.userSettings.settings.state.imageScale)-12,y:(-this.hv_hpc_y_final/Helioviewer.userSettings.settings.state.imageScale)-38};markerURL=serverSettings['staticAssetUrl']+'/resources/images/eventMarkers/'+this.event_type.toUpperCase()+'@2x'+'.png';this.eventMarkerDomNode.css({'left':this.pos.x+'px','top':this.pos.y+'px','z-index':zIndex,'background-image':"url('"+markerURL+"')"});if(typeof this.parentFRM!='undefined'){this.parentFRM.domNode.append(this.eventMarkerDomNode);}
else{return;}
this.eventMarkerDomNode.bind("click",$.proxy(this.toggleEventPopUp,this));this.eventMarkerDomNode.mouseenter($.proxy(this.toggleEventLabel,this));this.eventMarkerDomNode.mouseleave($.proxy(this.toggleEventLabel,this));},createRegion:function(zIndex){if(this.hpc_boundcc!=''){var regionURL;this.eventRegionDomNode=$('<div/>');this.eventRegionDomNode.attr({'class':"event-region"});this.region_scaled={width:this.hv_poly_width_max_zoom_pixels*(Helioviewer.userSettings._constraints.minImageScale/Helioviewer.userSettings.settings.state.imageScale),height:this.hv_poly_height_max_zoom_pixels*(Helioviewer.userSettings._constraints.minImageScale/Helioviewer.userSettings.settings.state.imageScale)}
this.region_pos={x:(this.hv_poly_hpc_x_final/Helioviewer.userSettings.settings.state.imageScale),y:(this.hv_poly_hpc_y_final/Helioviewer.userSettings.settings.state.imageScale)}
this.eventRegionDomNode.css({'left':this.region_pos.x+'px','top':this.region_pos.y+'px','z-index':zIndex,'background-image':"url('"+serverSettings['staticAssetUrl']
+"/"+this.hv_poly_url+"')",'background-size':this.region_scaled.width+'px '+this.region_scaled.height+'px','width':this.region_scaled.width+'px','height':this.region_scaled.height+'px'});if(typeof this.parentFRM!='undefined'){this.parentFRM.domNode.append(this.eventRegionDomNode);}
this.eventRegionDomNode.bind("click",$.proxy(this.toggleEventPopUp,this));this.eventRegionDomNode.mouseenter($.proxy(this.toggleEventLabel,this));this.eventRegionDomNode.mouseleave($.proxy(this.toggleEventLabel,this));}},formatLabels:function(){var self=this;if(this.hasOwnProperty('hv_labels_formatted')&&Object.keys(this.hv_labels_formatted).length>0){this.labelText="";$.each(this.hv_labels_formatted,function(key,value){self.labelText+=value+"<br/>\n";});}
else{this.labelText=this.concept;}},remove:function(){this.eventMarkerDomNode.qtip("destroy");this.eventMarkerDomNode.unbind();this.eventMarkerDomNode.remove();if(this.hpc_boundcc!=''){this.eventRegionDomNode.qtip("destroy");this.eventRegionDomNode.unbind();this.eventRegionDomNode.remove();}},refresh:function(){this.pos={x:(this.hv_hpc_x_final/Helioviewer.userSettings.settings.state.imageScale)-12,y:(-this.hv_hpc_y_final/Helioviewer.userSettings.settings.state.imageScale)-38};this.eventMarkerDomNode.css({'left':this.pos.x+'px','top':this.pos.y+'px'});if(this.hpc_boundcc!=''){this.region_scaled={width:this.hv_poly_width_max_zoom_pixels*(Helioviewer.userSettings._constraints.minImageScale/Helioviewer.userSettings.settings.state.imageScale),height:this.hv_poly_height_max_zoom_pixels*(Helioviewer.userSettings._constraints.minImageScale/Helioviewer.userSettings.settings.state.imageScale)}
this.region_pos={x:(this.hv_poly_hpc_x_final/Helioviewer.userSettings.settings.state.imageScale),y:(this.hv_poly_hpc_y_final/Helioviewer.userSettings.settings.state.imageScale)}
this.eventRegionDomNode.css({'left':this.region_pos.x+'px','top':this.region_pos.y+'px'});this.eventRegionDomNode.css({'width':this.region_scaled.width,'height':this.region_scaled.height,'background-size':this.region_scaled.width+'px '+this.region_scaled.height+'px'});}
if(this._popupVisible){this.popup_pos={x:(this.hv_hpc_x_final/Helioviewer.userSettings.settings.state.imageScale)+12,y:(-this.hv_hpc_y_final/Helioviewer.userSettings.settings.state.imageScale)-38};if(this.hv_hpc_x_final>400){this.popup_pos.x-=this.eventPopupDomNode.width()+38;}
this.eventPopupDomNode.css({'left':this.popup_pos.x+'px','top':this.popup_pos.y+'px'});}},setVisibility:function(visible){if(visible){this.eventRegionDomNode.show();this.eventMarkerDomNode.show();}
else{this.eventRegionDomNode.hide();this.eventMarkerDomNode.hide();}},toggleEventLabel:function(event){if(!this.label){this.label=$('<div/>');this.label.hide();this.label.attr({'class':"event-label"});this.label.html(this.labelText);this.label.click(function(event){event.stopImmediatePropagation();});this.label.mousedown(function(event){event.stopImmediatePropagation();});this.label.dblclick(function(event){event.stopImmediatePropagation();});this.label.enableSelection();this.eventMarkerDomNode.append(this.label);}
if(event.type=='toggle-event-label-on'){this.eventMarkerDomNode.css('zIndex','997');this._labelVisible=true;document.getSelection().removeAllRanges();this.label.show();Helioviewer.userSettings.set("state.eventLabels",true);}
else if(event.type=='toggle-event-label-off'){this._labelVisible=false;this.label.hide();this.eventMarkerDomNode.css('zIndex',this._zIndex);document.getSelection().removeAllRanges();Helioviewer.userSettings.set("state.eventLabels",false);}
else if(event.type=='mouseenter'){this.eventMarkerDomNode.css('zIndex','997');this.label.addClass("event-label-hover");this.label.show();}
else if(event.type=='mouseleave'){if(!this._labelVisible){this.label.hide();}
this.label.removeClass("event-label-hover");this.eventMarkerDomNode.css('zIndex',this._zIndex);}
return true;},toggleEventPopUp:function(){if(!this.eventPopupDomNode){this._populatePopup();}
if(this._popupVisible){this.eventPopupDomNode.hide();this.eventMarkerDomNode.css('z-index',this._zIndex);}
else{this.popup_pos={x:(this.hv_hpc_x_final/Helioviewer.userSettings.settings.state.imageScale)+12,y:(-this.hv_hpc_y_final/Helioviewer.userSettings.settings.state.imageScale)-38};if(this.hv_hpc_x_final>400){this.popup_pos.x-=this.eventPopupDomNode.width()+38;}
this.eventPopupDomNode.css({'left':this.popup_pos.x+'px','top':this.popup_pos.y+'px','z-index':'1000'});this.eventMarkerDomNode.css('z-index','998');this.eventPopupDomNode.show();}
this._popupVisible=!this._popupVisible;return true;},_showEventInfoDialog:function(){var params,dtype,split,self=this,dialog=$("#event-info-dialog");this._buildEventInfoDialog();$('.event-header-value.integer').number(true);$('.event-header-value.float').each(function(i,num){split=num.innerHTML.split('.')
if(typeof split[1]!='undefined'){num.innerHTML=$.number(num.innerHTML,split[1].length);}
else{num.innerHTML=$.number(num.innerHTML);}});},_buildEventInfoDialog:function(){var dialog,sortBtn,tabs,html='',tag,json,headingText,self=this;dialog=$("<div id='event-info-dialog' class='event-info-dialog' />");if(this.hasOwnProperty('hv_labels_formatted')&&Object.keys(this.hv_labels_formatted).length>0){headingText=this.event_type+': '+this.hv_labels_formatted[Object.keys(this.hv_labels_formatted)[0]];}
else{headingText=this.concept;}
html+='<div class="event-info-dialog-menu">'
+'<a class="show-tags-btn event-type selected">'+this.concept+'</a>'
+'<a class="show-tags-btn obs">Observation</a>'
+'<a class="show-tags-btn frm">Recognition Method</a>'
+'<a class="show-tags-btn ref">References</a>'
+'<a class="show-tags-btn all right">All</a>'
+'</div>';html+='<div class="event-header event-type" style="height: 400px; overflow: auto;">'
+this._generateEventKeywordsSection(this.event_type)+'</div>'
+'<div class="event-header obs" style="display: none; height: 400px; overflow: auto;">'
+this._generateEventKeywordsSection("obs")+'</div>'
+'<div class="event-header frm" style="display: none; height: 400px; overflow: auto;">'
+this._generateEventKeywordsSection("frm")+'</div>'
+'<div class="event-header ref" style="display: none; height: 400px; overflow: auto;">'
+this._generateEventKeywordsSection("ref")+'</div>'
+'<div class="event-header all" style="display: none; height: 400px; overflow: auto;">'
+this._generateEventKeywordsSection("all")+'</div>';dialog.append(html).appendTo("body").dialog({autoOpen:true,title:headingText,minWidth:746,width:646,height:550,draggable:true,resizable:false,buttons:[{text:'Hide Empty Rows','class':'toggle_empty',click:function(){var text=$(this).parent().find('.toggle_empty span.ui-button-text');$.each($(this).find("div.empty"),function(index,node){if($(node).css('display')=='none'){$(node).css('display','block');}
else{$(node).css('display','none');}});if(text.html()=='Hide Empty Rows'){text.html('Show Empty Rows');}
else{text.html('Hide Empty Rows');}}}],create:function(event,ui){dialog.css('overflow','hidden');var eventTypeTab=dialog.find(".show-tags-btn.event-type"),obsTab=dialog.find(".show-tags-btn.obs"),frmTab=dialog.find(".show-tags-btn.frm"),refTab=dialog.find(".show-tags-btn.ref"),allTab=dialog.find(".show-tags-btn.all");eventTypeTab.click(function(){eventTypeTab.addClass("selected");obsTab.removeClass("selected");frmTab.removeClass("selected");refTab.removeClass("selected");allTab.removeClass("selected");dialog.find(".event-header.event-type").show();dialog.find(".event-header.obs").hide();dialog.find(".event-header.frm").hide();dialog.find(".event-header.ref").hide();dialog.find(".event-header.all").hide();});obsTab.click(function(){eventTypeTab.removeClass("selected");obsTab.addClass("selected");frmTab.removeClass("selected");refTab.removeClass("selected");allTab.removeClass("selected");dialog.find(".event-header.event-type").hide();dialog.find(".event-header.obs").show();dialog.find(".event-header.frm").hide();dialog.find(".event-header.ref").hide();dialog.find(".event-header.all").hide();});frmTab.click(function(){eventTypeTab.removeClass("selected");obsTab.removeClass("selected");frmTab.addClass("selected");refTab.removeClass("selected");allTab.removeClass("selected");dialog.find(".event-header.event-type").hide();dialog.find(".event-header.obs").hide();dialog.find(".event-header.frm").show();dialog.find(".event-header.ref").hide();dialog.find(".event-header.all").hide();});refTab.click(function(){eventTypeTab.removeClass("selected");obsTab.removeClass("selected");frmTab.removeClass("selected");refTab.addClass("selected");allTab.removeClass("selected");dialog.find(".event-header.event-type").hide();dialog.find(".event-header.obs").hide();dialog.find(".event-header.frm").hide();dialog.find(".event-header.ref").show();dialog.find(".event-header.all").hide();});allTab.click(function(){eventTypeTab.removeClass("selected");obsTab.removeClass("selected");frmTab.removeClass("selected");refTab.removeClass("selected");allTab.addClass("selected");dialog.find(".event-header.event-type").hide();dialog.find(".event-header.obs").hide();dialog.find(".event-header.frm").hide();dialog.find(".event-header.ref").hide();dialog.find(".event-header.all").show();});}});},_generateEventKeywordsSection:function(tab){var formatted,tag,tags=[],lookup,attr,domClass,icon,list={},self=this;if(tab=='obs'){$.each(this.event,function(key,value){if(key.substring(0,4)=='obs_'){lookup=self._eventGlossary[key];if(typeof lookup!='undefined'){list[key]=lookup;list[key]["value"]=value;}
else{list[key]={"value":value};}}});}
else if(tab=='frm'){$.each(this.event,function(key,value){if(key.substring(0,4)=='frm_'){lookup=self._eventGlossary[key];if(typeof lookup!='undefined'){list[key]=lookup;list[key]["value"]=value;}
else{list[key]={"value":value};}}});}
else if(tab=='ref'){$.each(this.event['refs'],function(index,obj){lookup=self._eventGlossary[obj['ref_name']];if(typeof lookup!='undefined'){list[obj['ref_name']]=lookup;list[obj['ref_name']]["value"]=obj['ref_url'];}
else{list[obj['ref_name']]={"value":obj['ref_url']};}});}
else if(tab=='all'){$.each(this.event,function(key,value){if(key.substring(0,3)!='hv_'&&key!='refs'){lookup=self._eventGlossary[key];if(typeof lookup!='undefined'){list[key]=lookup;list[key]["value"]=value;}
else{list[key]={"value":value};}}});}
else if(tab.length==2){$.each(this.event,function(key,value){if(key.substring(0,3)==tab.toLowerCase()+'_'||key.substring(0,5)=='event'||key=='concept'||key.substring(0,3)=='kb_'){lookup=self._eventGlossary[key];if(typeof lookup!='undefined'){list[key]=lookup;list[key]["value"]=value;}
else{list[key]={"value":value};}}});}
else{console.warn('No logic for unexpected tab "'+tab+'".');}
formatted='<div>';$.each(list,function(key,obj){attr='';domClass='';icon='';if(tab!='all'&&typeof obj['hv_label']!='undefined'&&obj['hv_label']!==null){key=obj['hv_label'];}
if(typeof obj['hek_desc']!='undefined'&&obj['hek_desc']!==null){attr+=' title="'+obj['hek_desc']+'"';}
if(obj.value!=''&&obj.value!='N/A'&&obj.value!='n/a'&&typeof obj['hv_type']!='undefined'&&(obj['hv_type']=='url'||obj['hv_type']=='image_url')){if(obj.value.indexOf('://')==-1){obj.value='http://'+obj.value;}
obj.value='<a href="'+obj.value+'" target="_blank">'+obj.value+'</a>';}
if(obj.value!=''&&obj.value!='N/A'&&obj.value!='n/a'&&typeof obj['hv_type']!='undefined'&&obj['hv_type']=='email_or_url'){if(obj.value.indexOf('://')==-1&&obj.value.indexOf('/')!==-1&&obj.value.indexOf('@')==-1&&obj.value.indexOf(' at ')==-1){obj.value='http://'+obj.value;obj.value='<a href="'+obj.value+'" target="_blank">'+obj.value+'</a>';}
else if(obj.value.indexOf('://')!==-1){obj.value='<a href="'+obj.value+'" target="_blank">'+obj.value+'</a>';}
else if(obj.value.indexOf('@')>-1&&obj.value.indexOf(' ')==-1){obj.value='<a href="mailto:'+obj.value+'">'+obj.value+'</a>';}}
if(obj.value!=''&&obj.value!='N/A'&&obj.value!='n/a'&&typeof obj['hv_type']!='undefined'&&obj['hv_type']=='thumbnail_url'){if(obj.value.indexOf('://')==-1){obj.value='http://'+obj.value;}
obj.value='<img src="'+obj.value+'"/>';}
if(typeof obj['hv_type']!='undefined'&&obj['hv_type']=='date'){domClass+=' date';}
if(typeof obj['hek_type']!='undefined'&&obj['hek_type']=='float'){domClass+=' float';}
if(typeof obj['hek_type']!='undefined'&&(obj['hek_type']=='integer'||obj['hek_type']=='long')){domClass+=' integer';}
if(typeof obj['hv_type']!='undefined'&&obj['hv_type']=='boolean'){domClass+=' boolean';if(obj.value.toUpperCase()=="T"||obj.value==1||obj.value.toLowerCase()=='true'){domClass+=' true';}
if(obj.value.toUpperCase()=="F"||obj.value==0||obj.value.toLowerCase()=='false'){domClass+=' false';}}
if(typeof obj['hv_type']!='undefined'&&obj['hv_type']!='date'&&typeof obj['hek_type']!='undefined'&&obj['hek_type']=='string'){domClass+=' string';}
if(typeof obj.value==='undefined'||obj.value===null||obj.value==='null'||obj.value===''){tag='<div class="empty"><span class="event-header-tag empty"'+attr+'>'+key+': </span>'+'<span class="event-header-value empty">'+obj.value+'</span></div>';}
else{tag='<div><span class="event-header-tag"'+attr+'>'+key+': </span>'+'<span class="event-header-value'+domClass+'">'+obj.value+'</span></div>';}
tags.push(tag);formatted+=tag;});formatted+='</div>';return formatted;},_populatePopup:function(){var content='',headingText='',self=this;if(this.hasOwnProperty('hv_labels_formatted')&&Object.keys(this.hv_labels_formatted).length>0){headingText=this.event_type+': '+this.hv_labels_formatted[Object.keys(this.hv_labels_formatted)[0]];}
else{headingText=this.concept;}
content+='<div class="close-button ui-icon ui-icon-closethick" title="Close PopUp Window"></div>'+"\n"
+'<h1>'+headingText+'</h1>'+"\n";if(this.event_peaktime!=null&&this.event_peaktime!=''){content+='<div class="container">'+"\n"
+"\t"+'<div class="param-container"><div class="param-label">Peak Time:</div></div>'+"\n"
+"\t"+'<div class="value-container"><div class="param-value">'+this.event_peaktime.replace('T',' ')+'</div><div class="ui-icon ui-icon-arrowstop-1-n" title="Jump to Event Peak Time"></div></div>'+"\n"
+'</div>'+"\n";}
content+='<div class="container">'+"\n"
+"\t"+'<div class="param-container"><div class="param-label">Start Time: </div></div>'+"\n"
+"\t"+'<div class="value-container"><div class="param-value">'+this.event_starttime.replace('T',' ')+'</div><div class="ui-icon ui-icon-arrowstop-1-w" title="Jump to Event Start Time"></div></div>'+"\n"
+'</div>'+"\n"
+'<div class="container">'+"\n"
+"\t"+'<div class="param-container"><div class="param-label">End Time: </div></div>'+"\n"
+"\t"+'<div class="value-container"><div class="param-value">'+this.event_endtime.replace('T',' ')+'</div><div class="ui-icon ui-icon-arrowstop-1-e" title="Jump to Event End Time"></div>'+"\n"
+'</div>'+"\n";if(this.hasOwnProperty('hv_labels_formatted')&&Object.keys(this.hv_labels_formatted).length>0){$.each(this.hv_labels_formatted,function(param,value){content+='<div class="container">'+"\n"
+"\t"+'<div class="param-container"><div class="param-label">'+param+': </div></div>'+"\n"
+"\t"+'<div class="value-container"><div class="param-value">'+value+'</div></div>'+"\n"
+'</div>'+"\n";});}
content+='<div class="btn-container text-btn">'+"\n"
+"\t"+'<div class="ui-icon ui-icon-info btn event-info"></div><div class="btn-label btn event-info">View HEK data</div>'+"\n"
+'</div>'+"\n";this.eventPopupDomNode=$('<div/>');this.eventPopupDomNode.hide();this.eventPopupDomNode.attr({'class':"event-popup"});this.eventPopupDomNode.html(content);this.eventPopupDomNode.find(".ui-icon-arrowstop-1-w").bind('click',function(){helioviewer.timeControls.setDate(new Date(self.event_starttime+".000Z"));});this.eventPopupDomNode.find(".ui-icon-arrowstop-1-n").bind('click',function(){helioviewer.timeControls.setDate(new Date(self.event_peaktime+".000Z"));});this.eventPopupDomNode.find(".ui-icon-arrowstop-1-e").bind('click',function(){helioviewer.timeControls.setDate(new Date(self.event_endtime+".000Z"));});this.eventPopupDomNode.find(".event-movie").bind('click',function(){alert('Event-based movie generation not yet implemented.')});this.eventPopupDomNode.find(".btn.event-info").bind('click',$.proxy(this._showEventInfoDialog,this));this.eventPopupDomNode.find('.close-button').bind('click',$.proxy(this.toggleEventPopUp,this));this.eventPopupDomNode.bind("mousedown",function(){return false;});this.eventPopupDomNode.bind('dblclick',function(){return false;});this.eventPopupDomNode.draggable();this.eventPopupDomNode.find("h1, .param-label, .param-value, .btn-container .btn").click(function(event){event.stopImmediatePropagation();});this.eventPopupDomNode.find("h1, .param-label, .param-value, .btn-container .btn").mousedown(function(event){event.stopImmediatePropagation();});this.eventPopupDomNode.find("h1, .param-label, .param-value, .btn-container .btn").dblclick(function(event){event.stopImmediatePropagation();});this.eventPopupDomNode.find("h1, .param-label, .param-value").enableSelection();this.parentFRM.domNode.append(this.eventPopupDomNode);}});"use strict";var EventLayerManager=EventManager.extend({init:function(requestDate,defaultEventTypes,viewportScale,rsun,savedEventLayers,urlEventLayers){this._eventLayers=[];this._events=[];this._eventMarkers=[];this._treeContainer=$("#eventJSTree");this._eventTypes={};this._jsTreeData=[];if(typeof date=='undefined'){var date=requestDate;}
this._date=date;this._requestDate=requestDate;this.defaultEventTypes=defaultEventTypes;this.viewportScale=viewportScale;$(document).bind("event-layer-finished-loading",$.proxy(this.updateMaxDimensions,this)).bind("save-event-layers",$.proxy(this.save,this)).bind("add-new-event-layer",$.proxy(this.addNewLayer,this)).bind("remove-event-layer",$.proxy(this._onLayerRemove,this));},save:function(){var eventLayers=this.toJSON();Helioviewer.userSettings.set("state.eventLayers",eventLayers);},_onLayerRemove:function(event,id){this.removeLayer(id);},getRequestDateAsISOString:function(){return this._requestDate.toISOString();}});"use strict";var HelioviewerEventLayer=Class.extend({init:function(index,date,viewportScale,name,markersVisible,labelsVisible){this.id="event-layer-"+new Date().getTime();$(document).trigger("create-event-layer-accordion-entry",[index,this.id,name,date,true,markersVisible,labelsVisible]);}});"use strict";var HelioviewerEventLayerManager=EventLayerManager.extend({init:function(requestDate,defaultEventTypes,viewportScale,rsun,savedEventLayers,urlEventLayers){this._super(requestDate,defaultEventTypes,viewportScale,rsun,savedEventLayers,urlEventLayers);this._loadStartingLayers(defaultEventTypes);},addNewLayer:function(){this.addEventLayer(new HelioviewerEventLayer(this._eventLayers.length,this._requestDate,this.viewportScale,'HEK',true,true));},_loadStartingLayers:function(layers){var eventLayer,basicParams,self=this;this.addEventLayer(new HelioviewerEventLayer(this._eventLayers.length,this._requestDate,this.viewportScale,'HEK',true,Helioviewer.userSettings.get("state.eventLabels")));},toURIString:function(){var str="";$.each(this._eventLayers,function(){str+=this.uri+",";});str=str.slice(0,-1);return str;}});"use strict";var TreeSelect=Class.extend({init:function(selectIds,tree,initialChoices,callback){this.selectIds=selectIds;this.tree=tree;this.height=selectIds.length;this.callback=callback;this.selected=initialChoices;this._initSelectMenus();this._setupEventHandlers();},_initSelectMenus:function(){var self=this;this._updateSelectMenus(0);$.each(this.selectIds,function(depth,id){$(id+" > option").each(function(index,option){if(option.value===self.selected[depth]){$(id).prop("selectedIndex",index);}});});},_updateSelected:function(depth,newChoice){var nav,selectField,i;this.selected[depth]=newChoice;selectField=function(original,arr){if(original in arr){return original;}
for(var item in arr){return item;}};nav="this.tree";for(i=0;i<this.height;i+=1){if(i>depth){this.selected[i]=selectField(this.selected[i],eval(nav));}
nav+='["'+this.selected[i]+'"]';}
this._updateSelectMenus(depth+1);},_updateSelectMenus:function(startDepth){var select,choice,i,nav,opt,self=this;$.each(this.selectIds,function(depth,id){if(depth>=startDepth){select=$(id);select.empty();nav="self.tree";for(i=0;i<depth;i+=1){nav+='["'+self.selected[i]+'"]';}
for(var choice in eval(nav)){opt=$("<option value='"+choice+"'>"+
choice.replace(/_/,"-")+"</option>");select.append(opt);}
choice=self.selected[depth];choice=choice.replace('.','\\.');select.find("option[value="+choice+"]").prop("selected",true);}});},_value:function(){var nav="this.tree";$.each(this.selected,function(i,choice){nav+='["'+choice+'"]';});return eval(nav);},_setupEventHandlers:function(){var self=this;$.each(this.selectIds,function(i,id){$(id).change(function(e){self._updateSelected(i,this.value);self.callback(self._value());});});}});"use strict";var ImageSelectTool=Class.extend({init:function(){this.active=false;this.vpDomNode=$("#helioviewer-viewport");this.buttons=$("#image-area-select-buttons");this.container=$("#image-area-select-container");this.doneButton=$("#done-selecting-image");this.cancelButton=$("#cancel-selecting-image");this.helpButton=$("#help-selecting-image");this.vpButtons=$("#zoomControls, #center-button, #social-buttons, #fullscreen-btn, #mouse-coords");this._setupHelpDialog();this.x1=null;this.x2=null;this.y1=null;this.y2=null;$(document).bind("enable-select-tool",$.proxy(this.enableAreaSelect,this));},enableAreaSelect:function(event,callback){var imgContainer,body=$("body");if(this.active){this.cleanup();}
else{body.addClass('disable-fullscreen-mode');this.active=true;this.width=this.vpDomNode.width();this.height=this.vpDomNode.height();this.container.show();imgContainer=body.append('<div id="imgContainer"></div>');this.selectArea(callback);}},selectArea:function(callback){var area,self=this;if(this.x1===null){this.x1=this.width/4;this.x2=this.width*3/4;this.y1=this.height/4;this.y2=this.height*3/4;}
area=this.container.imgAreaSelect({instance:true,handles:true,parent:"#imgContainer",x1:self.x1,x2:self.x2,y1:self.y1,y2:self.y2,onInit:function(){self.vpButtons.hide('fast');self.buttons.show();}});$(window).resize(function(){if(self.active){self.cancelButton.click();self.enableAreaSelect(0,callback);}});this.doneButton.click(function(){self.submitSelectedArea(area,callback);});$(document).keypress(function(e){if(e.which===13){self.submitSelectedArea(area,callback);}});this.cancelButton.click(function(){self.cleanup();});},submitSelectedArea:function(area,callback){var selection,visibleCoords,roi;if(area){selection=area.getSelection();this.x1=selection.x1;this.x2=selection.x2;this.y1=selection.y1;this.y2=selection.y2;visibleCoords=helioviewer.getViewportRegionOfInterest();roi={top:visibleCoords.top+selection.y1,left:visibleCoords.left+selection.x1,bottom:visibleCoords.top+selection.y2,right:visibleCoords.left+selection.x2};this.cleanup();callback(roi);}},_setupHelpDialog:function(){this.helpButton.qtip({position:{my:'top right',at:'bottom left'},content:{title:{text:"Help"},text:"Resize by dragging the edges of the selection.<br /> Move the selection by clicking inside "+"and dragging it.<br /> Click and drag outside the selected area to start "+"a new selection.<br /> Click \"OK\" when you have finished to submit."}});},cleanup:function(){this.buttons.hide();this.container.imgAreaSelect({remove:true});this.vpButtons.show('fast');this.container.hide();$('#imgContainer').remove();this.doneButton.unbind('click');this.cancelButton.unbind('click');this.helpButton.qtip("hide");this.active=false;$("body").removeClass('disable-fullscreen-mode');$(document).unbind('keypress').trigger('re-enable-keyboard-shortcuts');}});"use strict";var MediaManagerUI=Class.extend({init:function(type){this._type=type;this._btn=$("#"+type+"-button");this._container=$("#"+type+"-manager-container");this._buildBtns=$("#"+type+"-manager-build-btns");this._fullViewportBtn=$("#"+type+"-manager-full-viewport");this._selectAreaBtn=$("#"+type+"-manager-select-area");this._historyTitle=$("#"+type+"-history-title");this._historyBody=$("#"+type+"-history");this._clearBtn=$("#"+type+"-clear-history-button");this._tooltips=$("#social-buttons div");this._allButtons=$("#movie-button, #screenshot-button");this._allContainers=$(".media-manager-container");this._loadSavedItems();},has:function(id){return this._manager.has(id);},hide:function(){this._container.hide();this._btn.removeClass("active");this._tooltips.qtip("enable");$(".qtip").qtip("hide");},show:function(){this._allContainers.hide();this._allButtons.removeClass("active");this._btn.addClass("active");$(".jGrowl-notification").trigger("jGrowl.close");this._refresh();this._container.show();this._tooltips.qtip("hide").qtip("disable",true);},toggle:function(){if(this._container.is(":visible")){this.hide();}else{this.show();}},_addItem:function(item){var htmlId,html,last,url,name=item.name;htmlId=this._type+"-"+item.id;if(this._type==="movie"){url=Helioviewer.api.replace("api/index.php","")+"?movieId="+item.id;}else{url=Helioviewer.api+"?action=downloadScreenshot&id="+item.id;}
html=$("<div id='"+htmlId+"' class='history-entry'>"+"<a class='text-btn' style='float: left' href='"+url+"'>"+name+"</a>"+"<div class='status'></div>"+"</div>");html.data("id",item.id);this._historyBody.prepend(html);this._buildPreviewTooltip(item);if(this._historyBody.find(".history-entry").length>this._manager._historyLimit){last=this._historyBody.find(".history-entry").last().data('id');this._removeItem(last);}
this._historyTitle.show();},_buildPreviewTooltip:function(item){var self=this;$("#"+this._type+"-"+item.id).qtip({content:{title:{text:item.name},text:self._buildPreviewTooltipHTML(item)},position:{adjust:{x:-10,y:-1},my:"right top",at:"left center"},show:{delay:140}});},_removeItem:function(id){$("#"+this._type+"-"+id).qtip("destroy").unbind().remove();if(this._historyBody.find(".history-entry").length===0){this._historyTitle.hide();}},_loadSavedItems:function(){var self=this;$.each(this._manager.toArray().reverse(),function(i,item){self._addItem(item);});},_refresh:function(){var type=this._type;this._historyBody.find(".qtip").qtip('reposition');$.each(this._manager.toArray(),function(i,item){var status,elapsed;status=$("#"+type+"-"+item.id).find(".status");elapsed=Date.parseUTCDate(item.dateRequested).getElapsedTime();status.html(elapsed);});},_toArcsecCoords:function(pixels,scale){var coordinates={x1:pixels.left,x2:pixels.right,y1:pixels.top,y2:pixels.bottom};return pixelsToArcseconds(coordinates,scale);},_initEvents:function(){var self=this;this._btn.click(function(){if(!self.working){self.toggle();}});this._clearBtn.click(function(){$.each(self._manager.toArray(),function(i,item){self._removeItem(item.id);});self._manager.empty();});},_validateRequest:function(roi,layers){var message;if(roi.bottom-roi.top<50||roi.right-roi.left<50){message="The area you have selected is too small to create a "+
this._type+". Please try again.";$(document).trigger("message-console-warn",[message]);return false;}else if(layers.length===0){message="You must have at least one layer in your "+this._type+". Please try again.";$(document).trigger("message-console-warn",[message]);return false;}
return true;}});"use strict";var MediaManager=Class.extend({init:function(savedItems){this._history=savedItems;if($.support.localStorage){this._historyLimit=20;}else{this._historyLimit=5;}},_getName:function(layerString){var layer,layerArray,observatory,instrument,detector,measurement,currentGroup,name="";layerArray=layerStringToLayerArray(layerString).sort();$.each(layerArray,function(i,layer){layer=extractLayerName(this);if(layer.length==1){name+=', data source '+layer[i];return true;}
else if(layer.length==0){return false}
observatory=layer[0];instrument=layer[1];detector=layer[2];measurement=layer[3];if(currentGroup===instrument||currentGroup===detector){name+="/";}else{if(instrument==="SECCHI"){currentGroup=detector;name+=", "+detector+"-"+
observatory.substr(-1)+" ";}else{currentGroup=instrument;name+=", "+instrument+" ";}}
if(instrument==="LASCO"){name+=detector;}else if(detector.substr(0,3)==="COR"){}else{name+=measurement;}});return name.slice(2);},add:function(item){if(this._history.unshift(item)>this._historyLimit){this._history=this._history.slice(0,this._historyLimit);}
this._save();},get:function(id){var index=null;$.each(this._history,function(i,item){if(item.id===id){index=i;}});return this._history[index];},empty:function(){var self=this;$.each(this._history,function(i,item){self._history[i]=null;});self._history=[];self._save();},has:function(id){var exists=false;$.each(this._history,function(i,item){if(item.id===id){exists=true;}});return exists;},remove:function(id){var self=this;$.each(this._history,function(i,item){if(item.id===id){self._history[i]=null;self._history.splice(i,1);self._save();return;}});},toArray:function(){return $.extend([],this._history);}});"use strict";var MovieManager=MediaManager.extend({init:function(movies){this._super(movies);this.format=$.support.vp8?"webm":"mp4";var self=this;$.each(movies,function(i,movie){if(movie.status<2){self._monitorQueuedMovie(movie.id,Date.parseUTCDate(movie.dateRequested),0);}});},add:function(id,duration,imageScale,layers,events,eventsLabels,scale,scaleType,scaleX,scaleY,dateRequested,startDate,endDate,frameRate,numFrames,x1,x2,y1,y2,width,height,thumbnail,url){var movie={"id":id,"duration":duration,"imageScale":imageScale,"layers":layers,"events":events,"eventsLabels":eventsLabels,"scale":scale,"scaleType":scaleType,"scaleX":scaleX,"scaleY":scaleY,"dateRequested":dateRequested,"startDate":startDate,"endDate":endDate,"frameRate":frameRate,"numFrames":numFrames,"x1":x1,"x2":x2,"y1":y1,"y2":y2,"width":width,"height":height,"ready":true,"name":this._getName(layers),"status":2,"thumbnail":thumbnail,"url":url};this._super(movie);return movie;},queue:function(id,eta,token,imageScale,layers,events,eventsLabels,scale,scaleType,scaleX,scaleY,dateRequested,startDate,endDate,x1,x2,y1,y2){var movie={"id":id,"imageScale":imageScale,"layers":layers,"events":events,"eventsLabels":eventsLabels,"scale":scale,"scaleType":scaleType,"scaleX":scaleX,"scaleY":scaleY,"dateRequested":dateRequested,"startDate":startDate,"endDate":endDate,"x1":x1,"x2":x2,"y1":y1,"y2":y2,"status":0,"token":token,"name":this._getName(layers)};if(this._history.unshift(movie)>this._historyLimit){this._history=this._history.slice(0,this._historyLimit);}
this._monitorQueuedMovie(id,Date.parseUTCDate(dateRequested),token,eta);this._save();return movie;},update:function(id,frameRate,numFrames,startDate,endDate,width,height,thumbnails,url){var movie=this.get(id);$.extend(movie,{"frameRate":frameRate,"numFrames":numFrames,"startDate":startDate,"endDate":endDate,"width":width,"height":height,"status":2,"thumbnail":thumbnails.small,"url":url});delete movie.token;this._save();$(document).trigger("movie-ready",[movie]);this._displayDownloadNotification(movie);},_displayDownloadNotification:function(movie){var jGrowlOpts,message,self=this;jGrowlOpts={sticky:true,header:"Just now",open:function(msg){msg.find(".message-console-movie-ready").data("movie",movie);}};message="<span class='message-console-movie-ready'>"+"Your "+movie.name+" movie is ready! "+"Click here to watch or download it.</span>";$(document).trigger("message-console-log",[message,jGrowlOpts,true,true]);},_monitorQueuedMovie:function(id,dateRequested,token,eta)
{var queryMovieStatus,self=this;queryMovieStatus=function(){var params,callback;callback=function(response){if(!self.has(id)){return;}
if(response.status<2){if((Date.now()-dateRequested)/1000>(24*60*60)){self._abort(id);}
self._monitorQueuedMovie(id,dateRequested,token,60);}else if(response.error){self._abort(id);}else{self.update(id,response.frameRate,response.numFrames,response.startDate,response.endDate,response.width,response.height,response.thumbnails,response.url);}};params={"action":"getMovieStatus","id":id,"token":token,"format":self.format};$.get(Helioviewer.api,params,callback,Helioviewer.dataType);};setTimeout(queryMovieStatus,Math.max(eta,5)*1000);},_abort:function(id){var error,movie=this.get(id);movie["status"]=3;this._save();error="Sorry, we were unable to create the movie you requested. "+"This usually means that there are not enough images for the "+"time range requested. Please try adjusting the observation "+"date or movie duration and try creating a new movie.";$(document).trigger("message-console-error",[error,{"sticky":true}]);},_save:function(){Helioviewer.userSettings.set("history.movies",this._history);}});"use strict";var MovieManagerUI=MediaManagerUI.extend({init:function(movieManager){var movies=Helioviewer.userSettings.get('history.movies');this._manager=new MovieManager(movies);this._super("movie");this._settingsDialog=$("#movie-settings-container");this._advancedSettings=$("#movie-settings-advanced");this._settingsHelp=$("#movie-settings-help");this._settingsForm=$("#movie-settings-form-container");this._settingsConsole=$("#movie-settings-validation-console");this._movieScale=null;this._movieROI=null;this._movieLayers=null;this._movieEvents=null;this._movieEventsLabels=null;this._initEvents();this._initSettings();},playMovie:function(id){var movie=this._manager.get(id);if(movie.status===2){this._createMoviePlayerDialog(movie);}else{return;}},_buildMovieRequest:function(serializedFormParams){var formParams,baseParams,params,frameRate;formParams={};$.each(serializedFormParams,function(i,field){formParams[field.name]=field.value;});this.building=true;if(Helioviewer.userSettings.get("state.eventLayerVisible")===false){this._movieEvents='';this._movieEventsLabels=false;}
baseParams={action:"queueMovie",imageScale:this._movieScale,layers:this._movieLayers,events:this._movieEvents,eventsLabels:this._movieEventsLabels,scale:Helioviewer.userSettings.get("state.scale"),scaleType:Helioviewer.userSettings.get("state.scaleType"),scaleX:Helioviewer.userSettings.get("state.scaleX"),scaleY:Helioviewer.userSettings.get("state.scaleY"),format:this._manager.format};params=$.extend(baseParams,this._movieROI,this._getMovieTimeWindow());if(formParams['speed-method']==="framerate"){frameRate=parseInt(formParams['framerate'],10);if(frameRate<1||frameRate>30){throw"Frame-rate must be between 1 and 30.";}
baseParams['frameRate']=formParams['framerate'];}
else{if(formParams['movie-length']<5||formParams['movie-length']>100){throw"Movie length must be between 5 and 100 seconds.";}
baseParams['movieLength']=formParams['movie-length'];}
this._queueMovie(params);this._advancedSettings.hide();this._settingsDialog.hide();this.building=false;},_getMovieTimeWindow:function(){var movieLength,currentTime,endTime,startTimeStr,endTimeStr,now,diff;movieLength=Helioviewer.userSettings.get("options.movies.duration");currentTime=helioviewer.getDate();endTime=helioviewer.getDate().addSeconds(movieLength/2);now=new Date();diff=endTime.getTime()-now.getTime();currentTime.addSeconds(Math.min(0,-diff/1000));return{"startTime":currentTime.addSeconds(-movieLength/2).toISOString(),"endTime":currentTime.addSeconds(movieLength).toISOString()};},_showMovieSettings:function(roi){if(typeof roi==="undefined"){roi=helioviewer.getViewportRegionOfInterest();}
var layers=helioviewer.getVisibleLayers(roi);var events=helioviewer.getEvents();if(!this._validateRequest(roi,layers)){return;}
this._movieScale=helioviewer.getImageScale();this._movieROI=this._toArcsecCoords(roi,this._movieScale);this._movieLayers=layers;this._movieEvents=events;this._movieEventsLabels=helioviewer.getEventsLabels();this.hide();this._settingsConsole.hide();this._settingsDialog.show();},_queueMovie:function(params){var callback,self=this;callback=function(response){var msg,movie,waitTime;if((response===null)||response.error){if(response.errno===40){msg=response.error;}else{msg="We are unable to create a movie for the time you "+"requested. Please select a different time range "+"and try again.";}
$(document).trigger("message-console-info",msg);return;}else if(response.warning){$(document).trigger("message-console-info",response.warning);return;}
movie=self._manager.queue(response.id,response.eta,response.token,params.imageScale,params.layers,params.events,params.eventsLabels,params.scale,params.scaleType,params.scaleX,params.scaleY,new Date().toISOString(),params.startTime,params.endTime,params.x1,params.x2,params.y1,params.y2);self._addItem(movie);waitTime=humanReadableNumSeconds(response.eta);msg="Your video is processing and will be available in "+"approximately "+waitTime+". You may view it at any "+"time after it is ready by clicking the 'Movie' button";$(document).trigger("message-console-info",msg);};$.get(Helioviewer.api,params,callback,Helioviewer.dataType);},_initEvents:function(){var timer,self=this;this._super();this._fullViewportBtn.click(function(){self.hide();self._showMovieSettings();});this._selectAreaBtn.click(function(){self.hide();$(document).trigger("enable-select-tool",$.proxy(self._showMovieSettings,self));});$("#movie-history .history-entry").live('click',$.proxy(this._onMovieClick,this)).live('mouseover mouseout',$.proxy(this._onMovieHover,this));$(".message-console-movie-ready").live('click',function(event){var movie=$(event.currentTarget).data('movie');self._createMoviePlayerDialog(movie);});$(document).bind("movie-ready",function(event,movie){$("#"+self._type+"-"+movie.id).qtip("destroy");self._buildPreviewTooltip(movie);});$("#youtube-video-info").submit(function(){self.submitVideoUploadForm();return false;});$("#movie-settings-toggle-advanced").click(function(){if(self._settingsHelp.is(":visible")){self._settingsHelp.hide();self._settingsForm.show();return;}
if(self._advancedSettings.is(":visible")){self._advancedSettings.animate({"height":0},function(){self._advancedSettings.hide();});}else{self._advancedSettings.css('height',0).show();self._advancedSettings.animate({"height":85},function(){});}});$("#movie-settings-toggle-help").click(function(){self._settingsForm.toggle();self._settingsHelp.toggle();});},_initSettings:function(){var length,lengthInput,duration,durationSelect,frameRateInput,settingsForm,self=this;frameRateInput=$("#frame-rate");lengthInput=$("#movie-length");durationSelect=$("#movie-duration");$("#speed-method-f").change(function(){lengthInput.attr("disabled",true);frameRateInput.attr("disabled",false);}).attr("checked","checked").change();$("#speed-method-l").change(function(){frameRateInput.attr("disabled",true);lengthInput.attr("disabled",false);});$("#movie-settings-cancel-btn").button().click(function(e){self._advancedSettings.hide();self._settingsDialog.hide();self.show();});settingsForm=$("#movie-settings-form");$("#movie-settings-submit-btn").button().click(function(e){try{self._buildMovieRequest(settingsForm.serializeArray());}catch(ex){self._settingsConsole.text(ex).fadeIn(1000,function(){setTimeout(function(){self._settingsConsole.text(ex).fadeOut(1000);},10000);});}
return false;});duration=Helioviewer.userSettings.get("options.movies.duration"),durationSelect.bind('change',function(e){Helioviewer.userSettings.set("options.movies.duration",parseInt(this.value,10));});frameRateInput.val(15);lengthInput.val(20);durationSelect.find("[value="+duration+"]").attr("selected","selected");},_onMovieClick:function(event){var id,movie,dialog,action;id=$(event.currentTarget).data('id');movie=this._manager.get(id);if(movie.status===2){dialog=$("movie-player-"+id);if(dialog.length>0){action=dialog.dialog('isOpen')?"close":"open";dialog.dialog(action);}else{this._createMoviePlayerDialog(movie);}}
return false;},_onMovieHover:function(event){if(event.type==='mouseover'){}else{}},_buildPreviewTooltipHTML:function(movie){var width,height,thumbnail,html="";if(movie.status===2){if(Helioviewer.api==="api/index.php"){thumbnail=movie.thumbnail.substr(movie.thumbnail.search("cache"));}else{thumbnail=movie.thumbnail;}
html+="<div style='text-align: center;'>"+"<img src='"+thumbnail+"' width='95%' alt='preview thumbnail' /></div>";width=movie.width;height=movie.height;}else{width=Math.round(movie.x2-movie.x1);height=Math.round(movie.y2-movie.y1);}
html+="<table class='preview-tooltip'>"+"<tr><td><b>Start:</b></td><td>"+movie.startDate+"</td></tr>"+"<tr><td><b>End:</b></td><td>"+movie.endDate+"</td></tr>"+"<tr><td><b>Scale:</b></td><td>"+movie.imageScale.toFixed(2)+" arcsec/px</td></tr>"+"<tr><td><b>Dimensions:</b></td><td>"+width+"x"+height+" px</td></tr>"+"</table>";return html;},_createMoviePlayerDialog:function(movie){var dimensions,title,uploadURL,flvURL,swfURL,html,dialog,screenshot,callback,self=this;dimensions=this.getVideoPlayerDimensions(movie.width,movie.height);html=self.getVideoPlayerHTML(movie,dimensions.width,dimensions.height);dialog=$("<div id='movie-player-"+movie.id+"' "+"class='movie-player-dialog'></div>").append(html);dialog.find(".video-download-icon").click(function(){if(typeof(_gaq)!="undefined"){_gaq.push(['_trackEvent','Movies','Download']);}});title=movie.name+" ("+movie.startDate+" - "+
movie.endDate+" UTC)";dialog.dialog({title:"Movie Player: "+title,width:((dimensions.width<575)?600:dimensions.width+25),height:dimensions.height+80,resizable:$.support.h264||$.support.vp8,close:function(){$(this).empty();},zIndex:9999,show:'fade'});$('#youtube-upload-'+movie.id).click(function(){self.showYouTubeUploadDialog(movie);return false;});$('#video-link-'+movie.id).click(function(){if(!($.support.h264||$.support.vp8)){$(".movie-player-dialog").dialog("close");}
helioviewer.displayMovieURL(movie.id);return false;});flvURL=Helioviewer.api+"/?action=downloadMovie&format=flv&id="+movie.id;swfURL=Helioviewer.root+"/lib/flowplayer/flowplayer-3.2.8.swf?config="+
encodeURIComponent("{'clip':{'url': '../../"+flvURL+"'}}");screenshot=movie.thumbnail.substr(0,movie.thumbnail.length-9)+"full.png";},showYouTubeUploadDialog:function(movie){var title,tags,url1,url2,description;title=movie.name+" ("+movie.startDate+" - "+
movie.endDate+" UTC)";tags=[];$.each(movie.layers.split("],["),function(i,layerStr){var parts=layerStr.replace(']',"").replace('[',"").split(",").slice(0,4);$.each(parts,function(i,item){if($.inArray(item,tags)===-1){tags.push(item);}});});url1=Helioviewer.root+"/?movieId="+movie.id;url2=Helioviewer.root+"/api/?action=downloadMovie&id="+movie.id+"&format=mp4&hq=true";description="This movie was produced by Helioviewer.org. See the "+"original at "+url1+" or download a high-quality "+"version from "+url2;$("#youtube-title").val(title);$("#youtube-tags").val(tags);$("#youtube-desc").val(description);$("#youtube-movie-id").val(movie.id);$(".movie-player-dialog").dialog("close");$("#upload-dialog").dialog({"title":"Upload video to YouTube","width":550,"height":440});},submitVideoUploadForm:function(event){var params,successMsg,uploadDialog,url,form,loader,callback,self=this;try{this._validateVideoUploadForm();}catch(ex){this._displayValidationErrorMsg(ex);return false;}
$("#upload-error-console").hide();form=$("#upload-form").hide();loader=$("#youtube-auth-loading-indicator").show();callback=function(auth){loader.hide();form.show();url=Helioviewer.api+"?"+$("#youtube-video-info").serialize();if(auth){$.get(url,{"action":"uploadMovieToYouTube"},function(response){if(response.error){self.hide();$(document).trigger("message-console-warn",[response.error]);}},"json");}else{window.open(url+"&action=getYouTubeAuth","_blank");}
$("#upload-dialog").dialog("close");return false;}
$.ajax({url:Helioviewer.api+"?action=checkYouTubeAuth",dataType:Helioviewer.dataType,success:callback});},_displayValidationErrorMsg:function(ex){var errorConsole=$("#upload-error-console");errorConsole.html("<b>Error:</b> "+ex).fadeIn(function(){window.setTimeout(function(){errorConsole.fadeOut();},15000);});},_validateVideoUploadForm:function(){var keywords=$("#youtube-tags").val(),keywordMinLength=2,keywordMaxLength=30;if($("#youtube-title").val().length===0){throw"Please specify a title for the movie.";}
if(keywords.length===0){throw"You must specifiy at least one tag for your video.";}
$.each(keywords.split(","),function(i,keyword){var len=$.trim(keyword).length;if(len>keywordMaxLength){throw"YouTube tags must not be longer than "+
keywordMaxLength+" characters each.";}else if(len<keywordMinLength){throw"YouTube tags must be at least "+keywordMinLength+" characters each.";}
return;});$.each($("#youtube-video-info input[type='text'], "+"#youtube-video-info textarea"),function(i,input){if($(input).val().match(/[<>]/)){throw"< and > characters are not allowed";}
return;});},addMovieUsingId:function(id){var callback,params,movie,self=this;callback=function(response){if(response.status===2){movie=self._manager.add(id,response.duration,response.imageScale,response.layers,response.events,response.eventsLabels,response.scale,response.scaleType,response.scaleX,response.scaleY,response.timestamp.replace(" ","T")+".000Z",response.startDate,response.endDate,response.frameRate,response.numFrames,response.x1,response.x2,response.y1,response.y2,response.width,response.height,response.thumbnails.small,response.url);self._addItem(movie);self._createMoviePlayerDialog(movie);}};params={"action":"getMovieStatus","id":id,"format":self._manager.format,"verbose":true};$.get(Helioviewer.api,params,callback,Helioviewer.dataType);},getVideoPlayerDimensions:function(width,height){var maxWidth=$(window).width()*0.80,maxHeight=$(window).height()*0.80,scaleFactor=Math.max(1,width/maxWidth,height/maxHeight);return{"width":Math.floor(width/scaleFactor),"height":Math.floor(height/scaleFactor)};},getVideoPlayerHTML:function(movie,width,height){var downloadURL,downloadLink,youtubeBtn,linkBtn,linkURL,tweetBtn,facebookBtn;downloadURL=Helioviewer.api+"?action=downloadMovie&id="+movie.id+"&format=mp4&hq=true";downloadLink="<div style='float:left;'><a target='_parent' href='"+downloadURL+"' title='Download high-quality video'>"+"<img style='width:93px; height:32px;' class='video-download-icon' "+"src='resources/images/download_93x32.png' /></a></div>";youtubeBtn='<div style="float:left;"><a id="youtube-upload-'+movie.id+'" href="#" '+'target="_blank"><img class="youtube-icon" '+'title="Upload video to YouTube" style="width:79px;height:32px;" '+'src="resources/images/youtube_79x32.png" /></a></div>';linkURL=helioviewer.serverSettings.rootURL+"/?movieId="+movie.id;linkBtn="<div style='float:left;'><a id='video-link-"+movie.id+"' href='"+linkURL+"' title='Get a link to the movie' "+"target='_blank'><img class='video-link-icon' "+"style='width:79px; height:32px;' "+"src='resources/images/link_79x32.png' /></a></div>";tweetBtn='<div style="float:right;"><a href="https://twitter.com/share" class="twitter-share-button" data-related="helioviewer" data-lang="en" data-size="medium" data-count="horizontal" data-url="http://'+document.domain+'/?movieId='+movie.id+'" data-text="Movie of the Sun created on Helioviewer.org:" data-hashtags="helioviewer" data-related="helioviewer">Tweet</a><script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></div>';facebookBtn='<div style="float:right;"><iframe src="//www.facebook.com/plugins/like.php?href='+encodeURIComponent('http://'+document.domain+'/?movieId='+movie.id)+'&amp;width=90&amp;height=21&amp;colorscheme=dark&amp;layout=button_count&amp;action=like&amp;show_faces=false&amp;send=false&amp;appId=6899099925" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:21px; width:90px;" allowTransparency="false"></iframe></div>';if($.support.vp8||$.support.h264){url=movie.url.substr(movie.url.search("cache"));return'<div><video id="movie-player-'+movie.id+'" src="'+url+'" controls preload autoplay'+' style="width:100%; height: 90%;"></video></div>'+'<div style="width:100%"><div style="float:left;" class="video-links">'+
youtubeBtn+linkBtn+downloadLink+'</div> <div style="float:right;">'+facebookBtn+
tweetBtn+'</div></div>';}
else{var url=Helioviewer.api+'?action=playMovie&id='+movie.id+'&width='+width+"&height="+height+'&format=flv';return'<div id="movie-player-'+movie.id+'">'+'<iframe src="'+url+'" width="'+width+'" height="'+height+'" marginheight="0" marginwidth="0" '+'scrolling="no" frameborder="0" style="width: 100%; margin-bottom: 2px;" />'+'</div>'+'<div style="width:100%;">'+'<div style="float:left;" class="video-links">'+
youtubeBtn+linkBtn+downloadLink+'</div>'+'<div style="float:right;">'+facebookBtn+tweetBtn+'</div>';}},_refresh:function(){var status,elapsedTime;$.each(this._manager.toArray(),function(i,item){status=$("#movie-"+item.id).find(".status");if(item.status===2){elapsedTime=Date.parseUTCDate(item.dateRequested).getElapsedTime();status.html(elapsedTime);}else if(item.status===3){status.html("<span style='color:LightCoral;'>Error</span>");}else{status.html("<span class='processing'>Processing</span>");}});},_validateRequest:function(roi,layerString){var layers,visibleLayers,message;layers=layerStringToLayerArray(layerString);visibleLayers=$.grep(layers,function(layer,i){var parts=layer.split(",");return(parts[4]==="1"&&parts[5]!=="0");});if(visibleLayers.length>3){message="Movies cannot have more than three layers. "+"Please hide/remove layers until there are no more "+"than three layers visible.";$(document).trigger("message-console-warn",[message]);return false;}
return this._super(roi,layerString);}});"use strict";var ScreenshotManager=MediaManager.extend({init:function(screenshots){this._super(screenshots);},add:function(id,imageScale,layers,dateRequested,date,x1,x2,y1,y2){var screenshot={"id":id,"imageScale":imageScale,"layers":layers,"dateRequested":dateRequested,"date":date,"x1":x1,"x2":x2,"y1":y1,"y2":y2,"name":this._getName(layers)};this._super(screenshot);return screenshot;},_save:function(){Helioviewer.userSettings.set("history.screenshots",this._history);}});"use strict";var ScreenshotManagerUI=MediaManagerUI.extend({init:function(){var screenshots=Helioviewer.userSettings.get('history.screenshots');this._manager=new ScreenshotManager(screenshots);this._super("screenshot");this._initEvents();},getScreenshotURL:function(){var roi,imageScale,layers,params;imageScale=helioviewer.getImageScale();roi=helioviewer.getViewportRegionOfInterest();layers=this._checkLayers(helioviewer.getLayers());if(!this._validateRequest(roi,layers)){return;}
params=$.extend({action:"takeScreenshot",imageScale:imageScale,layers:layers,date:helioviewer.getDate().toISOString(),display:true},this._toArcsecCoords(roi,imageScale));return Helioviewer.api+"?"+$.param(params);},_displayDownloadNotification:function(screenshot){var jGrowlOpts,body,self=this;jGrowlOpts={sticky:true,header:"Just now"};body="<a href='"+Helioviewer.api+"?action=downloadScreenshot&id="+
screenshot.id+"'>Your "+screenshot.name+" screenshot is ready! Click here to download. </a>";$(document).trigger("message-console-log",[body,jGrowlOpts,true,true]);},_initEvents:function(){var self=this;this._super();this._fullViewportBtn.click(function(){self.hide();self._takeScreenshot();});this._selectAreaBtn.click(function(){self.hide();$(document).trigger("enable-select-tool",$.proxy(self._takeScreenshot,self));});$("#screenshot-history .history-entry").live('click',$.proxy(this._onScreenshotClick,this));},_buildPreviewTooltipHTML:function(screenshot){var width,height,date,html;width=Math.round((screenshot.x2-screenshot.x1)/screenshot.imageScale);height=Math.round((screenshot.y2-screenshot.y1)/screenshot.imageScale);date=screenshot.date.substr(0,19).replace(/T/," ");html="<div style='text-align: center;'>"+"<img src='"+Helioviewer.api+"?action=downloadScreenshot&id="+screenshot.id+"' alt='preview thumbnail' class='screenshot-preview' /></div>"+"<table class='preview-tooltip'>"+"<tr><td><b>Date:</b></td><td>"+date+"</td></tr>"+"<tr><td><b>Scale:</b></td><td>"+
screenshot.imageScale.toFixed(2)+" arcsec/px</td></tr>"+"<tr><td><b>Dimensions:</b></td><td>"+width+"x"+height+" px</td></tr>"+"</table>";return html;},_onScreenshotClick:function(event){var id=$(event.currentTarget).data('id'),url=Helioviewer.api+"?action=downloadScreenshot&id="+id;window.open(url,'_parent');return false;},_takeScreenshot:function(roi){var params,dataType,imageScale,layers,events,eventLabels,scale,scaleType,scaleX,scaleY,screenshot,self=this;if(typeof roi==="undefined"){roi=helioviewer.getViewportRegionOfInterest();}
imageScale=helioviewer.getImageScale();layers=helioviewer.getVisibleLayers(roi);events=helioviewer.getEvents();if(Helioviewer.userSettings.get("state.eventLayerVisible")===false){events='';eventLabels=false;}
if(!this._validateRequest(roi,layers)){return;}
params=$.extend({action:"takeScreenshot",imageScale:imageScale,layers:layers,events:events,eventLabels:Helioviewer.userSettings.get("state.eventLabels"),scale:Helioviewer.userSettings.get("state.scale"),scaleType:Helioviewer.userSettings.get("state.scaleType"),scaleX:Helioviewer.userSettings.get("state.scaleX"),scaleY:Helioviewer.userSettings.get("state.scaleY"),date:helioviewer.getDate().toISOString(),display:false},this._toArcsecCoords(roi,imageScale));$.get(Helioviewer.api,params,function(response){if((response===null)||response.error){$(document).trigger("message-console-info","Unable to create screenshot. Please try again later.");return;}
screenshot=self._manager.add(response.id,params.imageScale,params.layers,new Date().toISOString(),params.date,params.x1,params.x2,params.y1,params.y2);self._addItem(screenshot);self._displayDownloadNotification(screenshot);},Helioviewer.dataType);}});"use strict";var TileLayerAccordion=Layer.extend({init:function(containerId,dataSources,observationDate){this.container=$(containerId);this._dataSources=dataSources;this._observationDate=observationDate;this._maximumTimeDiff=12*60*60*1000;this.options={};this._setupUI();this.domNode=$('#TileLayerAccordion-Container');this.domNode.dynaccordion({startClosed:true});$(document).bind("create-tile-layer-accordion-entry",$.proxy(this.addLayer,this)).bind("update-tile-layer-accordion-entry",$.proxy(this._updateAccordionEntry,this)).bind("observation-time-changed",$.proxy(this._onObservationTimeChange,this));this.container.delegate("span[title]",'mouseover',function(event){$(this).qtip({overwrite:false,show:{event:event.type,ready:true}},event);}).each(function(i){$.attr(this,'oldtitle',$.attr(this,'title'));this.removeAttribute('title');});},addLayer:function(event,index,id,name,observatory,instrument,detector,measurement,date,startOpened,opacity,visible,onOpacityChange){if(typeof(index)==="undefined"){index=1000;}
this._createAccordionEntry(index,id,name,visible,startOpened);this._initTreeSelect(id,observatory,instrument,detector,measurement);this._initOpacitySlider(id,opacity,onOpacityChange);this._setupEventHandlers(id);this._updateTimeStamp(id,date);},_createAccordionEntry:function(index,id,name,visible,startOpened){var visibilityBtn,removeBtn,hidden,head,body;hidden=(visible?"":" hidden");visibilityBtn="<span class='layerManagerBtn visible"+hidden+"' id='visibilityBtn-"+id+"' title='Toggle layer visibility'></span>";removeBtn="<span class='ui-icon ui-icon-closethick removeBtn' id='removeBtn-"+id+"' title='Remove layer'></span>";head="<div class='layer-Head ui-accordion-header ui-helper-reset ui-state-default ui-corner-all shadow'>"+"<span class=tile-accordion-header-left>"+name+"</span><span class=tile-accordion-header-right><span class=timestamp></span>"+"<span class=accordion-header-divider>|</span>"+visibilityBtn+removeBtn+"</span></div>";body=this._buildEntryBody(id);this.domNode.dynaccordion("addSection",{id:id,header:head,cell:body,index:index,open:startOpened});},_initTreeSelect:function(id,observatory,instrument,detector,measurement){var ids,selected,obs,inst,det,meas;obs="#observatory-select-"+id;inst="#instrument-select-"+id;det="#detector-select-"+id;meas="#measurement-select-"+id;ids=[obs,inst,det,meas];selected=[observatory,instrument,detector,measurement];this.selectMenus=new TreeSelect(ids,this._dataSources,selected,function(leaf){$(document).trigger("tile-layer-data-source-changed",[id,$(obs).prop("value"),$(inst).prop("value"),$(det).prop("value"),$(meas).prop("value"),leaf.sourceId,leaf.nickname,leaf.layeringOrder]);});},_initOpacitySlider:function(id,opacity,onOpacityChange){$("#opacity-slider-track-"+id).slider({value:opacity,min:0,max:100,slide:function(e,ui){if((ui.value%2)===0){onOpacityChange(ui.value);}},change:function(e,ui){onOpacityChange(ui.value);$(document).trigger("save-tile-layers");}});},_buildEntryBody:function(id){var opacitySlide,obs,inst,det,meas,jp2,info;opacitySlide="<div class='layer-select-label'>Opacity: </div>";opacitySlide+="<div class='opacity-slider-track' id='opacity-slider-track-"+id;opacitySlide+="' style='width: 120px; height: 8px;'>";opacitySlide+="</div>";obs="<div class=layer-select-label>Observatory: </div> ";obs+="<select name=observatory class=layer-select id='observatory-select-"+id+"'></select>";inst="<div class=layer-select-label>Instrument: </div> ";inst+="<select name=instrument class=layer-select id='instrument-select-"+id+"'></select>";det="<div class=layer-select-label>Detector: </div> ";det+="<select name=detector class=layer-select id='detector-select-"+id+"'></select>";meas="<div class=layer-select-label>Measurement: </div> ";meas+="<select name=measurement class=layer-select id='measurement-select-"+id+"'>";meas+="</select><br><br>";jp2="<span id='image-"+id+"-download-btn'"+" class='image-download-btn ui-icon ui-icon-image'"+" title='Download original grayscale JPEG 2000 image'></span>";info="<span id='image-"+id+"-info-btn'"+" class='image-info-dialog-btn ui-icon ui-icon-info'"+" title='Display image header'></span>";return(opacitySlide+obs+inst+det+meas+jp2+info);},_setupUI:function(){var title,addLayerBtn;title=$('<span class="section-header">Images</span>').css({'float':'left'});addLayerBtn=$('<a href=# class=dark>[Add]</a>').css({'margin-right':'14px'});this.container.append($('<div></div>').css('text-align','right').append(title).append(addLayerBtn));this.container.append($('<div id="TileLayerAccordion-Container"></div>'));addLayerBtn.click(function(){$(document).trigger("add-new-tile-layer");});},_setupEventHandlers:function(id){var toggleVisibility,opacityHandle,removeLayer,self=this,visibilityBtn=$("#visibilityBtn-"+id),removeBtn=$("#removeBtn-"+id);toggleVisibility=function(e){$(document).trigger("toggle-layer-visibility",[id]);$("#visibilityBtn-"+id).toggleClass('hidden');e.stopPropagation();};removeLayer=function(e){$(document).trigger("remove-tile-layer",[id]);self._removeTooltips(id);self.domNode.dynaccordion('removeSection',{id:id});$(document).trigger("save-tile-layers");e.stopPropagation();};opacityHandle=$("#"+id+" .ui-slider-handle")[0];assignTouchHandlers(opacityHandle);visibilityBtn.bind('click',this,toggleVisibility);removeBtn.bind('click',removeLayer);},_showImageInfoDialog:function(id,name,imageId){var params,dtype,self=this,dialog=$("#image-info-dialog-"+id);if(dialog.length!==0){if(!dialog.dialog("isOpen")){dialog.dialog("open");}
else{dialog.dialog("close");}
return;}
params={action:"getJP2Header",id:imageId};if(Helioviewer.dataType==="jsonp"){dtype="jsonp text xml";}else{dtype="xml";}
$.get(Helioviewer.api,params,function(response){self._buildImageInfoDialog(name,id,response);},dtype);},_buildImageInfoDialog:function(name,id,response){var dialog,sortBtn,tabs,html,tag,json;json=$.xml2json(response);dialog=$("<div id='image-info-dialog-"+id+"' class='image-info-dialog' />");html="<div class='image-info-dialog-menu'>"+"<a class='show-fits-tags-btn selected'>[FITS]</a>"+"<a class='show-helioviewer-tags-btn'>Helioviewer</a>"+"<span class='image-info-sort-btn'>Abc</span>"+"</div>";if(!json.helioviewer){json.helioviewer={};$.each(json.fits,function(key,value){if(key.substring(0,3)==="HV_"){json.helioviewer[key.slice(3)]=value;delete json.fits[key];}});}
html+="<div class='image-header-fits'>"+this._generateImageKeywordsSection(json.fits)+"</div>"+"<div class='image-header-helioviewer' style='display:none;'>"+
this._generateImageKeywordsSection(json.helioviewer)+"</div>";dialog.append(html).appendTo("body").dialog({autoOpen:true,title:"Image Information: "+name,minWidth:546,width:546,height:350,draggable:true,create:function(event,ui){var fitsBtn=dialog.find(".show-fits-tags-btn"),hvBtn=dialog.find(".show-helioviewer-tags-btn"),sortBtn=dialog.find(".image-info-sort-btn");fitsBtn.click(function(){fitsBtn.html("[FITS]");hvBtn.html("Helioviewer");dialog.find(".image-header-fits").show();dialog.find(".image-header-helioviewer").hide();});hvBtn.click(function(){fitsBtn.html("FITS");hvBtn.html("[Helioviewer]");dialog.find(".image-header-fits").hide();dialog.find(".image-header-helioviewer").show();});sortBtn.click(function(){var sorted=!$(this).hasClass("italic");$(this).toggleClass("italic");if(sorted){dialog.find(".unsorted").css('display','none');dialog.find(".sorted").css('display','block');}else{dialog.find(".sorted").css('display','none');dialog.find(".unsorted").css('display','block');}});}});},_generateImageKeywordsSection:function(list){var unsorted,sortFunction,sorted,tag,tags=[];unsorted="<div class='unsorted'>";$.each(list,function(key,value){tag="<span class='image-header-tag'>"+key+": </span>"+"<span class='image-header-value'>"+value+"</span>";tags.push(tag);unsorted+=tag+"<br>";});unsorted+="</div>";sortFunction=function(a,b){if(a.slice(31)<b.slice(31)){return-1;}else if(a.slice(31)>b.slice(31)){return 1;}
return 0;};sorted="<div class='sorted' style='display: none;'>";$.each(tags.sort(sortFunction),function(){sorted+=this+"<br>";});sorted+="</div>";return unsorted+sorted;},_removeTooltips:function(id){$("#"+id+" *[oldtitle]").qtip("destroy");},_onObservationTimeChange:function(event,requestDate){var actualDate,weight,domNode,self=this;this._observationDate=requestDate;$("#TileLayerAccordion-Container .timestamp").each(function(i,item){domNode=$(this);actualDate=new Date(getUTCTimestamp(domNode.text()));weight=self._getScaledTimeDifference(actualDate,requestDate);domNode.css("color",self._chooseTimeStampColor(weight,0,0,0));});},_updateAccordionEntry:function(event,id,name,opacity,date,imageId){var entry=$("#"+id),self=this;this._updateTimeStamp(id,date);entry.find(".tile-accordion-header-left").html(name);$("#image-info-dialog-"+id).remove();entry.find("#image-"+id+"-info-btn").unbind().bind('click',function(){self._showImageInfoDialog(id,name,imageId);});$("#image-"+id+"-download-btn").unbind().bind('click',function(){window.open(Helioviewer.api+"?action=getJP2Image&id="+imageId);return false;});},_updateTimeStamp:function(id,date){var weight=this._getScaledTimeDifference(date,this._observationDate);$("#"+id).find('.timestamp').html(date.toUTCDateString()+" "+date.toUTCTimeString()).css("color",this._chooseTimeStampColor(weight,0,0,0));},_getScaledTimeDifference:function(t1,t2){return Math.min(1,Math.abs(t1.getTime()-t2.getTime())/this._maximumTimeDiff);},_chooseTimeStampColor:function(w,rOffset,gOffset,bOffset){var r=Math.min(255,rOffset+parseInt(2*w*255,10)),g=Math.min(255,gOffset+parseInt(2*255*(1-w),10)),b=bOffset+0;return"rgb("+r+","+g+","+b+")";}});"use strict";var EventLayerAccordion=Layer.extend({init:function(containerId,eventTypes,date){this.container=$(containerId);this._eventTypes=eventTypes;this._date=date;this._maximumTimeDiff=12*60*60*1000;this.options={};this._setupUI();this.domNode=$('#EventLayerAccordion-Container');this.domNode.dynaccordion({startClosed:true});$(document).bind("create-event-layer-accordion-entry",$.proxy(this.addLayer,this)).bind("update-event-layer-accordion-entry",$.proxy(this._updateAccordionEntry,this)).bind("observation-time-changed",$.proxy(this._onObservationTimeChange,this));this.container.delegate("span[title]",'mouseover',function(event){$(this).qtip({overwrite:false,show:{event:event.type,ready:true}},event);}).each(function(i){$.attr(this,'oldtitle',$.attr(this,'title'));this.removeAttribute('title');});},addLayer:function(event,index,id,name,date,startOpened,markersVisible,labelsVisible){this._createAccordionEntry(index,id,name,markersVisible,labelsVisible,startOpened);this._setupEventHandlers(id);this._updateTimeStamp(id,date);},_createAccordionEntry:function(index,id,name,markersVisible,labelsVisible,startOpened){var visibilityBtn,labelsBtn,markersHidden,labelsHidden,head,body,self=this;markersHidden=(markersVisible?"":" hidden");labelsHidden=(labelsVisible?"":" hidden");visibilityBtn="<span class='layerManagerBtn visible"+markersHidden+"' id='visibilityBtn-"+id+"' title='Toggle visibility of event marker pins'></span>";labelsBtn="<span class='labelsBtn"+labelsHidden+"' id='labelsBtn-"+id+"' title='Toggle event labels'></span>";head="<div class='layer-Head ui-accordion-header ui-helper-reset ui-state-default ui-corner-all shadow'>"+"<span class=tile-accordion-header-left>"+name+"</span><span class=tile-accordion-header-right><span class='timestamp'></span>"+"<span class=accordion-header-divider>|</span>"+visibilityBtn+labelsBtn+"</span></div>";body='<div id="eventJSTree" style="margin-bottom: 5px;"></div>';body+='<div id="checkboxBtn-On-'+id+'" title="Toggle All Event Checkboxes On" style="display: inline-block; font-size: 10px; margin-right: 10px;"><div class="ui-icon ui-icon-circlesmall-plus" style="display: inline-block; vertical-align: middle; margin-bottom: 2px;"></div>check all</div>';body+='<div id="checkboxBtn-Off-'+id+'" title="Toggle All Event Checkboxes Off" style="display: inline-block; font-size: 10px;"><div class="ui-icon ui-icon-circlesmall-minus" style="display: inline-block; vertical-align: middle; margin-bottom: 2px;"></div>check none</div>';this.domNode.dynaccordion("addSection",{id:id,header:head,cell:body,index:index,open:startOpened});this.getEventGlossary();this.domNode.find("#checkboxBtn-"+id).click(function(){$(document).trigger("toggle-checkboxes");});this.domNode.find("#checkboxBtn-On-"+id).click(function(){$(document).trigger("toggle-checkboxes-to-state",['on']);});this.domNode.find("#checkboxBtn-Off-"+id).click(function(){$(document).trigger("toggle-checkboxes-to-state",['off']);});this.domNode.find("#labelsBtn-"+id).click(function(e){$(document).trigger("toggle-event-labels",[$("#labelsBtn-"+id)]);e.stopPropagation();});},getEventGlossary:function(){var params={"action":"getEventGlossary"};$.get("api/index.php",params,$.proxy(this._setEventGlossary,this),"json");},_setEventGlossary:function(response){this._eventManager=new EventManager(response,this._date);},_setupUI:function(){var title,addLayerBtn;title=$('<span class="section-header">Solar Features & Events</span>');this.container.append($('<div></div>').append(title));this.container.append($('<div id="EventLayerAccordion-Container"></div>'));},_setupEventHandlers:function(id){var toggleVisibility,opacityHandle,removeLayer,visState,self=this,visibilityBtn=$("#visibilityBtn-"+id);toggleVisibility=function(e){var domNode;domNode=$(document).find("#event-container");if(domNode.css('display')=='none'){domNode.show();Helioviewer.userSettings.set("state.eventLayerVisible",true);$("#visibilityBtn-"+id).removeClass('hidden');}
else{domNode.hide();Helioviewer.userSettings.set("state.eventLayerVisible",false);$("#visibilityBtn-"+id).addClass('hidden');}
e.stopPropagation();};visibilityBtn.bind('click',this,toggleVisibility);},_removeTooltips:function(id){$("#"+id+" *[oldtitle]").qtip("destroy");},_onObservationTimeChange:function(event,requestDate){var actualDate,weight,domNode,self=this;this._date=requestDate;this._eventManager.updateRequestTime();$("#EventLayerAccordion-Container .timestamp").each(function(i,item){domNode=$(this);domNode.html(self._date.toUTCDateString()+" "+self._date.toUTCTimeString()).css("color",self._chooseTimeStampColor(0,0,0,0));});},_updateAccordionEntry:function(event,id,name,opacity,date,imageId){var entry=$("#"+id),self=this;this._updateTimeStamp(id,date);entry.find(".tile-accordion-header-left").html(name);},_updateTimeStamp:function(id,date){var weight=this._getScaledTimeDifference(date,this._date);$("#"+id).find('.timestamp').html(date.toUTCDateString()+" "+date.toUTCTimeString()).css("color",this._chooseTimeStampColor(weight,0,0,0));},_getScaledTimeDifference:function(t1,t2){return Math.min(1,Math.abs(t1.getTime()-t2.getTime())/this._maximumTimeDiff);},_chooseTimeStampColor:function(w,rOffset,gOffset,bOffset){var r=Math.min(255,rOffset+parseInt(2*w*255,10)),g=Math.min(255,gOffset+parseInt(2*255*(1-w),10)),b=bOffset+0;return"rgb("+r+","+g+","+b+")";}});"use strict";var MessageConsole=Class.extend({init:function(){this._setupEventHandlers();this._defaults={"life":15000}},log:function(msg,options){options=$.extend(this._defaults,options);$("#message-console").jGrowl(msg,options);},info:function(msg,options){options=$.extend(this._defaults,options);$("#message-console").jGrowl(msg,options);},warn:function(msg,options){options=$.extend(this._defaults,options);$("#message-console").jGrowl(msg,options);},error:function(msg,options){options=$.extend(this._defaults,options);$("#message-console").jGrowl(msg,options);},_setupEventHandlers:function(){var events,self=this;events="message-console-log message-console-info message-console-warn message-console-error";$(document).bind(events,function(event,msg,options,showElapsedTime,easyClose){if(typeof options==="undefined"){options={};}
if(typeof showElapsedTime==="undefined"){showElapsedTime=false;}
if(typeof easyClose==="undefined"){easyClose=false;}
if(showElapsedTime){var id,header,headerText,i=1;options=$.extend(options,{beforeOpen:function(elem,message,opts){header=elem.find(".jGrowl-header");id=window.setInterval(function(){if(i===1){headerText="1 minute ago";}else if(i<60){headerText=i+" minutes ago";}else if(i<1440){headerText=parseInt(i/60,10)+" hours ago";}else{headerText="A long time ago...";}
header.text(headerText);i+=1;},60000);elem.data("timerId",id);},close:function(elem,message){window.clearInterval(elem.data("timerId"));}});}
if(easyClose){options=$.extend(options,{afterOpen:function(msg){msg.click(function(e){msg.trigger("jGrowl.close");});}});}
if(event.type==="message-console-log"){self.log(msg,options);}else if(event.type==="message-console-info"){self.info(msg,options);}else if(event.type==="message-console-warn"){self.warn(msg,options);}else if(event.type==="message-console-error"){self.error(msg,options);}});}});"use strict";var TimeControls=Class.extend({init:function(dateInput,timeInput,incrementSelect,backBtn,forwardBtn,urlDate){if(typeof urlDate==="undefined"){urlDate=false;}
this._setInitialDate(urlDate);this._timeIncrement=Helioviewer.userSettings.get("state.timeStep");this._timer;this._dateInput=$(dateInput);this._timeInput=$(timeInput);this._backBtn=$(backBtn);this._forwardBtn=$(forwardBtn);this._incrementSelect=$(incrementSelect);this._addTimeIncrements();this._updateInputFields();this._initDatePicker();this._initEventHandlers();},getDate:function(){return new Date(this._date.getTime());},getTimestamp:function(){return this._date.getTime();},getDateField:function(){return this._dateInput.val();},getTimeField:function(){return this._timeInput.val();},getTimeIncrement:function(){return this._timeIncrement;},goToPresent:function(){var dataType,callback,layers,date,mostRecent=new Date(0,0,0),self=this;callback=function(dataSources){layers=[];$(".tile-accordion-header-left").each(function(){layers.push($(this).html());});$.each(dataSources,function(observatory,instruments){$.each(instruments,function(inst,detectors){$.each(detectors,function(det,measurements){$.each(measurements,function(meas,properties){if($.inArray(this.nickname,layers)===-1){return true;}
date=Date.parseUTCDate(this.end);if(date>mostRecent){mostRecent=date;}});});});});self.setDate(mostRecent);};$.get(Helioviewer.api,{action:"getDataSources"},callback,Helioviewer.dataType);},setDate:function(date){this._date=date;this._onDateChange();},enableAutoRefresh:function(){this._timer=setInterval($.proxy(this.goToPresent,this),300000);},disableAutoRefresh:function(){clearInterval(this._timer);},_setInitialDate:function(urlDate){if(urlDate){this._date=urlDate;}else if(Helioviewer.userSettings.get("options.date")==="latest"){this._date=new Date(+new Date());}else{this._date=new Date(Helioviewer.userSettings.get("state.date"));}
Helioviewer.userSettings.set("state.date",this._date.getTime());},timePrevious:function(){this._addSeconds(-this._timeIncrement);},timeNext:function(){this._addSeconds(this._timeIncrement);},toISOString:function(){return this._date.toISOString();},_initEventHandlers:function(){this._backBtn.bind('click',$.proxy(this.timePrevious,this));this._forwardBtn.bind('click',$.proxy(this.timeNext,this));this._timeInput.bind('change',$.proxy(this._onTextFieldChange,this));this._dateInput.bind('change',$.proxy(this._onTextFieldChange,this));$("#timeNowBtn").click($.proxy(this.goToPresent,this));$(document).bind('timestep-backward',$.proxy(this.timePrevious,this)).bind('timestep-forward',$.proxy(this.timeNext,this));},_addSeconds:function(seconds){this._date.addSeconds(seconds);this._onDateChange();},_addTimeIncrements:function(){var timeSteps,select,opt;timeSteps=[{numSecs:1,txt:"1&nbsp;Sec"},{numSecs:60,txt:"1&nbsp;Min"},{numSecs:300,txt:"5&nbsp;Mins"},{numSecs:900,txt:"15&nbsp;Mins"},{numSecs:3600,txt:"1&nbsp;Hour"},{numSecs:21600,txt:"6&nbsp;Hours"},{numSecs:43200,txt:"12&nbsp;Hours"},{numSecs:86400,txt:"1&nbsp;Day"},{numSecs:604800,txt:"1&nbsp;Week"},{numSecs:2419200,txt:"28&nbsp;Days"},{numSecs:31556926,txt:"1&nbsp;Year"}];select=this._incrementSelect;$(timeSteps).each(function(i,timestep){opt=$("<option value='"+timestep.numSecs+"'>"+timestep.txt+"</option>");select.append(opt);});select.bind('change',$.proxy(this._onTimeIncrementChange,this)).find("[value = "+this._timeIncrement+"]").attr("selected","selected");},_initDatePicker:function(){var btnId,btn,self=this;this.cal=this._dateInput.datepicker({buttonImage:'resources/images/blackGlass/calendar_small.png',buttonImageOnly:true,buttonText:"Select a date.",changeYear:true,dateFormat:'yy/mm/dd',mandatory:true,showOn:'button',yearRange:'1990:'+String((new Date).getFullYear()),onSelect:function(dateStr){window.setTimeout(function(){self._onTextFieldChange();},500);}});btnId='#observation-controls .ui-datepicker-trigger';btn=$(btnId);btn.hover(function(){this.src="resources/images/blackGlass/calendar_small-hover.png";},function(){this.src="resources/images/blackGlass/calendar_small.png";}).attr("title","Select an observation date.").click(function(){btn.qtip("hide");});btn.qtip();},_onDateChange:function(){this._updateInputFields();Helioviewer.userSettings.set("state.date",this._date.getTime());$(document).trigger("observation-time-changed",[this._date]);},_onTextFieldChange:function(){if(this._validateDate()&&this._validateTime()){this.setDate(this._timeFieldsToDateObj());}
return false;},_onTimeIncrementChange:function(e){this._timeIncrement=parseInt(e.target.value,10);Helioviewer.userSettings.set("state.timeStep",this._timeIncrement);},_timeFieldsToDateObj:function(){return Date.parseUTCDate(this.getDateField()+" "+this.getTimeField());},_updateInputFields:function(){this._dateInput.val(this._date.toUTCDateString());this._timeInput.val(this._date.toUTCTimeString());},_validateDate:function(){var dateString=this.getDateField();if(dateString.match(/^\d{4}\/\d{2}\/\d{2}?/)&&(dateString.length===10)){return true;}else{$(document).trigger("message-console-warn",["Invalid date. Please enter a date of the form YYYY/MM/DD."]);return false;}},_validateTime:function(){var timeString=this.getTimeField();if(timeString.match(/^\d{2}:\d{2}:\d{2}?/)&&(timeString.length===8)){return true;}else{$(document).trigger("message-console-warn",["Invalid time. Please enter a time of the form HH:MM:SS."]);return false;}}});"use strict";var FullscreenControl=Class.extend({init:function(btnId,speed){this.btn=$(btnId);this.btn.append('<span class="ui-icon ui-icon-arrow-4-diag"></span>');this.btn.attr('title','Enable fullscreen mode.');this.icon=$(btnId).find('span.ui-icon');this.body=$('body');this.colmid=$('#colmid');this.colright=$('#colright');this.col1pad=$('#col1pad');this.col2=$('#col2');this.viewport=$('#helioviewer-viewport-container-outer');this.shadow=$('#helioviewer-viewport-container-shadow');this.sandbox=$('#sandbox');this.header=$('#header');this.footer=$('#footer');this.meta=$('#footer-container-outer');this.panels=$('#col2, #col3, #header, #footer');this.sidebarWidth=280;this.marginSize=4;this.disabled_col1padMarginLeft=2*(this.sidebarWidth+this.marginSize);this.disabled_col1padMarginRight=0;this.disabled_col1padMarginTop=0;this.disabled_colRightMarginLeft=-2*(this.sidebarWidth+this.marginSize);this.disabled_col2Left=this.sidebarWidth+this.marginSize+2;this.disabled_colMidLeft=this.sidebarWidth+this.marginSize;this.enabled_colMidLeft=0;this.enabled_colMidRight=0;this.enabled_col2Left=-(this.sidebarWidth+this.marginSize+2)-this.sidebarWidth;this.enabled_colrightMarginLeft=0;this.static_headerHeight=this.header.height();this.static_footerHeight=this.footer.height();this._overrideAnimate();this._setupEventHandlers();},isEnabled:function(){if($('#morescreen-btn > span.ui-icon').hasClass('ui-icon-arrowstop-1-w')){this._fullscreenMode=false;}
return this._fullscreenMode;},enableFullscreenMode:function(animated){this.body.css({'overflow':'hidden','min-width':450});this.meta.hide();if(animated){this._expandAnimated();}else{this._expand();}},_expandAnimated:function(){var self=this,moreScreenBtn;this.colmid.animate({left:this.enabled_colMidLeft+'px',right:this.enabled_colMidRight+'px'},this.speed,function(){$(document).trigger('update-viewport');self.shadow.css({'width':self.viewport.width(),'height':self.viewport.height(),'top':self.marginSize,'left':self.marginSize});self.panels.hide();self.body.removeClass('disable-fullscreen-mode');});this.colright.animate({'margin-left':this.enabled_colrightMarginLeft+'px'},this.speed);this.col1pad.animate({'margin-left':this.marginSize,'margin-right':this.marginSize,'margin-top':this.marginSize},this.speed);this.col2.animate({'left':this.enabled_col2Left+'px'},this.speed);this.header.animate({'height':0},this.speed);this.viewport.animate({'height':$(window).height()-(3*this.marginSize)},this.speed);this.sandbox.animate({'right':0.1},this.speed);this.btn.attr('title','Disable fullscreen mode.');moreScreenBtn=$('#morescreen-btn > span.ui-icon');if(moreScreenBtn.length==1){$('#morescreen-btn > span.ui-icon').removeClass('ui-icon-arrowstop-1-w').addClass('ui-icon-arrowstop-1-e');$('#morescreen-btn').attr('title','Show left sidebar.');}},_expand:function(){var moreScreenBtn;this.colmid.css({'left':this.enabled_colMidLeft+'px','right':this.enabled_colMidRight+'px'});this.col1pad.css({'margin-left':this.marginSize,'margin-right':this.marginSize,'margin-top':this.marginSize});this.col2.css({'left':this.enabled_col2Left+'px'});this.header.height(0);this.viewport.css({'height':$(window).height()-(3*this.marginSize)});this.sandbox.css({'right':0.1});$(document).trigger('update-viewport');this.shadow.css({'width':this.viewport.width(),'height':this.viewport.height(),'top':this.marginSize,'left':this.marginSize});this.panels.hide();this.body.removeClass('disable-fullscreen-mode');this.btn.attr('title','Disable fullscreen mode.');moreScreenBtn=$('#morescreen-btn > span.ui-icon');if(moreScreenBtn.length==1){$('#morescreen-btn > span.ui-icon').removeClass('ui-icon-arrowstop-1-w').addClass('ui-icon-arrowstop-1-e');$('#morescreen-btn').attr('title','Show left sidebar.');}},disableFullscreenMode:function(){var offset,self=this,viewportHeight=$(window).height()-this.static_headerHeight-this.static_footerHeight-2,moreScreenBtn;this.shadow.hide();this.panels.show();this.colmid.animate({'left':this.disabled_colMidLeft+'px'},this.speed,function(){self.meta.show();self.body.css({'overflow':'visible',}).removeClass('disable-fullscreen-mode');});this.colright.animate({'margin-left':this.disabled_colRightMarginLeft+'px'},this.speed);this.col1pad.animate({'margin-left':this.disabled_col1padMarginLeft+'px','margin-right':this.disabled_col1padMarginRight+'px','margin-top':this.disabled_col1padMarginTop+'px'},this.speed);this.col2.animate({'left':this.disabled_col2Left+'px'},this.speed);this.header.animate({'height':this.static_headerHeight+'px'},this.speed);this.viewport.animate({'height':viewportHeight+'px'},this.speed);this.sandbox.animate({'right':0},this.speed,function(){offset=self.viewport.offset();self.shadow.css({'width':self.viewport.width(),'height':self.viewport.height(),'top':offset.top,'left':offset.left}).show();});this.body.animate({'min-width':'972px'},this.speed);this.btn.attr('title','Enable fullscreen mode.');moreScreenBtn=$('#morescreen-btn > span.ui-icon');if(moreScreenBtn.length==1){$('#morescreen-btn > span.ui-icon').removeClass('ui-icon-arrowstop-1-w').addClass('ui-icon-arrowstop-1-e');$('#morescreen-btn').attr('title','Hide right sidebar.');}},_setupEventHandlers:function(){this.btn.click($.proxy(this._toggle,this));$(document).bind('toggle-fullscreen',$.proxy(this._toggle,this));},_toggle:function(animated){if(this.body.hasClass('disable-fullscreen-mode')){return;}
if(typeof(animated)=='undefined'){animated=true;}
this.body.addClass('disable-fullscreen-mode');if(this.isEnabled()){this.disableFullscreenMode();this.viewport.removeClass('fullscreen-mode');}
else{this.enableFullscreenMode(animated);this.viewport.addClass('fullscreen-mode');}
this._fullscreenMode=!this._fullscreenMode;$(document).trigger('viewport-resized');},_overrideAnimate:function(){var doc=$(document),$_fx_step_default=$.fx.step._default;$.fx.step._default=function(fx){if(fx.elem.id!=='sandbox'){return $_fx_step_default(fx);}
doc.trigger('update-viewport');fx.elem.updated=true;};}});"use strict";var MorescreenControl=Class.extend({init:function(btnId,speed){this.btn=$(btnId);this.btn.append('<span class="ui-icon ui-icon-arrowstop-1-e"></span>');this.btn.attr('title','Hide right sidebar.');this.icon=$(btnId).find('span.ui-icon');this.body=$('body');this.colmid=$('#colmid');this.colright=$('#colright');this.col1pad=$('#col1pad');this.col2=$('#col2');this.col3=$('#col3');this.viewport=$('#helioviewer-viewport-container-outer');this.shadow=$('#helioviewer-viewport-container-shadow');this.sandbox=$('#sandbox');this.header=$('#header');this.footer=$('#footer');this.meta=$('#footer-container-outer');this.panels=$("#col2, #header, #footer");this.sidebarWidth=280;this.marginSize=4;this.disabled_col1padMarginLeft=2*(this.sidebarWidth+this.marginSize);this.disabled_colRightMarginLeft=-this.disabled_col1padMarginLeft;this.disabled_col2Left=this.sidebarWidth+this.marginSize+2;this.enabled_col1padMarginLeft=2*(this.sidebarWidth+this.marginSize);this.enabled_col1padMarginRight=-this.sidebarWidth;this.enabled_col2Left=this.sidebarWidth+this.marginSize+2;this.enabled_colrightMarginLeft=-2*(this.sidebarWidth+this.marginSize);this.static_colMidLeft=this.sidebarWidth+this.marginSize;this.static_headerHeight=this.header.height();this.static_footerHeight=this.footer.height();this._overrideAnimate();this._setupEventHandlers();},isEnabled:function(){if(this.icon.hasClass('ui-icon-arrowstop-1-w')){return true;}
return false;},enableMorescreenMode:function(animated){this.body.css({'overflow':'hidden','min-width':450});if(animated){this._expandAnimated();}else{this._expand();}},_expandAnimated:function(){var self=this,fullScreenBtn;this.col3.hide();this.shadow.hide();this.colmid.animate({left:this.static_colMidLeft+'px',right:0},this.speed,function(){var offset;$(document).trigger('update-viewport');self.col2.show();self.col2.animate({"left":self.enabled_col2Left+'px'});offset=self.viewport.offset();self.shadow.css({"width":self.viewport.width(),"height":self.viewport.height(),"top":offset.top,"left":offset.left}).show();self.body.removeClass('disable-morescreen-mode');});this.col1pad.animate({"margin-left":this.enabled_col1padMarginLeft+"px","margin-right":this.enabled_col1padMarginRight+"px"},this.speed);this.colright.animate({"margin-left":this.enabled_colrightMarginLeft+"px"},this.speed);this.sandbox.animate({"right":0.1},this.speed);this.icon.removeClass('ui-icon-arrowstop-1-e').addClass('ui-icon-arrowstop-1-w');this.btn.attr('title','Show right sidebar.');fullScreenBtn=$('#fullscreen-btn > span.ui-icon');if(fullScreenBtn.length==1){$('#fullscreen-btn').attr('title','Enable fullscreen mode.');}},_expand:function(){var offset,fullScreenBtn;this.col2.css({"left":this.enabled_col2Left+'px'});this.col2.show();this.col3.hide();this.shadow.hide();this.colmid.css({"left":this.static_colMidLeft+'px',"right":0});this.col1pad.css({"margin-left":this.enabled_col1padMarginLeft+"px","margin-right":this.enabled_col1padMarginRight+"px"});this.colright.css({"margin-left":this.enabled_colrightMarginLeft+"px"});this.sandbox.css({"right":0.1});$(document).trigger('update-viewport');offset=this.viewport.offset();this.shadow.css({"width":this.viewport.width(),"height":this.viewport.height(),"top":offset.top,"left":offset.left}).show();this.body.removeClass('disable-morescreen-mode');this.icon.removeClass('ui-icon-arrowstop-1-e').addClass('ui-icon-arrowstop-1-w');this.btn.attr('title','Show right sidebar.');fullScreenBtn=$('#fullscreen-btn > span.ui-icon');if(fullScreenBtn.length==1){$('#fullscreen-btn').attr('title','Enable fullscreen mode.');}},disableMorescreenMode:function(){var offset,self=this,viewportHeight=$(window).height()-this.static_headerHeight-this.static_footerHeight-2,fullScreenBtn;this.shadow.hide();this.colmid.animate({"left":this.static_colMidLeft+'px'},this.speed,function(){self.panels.show();self.meta.show();self.col3.show();self.body.css({"overflow":"visible",}).removeClass('disable-morescreen-mode');});this.colright.animate({"margin-left":this.disabled_colRightMarginLeft+'px'},this.speed);this.col1pad.animate({"margin-left":this.disabled_col1padMarginLeft+'px',"margin-right":0,"margin-top":0},this.speed);this.col2.animate({"left":this.disabled_col2Left+'px'},this.speed);this.header.animate({"height":this.static_headerHeight+'px'},this.speed);this.viewport.animate({"height":viewportHeight},this.speed);this.sandbox.animate({"right":0},this.speed,function(){offset=self.viewport.offset();self.shadow.css({"width":self.viewport.width(),"height":self.viewport.height(),"top":offset.top,"left":offset.left}).show();});this.body.animate({"min-width":"972px"},this.speed);this.icon.removeClass('ui-icon-arrowstop-1-w').addClass('ui-icon-arrowstop-1-e');this.btn.attr('title','Hide right sidebar.');fullScreenBtn=$('#fullscreen-btn > span.ui-icon');if(fullScreenBtn.length==1){$('#fullscreen-btn').attr('title','Enable fullscreen mode.');}},_setupEventHandlers:function(){this.btn.click($.proxy(this._toggle,this));$(document).bind('toggle-morescreen',$.proxy(this._toggle,this));},_toggle:function(animated){if(this.body.hasClass('disable-morescreen-mode')){return;}
if(typeof(animated)=="undefined"){animated=true;}
this.body.addClass('disable-morescreen-mode');if(this.isEnabled()){this.disableMorescreenMode();this.viewport.removeClass("morescreen-mode");}else{this.enableMorescreenMode(animated);this.viewport.addClass("morescreen-mode");}},_overrideAnimate:function(){var doc=$(document),$_fx_step_default=$.fx.step._default;$.fx.step._default=function(fx){if(fx.elem.id!=="sandbox"){return $_fx_step_default(fx);}
doc.trigger('update-viewport');fx.elem.updated=true;};}});"use strict";var HelioviewerWebClient=HelioviewerClient.extend({init:function(urlSettings,serverSettings,zoomLevels){var urlDate,imageScale,paddingHeight;this._super(urlSettings,serverSettings,zoomLevels);if(urlSettings.debug){this._showDebugHelpers();}
this._initLoadingIndicator();this._initTooltips();imageScale=this._chooseInitialImageScale(Helioviewer.userSettings.get('state.imageScale'),zoomLevels);urlDate=urlSettings.date?Date.parseUTCDate(urlSettings.date):false;this.timeControls=new TimeControls('#date','#time','#timestep-select','#timeBackBtn','#timeForwardBtn',urlDate);this._initViewport(this.timeControls.getDate(),$("#header").height()+1,$("#footer").height()+1);this.messageConsole=new MessageConsole();this.keyboard=new KeyboardManager();this.zoomControls=new ZoomControls('#zoomControls',imageScale,zoomLevels,this.serverSettings.minImageScale,this.serverSettings.maxImageScale);this.earthScale=new ImageScale();this.fullScreenMode=new FullscreenControl("#fullscreen-btn",500);this.moreScreenMode=new MorescreenControl("#morescreen-btn",500);this.displayBlogFeed(3,false);this._userVideos=new UserVideoGallery(this.serverSettings.videoFeed);this.imageSelectTool=new ImageSelectTool();this._screenshotManagerUI=new ScreenshotManagerUI();this._movieManagerUI=new MovieManagerUI();this._glossary=new VisualGlossary(this._setupDialog);this._setupDialogs();this._initEventHandlers();this._setupSettingsUI();this._displayGreeting();},_initLoadingIndicator:function(){$(document).ajaxStart(function(){$('#loading').show();}).ajaxStop(function(){$('#loading').hide();});},_initTooltips:function(){$.fn.qtip.defaults=$.extend(true,{},$.fn.qtip.defaults,{show:{delay:1000},style:{classes:'ui-tooltip-light ui-tooltip-shadow ui-tooltip-rounded'}});$("*[title]:not(.qtip-left)").qtip();$(".qtip-left").qtip({position:{my:"top right",at:"bottom middle"}});$(".qtip-topleft").qtip({position:{my:"bottom right",at:"top middle"}});},_initViewport:function(date,marginTop,marginBottom){var shadow,updateShadow,self=this;$(document).bind("datasources-initialized",function(e,dataSources){var tileLayerAccordion=new TileLayerAccordion('#tileLayerAccordion',dataSources,date);});$(document).bind("event-types-initialized",function(e,eventTypes,date){var eventLayerAccordion=new EventLayerAccordion('#eventLayerAccordion',eventTypes,date);});this._super("#helioviewer-viewport-container-outer",date,marginTop,marginBottom);shadow=$('#helioviewer-viewport-container-shadow');if($.browser.msie){shadow.css("box-shadow","none");return;}
shadow.show();updateShadow=function(){shadow.width(self.viewport.outerNode.width()).height(self.viewport.outerNode.height());};updateShadow();$(document).bind("viewport-resized",updateShadow);},loadMovie:function(movieId){if(!this._movieManagerUI.has(movieId)){this._movieManagerUI.addMovieUsingId(movieId);}else{this._movieManagerUI.playMovie(movieId);}},_setupDialogs:function(){var self=this;this._setupDialog("#helioviewer-about","#about-dialog",{"title":"Helioviewer - About","height":400});this._setupDialog("#helioviewer-usage","#usage-dialog",{"title":"Helioviewer - Usage Tips"});this._setupDialog("#settings-button","#settings-dialog",{"buttons":{"Ok":function(){$(this).dialog("close");}},"title":"Helioviewer - Settings","width":400,"height":'auto',"resizable":false,"create":function(e){}});},_setupDialog:function(btn,dialog,options,onLoad){var defaults={title:"Helioviewer.org",autoOpen:true,draggable:true,width:480,height:400};$(btn).click(function(){var d=$(dialog),btn=$(this);if(btn.hasClass("dialog-loaded")){if(d.dialog('isOpen')){d.dialog('close');}
else{d.dialog('open');}}else{d.load(this.href,onLoad).dialog($.extend(defaults,options));btn.addClass("dialog-loaded");}
return false;});},_showDebugHelpers:function(){var dimensions,win=$(window);dimensions=$("<div id='debug-dimensions'></div>").appendTo("body");win.resize(function(e){dimensions.html(win.width()+"x"+win.height());});},_setupSettingsUI:function(){var form,dateLatest,datePrevious,autorefresh,self=this;form=$("#helioviewer-settings");dateLatest=$("#settings-date-latest");datePrevious=$("#settings-date-previous");autorefresh=$("#settings-latest-image");if(Helioviewer.userSettings.get("options.date")==="latest"){dateLatest.attr("checked","checked");}else{datePrevious.attr("checked","checked");}
if(Helioviewer.userSettings.get("options.autorefresh")){autorefresh.attr("checked","checked");this.timeControls.enableAutoRefresh();}else{autorefresh.removeAttr("checked");this.timeControls.disableAutoRefresh();}
dateLatest.change(function(e){Helioviewer.userSettings.set("options.date","latest");});datePrevious.change(function(e){Helioviewer.userSettings.set("options.date","previous");});autorefresh.change(function(e){Helioviewer.userSettings.set("options.autorefresh",e.target.checked);if(e.target.checked){self.timeControls.enableAutoRefresh();}else{self.timeControls.disableAutoRefresh();}});},_initEventHandlers:function(){var self=this,msg="Use the following link to refer to current page:",btns;$('#link-button').click(function(e){if(typeof(_gaq)!=="undefined"){_gaq.push(['_trackEvent','Shares','Homepage - URL']);}
self.displayURL(self.toURL(),msg);});btns=$("#social-buttons .text-btn, "+"#movie-manager-container .text-btn, "+"#image-area-select-buttons > .text-btn, "+"#screenshot-manager-container .text-btn, "+"#event-container .text-btn");btns.live("mouseover",function(){$(this).find(".ui-icon").addClass("ui-icon-hover");});btns.live("mouseout",function(){$(this).find(".ui-icon").removeClass("ui-icon-hover");});$("#helioviewer-viewport, .ui-slider-handle").each(function(){assignTouchHandlers(this);});$("#helioviewer-url-shorten").click(function(e){var url;if(e.target.checked){url=$("#helioviewer-short-url").attr("value");}else{url=$("#helioviewer-long-url").attr("value");}
$("#helioviewer-url-input-box").attr('value',url).select();});},displayURL:function(url,msg){var callback=function(response){$("#helioviewer-long-url").attr("value",url);$("#helioviewer-short-url").attr("value",response.data.url);$("#helioviewer-url-box-msg").text(msg);$("#url-dialog").dialog({dialogClass:'helioviewer-modal-dialog',height:110,width:$('html').width()*0.7,modal:true,resizable:false,title:"URL",open:function(e){$("#helioviewer-url-shorten").removeAttr("checked");$('.ui-widget-overlay').hide().fadeIn();$("#helioviewer-url-input-box").attr('value',url).select();}});};$.ajax({url:Helioviewer.api,dataType:Helioviewer.dataType,data:{"action":"shortenURL","queryString":url.substr(this.serverSettings.rootURL.length+2)},success:callback});},displayMovieURL:function(movieId){var msg="Use the following link to refer to this movie:",url=this.serverSettings.rootURL+"/?movieId="+movieId;if(typeof(_gaq)!=="undefined"){_gaq.push(['_trackEvent','Shares','Movie - URL']);}
this.displayURL(url,msg);},displayMailForm:function(){var html,url=this.toURL();html='<div id="helioviewer-url-box">'+'Who would you like to send this page to?<br>'+'<form style="margin-top:15px;">'+'<label>From:</label>'+'<input type="email" <email address hidden>" class="email-input-field" '+'id="email-from" value="Your Email Address"></input><br>'+'<label>To:</label>'+'<input type="email" <email address hidden>" class="email-input-field" id="email-from" '+'value="Recipient\'s Email Address"></input>'+'<label style="float:none; margin-top: 10px;">Message: </label>'+'<textarea style="width: 370px; height: 270px; margin-top: 8px;">Check this out:\n\n'+url+'</textarea>'+'<span style="float: right; margin-top:8px;">'+'<input type="submit" value="Send"></input>'+'</span></form>'+'</div>';},displayBlogFeed:function(n,showDescription,descriptionWordLength){var url,dtype,html="";url=this.serverSettings.newsURL;if(Helioviewer.dataType==="jsonp"){dtype="jsonp text xml";}else{dtype="xml";}
$.getFeed({url:Helioviewer.api,data:{"action":"getNewsFeed"},dataType:dtype,success:function(feed){var link,date,more,description;if(!feed.items){$("#social-panel").append("Unable to retrieve news feed...");return;}
$.each(feed.items.slice(0,n),function(i,a){link="<a href='"+a.link+"' alt='"+a.title+"' target='_blank'>"+a.title+"</a><br />";date="<div class='article-date'>"+a.updated.slice(0,26)+"UTC</div>";html+="<div class='blog-entry'>"+link+date;if(showDescription){description=a.description;if(typeof descriptionWordLength==="number"){description=description.split(" ").slice(0,descriptionWordLength).join(" ")+" [...]";}
html+="<div class='article-desc'>"+description+"</div>";}
html+="</div>";});more="<div id='more-articles'><a href='"+url+"' title='The Helioviewer Project Blog'>Visit Blog...</a></div>";$("#social-panel").append(html+more);}});},launchJHelioviewer:function(){var endDate,params;endDate=new Date(Math.min(this.timeControls.getDate().addHours(12),new Date()));params={"action":"launchJHelioviewer","endTime":endDate.toISOString(),"startTime":endDate.addHours(-24).toISOString(),"imageScale":this.viewport.getImageScaleInKilometersPerPixel(),"layers":this.viewport.serialize()};window.open(Helioviewer.api+"?"+$.param(params),"_blank");},_displayGreeting:function(){if(!Helioviewer.userSettings.get("notifications.welcome")){return;}
$(document).trigger("message-console-info",["<b>Welcome to Helioviewer.org</b>, a solar data browser. First time here? Be sure to check out our "+"<a href=\"http://wiki.helioviewer.org/wiki/Helioviewer.org_User_Guide_2.4.0\" "+"class=\"message-console-link\" target=\"_blank\"> User Guide</a>.</br>",{sticky:true}]);Helioviewer.userSettings.set("notifications.welcome",false);},getDate:function(){return this.timeControls.getDate();},getLayers:function(){return this.viewport.serialize();},getEvents:function(){return this.viewport.serializeEvents();},getEventsLabels:function(){return Helioviewer.userSettings.get("state.eventLabels");},getVisibleLayers:function(roi){return this.viewport.getVisibleLayers(roi);},getImageScale:function(){return this.viewport.getImageScale();},getViewportRegionOfInterest:function(){return this.viewport.getRegionOfInterest();},toURL:function(shorten){var params={"date":this.viewport._tileLayerManager.getRequestDateAsISOString(),"imageScale":this.viewport.getImageScale(),"centerX":Helioviewer.userSettings.get("state.centerX"),"centerY":Helioviewer.userSettings.get("state.centerY"),"imageLayers":encodeURI(this.viewport.serialize()),"eventLayers":encodeURI(this.viewport.serializeEvents()),"eventLabels":Helioviewer.userSettings.get("state.eventLabels")};return this.serverSettings.rootURL+"/?"+decodeURIComponent($.param(params));},constants:{au:149597870700,rsun:695700000}});"use strict";var UserVideoGallery=Class.extend({init:function(url){this._container=$("#user-video-gallery-main");this._loader=$("#user-video-gallery-spinner");this._nextPageBtn=$("#user-video-gallery-next");this._prevPageBtn=$("#user-video-gallery-prev");this._working=false;this.url=url||Helioviewer.api;this._pageSize=this._choosePageSize();this._startIndex=0;this._numVideos=15;this._videos=[];this._setupEventHandlers();this._fetchVideos();var self=this;window.setInterval(function(){self._checkForNewMovies();},120000);},_updateGallery:function(){var endIndex=Math.min(this._startIndex+this._pageSize,this._videos.length);this._buildHTML(this._videos.slice(this._startIndex,endIndex));},_fetchVideos:function(){var params={"action":"getUserVideos","num":this._numVideos};this._container.find("a").empty();this._loader.show();this._working=true;$.get(this.url,params,$.proxy(this._processResponse,this),Helioviewer.dataType);},_checkForNewMovies:function(){var params={"action":"getUserVideos","num":this._numVideos};if(this._videos.length>0){params.since=this._videos[0].published.replace(" ","T")+".000Z";}
this._working=true;$.get(this.url,params,$.proxy(this._processResponse,this),Helioviewer.dataType);},_processResponse:function(response){var videos,error;if(response.error){error="<b>Error:</b> Did you specify a valid YouTube API key "+"in Config.ini?";$("#user-video-gallery-main").html(error);return;}
if(response.count){videos=response.value.items;}else{videos=response;}
this._videos=videos.concat(this._videos);this._updateGallery();},_buildHTML:function(videos){var html="";this._container.find("a, br").remove();$.each(videos,function(i,vid){var when=new Date.parseUTCDate(vid.published).getElapsedTime()+" ago",img=vid.thumbnails['small'];html+="<a target='_blank' href='"+vid.url+"' "+"alt='video thumbnail'>"+"<div class='user-video-thumbnail-container'>"+"<div style='text-align: left; margin-left: 25px;'>"+
when+"</div>"+"<img src='"+img+"' alt='user video thumbnail' />"+"</div></a><br />";});html=html.slice(0,-6);this._loader.hide();this._container.append(html);this._working=false;},_prevPage:function(){if(this._working){return false;}
if(this._startIndex+this._pageSize<this._videos.length){this._startIndex+=this._pageSize;this._updateGallery();}
return false;},_nextPage:function(){if(this._working){return false;}
if(this._startIndex>0){this._startIndex=Math.max(0,this._startIndex-this._pageSize);this._updateGallery();}
return false;},_choosePageSize:function(){var height=$(window).height();if(height>1035){return 3;}else if(height>780){return 2;}
return 1;},_onMouseWheelMove:function(e,delta){if(delta>0){this._nextPage();}else{this._prevPage();}
return false;},_onResize:function(e){var oldPageSize=this._pageSize;this._pageSize=this._choosePageSize();if(this._videos.length===0){return;}
if(this._pageSize!==oldPageSize){if(this._startIndex+this._pageSize>this._videos.length){this._startIndex=this._videos.length-this._pageSize;}
this._updateGallery();}},_onVideoHover:function(event){if(event.type==='mouseover'){$(this).find("img").addClass("video-glow");}else{$(this).find("img").removeClass("video-glow");}},_setupEventHandlers:function(){this._nextPageBtn.click($.proxy(this._nextPage,this));this._prevPageBtn.click($.proxy(this._prevPage,this));$(window).resize($.proxy(this._onResize,this));this._container.mousewheel($.proxy(this._onMouseWheelMove,this));}});"use strict";var VisualGlossary=Class.extend({init:function(setupDialog){setupDialog("#helioviewer-glossary","#glossary-dialog",{"title":"Helioviewer - Glossary","width":800,"height":$(document).height()*0.8},$.proxy(this._onLoad,this));},_onLoad:function(evt){var self=this;this.btns=$('#glossary-menu .text-btn');this.entries=$("#glossary-contents tr");$("#glossary-menu .text-btn").hover(function(){$(this).find(".ui-icon").addClass("ui-icon-hover");},function(){$(this).find(".ui-icon").removeClass("ui-icon-hover");});this.btns.click(function(e){self.btns.removeClass("selected");self.btns.find('.ui-icon').removeClass('ui-icon-bullet').addClass('ui-icon-radio-on');$(this).addClass("selected").find('.ui-icon').removeClass('ui-icon-radio-on').addClass('ui-icon-bullet');self._showCategory(this.id.split("-").pop());});this._showCategory("basic");},_showCategory:function(category){this.entries.hide();if(category==="all"){this.entries.show();}else{this.entries.filter(".g-"+category).show();}}});"use strict";(function($){$.widget("ui.dynaccordion",{options:{displayArrows:true,startClosed:true},init:function(){return this.element;},updateHeader:function(o){$(this.element).find('#'+o.id+' > .dynaccordion-tab').text(o.content);},updateCell:function(o){$(this.element).find('#'+o.id+' > .dynaccordion-cell').text(o.content);},removeSection:function(o){$(this.element).find('#'+o.id).remove();},addSection:function(o){var index,id,arrow,header,body,domNode,container,sections,self=this;id=o.id;container=$(this.element);sections=container.find(".dynaccordion-section");if(this.options.displayArrows){if(o.open){arrow="<div class='accordion-arrow ui-icon ui-icon-triangle-1-s'></div>";}
else{arrow="<div class='accordion-arrow ui-icon ui-icon-triangle-1-e'></div>";}}else{arrow="";}
header=$('<div class="dynaccordion-tab">'+arrow+o.header+'</div>');body=$('<div class="dynaccordion-cell ui-accordion-content ui-helper-reset ui-widget-content '+'ui-corner-bottom ui-corner-top shadow">'+o.cell+'</div>');domNode=$('<div class="dynaccordion-section" id="'+id+'"></div>').append(header).append(body);if((o.index!=="undefined")&&(o.index<sections.length)){$(container.find(".dynaccordion-section")[o.index]).before(domNode);}else{container.append(domNode);}
header.find(".layer-Head").hover(function(){$(this).addClass("ui-state-hover-bgonly");},function(){$(this).removeClass("ui-state-hover-bgonly");});$('#'+id+' > div.dynaccordion-tab').unbind().click(function(){if(self.options.displayArrows){var arrowIcon=$(this).find('.accordion-arrow')[0];$(arrowIcon).toggleClass('ui-icon-triangle-1-s');$(arrowIcon).toggleClass('ui-icon-triangle-1-e');}
$(this).next().slideToggle('fast');});if(this.options.startClosed&&(!o.open)){$('#'+id+' > div.dynaccordion-cell').hide();}}});}(jQuery));

alexsey (avizard2008) said : #2

{basicParams=self.dataSources[params.observatory][params.instrument][params.detector][params.measurement];$.extend(params,basicParams);layer=new HelioviewerTileLayer(index,self._observationDate,self.tileSize,self.viewportScale,self.tileVisibilityRange,params.observatory,params.instrument,params.detector,params.measurement,params.sourceId,params.nickname,params.visible,params.opacity,params.layeringOrder);self.addLayer(layer);});},_onViewportUpdated:function(){var numLayers=Helioviewer.userSettings.get("state.tileLayers").length;this._layersLoaded+=1;if(!this._finishedLoading&&this._layersLoaded===numLayers){$(document).trigger("load-saved-roi-position");}},_updateDataSource:function(event,id,observatory,instrument,detector,measurement,sourceId,name,layeringOrder){var opacity,layer;$.each(this._layers,function(){if(this.id===id){layer=this;}});layer.name=name;layer.layeringOrder=layeringOrder;layer.domNode.css("z-index",parseInt(layer.layeringOrder,10)-10);layer.image.updateDataSource(observatory,instrument,detector,measurement,sourceId);opacity=this._computeLayerStartingOpacity(layer.layeringOrder,true);$("#opacity-slider-track-"+id).slider("value",opacity);},checkDataSource:function(obs,inst,det,meas){if(this.dataSources[obs]!==undefined){if(this.dataSources[obs][inst]!==undefined){if(this.dataSources[obs][inst][det]!==undefined){if(this.dataSources[obs][inst][det][meas]!==undefined){return true;}}}}
return false;},toURIString:function(){var str="";$.each(this._layers,function(){str+=this.uri+",";});str=str.slice(0,-1);return str;}});"use strict";var JP2Image=Class.extend({init:function(observatory,instrument,detector,measurement,sourceId,date,onChange){this.observatory=observatory;this.instrument=instrument;this.detector=detector;this.measurement=measurement;this.sourceId=sourceId;this.requestDate=date;this._onChange=onChange;this._requestImage();},_requestImage:function(){var params,dataType;params={action:'getClosestImage',sourceId:this.sourceId,date:this.requestDate.toISOString()};$.get(Helioviewer.api,params,$.proxy(this._onImageLoad,this),Helioviewer.dataType);},updateDataSource:function(observatory,instrument,detector,measurement,sourceId){this.observatory=observatory;this.instrument=instrument;this.detector=detector;this.measurement=measurement;this.sourceId=sourceId;this._requestImage();},updateTime:function(requestDate){this.requestDate=requestDate;this._requestImage();},_onImageLoad:function(result){if(this.id===result.id){return;}
$.extend(this,result);this.offsetX=parseFloat((this.refPixelX-(this.width/2)).toPrecision(8));this.offsetY=-parseFloat((this.refPixelY-(this.height/2)).toPrecision(8));this._onChange();},getLayerName:function(){return this.observatory+","+this.instrument+","+
this.detector+","+this.measurement;},getSourceId:function(){return this.sourceId;}});"use strict";var MouseCoordinates=Class.extend({enabled:true,visible:false,init:function(imageScale,showMouseCoordsWarning){this.imageScale=imageScale;this.warnMouseCoords=showMouseCoordsWarning;this.viewportContainer=$('#helioviewer-viewport').parent();this.movingContainer=$("#moving-container");this.container=$('#mouse-coords');this.sandbox=$("#sandbox");this.mouseCoords="disabled";this.mouseCoordsX=$('#mouse-coords-x');this.mouseCoordsY=$('#mouse-coords-y');this._initEventHandlers();},_initEventHandlers:function(){$(document).bind('toggle-mouse-coords',$.proxy(this.toggleMouseCoords,this));},enable:function(){this.enabled=true;},disable:function(){this.enabled=false;},updateImageScale:function(imageScale){this.imageScale=imageScale;},getRelativeCoords:function(screenx,screeny){var offset=this.viewportContainer.offset();return{x:screenx-offset.left-1,y:screeny-offset.top-1};},toggleMouseCoords:function(){if(this.mouseCoords==="disabled"){this.mouseCoords="enabled";this.container.toggle();}
else{this.container.toggle();this.mouseCoords="disabled";}
this._checkWarning();this._reassignEventHandlers();},_reassignEventHandlers:function(){if(this.mouseCoords!=="disabled"){this.mouseCoordsX.empty();this.mouseCoordsY.empty();$(document).bind('mousemove',$.proxy(this.updateMouseCoords,this));}else{$(document).unbind('mousemove',this.updateMouseCoords);}},_checkWarning:function(){if(this.warnMouseCoords===true){var warning="<b>Note:</b> Mouse-coordinates should not be used "+"for science operations!";$(document).trigger("message-console-log",[warning,{life:30000}]);Helioviewer.userSettings.set("notifications.coordinates",false);this.warnMouseCoords=false;}},updateMouseCoords:function(event){var cartesian;if(!this.enabled){return;}
cartesian=this.computeMouseCoords(event.pageX,event.pageY);this.mouseCoordsX.html("x: "+cartesian.x+" &prime;&prime;");this.mouseCoordsY.html("y: "+cartesian.y+" &prime;&prime;");},computeMouseCoords:function(screenX,screenY){var VX,negSV,SV,SM,MX,scale,x,y;VX=this.getRelativeCoords(screenX,screenY);negSV=this.sandbox.position();SV={x:-negSV.left,y:-negSV.top};SM=this.movingContainer.position();MX={x:VX.x+(SV.x-SM.left),y:VX.y+(SV.y-SM.top)};scale=this.imageScale;x=Math.round((scale*MX.x));y=-Math.round((scale*MX.y));return{x:x,y:y};}});"use strict";var HelioviewerMouseCoordinates=MouseCoordinates.extend({init:function(imageScale,rsun,showMouseCoordsWarning){this.rsun=rsun;this._super(imageScale,showMouseCoordsWarning);},toggleMouseCoords:function(){if(this.mouseCoords==="disabled"){this.mouseCoords="arcseconds";this.container.toggle();}
else if(this.mouseCoords==="arcseconds"){this.mouseCoords="polar";}
else{this.container.toggle();this.mouseCoords="disabled";}
this._checkWarning();this._reassignEventHandlers();},_reassignEventHandlers:function(){if(this.mouseCoords!=="disabled"){this.mouseCoordsX.empty();this.mouseCoordsY.empty();if(this.mouseCoords==="polar"){this.movingContainer.unbind('mousemove',this.updateMouseCoords);}
this.movingContainer.bind('mousemove',$.proxy(this.updateMouseCoords,this));this.movingContainer.trigger("mousemove");}else{this.movingContainer.unbind('mousemove',this.updateMouseCoords);}},updateMouseCoords:function(event){var cartesian,polar,r,theta;if(!this.enabled){return;}
if(typeof(event.pageX)=="undefined"){if(this.mouseCoords==="arcseconds"){this.showCartesianCoordinates("--","--");}else{this.showPolarCoordinates("--","--");}
return;}
cartesian=this.computeMouseCoords(event.pageX,event.pageY);if(this.mouseCoords==="arcseconds"){this.showCartesianCoordinates(cartesian.x,cartesian.y);}else{polar=Math.toPolarCoords(cartesian.x,cartesian.y);r=((polar.r/this.rsun)+"").substring(0,5);theta=Math.round(polar.theta);this.showPolarCoordinates(r,theta);}},showCartesianCoordinates:function(x,y){this.mouseCoordsX.html("x: "+x+" &prime;&prime;");this.mouseCoordsY.html("y: "+y+" &prime;&prime;");},showPolarCoordinates:function(r,theta){this.mouseCoordsX.html(r+" R<span style='vertical-align: sub; font-size:10px;'>&#9737;</span>");this.mouseCoordsY.html(theta+" &#176;");}});"use strict";var SandboxHelper=Class.extend({init:function(x,y){this.domNode=$("#sandbox");this.movingContainer=$("#moving-container");this.domNode.css({"left":x,"top":y});},center:function(){var top,left;left=0.5*this.domNode.width();top=0.5*this.domNode.height();this.moveContainerTo(left,top);},getCenter:function(){return{x:0.5*this.domNode.width(),y:0.5*this.domNode.height()};},updateSandbox:function(viewportCenter,desiredSandboxSize){var change,oldCenter,newCenter,newHCLeft,newHCTop,containerPos;oldCenter=this.getCenter();this.domNode.css({width:desiredSandboxSize.width+'px',height:desiredSandboxSize.height+'px',left:viewportCenter.x-(0.5*desiredSandboxSize.width)+'px',top:viewportCenter.y-(0.5*desiredSandboxSize.height)+'px'});newCenter=this.getCenter();change={x:newCenter.x-oldCenter.x,y:newCenter.y-oldCenter.y};if(Math.abs(change.x)<0.01&&Math.abs(change.y)<0.01){return;}
containerPos=this.movingContainer.position();newHCLeft=Math.max(0,Math.min(desiredSandboxSize.width,containerPos.left+change.x));newHCTop=Math.max(0,Math.min(desiredSandboxSize.height,containerPos.top+change.y));this.moveContainerTo(newHCLeft,newHCTop);},moveContainerTo:function(x,y){this.movingContainer.css({left:x,top:y});}});"use strict";var ViewportMovementHelper=Class.extend({isMoving:false,maxLayerDimensions:{width:0,height:0},mouseStartingPosition:{x:0,y:0},moveCounter:0,imageUpdateThrottle:3,tileUpdateThrottle:9,init:function(domNode,mouseCoords,offsetX,offsetY){this.domNode=$(domNode);this.sandbox=$("#sandbox");this.movingContainer=$("#moving-container");this.mouseCoords=mouseCoords;var center=this._getCenter();this.sandboxHelper=new SandboxHelper(center.x,center.y);if($.browser.msie){this._cursorCSS="url('resources/cursors/grabbing.cur'), move";}else{this._cursorCSS='move';}},centerViewport:function(){this.sandboxHelper.center();},mouseDown:function(event){this.domNode.css("cursor",this._cursorCSS);if((this.sandbox.width()===0)&&(this.sandbox.height()===0)){return;}
this.mouseStartingPosition={x:event.pageX,y:event.pageY};this._startMoving();},mouseUp:function(event){this.domNode.css("cursor","");if(this.isMoving){this._endMoving();}},mouseMove:function(event){if(!this.isMoving){return;}
this.moveCounter=this.moveCounter+1;if((this.moveCounter%this.imageUpdateThrottle)!==0){return;}
this.moveCounter=this.moveCounter%this.tileUpdateThrottle;this._moveBy(this.mouseStartingPosition.x-event.pageX,this.mouseStartingPosition.y-event.pageY);},doubleClick:function(event){var pos,center,diff;pos=this.mouseCoords.getRelativeCoords(event.pageX,event.pageY);center=this._getCenter();diff={x:(pos.x-center.x),y:(pos.y-center.y)};this._startMoving();this._moveBy(diff.x,diff.y);this._endMoving();},updateMaxLayerDimensions:function(maxDimensions){this.maxLayerDimensions=maxDimensions;this.update();},getMaxImageCoordinates:function(coordinates){var halfWidth,halfHeight,maxCoordinates;halfWidth=this.maxLayerDimensions.width/2;halfHeight=this.maxLayerDimensions.height/2;maxCoordinates={left:Math.max(coordinates.left,-halfWidth),top:Math.max(coordinates.top,-halfHeight),right:Math.min(coordinates.right,halfWidth),bottom:Math.min(coordinates.bottom,halfHeight)};return maxCoordinates;},update:function(){var center,newSize;center=this._getCenter();newSize=this._getDesiredSandboxDimensions();this.sandboxHelper.updateSandbox(center,newSize);},getViewportCoords:function(){var sb,mc,left,top,vpWidth,vpHeight;sb=this.sandbox.position();mc=this.movingContainer.position();left=-(sb.left+mc.left);top=-(sb.top+mc.top);vpWidth=this.domNode.width();vpHeight=this.domNode.height();if(vpWidth%2===1){vpWidth+=1;}
if(vpHeight%2===1){vpHeight+=1;}
return{left:left,top:top,right:vpWidth+left,bottom:vpHeight+top};},moveViewport:function(x,y){this._startMoving();this.moveCounter+=1;this.moveCounter=this.moveCounter%this.tileUpdateThrottle;this._moveBy(x,y);this._endMoving();},zoomTo:function(imageScale){var vpCoords,center,newScale,newCenter,newCoords;newScale=this.mouseCoords.imageScale/imageScale;this._scaleLayerDimensions(newScale);vpCoords=this.getViewportCoords();center={x:(vpCoords.right+vpCoords.left)/2,y:(vpCoords.bottom+vpCoords.top)/2};newCenter={x:center.x*newScale,y:center.y*newScale};this.update();newCoords=this._viewportCoordsToMovingContainerCoords(newCenter);this._moveTo(newCoords.x,newCoords.y);this.mouseCoords.updateImageScale(imageScale);},_viewportCoordsToMovingContainerCoords:function(newCenter){var sbCenter,mcCoords;sbCenter=this.sandboxHelper.getCenter();mcCoords={x:Math.max(Math.min(sbCenter.x-newCenter.x,this.sandbox.width()),0),y:Math.max(Math.min(sbCenter.y-newCenter.y,this.sandbox.height()),0)};return mcCoords;},_getDesiredSandboxDimensions:function(){var width,height;width=this.domNode.width();height=this.domNode.height();return{width:Math.max(0,this.maxLayerDimensions.width-width),height:Math.max(0,this.maxLayerDimensions.height-height)};},_getContainerPos:function(){var position=this.movingContainer.position();return{x:position.left,y:position.top};},_moveBy:function(x,y){var pos={x:Math.min(Math.max(this.startMovingPosition.x-x,0),this.sandbox.width()),y:Math.min(Math.max(this.startMovingPosition.y-y,0),this.sandbox.height())};this.sandboxHelper.moveContainerTo(pos.x,pos.y);},_moveTo:function(x,y){this.sandboxHelper.moveContainerTo(x,y);if(this.moveCounter===0){$(document).trigger("update-viewport",[true]);}},_startMoving:function(){this.isMoving=true;this.mouseCoords.disable();this.startMovingPosition=this._getContainerPos();},_endMoving:function(){this.isMoving=false;this.mouseCoords.enable();$(document).trigger("update-viewport",[true]);},_getCenter:function(){return{x:this.domNode.width()/2,y:this.domNode.height()/2};},_scaleLayerDimensions:function(scaleFactor){this.maxLayerDimensions.width*=scaleFactor;this.maxLayerDimensions.height*=scaleFactor;}});"use strict";var HelioviewerViewport=Class.extend({defaultOptions:{imageScale:1,tileSize:512,minHeight:450,prefetch:0},dimensions:{width:0,height:0},maxLayerDimensions:{width:0,height:0},maxTileLayers:6,init:function(options){$.extend(this,this.defaultOptions);$.extend(this,options);this._rsunInArcseconds=959.705;this.domNode=$(this.id);this.outerNode=$(this.container);this.mouseCoords=new HelioviewerMouseCoordinates(this.imageScale,this._rsunInArcseconds,this.warnMouseCoords);this.resize();var centerX=this.centerX/this.imageScale,centerY=this.centerY/this.imageScale;this.movementHelper=new ViewportMovementHelper(this.domNode,this.mouseCoords,centerX,centerY);this.loadDataSources();this.loadEventTypes();this._initEventHandlers();},loadDataSources:function(){var callback,dataType,tileLayerAccordion,self=this;callback=function(dataSources){self.dataSources=dataSources;$(document).trigger("datasources-initialized",[dataSources]);self._tileLayerManager=new HelioviewerTileLayerManager(self.requestDate,self.dataSources,self.tileSize,self.imageScale,self.maxTileLayers,self.tileLayers);$(document).trigger("update-viewport");};$.get(Helioviewer.api,{action:"getDataSources"},callback,Helioviewer.dataType);},loadEventTypes:function(){$(document).trigger("event-types-initialized",[this.eventTypes,this.requestDate]);this._eventLayerManager=new HelioviewerEventLayerManager(this.requestDate,this.eventTypes,this.imageScale,this.rsun,this.savedEventLayers,this.urlEventLayers);},getImageScale:function(){return parseFloat(this.imageScale.toPrecision(8));},resize:function(){var oldDimensions,width,height;oldDimensions=this.dimensions;height=Math.max(this.minHeight,$(window).height()-this._getPadHeight());this.outerNode.height(height);this.dimensions={width:this.domNode.width()+this.prefetch,height:this.domNode.height()+this.prefetch};$(document).trigger("viewport-resized");if(oldDimensions.width===0&&oldDimensions.height===0){return;}
if(!this._hasSameDimensions(this.dimensions,oldDimensions)){this.updateViewport();}},setImageScale:function(imageScale){this.imageScale=imageScale;},updateViewportRanges:function(coordinates){this._updateTileVisibilityRange(coordinates);if(typeof this._tileLayerManager!=="undefined"){this._tileLayerManager.adjustImageScale(this.imageScale);}},serialize:function(){return this._tileLayerManager.serialize();},serializeEvents:function(){return Helioviewer.userSettings.parseEventsURLString();},getVisibleLayers:function(roi){return this._tileLayerManager.getVisibleLayers(roi);},_getPadHeight:function(){if(this.domNode.hasClass("fullscreen-mode")){return 0;}
return this.marginTop+this.marginBottom;},_updateTileVisibilityRange:function(coordinates){if(typeof this._tileLayerManager!=="undefined"){this._tileLayerManager.updateTileVisibilityRange(coordinates);}},_hasSameDimensions:function(newDimensions,old){return(newDimensions.width===old.width)&&(newDimensions.height===old.height);},_initEventHandlers:function(){$(document).bind("image-scale-changed",$.proxy(this.zoomViewport,this)).bind("update-viewport",$.proxy(this.onUpdateViewport,this)).bind("load-saved-roi-position",$.proxy(this.loadROIPosition,this)).bind("move-viewport mousemove mouseup",$.proxy(this.onMouseMove,this)).bind("layer-max-dimensions-changed",$.proxy(this.updateMaxLayerDimensions,this)).bind("center-viewport",$.proxy(this.centerViewport,this));$(this.domNode).bind("mousedown",$.proxy(this.onMouseMove,this));this.domNode.dblclick($.proxy(this.doubleClick,this));$('#center-button').click($.proxy(this.centerViewport,this));$(window).resize($.proxy(this.resize,this));},onMouseMove:function(event,x,y){switch(event.type){case"mouseup":this.movementHelper.mouseUp(event);break;case"mousedown":this.movementHelper.mouseDown(event);break;case"mousemove":this.movementHelper.mouseMove(event);break;default:this.movementHelper.moveViewport(x,y);break;}},zoomViewport:function(event,imageScale){this.setImageScale(imageScale);this.movementHelper.zoomTo(imageScale);this.updateViewport();Helioviewer.userSettings.set("state.imageScale",imageScale);},onUpdateViewport:function(event,storeCoordinates){if(typeof storeCoordinates==="undefined"){storeCoordinates=false;}
this.updateViewport(storeCoordinates);},loadROIPosition:function(event){var sandbox,sbWidth,sbHeight,centerX,centerY;sandbox=$("#sandbox");sbWidth=sandbox.width();sbHeight=sandbox.height();centerX=Helioviewer.userSettings.get("state.centerX")/this.getImageScale();centerY=Helioviewer.userSettings.get("state.centerY")/this.getImageScale();$("#moving-container").css({"left":sbWidth-Math.max(0,Math.min(sbWidth,Math.round(sbWidth/2+centerX))),"top":sbHeight-Math.max(0,Math.min(sbHeight,Math.round(sbHeight/2+centerY)))});this.updateViewport();},updateViewport:function(storeCoordinates){var coordinates,imageScale,offsetX,offsetY;if(typeof storeCoordinates==="undefined"){storeCoordinates=false;}
this.movementHelper.update();coordinates=this.movementHelper.getViewportCoords();imageScale=this.getImageScale();offsetX=imageScale*((coordinates.left+coordinates.right)/2);offsetY=imageScale*((coordinates.top+coordinates.bottom)/2);if(storeCoordinates){Helioviewer.userSettings.set("state.centerX",offsetX);Helioviewer.userSettings.set("state.centerY",offsetY);}
this.updateViewportRanges(coordinates);},getRegionOfInterest:function(){return this.movementHelper.getViewportCoords();},centerViewport:function(){this.movementHelper.centerViewport();this.updateViewport();Helioviewer.userSettings.set("state.centerX",0);Helioviewer.userSettings.set("state.centerY",0);},setViewportCenter:function(x,y){this.movementHelper.moveViewport(x,y);},doubleClick:function(event){this.movementHelper.doubleClick(event);if(event.shiftKey){$("#zoomControlZoomOut").click();}else{$("#zoomControlZoomIn").click();}},updateMaxLayerDimensions:function(event,type,dimensions){this.movementHelper.updateMaxLayerDimensions(dimensions);},getViewportInformation:function(){return{coordinates:this.movementHelper.getViewportCoords(),imageScale:this.imageScale,layers:this.serialize(),time:this._tileLayerManager.getRequestDateAsISOString()};},getImageScaleInKilometersPerPixel:function(){}});"use strict";var Helioviewer={};var HelioviewerClient=Class.extend({init:function(urlSettings,serverSettings,zoomLevels){this._checkBrowser();this.serverSettings=serverSettings;Helioviewer.api=serverSettings['backEnd'];Helioviewer.dataType=serverSettings['backEnd']==="api/index.php"?"json":"jsonp";Helioviewer.userSettings=SettingsLoader.loadSettings(urlSettings,serverSettings);if(serverSettings['backEnd']==="api/index.php"){Helioviewer.root=serverSettings['rootURL'];}else{Helioviewer.root=Helioviewer.api.substr(0,Helioviewer.api.search("/api"));}},_checkBrowser:function(){$.extend($.support,{"localStorage":('localStorage'in window)&&window['localStorage']!==null,"nativeJSON":typeof(JSON)!=="undefined","video":!!document.createElement('video').canPlayType,"h264":false,"vp8":false});if($.support.video){var v=document.createElement("video");if(v.canPlayType('video/webm; codecs="vp8"')){$.support.vp8=false;}
if(v.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"')){$.support.h264=false;}}},_initViewport:function(container,date,marginTop,marginBottom){this.viewport=new HelioviewerViewport({id:'#helioviewer-viewport',container:container,requestDate:date,maxTileLayers:this.serverSettings.maxTileLayers,minImageScale:this.serverSettings.minImageScale,maxImageScale:this.serverSettings.maxImageScale,prefetch:this.serverSettings.prefetchSize,tileLayers:Helioviewer.userSettings.get('state.tileLayers'),eventLayers:Helioviewer.userSettings.get('state.eventLayers'),eventLabels:Helioviewer.userSettings.get('state.eventLabels'),imageScale:Helioviewer.userSettings.get('state.imageScale'),centerX:Helioviewer.userSettings.get('state.centerX'),centerY:Helioviewer.userSettings.get('state.centerY'),marginTop:marginTop,marginBottom:marginBottom,warnMouseCoords:Helioviewer.userSettings.get('notifications.coordinates')});},_chooseInitialImageScale:function(imageScale,increments){if($.inArray(imageScale,increments)!==-1){return imageScale;}
var diff,closestScale,bestMatch=Infinity;$.each(increments,function(i,scale){diff=Math.abs(scale-imageScale);if(diff<bestMatch){bestMatch=diff;closestScale=scale;}});Helioviewer.userSettings.set('state.imageScale',closestScale);return closestScale;}});"use strict";var ZoomControls=Class.extend({init:function(id,imageScale,increments,minImageScale,maxImageScale){this.id=id;this.imageScale=imageScale;this.increments=increments;this.minImageScale=minImageScale;this.maxImageScale=maxImageScale;this.zoomInBtn=$('#zoomControlZoomIn');this.zoomSlider=$('#zoomControlSlider');this.zoomOutBtn=$('#zoomControlZoomOut');this._initSlider();this._initEventHandlers();},_onSlide:function(v){this._setImageScale(v);},_setImageScale:function(v){$(document).trigger('image-scale-changed',[this.increments[v]]);$(document).trigger('replot-event-markers');$(document).trigger('earth-scale');},_initSlider:function(){var description,self=this;this.increments.reverse();this.zoomSlider.slider({slide:function(event,slider){self._onSlide(slider.value);},min:0,max:this.increments.length-1,orientation:'vertical',value:$.inArray(this.imageScale,this.increments)});description="Drag this handle up and down to zoom in and out of "+"the displayed image.";$("#zoomControlSlider > .ui-slider-handle").attr('title',description).qtip();},_onZoomInBtnClick:function(){var index=this.zoomSlider.slider("value")+1;if(this.increments[index]>=this.minImageScale){this.zoomSlider.slider("value",index);this._setImageScale(index);}},_onZoomOutBtnClick:function(){var index=this.zoomSlider.slider("value")-1;if(this.increments[index]<=this.maxImageScale){this.zoomSlider.slider("value",index);this._setImageScale(index);}},_onMouseWheelMove:function(e,delta){if(delta>0){this.zoomInBtn.click();}else{this.zoomOutBtn.click();}
return false;},_initEventHandlers:function(){this.zoomInBtn.click($.proxy(this._onZoomInBtnClick,this));this.zoomOutBtn.click($.proxy(this._onZoomOutBtnClick,this));$("#helioviewer-viewport").mousewheel($.proxy(this._onMouseWheelMove,this));$(document).bind("zoom-in",$.proxy(this._onZoomInBtnClick,this)).bind("zoom-out",$.proxy(this._onZoomOutBtnClick,this));}});"use strict";var ImageScale=Class.extend({init:function(){this._rsunInArcseconds=959.705;this._earthSunRadiusFraction=6367.5/695500.;this._initScale();this.display();},_initScale:function(){var earthURL='resources/images/earth.png';if($('#earth-container').length>0){$('#earth-container').remove();}
this._earthDiameterInPixels();this.scale_container=$('<div id="earth-container"></div>').appendTo("#helioviewer-viewport");this.scale_container.draggable();this.scale_container.css({'position':'absolute','bottom':'0','z-index':'999','width':'73px','height':'56px','background-color':'rgba(17,17,17,0.5)','border-top':'1px solid #333','border-right':'1px solid #333','box-shadow':'0px 0px 5px black','cursor':'move','display':'none'});this.scale_container.attr('title','Click and drag to re-position scale indicator.');$('<div style="position:relative; height:12px;"><div id="earth-button" class="minimize ui-icon ui-icon-arrow-1-sw" style="float: right; cursor:pointer;" title="Hide Scale Indicator"></div><div id="earthLabel" style="color: white; background-color: #333; text-align: center; font-size: 10px; padding: 2px 0 2px 2px;">Earth Scale</div></div>').appendTo("#earth-container");$('<div style="position:relative; width:72px; height:45px;"><img id="earthScale" src="resources/images/earth.png" style="width: '+this.earthDiameterInPixels+'px;height: '+this.earthDiameterInPixels+'px; position: absolute; left: '+(36-(this.earthDiameterInPixels/2))+'px; top: '+(23-(this.earthDiameterInPixels/2))+'px;" /></div>').appendTo("#earth-container");this.scale_button=this.scale_container.find('#earth-button');this.scale_image=this.scale_container.find('#earthScale');this.scale_label=this.scale_container.find('#earthLabel');$(document).bind("earth-scale",$.proxy(this.earthRescale,this));this.scale_container.bind("mousedown",function(){return false;});this.scale_container.bind('dblclick',function(){return false;});this.scale_container.bind('click',function(){return false;});this.scale_container.bind('drag',$.proxy(this.scaleContainerDrag,this));this.scale_container.bind('dragstop',$.proxy(this.scaleContainerDragStop,this));this.scale_button.bind('click',$.proxy(this.earthMinimize,this));},earthRescale:function(){this._earthDiameterInPixels();this.scale_image.css({'width':this.earthDiameterInPixels+'px','height':this.earthDiameterInPixels+'px','position':'absolute','left':(36-(this.earthDiameterInPixels/2))+'px','top':(23-(this.earthDiameterInPixels/2))+'px'});this.scaleContainerDragStop();},earthMinimize:function(event){Helioviewer.userSettings.set("state.scale",false);Helioviewer.userSettings.set("state.scaleType",'earth');Helioviewer.userSettings.set("state.scaleX",0);Helioviewer.userSettings.set("state.scaleY",0);this.scale_container.draggable({disabled:true});this.scale_image.hide();this.scale_label.hide();this.scale_button.attr('title','Show Scale Indicator');this.scale_container.css({'width':'10px','height':'10px','border':'1px solid #888','border-left':'0','border-bottom':'0'});this.scale_container.css({'position':'absolute','top':'auto','bottom':'0px','left':'0px'});this.scale_button.removeClass('minimize').addClass('maximize');this.scale_button.removeClass('ui-icon-arrow-1-sw').addClass('ui-icon-arrow-1-ne');this.scale_button.css({'margin':'-3px -3px 0 0'});this.scale_button.unbind();this.scale_button.bind('click',$.proxy(this.earthMaximize,this));},earthMaximize:function(){Helioviewer.userSettings.set("state.scale",true);Helioviewer.userSettings.set("state.scaleType",'earth');Helioviewer.userSettings.set("state.scaleX",0);Helioviewer.userSettings.set("state.scaleY",0);this.scale_container.draggable({disabled:false});this.scale_image.show();this.scale_label.show();this.scale_button.attr('title','Hide Scale Indicator');this.scale_container.css({'position':'absolute','top':'auto','bottom':'0px','left':'0px','width':'73px','height':'56px','border':'1px solid #333','border-left':'0','border-bottom':'0'});this.scale_button.removeClass('maximize').addClass('minimize');this.scale_button.removeClass('ui-icon-arrow-1-ne').addClass('ui-icon-arrow-1-sw');this.scale_button.css({'margin':'0'});this.scale_button.unbind();this.scale_button.bind('click',$.proxy(this.earthMinimize,this));},scaleContainerDrag:function(){this.scale_container.css({'border':'1px solid #888'});},scaleContainerDragTo:function(containerX,containerY){this.scale_container.css({'position':'absolute','top':containerY+'px','left':containerX+'px','border':'1px solid #888'});},scaleContainerDragStop:function(event){var coords;coords=new HelioviewerMouseCoordinates(Helioviewer.userSettings.get("state.imageScale"),959.705,false);coords=coords.computeMouseCoords(this.scale_container.offset().left,this.scale_container.offset().top)
if(this.scale_container.position().left<=0||this.scale_container.position().left+this.scale_container.width()>=this.scale_container.parent().width()||this.scale_container.position().top+this.scale_container.height()>=this.scale_container.parent().height()||this.scale_container.position().top<=0){this.earthMaximize();}
else{Helioviewer.userSettings.set("state.scale",true);Helioviewer.userSettings.set("state.scaleType",'earth');Helioviewer.userSettings.set("state.scaleX",coords.x);Helioviewer.userSettings.set("state.scaleY",coords.y);Helioviewer.userSettings.set("state.containerX",this.scale_container.position().left);Helioviewer.userSettings.set("state.containerY",this.scale_container.position().top);}},_earthDiameterInPixels:function(){this.imageScale=Helioviewer.userSettings.get("state.imageScale");this.earthDiameterInPixels=Math.round(2*this._earthSunRadiusFraction*(this._rsunInArcseconds/this.imageScale));},_getScaleSettings:function(){this.scale=Helioviewer.userSettings.get("state.scale");this.scaleType=Helioviewer.userSettings.get("state.scaleType");this.scaleX=Helioviewer.userSettings.get("state.scaleX");this.scaleY=Helioviewer.userSettings.get("state.scaleY");this.containerX=Helioviewer.userSettings.get("state.containerX");this.containerY=Helioviewer.userSettings.get("state.containerY");},display:function(){this._getScaleSettings();if(this.scale===false){this.earthMinimize();}
else{if(this.scaleX==0||this.scaleY==0){this.earthMaximize();}
else{this.scaleContainerDragTo(this.containerX,this.containerY);}}
$(this.scale_container).css({'display':'block'});}});"use strict";var InputValidator=Class.extend({init:function(){},checkDateString:function(value,opts){var t=Date.parseUTCDate(value);t=null;},checkInt:function(value,opts){var options={"min":-Infinity,"max":Infinity};$.extend(options,opts||{});if(isNaN(value)||value<options.min||value>options.max||(typeof value==="string"&&parseInt(value,10)!==value.toString())){throw"Unacceptable integer value specified.";}},checkFloat:function(value,opts){var options={"min":-Infinity,"max":Infinity};$.extend(options,opts||{});if(isNaN(value)||value<options.min||value>options.max){throw"Unacceptable float value specified.";}},checkTimestamp:function(value,opts){var options={"min":0,"max":Math.round(new Date().getTime()/1000)+(24*60*60)};$.extend(options,opts||{});if(value.toString().length>10){value=value/1000;}
if(isNaN(value)||value<options.min||value>options.max){throw"Unacceptable timestamp value specified.";}}});"use strict";var SettingsLoader=({loadSettings:function(urlSettings,serverSettings){var defaults=this._getDefaultSettings(serverSettings),constraints={"minImageScale":serverSettings.minImageScale,"maxImageScale":serverSettings.maxImageScale,"minMovieLength":300,"maxMovieLength":16934400};return new UserSettings(defaults,urlSettings,constraints);},_getDefaultSettings:function(serverSettings){var date=new Date(+new Date());return{options:{date:"latest",movies:{cadence:"auto",duration:86400,format:"mp4"},autorefresh:false},history:{movies:[],screenshots:[]},notifications:{coordinates:true,welcome:true},state:{centerX:0,centerY:0,date:date.getTime(),eventLayers:[],eventLabels:true,scale:true,scaleType:'earth',scaleX:0,scaleY:0,imageScale:serverSettings.defaultImageScale,tileLayers:[{observatory:'SDO',instrument:'AIA',detector:'AIA',measurement:'304',visible:true,opacity:100}],timeStep:86400},version:serverSettings.version};}});"use strict";var UserSettings=Class.extend({init:function(defaults,urlSettings,constraints){this._defaults=defaults;this._constraints=constraints;this._validator=new InputValidator();this._initStorage();this._processURLSettings(urlSettings);},get:function(key){try{return this._get(key);}catch(ex){var value=this._getDefault(key);this.set(key,value)
return value;}},_get:function(key){var lookup=key.split(".");if(lookup.length===1){return this.settings[key];}else if(lookup.length===2){return this.settings[lookup[0]][lookup[1]];}
return this.settings[lookup[0]][lookup[1]][lookup[2]];},_getDefault:function(key){var lookup=key.split(".");if(lookup.length===1){return this._defaults[key];}else if(lookup.length===2){return this._defaults[lookup[0]][lookup[1]];}
return this._defaults[lookup[0]][lookup[1]][lookup[2]];},set:function(key,value){try{this._validate(key,value);}catch(e){return;}
var lookup=key.split(".");if(lookup.length===1){this.settings[key]=value;}else if(lookup.length===2){this.settings[lookup[0]][lookup[1]]=value;}else{this.settings[lookup[0]][lookup[1]][lookup[2]]=value;}
this._save();},_save:function(){if($.support.localStorage){localStorage.setItem("settings",$.toJSON(this.settings));}
else{this.cookies.set("settings",this.settings);}},_empty:function(){if($.support.localStorage){localStorage.removeItem("settings");}else{$.cookieJar("empty");}},_exists:function(){return($.support.localStorage?(localStorage.getItem("settings")!==null):(this.cookies.toString().length>2));},_initStorage:function(){if(!$.support.localStorage){this.cookies=$.cookieJar("settings");}
if(!this._exists()){this._loadDefaults();}
else{this._loadSavedSettings();}
if(this.get('version')<this._defaults.version){this._updateSettings(this.get('version'));}},_updateSettings:function(version){var statuses,self=this;if(version<567){this._loadDefaults();}else if(version<700){statuses={"QUEUED":0,"PROCESSING":1,"FINISHED":2,"ERROR":3};$.each(this.settings.history.movies,function(i,movie){self.settings.history.movies[i].status=statuses[movie.status];});this.settings.options=this.settings.defaults;delete this.settings.defaults;this.set('version',this._defaults.version);}},_loadDefaults:function(){this._empty();if($.support.localStorage){localStorage.setItem("settings",$.toJSON(this._defaults));}
else{this.cookies.set("settings",this._defaults);}
this.settings=this._defaults;},_loadSavedSettings:function(){if($.support.localStorage){this.settings=$.evalJSON(localStorage.getItem("settings"));}
else{this.settings=this.cookies.get("settings");}},_processURLSettings:function(urlSettings){if(urlSettings.imageScale){this.set("state.imageScale",parseFloat(urlSettings.imageScale));}
if(urlSettings.centerX){this.set("state.centerX",parseFloat(urlSettings.centerX));}
if(urlSettings.centerY){this.set("state.centerY",parseFloat(urlSettings.centerY));}
if(urlSettings.imageLayers){this.set("state.tileLayers",this._parseURLStringLayers(urlSettings.imageLayers));}
if(typeof urlSettings.eventLayers!='undefined'&&urlSettings.eventLayers!=''){this.set("state.eventLayers",this._parseURLStringEvents(urlSettings.eventLayers));}
if(urlSettings.eventLabels==true){this.set("state.eventLabels",true);}
else if(typeof urlSettings.eventLabels!='undefined'&&urlSettings.eventLabels==false){this.set("state.eventLabels",false);}},_parseURLStringLayers:function(urlLayers){var layers=[],self=this;$.each(urlLayers,function(i,layerString){layers.push(parseLayerString(layerString));});return layers;},_parseURLStringEvents:function(urlEventLayers){var events=[],self=this;$.each(urlEventLayers,function(i,eventLayerString){events.push(parseEventString(eventLayerString));});return events;},parseEventsURLString:function(eventLayerArray){var eventLayerString='';if(typeof eventLayerArray=="undefined"){eventLayerArray=this.get("state.eventLayers");}
$.each(eventLayerArray,function(i,eventLayerObj){eventLayerString+="["+eventLayerObj.event_type+","
+eventLayerObj.frms.join(';')+","
+eventLayerObj.open+"],";});return eventLayerString.slice(0,-1);},_validate:function(setting,value){var self=this;switch(setting){case"state.date":this._validator.checkTimestamp(value);break;case"state.imageScale":this._validator.checkFloat(value,{"min":this._constraints.minImageScale,"max":this._constraints.maxImageScale});break;case"history.movies":$.each(value,function(i,movie){self._validator.checkDateString(movie["dateRequested"]);});break;case"history.screenshots":$.each(value,function(i,screenshot){self._validator.checkDateString(screenshot["dateRequested"]);});break;case"options.movies.duration":this._validator.checkInt(value,{"min":this._constraints.minMovieLength,"max":this._constraints.maxMovieLength});break;default:break;}}});"use strict";var LayerManager=Class.extend({init:function(){this._layers=[];this._maxLayerDimensions={width:0,height:0};},addLayer:function(layer){this._layers.push(layer);},size:function(){return this._layers.length;},indexOf:function(id){var index=-1;$.each(this._layers,function(i,item){if(item.id===id){index=i;}});return index;},updateMaxDimensions:function(event){var type=event.type.split("-")[0];this.refreshMaxDimensions(type);$(document).trigger("viewport-max-dimensions-updated");},refreshMaxDimensions:function(type){var maxLeft=0,maxTop=0,maxBottom=0,maxRight=0,old=this._maxLayerDimensions;$.each(this._layers,function(){var d=this.getDimensions();maxLeft=Math.max(maxLeft,d.left);maxTop=Math.max(maxTop,d.top);maxBottom=Math.max(maxBottom,d.bottom);maxRight=Math.max(maxRight,d.right);});this._maxLayerDimensions={width:maxLeft+maxRight,height:maxTop+maxBottom};if((this._maxLayerDimensions.width!==old.width)||(this._maxLayerDimensions.height!==old.height)){$(document).trigger("layer-max-dimensions-changed",[type,this._maxLayerDimensions]);}},getMaxDimensions:function(){return this._maxLayerDimensions;},removeLayer:function(id){var type=id.split("-")[0],index=this.indexOf(id),layer=this._layers[index];layer.domNode.remove();this._layers=$.grep(this._layers,function(e,i){return(e.id!==layer.id);});layer=null;this.refreshMaxDimensions(type);},each:function(fn){$.each(this._layers,fn);},toJSON:function(){var layers=[];$.each(this._layers,function(){layers.push(this.toJSON());});return layers;}});"use strict";var EventManager=Class.extend({init:function(eventGlossary,date){var visState,scale;this._eventLayers=[];this._events=[];this._eventMarkers=[];this._eventTypes={};this._treeContainer=$("#eventJSTree");this._jsTreeData=[];this._date=date;this._eventLabelsVis=Helioviewer.userSettings.get("state.eventLabels");this._eventGlossary=eventGlossary;scale=new ImageScale();$('<div id="event-container"></div>').appendTo("#moving-container");visState=Helioviewer.userSettings.get("state.eventLayerVisible");if(typeof visState=='undefined'){Helioviewer.userSettings.set("state.eventLayerVisible",true);visState=true;}
if(visState===false&&$("#event-container").css('display')!='none'){$('span[id^="visibilityBtn-event-layer-"]').click();}
else if(visState===true&&$("#event-container").css('display')=='none'){$('span[id^="visibilityBtn-event-layer-"]').click();}
this._queryDefaultEventTypes();this._queryEventFRMs();$(document).bind("fetch-eventFRMs",$.proxy(this._queryEventFRMs,this));$(document).bind("toggle-events",$.proxy(this._toggleEvents,this));$(document).bind('toggle-event-labels',$.proxy(this.toggleEventLabels,this));},reinit:function(date){var visState;$("#event-container").remove();$('<div id="event-container"></div>').appendTo("#moving-container");visState=Helioviewer.userSettings.get("state.eventLayerVisible");if(typeof visState=='undefined'){Helioviewer.userSettings.set("state.eventLayerVisible",true);visState=true;}
if(visState===false&&$("#event-container").css('display')!='none'){$('span[id^="visibilityBtn-event-layer-"]').click();}
else if(visState===true&&$("#event-container").css('display')=='none'){$('span[id^="visibilityBtn-event-layer-"]').click();}
this._eventLayers=[];this._events=[];this._eventMarkers=[];this._eventTypes={};this._jsTreeData=[];this._date=date;this._queryEventFRMs();},_queryDefaultEventTypes:function(){var params={"action":"getDefaultEventTypes"};$.get("api/index.php",params,$.proxy(this._parseEventFRMs,this),"json");},_queryEventFRMs:function(){if(this._events.length==0){var params={"action":"getEventFRMs","startTime":new Date(this._date.getTime()).toISOString(),"ar_filter":true};$.get("api/index.php",params,$.proxy(this._parseEventFRMs,this),"json");}},_parseEventFRMs:function(result){var self=this,domNode,eventAbbr,settings;$("#event-container").empty();self._eventTypes={};$.each(result,function(eventType,eventFRMs){eventAbbr=eventType.split('/');eventAbbr=eventAbbr[1];self._eventTypes[eventAbbr]=new EventType(eventAbbr);$.each(eventFRMs,function(frmName,eventFRM){self._eventTypes[eventAbbr]._eventFRMs[frmName]=new EventFeatureRecognitionMethod(frmName,self.eventGlossary);domNode='<div class="event-layer" id="'
+eventAbbr+'__'+frmName.replace(/ /g,'_')
+'" style="position: absolute;">';self._eventTypes[eventAbbr]._eventFRMs[frmName].setDomNode($(domNode).appendTo("#event-container"));});});this._generateTreeData(result);this._queryEvents();},_queryEvents:function(){var params;params={"action":"getEvents","startTime":new Date(this._date.getTime()).toISOString(),"eventType":'**'};$.get("api/index.php",params,$.proxy(this._parseEvents,this),"json");},_parseEvents:function(result){var eventMarker,self=this,parentDomNode,eventGlossary;eventGlossary=this._eventGlossary;$.each(this._eventMarkers,function(i,eventMarker){eventMarker.remove();});this._eventMarkers=[];this._events=result;$.each(this._events,function(i,event){if(typeof self._eventTypes[event['event_type']]!='undefined'){self._eventMarkers.push(new EventMarker(eventGlossary,self._eventTypes[event['event_type']]._eventFRMs[event['frm_name']],event,i+1));}});this._toggleEvents();},_generateTreeData:function(data){var self=this,obj,index=0,event_type_arr,type_count=0,count_str;self._jsTreeData=[];$.each(data,function(event_type,event_type_obj){event_type_arr=event_type.split('/');if(event_type_arr[0].charAt(event_type_arr[0].length-1)==" "){event_type_arr[0]=event_type_arr[0].slice(0,-1);}
switch(event_type_arr[0].charAt(event_type_arr[0].length-1)){case'x':event_type_arr[0]+='es';break;case'y':event_type_arr[0]=event_type_arr[0].slice(0,-1)+'ies';break;default:event_type_arr[0]+='s';}
obj=Object();obj['data']=event_type_arr[0];obj['attr']={'id':event_type_arr[1]};obj['state']='open';obj['children']=[];self._jsTreeData.push(obj);type_count=0;$.each(event_type_obj,function(frm_name,frm_obj){type_count+=frm_obj['count'];count_str='';if(frm_obj['count']>0){count_str=" ("+frm_obj['count']+")";}
self._jsTreeData[index].children.push({'data':frm_name+count_str,'attr':{'id':event_type_arr[1]
+'--'
+self._escapeInvalidCssChars(frm_name)}});});count_str='';if(type_count>0){count_str=" ("+type_count+")";}
obj['data']=obj['data']+count_str;index++;});if(!self._eventTree){self._eventTree=new EventTree(this._jsTreeData,this._treeContainer);}
self._eventTree.reload(this._jsTreeData);$(document).trigger('viewport-resized');},_escapeInvalidCssChars:function(selector){selector=selector.replace(/ /g,"_");selector=selector.replace(/([\+\.\(\)])/g,'\\$1');return selector;},updateRequestTime:function(){var managerStartDate,managerEndDate,eventStartDate,eventEndDate,self=this;this.reinit(new Date($("#date").val().replace(/\//g,"-")+"T"+$("#time").val()+"Z"));},addEventLayer:function(eventLayer){this._eventLayers.push(eventLayer);},size:function(){return this._eventLayers.length;},indexOf:function(id){var index=-1;$.each(this._eventLayers,function(i,item){if(item.id===id){index=i;}});return index;},each:function(fn){$.each(this._eventLayers,fn);},toJSON:function(){var eventLayers=[];$.each(this._eventLayers,function(){eventLayers.push(this.toJSON());});return eventLayers;},_toggleEvents:function(event){var newState,checkedEventTypes=[],checkedFRMs={},self=this;newState=Helioviewer.userSettings.get("state.eventLayers");$.each(newState,function(i,checkedTypeObj){checkedEventTypes.push(checkedTypeObj['event_type']);checkedFRMs[checkedTypeObj['event_type']]=[];$.each(checkedTypeObj['frms'],function(j,frmName){checkedFRMs[checkedTypeObj['event_type']].push(frmName);});});$.each(this._eventTypes,function(eventTypeName,eventTypeObj){$.each(eventTypeObj._eventFRMs,function(frmName,frmObj){if($.inArray(eventTypeName,checkedEventTypes)==-1){self._eventTypes[eventTypeName]._eventFRMs[frmName].domNode.hide();}
else{if(checkedFRMs[eventTypeName][0]=='all'||$.inArray(frmName.replace(/ /g,'_'),checkedFRMs[eventTypeName])!=-1){self._eventTypes[eventTypeName]._eventFRMs[frmName].domNode.show();}
else{self._eventTypes[eventTypeName]._eventFRMs[frmName].domNode.hide();}}});});this.eventLabels();},toggleEventLabels:function(event,labelsBtn){if(typeof labelsBtn=='undefined'){labelsBtn=$('span[id^="labelsBtn-event-layer-"]');}
if(this._eventLabelsVis){$(document).trigger('toggle-event-label-off');labelsBtn.addClass('hidden');}
else{$(document).trigger('toggle-event-label-on');labelsBtn.removeClass('hidden');}
this._eventLabelsVis=!this._eventLabelsVis;return true;},eventLabels:function(event){this._eventLabelsVis=Helioviewer.userSettings.get("state.eventLabels");if(this._eventLabelsVis){$(document).trigger('toggle-event-label-on');}
else{$(document).trigger('toggle-event-label-off');}
return true;}});"use strict";var EventType=Class.extend({init:function(name){this._name=name;this._eventFRMs={};this._queried=false;},getEventFRMs:function(){return this._eventFRMs;},getName:function(){return this._name;},addFRM:function(frm){this._eventFRMs[frm._name]=frm;},isQueried:function(startTime,endTime){var typeIsQueried=true;$.each(this._eventFRMs,function(frmName,FRM){if(!FRM.isQueried(startTime,endTime)){typeIsQueried=false;return false;}});return typeIsQueried;}});"use strict";var EventTree=Class.extend({init:function(data,container){this._container=container;this._build(data);$(document).bind("toggle-checkboxes",$.proxy(this.toggle_checkboxes,this));$(document).bind("toggle-checkboxes-to-state",$.proxy(this.toggle_checkboxes_state,this));},destroy:function(data){this._container.empty();},reload:function(newData){this.destroy();this._build(newData);},close_all:function(){this._container.jstree("close_all",null,true);},open_all:function(){this._container.jstree("open_all",null,true);},toggle_checkboxes:function(){var numChecked;numChecked=Helioviewer.userSettings.get("state.eventLayers").length;if(numChecked>0){this._container.jstree("uncheck_all",null,true);}
else{this._container.jstree("check_all",null,true);this._container.unbind("change_state.jstree",$.proxy(this._treeChangedState,this));$(document).trigger("fetch-eventFRMs");this._container.bind("change_state.jstree",$.proxy(this._treeChangedState,this));}},toggle_checkboxes_state:function(e,toState){if(toState=='off'){this._container.jstree("uncheck_all",null,true);}
else if(toState=='on'){this._container.jstree("check_all",null,true);}
else{this.toggle_checkboxes();return;}
this._container.unbind("change_state.jstree",$.proxy(this._treeChangedState,this));$(document).trigger("fetch-eventFRMs");this._container.bind("change_state.jstree",$.proxy(this._treeChangedState,this));},jstreeFunc:function(name,args){this._container.jstree(name,args);},_build:function(jsTreeData){var self=this,saved,node;this._container.jstree({"json_data":{"data":jsTreeData},"themes":{"theme":"default","dots":true,"icons":false},"plugins":["json_data","themes","ui","checkbox"],});$.each(jsTreeData,function(index,event_type){$('#'+event_type['attr'].id+' a').hover($.proxy(self.hoverOn,this),$.proxy(self.hoverOff,this));if(event_type.children.length==0){$('#'+event_type['attr'].id).css({'opacity':'0.5'});}
$.each(event_type['children'],function(j,frm){$('#'+self._escapeInvalidJQueryChars(frm['attr'].id)+' a').hover($.proxy(self.hoverOnFRM,this),$.proxy(self.hoverOffFRM,this));});});this._container.unbind("change_state.jstree",$.proxy(this._treeChangedState,this));saved=Helioviewer.userSettings.get("state.eventLayers");$.each(saved,function(i,eventLayer){if(eventLayer.frms[0]=='all'){node="#"+eventLayer.event_type;if($(node).length!=0){self.jstreeFunc("check_node",node);}}
else{$.each(eventLayer.frms,function(j,frm){node="#"+eventLayer.event_type+"--"+frm;if($(node).length!=0){self.jstreeFunc("check_node",node);}});}});this._container.bind("change_state.jstree",$.proxy(this._treeChangedState,this));$(document).trigger("change_state.jstree",this);},_escapeInvalidJQueryChars:function(selector){selector=selector.replace(/(\+)/g,'\\\\$1');selector=selector.replace(/(\.)/g,'\\\\$1');selector=selector.replace(/(\()/g,'\\\\$1');selector=selector.replace(/(\))/g,'\\\\$1');return selector;},_treeChangedState:function(event,data){var checked=[],event_types=[],index;this._container.jstree("get_checked",null,false).each(function(){var eventLayer,event_type,frm;event_type=this.id.split("--");if(event_type.length>1){frm=event_type[1];}
else{frm='all';}
event_type=event_type[0];index=$.inArray(event_type,event_types)
if(index==-1){eventLayer={'event_type':event_type,'frms':[frm],'open':1};checked.push(eventLayer);event_types.push(event_type);}
else{checked[index].frms.push(frm);}});Helioviewer.userSettings.set("state.eventLayers",checked);$(document).trigger("toggle-events");},hoverOn:function(event){var emphasisNodes,eventLayerNodes,found;emphasisNodes=$("[id^="+this['attr'].id+"__]");eventLayerNodes=$("#event-container > div.event-layer");$.each(eventLayerNodes,function(i,obj){found=false;$.each(emphasisNodes,function(j,emphObj){if($(obj)[0].id==$(emphObj)[0].id){found=true;}});if(found===false&&emphasisNodes.length>0){$(obj).css({'opacity':'0.20'});}
else{$(obj).css({'opacity':'1.00'});}});},hoverOff:function(event){$("#event-container > div.event-layer").css({'opacity':'1.0'});},hoverOnFRM:function(event){var emphasisNode,deEmphasisNodes,eventTypeAbbr,eventLayerNodes,found;eventTypeAbbr=this['attr'].id.split("--")[0];emphasisNode=$("#"+this['attr'].id.replace("--","__"));deEmphasisNodes=$("[id^="+eventTypeAbbr+"__]");eventLayerNodes=$("#event-container > div.event-layer");$.each(eventLayerNodes,function(i,obj){if($(obj)[0].id==$(emphasisNode)[0].id){$(obj).css({'opacity':'1.00'});}
else{found=false;$.each(deEmphasisNodes,function(j,deEmphObj){if($(obj)[0].id==$(deEmphObj)[0].id){found=true;}});if(found===true){$(obj).css({'opacity':'0.20'});}
else{$(obj).css({'opacity':'0.20'});}}});},hoverOffFRM:function(event){var emphasisNode,deEmphasisNodes,eventTypeAbbr,eventLayerNodes,found;eventTypeAbbr=this['attr'].id.split("--")[0];emphasisNode=$("#"+this['attr'].id.replace("--","__"));deEmphasisNodes=$("[id^="+eventTypeAbbr+"__]");eventLayerNodes=$("#event-container > div.event-layer");$.each(eventLayerNodes,function(i,obj){if($(obj)[0].id==$(emphasisNode)[0].id){$(obj).css({'opacity':'1.0'});}
else{found=false;$.each(deEmphasisNodes,function(j,deEmphObj){if($(obj)[0].id==$(deEmphObj)[0].id){found=true;}});if(found===true){$(obj).css({'opacity':'1.0'});}
else{$(obj).css({'opacity':'1.0'});}}});}});"use strict";var EventFeatureRecognitionMethod=Class.extend({init:function(name,eventGlossary){this._events=[];this._name=name;this._visible=false;this.eventGlossary=eventGlossary;},getName:function(){return this._name;},setDomNode:function(domNode){this.domNode=domNode;}});"use strict";var EventLayerManager=EventManager.extend({init:function(requestDate,defaultEventTypes,viewportScale,rsun,savedEventLayers,urlEventLayers){this._eventLayers=[];this._events=[];this._eventMarkers=[];this._treeContainer=$("#eventJSTree");this._eventTypes={};this._jsTreeData=[];if(typeof date=='undefined'){var date=requestDate;}
this._date=date;this._requestDate=requestDate;this.defaultEventTypes=defaultEventTypes;this.viewportScale=viewportScale;$(document).bind("event-layer-finished-loading",$.proxy(this.updateMaxDimensions,this)).bind("save-event-layers",$.proxy(this.save,this)).bind("add-new-event-layer",$.proxy(this.addNewLayer,this)).bind("remove-event-layer",$.proxy(this._onLayerRemove,this));},save:function(){var eventLayers=this.toJSON();Helioviewer.userSettings.set("state.eventLayers",eventLayers);},_onLayerRemove:function(event,id){this.removeLayer(id);},getRequestDateAsISOString:function(){return this._requestDate.toISOString();}});"use strict";var EventMarker=Class.extend({init:function(eventGlossary,parentFRM,event,zIndex){$.extend(this,event);this.event=event;this.behindSun=false;this.parentFRM=parentFRM;this._labelVisible=false;this._popupVisible=false;this._zIndex=zIndex;this._eventGlossary=eventGlossary;this.formatLabels();this.createRegion(0);this.createMarker(zIndex);$(document).bind("replot-event-markers",$.proxy(this.refresh,this));$(document).bind('toggle-event-label-on',$.proxy(this.toggleEventLabel,this));$(document).bind('toggle-event-label-off',$.proxy(this.toggleEventLabel,this));},createMarker:function(zIndex){var markerURL;this.eventMarkerDomNode=$('<div/>');this.eventMarkerDomNode.attr({'class':"event-marker"});this.pos={x:(this.hv_hpc_x_final/Helioviewer.userSettings.settings.state.imageScale)-12,y:(-this.hv_hpc_y_final/Helioviewer.userSettings.settings.state.imageScale)-38};markerURL=serverSettings['staticAssetUrl']+'/resources/images/eventMarkers/'+this.event_type.toUpperCase()+'@2x'+'.png';this.eventMarkerDomNode.css({'left':this.pos.x+'px','top':this.pos.y+'px','z-index':zIndex,'background-image':"url('"+markerURL+"')"});if(typeof this.parentFRM!='undefined'){this.parentFRM.domNode.append(this.eventMarkerDomNode);}
else{return;}
this.eventMarkerDomNode.bind("click",$.proxy(this.toggleEventPopUp,this));this.eventMarkerDomNode.mouseenter($.proxy(this.toggleEventLabel,this));this.eventMarkerDomNode.mouseleave($.proxy(this.toggleEventLabel,this));},createRegion:function(zIndex){if(this.hpc_boundcc!=''){var regionURL;this.eventRegionDomNode=$('<div/>');this.eventRegionDomNode.attr({'class':"event-region"});this.region_scaled={width:this.hv_poly_width_max_zoom_pixels*(Helioviewer.userSettings._constraints.minImageScale/Helioviewer.userSettings.settings.state.imageScale),height:this.hv_poly_height_max_zoom_pixels*(Helioviewer.userSettings._constraints.minImageScale/Helioviewer.userSettings.settings.state.imageScale)}
this.region_pos={x:(this.hv_poly_hpc_x_final/Helioviewer.userSettings.settings.state.imageScale),y:(this.hv_poly_hpc_y_final/Helioviewer.userSettings.settings.state.imageScale)}
this.eventRegionDomNode.css({'left':this.region_pos.x+'px','top':this.region_pos.y+'px','z-index':zIndex,'background-image':"url('"+serverSettings['staticAssetUrl']
+"/"+this.hv_poly_url+"')",'background-size':this.region_scaled.width+'px '+this.region_scaled.height+'px','width':this.region_scaled.width+'px','height':this.region_scaled.height+'px'});if(typeof this.parentFRM!='undefined'){this.parentFRM.domNode.append(this.eventRegionDomNode);}
this.eventRegionDomNode.bind("click",$.proxy(this.toggleEventPopUp,this));this.eventRegionDomNode.mouseenter($.proxy(this.toggleEventLabel,this));this.eventRegionDomNode.mouseleave($.proxy(this.toggleEventLabel,this));}},formatLabels:function(){var self=this;if(this.hasOwnProperty('hv_labels_formatted')&&Object.keys(this.hv_labels_formatted).length>0){this.labelText="";$.each(this.hv_labels_formatted,function(key,value){self.labelText+=value+"<br/>\n";});}
else{this.labelText=this.concept;}},remove:function(){this.eventMarkerDomNode.qtip("destroy");this.eventMarkerDomNode.unbind();this.eventMarkerDomNode.remove();if(this.hpc_boundcc!=''){this.eventRegionDomNode.qtip("destroy");this.eventRegionDomNode.unbind();this.eventRegionDomNode.remove();}},refresh:function(){this.pos={x:(this.hv_hpc_x_final/Helioviewer.userSettings.settings.state.imageScale)-12,y:(-this.hv_hpc_y_final/Helioviewer.userSettings.settings.state.imageScale)-38};this.eventMarkerDomNode.css({'left':this.pos.x+'px','top':this.pos.y+'px'});if(this.hpc_boundcc!=''){this.region_scaled={width:this.hv_poly_width_max_zoom_pixels*(Helioviewer.userSettings._constraints.minImageScale/Helioviewer.userSettings.settings.state.imageScale),height:this.hv_poly_height_max_zoom_pixels*(Helioviewer.userSettings._constraints.minImageScale/Helioviewer.userSettings.settings.state.imageScale)}
this.region_pos={x:(this.hv_poly_hpc_x_final/Helioviewer.userSettings.settings.state.imageScale),y:(this.hv_poly_hpc_y_final/Helioviewer.userSettings.settings.state.imageScale)}
this.eventRegionDomNode.css({'left':this.region_pos.x+'px','top':this.region_pos.y+'px'});this.eventRegionDomNode.css({'width':this.region_scaled.width,'height':this.region_scaled.height,'background-size':this.region_scaled.width+'px '+this.region_scaled.height+'px'});}
if(this._popupVisible){this.popup_pos={x:(this.hv_hpc_x_final/Helioviewer.userSettings.settings.state.imageScale)+12,y:(-this.hv_hpc_y_final/Helioviewer.userSettings.settings.state.imageScale)-38};if(this.hv_hpc_x_final>400){this.popup_pos.x-=this.eventPopupDomNode.width()+38;}
this.eventPopupDomNode.css({'left':this.popup_pos.x+'px','top':this.popup_pos.y+'px'});}},setVisibility:function(visible){if(visible){this.eventRegionDomNode.show();this.eventMarkerDomNode.show();}
else{this.eventRegionDomNode.hide();this.eventMarkerDomNode.hide();}},toggleEventLabel:function(event){if(!this.label){this.label=$('<div/>');this.label.hide();this.label.attr({'class':"event-label"});this.label.html(this.labelText);this.label.click(function(event){event.stopImmediatePropagation();});this.label.mousedown(function(event){event.stopImmediatePropagation();});this.label.dblclick(function(event){event.stopImmediatePropagation();});this.label.enableSelection();this.eventMarkerDomNode.append(this.label);}
if(event.type=='toggle-event-label-on'){this.eventMarkerDomNode.css('zIndex','997');this._labelVisible=true;document.getSelection().removeAllRanges();this.label.show();Helioviewer.userSettings.set("state.eventLabels",true);}
else if(event.type=='toggle-event-label-off'){this._labelVisible=false;this.label.hide();this.eventMarkerDomNode.css('zIndex',this._zIndex);document.getSelection().removeAllRanges();Helioviewer.userSettings.set("state.eventLabels",false);}
else if(event.type=='mouseenter'){this.eventMarkerDomNode.css('zIndex','997');this.label.addClass("event-label-hover");this.label.show();}
else if(event.type=='mouseleave'){if(!this._labelVisible){this.label.hide();}
this.label.removeClass("event-label-hover");this.eventMarkerDomNode.css('zIndex',this._zIndex);}
return true;},toggleEventPopUp:function(){if(!this.eventPopupDomNode){this._populatePopup();}
if(this._popupVisible){this.eventPopupDomNode.hide();this.eventMarkerDomNode.css('z-index',this._zIndex);}
else{this.popup_pos={x:(this.hv_hpc_x_final/Helioviewer.userSettings.settings.state.imageScale)+12,y:(-this.hv_hpc_y_final/Helioviewer.userSettings.settings.state.imageScale)-38};if(this.hv_hpc_x_final>400){this.popup_pos.x-=this.eventPopupDomNode.width()+38;}
this.eventPopupDomNode.css({'left':this.popup_pos.x+'px','top':this.popup_pos.y+'px','z-index':'1000'});this.eventMarkerDomNode.css('z-index','998');this.eventPopupDomNode.show();}
this._popupVisible=!this._popupVisible;return true;},_showEventInfoDialog:function(){var params,dtype,split,self=this,dialog=$("#event-info-dialog");this._buildEventInfoDialog();$('.event-header-value.integer').number(true);$('.event-header-value.float').each(function(i,num){split=num.innerHTML.split('.')
if(typeof split[1]!='undefined'){num.innerHTML=$.number(num.innerHTML,split[1].length);}
else{num.innerHTML=$.number(num.innerHTML);}});},_buildEventInfoDialog:function(){var dialog,sortBtn,tabs,html='',tag,json,headingText,self=this;dialog=$("<div id='event-info-dialog' class='event-info-dialog' />");if(this.hasOwnProperty('hv_labels_formatted')&&Object.keys(this.hv_labels_formatted).length>0){headingText=this.event_type+': '+this.hv_labels_formatted[Object.keys(this.hv_labels_formatted)[0]];}
else{headingText=this.concept;}
html+='<div class="event-info-dialog-menu">'
+'<a class="show-tags-btn event-type selected">'+this.concept+'</a>'
+'<a class="show-tags-btn obs">Observation</a>'
+'<a class="show-tags-btn frm">Recognition Method</a>'
+'<a class="show-tags-btn ref">References</a>'
+'<a class="show-tags-btn all right">All</a>'
+'</div>';html+='<div class="event-header event-type" style="height: 400px; overflow: auto;">'
+this._generateEventKeywordsSection(this.event_type)+'</div>'
+'<div class="event-header obs" style="display: none; height: 400px; overflow: auto;">'
+this._generateEventKeywordsSection("obs")+'</div>'
+'<div class="event-header frm" style="display: none; height: 400px; overflow: auto;">'
+this._generateEventKeywordsSection("frm")+'</div>'
+'<div class="event-header ref" style="display: none; height: 400px; overflow: auto;">'
+this._generateEventKeywordsSection("ref")+'</div>'
+'<div class="event-header all" style="display: none; height: 400px; overflow: auto;">'
+this._generateEventKeywordsSection("all")+'</div>';dialog.append(html).appendTo("body").dialog({autoOpen:true,title:headingText,minWidth:746,width:646,height:550,draggable:true,resizable:false,buttons:[{text:'Hide Empty Rows','class':'toggle_empty',click:function(){var text=$(this).parent().find('.toggle_empty span.ui-button-text');$.each($(this).find("div.empty"),function(index,node){if($(node).css('display')=='none'){$(node).css('display','block');}
else{$(node).css('display','none');}});if(text.html()=='Hide Empty Rows'){text.html('Show Empty Rows');}
else{text.html('Hide Empty Rows');}}}],create:function(event,ui){dialog.css('overflow','hidden');var eventTypeTab=dialog.find(".show-tags-btn.event-type"),obsTab=dialog.find(".show-tags-btn.obs"),frmTab=dialog.find(".show-tags-btn.frm"),refTab=dialog.find(".show-tags-btn.ref"),allTab=dialog.find(".show-tags-btn.all");eventTypeTab.click(function(){eventTypeTab.addClass("selected");obsTab.removeClass("selected");frmTab.removeClass("selected");refTab.removeClass("selected");allTab.removeClass("selected");dialog.find(".event-header.event-type").show();dialog.find(".event-header.obs").hide();dialog.find(".event-header.frm").hide();dialog.find(".event-header.ref").hide();dialog.find(".event-header.all").hide();});obsTab.click(function(){eventTypeTab.removeClass("selected");obsTab.addClass("selected");frmTab.removeClass("selected");refTab.removeClass("selected");allTab.removeClass("selected");dialog.find(".event-header.event-type").hide();dialog.find(".event-header.obs").show();dialog.find(".event-header.frm").hide();dialog.find(".event-header.ref").hide();dialog.find(".event-header.all").hide();});frmTab.click(function(){eventTypeTab.removeClass("selected");obsTab.removeClass("selected");frmTab.addClass("selected");refTab.removeClass("selected");allTab.removeClass("selected");dialog.find(".event-header.event-type").hide();dialog.find(".event-header.obs").hide();dialog.find(".event-header.frm").show();dialog.find(".event-header.ref").hide();dialog.find(".event-header.all").hide();});refTab.click(function(){eventTypeTab.removeClass("selected");obsTab.removeClass("selected");frmTab.removeClass("selected");refTab.addClass("selected");allTab.removeClass("selected");dialog.find(".event-header.event-type").hide();dialog.find(".event-header.obs").hide();dialog.find(".event-header.frm").hide();dialog.find(".event-header.ref").show();dialog.find(".event-header.all").hide();});allTab.click(function(){eventTypeTab.removeClass("selected");obsTab.removeClass("selected");frmTab.removeClass("selected");refTab.removeClass("selected");allTab.addClass("selected");dialog.find(".event-header.event-type").hide();dialog.find(".event-header.obs").hide();dialog.find(".event-header.frm").hide();dialog.find(".event-header.ref").hide();dialog.find(".event-header.all").show();});}});},_generateEventKeywordsSection:function(tab){var formatted,tag,tags=[],lookup,attr,domClass,icon,list={},self=this;if(tab=='obs'){$.each(this.event,function(key,value){if(key.substring(0,4)=='obs_'){lookup=self._eventGlossary[key];if(typeof lookup!='undefined'){list[key]=lookup;list[key]["value"]=value;}
else{list[key]={"value":value};}}});}
else if(tab=='frm'){$.each(this.event,function(key,value){if(key.substring(0,4)=='frm_'){lookup=self._eventGlossary[key];if(typeof lookup!='undefined'){list[key]=lookup;list[key]["value"]=value;}
else{list[key]={"value":value};}}});}
else if(tab=='ref'){$.each(this.event['refs'],function(index,obj){lookup=self._eventGlossary[obj['ref_name']];if(typeof lookup!='undefined'){list[obj['ref_name']]=lookup;list[obj['ref_name']]["value"]=obj['ref_url'];}
else{list[obj['ref_name']]={"value":obj['ref_url']};}});}
else if(tab=='all'){$.each(this.event,function(key,value){if(key.substring(0,3)!='hv_'&&key!='refs'){lookup=self._eventGlossary[key];if(typeof lookup!='undefined'){list[key]=lookup;list[key]["value"]=value;}
else{list[key]={"value":value};}}});}
else if(tab.length==2){$.each(this.event,function(key,value){if(key.substring(0,3)==tab.toLowerCase()+'_'||key.substring(0,5)=='event'||key=='concept'||key.substring(0,3)=='kb_'){lookup=self._eventGlossary[key];if(typeof lookup!='undefined'){list[key]=lookup;list[key]["value"]=value;}
else{list[key]={"value":value};}}});}
else{console.warn('No logic for unexpected tab "'+tab+'".');}
formatted='<div>';$.each(list,function(key,obj){attr='';domClass='';icon='';if(tab!='all'&&typeof obj['hv_label']!='undefined'&&obj['hv_label']!==null){key=obj['hv_label'];}
if(typeof obj['hek_desc']!='undefined'&&obj['hek_desc']!==null){attr+=' title="'+obj['hek_desc']+'"';}
if(obj.value!=''&&obj.value!='N/A'&&obj.value!='n/a'&&typeof obj['hv_type']!='undefined'&&(obj['hv_type']=='url'||obj['hv_type']=='image_url')){if(obj.value.indexOf('://')==-1){obj.value='http://'+obj.value;}
obj.value='<a href="'+obj.value+'" target="_blank">'+obj.value+'</a>';}
if(obj.value!=''&&obj.value!='N/A'&&obj.value!='n/a'&&typeof obj['hv_type']!='undefined'&&obj['hv_type']=='email_or_url'){if(obj.value.indexOf('://')==-1&&obj.value.indexOf('/')!==-1&&obj.value.indexOf('@')==-1&&obj.value.indexOf(' at ')==-1){obj.value='http://'+obj.value;obj.value='<a href="'+obj.value+'" target="_blank">'+obj.value+'</a>';}
else if(obj.value.indexOf('://')!==-1){obj.value='<a href="'+obj.value+'" target="_blank">'+obj.value+'</a>';}
else if(obj.value.indexOf('@')>-1&&obj.value.indexOf(' ')==-1){obj.value='<a href="mailto:'+obj.value+'">'+obj.value+'</a>';}}
if(obj.value!=''&&obj.value!='N/A'&&obj.value!='n/a'&&typeof obj['hv_type']!='undefined'&&obj['hv_type']=='thumbnail_url'){if(obj.value.indexOf('://')==-1){obj.value='http://'+obj.value;}
obj.value='<img src="'+obj.value+'"/>';}
if(typeof obj['hv_type']!='undefined'&&obj['hv_type']=='date'){domClass+=' date';}
if(typeof obj['hek_type']!='undefined'&&obj['hek_type']=='float'){domClass+=' float';}
if(typeof obj['hek_type']!='undefined'&&(obj['hek_type']=='integer'||obj['hek_type']=='long')){domClass+=' integer';}
if(typeof obj['hv_type']!='undefined'&&obj['hv_type']=='boolean'){domClass+=' boolean';if(obj.value.toUpperCase()=="T"||obj.value==1||obj.value.toLowerCase()=='true'){domClass+=' true';}
if(obj.value.toUpperCase()=="F"||obj.value==0||obj.value.toLowerCase()=='false'){domClass+=' false';}}
if(typeof obj['hv_type']!='undefined'&&obj['hv_type']!='date'&&typeof obj['hek_type']!='undefined'&&obj['hek_type']=='string'){domClass+=' string';}
if(typeof obj.value==='undefined'||obj.value===null||obj.value==='null'||obj.value===''){tag='<div class="empty"><span class="event-header-tag empty"'+attr+'>'+key+': </span>'+'<span class="event-header-value empty">'+obj.value+'</span></div>';}
else{tag='<div><span class="event-header-tag"'+attr+'>'+key+': </span>'+'<span class="event-header-value'+domClass+'">'+obj.value+'</span></div>';}
tags.push(tag);formatted+=tag;});formatted+='</div>';return formatted;},_populatePopup:function(){var content='',headingText='',self=this;if(this.hasOwnProperty('hv_labels_formatted')&&Object.keys(this.hv_labels_formatted).length>0){headingText=this.event_type+': '+this.hv_labels_formatted[Object.keys(this.hv_labels_formatted)[0]];}
else{headingText=this.concept;}
content+='<div class="close-button ui-icon ui-icon-closethick" title="Close PopUp Window"></div>'+"\n"
+'<h1>'+headingText+'</h1>'+"\n";if(this.event_peaktime!=null&&this.event_peaktime!=''){content+='<div class="container">'+"\n"
+"\t"+'<div class="param-container"><div class="param-label">Peak Time:</div></div>'+"\n"
+"\t"+'<div class="value-container"><div class="param-value">'+this.event_peaktime.replace('T',' ')+'</div><div class="ui-icon ui-icon-arrowstop-1-n" title="Jump to Event Peak Time"></div></div>'+"\n"
+'</div>'+"\n";}
content+='<div class="container">'+"\n"
+"\t"+'<div class="param-container"><div class="param-label">Start Time: </div></div>'+"\n"
+"\t"+'<div class="value-container"><div class="param-value">'+this.event_starttime.replace('T',' ')+'</div><div class="ui-icon ui-icon-arrowstop-1-w" title="Jump to Event Start Time"></div></div>'+"\n"
+'</div>'+"\n"
+'<div class="container">'+"\n"
+"\t"+'<div class="param-container"><div class="param-label">End Time: </div></div>'+"\n"
+"\t"+'<div class="value-container"><div class="param-value">'+this.event_endtime.replace('T',' ')+'</div><div class="ui-icon ui-icon-arrowstop-1-e" title="Jump to Event End Time"></div>'+"\n"
+'</div>'+"\n";if(this.hasOwnProperty('hv_labels_formatted')&&Object.keys(this.hv_labels_formatted).length>0){$.each(this.hv_labels_formatted,function(param,value){content+='<div class="container">'+"\n"
+"\t"+'<div class="param-container"><div class="param-label">'+param+': </div></div>'+"\n"
+"\t"+'<div class="value-container"><div class="param-value">'+value+'</div></div>'+"\n"
+'</div>'+"\n";});}
content+='<div class="btn-container text-btn">'+"\n"
+"\t"+'<div class="ui-icon ui-icon-info btn event-info"></div><div class="btn-label btn event-info">View HEK data</div>'+"\n"
+'</div>'+"\n";this.eventPopupDomNode=$('<div/>');this.eventPopupDomNode.hide();this.eventPopupDomNode.attr({'class':"event-popup"});this.eventPopupDomNode.html(content);this.eventPopupDomNode.find(".ui-icon-arrowstop-1-w").bind('click',function(){helioviewer.timeControls.setDate(new Date(self.event_starttime+".000Z"));});this.eventPopupDomNode.find(".ui-icon-arrowstop-1-n").bind('click',function(){helioviewer.timeControls.setDate(new Date(self.event_peaktime+".000Z"));});this.eventPopupDomNode.find(".ui-icon-arrowstop-1-e").bind('click',function(){helioviewer.timeControls.setDate(new Date(self.event_endtime+".000Z"));});this.eventPopupDomNode.find(".event-movie").bind('click',function(){alert('Event-based movie generation not yet implemented.')});this.eventPopupDomNode.find(".btn.event-info").bind('click',$.proxy(this._showEventInfoDialog,this));this.eventPopupDomNode.find('.close-button').bind('click',$.proxy(this.toggleEventPopUp,this));this.eventPopupDomNode.bind("mousedown",function(){return false;});this.eventPopupDomNode.bind('dblclick',function(){return false;});this.eventPopupDomNode.draggable();this.eventPopupDomNode.find("h1, .param-label, .param-value, .btn-container .btn").click(function(event){event.stopImmediatePropagation();});this.eventPopupDomNode.find("h1, .param-label, .param-value, .btn-container .btn").mousedown(function(event){event.stopImmediatePropagation();});this.eventPopupDomNode.find("h1, .param-label, .param-value, .btn-container .btn").dblclick(function(event){event.stopImmediatePropagation();});this.eventPopupDomNode.find("h1, .param-label, .param-value").enableSelection();this.parentFRM.domNode.append(this.eventPopupDomNode);}});"use strict";var EventLayerManager=EventManager.extend({init:function(requestDate,defaultEventTypes,viewportScale,rsun,savedEventLayers,urlEventLayers){this._eventLayers=[];this._events=[];this._eventMarkers=[];this._treeContainer=$("#eventJSTree");this._eventTypes={};this._jsTreeData=[];if(typeof date=='undefined'){var date=requestDate;}
this._date=date;this._requestDate=requestDate;this.defaultEventTypes=defaultEventTypes;this.viewportScale=viewportScale;$(document).bind("event-layer-finished-loading",$.proxy(this.updateMaxDimensions,this)).bind("save-event-layers",$.proxy(this.save,this)).bind("add-new-event-layer",$.proxy(this.addNewLayer,this)).bind("remove-event-layer",$.proxy(this._onLayerRemove,this));},save:function(){var eventLayers=this.toJSON();Helioviewer.userSettings.set("state.eventLayers",eventLayers);},_onLayerRemove:function(event,id){this.removeLayer(id);},getRequestDateAsISOString:function(){return this._requestDate.toISOString();}});"use strict";var HelioviewerEventLayer=Class.extend({init:function(index,date,viewportScale,name,markersVisible,labelsVisible){this.id="event-layer-"+new Date().getTime();$(document).trigger("create-event-layer-accordion-entry",[index,this.id,name,date,true,markersVisible,labelsVisible]);}});"use strict";var HelioviewerEventLayerManager=EventLayerManager.extend({init:function(requestDate,defaultEventTypes,viewportScale,rsun,savedEventLayers,urlEventLayers){this._super(requestDate,defaultEventTypes,viewportScale,rsun,savedEventLayers,urlEventLayers);this._loadStartingLayers(defaultEventTypes);},addNewLayer:function(){this.addEventLayer(new HelioviewerEventLayer(this._eventLayers.length,this._requestDate,this.viewportScale,'HEK',true,true));},_loadStartingLayers:function(layers){var eventLayer,basicParams,self=this;this.addEventLayer(new HelioviewerEventLayer(this._eventLayers.length,this._requestDate,this.viewportScale,'HEK',true,Helioviewer.userSettings.get("state.eventLabels")));},toURIString:function(){var str="";$.each(this._eventLayers,function(){str+=this.uri+",";});str=str.slice(0,-1);return str;}});"use strict";var TreeSelect=Class.extend({init:function(selectIds,tree,initialChoices,callback){this.selectIds=selectIds;this.tree=tree;this.height=selectIds.length;this.callback=callback;this.selected=initialChoices;this._initSelectMenus();this._setupEventHandlers();},_initSelectMenus:function(){var self=this;this._updateSelectMenus(0);$.each(this.selectIds,function(depth,id){$(id+" > option").each(function(index,option){if(option.value===self.selected[depth]){$(id).prop("selectedIndex",index);}});});},_updateSelected:function(depth,newChoice){var nav,selectField,i;this.selected[depth]=newChoice;selectField=function(original,arr){if(original in arr){return original;}
for(var item in arr){return item;}};nav="this.tree";for(i=0;i<this.height;i+=1){if(i>depth){this.selected[i]=selectField(this.selected[i],eval(nav));}
nav+='["'+this.selected[i]+'"]';}
this._updateSelectMenus(depth+1);},_updateSelectMenus:function(startDepth){var select,choice,i,nav,opt,self=this;$.each(this.selectIds,function(depth,id){if(depth>=startDepth){select=$(id);select.empty();nav="self.tree";for(i=0;i<depth;i+=1){nav+='["'+self.selected[i]+'"]';}
for(var choice in eval(nav)){opt=$("<option value='"+choice+"'>"+
choice.replace(/_/,"-")+"</option>");select.append(opt);}
choice=self.selected[depth];choice=choice.replace('.','\\.');select.find("option[value="+choice+"]").prop("selected",true);}});},_value:function(){var nav="this.tree";$.each(this.selected,function(i,choice){nav+='["'+choice+'"]';});return eval(nav);},_setupEventHandlers:function(){var self=this;$.each(this.selectIds,function(i,id){$(id).change(function(e){self._updateSelected(i,this.value);self.callback(self._value());});});}});"use strict";var ImageSelectTool=Class.extend({init:function(){this.active=false;this.vpDomNode=$("#helioviewer-viewport");this.buttons=$("#image-area-select-buttons");this.container=$("#image-area-select-container");this.doneButton=$("#done-selecting-image");this.cancelButton=$("#cancel-selecting-image");this.helpButton=$("#help-selecting-image");this.vpButtons=$("#zoomControls, #center-button, #social-buttons, #fullscreen-btn, #mouse-coords");this._setupHelpDialog();this.x1=null;this.x2=null;this.y1=null;this.y2=null;$(document).bind("enable-select-tool",$.proxy(this.enableAreaSelect,this));},enableAreaSelect:function(event,callback){var imgContainer,body=$("body");if(this.active){this.cleanup();}
else{body.addClass('disable-fullscreen-mode');this.active=true;this.width=this.vpDomNode.width();this.height=this.vpDomNode.height();this.container.show();imgContainer=body.append('<div id="imgContainer"></div>');this.selectArea(callback);}},selectArea:function(callback){var area,self=this;if(this.x1===null){this.x1=this.width/4;this.x2=this.width*3/4;this.y1=this.height/4;this.y2=this.height*3/4;}
area=this.container.imgAreaSelect({instance:true,handles:true,parent:"#imgContainer",x1:self.x1,x2:self.x2,y1:self.y1,y2:self.y2,onInit:function(){self.vpButtons.hide('fast');self.buttons.show();}});$(window).resize(function(){if(self.active){self.cancelButton.click();self.enableAreaSelect(0,callback);}});this.doneButton.click(function(){self.submitSelectedArea(area,callback);});$(document).keypress(function(e){if(e.which===13){self.submitSelectedArea(area,callback);}});this.cancelButton.click(function(){self.cleanup();});},submitSelectedArea:function(area,callback){var selection,visibleCoords,roi;if(area){selection=area.getSelection();this.x1=selection.x1;this.x2=selection.x2;this.y1=selection.y1;this.y2=selection.y2;visibleCoords=helioviewer.getViewportRegionOfInterest();roi={top:visibleCoords.top+selection.y1,left:visibleCoords.left+selection.x1,bottom:visibleCoords.top+selection.y2,right:visibleCoords.left+selection.x2};this.cleanup();callback(roi);}},_setupHelpDialog:function(){this.helpButton.qtip({position:{my:'top right',at:'bottom left'},content:{title:{text:"Help"},text:"Resize by dragging the edges of the selection.<br /> Move the selection by clicking inside "+"and dragging it.<br /> Click and drag outside the selected area to start "+"a new selection.<br /> Click \"OK\" when you have finished to submit."}});},cleanup:function(){this.buttons.hide();this.container.imgAreaSelect({remove:true});this.vpButtons.show('fast');this.container.hide();$('#imgContainer').remove();this.doneButton.unbind('click');this.cancelButton.unbind('click');this.helpButton.qtip("hide");this.active=false;$("body").removeClass('disable-fullscreen-mode');$(document).unbind('keypress').trigger('re-enable-keyboard-shortcuts');}});"use strict";var MediaManagerUI=Class.extend({init:function(type){this._type=type;this._btn=$("#"+type+"-button");this._container=$("#"+type+"-manager-container");this._buildBtns=$("#"+type+"-manager-build-btns");this._fullViewportBtn=$("#"+type+"-manager-full-viewport");this._selectAreaBtn=$("#"+type+"-manager-select-area");this._historyTitle=$("#"+type+"-history-title");this._historyBody=$("#"+type+"-history");this._clearBtn=$("#"+type+"-clear-history-button");this._tooltips=$("#social-buttons div");this._allButtons=$("#movie-button, #screenshot-button");this._allContainers=$(".media-manager-container");this._loadSavedItems();},has:function(id){return this._manager.has(id);},hide:function(){this._container.hide();this._btn.removeClass("active");this._tooltips.qtip("enable");$(".qtip").qtip("hide");},show:function(){this._allContainers.hide();this._allButtons.removeClass("active");this._btn.addClass("active");$(".jGrowl-notification").trigger("jGrowl.close");this._refresh();this._container.show();this._tooltips.qtip("hide").qtip("disable",true);},toggle:function(){if(this._container.is(":visible")){this.hide();}else{this.show();}},_addItem:function(item){var htmlId,html,last,url,name=item.name;htmlId=this._type+"-"+item.id;if(this._type==="movie"){url=Helioviewer.api.replace("api/index.php","")+"?movieId="+item.id;}else{url=Helioviewer.api+"?action=downloadScreenshot&id="+item.id;}
html=$("<div id='"+htmlId+"' class='history-entry'>"+"<a class='text-btn' style='float: left' href='"+url+"'>"+name+"</a>"+"<div class='status'></div>"+"</div>");html.data("id",item.id);this._historyBody.prepend(html);this._buildPreviewTooltip(item);if(this._historyBody.find(".history-entry").length>this._manager._historyLimit){last=this._historyBody.find(".history-entry").last().data('id');this._removeItem(last);}
this._historyTitle.show();},_buildPreviewTooltip:function(item){var self=this;$("#"+this._type+"-"+item.id).qtip({content:{title:{text:item.name},text:self._buildPreviewTooltipHTML(item)},position:{adjust:{x:-10,y:-1},my:"right top",at:"left center"},show:{delay:140}});},_removeItem:function(id){$("#"+this._type+"-"+id).qtip("destroy").unbind().remove();if(this._historyBody.find(".history-entry").length===0){this._historyTitle.hide();}},_loadSavedItems:function(){var self=this;$.each(this._manager.toArray().reverse(),function(i,item){self._addItem(item);});},_refresh:function(){var type=this._type;this._historyBody.find(".qtip").qtip('reposition');$.each(this._manager.toArray(),function(i,item){var status,elapsed;status=$("#"+type+"-"+item.id).find(".status");elapsed=Date.parseUTCDate(item.dateRequested).getElapsedTime();status.html(elapsed);});},_toArcsecCoords:function(pixels,scale){var coordinates={x1:pixels.left,x2:pixels.right,y1:pixels.top,y2:pixels.bottom};return pixelsToArcseconds(coordinates,scale);},_initEvents:function(){var self=this;this._btn.click(function(){if(!self.working){self.toggle();}});this._clearBtn.click(function(){$.each(self._manager.toArray(),function(i,item){self._removeItem(item.id);});self._manager.empty();});},_validateRequest:function(roi,layers){var message;if(roi.bottom-roi.top<50||roi.right-roi.left<50){message="The area you have selected is too small to create a "+
this._type+". Please try again.";$(document).trigger("message-console-warn",[message]);return false;}else if(layers.length===0){message="You must have at least one layer in your "+this._type+". Please try again.";$(document).trigger("message-console-warn",[message]);return false;}
return true;}});"use strict";var MediaManager=Class.extend({init:function(savedItems){this._history=savedItems;if($.support.localStorage){this._historyLimit=20;}else{this._historyLimit=5;}},_getName:function(layerString){var layer,layerArray,observatory,instrument,detector,measurement,currentGroup,name="";layerArray=layerStringToLayerArray(layerString).sort();$.each(layerArray,function(i,layer){layer=extractLayerName(this);if(layer.length==1){name+=', data source '+layer[i];return true;}
else if(layer.length==0){return false}
observatory=layer[0];instrument=layer[1];detector=layer[2];measurement=layer[3];if(currentGroup===instrument||currentGroup===detector){name+="/";}else{if(instrument==="SECCHI"){currentGroup=detector;name+=", "+detector+"-"+
observatory.substr(-1)+" ";}else{currentGroup=instrument;name+=", "+instrument+" ";}}
if(instrument==="LASCO"){name+=detector;}else if(detector.substr(0,3)==="COR"){}else{name+=measurement;}});return name.slice(2);},add:function(item){if(this._history.unshift(item)>this._historyLimit){this._history=this._history.slice(0,this._historyLimit);}
this._save();},get:function(id){var index=null;$.each(this._history,function(i,item){if(item.id===id){index=i;}});return this._history[index];},empty:function(){var self=this;$.each(this._history,function(i,item){self._history[i]=null;});self._history=[];self._save();},has:function(id){var exists=false;$.each(this._history,function(i,item){if(item.id===id){exists=true;}});return exists;},remove:function(id){var self=this;$.each(this._history,function(i,item){if(item.id===id){self._history[i]=null;self._history.splice(i,1);self._save();return;}});},toArray:function(){return $.extend([],this._history);}});"use strict";var MovieManager=MediaManager.extend({init:function(movies){this._super(movies);this.format=$.support.vp8?"webm":"mp4";var self=this;$.each(movies,function(i,movie){if(movie.status<2){self._monitorQueuedMovie(movie.id,Date.parseUTCDate(movie.dateRequested),0);}});},add:function(id,duration,imageScale,layers,events,eventsLabels,scale,scaleType,scaleX,scaleY,dateRequested,startDate,endDate,frameRate,numFrames,x1,x2,y1,y2,width,height,thumbnail,url){var movie={"id":id,"duration":duration,"imageScale":imageScale,"layers":layers,"events":events,"eventsLabels":eventsLabels,"scale":scale,"scaleType":scaleType,"scaleX":scaleX,"scaleY":scaleY,"dateRequested":dateRequested,"startDate":startDate,"endDate":endDate,"frameRate":frameRate,"numFrames":numFrames,"x1":x1,"x2":x2,"y1":y1,"y2":y2,"width":width,"height":height,"ready":true,"name":this._getName(layers),"status":2,"thumbnail":thumbnail,"url":url};this._super(movie);return movie;},queue:function(id,eta,token,imageScale,layers,events,eventsLabels,scale,scaleType,scaleX,scaleY,dateRequested,startDate,endDate,x1,x2,y1,y2){var movie={"id":id,"imageScale":imageScale,"layers":layers,"events":events,"eventsLabels":eventsLabels,"scale":scale,"scaleType":scaleType,"scaleX":scaleX,"scaleY":scaleY,"dateRequested":dateRequested,"startDate":startDate,"endDate":endDate,"x1":x1,"x2":x2,"y1":y1,"y2":y2,"status":0,"token":token,"name":this._getName(layers)};if(this._history.unshift(movie)>this._historyLimit){this._history=this._history.slice(0,this._historyLimit);}
this._monitorQueuedMovie(id,Date.parseUTCDate(dateRequested),token,eta);this._save();return movie;},update:function(id,frameRate,numFrames,startDate,endDate,width,height,thumbnails,url){var movie=this.get(id);$.extend(movie,{"frameRate":frameRate,"numFrames":numFrames,"startDate":startDate,"endDate":endDate,"width":width,"height":height,"status":2,"thumbnail":thumbnails.small,"url":url});delete movie.token;this._save();$(document).trigger("movie-ready",[movie]);this._displayDownloadNotification(movie);},_displayDownloadNotification:function(movie){var jGrowlOpts,message,self=this;jGrowlOpts={sticky:true,header:"Just now",open:function(msg){msg.find(".message-console-movie-ready").data("movie",movie);}};message="<span class='message-console-movie-ready'>"+"Your "+movie.name+" movie is ready! "+"Click here to watch or download it.</span>";$(document).trigger("message-console-log",[message,jGrowlOpts,true,true]);},_monitorQueuedMovie:function(id,dateRequested,token,eta)
{var queryMovieStatus,self=this;queryMovieStatus=function(){var params,callback;callback=function(response){if(!self.has(id)){return;}
if(response.status<2){if((Date.now()-dateRequested)/1000>(24*60*60)){self._abort(id);}
self._monitorQueuedMovie(id,dateRequested,token,60);}else if(response.error){self._abort(id);}else{self.update(id,response.frameRate,response.numFrames,response.startDate,response.endDate,response.width,response.height,response.thumbnails,response.url);}};params={"action":"getMovieStatus","id":id,"token":token,"format":self.format};$.get(Helioviewer.api,params,callback,Helioviewer.dataType);};setTimeout(queryMovieStatus,Math.max(eta,5)*1000);},_abort:function(id){var error,movie=this.get(id);movie["status"]=3;this._save();error="Sorry, we were unable to create the movie you requested. "+"This usually means that there are not enough images for the "+"time range requested. Please try adjusting the observation "+"date or movie duration and try creating a new movie.";$(document).trigger("message-console-error",[error,{"sticky":true}]);},_save:function(){Helioviewer.userSettings.set("history.movies",this._history);}});"use strict";var MovieManagerUI=MediaManagerUI.extend({init:function(movieManager){var movies=Helioviewer.userSettings.get('history.movies');this._manager=new MovieManager(movies);this._super("movie");this._settingsDialog=$("#movie-settings-container");this._advancedSettings=$("#movie-settings-advanced");this._settingsHelp=$("#movie-settings-help");this._settingsForm=$("#movie-settings-form-container");this._settingsConsole=$("#movie-settings-validation-console");this._movieScale=null;this._movieROI=null;this._movieLayers=null;this._movieEvents=null;this._movieEventsLabels=null;this._initEvents();this._initSettings();},playMovie:function(id){var movie=this._manager.get(id);if(movie.status===2){this._createMoviePlayerDialog(movie);}else{return;}},_buildMovieRequest:function(serializedFormParams){var formParams,baseParams,params,frameRate;formParams={};$.each(serializedFormParams,function(i,field){formParams[field.name]=field.value;});this.building=true;if(Helioviewer.userSettings.get("state.eventLayerVisible")===false){this._movieEvents='';this._movieEventsLabels=false;}
baseParams={action:"queueMovie",imageScale:this._movieScale,layers:this._movieLayers,events:this._movieEvents,eventsLabels:this._movieEventsLabels,scale:Helioviewer.userSettings.get("state.scale"),scaleType:Helioviewer.userSettings.get("state.scaleType"),scaleX:Helioviewer.userSettings.get("state.scaleX"),scaleY:Helioviewer.userSettings.get("state.scaleY"),format:this._manager.format};params=$.extend(baseParams,this._movieROI,this._getMovieTimeWindow());if(formParams['speed-method']==="framerate"){frameRate=parseInt(formParams['framerate'],10);if(frameRate<1||frameRate>30){throw"Frame-rate must be between 1 and 30.";}
baseParams['frameRate']=formParams['framerate'];}
else{if(formParams['movie-length']<5||formParams['movie-length']>100){throw"Movie length must be between 5 and 100 seconds.";}
baseParams['movieLength']=formParams['movie-length'];}
this._queueMovie(params);this._advancedSettings.hide();this._settingsDialog.hide();this.building=false;},_getMovieTimeWindow:function(){var movieLength,currentTime,endTime,startTimeStr,endTimeStr,now,diff;movieLength=Helioviewer.userSettings.get("options.movies.duration");currentTime=helioviewer.getDate();endTime=helioviewer.getDate().addSeconds(movieLength/2);now=new Date();diff=endTime.getTime()-now.getTime();currentTime.addSeconds(Math.min(0,-diff/1000));return{"startTime":currentTime.addSeconds(-movieLength/2).toISOString(),"endTime":currentTime.addSeconds(movieLength).toISOString()};},_showMovieSettings:function(roi){if(typeof roi==="undefined"){roi=helioviewer.getViewportRegionOfInterest();}
var layers=helioviewer.getVisibleLayers(roi);var events=helioviewer.getEvents();if(!this._validateRequest(roi,layers)){return;}
this._movieScale=helioviewer.getImageScale();this._movieROI=this._toArcsecCoords(roi,this._movieScale);this._movieLayers=layers;this._movieEvents=events;this._movieEventsLabels=helioviewer.getEventsLabels();this.hide();this._settingsConsole.hide();this._settingsDialog.show();},_queueMovie:function(params){var callback,self=this;callback=function(response){var msg,movie,waitTime;if((response===null)||response.error){if(response.errno===40){msg=response.error;}else{msg="We are unable to create a movie for the time you "+"requested. Please select a different time range "+"and try again.";}
$(document).trigger("message-console-info",msg);return;}else if(response.warning){$(document).trigger("message-console-info",response.warning);return;}
movie=self._manager.queue(response.id,response.eta,response.token,params.imageScale,params.layers,params.events,params.eventsLabels,params.scale,params.scaleType,params.scaleX,params.scaleY,new Date().toISOString(),params.startTime,params.endTime,params.x1,params.x2,params.y1,params.y2);self._addItem(movie);waitTime=humanReadableNumSeconds(response.eta);msg="Your video is processing and will be available in "+"approximately "+waitTime+". You may view it at any "+"time after it is ready by clicking the 'Movie' button";$(document).trigger("message-console-info",msg);};$.get(Helioviewer.api,params,callback,Helioviewer.dataType);},_initEvents:function(){var timer,self=this;this._super();this._fullViewportBtn.click(function(){self.hide();self._showMovieSettings();});this._selectAreaBtn.click(function(){self.hide();$(document).trigger("enable-select-tool",$.proxy(self._showMovieSettings,self));});$("#movie-history .history-entry").live('click',$.proxy(this._onMovieClick,this)).live('mouseover mouseout',$.proxy(this._onMovieHover,this));$(".message-console-movie-ready").live('click',function(event){var movie=$(event.currentTarget).data('movie');self._createMoviePlayerDialog(movie);});$(document).bind("movie-ready",function(event,movie){$("#"+self._type+"-"+movie.id).qtip("destroy");self._buildPreviewTooltip(movie);});$("#youtube-video-info").submit(function(){self.submitVideoUploadForm();return false;});$("#movie-settings-toggle-advanced").click(function(){if(self._settingsHelp.is(":visible")){self._settingsHelp.hide();self._settingsForm.show();return;}
if(self._advancedSettings.is(":visible")){self._advancedSettings.animate({"height":0},function(){self._advancedSettings.hide();});}else{self._advancedSettings.css('height',0).show();self._advancedSettings.animate({"height":85},function(){});}});$("#movie-settings-toggle-help").click(function(){self._settingsForm.toggle();self._settingsHelp.toggle();});},_initSettings:function(){var length,lengthInput,duration,durationSelect,frameRateInput,settingsForm,self=this;frameRateInput=$("#frame-rate");lengthInput=$("#movie-length");durationSelect=$("#movie-duration");$("#speed-method-f").change(function(){lengthInput.attr("disabled",true);frameRateInput.attr("disabled",false);}).attr("checked","checked").change();$("#speed-method-l").change(function(){frameRateInput.attr("disabled",true);lengthInput.attr("disabled",false);});$("#movie-settings-cancel-btn").button().click(function(e){self._advancedSettings.hide();self._settingsDialog.hide();self.show();});settingsForm=$("#movie-settings-form");$("#movie-settings-submit-btn").button().click(function(e){try{self._buildMovieRequest(settingsForm.serializeArray());}catch(ex){self._settingsConsole.text(ex).fadeIn(1000,function(){setTimeout(function(){self._settingsConsole.text(ex).fadeOut(1000);},10000);});}
return false;});duration=Helioviewer.userSettings.get("options.movies.duration"),durationSelect.bind('change',function(e){Helioviewer.userSettings.set("options.movies.duration",parseInt(this.value,10));});frameRateInput.val(15);lengthInput.val(20);durationSelect.find("[value="+duration+"]").attr("selected","selected");},_onMovieClick:function(event){var id,movie,dialog,action;id=$(event.currentTarget).data('id');movie=this._manager.get(id);if(movie.status===2){dialog=$("movie-player-"+id);if(dialog.length>0){action=dialog.dialog('isOpen')?"close":"open";dialog.dialog(action);}else{this._createMoviePlayerDialog(movie);}}
return false;},_onMovieHover:function(event){if(event.type==='mouseover'){}else{}},_buildPreviewTooltipHTML:function(movie){var width,height,thumbnail,html="";if(movie.status===2){if(Helioviewer.api==="api/index.php"){thumbnail=movie.thumbnail.substr(movie.thumbnail.search("cache"));}else{thumbnail=movie.thumbnail;}
html+="<div style='text-align: center;'>"+"<img src='"+thumbnail+"' width='95%' alt='preview thumbnail' /></div>";width=movie.width;height=movie.height;}else{width=Math.round(movie.x2-movie.x1);height=Math.round(movie.y2-movie.y1);}
html+="<table class='preview-tooltip'>"+"<tr><td><b>Start:</b></td><td>"+movie.startDate+"</td></tr>"+"<tr><td><b>End:</b></td><td>"+movie.endDate+"</td></tr>"+"<tr><td><b>Scale:</b></td><td>"+movie.imageScale.toFixed(2)+" arcsec/px</td></tr>"+"<tr><td><b>Dimensions:</b></td><td>"+width+"x"+height+" px</td></tr>"+"</table>";return html;},_createMoviePlayerDialog:function(movie){var dimensions,title,uploadURL,flvURL,swfURL,html,dialog,screenshot,callback,self=this;dimensions=this.getVideoPlayerDimensions(movie.width,movie.height);html=self.getVideoPlayerHTML(movie,dimensions.width,dimensions.height);dialog=$("<div id='movie-player-"+movie.id+"' "+"class='movie-player-dialog'></div>").append(html);dialog.find(".video-download-icon").click(function(){if(typeof(_gaq)!="undefined"){_gaq.push(['_trackEvent','Movies','Download']);}});title=movie.name+" ("+movie.startDate+" - "+
movie.endDate+" UTC)";dialog.dialog({title:"Movie Player: "+title,width:((dimensions.width<575)?600:dimensions.width+25),height:dimensions.height+80,resizable:$.support.h264||$.support.vp8,close:function(){$(this).empty();},zIndex:9999,show:'fade'});$('#youtube-upload-'+movie.id).click(function(){self.showYouTubeUploadDialog(movie);return false;});$('#video-link-'+movie.id).click(function(){if(!($.support.h264||$.support.vp8)){$(".movie-player-dialog").dialog("close");}
helioviewer.displayMovieURL(movie.id);return false;});flvURL=Helioviewer.api+"/?action=downloadMovie&format=flv&id="+movie.id;swfURL=Helioviewer.root+"/lib/flowplayer/flowplayer-3.2.8.swf?config="+
encodeURIComponent("{'clip':{'url': '../../"+flvURL+"'}}");screenshot=movie.thumbnail.substr(0,movie.thumbnail.length-9)+"full.png";},showYouTubeUploadDialog:function(movie){var title,tags,url1,url2,description;title=movie.name+" ("+movie.startDate+" - "+
movie.endDate+" UTC)";tags=[];$.each(movie.layers.split("],["),function(i,layerStr){var parts=layerStr.replace(']',"").replace('[',"").split(",").slice(0,4);$.each(parts,function(i,item){if($.inArray(item,tags)===-1){tags.push(item);}});});url1=Helioviewer.root+"/?movieId="+movie.id;url2=Helioviewer.root+"/api/?action=downloadMovie&id="+movie.id+"&format=mp4&hq=true";description="This movie was produced by Helioviewer.org. See the "+"original at "+url1+" or download a high-quality "+"version from "+url2;$("#youtube-title").val(title);$("#youtube-tags").val(tags);$("#youtube-desc").val(description);$("#youtube-movie-id").val(movie.id);$(".movie-player-dialog").dialog("close");$("#upload-dialog").dialog({"title":"Upload video to YouTube","width":550,"height":440});},submitVideoUploadForm:function(event){var params,successMsg,uploadDialog,url,form,loader,callback,self=this;try{this._validateVideoUploadForm();}catch(ex){this._displayValidationErrorMsg(ex);return false;}
$("#upload-error-console").hide();form=$("#upload-form").hide();loader=$("#youtube-auth-loading-indicator").show();callback=function(auth){loader.hide();form.show();url=Helioviewer.api+"?"+$("#youtube-video-info").serialize();if(auth){$.get(url,{"action":"uploadMovieToYouTube"},function(response){if(response.error){self.hide();$(document).trigger("message-console-warn",[response.error]);}},"json");}else{window.open(url+"&action=getYouTubeAuth","_blank");}
$("#upload-dialog").dialog("close");return false;}
$.ajax({url:Helioviewer.api+"?action=checkYouTubeAuth",dataType:Helioviewer.dataType,success:callback});},_displayValidationErrorMsg:function(ex){var errorConsole=$("#upload-error-console");errorConsole.html("<b>Error:</b> "+ex).fadeIn(function(){window.setTimeout(function(){errorConsole.fadeOut();},15000);});},_validateVideoUploadForm:function(){var keywords=$("#youtube-tags").val(),keywordMinLength=2,keywordMaxLength=30;if($("#youtube-title").val().length===0){throw"Please specify a title for the movie.";}
if(keywords.length===0){throw"You must specifiy at least one tag for your video.";}
$.each(keywords.split(","),function(i,keyword){var len=$.trim(keyword).length;if(len>keywordMaxLength){throw"YouTube tags must not be longer than "+
keywordMaxLength+" characters each.";}else if(len<keywordMinLength){throw"YouTube tags must be at least "+keywordMinLength+" characters each.";}
return;});$.each($("#youtube-video-info input[type='text'], "+"#youtube-video-info textarea"),function(i,input){if($(input).val().match(/[<>]/)){throw"< and > characters are not allowed";}
return;});},addMovieUsingId:function(id){var callback,params,movie,self=this;callback=function(response){if(response.status===2){movie=self._manager.add(id,response.duration,response.imageScale,response.layers,response.events,response.eventsLabels,response.scale,response.scaleType,response.scaleX,response.scaleY,response.timestamp.replace(" ","T")+".000Z",response.startDate,response.endDate,response.frameRate,response.numFrames,response.x1,response.x2,response.y1,response.y2,response.width,response.height,response.thumbnails.small,response.url);self._addItem(movie);self._createMoviePlayerDialog(movie);}};params={"action":"getMovieStatus","id":id,"format":self._manager.format,"verbose":true};$.get(Helioviewer.api,params,callback,Helioviewer.dataType);},getVideoPlayerDimensions:function(width,height){var maxWidth=$(window).width()*0.80,maxHeight=$(window).height()*0.80,scaleFactor=Math.max(1,width/maxWidth,height/maxHeight);return{"width":Math.floor(width/scaleFactor),"height":Math.floor(height/scaleFactor)};},getVideoPlayerHTML:function(movie,width,height){var downloadURL,downloadLink,youtubeBtn,linkBtn,linkURL,tweetBtn,facebookBtn;downloadURL=Helioviewer.api+"?action=downloadMovie&id="+movie.id+"&format=mp4&hq=true";downloadLink="<div style='float:left;'><a target='_parent' href='"+downloadURL+"' title='Download high-quality video'>"+"<img style='width:93px; height:32px;' class='video-download-icon' "+"src='resources/images/download_93x32.png' /></a></div>";youtubeBtn='<div style="float:left;"><a id="youtube-upload-'+movie.id+'" href="#" '+'target="_blank"><img class="youtube-icon" '+'title="Upload video to YouTube" style="width:79px;height:32px;" '+'src="resources/images/youtube_79x32.png" /></a></div>';linkURL=helioviewer.serverSettings.rootURL+"/?movieId="+movie.id;linkBtn="<div style='float:left;'><a id='video-link-"+movie.id+"' href='"+linkURL+"' title='Get a link to the movie' "+"target='_blank'><img class='video-link-icon' "+"style='width:79px; height:32px;' "+"src='resources/images/link_79x32.png' /></a></div>";tweetBtn='<div style="float:right;"><a href="https://twitter.com/share" class="twitter-share-button" data-related="helioviewer" data-lang="en" data-size="medium" data-count="horizontal" data-url="http://'+document.domain+'/?movieId='+movie.id+'" data-text="Movie of the Sun created on Helioviewer.org:" data-hashtags="helioviewer" data-related="helioviewer">Tweet</a><script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></div>';facebookBtn='<div style="float:right;"><iframe src="//www.facebook.com/plugins/like.php?href='+encodeURIComponent('http://'+document.domain+'/?movieId='+movie.id)+'&amp;width=90&amp;height=21&amp;colorscheme=dark&amp;layout=button_count&amp;action=like&amp;show_faces=false&amp;send=false&amp;appId=6899099925" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:21px; width:90px;" allowTransparency="false"></iframe></div>';if($.support.vp8||$.support.h264){url=movie.url.substr(movie.url.search("cache"));return'<div><video id="movie-player-'+movie.id+'" src="'+url+'" controls preload autoplay'+' style="width:100%; height: 90%;"></video></div>'+'<div style="width:100%"><div style="float:left;" class="video-links">'+
youtubeBtn+linkBtn+downloadLink+'</div> <div style="float:right;">'+facebookBtn+
tweetBtn+'</div></div>';}
else{var url=Helioviewer.api+'?action=playMovie&id='+movie.id+'&width='+width+"&height="+height+'&format=flv';return'<div id="movie-player-'+movie.id+'">'+'<iframe src="'+url+'" width="'+width+'" height="'+height+'" marginheight="0" marginwidth="0" '+'scrolling="no" frameborder="0" style="width: 100%; margin-bottom: 2px;" />'+'</div>'+'<div style="width:100%;">'+'<div style="float:left;" class="video-links">'+
youtubeBtn+linkBtn+downloadLink+'</div>'+'<div style="float:right;">'+facebookBtn+tweetBtn+'</div>';}},_refresh:function(){var status,elapsedTime;$.each(this._manager.toArray(),function(i,item){status=$("#movie-"+item.id).find(".status");if(item.status===2){elapsedTime=Date.parseUTCDate(item.dateRequested).getElapsedTime();status.html(elapsedTime);}else if(item.status===3){status.html("<span style='color:LightCoral;'>Error</span>");}else{status.html("<span class='processing'>Processing</span>");}});},_validateRequest:function(roi,layerString){var layers,visibleLayers,message;layers=layerStringToLayerArray(layerString);visibleLayers=$.grep(layers,function(layer,i){var parts=layer.split(",");return(parts[4]==="1"&&parts[5]!=="0");});if(visibleLayers.length>3){message="Movies cannot have more than three layers. "+"Please hide/remove layers until there are no more "+"than three layers visible.";$(document).trigger("message-console-warn",[message]);return false;}
return this._super(roi,layerString);}});"use strict";var ScreenshotManager=MediaManager.extend({init:function(screenshots){this._super(screenshots);},add:function(id,imageScale,layers,dateRequested,date,x1,x2,y1,y2){var screenshot={"id":id,"imageScale":imageScale,"layers":layers,"dateRequested":dateRequested,"date":date,"x1":x1,"x2":x2,"y1":y1,"y2":y2,"name":this._getName(layers)};this._super(screenshot);return screenshot;},_save:function(){Helioviewer.userSettings.set("history.screenshots",this._history);}});"use strict";var ScreenshotManagerUI=MediaManagerUI.extend({init:function(){var screenshots=Helioviewer.userSettings.get('history.screenshots');this._manager=new ScreenshotManager(screenshots);this._super("screenshot");this._initEvents();},getScreenshotURL:function(){var roi,imageScale,layers,params;imageScale=helioviewer.getImageScale();roi=helioviewer.getViewportRegionOfInterest();layers=this._checkLayers(helioviewer.getLayers());if(!this._validateRequest(roi,layers)){return;}
params=$.extend({action:"takeScreenshot",imageScale:imageScale,layers:layers,date:helioviewer.getDate().toISOString(),display:true},this._toArcsecCoords(roi,imageScale));return Helioviewer.api+"?"+$.param(params);},_displayDownloadNotification:function(screenshot){var jGrowlOpts,body,self=this;jGrowlOpts={sticky:true,header:"Just now"};body="<a href='"+Helioviewer.api+"?action=downloadScreenshot&id="+
screenshot.id+"'>Your "+screenshot.name+" screenshot is ready! Click here to download. </a>";$(document).trigger("message-console-log",[body,jGrowlOpts,true,true]);},_initEvents:function(){var self=this;this._super();this._fullViewportBtn.click(function(){self.hide();self._takeScreenshot();});this._selectAreaBtn.click(function(){self.hide();$(document).trigger("enable-select-tool",$.proxy(self._takeScreenshot,self));});$("#screenshot-history .history-entry").live('click',$.proxy(this._onScreenshotClick,this));},_buildPreviewTooltipHTML:function(screenshot){var width,height,date,html;width=Math.round((screenshot.x2-screenshot.x1)/screenshot.imageScale);height=Math.round((screenshot.y2-screenshot.y1)/screenshot.imageScale);date=screenshot.date.substr(0,19).replace(/T/," ");html="<div style='text-align: center;'>"+"<img src='"+Helioviewer.api+"?action=downloadScreenshot&id="+screenshot.id+"' alt='preview thumbnail' class='screenshot-preview' /></div>"+"<table class='preview-tooltip'>"+"<tr><td><b>Date:</b></td><td>"+date+"</td></tr>"+"<tr><td><b>Scale:</b></td><td>"+
screenshot.imageScale.toFixed(2)+" arcsec/px</td></tr>"+"<tr><td><b>Dimensions:</b></td><td>"+width+"x"+height+" px</td></tr>"+"</table>";return html;},_onScreenshotClick:function(event){var id=$(event.currentTarget).data('id'),url=Helioviewer.api+"?action=downloadScreenshot&id="+id;window.open(url,'_parent');return false;},_takeScreenshot:function(roi){var params,dataType,imageScale,layers,events,eventLabels,scale,scaleType,scaleX,scaleY,screenshot,self=this;if(typeof roi==="undefined"){roi=helioviewer.getViewportRegionOfInterest();}
imageScale=helioviewer.getImageScale();layers=helioviewer.getVisibleLayers(roi);events=helioviewer.getEvents();if(Helioviewer.userSettings.get("state.eventLayerVisible")===false){events='';eventLabels=false;}
if(!this._validateRequest(roi,layers)){return;}
params=$.extend({action:"takeScreenshot",imageScale:imageScale,layers:layers,events:events,eventLabels:Helioviewer.userSettings.get("state.eventLabels"),scale:Helioviewer.userSettings.get("state.scale"),scaleType:Helioviewer.userSettings.get("state.scaleType"),scaleX:Helioviewer.userSettings.get("state.scaleX"),scaleY:Helioviewer.userSettings.get("state.scaleY"),date:helioviewer.getDate().toISOString(),display:false},this._toArcsecCoords(roi,imageScale));$.get(Helioviewer.api,params,function(response){if((response===null)||response.error){$(document).trigger("message-console-info","Unable to create screenshot. Please try again later.");return;}
screenshot=self._manager.add(response.id,params.imageScale,params.layers,new Date().toISOString(),params.date,params.x1,params.x2,params.y1,params.y2);self._addItem(screenshot);self._displayDownloadNotification(screenshot);},Helioviewer.dataType);}});"use strict";var TileLayerAccordion=Layer.extend({init:function(containerId,dataSources,observationDate){this.container=$(containerId);this._dataSources=dataSources;this._observationDate=observationDate;this._maximumTimeDiff=12*60*60*1000;this.options={};this._setupUI();this.domNode=$('#TileLayerAccordion-Container');this.domNode.dynaccordion({startClosed:true});$(document).bind("create-tile-layer-accordion-entry",$.proxy(this.addLayer,this)).bind("update-tile-layer-accordion-entry",$.proxy(this._updateAccordionEntry,this)).bind("observation-time-changed",$.proxy(this._onObservationTimeChange,this));this.container.delegate("span[title]",'mouseover',function(event){$(this).qtip({overwrite:false,show:{event:event.type,ready:true}},event);}).each(function(i){$.attr(this,'oldtitle',$.attr(this,'title'));this.removeAttribute('title');});},addLayer:function(event,index,id,name,observatory,instrument,detector,measurement,date,startOpened,opacity,visible,onOpacityChange){if(typeof(index)==="undefined"){index=1000;}
this._createAccordionEntry(index,id,name,visible,startOpened);this._initTreeSelect(id,observatory,instrument,detector,measurement);this._initOpacitySlider(id,opacity,onOpacityChange);this._setupEventHandlers(id);this._updateTimeStamp(id,date);},_createAccordionEntry:function(index,id,name,visible,startOpened){var visibilityBtn,removeBtn,hidden,head,body;hidden=(visible?"":" hidden");visibilityBtn="<span class='layerManagerBtn visible"+hidden+"' id='visibilityBtn-"+id+"' title='Toggle layer visibility'></span>";removeBtn="<span class='ui-icon ui-icon-closethick removeBtn' id='removeBtn-"+id+"' title='Remove layer'></span>";head="<div class='layer-Head ui-accordion-header ui-helper-reset ui-state-default ui-corner-all shadow'>"+"<span class=tile-accordion-header-left>"+name+"</span><span class=tile-accordion-header-right><span class=timestamp></span>"+"<span class=accordion-header-divider>|</span>"+visibilityBtn+removeBtn+"</span></div>";body=this._buildEntryBody(id);this.domNode.dynaccordion("addSection",{id:id,header:head,cell:body,index:index,open:startOpened});},_initTreeSelect:function(id,observatory,instrument,detector,measurement){var ids,selected,obs,inst,det,meas;obs="#observatory-select-"+id;inst="#instrument-select-"+id;det="#detector-select-"+id;meas="#measurement-select-"+id;ids=[obs,inst,det,meas];selected=[observatory,instrument,detector,measurement];this.selectMenus=new TreeSelect(ids,this._dataSources,selected,function(leaf){$(document).trigger("tile-layer-data-source-changed",[id,$(obs).prop("value"),$(inst).prop("value"),$(det).prop("value"),$(meas).prop("value"),leaf.sourceId,leaf.nickname,leaf.layeringOrder]);});},_initOpacitySlider:function(id,opacity,onOpacityChange){$("#opacity-slider-track-"+id).slider({value:opacity,min:0,max:100,slide:function(e,ui){if((ui.value%2)===0){onOpacityChange(ui.value);}},change:function(e,ui){onOpacityChange(ui.value);$(document).trigger("save-tile-layers");}});},_buildEntryBody:function(id){var opacitySlide,obs,inst,det,meas,jp2,info;opacitySlide="<div class='layer-select-label'>Opacity: </div>";opacitySlide+="<div class='opacity-slider-track' id='opacity-slider-track-"+id;opacitySlide+="' style='width: 120px; height: 8px;'>";opacitySlide+="</div>";obs="<div class=layer-select-label>Observatory: </div> ";obs+="<select name=observatory class=layer-select id='observatory-select-"+id+"'></select>";inst="<div class=layer-select-label>Instrument: </div> ";inst+="<select name=instrument class=layer-select id='instrument-select-"+id+"'></select>";det="<div class=layer-select-label>Detector: </div> ";det+="<select name=detector class=layer-select id='detector-select-"+id+"'></select>";meas="<div class=layer-select-label>Measurement: </div> ";meas+="<select name=measurement class=layer-select id='measurement-select-"+id+"'>";meas+="</select><br><br>";jp2="<span id='image-"+id+"-download-btn'"+" class='image-download-btn ui-icon ui-icon-image'"+" title='Download original grayscale JPEG 2000 image'></span>";info="<span id='image-"+id+"-info-btn'"+" class='image-info-dialog-btn ui-icon ui-icon-info'"+" title='Display image header'></span>";return(opacitySlide+obs+inst+det+meas+jp2+info);},_setupUI:function(){var title,addLayerBtn;title=$('<span class="section-header">Images</span>').css({'float':'left'});addLayerBtn=$('<a href=# class=dark>[Add]</a>').css({'margin-right':'14px'});this.container.append($('<div></div>').css('text-align','right').append(title).append(addLayerBtn));this.container.append($('<div id="TileLayerAccordion-Container"></div>'));addLayerBtn.click(function(){$(document).trigger("add-new-tile-layer");});},_setupEventHandlers:function(id){var toggleVisibility,opacityHandle,removeLayer,self=this,visibilityBtn=$("#visibilityBtn-"+id),removeBtn=$("#removeBtn-"+id);toggleVisibility=function(e){$(document).trigger("toggle-layer-visibility",[id]);$("#visibilityBtn-"+id).toggleClass('hidden');e.stopPropagation();};removeLayer=function(e){$(document).trigger("remove-tile-layer",[id]);self._removeTooltips(id);self.domNode.dynaccordion('removeSection',{id:id});$(document).trigger("save-tile-layers");e.stopPropagation();};opacityHandle=$("#"+id+" .ui-slider-handle")[0];assignTouchHandlers(opacityHandle);visibilityBtn.bind('click',this,toggleVisibility);removeBtn.bind('click',removeLayer);},_showImageInfoDialog:function(id,name,imageId){var params,dtype,self=this,dialog=$("#image-info-dialog-"+id);if(dialog.length!==0){if(!dialog.dialog("isOpen")){dialog.dialog("open");}
else{dialog.dialog("close");}
return;}
params={action:"getJP2Header",id:imageId};if(Helioviewer.dataType==="jsonp"){dtype="jsonp text xml";}else{dtype="xml";}
$.get(Helioviewer.api,params,function(response){self._buildImageInfoDialog(name,id,response);},dtype);},_buildImageInfoDialog:function(name,id,response){var dialog,sortBtn,tabs,html,tag,json;json=$.xml2json(response);dialog=$("<div id='image-info-dialog-"+id+"' class='image-info-dialog' />");html="<div class='image-info-dialog-menu'>"+"<a class='show-fits-tags-btn selected'>[FITS]</a>"+"<a class='show-helioviewer-tags-btn'>Helioviewer</a>"+"<span class='image-info-sort-btn'>Abc</span>"+"</div>";if(!json.helioviewer){json.helioviewer={};$.each(json.fits,function(key,value){if(key.substring(0,3)==="HV_"){json.helioviewer[key.slice(3)]=value;delete json.fits[key];}});}
html+="<div class='image-header-fits'>"+this._generateImageKeywordsSection(json.fits)+"</div>"+"<div class='image-header-helioviewer' style='display:none;'>"+
this._generateImageKeywordsSection(json.helioviewer)+"</div>";dialog.append(html).appendTo("body").dialog({autoOpen:true,title:"Image Information: "+name,minWidth:546,width:546,height:350,draggable:true,create:function(event,ui){var fitsBtn=dialog.find(".show-fits-tags-btn"),hvBtn=dialog.find(".show-helioviewer-tags-btn"),sortBtn=dialog.find(".image-info-sort-btn");fitsBtn.click(function(){fitsBtn.html("[FITS]");hvBtn.html("Helioviewer");dialog.find(".image-header-fits").show();dialog.find(".image-header-helioviewer").hide();});hvBtn.click(function(){fitsBtn.html("FITS");hvBtn.html("[Helioviewer]");dialog.find(".image-header-fits").hide();dialog.find(".image-header-helioviewer").show();});sortBtn.click(function(){var sorted=!$(this).hasClass("italic");$(this).toggleClass("italic");if(sorted){dialog.find(".unsorted").css('display','none');dialog.find(".sorted").css('display','block');}else{dialog.find(".sorted").css('display','none');dialog.find(".unsorted").css('display','block');}});}});},_generateImageKeywordsSection:function(list){var unsorted,sortFunction,sorted,tag,tags=[];unsorted="<div class='unsorted'>";$.each(list,function(key,value){tag="<span class='image-header-tag'>"+key+": </span>"+"<span class='image-header-value'>"+value+"</span>";tags.push(tag);unsorted+=tag+"<br>";});unsorted+="</div>";sortFunction=function(a,b){if(a.slice(31)<b.slice(31)){return-1;}else if(a.slice(31)>b.slice(31)){return 1;}
return 0;};sorted="<div class='sorted' style='display: none;'>";$.each(tags.sort(sortFunction),function(){sorted+=this+"<br>";});sorted+="</div>";return unsorted+sorted;},_removeTooltips:function(id){$("#"+id+" *[oldtitle]").qtip("destroy");},_onObservationTimeChange:function(event,requestDate){var actualDate,weight,domNode,self=this;this._observationDate=requestDate;$("#TileLayerAccordion-Container .timestamp").each(function(i,item){domNode=$(this);actualDate=new Date(getUTCTimestamp(domNode.text()));weight=self._getScaledTimeDifference(actualDate,requestDate);domNode.css("color",self._chooseTimeStampColor(weight,0,0,0));});},_updateAccordionEntry:function(event,id,name,opacity,date,imageId){var entry=$("#"+id),self=this;this._updateTimeStamp(id,date);entry.find(".tile-accordion-header-left").html(name);$("#image-info-dialog-"+id).remove();entry.find("#image-"+id+"-info-btn").unbind().bind('click',function(){self._showImageInfoDialog(id,name,imageId);});$("#image-"+id+"-download-btn").unbind().bind('click',function(){window.open(Helioviewer.api+"?action=getJP2Image&id="+imageId);return false;});},_updateTimeStamp:function(id,date){var weight=this._getScaledTimeDifference(date,this._observationDate);$("#"+id).find('.timestamp').html(date.toUTCDateString()+" "+date.toUTCTimeString()).css("color",this._chooseTimeStampColor(weight,0,0,0));},_getScaledTimeDifference:function(t1,t2){return Math.min(1,Math.abs(t1.getTime()-t2.getTime())/this._maximumTimeDiff);},_chooseTimeStampColor:function(w,rOffset,gOffset,bOffset){var r=Math.min(255,rOffset+parseInt(2*w*255,10)),g=Math.min(255,gOffset+parseInt(2*255*(1-w),10)),b=bOffset+0;return"rgb("+r+","+g+","+b+")";}});"use strict";var EventLayerAccordion=Layer.extend({init:function(containerId,eventTypes,date){this.container=$(containerId);this._eventTypes=eventTypes;this._date=date;this._maximumTimeDiff=12*60*60*1000;this.options={};this._setupUI();this.domNode=$('#EventLayerAccordion-Container');this.domNode.dynaccordion({startClosed:true});$(document).bind("create-event-layer-accordion-entry",$.proxy(this.addLayer,this)).bind("update-event-layer-accordion-entry",$.proxy(this._updateAccordionEntry,this)).bind("observation-time-changed",$.proxy(this._onObservationTimeChange,this));this.container.delegate("span[title]",'mouseover',function(event){$(this).qtip({overwrite:false,show:{event:event.type,ready:true}},event);}).each(function(i){$.attr(this,'oldtitle',$.attr(this,'title'));this.removeAttribute('title');});},addLayer:function(event,index,id,name,date,startOpened,markersVisible,labelsVisible){this._createAccordionEntry(index,id,name,markersVisible,labelsVisible,startOpened);this._setupEventHandlers(id);this._updateTimeStamp(id,date);},_createAccordionEntry:function(index,id,name,markersVisible,labelsVisible,startOpened){var visibilityBtn,labelsBtn,markersHidden,labelsHidden,head,body,self=this;markersHidden=(markersVisible?"":" hidden");labelsHidden=(labelsVisible?"":" hidden");visibilityBtn="<span class='layerManagerBtn visible"+markersHidden+"' id='visibilityBtn-"+id+"' title='Toggle visibility of event marker pins'></span>";labelsBtn="<span class='labelsBtn"+labelsHidden+"' id='labelsBtn-"+id+"' title='Toggle event labels'></span>";head="<div class='layer-Head ui-accordion-header ui-helper-reset ui-state-default ui-corner-all shadow'>"+"<span class=tile-accordion-header-left>"+name+"</span><span class=tile-accordion-header-right><span class='timestamp'></span>"+"<span class=accordion-header-divider>|</span>"+visibilityBtn+labelsBtn+"</span></div>";body='<div id="eventJSTree" style="margin-bottom: 5px;"></div>';body+='<div id="checkboxBtn-On-'+id+'" title="Toggle All Event Checkboxes On" style="display: inline-block; font-size: 10px; margin-right: 10px;"><div class="ui-icon ui-icon-circlesmall-plus" style="display: inline-block; vertical-align: middle; margin-bottom: 2px;"></div>check all</div>';body+='<div id="checkboxBtn-Off-'+id+'" title="Toggle All Event Checkboxes Off" style="display: inline-block; font-size: 10px;"><div class="ui-icon ui-icon-circlesmall-minus" style="display: inline-block; vertical-align: middle; margin-bottom: 2px;"></div>check none</div>';this.domNode.dynaccordion("addSection",{id:id,header:head,cell:body,index:index,open:startOpened});this.getEventGlossary();this.domNode.find("#checkboxBtn-"+id).click(function(){$(document).trigger("toggle-checkboxes");});this.domNode.find("#checkboxBtn-On-"+id).click(function(){$(document).trigger("toggle-checkboxes-to-state",['on']);});this.domNode.find("#checkboxBtn-Off-"+id).click(function(){$(document).trigger("toggle-checkboxes-to-state",['off']);});this.domNode.find("#labelsBtn-"+id).click(function(e){$(document).trigger("toggle-event-labels",[$("#labelsBtn-"+id)]);e.stopPropagation();});},getEventGlossary:function(){var params={"action":"getEventGlossary"};$.get("api/index.php",params,$.proxy(this._setEventGlossary,this),"json");},_setEventGlossary:function(response){this._eventManager=new EventManager(response,this._date);},_setupUI:function(){var title,addLayerBtn;title=$('<span class="section-header">Solar Features & Events</span>');this.container.append($('<div></div>').append(title));this.container.append($('<div id="EventLayerAccordion-Container"></div>'));},_setupEventHandlers:function(id){var toggleVisibility,opacityHandle,removeLayer,visState,self=this,visibilityBtn=$("#visibilityBtn-"+id);toggleVisibility=function(e){var domNode;domNode=$(document).find("#event-container");if(domNode.css('display')=='none'){domNode.show();Helioviewer.userSettings.set("state.eventLayerVisible",true);$("#visibilityBtn-"+id).removeClass('hidden');}
else{domNode.hide();Helioviewer.userSettings.set("state.eventLayerVisible",false);$("#visibilityBtn-"+id).addClass('hidden');}
e.stopPropagation();};visibilityBtn.bind('click',this,toggleVisibility);},_removeTooltips:function(id){$("#"+id+" *[oldtitle]").qtip("destroy");},_onObservationTimeChange:function(event,requestDate){var actualDate,weight,domNode,self=this;this._date=requestDate;this._eventManager.updateRequestTime();$("#EventLayerAccordion-Container .timestamp").each(function(i,item){domNode=$(this);domNode.html(self._date.toUTCDateString()+" "+self._date.toUTCTimeString()).css("color",self._chooseTimeStampColor(0,0,0,0));});},_updateAccordionEntry:function(event,id,name,opacity,date,imageId){var entry=$("#"+id),self=this;this._updateTimeStamp(id,date);entry.find(".tile-accordion-header-left").html(name);},_updateTimeStamp:function(id,date){var weight=this._getScaledTimeDifference(date,this._date);$("#"+id).find('.timestamp').html(date.toUTCDateString()+" "+date.toUTCTimeString()).css("color",this._chooseTimeStampColor(weight,0,0,0));},_getScaledTimeDifference:function(t1,t2){return Math.min(1,Math.abs(t1.getTime()-t2.getTime())/this._maximumTimeDiff);},_chooseTimeStampColor:function(w,rOffset,gOffset,bOffset){var r=Math.min(255,rOffset+parseInt(2*w*255,10)),g=Math.min(255,gOffset+parseInt(2*255*(1-w),10)),b=bOffset+0;return"rgb("+r+","+g+","+b+")";}});"use strict";var MessageConsole=Class.extend({init:function(){this._setupEventHandlers();this._defaults={"life":15000}},log:function(msg,options){options=$.extend(this._defaults,options);$("#message-console").jGrowl(msg,options);},info:function(msg,options){options=$.extend(this._defaults,options);$("#message-console").jGrowl(msg,options);},warn:function(msg,options){options=$.extend(this._defaults,options);$("#message-console").jGrowl(msg,options);},error:function(msg,options){options=$.extend(this._defaults,options);$("#message-console").jGrowl(msg,options);},_setupEventHandlers:function(){var events,self=this;events="message-console-log message-console-info message-console-warn message-console-error";$(document).bind(events,function(event,msg,options,showElapsedTime,easyClose){if(typeof options==="undefined"){options={};}
if(typeof showElapsedTime==="undefined"){showElapsedTime=false;}
if(typeof easyClose==="undefined"){easyClose=false;}
if(showElapsedTime){var id,header,headerText,i=1;options=$.extend(options,{beforeOpen:function(elem,message,opts){header=elem.find(".jGrowl-header");id=window.setInterval(function(){if(i===1){headerText="1 minute ago";}else if(i<60){headerText=i+" minutes ago";}else if(i<1440){headerText=parseInt(i/60,10)+" hours ago";}else{headerText="A long time ago...";}
header.text(headerText);i+=1;},60000);elem.data("timerId",id);},close:function(elem,message){window.clearInterval(elem.data("timerId"));}});}
if(easyClose){options=$.extend(options,{afterOpen:function(msg){msg.click(function(e){msg.trigger("jGrowl.close");});}});}
if(event.type==="message-console-log"){self.log(msg,options);}else if(event.type==="message-console-info"){self.info(msg,options);}else if(event.type==="message-console-warn"){self.warn(msg,options);}else if(event.type==="message-console-error"){self.error(msg,options);}});}});"use strict";var TimeControls=Class.extend({init:function(dateInput,timeInput,incrementSelect,backBtn,forwardBtn,urlDate){if(typeof urlDate==="undefined"){urlDate=false;}
this._setInitialDate(urlDate);this._timeIncrement=Helioviewer.userSettings.get("state.timeStep");this._timer;this._dateInput=$(dateInput);this._timeInput=$(timeInput);this._backBtn=$(backBtn);this._forwardBtn=$(forwardBtn);this._incrementSelect=$(incrementSelect);this._addTimeIncrements();this._updateInputFields();this._initDatePicker();this._initEventHandlers();},getDate:function(){return new Date(this._date.getTime());},getTimestamp:function(){return this._date.getTime();},getDateField:function(){return this._dateInput.val();},getTimeField:function(){return this._timeInput.val();},getTimeIncrement:function(){return this._timeIncrement;},goToPresent:function(){var dataType,callback,layers,date,mostRecent=new Date(0,0,0),self=this;callback=function(dataSources){layers=[];$(".tile-accordion-header-left").each(function(){layers.push($(this).html());});$.each(dataSources,function(observatory,instruments){$.each(instruments,function(inst,detectors){$.each(detectors,function(det,measurements){$.each(measurements,function(meas,properties){if($.inArray(this.nickname,layers)===-1){return true;}
date=Date.parseUTCDate(this.end);if(date>mostRecent){mostRecent=date;}});});});});self.setDate(mostRecent);};$.get(Helioviewer.api,{action:"getDataSources"},callback,Helioviewer.dataType);},setDate:function(date){this._date=date;this._onDateChange();},enableAutoRefresh:function(){this._timer=setInterval($.proxy(this.goToPresent,this),300000);},disableAutoRefresh:function(){clearInterval(this._timer);},_setInitialDate:function(urlDate){if(urlDate){this._date=urlDate;}else if(Helioviewer.userSettings.get("options.date")==="latest"){this._date=new Date(+new Date());}else{this._date=new Date(Helioviewer.userSettings.get("state.date"));}
Helioviewer.userSettings.set("state.date",this._date.getTime());},timePrevious:function(){this._addSeconds(-this._timeIncrement);},timeNext:function(){this._addSeconds(this._timeIncrement);},toISOString:function(){return this._date.toISOString();},_initEventHandlers:function(){this._backBtn.bind('click',$.proxy(this.timePrevious,this));this._forwardBtn.bind('click',$.proxy(this.timeNext,this));this._timeInput.bind('change',$.proxy(this._onTextFieldChange,this));this._dateInput.bind('change',$.proxy(this._onTextFieldChange,this));$("#timeNowBtn").click($.proxy(this.goToPresent,this));$(document).bind('timestep-backward',$.proxy(this.timePrevious,this)).bind('timestep-forward',$.proxy(this.timeNext,this));},_addSeconds:function(seconds){this._date.addSeconds(seconds);this._onDateChange();},_addTimeIncrements:function(){var timeSteps,select,opt;timeSteps=[{numSecs:1,txt:"1&nbsp;Sec"},{numSecs:60,txt:"1&nbsp;Min"},{numSecs:300,txt:"5&nbsp;Mins"},{numSecs:900,txt:"15&nbsp;Mins"},{numSecs:3600,txt:"1&nbsp;Hour"},{numSecs:21600,txt:"6&nbsp;Hours"},{numSecs:43200,txt:"12&nbsp;Hours"},{numSecs:86400,txt:"1&nbsp;Day"},{numSecs:604800,txt:"1&nbsp;Week"},{numSecs:2419200,txt:"28&nbsp;Days"},{numSecs:31556926,txt:"1&nbsp;Year"}];select=this._incrementSelect;$(timeSteps).each(function(i,timestep){opt=$("<option value='"+timestep.numSecs+"'>"+timestep.txt+"</option>");select.append(opt);});select.bind('change',$.proxy(this._onTimeIncrementChange,this)).find("[value = "+this._timeIncrement+"]").attr("selected","selected");},_initDatePicker:function(){var btnId,btn,self=this;this.cal=this._dateInput.datepicker({buttonImage:'resources/images/blackGlass/calendar_small.png',buttonImageOnly:true,buttonText:"Select a date.",changeYear:true,dateFormat:'yy/mm/dd',mandatory:true,showOn:'button',yearRange:'1990:'+String((new Date).getFullYear()),onSelect:function(dateStr){window.setTimeout(function(){self._onTextFieldChange();},500);}});btnId='#observation-controls .ui-datepicker-trigger';btn=$(btnId);btn.hover(function(){this.src="resources/images/blackGlass/calendar_small-hover.png";},function(){this.src="resources/images/blackGlass/calendar_small.png";}).attr("title","Select an observation date.").click(function(){btn.qtip("hide");});btn.qtip();},_onDateChange:function(){this._updateInputFields();Helioviewer.userSettings.set("state.date",this._date.getTime());$(document).trigger("observation-time-changed",[this._date]);},_onTextFieldChange:function(){if(this._validateDate()&&this._validateTime()){this.setDate(this._timeFieldsToDateObj());}
return false;},_onTimeIncrementChange:function(e){this._timeIncrement=parseInt(e.target.value,10);Helioviewer.userSettings.set("state.timeStep",this._timeIncrement);},_timeFieldsToDateObj:function(){return Date.parseUTCDate(this.getDateField()+" "+this.getTimeField());},_updateInputFields:function(){this._dateInput.val(this._date.toUTCDateString());this._timeInput.val(this._date.toUTCTimeString());},_validateDate:function(){var dateString=this.getDateField();if(dateString.match(/^\d{4}\/\d{2}\/\d{2}?/)&&(dateString.length===10)){return true;}else{$(document).trigger("message-console-warn",["Invalid date. Please enter a date of the form YYYY/MM/DD."]);return false;}},_validateTime:function(){var timeString=this.getTimeField();if(timeString.match(/^\d{2}:\d{2}:\d{2}?/)&&(timeString.length===8)){return true;}else{$(document).trigger("message-console-warn",["Invalid time. Please enter a time of the form HH:MM:SS."]);return false;}}});"use strict";var FullscreenControl=Class.extend({init:function(btnId,speed){this.btn=$(btnId);this.btn.append('<span class="ui-icon ui-icon-arrow-4-diag"></span>');this.btn.attr('title','Enable fullscreen mode.');this.icon=$(btnId).find('span.ui-icon');this.body=$('body');this.colmid=$('#colmid');this.colright=$('#colright');this.col1pad=$('#col1pad');this.col2=$('#col2');this.viewport=$('#helioviewer-viewport-container-outer');this.shadow=$('#helioviewer-viewport-container-shadow');this.sandbox=$('#sandbox');this.header=$('#header');this.footer=$('#footer');this.meta=$('#footer-container-outer');this.panels=$('#col2, #col3, #header, #footer');this.sidebarWidth=280;this.marginSize=4;this.disabled_col1padMarginLeft=2*(this.sidebarWidth+this.marginSize);this.disabled_col1padMarginRight=0;this.disabled_col1padMarginTop=0;this.disabled_colRightMarginLeft=-2*(this.sidebarWidth+this.marginSize);this.disabled_col2Left=this.sidebarWidth+this.marginSize+2;this.disabled_colMidLeft=this.sidebarWidth+this.marginSize;this.enabled_colMidLeft=0;this.enabled_colMidRight=0;this.enabled_col2Left=-(this.sidebarWidth+this.marginSize+2)-this.sidebarWidth;this.enabled_colrightMarginLeft=0;this.static_headerHeight=this.header.height();this.static_footerHeight=this.footer.height();this._overrideAnimate();this._setupEventHandlers();},isEnabled:function(){if($('#morescreen-btn > span.ui-icon').hasClass('ui-icon-arrowstop-1-w')){this._fullscreenMode=false;}
return this._fullscreenMode;},enableFullscreenMode:function(animated){this.body.css({'overflow':'hidden','min-width':450});this.meta.hide();if(animated){this._expandAnimated();}else{this._expand();}},_expandAnimated:function(){var self=this,moreScreenBtn;this.colmid.animate({left:this.enabled_colMidLeft+'px',right:this.enabled_colMidRight+'px'},this.speed,function(){$(document).trigger('update-viewport');self.shadow.css({'width':self.viewport.width(),'height':self.viewport.height(),'top':self.marginSize,'left':self.marginSize});self.panels.hide();self.body.removeClass('disable-fullscreen-mode');});this.colright.animate({'margin-left':this.enabled_colrightMarginLeft+'px'},this.speed);this.col1pad.animate({'margin-left':this.marginSize,'margin-right':this.marginSize,'margin-top':this.marginSize},this.speed);this.col2.animate({'left':this.enabled_col2Left+'px'},this.speed);this.header.animate({'height':0},this.speed);this.viewport.animate({'height':$(window).height()-(3*this.marginSize)},this.speed);this.sandbox.animate({'right':0.1},this.speed);this.btn.attr('title','Disable fullscreen mode.');moreScreenBtn=$('#morescreen-btn > span.ui-icon');if(moreScreenBtn.length==1){$('#morescreen-btn > span.ui-icon').removeClass('ui-icon-arrowstop-1-w').addClass('ui-icon-arrowstop-1-e');$('#morescreen-btn').attr('title','Show left sidebar.');}},_expand:function(){var moreScreenBtn;this.colmid.css({'left':this.enabled_colMidLeft+'px','right':this.enabled_colMidRight+'px'});this.col1pad.css({'margin-left':this.marginSize,'margin-right':this.marginSize,'margin-top':this.marginSize});this.col2.css({'left':this.enabled_col2Left+'px'});this.header.height(0);this.viewport.css({'height':$(window).height()-(3*this.marginSize)});this.sandbox.css({'right':0.1});$(document).trigger('update-viewport');this.shadow.css({'width':this.viewport.width(),'height':this.viewport.height(),'top':this.marginSize,'left':this.marginSize});this.panels.hide();this.body.removeClass('disable-fullscreen-mode');this.btn.attr('title','Disable fullscreen mode.');moreScreenBtn=$('#morescreen-btn > span.ui-icon');if(moreScreenBtn.length==1){$('#morescreen-btn > span.ui-icon').removeClass('ui-icon-arrowstop-1-w').addClass('ui-icon-arrowstop-1-e');$('#morescreen-btn').attr('title','Show left sidebar.');}},disableFullscreenMode:function(){var offset,self=this,viewportHeight=$(window).height()-this.static_headerHeight-this.static_footerHeight-2,moreScreenBtn;this.shadow.hide();this.panels.show();this.colmid.animate({'left':this.disabled_colMidLeft+'px'},this.speed,function(){self.meta.show();self.body.css({'overflow':'visible',}).removeClass('disable-fullscreen-mode');});this.colright.animate({'margin-left':this.disabled_colRightMarginLeft+'px'},this.speed);this.col1pad.animate({'margin-left':this.disabled_col1padMarginLeft+'px','margin-right':this.disabled_col1padMarginRight+'px','margin-top':this.disabled_col1padMarginTop+'px'},this.speed);this.col2.animate({'left':this.disabled_col2Left+'px'},this.speed);this.header.animate({'height':this.static_headerHeight+'px'},this.speed);this.viewport.animate({'height':viewportHeight+'px'},this.speed);this.sandbox.animate({'right':0},this.speed,function(){offset=self.viewport.offset();self.shadow.css({'width':self.viewport.width(),'height':self.viewport.height(),'top':offset.top,'left':offset.left}).show();});this.body.animate({'min-width':'972px'},this.speed);this.btn.attr('title','Enable fullscreen mode.');moreScreenBtn=$('#morescreen-btn > span.ui-icon');if(moreScreenBtn.length==1){$('#morescreen-btn > span.ui-icon').removeClass('ui-icon-arrowstop-1-w').addClass('ui-icon-arrowstop-1-e');$('#morescreen-btn').attr('title','Hide right sidebar.');}},_setupEventHandlers:function(){this.btn.click($.proxy(this._toggle,this));$(document).bind('toggle-fullscreen',$.proxy(this._toggle,this));},_toggle:function(animated){if(this.body.hasClass('disable-fullscreen-mode')){return;}
if(typeof(animated)=='undefined'){animated=true;}
this.body.addClass('disable-fullscreen-mode');if(this.isEnabled()){this.disableFullscreenMode();this.viewport.removeClass('fullscreen-mode');}
else{this.enableFullscreenMode(animated);this.viewport.addClass('fullscreen-mode');}
this._fullscreenMode=!this._fullscreenMode;$(document).trigger('viewport-resized');},_overrideAnimate:function(){var doc=$(document),$_fx_step_default=$.fx.step._default;$.fx.step._default=function(fx){if(fx.elem.id!=='sandbox'){return $_fx_step_default(fx);}
doc.trigger('update-viewport');fx.elem.updated=true;};}});"use strict";var MorescreenControl=Class.extend({init:function(btnId,speed){this.btn=$(btnId);this.btn.append('<span class="ui-icon ui-icon-arrowstop-1-e"></span>');this.btn.attr('title','Hide right sidebar.');this.icon=$(btnId).find('span.ui-icon');this.body=$('body');this.colmid=$('#colmid');this.colright=$('#colright');this.col1pad=$('#col1pad');this.col2=$('#col2');this.col3=$('#col3');this.viewport=$('#helioviewer-viewport-container-outer');this.shadow=$('#helioviewer-viewport-container-shadow');this.sandbox=$('#sandbox');this.header=$('#header');this.footer=$('#footer');this.meta=$('#footer-container-outer');this.panels=$("#col2, #header, #footer");this.sidebarWidth=280;this.marginSize=4;this.disabled_col1padMarginLeft=2*(this.sidebarWidth+this.marginSize);this.disabled_colRightMarginLeft=-this.disabled_col1padMarginLeft;this.disabled_col2Left=this.sidebarWidth+this.marginSize+2;this.enabled_col1padMarginLeft=2*(this.sidebarWidth+this.marginSize);this.enabled_col1padMarginRight=-this.sidebarWidth;this.enabled_col2Left=this.sidebarWidth+this.marginSize+2;this.enabled_colrightMarginLeft=-2*(this.sidebarWidth+this.marginSize);this.static_colMidLeft=this.sidebarWidth+this.marginSize;this.static_headerHeight=this.header.height();this.static_footerHeight=this.footer.height();this._overrideAnimate();this._setupEventHandlers();},isEnabled:function(){if(this.icon.hasClass('ui-icon-arrowstop-1-w')){return true;}
return false;},enableMorescreenMode:function(animated){this.body.css({'overflow':'hidden','min-width':450});if(animated){this._expandAnimated();}else{this._expand();}},_expandAnimated:function(){var self=this,fullScreenBtn;this.col3.hide();this.shadow.hide();this.colmid.animate({left:this.static_colMidLeft+'px',right:0},this.speed,function(){var offset;$(document).trigger('update-viewport');self.col2.show();self.col2.animate({"left":self.enabled_col2Left+'px'});offset=self.viewport.offset();self.shadow.css({"width":self.viewport.width(),"height":self.viewport.height(),"top":offset.top,"left":offset.left}).show();self.body.removeClass('disable-morescreen-mode');});this.col1pad.animate({"margin-left":this.enabled_col1padMarginLeft+"px","margin-right":this.enabled_col1padMarginRight+"px"},this.speed);this.colright.animate({"margin-left":this.enabled_colrightMarginLeft+"px"},this.speed);this.sandbox.animate({"right":0.1},this.speed);this.icon.removeClass('ui-icon-arrowstop-1-e').addClass('ui-icon-arrowstop-1-w');this.btn.attr('title','Show right sidebar.');fullScreenBtn=$('#fullscreen-btn > span.ui-icon');if(fullScreenBtn.length==1){$('#fullscreen-btn').attr('title','Enable fullscreen mode.');}},_expand:function(){var offset,fullScreenBtn;this.col2.css({"left":this.enabled_col2Left+'px'});this.col2.show();this.col3.hide();this.shadow.hide();this.colmid.css({"left":this.static_colMidLeft+'px',"right":0});this.col1pad.css({"margin-left":this.enabled_col1padMarginLeft+"px","margin-right":this.enabled_col1padMarginRight+"px"});this.colright.css({"margin-left":this.enabled_colrightMarginLeft+"px"});this.sandbox.css({"right":0.1});$(document).trigger('update-viewport');offset=this.viewport.offset();this.shadow.css({"width":this.viewport.width(),"height":this.viewport.height(),"top":offset.top,"left":offset.left}).show();this.body.removeClass('disable-morescreen-mode');this.icon.removeClass('ui-icon-arrowstop-1-e').addClass('ui-icon-arrowstop-1-w');this.btn.attr('title','Show right sidebar.');fullScreenBtn=$('#fullscreen-btn > span.ui-icon');if(fullScreenBtn.length==1){$('#fullscreen-btn').attr('title','Enable fullscreen mode.');}},disableMorescreenMode:function(){var offset,self=this,viewportHeight=$(window).height()-this.static_headerHeight-this.static_footerHeight-2,fullScreenBtn;this.shadow.hide();this.colmid.animate({"left":this.static_colMidLeft+'px'},this.speed,function(){self.panels.show();self.meta.show();self.col3.show();self.body.css({"overflow":"visible",}).removeClass('disable-morescreen-mode');});this.colright.animate({"margin-left":this.disabled_colRightMarginLeft+'px'},this.speed);this.col1pad.animate({"margin-left":this.disabled_col1padMarginLeft+'px',"margin-right":0,"margin-top":0},this.speed);this.col2.animate({"left":this.disabled_col2Left+'px'},this.speed);this.header.animate({"height":this.static_headerHeight+'px'},this.speed);this.viewport.animate({"height":viewportHeight},this.speed);this.sandbox.animate({"right":0},this.speed,function(){offset=self.viewport.offset();self.shadow.css({"width":self.viewport.width(),"height":self.viewport.height(),"top":offset.top,"left":offset.left}).show();});this.body.animate({"min-width":"972px"},this.speed);this.icon.removeClass('ui-icon-arrowstop-1-w').addClass('ui-icon-arrowstop-1-e');this.btn.attr('title','Hide right sidebar.');fullScreenBtn=$('#fullscreen-btn > span.ui-icon');if(fullScreenBtn.length==1){$('#fullscreen-btn').attr('title','Enable fullscreen mode.');}},_setupEventHandlers:function(){this.btn.click($.proxy(this._toggle,this));$(document).bind('toggle-morescreen',$.proxy(this._toggle,this));},_toggle:function(animated){if(this.body.hasClass('disable-morescreen-mode')){return;}
if(typeof(animated)=="undefined"){animated=true;}
this.body.addClass('disable-morescreen-mode');if(this.isEnabled()){this.disableMorescreenMode();this.viewport.removeClass("morescreen-mode");}else{this.enableMorescreenMode(animated);this.viewport.addClass("morescreen-mode");}},_overrideAnimate:function(){var doc=$(document),$_fx_step_default=$.fx.step._default;$.fx.step._default=function(fx){if(fx.elem.id!=="sandbox"){return $_fx_step_default(fx);}
doc.trigger('update-viewport');fx.elem.updated=true;};}});"use strict";var HelioviewerWebClient=HelioviewerClient.extend({init:function(urlSettings,serverSettings,zoomLevels){var urlDate,imageScale,paddingHeight;this._super(urlSettings,serverSettings,zoomLevels);if(urlSettings.debug){this._showDebugHelpers();}
this._initLoadingIndicator();this._initTooltips();imageScale=this._chooseInitialImageScale(Helioviewer.userSettings.get('state.imageScale'),zoomLevels);urlDate=urlSettings.date?Date.parseUTCDate(urlSettings.date):false;this.timeControls=new TimeControls('#date','#time','#timestep-select','#timeBackBtn','#timeForwardBtn',urlDate);this._initViewport(this.timeControls.getDate(),$("#header").height()+1,$("#footer").height()+1);this.messageConsole=new MessageConsole();this.keyboard=new KeyboardManager();this.zoomControls=new ZoomControls('#zoomControls',imageScale,zoomLevels,this.serverSettings.minImageScale,this.serverSettings.maxImageScale);this.earthScale=new ImageScale();this.fullScreenMode=new FullscreenControl("#fullscreen-btn",500);this.moreScreenMode=new MorescreenControl("#morescreen-btn",500);this.displayBlogFeed(3,false);this._userVideos=new UserVideoGallery(this.serverSettings.videoFeed);this.imageSelectTool=new ImageSelectTool();this._screenshotManagerUI=new ScreenshotManagerUI();this._movieManagerUI=new MovieManagerUI();this._glossary=new VisualGlossary(this._setupDialog);this._setupDialogs();this._initEventHandlers();this._setupSettingsUI();this._displayGreeting();},_initLoadingIndicator:function(){$(document).ajaxStart(function(){$('#loading').show();}).ajaxStop(function(){$('#loading').hide();});},_initTooltips:function(){$.fn.qtip.defaults=$.extend(true,{},$.fn.qtip.defaults,{show:{delay:1000},style:{classes:'ui-tooltip-light ui-tooltip-shadow ui-tooltip-rounded'}});$("*[title]:not(.qtip-left)").qtip();$(".qtip-left").qtip({position:{my:"top right",at:"bottom middle"}});$(".qtip-topleft").qtip({position:{my:"bottom right",at:"top middle"}});},_initViewport:function(date,marginTop,marginBottom){var shadow,updateShadow,self=this;$(document).bind("datasources-initialized",function(e,dataSources){var tileLayerAccordion=new TileLayerAccordion('#tileLayerAccordion',dataSources,date);});$(document).bind("event-types-initialized",function(e,eventTypes,date){var eventLayerAccordion=new EventLayerAccordion('#eventLayerAccordion',eventTypes,date);});this._super("#helioviewer-viewport-container-outer",date,marginTop,marginBottom);shadow=$('#helioviewer-viewport-container-shadow');if($.browser.msie){shadow.css("box-shadow","none");return;}
shadow.show();updateShadow=function(){shadow.width(self.viewport.outerNode.width()).height(self.viewport.outerNode.height());};updateShadow();$(document).bind("viewport-resized",updateShadow);},loadMovie:function(movieId){if(!this._movieManagerUI.has(movieId)){this._movieManagerUI.addMovieUsingId(movieId);}else{this._movieManagerUI.playMovie(movieId);}},_setupDialogs:function(){var self=this;this._setupDialog("#helioviewer-about","#about-dialog",{"title":"Helioviewer - About","height":400});this._setupDialog("#helioviewer-usage","#usage-dialog",{"title":"Helioviewer - Usage Tips"});this._setupDialog("#settings-button","#settings-dialog",{"buttons":{"Ok":function(){$(this).dialog("close");}},"title":"Helioviewer - Settings","width":400,"height":'auto',"resizable":false,"create":function(e){}});},_setupDialog:function(btn,dialog,options,onLoad){var defaults={title:"Helioviewer.org",autoOpen:true,draggable:true,width:480,height:400};$(btn).click(function(){var d=$(dialog),btn=$(this);if(btn.hasClass("dialog-loaded")){if(d.dialog('isOpen')){d.dialog('close');}
else{d.dialog('open');}}else{d.load(this.href,onLoad).dialog($.extend(defaults,options));btn.addClass("dialog-loaded");}
return false;});},_showDebugHelpers:function(){var dimensions,win=$(window);dimensions=$("<div id='debug-dimensions'></div>").appendTo("body");win.resize(function(e){dimensions.html(win.width()+"x"+win.height());});},_setupSettingsUI:function(){var form,dateLatest,datePrevious,autorefresh,self=this;form=$("#helioviewer-settings");dateLatest=$("#settings-date-latest");datePrevious=$("#settings-date-previous");autorefresh=$("#settings-latest-image");if(Helioviewer.userSettings.get("options.date")==="latest"){dateLatest.attr("checked","checked");}else{datePrevious.attr("checked","checked");}
if(Helioviewer.userSettings.get("options.autorefresh")){autorefresh.attr("checked","checked");this.timeControls.enableAutoRefresh();}else{autorefresh.removeAttr("checked");this.timeControls.disableAutoRefresh();}
dateLatest.change(function(e){Helioviewer.userSettings.set("options.date","latest");});datePrevious.change(function(e){Helioviewer.userSettings.set("options.date","previous");});autorefresh.change(function(e){Helioviewer.userSettings.set("options.autorefresh",e.target.checked);if(e.target.checked){self.timeControls.enableAutoRefresh();}else{self.timeControls.disableAutoRefresh();}});},_initEventHandlers:function(){var self=this,msg="Use the following link to refer to current page:",btns;$('#link-button').click(function(e){if(typeof(_gaq)!=="undefined"){_gaq.push(['_trackEvent','Shares','Homepage - URL']);}
self.displayURL(self.toURL(),msg);});btns=$("#social-buttons .text-btn, "+"#movie-manager-container .text-btn, "+"#image-area-select-buttons > .text-btn, "+"#screenshot-manager-container .text-btn, "+"#event-container .text-btn");btns.live("mouseover",function(){$(this).find(".ui-icon").addClass("ui-icon-hover");});btns.live("mouseout",function(){$(this).find(".ui-icon").removeClass("ui-icon-hover");});$("#helioviewer-viewport, .ui-slider-handle").each(function(){assignTouchHandlers(this);});$("#helioviewer-url-shorten").click(function(e){var url;if(e.target.checked){url=$("#helioviewer-short-url").attr("value");}else{url=$("#helioviewer-long-url").attr("value");}
$("#helioviewer-url-input-box").attr('value',url).select();});},displayURL:function(url,msg){var callback=function(response){$("#helioviewer-long-url").attr("value",url);$("#helioviewer-short-url").attr("value",response.data.url);$("#helioviewer-url-box-msg").text(msg);$("#url-dialog").dialog({dialogClass:'helioviewer-modal-dialog',height:110,width:$('html').width()*0.7,modal:true,resizable:false,title:"URL",open:function(e){$("#helioviewer-url-shorten").removeAttr("checked");$('.ui-widget-overlay').hide().fadeIn();$("#helioviewer-url-input-box").attr('value',url).select();}});};$.ajax({url:Helioviewer.api,dataType:Helioviewer.dataType,data:{"action":"shortenURL","queryString":url.substr(this.serverSettings.rootURL.length+2)},success:callback});},displayMovieURL:function(movieId){var msg="Use the following link to refer to this movie:",url=this.serverSettings.rootURL+"/?movieId="+movieId;if(typeof(_gaq)!=="undefined"){_gaq.push(['_trackEvent','Shares','Movie - URL']);}
this.displayURL(url,msg);},displayMailForm:function(){var html,url=this.toURL();html='<div id="helioviewer-url-box">'+'Who would you like to send this page to?<br>'+'<form style="margin-top:15px;">'+'<label>From:</label>'+'<input type="email" <email address hidden>" class="email-input-field" '+'id="email-from" value="Your Email Address"></input><br>'+'<label>To:</label>'+'<input type="email" <email address hidden>" class="email-input-field" id="email-from" '+'value="Recipient\'s Email Address"></input>'+'<label style="float:none; margin-top: 10px;">Message: </label>'+'<textarea style="width: 370px; height: 270px; margin-top: 8px;">Check this out:\n\n'+url+'</textarea>'+'<span style="float: right; margin-top:8px;">'+'<input type="submit" value="Send"></input>'+'</span></form>'+'</div>';},displayBlogFeed:function(n,showDescription,descriptionWordLength){var url,dtype,html="";url=this.serverSettings.newsURL;if(Helioviewer.dataType==="jsonp"){dtype="jsonp text xml";}else{dtype="xml";}
$.getFeed({url:Helioviewer.api,data:{"action":"getNewsFeed"},dataType:dtype,success:function(feed){var link,date,more,description;if(!feed.items){$("#social-panel").append("Unable to retrieve news feed...");return;}
$.each(feed.items.slice(0,n),function(i,a){link="<a href='"+a.link+"' alt='"+a.title+"' target='_blank'>"+a.title+"</a><br />";date="<div class='article-date'>"+a.updated.slice(0,26)+"UTC</div>";html+="<div class='blog-entry'>"+link+date;if(showDescription){description=a.description;if(typeof descriptionWordLength==="number"){description=description.split(" ").slice(0,descriptionWordLength).join(" ")+" [...]";}
html+="<div class='article-desc'>"+description+"</div>";}
html+="</div>";});more="<div id='more-articles'><a href='"+url+"' title='The Helioviewer Project Blog'>Visit Blog...</a></div>";$("#social-panel").append(html+more);}});},launchJHelioviewer:function(){var endDate,params;endDate=new Date(Math.min(this.timeControls.getDate().addHours(12),new Date()));params={"action":"launchJHelioviewer","endTime":endDate.toISOString(),"startTime":endDate.addHours(-24).toISOString(),"imageScale":this.viewport.getImageScaleInKilometersPerPixel(),"layers":this.viewport.serialize()};window.open(Helioviewer.api+"?"+$.param(params),"_blank");},_displayGreeting:function(){if(!Helioviewer.userSettings.get("notifications.welcome")){return;}
$(document).trigger("message-console-info",["<b>Welcome to Helioviewer.org</b>, a solar data browser. First time here? Be sure to check out our "+"<a href=\"http://wiki.helioviewer.org/wiki/Helioviewer.org_User_Guide_2.4.0\" "+"class=\"message-console-link\" target=\"_blank\"> User Guide</a>.</br>",{sticky:true}]);Helioviewer.userSettings.set("notifications.welcome",false);},getDate:function(){return this.timeControls.getDate();},getLayers:function(){return this.viewport.serialize();},getEvents:function(){return this.viewport.serializeEvents();},getEventsLabels:function(){return Helioviewer.userSettings.get("state.eventLabels");},getVisibleLayers:function(roi){return this.viewport.getVisibleLayers(roi);},getImageScale:function(){return this.viewport.getImageScale();},getViewportRegionOfInterest:function(){return this.viewport.getRegionOfInterest();},toURL:function(shorten){var params={"date":this.viewport._tileLayerManager.getRequestDateAsISOString(),"imageScale":this.viewport.getImageScale(),"centerX":Helioviewer.userSettings.get("state.centerX"),"centerY":Helioviewer.userSettings.get("state.centerY"),"imageLayers":encodeURI(this.viewport.serialize()),"eventLayers":encodeURI(this.viewport.serializeEvents()),"eventLabels":Helioviewer.userSettings.get("state.eventLabels")};return this.serverSettings.rootURL+"/?"+decodeURIComponent($.param(params));},constants:{au:149597870700,rsun:695700000}});"use strict";var UserVideoGallery=Class.extend({init:function(url){this._container=$("#user-video-gallery-main");this._loader=$("#user-video-gallery-spinner");this._nextPageBtn=$("#user-video-gallery-next");this._prevPageBtn=$("#user-video-gallery-prev");this._working=false;this.url=url||Helioviewer.api;this._pageSize=this._choosePageSize();this._startIndex=0;this._numVideos=15;this._videos=[];this._setupEventHandlers();this._fetchVideos();var self=this;window.setInterval(function(){self._checkForNewMovies();},120000);},_updateGallery:function(){var endIndex=Math.min(this._startIndex+this._pageSize,this._videos.length);this._buildHTML(this._videos.slice(this._startIndex,endIndex));},_fetchVideos:function(){var params={"action":"getUserVideos","num":this._numVideos};this._container.find("a").empty();this._loader.show();this._working=true;$.get(this.url,params,$.proxy(this._processResponse,this),Helioviewer.dataType);},_checkForNewMovies:function(){var params={"action":"getUserVideos","num":this._numVideos};if(this._videos.length>0){params.since=this._videos[0].published.replace(" ","T")+".000Z";}
this._working=true;$.get(this.url,params,$.proxy(this._processResponse,this),Helioviewer.dataType);},_processResponse:function(response){var videos,error;if(response.error){error="<b>Error:</b> Did you specify a valid YouTube API key "+"in Config.ini?";$("#user-video-gallery-main").html(error);return;}
if(response.count){videos=response.value.items;}else{videos=response;}
this._videos=videos.concat(this._videos);this._updateGallery();},_buildHTML:function(videos){var html="";this._container.find("a, br").remove();$.each(videos,function(i,vid){var when=new Date.parseUTCDate(vid.published).getElapsedTime()+" ago",img=vid.thumbnails['small'];html+="<a target='_blank' href='"+vid.url+"' "+"alt='video thumbnail'>"+"<div class='user-video-thumbnail-container'>"+"<div style='text-align: left; margin-left: 25px;'>"+
when+"</div>"+"<img src='"+img+"' alt='user video thumbnail' />"+"</div></a><br />";});html=html.slice(0,-6);this._loader.hide();this._container.append(html);this._working=false;},_prevPage:function(){if(this._working){return false;}
if(this._startIndex+this._pageSize<this._videos.length){this._startIndex+=this._pageSize;this._updateGallery();}
return false;},_nextPage:function(){if(this._working){return false;}
if(this._startIndex>0){this._startIndex=Math.max(0,this._startIndex-this._pageSize);this._updateGallery();}
return false;},_choosePageSize:function(){var height=$(window).height();if(height>1035){return 3;}else if(height>780){return 2;}
return 1;},_onMouseWheelMove:function(e,delta){if(delta>0){this._nextPage();}else{this._prevPage();}
return false;},_onResize:function(e){var oldPageSize=this._pageSize;this._pageSize=this._choosePageSize();if(this._videos.length===0){return;}
if(this._pageSize!==oldPageSize){if(this._startIndex+this._pageSize>this._videos.length){this._startIndex=this._videos.length-this._pageSize;}
this._updateGallery();}},_onVideoHover:function(event){if(event.type==='mouseover'){$(this).find("img").addClass("video-glow");}else{$(this).find("img").removeClass("video-glow");}},_setupEventHandlers:function(){this._nextPageBtn.click($.proxy(this._nextPage,this));this._prevPageBtn.click($.proxy(this._prevPage,this));$(window).resize($.proxy(this._onResize,this));this._container.mousewheel($.proxy(this._onMouseWheelMove,this));}});"use strict";var VisualGlossary=Class.extend({init:function(setupDialog){setupDialog("#helioviewer-glossary","#glossary-dialog",{"title":"Helioviewer - Glossary","width":800,"height":$(document).height()*0.8},$.proxy(this._onLoad,this));},_onLoad:function(evt){var self=this;this.btns=$('#glossary-menu .text-btn');this.entries=$("#glossary-contents tr");$("#glossary-menu .text-btn").hover(function(){$(this).find(".ui-icon").addClass("ui-icon-hover");},function(){$(this).find(".ui-icon").removeClass("ui-icon-hover");});this.btns.click(function(e){self.btns.removeClass("selected");self.btns.find('.ui-icon').removeClass('ui-icon-bullet').addClass('ui-icon-radio-on');$(this).addClass("selected").find('.ui-icon').removeClass('ui-icon-radio-on').addClass('ui-icon-bullet');self._showCategory(this.id.split("-").pop());});this._showCategory("basic");},_showCategory:function(category){this.entries.hide();if(category==="all"){this.entries.show();}else{this.entries.filter(".g-"+category).show();}}});"use strict";(function($){$.widget("ui.dynaccordion",{options:{displayArrows:true,startClosed:true},init:function(){return this.element;},updateHeader:function(o){$(this.element).find('#'+o.id+' > .dynaccordion-tab').text(o.content);},updateCell:function(o){$(this.element).find('#'+o.id+' > .dynaccordion-cell').text(o.content);},removeSection:function(o){$(this.element).find('#'+o.id).remove();},addSection:function(o){var index,id,arrow,header,body,domNode,container,sections,self=this;id=o.id;container=$(this.element);sections=container.find(".dynaccordion-section");if(this.options.displayArrows){if(o.open){arrow="<div class='accordion-arrow ui-icon ui-icon-triangle-1-s'></div>";}
else{arrow="<div class='accordion-arrow ui-icon ui-icon-triangle-1-e'></div>";}}else{arrow="";}
header=$('<div class="dynaccordion-tab">'+arrow+o.header+'</div>');body=$('<div class="dynaccordion-cell ui-accordion-content ui-helper-reset ui-widget-content '+'ui-corner-bottom ui-corner-top shadow">'+o.cell+'</div>');domNode=$('<div class="dynaccordion-section" id="'+id+'"></div>').append(header).append(body);if((o.index!=="undefined")&&(o.index<sections.length)){$(container.find(".dynaccordion-section")[o.index]).before(domNode);}else{container.append(domNode);}
header.find(".layer-Head").hover(function(){$(this).addClass("ui-state-hover-bgonly");},function(){$(this).removeClass("ui-state-hover-bgonly");});$('#'+id+' > div.dynaccordion-tab').unbind().click(function(){if(self.options.displayArrows){var arrowIcon=$(this).find('.accordion-arrow')[0];$(arrowIcon).toggleClass('ui-icon-triangle-1-s');$(arrowIcon).toggleClass('ui-icon-triangle-1-e');}
$(this).next().slideToggle('fast');});if(this.options.startClosed&&(!o.open)){$('#'+id+' > div.dynaccordion-cell').hide();}}});}(jQuery));