ShowController.js 102 KB

1
  1. var kShowControllerState_Stopped="Stopped";var kShowControllerState_Starting="Starting";var kShowControllerState_DownloadingScript="DownloadingScipt";var kShowControllerState_SettingUpScene="SettingUpScene";var kShowControllerState_IdleAtFinalState="IdleAtFinalState";var kShowControllerState_IdleAtInitialState="IdleAtInitialState";var kShowControllerState_WaitingToJump="WaitingToJump";var kShowControllerState_ReadyToJump="ReadyToJump";var kShowControllerState_WaitingToDisplay="WaitingToDisplay";var kShowControllerState_ReadyToDisplay="ReadyToDisplay";var kShowControllerState_WaitingToPlay="WaitingToPlay";var kShowControllerState_ReadyToPlay="ReadyToPlay";var kShowControllerState_Playing="Playing";var kKeyDownEvent="keydown";var kNullActionEmphasis={rotationEmphasis:[0,0,0,0,0,0],translationEmphasis:[0,0,0],scaleEmphasis:[0,0,0,0,0,0]};var ShowController=Class.create({initialize:function(){this.extractDelegateFromUrlParameter();this.delegate.showDidLoad();this.showUrl="../";debugMessage(kDebugShowController_Initialize,"showUrl: "+this.showUrl);this.displayManager=new DisplayManager();this.scriptManager=new ScriptManager(this.showUrl);this.textureManager=new TextureManager(this.showUrl);this.stageManager=new StageManager(this.textureManager,this.scriptManager);this.touchController=new TouchController();this.animationManager=new AnimationManager();this.orientationController=new OrientationController();this.activeHyperlinks=new Array();this.movieHyperlinks=new Array();this.script=null;this.currentSceneIndex=-1;this.nextSceneIndex=-1;this.currentSlideIndex=-1;this.previousSlideIndex=-1;this.currentSoundTrackIndex=0;this.transformOriginValue="";this.accumulatingDigits=false;this.digitAccumulator=0;this.firstSlide=true;this.embedMode=kEmbedModeNonEmbedded;this.accountID="";this.guid="";this.locale="EN";this.isNavigationBarVisible=false;this.isFullscreen=false;this.volume=3;this.muted=false;this.soundTrackPlayer=null;this.sceneIndexOfPrebuiltAnimations=-1;this.queuedUserAction=null;this.autoAdvance=false;this.autoAdvanceReversed=false;this.autoAdvanceCount=0;var a=this;document.observe(kStageIsReadyEvent,function(b){a.handleStageIsReadyEvent(b)},false);document.observe(kScriptDidDownloadEvent,function(b){a.handleScriptDidDownloadEvent(b)},false);document.observe(kScriptDidNotDownloadEvent,function(b){a.handleScriptDidNotDownloadEvent(b)},false);document.observe(kSwipeEvent,function(b){a.handleSwipeEvent(b)},false);document.observe(kStageSizeDidChangeEvent,function(b){a.handleStageSizeDidChangeEvent(b)},false);document.observe(kKeyDownEvent,function(b){a.handleKeyDownEvent(b)},false);this.touchController.registerTapEventCallback(function(b){a.handleTapEvent(b)});this.changeState(kShowControllerState_Stopped)},extractDelegateFromUrlParameter:function(){var c=getUrlParameter("delegate");if((c=="")||(c==null)||(typeof(c)=="undefined")){debugMessage(kDebugShowController_ExtractDelegateFromUrlParameter,"no delegate parameter specified in URL, using null delegate");this.delegate=new NullDelegate();return}debugMessage(kDebugShowController_ExtractDelegateFromUrlParameter,"delegate: "+c);var b=c.indexOf(".");this.delegate=window;while(b!=-1){var a=c.substring(0,b);debugMessage(kDebugShowController_ExtractDelegateFromUrlParameter,"- nextPart: "+a);this.delegate=this.delegate[a];c=c.substring(b+1);b=c.indexOf(".")}debugMessage(kDebugShowController_ExtractDelegateFromUrlParameter,"- lasePart: "+c);this.delegate=this.delegate[c]},setDelegate:function(a){debugMessage(kDebugShowController_SetDelegate,"delegate has been set")},setProperty:function(b,a){debugMessage(kDebugShowController_SetProperty,"setting '"+b+"' to: "+a);switch(b){case kPropertyName_embedMode:switch(a){case kEmbedModeEmbedded:case kEmbedModeNonEmbedded:this.embedMode=a;break;default:debugMessage(kDebugShowController_SetProperty,"invalid value specified for "+kPropertyName_embedMode+": "+a);break}break;case kPropertyName_presentationName:break;case kPropertyName_accountID:this.accountID=a;break;case kPropertyName_guid:this.guid=a;break;case kPropertyName_locale:this.locale=a;break;case kPropertyName_currentSlide:this.jumpToSlide(a);break;case kPropertyName_isNavigationBarVisible:this.isNavigationBarVisible=a;break;case kPropertyName_isFullscreen:break;case kPropertyName_volume:break;case kPropertyName_muted:this.setMuted(a);break;default:debugMessage(kDebugShowController_SetProperty,"- unknown property name");break}},getProperty:function(b){debugMessage(kDebugShowController_GetProperty);var a=null;switch(b){case kPropertyName_embedMode:a=this.embedMode;break;case kPropertyName_presentationName:a=this.showUrl;break;case kPropertyName_accountID:a=null;break;case kPropertyName_guid:a=null;break;case kPropertyName_locale:a=null;break;case kPropertyName_currentSlide:a=this.currentSlideIndex+1;break;case kPropertyName_isNavigationBarVisible:a=null;break;case kPropertyName_isFullscreen:a=null;break;case kPropertyName_volume:a=null;break;default:debugMessage(kDebugShowController_SetProperty,"unknown property name");break}debugMessage(kDebugShowController_GetProperty,"getting '"+b+"'... returning '"+a+"'");return a},gotoSlide:function(a){debugMessage(kDebugShowController_GotoSlide,"slideNumber: "+a);this.jumpToSlide(a)},pause:function(){debugMessage(kDebugShowController_Pause,"currently not implemented!")},play:function(){debugMessage(kDebugShowController_Play,"currently not implemented!")},debugToggleMobileDebugging:function(){if(gDebugOnMobile){debugMessageAlways("ShowController_DebugEnableFullDebugging","turning mobile debugging off...");gDebugOnMobile=false}else{debugMessageAlways("ShowController_DebugEnableFullDebugging","turning mobile debugging on...");gDebugOnMobile=true}},debugDiagnosticDump:function(){if(kDebugShowController_DiagnosticsDump_Banner){debugMessageAlways(kDebugShowController_DiagnosticsDump,"*****************************************************");debugMessageAlways(kDebugShowController_DiagnosticsDump,"*** S T A R T D I A G N O S T I C D U M P ****");debugMessageAlways(kDebugShowController_DiagnosticsDump,"*****************************************************")}if(kDebugShowController_DiagnosticsDump_Header){debugMessageAlways(kDebugShowController_DiagnosticsDump,"- state: "+this.state);debugMessageAlways(kDebugShowController_DiagnosticsDump,"- numSlides: "+this.script.slideCount);debugMessageAlways(kDebugShowController_DiagnosticsDump,"- numScenes: "+this.script.numScenes);debugMessageAlways(kDebugShowController_DiagnosticsDump,"- currentSceneIndex: "+this.currentSceneIndex);debugMessageAlways(kDebugShowController_DiagnosticsDump,"- nextSceneIndex: "+this.nextSceneIndex);debugMessageAlways(kDebugShowController_DiagnosticsDump,"- currentSlideIndex: "+this.currentSlideIndex);debugMessageAlways(kDebugShowController_DiagnosticsDump,"- previousSlideIndex: "+this.previousSlideIndex);debugMessageAlways(kDebugShowController_DiagnosticsDump,"- loopSlideshow: "+(this.script.loopSlideshow?"yes":"no"));debugMessageAlways(kDebugShowController_DiagnosticsDump,"- hyperlinksOnly: "+(this.script.showMode==kShowModeHyperlinksOnly?"yes":"no"))}if(kDebugShowController_DiagnosticsDump_Animations){debugMessageAlways(kDebugShowController_DiagnosticsDump,"-");debugMessageAlways(kDebugShowController_DiagnosticsDump,"- Pre-Built Texture Animations:");debugMessageAlways(kDebugShowController_DiagnosticsDump,"- -----------------------------");for(var a in this.textureAnimations){debugMessage(kDebugShowController_DiagnosticsDump,"- "+a)}}if(kDebugShowController_DiagnosticsDump_Textures){debugMessageAlways(kDebugShowController_DiagnosticsDump,"-");debugMessageAlways(kDebugShowController_DiagnosticsDump,"- Textures In Scene:");debugMessageAlways(kDebugShowController_DiagnosticsDump,"- ------------------");var g;for(g=0;g<this.stageManager.stage.childNodes.length;g++){var c=this.stageManager.stage.childNodes[g];var i="";debugMessageAlways(kDebugShowController_DiagnosticsDump,"- "+g+": DIV id='"+c.id+"' opacity:"+c.style.opacity);var f=false;var e=c;var h=1;do{i+=" ";if(e.childNodes.length>0){e=e.childNodes[0];if(e.hasOwnProperty("opacity")){h*=e.style.opacity}debugMessageAlways(kDebugShowController_DiagnosticsDump,"- "+i+e.nodeName+" id='"+e.id+"' opacity: "+e.style.opacity+(e.hasOwnProperty("src")?" src: "+e.src:""))}else{debugMessageAlways(kDebugShowController_DiagnosticsDump,"- "+i+"net opacity: "+h+" = "+(h>0?"visible":"hidden"));f=true}}while(!f)}}if(kDebugShowController_DiagnosticsDump_Hyperlinks){debugMessageAlways(kDebugShowController_DiagnosticsDump,"-");debugMessageAlways(kDebugShowController_DiagnosticsDump,"- Active Hyperlinks:");debugMessageAlways(kDebugShowController_DiagnosticsDump,"- ------------------");var d=0;var b;if(this.activeHyperlinks!=null){d=this.activeHyperlinks.length}if(d==0){debugMessageAlways(kDebugShowController_DiagnosticsDump,"- no hyperlinks")}for(b=0;b<d;b++){var j=this.activeHyperlinks[b];debugMessageAlways(kDebugShowController_DiagnosticsDump,"- "+b+":: x:"+j.targetRectangle.x+" y:"+j.targetRectangle.y+" w:"+j.targetRectangle.width+" h:"+j.targetRectangle.height+" url:"+j.url)}}if(kDebugShowController_DiagnosticsDump_TextureCache){this.textureManager.debugDumpCache()}if(kDebugShowController_DiagnosticsDump_Banner){debugMessageAlways(kDebugShowController_DiagnosticsDump,"*************************************************");debugMessageAlways(kDebugShowController_DiagnosticsDump,"*** E N D D I A G N O S T I C D U M P ****");debugMessageAlways(kDebugShowController_DiagnosticsDump,"*************************************************")}},exitShow:function(){debugMessage(kDebugShowController_ExitShow,"- exiting show...");this.delegate.showExited()},onMouseDown:function(a){debugMessage(kDebugShowController_OnMouseDown,(a.leftClick?"Left":a.rightClick?"Right":a.middleClick?"Middle":"no")+" button clicked");if(a.leftClick){this.advanceToNextBuild("onMouseDown")}else{if(a.rightClick){this.goBackToPreviousBuild("onMouseDown")}}},onKeyPress:function(c,a){debugMessage(kDebugShowController_OnKeyPress,"key: "+c+" modifier(s): "+(a.shiftKey?"shift ":"")+(a.altKey?"alt ":"")+(a.ctrlKey?"ctrl ":"")+(a.metaKey?"meta":""));if((c>=kKeyCode_Numeric_0)&&(c<=kKeyCode_Numeric_9)){c=kKeyCode_0+(c-kKeyCode_Numeric_0)}c+=(a.shiftKey?kKeyModifier_Shift:0);c+=(a.altKey?kKeyModifier_Alt:0);c+=(a.ctrlKey?kKeyModifier_Ctrl:0);c+=(a.metaKey?kKeyModifier_Meta:0);var b=false;switch(c){case kKeyCode_Escape:this.exitShow();break;case kKeyCode_Return+kKeyModifier_Ctrl:this.displayManager.showWaitingIndicator();break;case kKeyCode_Return+kKeyModifier_Alt:this.displayManager.hideWaitingIndicator();break;case kKeyCode_Return+kKeyModifier_Meta:this.debugDiagnosticDump();break;case kKeyCode_Return:if(this.accumulatingDigits){debugMessage(kDebugShowController_OnKeyPress,"- return pressed while accumulating digits, accumulator is now: "+this.digitAccumulator);this.accumulatingDigits=false;if(this.script.showMode==kShowModeHyperlinksOnly){debugMessage(kDebugShowController_OnKeyPress,"- can't do it, we're in hyperlinks only mode")}else{if(this.digitAccumulator<=this.script.slideCount){this.jumpToSlide(this.digitAccumulator)}}break}else{}case kKeyCode_N:case kKeyCode_Space:case kKeyCode_DownArrow:case kKeyCode_RightArrow:case kKeyCode_PageDown:debugMessage(kDebugShowController_OnKeyPress,"- advance to next build...");this.advanceToNextBuild("onKeyPress");break;case kKeyCode_RightArrow+kKeyModifier_Shift:case kKeyCode_DownArrow+kKeyModifier_Shift:case kKeyCode_PageDown+kKeyModifier_Shift:case kKeyCode_CloseBracket:debugMessage(kDebugShowController_OnKeyPress,"- advance to next slide...");this.advanceToNextSlide("onKeyPress");break;case kKeyCode_LeftArrow+kKeyModifier_Shift:case kKeyCode_PageUp+kKeyModifier_Shift:case kKeyCode_OpenBracket:debugMessage(kDebugShowController_OnKeyPress,"- go back to previous build...");this.goBackToPreviousBuild("onKeyPress");break;case kKeyCode_P:case kKeyCode_Delete:case kKeyCode_PageUp:case kKeyCode_LeftArrow:case kKeyCode_UpArrow:case kKeyCode_UpArrow+kKeyModifier_Shift:debugMessage(kDebugShowController_OnKeyPress,"- go back to previous slide...");this.goBackToPreviousSlide("onKeyPress");break;case kKeyCode_Home:debugMessage(kDebugShowController_OnKeyPress,"- go back to first slide...");if(this.script.showMode==kShowModeHyperlinksOnly){debugMessage(kDebugShowController_OnKeyPress,"- can't do it, we're in hyperlinks only mode")}else{this.jumpToSlide(1)}break;case kKeyCode_End:debugMessage(kDebugShowController_OnKeyPress,"- go back to last slide...");if(this.script.showMode==kShowModeHyperlinksOnly){debugMessage(kDebugShowController_OnKeyPress,"- can't do it, we're in hyperlinks only mode")}else{this.jumpToSlide(this.script.slideCount)}break;default:if((c>=kKeyCode_0)&&(c<=kKeyCode_9)){b=true;if(this.accumulatingDigits==false){debugMessage(kDebugShowController_OnKeyPress,"- digit entered, start accumulating digits...");this.accumulatingDigits=true;this.digitAccumulator=0}debugMessage(kDebugShowController_OnKeyPress,"- accumulator was: "+this.digitAccumulator);this.digitAccumulator*=10;this.digitAccumulator+=(c-kKeyCode_0);debugMessage(kDebugShowController_OnKeyPress,"- accumulator now: "+this.digitAccumulator)}break}if(this.accumulatingDigits&&(b==false)){debugMessage(kDebugShowController_OnKeyPress,"- non-digit entered, stop accumulating digits...");this.accumulatingDigits=false;this.digitAccumulator=0}},handleKeyDownEvent:function(c){var b=c.charCode||c.keyCode;var a={altKey:!!c.altKey,ctrlKey:!!c.ctrlKey,shiftKey:!!c.shiftKey,metaKey:!!c.metaKey};kKeyCode_Return;if(a.metaKey){if(b!=kKeyCode_Return){return}}debugMessage(kDebugShowController_HandleKeyDownEvent,"keyCode: "+b);c.stop();this.onKeyPress(b,a)},handleClickEvent:function(a){debugMessage(kDebugShowController_HandleClickEvent,"location: "+a.x+", "+a.y);var b={pointX:a.x,pointY:a.y};this.processClickOrTapAtDisplayCoOrds(b)},incrementViewCount:function(){},startShow:function(){this.changeState(kShowControllerState_DownloadingScript);this.scriptManager.downloadScript();if(gMode==kModeMobile&&gIsPublicViewer){this.incrementViewCount()}},changeState:function(a){if(a!=this.state){debugMessage(kDebugShowController_ChangeState,"leaving '"+this.state+"' entering '"+a+"'");this.accumulatingDigits=false;this.digitAccumulator=0;this.leavingState();this.state=a;this.enteringState()}},leavingState:function(){debugMessage(kDebugShowController_LeavingState,"leaving "+this.state+" currentSceneIndex: "+this.currentSceneIndex);switch(this.state){case kShowControllerState_Stopped:break;case kShowControllerState_Starting:break;case kShowControllerState_SettingUpScene:break;case kShowControllerState_IdleAtFinalState:break;case kShowControllerState_IdleAtInitialState:break;case kShowControllerState_WaitingToJump:break;case kShowControllerState_ReadyToJump:break;case kShowControllerState_WaitingToPlay:this.displayManager.hideWaitingIndicator();break;case kShowControllerState_ReadyToPlay:break;case kShowControllerState_Playing:break}},enteringState:function(){debugMessage(kDebugShowController_EnteringState,"entering "+this.state+" state, currentSceneIndex: "+this.currentSceneIndex);var a=this;switch(this.state){case kShowControllerState_Stopped:break;case kShowControllerState_Starting:this.displayManager.showWaitingIndicator();break;case kShowControllerState_SettingUpScene:break;case kShowControllerState_IdleAtFinalState:case kShowControllerState_IdleAtInitialState:this.updateSlideNumber();this.displayManager.hideWaitingIndicator();this.createHyperlinksForCurrentState("idle");runInNextEventLoop(function(){a.doIdleProcessing()});break;case kShowControllerState_WaitingToJump:break;case kShowControllerState_ReadyToJump:break;case kShowControllerState_WaitingToPlay:this.displayManager.showWaitingIndicator();break;case kShowControllerState_ReadyToPlay:break;case kShowControllerState_Playing:break}},doIdleProcessing:function(){this.preloadAppropriateScenes();if(this.queuedUserAction!=null){debugMessageAlways(kDebugShowController_DoIdleProcessing,"executing queued user action...");this.queuedUserAction();this.queuedUserAction=null}else{var b=this.stageManager.stage;if(b.childNodes.length==0){debugWarning(kDebugShowController_DoIdleProcessing,"we are idle, and there is nothing on the stage!")}else{debugMessageAlways(kDebugShowController_DoIdleProcessing,"at the "+(this.state==kShowControllerState_IdleAtFinalState?"end":"start")+" of scene "+this.currentSceneIndex+" with "+b.childNodes.length+" textures on stage and scenes "+this.textureManager.scenesInCache()+" in the cache.");this.displayManager.updateStatisticsDisplay();this.updateNavigationButtons()}if(this.autoAdvance){var a=this;setTimeout(function(){a.debugAutoAdvance()},500)}}},debugAutoAdvance:function(){this.autoAdvanceCount++;debugMessageAlways("ShowController_AutoAdvance","advancing to next build... (Total Advances: "+this.autoAdvanceCount+")");var a;if(this.autoAdvanceReversed){a=this.goBackToPreviousSlide("autoAdvance")}else{a=this.advanceToNextBuild("autoAdvance")}if(a==false){debugMessageAlways("ShowController_AutoAdvance","looks like we've reached the end, reverse direction...");this.autoAdvanceReversed=!this.autoAdvanceReversed;var b=this;setTimeout(function(){b.debugAutoAdvance()},500)}},truncatedSlideIndex:function(a){return this.truncatedIndex(a,this.script.lastSlideIndex,this.script.loopSlideshow)},truncatedSceneIndex:function(a){return this.truncatedIndex(a,this.script.lastSceneIndex,this.script.loopSlideshow)},truncatedIndex:function(a,c,b){if(a<0){if(b){a=a+c+1}else{a=-1}}else{if(a>c){if(b){a=a-c-1}else{a=-1}}}return a},preloadAppropriateScenes:function(){debugMessage(kDebugShowController_PreloadAppropriateScenes);var d=this.currentSceneIndex;if(this.state==kShowControllerState_IdleAtFinalState){d++}var a=this.scriptManager.slideIndexFromSceneIndex(d);var e=this.scriptManager.sceneIndexFromSlideIndex(this.truncatedSlideIndex(a-1));var b=this.scriptManager.sceneIndexFromSlideIndex(this.truncatedSlideIndex(a-2));var p=this.scriptManager.sceneIndexFromSlideIndex(this.truncatedSlideIndex(a-3));var g=this.truncatedSceneIndex(d-1);var f=this.truncatedSceneIndex(d-2);var c=this.truncatedSceneIndex(d-3);var n=this.truncatedSceneIndex(d+1);var m=this.truncatedSceneIndex(d+2);var k=this.truncatedSceneIndex(d+3);var l=this.scriptManager.sceneIndexFromSlideIndex(this.truncatedSlideIndex(a+1));var j=this.scriptManager.sceneIndexFromSlideIndex(this.truncatedSlideIndex(a+2));var i=this.scriptManager.sceneIndexFromSlideIndex(this.truncatedSlideIndex(a+3));debugMessage(kDebugShowController_PreloadAppropriateScenes,"- previousSlideIndex3: "+p);debugMessage(kDebugShowController_PreloadAppropriateScenes,"- previousSlideIndex2: "+b);debugMessage(kDebugShowController_PreloadAppropriateScenes,"- previousSlideIndex1: "+e);debugMessage(kDebugShowController_PreloadAppropriateScenes,"- previousBuildIndex1: "+g);debugMessage(kDebugShowController_PreloadAppropriateScenes,"- previousBuildIndex2: "+f);debugMessage(kDebugShowController_PreloadAppropriateScenes,"- previousBuildIndex3: "+c);debugMessage(kDebugShowController_PreloadAppropriateScenes,"- sceneIndexToUse: "+d);debugMessage(kDebugShowController_PreloadAppropriateScenes,"- nextBuildIndex1: "+n);debugMessage(kDebugShowController_PreloadAppropriateScenes,"- nextBuildIndex2: "+m);debugMessage(kDebugShowController_PreloadAppropriateScenes,"- nextBuildIndex3: "+k);debugMessage(kDebugShowController_PreloadAppropriateScenes,"- nextSlideIndex1: "+l);debugMessage(kDebugShowController_PreloadAppropriateScenes,"- nextSlideIndex2: "+j);debugMessage(kDebugShowController_PreloadAppropriateScenes,"- nextSlideIndex3: "+i);var o={};var h=(gIpad==true);if(!h&&p!=-1){o[p]=true}if(!h&&b!=-1){o[b]=true}if(!h&&e!=-1){o[e]=true}if(!h&&c!=-1){o[c]=true}if(!h&&f!=-1){o[f]=true}if(!h&&g!=-1){o[g]=true}o[this.currentSceneIndex]=true;o[d]=true;if(n!=-1){o[n]=true}if(!h&&m!=-1){o[m]=true}if(!h&&k!=-1){o[k]=true}if(!h&&l!=-1){o[l]=true}if(!h&&j!=-1){o[j]=true}if(!h&&i!=-1){o[i]=true}this.textureManager.preloadScenes(o)},updateSlideNumber:function(){var c=this.currentSceneIndex;debugMessage(kDebugShowController_UpdateSlideNumber,"this.currentSceneIndex: "+this.currentSceneIndex);if(this.state==kShowControllerState_IdleAtFinalState){debugMessage(kDebugShowController_UpdateSlideNumber,"- but because we're waiting at end state, we need to add one...");c++}var b=this.scriptManager.slideIndexFromSceneIndex(c);if(this.firstSlide){var a=this;runInNextEventLoop(function(){a.startSoundTrack();a.displayManager.clearLaunchMode()});this.firstSlide=false}debugMessage(kDebugShowController_UpdateSlideNumber,"- that makes slide index: "+b);if(this.currentSlideIndex!=b){debugMessage(kDebugShowController_UpdateSlideNumber,"- this differs from previous index of "+this.currentSlideIndex+", update display and inform delegate...");this.previousSlideIndex=this.currentSlideIndex;this.currentSlideIndex=b;this.displayManager.updateSlideNumber(this.currentSlideIndex+1,this.script.slideCount);this.delegate.propertyChanged(kPropertyName_currentSlide,this.currentSlideIndex+1)}else{debugMessage(kDebugShowController_UpdateSlideNumber,"- this has not changed, nothing to do...")}},showInfoPanel:function(){debugMessage(kDebugShowController_ShowInfoPanel);this.clearExistingAnimations();this.displayManager.showInfoPanel();this.touchController.setTouchTrackingEnabled(false)},hideInfoPanel:function(){debugMessage(kDebugShowController_HideInfoPanel,"hide the info panel and re-show the slides");this.displayManager.hideInfoPanel();debugMessage(kDebugShowController_HideInfoPanel,"re-enable touch tracking");this.touchController.setTouchTrackingEnabled(true);debugMessage(kDebugShowController_HideInfoPanel,"we're done")},handleStageSizeDidChangeEvent:function(a){debugMessage(kDebugShowController_HandleStageSizeDidChangeEvent,"need to update TouchController with new track area");this.touchController.setTrackArea(a.memo.left,a.memo.top,a.memo.width,a.memo.height)},handleTapEvent:function(a){debugMessage(kDebugShowController_HandleTapEvent,"fingers: "+a.memo.fingers);var b={pointX:a.memo.pointX,pointY:a.memo.pointY};this.processClickOrTapAtDisplayCoOrds(b)},processClickOrTapAtDisplayCoOrds:function(c){var b=false;var d="";if(this.displayManager.isInfoPanelShowing()){debugMessage(kDebugShowController_ProcessClickOrTapAtDisplayCoOrds,"info panel is showing, ignore clicks and taps");return}debugMessage(kDebugShowController_ProcessClickOrTapAtDisplayCoOrds,"display location: ("+c.pointX+","+c.pointY+")");var a=this.displayManager.convertDisplayCoOrdsToShowCoOrds(c);debugMessage(kDebugShowController_ProcessClickOrTapAtDisplayCoOrds,"- show location: ("+a.pointX+","+a.pointY+")");if(a.pointX==-1){debugMessage(kDebugShowController_ProcessClickOrTapAtDisplayCoOrds,"- outside of show area")}else{d=this.findHyperlinkAtCoOrds(a);b=(d!="")}if(b){debugMessage(kDebugShowController_ProcessClickOrTapAtDisplayCoOrds,"- hyperlink invokded. url: "+d);this.processHyperlinkUrl(d)}else{this.advanceToNextBuild("processClickOrTapAtDisplayCoOrds")}},processHyperlinkUrl:function(g){debugMessage(kDebugShowController_ProcessHyperlinkUrl,g);if(g.indexOf("?slide=")==0){var f=g.substring(7);debugMessage(kDebugShowController_ProcessHyperlinkUrl,"- it's a jump to slide "+f);var d=parseInt(f);this.jumpToSlide(d)}else{if(g.indexOf("?action=exitpresentation")==0){debugMessage(kDebugShowController_ProcessHyperlinkUrl,"- it's a call to exit the presentation");this.exitShow()}else{if(g.indexOf("?action=retreat")==0){if(this.previousSlideIndex!=-1){debugMessage(kDebugShowController_ProcessHyperlinkUrl,"- it's a jump to the last viewed slide, which was "+this.previousSlideIndex+1);this.jumpToSlide(this.previousSlideIndex+1)}else{debugMessage(kDebugShowController_ProcessHyperlinkUrl,"- it's a jump to the last viewed slide, but this is the first slide we've displayed")}}else{if(g.indexOf("?id=")==0){var f=g.substring(4);debugMessage(kDebugShowController_ProcessHyperlinkUrl,"- it's a jump to a slide number: "+f)}else{if(g.indexOf("http:")==0){debugMessage(kDebugShowController_ProcessHyperlinkUrl,"- it's a jump to a web page: "+g);window.open(g,"_blank",null)}else{if(g.indexOf("mailto:")==0){debugMessage(kDebugShowController_ProcessHyperlinkUrl,"- it's an e-mail link: "+g);window.location=g}else{if(g.indexOf("playMovie:")==0){var h=g.indexOf(":");var e=g.substring(h+1);debugMessage(kDebugShowController_ProcessHyperlinkUrl,"- it's a playMovie directive, movieObjectId: '"+e+"'");if(gMoviesRespectTransforms){var c=e.substring(0,e.lastIndexOf("-movieObject"))+"-root"}else{var c=e.substring(0,e.lastIndexOf("-movieObjectClone"))+"-root"}var a=document.getElementById(c);var b=a.style.opacity;if(b==0){this.advanceToNextBuild("invisibleMovie");return}this.startMoviePlaying(e,true)}else{debugMessage(kDebugShowController_ProcessHyperlinkUrl,"- it's an unknown hyperlink type: "+g)}}}}}}}},addMovieHyperlink:function(c,a){var b={targetRectangle:c,url:a};this.movieHyperlinks.push(b);debugMessage(kDebugShowController_AddMovieHyperlink,"movie hyperlink added, now there are "+this.movieHyperlinks.length)},clearMovieHyperlinks:function(){debugMessage(kDebugShowController_ClearMovieHyperlinks,"deleting old movie hyperlinks array and creating new one...");delete this.movieHyperlinks;this.movieHyperlinks=new Array()},clearAllHyperlinks:function(){debugMessage(kDebugShowController_ClearAllHyperlinks,"deleting old hyperlinks array and creating new one...");this.stageManager.clearAllHyperlinks();delete this.activeHyperlinks;this.activeHyperlinks=new Array()},findHyperlinkAtCoOrds:function(b){var a=0;var d;if(this.activeHyperlinks!=null){a=this.activeHyperlinks.length}debugMessage(kDebugShowController_FindHyperlinkAtCoOrds,"showCoOrds: ("+b.pointX+","+b.pointY+")");debugMessage(kDebugShowController_FindHyperlinkAtCoOrds,"- looking through "+a+" hyperlinks...");for(d=a;d>0;d--){var e=this.activeHyperlinks[d-1];var c=e.targetRectangle;hyperlinkLeft=Math.floor(c.x);hyperlinkTop=Math.floor(c.y);hyperlinkRight=hyperlinkLeft+Math.floor(c.width);hyperlinkBottom=hyperlinkTop+Math.floor(c.height);debugMessage(kDebugShowController_FindHyperlinkAtCoOrds,"- "+d+": (left: "+hyperlinkLeft+", top:"+hyperlinkTop+", right: "+hyperlinkRight+", bottom: "+hyperlinkBottom+", width: "+c.width+", height: "+c.height+")");if((b.pointX>=hyperlinkLeft)&&(b.pointX<=hyperlinkRight)&&(b.pointY>=hyperlinkTop)&&(b.pointY<=hyperlinkBottom)){debugMessage(kDebugShowController_FindHyperlinkAtCoOrds,"---- found it: url: "+e.url);return e.url}else{debugMessage(kDebugShowController_FindHyperlinkAtCoOrds,"---- not in this one...")}}debugMessage(kDebugShowController_FindHyperlinkAtCoOrds,"- no hyperlink containing this point found.");return""},handleSwipeEvent:function(a){debugMessage(kDebugShowController_HandleSwipeEvent,"direction: "+a.memo.direction+" fingers: "+a.memo.fingers);if(a.memo.direction=="left"){switch(a.memo.fingers){case 1:this.advanceToNextBuild("handleSwipeEvent");break;case 2:this.advanceToNextSlide("handleSwipeEvent");break;default:break}}else{if(a.memo.direction=="right"){switch(a.memo.fingers){case 1:this.goBackToPreviousSlide("handleSwipeEvent");break;case 2:this.goBackToPreviousBuild("handleSwipeEvent");break;default:break}}else{debugMessage(kDebugShowController_HandleSwipeEvent,"unsupported swipe")}}},toggleMute:function(){var a;if(this.muted){debugMessage(kDebugShowController_ToggleMute,"turn sound on...");a=false}else{debugMessage(kDebugShowController_ToggleMute,"turn sound off...");a=true}this.setMuted(a);this.delegate.propertyChanged(kPropertyName_muted,this.muted)},setMuted:function(a){this.muted=a;if(this.soundTrackPlayer){debugMessage(kDebugShowController_setMuted,"- setting mute state of running soundtrack...");this.soundTrackPlayer.muted=this.muted}else{debugMessage(kDebugShowController_setMuted,"- there is no running soundtrack to mute/un-mute")}debugMessage(kDebugShowController_setMuted,"- check if there are any running videos...");this.stageManager.setMutedStateOnAllVideoElements(this.muted);this.updateNavigationButtons();debugMessage(kDebugShowController_setMuted,"- and we're done!")},handleLinkControl:function(){var a="http://public.iwork.com/document/?a="+getUrlParameter("a")+"&d="+getUrlParameter("d");window.open(a,"_top")},advanceToNextBuild:function(c){if(this.script.showMode==kShowModeHyperlinksOnly&&c!="currentSceneDidComplete"){debugMessage(kDebugShowController_AdvanceToNextBuild,"can't do it, we're in hyperlinks only mode");return false}if(this.displayManager.infoPanelIsShowing){debugMessage(kDebugShowController_AdvanceToNextBuild,"can't do it, info panel is showing");return false}debugMessage(kDebugShowController_AdvanceToNextBuild,"================================================================================");debugMessage(kDebugShowController_AdvanceToNextBuild,"=== A D V A N C E T O N E X T B U I L D ===");debugMessage(kDebugShowController_AdvanceToNextBuild,"================================================================================");debugMessage(kDebugShowController_AdvanceToNextBuild,"- context: "+c);debugMessage(kDebugShowController_AdvanceToNextBuild,"- state: "+this.state);debugMessage(kDebugShowController_AdvanceToNextBuild,"- currentSceneIndex: "+this.currentSceneIndex);debugMessage(kDebugShowController_AdvanceToNextBuild,"- nextSceneIndex: "+this.nextSceneIndex);this.debugTimerAdvanceToBuild=new DebugTimer(kDebugTimer_AdvanceToNextBuild);this.debugTimerAdvanceToBuild_to_ApplyAnimations=new DebugTimer(kDebugTimer_AdvanceToNextBuild_to_ApplyAnimations);var a=false;switch(this.state){case kShowControllerState_IdleAtFinalState:if(this.nextSceneIndex==-1){debugMessage(kDebugShowController_AdvanceToNextBuild,"- this.nextSceneIndex is -1, that's the end!");break}debugMessage(kDebugShowController_AdvanceToNextBuild,"- we're sitting idle on final state of "+this.currentSceneIndex+", jump to next scene... ("+this.nextSceneIndex+")");var d;if(this.nextSceneIndex>this.currentSceneIndex){debugMessage(kDebugShowController_AdvanceToNextBuild,"next > current, we're NOT looping back to the start, so play animations after jump");d=true}else{debugMessage(kDebugShowController_AdvanceToNextBuild,"next <= current, we ARE looping back to the start, so do NOT play animations after jump");d=false}a=true;this.jumpToScene(this.nextSceneIndex,d);break;case kShowControllerState_IdleAtInitialState:if(this.currentSceneIndex>=this.script.numScenes){if(this.script.loopSlideshow==false){debugMessage(kDebugShowController_AdvanceToNextBuild,"- we're at the end and this is NOT a looping show, can't advance")}else{debugMessage(kDebugShowController_AdvanceToNextBuild,"- we're at the end but this IS a looping show, jump to start");a=true;this.jumpToScene(0,false)}}else{debugMessage(kDebugShowController_AdvanceToNextBuild,"- we're sitting idle on initial state of "+this.currentSceneIndex+", preload next scene ("+this.nextSceneIndex+"), and play current scene...");a=true;this.playCurrentScene()}break;default:debugMessageAlways(kDebugShowController_AdvanceToNextBuild,"nextSceneIndex: "+this.nextSceneIndex+" can't advance now, not in an idle state (currently in '"+this.state+"' state)");if(this.queuedUserAction==null){debugMessageAlways(kDebugShowController_AdvanceToNextBuild,"- queue up action to run in next idle time");var b=this;a=true;this.queuedUserAction=function(){b.advanceToNextBuild(c)}}break}debugMessage(kDebugShowController_AdvanceToNextBuild,"complete, context:"+c);return a},advanceToNextSlide:function(c){if(this.script.showMode==kShowModeHyperlinksOnly){debugMessage(kDebugShowController_AdvanceToNextSlide,"can't do it, we're in hyperlinks only mode");return}if(this.displayManager.infoPanelIsShowing){debugMessage(kDebugShowController_AdvanceToNextBuild,"can't do it, info panel is showing");return}debugMessage(kDebugShowController_AdvanceToNextSlide,"================================================================================");debugMessage(kDebugShowController_AdvanceToNextSlide,"=== A D V A N C E T O N E X T S L I D E ===");debugMessage(kDebugShowController_AdvanceToNextSlide,"================================================================================");debugMessage(kDebugShowController_AdvanceToNextSlide,"- context: "+c);debugMessage(kDebugShowController_AdvanceToNextSlide,"- state: "+this.state);debugMessage(kDebugShowController_AdvanceToNextSlide,"- currentSceneIndex: "+this.currentSceneIndex);var b=this.currentSceneIndex;switch(this.state){case kShowControllerState_IdleAtFinalState:b++;case kShowControllerState_IdleAtInitialState:var e=this.scriptManager.slideIndexFromSceneIndex(b)+1;var d=e+1;debugMessage(kDebugShowController_AdvanceToNextSlide,"- sceneIndexToUse: "+b);debugMessage(kDebugShowController_AdvanceToNextSlide,"- currentSlide: "+e);debugMessage(kDebugShowController_AdvanceToNextSlide,"- nextSlide: "+d);if(d==this.script.slideCount){if(this.script.loopSlideshow){nextSlideIndex=0;debugMessage(kDebugShowController_AdvanceToNextSlide,"- nextSlide: "+d+" (Adjusted for looping)")}}if(d<=this.script.slideCount){debugMessage(kDebugShowController_AdvanceToNextSlide,"- jumping to next slide...");this.jumpToSlide(d)}else{debugMessageAlways(kDebugShowController_AdvanceToNextSlide,"- can't advance, alrady at end of show")}break;default:debugMessage(kDebugShowController_AdvanceToNextSlide,"can't advance now, not in an idle state (currently in '"+this.state+"' state)");if(this.queuedUserAction==null){var a=this;this.queuedUserAction=function(){return a.advanceToNextSlide(c)}}break}},goBackToPreviousSlide:function(c){if(this.script.showMode==kShowModeHyperlinksOnly){debugMessage(kDebugShowController_GoBackToPreviousSlide,"can't do it, we're in hyperlinks only mode");return false}if(this.displayManager.infoPanelIsShowing){debugMessage(kDebugShowController_AdvanceToNextBuild,"can't do it, info panel is showing");return false}debugMessage(kDebugShowController_GoBackToPreviousSlide,"================================================================================");debugMessage(kDebugShowController_GoBackToPreviousSlide,"=== G O B A C K T O P R E V I O U S S L I D E ===");debugMessage(kDebugShowController_GoBackToPreviousSlide,"================================================================================");debugMessage(kDebugShowController_GoBackToPreviousSlide,"- context: "+c);debugMessage(kDebugShowController_GoBackToPreviousSlide,"- state: "+this.state);debugMessage(kDebugShowController_GoBackToPreviousSlide,"- currentSceneIndex: "+this.currentSceneIndex);var b=this.currentSceneIndex;var i=false;switch(this.state){case kShowControllerState_IdleAtFinalState:b++;case kShowControllerState_Playing:case kShowControllerState_IdleAtInitialState:var a=this.scriptManager.slideIndexFromSceneIndex(b);var g=this.scriptManager.sceneIndexFromSlideIndex(a);var e=this.script.eventTimelines[g];var h=g;if(this.isSceneTransitionDelayOnly(g)){h++}debugMessage(kDebugShowController_GoBackToPreviousSlide,"- sceneIndexToUse: "+b);debugMessage(kDebugShowController_GoBackToPreviousSlide,"- currentSlideIndex: "+a);debugMessage(kDebugShowController_GoBackToPreviousSlide,"- firstSceneOnCurrentSlide: "+g);debugMessage(kDebugShowController_GoBackToPreviousSlide,"- firstSceneIndexToUse: "+h);if(h!=b){debugMessage(kDebugShowController_GoBackToPreviousSlide,"- we're part-way through the current slide, go back to the beginning of this slide");i=true;this.jumpToScene(h,false)}else{if((a==0)&&(this.script.loopSlideshow==false)){debugMessage(kDebugShowController_GoBackToPreviousSlide,"- can't go back, already at start of show")}else{var d=(a>0?a-1:this.script.slideCount-1);debugMessage(kDebugShowController_GoBackToPreviousSlide,"- previousSlideIndex: "+d);i=true;this.jumpToSlide(d+1)}}break;default:debugMessage(kDebugShowController_GoBackToPreviousSlide,"can't go back now, not in an idle state (currently in '"+this.state+"' state)");if(this.queuedUserAction==null){var f=this;i=true;this.queuedUserAction=function(){return f.goBackToPreviousSlide(c)}}break}return i},isSceneTransitionDelayOnly:function(d){debugMessage(kDebugShowController_IsSceneTransitionDelayOnly,"sceneIndex: "+d);var b=this.script.eventTimelines[d];if(b.automaticPlay!=1){debugMessage(kDebugShowController_IsSceneTransitionDelayOnly,"- not a transition-delay only scene, because it is NOT autoplay");return false}var c=b.eventAnimations;if(c.length!=1){debugMessage(kDebugShowController_IsSceneTransitionDelayOnly,"- not a transition-delay only scene, because there is NOT exactly 1 animation in the scene");return false}var a=c[0];if(a.effect!="transition-delay"){debugMessage(kDebugShowController_IsSceneTransitionDelayOnly,"- not a transition-delay only scene, because the effect name is NOT 'transition-delay'");return false}debugMessage(kDebugShowController_IsSceneTransitionDelayOnly,"sceneIndex: "+d+" is a transition-delay only scene");return true},calculatePreviousSceneIndex:function(b){debugMessage(kDebugShowController_CalculatePreviousSceneIndex,"sceneIndex: "+b);var a=b;do{a--;if(a==-1){a=this.script.lastSceneIndex}}while(this.isSceneTransitionDelayOnly(a));debugMessage(kDebugShowController_CalculatePreviousSceneIndex,"previousSceneIndex: "+a);return a},goBackToPreviousBuild:function(d){if(this.script.showMode==kShowModeHyperlinksOnly){debugMessage(kDebugShowController_GoBackToPreviousBuild,"can't do it, we're in hyperlinks only mode");return}if(this.displayManager.infoPanelIsShowing){debugMessage(kDebugShowController_AdvanceToNextBuild,"can't do it, info panel is showing");return}debugMessage(kDebugShowController_GoBackToPreviousBuild,"================================================================================");debugMessage(kDebugShowController_GoBackToPreviousBuild,"=== G O B A C K T O P R E V I O U S B U I L D ===");debugMessage(kDebugShowController_GoBackToPreviousBuild,"================================================================================");debugMessage(kDebugShowController_GoBackToPreviousBuild,"- context: "+d);debugMessage(kDebugShowController_GoBackToPreviousBuild,"- state: "+this.state);debugMessage(kDebugShowController_GoBackToPreviousBuild,"- currentSceneIndex: "+this.currentSceneIndex);var b=this.currentSceneIndex;switch(this.state){case kShowControllerState_IdleAtFinalState:b++;case kShowControllerState_Playing:case kShowControllerState_IdleAtInitialState:debugMessage(kDebugShowController_GoBackToPreviousBuild,"- sceneIndexToUse: "+b);if((b==0)&&(this.script.loopSlideshow==false)){debugMessage(kDebugShowController_GoBackToPreviousSlide,"- can't go back, already at start of show")}else{var c=this.calculatePreviousSceneIndex(b);debugMessage(kDebugShowController_GoBackToPreviousBuild,"-previousSceneIndex: "+c);this.jumpToScene(c,false)}break;default:debugMessage(kDebugShowController_GoBackToPreviousSlide,"can't go back now, not in an idle state (currently in '"+this.state+"' state)");if(this.queuedUserAction==null){var a=this;this.queuedUserAction=function(){return a.goBackToPreviousBuild(d)}}break}},handleStageIsReadyEvent:function(a){debugMessage(kDebugShowController_HandleStageIsReadyEvent)},handleScriptDidDownloadEvent:function(e){debugMessage(kDebugShowController_HandleScriptDidDownloadEvent);switch(this.state){case kShowControllerState_DownloadingScript:this.script=e.memo.script;this.script.numScenes=this.script.eventTimelines.length-1;if(this.script.showMode==kShowModeHyperlinksOnly){this.displayManager.setHyperlinksOnlyMode()}debugMessage(kDebugShowController_HandleScriptDidDownloadEvent,"- this.script.numScenes: "+this.script.numScenes);debugMessage(kDebugShowController_HandleScriptDidDownloadEvent,"- switching to 'starting'...");this.changeState(kShowControllerState_Starting);debugMessage(kDebugShowController_HandleScriptDidDownloadEvent,"- checking to see if a restarting scene index was specified in url...");var h;var c=parseInt(getUrlParameter("restartingSceneIndex"));var f=document.URL.split("?");var a=f[0].split("#");if(a[1]){c=parseInt(a[1])}if(c){debugMessageAlways(kDebugShowController_HandleScriptDidDownloadEvent,"- found a restarting scene index, using that... ("+c+")");h=c}else{debugMessage(kDebugShowController_HandleScriptDidDownloadEvent,"- checking to see if a starting slide number was specified in url...");var d=getUrlParameter("currentSlide");var g;if(d){g=parseInt(d)}else{debugMessage(kDebugShowController_HandleScriptDidDownloadEvent,"- nope, not there, use 1...");g=1}h=this.scriptManager.sceneIndexFromSlideIndex(g-1)}var b=this.script.eventTimelines[h];this.jumpToScene(h,(b.automaticPlay==1));break;default:debugMessage(kDebugShowController_HandleScriptDidDownloadEvent,"- hmmm we seem to have arrived here from an unpredicted state");break}},handleScriptDidNotDownloadEvent:function(b){debugMessage(kDebugShowController_HandleScriptDidNotDownloadEvent);var a=this.promptUserToTryAgain(kUnableToReachiWorkTryAgain);if(a){this.scriptManager.downloadScript()}else{this.displayManager.clearLaunchMode();this.displayManager.hideWaitingIndicator();window.console.log("exitShow() commented out")}},startSoundTrack:function(){if(gMode==kModeMobile){debugMessage(kDebugShowController_StartSoundTrack,"soundTrackMode are currently not supported on the phone...");return}if(this.script.soundTrackMode==kSoundTrackModeOff){debugMessage(kDebugShowController_StartSoundTrack,"soundTrackMode is 'off', nothing to do here...");return}if(this.script.soundTrackMedia==null){debugMessage(kDebugShowController_StartSoundTrack,"soundTrackMedia is null, nothing to do here...");return}debugMessage(kDebugShowController_StartSoundTrack,"soundTrackMedia is present, start it playing... (There are "+this.script.soundTrackMedia.length+" items)");this.currentSoundTrackIndex=0;this.playNextItemInSoundTrack();this.updateNavigationButtons()},playNextItemInSoundTrack:function(){var c=this.script.soundTrackMedia[this.currentSoundTrackIndex];var b=this.textureManager.urlForMovie(c);debugMessage(kDebugShowController_PlayNextItemInSoundTrack,"time: "+Date().toString()+", start item "+this.currentSoundTrackIndex+" playing...");this.soundTrackPlayer=new Audio();var a=this;this.soundTrackPlayer.muted=this.muted;this.soundTrackPlayer.style.display="none";this.soundTrackPlayer.src=b;this.soundTrackPlayer.observe("ended",function(d){a.soundTrackItemDidComplete()},false);this.soundTrackPlayer.load();this.soundTrackPlayer.play()},soundTrackItemDidComplete:function(){debugMessage(kDebugShowController_SoundTrackItemDidComplete,"time: "+Date().toString()+", item "+this.currentSoundTrackIndex+" completed playing, lets see if there's anything else to play...");this.currentSoundTrackIndex++;if(this.currentSoundTrackIndex<this.script.soundTrackMedia.length){debugMessage(kDebugShowController_SoundTrackItemDidComplete,"- why yes there is...");this.playNextItemInSoundTrack()}else{if(this.script.soundTrackMode==kSoundTrackModePlayOnce){debugMessage(kDebugShowController_SoundTrackItemDidComplete,"- nope, that's it");this.soundTrackPlayer=null;this.updateNavigationButtons()}else{if(this.script.soundTrackMode==kSoundTrackModeLooping){debugMessage(kDebugShowController_SoundTrackItemDidComplete,"- nope, but we're in loop mode so take it from the top...");this.startSoundTrack()}}}},promptUserToTryAgain:function(b){var a=false;if(gMode==kModeMobile){debugMessage(kDebugShowController_PromptUserToTryAgain,"we're in mobile mode, pop up a 'confirm' dialog...");a=confirm(b)}else{debugMessage(kDebugShowController_PromptUserToTryAgain,"we're in desktop mode, pop up a 'confirm' dialog...");a=confirm(b)}return a},jumpToSlide:function(a){var b=a-1;var c=this.scriptManager.sceneIndexFromSlideIndex(b);this.jumpToScene(c,false)},jumpToScene:function(d,c){this.debugTimerJumpToScene=new DebugTimer(kDebugTimer_JumpToScene);debugMessage(kDebugShowController_JumpToScene,"sceneIndex: "+d+" playAnimations: "+(c?"true":"false")+" state: "+this.state);switch(this.state){case kShowControllerState_Starting:case kShowControllerState_IdleAtInitialState:case kShowControllerState_IdleAtFinalState:case kShowControllerState_ReadyToJump:break;default:debugMessageAlways(kDebugShowController_JumpToScene,"can't jump now, currently in '"+this.state+"' state which does not supports jumping...");return}if(this.textureManager.isScenePreloaded(d)==false){debugMessageAlways(kDebugShowController_JumpToScene,"- scene "+d+" is not yet preloaded, issuing request to load it now and waiting...");var b={sceneToLoad:d,playAnimationsAfterLoading:c};this.changeState(kShowControllerState_WaitingToJump);this.textureManager.unloadScene(d);this.textureManager.loadScene(d);this.setupWaitForSceneToLoadPoller(b);return}this.changeState(kShowControllerState_SettingUpScene);var a=this;runInNextEventLoop(function(){a.jumpToScene_partThree(d,c)})},jumpToScene_partTwo:function(c,b){this.changeState(kShowControllerState_SettingUpScene);debugMessage(kDebugShowController_JumpToScene_partTwo,"- state changed (UI controls should disable), run partThree in next event loop...");var a=this;runInNextEventLoop(function(){a.jumpToScene_partThree(c,b)})},jumpToScene_partThree:function(e,b){debugMessage(kDebugShowController_JumpToScene_partThree,"sceneIndex: "+e+" playAnimations: "+b);if(this.sceneIndexOfPrebuiltAnimations!=e){this.createAnimationsForScene(e)}debugStopTimer(this.debugTimerJumpToScene);var d=false;if(gOS==kOSWindows){var c=this.scriptManager.getMoviesInScene(e);if(c&&c.length>0){debugMessageAlways(kDebugShowController_DisplayScene,"we're on Windows, and this scene contains movies, we need to wait for the next event loop to avoid flicker...");d=true}}if(d){var a=this;runInNextEventLoop(function(){a.jumpToScene_partFour(e,b)})}else{this.jumpToScene_partFour(e,b)}},jumpToScene_partFour:function(b,a){this.displayScene(b,a?1:0);if(a){debugMessage(kDebugShowController_JumpToScene_partThree,"- playAnimations was set to 'true' so let 'er rip...");this.playCurrentScene()}else{this.changeState(kShowControllerState_IdleAtInitialState)}},calculateNextSceneIndex:function(b){var a=this.calculateNextSceneIndex_internal(b);if(gMode==kModeMobile){if(this.scriptManager.isOnlyActionInSceneAMovieStart(a)){debugMessage(kDebugShowController_CalculateNextSceneIndex,"we're on a phone and the next build is only a movie start, go to one after that...");a=this.calculateNextSceneIndex_internal(a)}}return a},calculateNextSceneIndex_internal:function(b){var a=-1;debugMessage(kDebugShowController_CalculateNextSceneIndex,"using sceneIndex: "+b);debugMessage(kDebugShowController_CalculateNextSceneIndex,"- state: "+this.state);debugMessage(kDebugShowController_CalculateNextSceneIndex,"- numSlides: "+this.script.slideCount);debugMessage(kDebugShowController_CalculateNextSceneIndex,"- numScenes: "+this.script.numScenes);debugMessage(kDebugShowController_CalculateNextSceneIndex,"- lastSceneIndex: "+this.script.lastSceneIndex);if(b<this.script.lastSceneIndex){a=b+1;debugMessage(kDebugShowController_CalculateNextSceneIndex,"- we're NOT at the end, so set it to current + 1... ("+b+" + 1 = "+a+")")}else{if(this.script.loopSlideshow){a=0;debugMessage(kDebugShowController_CalculateNextSceneIndex,"- we're at the end, and we're looping so set it to 0...")}else{a=-1;debugMessage(kDebugShowController_CalculateNextSceneIndex,"- we're at the end, and we're NOT looping so set it to -1...")}}debugMessage(kDebugShowController_CalculateNextSceneIndex,"---------- for sceneIndex: "+b+" nextSceneIndex is: "+a);return a},assignNextSceneIndex:function(){debugMessage(kDebugShowController_AssignNextSceneIndex);this.nextSceneIndex=this.calculateNextSceneIndex(this.currentSceneIndex)},playCurrentScene:function(){debugMessage(kDebugShowController_PlayCurrentScene,"this.currentSceneIndex: "+this.currentSceneIndex+" this.overallEndTime: "+this.overallEndTime);debugMessage(kDebugShowController_PlayCurrentScene,"- check for special case of zero delay automatic play on the first scene...");var b=false;var c=1500;if(this.currentSceneIndex==0){debugMessage(kDebugShowController_PlayCurrentScene,"- it's the first scene...");if(this.script.eventTimelines[this.currentSceneIndex].automaticPlay==1){debugMessage(kDebugShowController_PlayCurrentScene,"- and it's automatic play...");if(this.earliestBeginTime==0){debugMessage(kDebugShowController_PlayCurrentScene,"- and it's has no delay...");b=true}else{debugMessage(kDebugShowController_PlayCurrentScene,"- nevermind, it's has a delay...")}}else{debugMessage(kDebugShowController_PlayCurrentScene,"- nevermind, it's not automatic play...")}}else{debugMessage(kDebugShowController_PlayCurrentScene,"- nevermind, it's not the first scene...")}this.clearExistingAnimations();var a=this;if(b){debugMessage(kDebugShowController_PlayCurrentScene,"- introduce 1.5s delay so the first scene will be visible for a split second...");setTimeout(function(){a.playCurrentScene_partTwo()},c)}else{this.playCurrentScene_partTwo()}},playCurrentScene_partTwo:function(){debugMessage(kDebugShowController_PlayCurrentScene," partTwo: this.currentSceneIndex: "+this.currentSceneIndex+" this.overallEndTime: "+this.overallEndTime);this.changeState(kShowControllerState_Playing);var c=this.applyAnimationsForScene();var b=this.scriptManager.getMoviesInScene(this.currentSceneIndex+1);var d=false;if(b&&b.length>0){debugMessage(kDebugShowController_PlayCurrentScene,"- next scene ("+(this.currentScene+1)+" has some movies, so set anyMoviesInNextScene to true");d=true}var a=this;setTimeout(function(){a.currentSceneDidComplete(c,d)},this.overallEndTime*1000+100);debugStopTimer(this.debugTimerAdvanceToBuild)},createHyperlinksForCurrentState:function(a){debugMessage(kDebugShowController_CreateHyperlinksForCurrentState);debugMessage(kDebugShowController_CreateHyperlinksForCurrentState,"- context:"+a);debugMessage(kDebugShowController_CreateHyperlinksForCurrentState,"- state:"+this.state);debugMessage(kDebugShowController_CreateHyperlinksForCurrentState,"- currentSceneIndex:"+this.currentSceneIndex);debugMessage(kDebugShowController_CreateHyperlinksForCurrentState,"- lastSceneIndex:"+this.script.lastSceneIndex);debugMessage(kDebugShowController_CreateHyperlinksForCurrentState,"- hyperlinks only:"+((this.script.showMode==kShowModeHyperlinksOnly)?"YES":"NO"));debugMessage(kDebugShowController_CreateHyperlinksForCurrentState,"- looping:"+(this.script.loopSlideshow?"YES":"NO"));var b=-1;switch(this.state){case kShowControllerState_IdleAtInitialState:debugMessage(kDebugShowController_CreateHyperlinksForCurrentState,"- we're at initial state, always use current scene index");b=this.currentSceneIndex;break;case kShowControllerState_IdleAtFinalState:debugMessage(kDebugShowController_CreateHyperlinksForCurrentState,"- we're at final state, check if we're at the end");if(this.currentSceneIndex<this.script.lastSceneIndex){debugMessage(kDebugShowController_CreateHyperlinksForCurrentState,"- we're not at the end, use next scene");b=this.currentSceneIndex+1}else{debugMessage(kDebugShowController_CreateHyperlinksForCurrentState,"- we're ARE at the end, check if we're in hyperlinks-only mode...");if(this.script.showMode==kShowModeHyperlinksOnly){debugMessage(kDebugShowController_CreateHyperlinksForCurrentState,"- we're ARE in hyperlinks-only mode, use current scene");b=this.currentSceneIndex}else{debugMessage(kDebugShowController_CreateHyperlinksForCurrentState,"- we're are NOT in hyperlinks-only mode, check if we're in looping mode...");if(this.script.loopSlideshow){debugMessage(kDebugShowController_CreateHyperlinksForCurrentState,"- we're ARE in looping mode, use next scene");b=this.currentSceneIndex+1}else{debugMessage(kDebugShowController_CreateHyperlinksForCurrentState,"- we're are NOT in looping mode, use next scene");b=this.currentSceneIndex+1}}}break;default:debugMessage(kDebugShowController_CreateHyperlinksForCurrentState,"- we're at not in an idle state, what to do? what to do?");break}if(b!=-1){this.clearAllHyperlinks();this.createHyperlinks(b)}},currentSceneDidComplete:function(d,e){debugMessage(kDebugShowController_CurrentSceneDidComplete,"this.currentSceneIndex: "+this.currentSceneIndex);this.changeState(kShowControllerState_IdleAtFinalState);if(this.nextSceneIndex==-1){debugMessage(kDebugShowController_CurrentSceneDidComplete,"- next scene is -1, nothing to do except update navigation button status");this.updateNavigationButtons()}else{if(this.scriptManager.isOnlyActionInSceneAMovieStart(this.currentSceneIndex)&&gMode==kModeMobile){debugMessage(kDebugShowController_CurrentSceneDidComplete,"- current scene is only a movie start and we're on a mobile device, proceed to next scene immediately...");this.advanceToNextBuild("currentSceneDidComplete")}else{if((this.script.eventTimelines[this.nextSceneIndex].automaticPlay==1)&&(this.currentSceneIndex<this.nextSceneIndex)){debugMessage(kDebugShowController_CurrentSceneDidComplete,"- next scene ("+this.nextSceneIndex+") is autoplay");if(this.isSceneTransitionDelayOnly(this.nextSceneIndex)){var c=this.script.eventTimelines[this.nextSceneIndex].eventAnimations[0].duration;debugMessage(kDebugShowController_CurrentSceneDidComplete,"- but it's only a 'transition-delay', so invoke the scene AFTER it after a delay of "+c+" seconds...");var a=this;setTimeout(function(){a.jumpToScene(a.nextSceneIndex+1,true)},c*1000)}else{debugMessage(kDebugShowController_CurrentSceneDidComplete,"- invoking advanceToNextBuild() on next event loop...");var a=this;runInNextEventLoop(function(){a.advanceToNextBuild("currentSceneDidComplete")})}}else{if((gMode==kModeMobile)&&(d==false)&&(e==true)){var b=this.currentSceneIndex+1;debugMessage(kDebugShowController_CurrentSceneDidComplete,"- next scene ("+b+") has a movie, since we're in mobile mode, advance to it...");var a=this;runInNextEventLoop(function(){a.jumpToScene(b,false)})}else{debugMessage(kDebugShowController_CurrentSceneDidComplete,"- we just finished animating, should be waiting on end state, prebuild animations for next scene and update navigation button status and add hyperlinks of next scene...");this.createAnimationsForScene(this.nextSceneIndex);this.updateNavigationButtons()}}}}},ensureInitialStateHasEmphasisTransform:function(g,f,c,e,d){var b=false;var a=this.initialStateForTexture(g,f);switch(c){case"translationEmphasis":b=(a.translationEmphasis!=null);break;case"rotationEmphasis":b=(a.rotationEmphasis!=null);break;case"opacityMultiplier":b=(a.opacityMultiplier!=null);break;case"scaleEmphasis":b=(a.scaleEmphasis!=null);break}if(b){return}debugMessage(kDebugShowController_EnsureInitialStateHasEmphasisTransform,"textureId: '"+f+"' has no initial emphasis transform");switch(c){case"translationEmphasis":debugMessage(kDebugShowController_EnsureInitialStateHasEmphasisTransform,"- using fromValue.translationEmphasis: ("+d.translationEmphasis+")");a.translationEmphasis=d.translationEmphasis;debugMessage(kDebugShowController_EnsureInitialStateHasEmphasisTransform,"- translationEmphasis is now: "+a.translationEmphasis);break;case"rotationEmphasis":debugMessage(kDebugShowController_EnsureInitialStateHasEmphasisTransform,"- using fromValue.rotationEmphasis: ("+d.rotationEmphasis+")");a.rotationEmphasis=d.rotationEmphasis;debugMessage(kDebugShowController_EnsureInitialStateHasEmphasisTransform,"- rotationEmphasis is now: "+a.rotationEmphasis);break;case"opacityMultiplier":debugMessage(kDebugShowController_EnsureInitialStateHasEmphasisTransform,"- using fromValue.opacityMultiplier: ("+d.opacityMultiplier+")");a.opacityMultiplier=d.opacityMultiplier;debugMessage(kDebugShowController_EnsureInitialStateHasEmphasisTransform,"- opacityMultiplier is now: "+a.opacityMultiplier);break;case"scaleEmphasis":debugMessage(kDebugShowController_EnsureInitialStateHasEmphasisTransform,"- using fromValue.scaleEmphasis: ("+d.scaleEmphasis+")");a.scaleEmphasis=d.scaleEmphasis;debugMessage(kDebugShowController_EnsureInitialStateHasEmphasisTransform,"- scaleEmphasis is now: "+a.scaleEmphasis);break}},preProcessSceneAnimations:function(J,O,z){var P=this.scriptManager.slideIndexFromSceneIndex(J);var n=new DebugTimer(kDebugTimer_PreProcessSceneAnimations);debugMessage(kDebugShowController_PreProcessSceneAnimations);debugMessage(kDebugShowController_PreProcessSceneAnimations,"------------------------------------------------------");debugMessage(kDebugShowController_PreProcessSceneAnimations,"- First, calculate overall duration of eventTimeline -");debugMessage(kDebugShowController_PreProcessSceneAnimations,"------------------------------------------------------");var i=0;var x=O.length;this.overallEndTime=0;this.earliestBeginTime=0;debugMessage(kDebugShowController_PreProcessSceneAnimations,"- numEventAnimations: "+x);for(i=0;i<x;i++){var o=O[i];var G=o.beginTime;var A=o.duration;var s=G+A;debugMessage(kDebugShowController_PreProcessSceneAnimations,"- iEventAnimation: "+i+": beginTime: "+G+": duration: "+A+" endTime: "+s);if(s>this.overallEndTime){this.overallEndTime=s;debugMessage(kDebugShowController_PreProcessSceneAnimations,"- that's a new maximum, overallEndTime now "+this.overallEndTime)}}debugMessage(kDebugShowController_PreProcessSceneAnimations,"this.overallEndTime: "+this.overallEndTime);debugMessage(kDebugShowController_PreProcessSceneAnimations,"------------------------------------------------------------------------------");debugMessage(kDebugShowController_PreProcessSceneAnimations,"- Second, build x-ref table between canvasObjectID and applicable textureIds -");debugMessage(kDebugShowController_PreProcessSceneAnimations,"------------------------------------------------------------------------------");var g={};var v={};this.movieCanvasObjectIdToTextureIdTable={};var F;var S=z.length;for(F=0;F<S;F++){var Q=z[F];var p=Q.canvasObjectID;var H=Q.texture;var c=H;if(this.isMovie(H)){H="movieCanvasObject."+P+"."+p;this.movieCanvasObjectIdToTextureIdTable[H]=c}debugMessage(kDebugShowController_PreProcessSceneAnimations,"- textureId: "+H);if(p!=null){debugMessage(kDebugShowController_PreProcessSceneAnimations,"---- has a canvasObjectID: "+p);v[c]=p;var E=g[p];if(E==null){debugMessage(kDebugShowController_PreProcessSceneAnimations,"------ this is the first texture with this canvasObjectID, creating entry in table...");E=new Array();g[p]=E}else{debugMessage(kDebugShowController_PreProcessSceneAnimations,"------ there are already textures with this canvasObjectID...")}debugMessage(kDebugShowController_PreProcessSceneAnimations,"------ appending textureId to array for this canvasObjectID...");E.push(H)}}debugMessage(kDebugShowController_PreProcessSceneAnimations,"- dumping canvasObjectToTextureLookupTable...");for(var p in g){debugMessage(kDebugShowController_PreProcessSceneAnimations,"- canvasObjectID: "+p);var E=g[p];var B;var y=E.length;for(B=0;B<y;B++){var H=E[B];debugMessage(kDebugShowController_PreProcessSceneAnimations,"--- textureId: "+H)}}debugMessage(kDebugShowController_PreProcessSceneAnimations,"- dumping textureIdToCanvasObjectIdLookupTable...");for(var H in v){debugMessage(kDebugShowController_PreProcessSceneAnimations,"- textureId: "+H+" => canvasObjectID: "+v[H])}debugMessage(kDebugShowController_PreProcessSceneAnimations,"- dumping movieCanvasObjectIdToTextureIdTable...");for(var N in this.movieCanvasObjectIdToTextureIdTable){debugMessage(kDebugShowController_PreProcessSceneAnimations,"- movieCanvasObjectId: "+N+" => textureId: "+this.movieCanvasObjectIdToTextureIdTable[N])}debugMessage(kDebugShowController_PreProcessSceneAnimations,"------------------------------------------------------------------------------");debugMessage(kDebugShowController_PreProcessSceneAnimations,"- Third, calculate individual delay and duration of each property animation -");debugMessage(kDebugShowController_PreProcessSceneAnimations,"------------------------------------------------------------------------------");this.textureAnimations={};for(i=0;i<x;i++){debugMessage(kDebugShowController_PreProcessSceneAnimations,"- iEventAnimation: "+i);var o=O[i];if(o.preprocessed==null||o.preprocessed==false){o.preprocessed=true;if((o.textures!=null)&&this.isMovie(o.textures[0])&&(o.animationType=="buildIn"||o.animationType=="buildOut")){if(o.effect!="apple:movie-start"){var N="movieCanvasObject-"+P+"-"+v[o.textures[0]];if(this.scriptManager.isMovieInScene(J,N,this.textureManager)){o.actions=new Array();o.actions[0]=new Object();var D=o.actions[0];D.action="hidden";D.beginTime=o.beginTime;D.duration=o.duration;D.texture=o.textures[0];D.timingFunction="linear";D.from=new Object();D.to=new Object();if(o.animationType=="buildIn"){D.from.scalar=1;D.to.scalar=0}else{D.from.scalar=0;D.to.scalar=1}}}}}var K=o.actions;if(K==null){K=o.noPluginActions}var I=false;var u=null;if((o.animationType!=null)&&(o.animationType=="actionBuild")){I=true;debugMessage(kDebugShowController_PreProcessSceneAnimations,"--- this one is an actionBuild...");var T=o.canvasObjectID;u=g[T];if(typeof(u)=="undefined"){debugMessage(kDebugShowController_PreProcessSceneAnimations,"- textureArray is undefined, using empty array");u=new Array()}}var R=K.length;var M;for(M=0;M<R;M++){var a=K[M];if(I==false){debugMessage(kDebugShowController_PreProcessSceneAnimations,"--- this one is NOT an actionBuild, create an array with 1 texture in it...");var H=a.texture;u=new Array();u[0]=H}var B;var y=u.length;for(B=0;B<y;B++){var H=u[B];var c=H;if(this.isMovie(H)){var p=v[H];var f="movieCanvasObject."+P+"."+p;debugMessage(kDebugShowController_PreProcessSceneAnimations,"- it's a movie, hack its id ("+H+") to use the canvasObjectID ("+p+") to yeild: "+f);H=f}var G=a.beginTime;var A=a.duration;var s=G+A;var w=a.action;if(w=="transform.translation.z"){if(o.effect!="apple:revolve"){w="z.order"}}debugMessage(kDebugShowController_PreProcessSceneAnimations,"- texure: "+H);var m=this.textureAnimations[H];if(m==null){debugMessage(kDebugShowController_PreProcessSceneAnimations,"- - was not in textureAnimations yet, adding now...");var b=this.isMovie(H);debugMessage(b?kDebugShowController_PreProcessSceneAnimations:kDebugSurpressMessage,"- - it's a movie, tag it in the 'textureAnimation' data structure...");m={numAnimatedKeys:0,numRequiredDivs:0,isMovie:b,originalTextureId:c,keyAnimations:{}};this.textureAnimations[H]=m}if(w=="rotationEmphasis"){var j={x:a.from.rotationEmphasis[0],y:a.from.rotationEmphasis[1],};m.anchorPoint=j;debugMessage(kDebugShowController,"preProcessSceneAnimations","- squirreled away anchor point of "+j.x+","+j.y+" for texture "+H)}var l=m.keyAnimations[w];debugMessage(kDebugShowController_PreProcessSceneAnimations,"- keyName: "+w);if(l==null){debugMessage(kDebugShowController_PreProcessSceneAnimations,"- - was not in textureAnimation.keyAnimations yet, adding now...");l={earliestBeginTime:G,latestEndTime:-1,keyActions:[]};m.keyAnimations[w]=l;m.numAnimatedKeys++;if((w!="isPlaying")&&(w!="opacityMultiplier")&&(w!="zOrderHint")&&(w!="hidden")){m.numRequiredDivs++;debugMessage(kDebugShowController_PreProcessSceneAnimations,"- - '"+w+"' requires a div, increment count...")}else{debugMessage(kDebugShowController_PreProcessSceneAnimations,"- - '"+w+"' does NOT requires a div, don't increment count...")}}if(s>l.latestEndTime){debugMessage(kDebugShowController_PreProcessSceneAnimations,"- endTime of "+s+" is a new latest, updating...");l.latestEndTime=s}}}}debugMessage(kDebugShowController_PreProcessSceneAnimations,"-----------------------------------------------------------------------------------------------------------------------");debugMessage(kDebugShowController_PreProcessSceneAnimations,"- Fourth, iterate over all actions in all eventAnimations, converting there begin/duration to % of individual duration -");debugMessage(kDebugShowController_PreProcessSceneAnimations,"-----------------------------------------------------------------------------------------------------------------------");for(i=0;i<x;i++){debugMessage(kDebugShowController_PreProcessSceneAnimations,"- iEventAnimation: "+i);var o=O[i];var K=o.actions;if(K==null){K=o.noPluginActions}var I=false;var u=null;if((o.animationType!=null)&&(o.animationType=="actionBuild")){I=true;debugMessage(kDebugShowController_PreProcessSceneAnimations,"--- this one is an actionBuild...");var T=o.canvasObjectID;u=g[T];if(typeof(u)=="undefined"){debugMessage(kDebugShowController_PreProcessSceneAnimations,"- textureArray is undefined, using empty array");u=new Array()}}var R=K.length;var M;for(M=0;M<R;M++){var a=K[M];var G=a.beginTime;var A=a.duration;var s=G+A;var w=a.action;debugMessage(kDebugShowController_PreProcessSceneAnimations,"--- iAction: "+M+", keyName: "+w);if(I==false){var H=a.texture;if(this.isMovie(H)){H="movieCanvasObject."+P+"."+v[H]}u=new Array();u[0]=H}var B;var y=u.length;for(B=0;B<y;B++){var H=u[B];debugMessage(kDebugShowController_PreProcessSceneAnimations,"------ iTexture: "+B+", textureId: "+H);if(w=="transform.translation.z"){if(o.effect!="apple:revolve"){w="z.order"}}if((w=="translationEmphasis")||(w=="rotationEmphasis")||(w=="opacityMultiplier")||(w=="scaleEmphasis")){this.ensureInitialStateHasEmphasisTransform(J,H,w,z,a.from)}var m=this.textureAnimations[H];if(m==null){continue}var l=m.keyAnimations[w];if(l==null){continue}var t=l.keyActions;var e=l.latestEndTime-l.earliestBeginTime;var h=0;var d=100;if(e>0){h=100*G/this.overallEndTime;d=100*s/this.overallEndTime}debugMessage(kDebugShowController_PreProcessSceneAnimations,"- Action: "+M);debugMessage(kDebugShowController_PreProcessSceneAnimations,"- textureId: "+H);debugMessage(kDebugShowController_PreProcessSceneAnimations,"- keyName: "+w);debugMessage(kDebugShowController_PreProcessSceneAnimations,"- overallEndTime: "+this.overallEndTime);debugMessage(kDebugShowController_PreProcessSceneAnimations,"- beginTime: "+G+" startKeyframe: "+h);debugMessage(kDebugShowController_PreProcessSceneAnimations,"- endTime: "+s+" endKeyframe: "+d);var D={startKeyframe:h,endKeyframe:d,from:a.from,to:a.to,timingFunction:a.timingFunction};if(I&&m.isMovie){debugMessageAlways(kDebugShowController_PreProcessSceneAnimations,"- this is an action build on a movie, we don't do those, set the to/from values to 0...");debugMessageAlways(kDebugShowController_PreProcessSceneAnimations,"- was: newAction.from: "+D.from.translationEmphasis[0]+","+D.from.translationEmphasis[1]+","+D.from.translationEmphasis[2]+" to: "+D.to.translationEmphasis[0]+","+D.from.translationEmphasis[1]+","+D.from.translationEmphasis[2]);D.to=kNullActionEmphasis;D.from=kNullActionEmphasis;debugMessageAlways(kDebugShowController_PreProcessSceneAnimations,"- noew: newAction.from: "+D.from.translationEmphasis[0]+","+D.from.translationEmphasis[1]+","+D.from.translationEmphasis[2]+" to: "+D.to.translationEmphasis[0]+","+D.from.translationEmphasis[1]+","+D.from.translationEmphasis[2])}if(a.action=="opacityMultiplier"){debugMessage(kDebugShowController_PreProcessSceneAnimations,"- this is an opacityMultiplier, convert to absolute opacity by multiplying it against initial state's opacity...");if(B==0){var L=this.initialStateForTexture(J,H);var r=L.opacity;var k=a.from.scalar*r;var C=a.to.scalar*r;debugMessage(kDebugShowController_PreProcessSceneAnimations,"- initialOpacity: "+r);debugMessage(kDebugShowController_PreProcessSceneAnimations,"- from: "+a.from.scalar);debugMessage(kDebugShowController_PreProcessSceneAnimations,"- to: "+a.to.scalar);debugMessage(kDebugShowController_PreProcessSceneAnimations,"- absoluteFromOpacity: "+k);debugMessage(kDebugShowController_PreProcessSceneAnimations,"- absoluteToOpacity: "+C);D.from.scalar=k;D.to.scalar=C}else{debugMessage(kDebugShowController_PreProcessSceneAnimations,"- but this is not the first texture in this array, so we've already done the multiplying, skip it...")}}var q=a.timingFunction;if(a.timingFunction=="custom"){D.timingControlPoint1x=a.timingControlPoint1x;D.timingControlPoint1y=a.timingControlPoint1y;D.timingControlPoint2x=a.timingControlPoint2x;D.timingControlPoint2y=a.timingControlPoint2y;q="cubic-bezier("+D.timingControlPoint1x+","+D.timingControlPoint1y+","+D.timingControlPoint2x+","+D.timingControlPoint2y+")"}debugMessage(kDebugShowController_PreProcessSceneAnimations,"- timingFunction: "+q);t.push(D)}}}debugStopTimer(n)},debugDumpPreProcessedEventAnimations:function(){debugMessage(kDebugShowController_DumpPreProcessedEventAnimations);debugMessage(kDebugShowController_DumpPreProcessedEventAnimations,"-------------------------------------------------------------------");debugMessage(kDebugShowController_DumpPreProcessedEventAnimations,"- D U M P O F P R E P R O C E S S S E D A N I M A T I O N S -");debugMessage(kDebugShowController_DumpPreProcessedEventAnimations,"-------------------------------------------------------------------");for(var h in this.textureAnimations){var g=this.textureAnimations[h];debugMessage(kDebugShowController_DumpPreProcessedEventAnimations,"- texture: "+h+" ("+g.numAnimatedKeys+" animated key(s), Required Divs: "+g.numRequiredDivs+")");var c=0;for(var e in g.keyAnimations){var b=g.keyAnimations[e];var a=b.keyActions;debugMessage(kDebugShowController_DumpPreProcessedEventAnimations,"- key "+c+": "+e+" (from t="+b.earliestBeginTime+" to t="+b.latestEndTime+" - "+a.length+" actions)");for(var d=0;d<a.length;d++){var f=a[d];debugMessage(kDebugShowController_DumpPreProcessedEventAnimations,"- action: "+d);if(f.timingFunction=="custom"){debugMessage(kDebugShowController_DumpPreProcessedEventAnimations,"- curve: cubic-bezier("+f.timingControlPoint1x+","+f.timingControlPoint1y+","+f.timingControlPoint2x+","+f.timingControlPoint2y+")")}else{debugMessage(kDebugShowController_DumpPreProcessedEventAnimations,"- curve: "+f.timingFunction)}debugMessage(kDebugShowController_DumpPreProcessedEventAnimations,"- start: "+f.startKeyframe+"% = "+this.cssPropertyValueForActionValue(e,f.from));debugMessage(kDebugShowController_DumpPreProcessedEventAnimations,"- end: "+f.endKeyframe+"% = "+this.cssPropertyValueForActionValue(e,f.to))}c++}}},cssPropertyNameForAction:function(a){switch(a){case"hidden":return kVisibilityPropertyName;case"anchorPoint":return kTransformOriginPropertyName;case"opacityMultiplier":return kOpacityPropertyName;case"translationEmphasis":case"rotationEmphasis":case"scaleEmphasis":case"position":case"transform":case"transform.scale":case"transform.scale.x":case"transform.scale.y":case"transform.rotation.x":case"transform.rotation.y":case"transform.rotation.z":case"transform.translation.x":case"transform.translation.y":case"transform.translation.z":return kTransformPropertyName;case"zOrderHint":return kZIndexPropertyName;default:return a}},cssPropertyValueForActionValue:function(a,b){switch(a){case"hidden":if(b.scalar==true){return"hidden"}else{return"visible"}case"anchorPoint":return b.pointX+"% "+b.pointY+"%";case"position":return"translate("+b.pointX+"px,"+b.pointY+"px)";case"translationEmphasis":return"translateX("+b.translationEmphasis[0]+"px) translateY("+b.translationEmphasis[1]+"px) translateZ("+b.translationEmphasis[2]+")";case"rotationEmphasis":return"rotateZ("+b.rotationEmphasis[6]+"rad)";case"scaleEmphasis":return"scale3d("+ensureScaleFactorNotZero(b.scaleEmphasis[3])+","+ensureScaleFactorNotZero(b.scaleEmphasis[4])+","+ensureScaleFactorNotZero(b.scaleEmphasis[5])+")";case"transform.scale":return"scale("+ensureScaleFactorNotZero(b.scalar)+")";case"transform.scale.x":return"scaleX("+ensureScaleFactorNotZero(b.scalar)+")";case"transform.scale.y":return"scaleY("+ensureScaleFactorNotZero(b.scalar)+")";case"transform.rotation.x":return"rotateX("+b.scalar+"rad)";case"transform.rotation.y":return"rotateY("+b.scalar+"rad)";case"transform.rotation.z":return"rotateZ("+b.scalar+"rad)";case"transform.translation.x":return"translateX("+b.scalar+"px)";case"transform.translation.y":return"translateY("+b.scalar+"px)";case"transform.translation.z":return"translateZ("+b.scalar+"px)";case"zOrderHint":case"isPlaying":case"zPosition":case"opacity":case"opacityMultiplier":return b.scalar+"";case"transform":return"matrix3d("+b.transform+")";default:return"some value"}},createTimingFunctionForAction:function(b){debugMessage(kDebugShowController_CreateTimingFunctionForAction,"action.timingFunction: "+b.timingFunction);var a="";switch(b.timingFunction){case"easeIn":a="ease-in";break;case"easeOut":a="ease-out";break;case"easeInOut":case"easeInEaseOut":a="ease-in-out";break;case"custom":a="cubic-bezier("+b.timingControlPoint1x+","+b.timingControlPoint1y+","+b.timingControlPoint2x+","+b.timingControlPoint2y+")";break;case"linear":a="linear";break;default:a="linear";break}debugMessage(kDebugShowController_CreateTimingFunctionForAction,"- returning: "+a);return a},initialStateForTexture:function(i,a){var h=null;if(a.match(/^movieCanvasObject/)){var c=a.split(/\./);h=c[2]}debugMessage(kDebugShowController_InitialStateForTexture,"looking for initial state of texture '"+a+"' in scene "+i);var g=this.script.eventTimelines[i];var d=g.eventInitialStates;var b=d.length;var f;debugMessage(kDebugShowController_InitialStateForTexture,"- there are "+b+" textures in this scene");for(f=0;f<b;f++){var j=d[f];var e=j.texture;debugMessage(kDebugShowController_InitialStateForTexture,"- looking at: "+e);if(e==a){debugMessage(kDebugShowController_InitialStateForTexture,"- found it!");return j}if(j.canvasObjectID!=null&&j.canvasObjectID==h){debugMessage(kDebugShowController_InitialStateForTexture,"- found the matching canvasObjectId!");return j}}debugMessage(kDebugShowController_InitialStateForTexture,"- not found!");return null},createInitialKeyframeValue:function(f,e,b,d){debugMessage(kDebugShowController_CreateInitialKeyframeValue,"sceneIndex: "+f+" textureId: "+e+" keyName: "+b);var c={};var a=this.initialStateForTexture(f,e);switch(b){case"opacity":case"opacityMultiplier":c.scalar=a.opacity;break;case"hidden":c.scalar=a.hidden;break;case"position":c.pointX=d.pointX;c.pointY=d.pointY;break;case"translationEmphasis":c.translationEmphasis=a.translationEmphasis;debugMessage(kDebugShowController_CreateInitialKeyframeValue,"- got a translationEmphasis, hope this works! actionValue.translationEmphasis: "+c.translationEmphasis);break;case"rotationEmphasis":c.rotationEmphasis=a.rotationEmphasis;debugMessage(kDebugShowController_CreateInitialKeyframeValue,"- got a rotationEmphasis, hope this works! actionValue.rotationEmphasis: "+c.rotationEmphasis);break;case"scaleEmphasis":c.scaleEmphasis=a.scaleEmphasis;debugMessage(kDebugShowController_CreateInitialKeyframeValue,"- got a scaleEmphasis, hope this works! actionValue.scaleEmphasis: "+c.scaleEmphasis);break;case"transform.scale":case"transform.scale.x":case"transform.scale.y":c.scalar=a.affineTransform[0];debugMessage(kDebugShowController_CreateInitialKeyframeValue,"- got a transform.scale, hope this works! actionValue.scalar: "+c.scalar);break;case"transform":c.transform=d.transform;break;default:c.scalar=0;c.pointX=0;c.pointY=0;break}return c},anchorPointOffset:function(f,d){debugMessage(kDebugShowController_AnchorPointOffset);debugMessage(kDebugShowController_AnchorPointOffset,"- textureId: "+f);debugMessage(kDebugShowController_AnchorPointOffset,"- newAnchorPoint: "+d.x+", "+d.y);var a={};var b={};var e={};var c=this.script.textures[f];a.x=c.width/2;a.y=c.height/2;b.x=d.x*c.width;b.y=d.y*c.height;debugMessage(kDebugShowController_AnchorPointOffset,"- newOrigin: "+b.x+", "+b.y);debugMessage(kDebugShowController_AnchorPointOffset,"- currentOrigin: "+a.x+", "+a.y);e.x=(a.x-b.x);e.y=(a.y-b.y);debugMessage(kDebugShowController_AnchorPointOffset,"- offset: "+e.x+", "+e.y);return e},createAnimationRuleForKeyframe:function(c,i,h,g,j){var d;if(h=="hidden"){var a={scalar:-1};if(g.scalar==0){a.scalar=1}else{a.scalar=0}h="opacity";d=this.cssPropertyValueForActionValue(h,a)}else{d=this.cssPropertyValueForActionValue(h,g)}var b=this.cssPropertyNameForAction(h)+": "+d+"; "+(i<100?"-webkit-animation-timing-function: "+j+";":"");var e="";if(this.transformOriginValue!=""){e=kTransformOriginPropertyName+": "+this.transformOriginValue+";"}else{if(this.emphasisTransformOrigin!=""){e=kTransformOriginPropertyName+": "+this.emphasisTransformOrigin+";";debugMessage(kDebugShowController_CreateAnimationsForScene,"emphasisTransformOrigin: "+this.emphasisTransformOrigin)}}var f=i+"% {"+e+b+"}";c.insertRule(f);if(e==""){debugMessage(kDebugShowController_CreateAnimationsForScene,"- "+f)}else{debugMessage(kDebugShowController_CreateAnimationsForScene,"- "+i+"%");debugMessage(kDebugShowController_CreateAnimationsForScene,"- {");debugMessage(kDebugShowController_CreateAnimationsForScene,"- "+e);debugMessage(kDebugShowController_CreateAnimationsForScene,"- "+b);debugMessage(kDebugShowController_CreateAnimationsForScene,"- }")}return d},createAnimationsForScene:function(l){debugMessage(kDebugShowController_CreateAnimationsForScene);debugMessage(kDebugShowController_CreateAnimationsForScene,"---------------------------------------------------");debugMessage(kDebugShowController_CreateAnimationsForScene,"- c r e a t e A n i m a t i o n s F o r S c e n e -");debugMessage(kDebugShowController_CreateAnimationsForScene,"---------------------------------------------------");debugMessage(kDebugShowController_CreateAnimationsForScene,"- sceneIndex: "+l);var b=this.script.eventTimelines[l];var o=b.eventInitialStates;var u=b.eventAnimations;if(!b.automaticPlay){this.animationManager.deleteAllAnimations()}else{if(this.animationManager.animationsCreated(l)){this.sceneIndexOfPrebuiltAnimations=l;this.preProcessSceneAnimations(l,u,o);return}}if((l+1)<this.script.eventTimelines.length){if(this.script.eventTimelines[l+1].automaticPlay){this.createAnimationsForScene(l+1)}}this.animationManager.markAnimationsCreated(l);this.preProcessSceneAnimations(l,u,o);this.debugDumpPreProcessedEventAnimations();var n=new DebugTimer(kDebugTimer_CreateAnimationsForScene);var e=0.001;for(var v in this.textureAnimations){var t=this.textureAnimations[v];debugMessage(kDebugShowController_CreateAnimationsForScene,"- texture: "+v);this.transformOriginValue="";for(var h in t.keyAnimations){if(h=="playing"){debugMessage(kDebugShowController_CreateAnimationsForScene,"- keyName: "+h+" - we don't animate this one...");continue}var q=t.keyAnimations[h];var g=q.keyActions;var k=escapeTextureId(v)+"-"+escapeTextureId(h)+"-"+l;var s=this.animationManager.createAnimation(k);debugMessage(kDebugShowController_CreateAnimationsForScene,"- @keyframe "+k);debugMessage(kDebugShowController_CreateAnimationsForScene,"- {");if(h=="anchorPoint"){debugMessage(kDebugShowController_CreateAnimationsForScene,"- this is an anchor point action, need special case");var p=g[0];var c={};c.x=p.to.pointX;c.y=p.to.pointY;var f=this.anchorPointOffset(t.originalTextureId,c);var m={pointX:f.x,pointY:f.y};this.emphasisTransformOrigin="";debugMessage(kDebugShowController_CreateAnimationsForScene,"- newAnchorPoint: ("+c.x+", "+c.y+")");debugMessage(kDebugShowController_CreateAnimationsForScene,"- offsetValue: ("+m.pointX+", "+m.pointY+")");this.createAnimationRuleForKeyframe(s,0,"position",m,"linear");this.createAnimationRuleForKeyframe(s,100,"position",m);this.transformOriginValue=(c.x*100)+"% "+(c.y*100)+"%"}else{var p=g[0];var j=0;var r=null;if(p==null){continue}if(p.startKeyframe!=0){var d=this.createInitialKeyframeValue(l,v,h,p.from);debugMessage(kDebugShowController_CreateAnimationsForScene_Adjustments,"---> insert keyframes at 0 and "+(p.startKeyframe-e)+" because 1st keyframe in list ("+p.startKeyframe+") is not 0");this.createAnimationRuleForKeyframe(s,0,h,d,"linear");this.createAnimationRuleForKeyframe(s,p.startKeyframe-e,h,d,"linear");j=p.startKeyframe;r=d;debugMessage(kDebugShowController_CreateAnimationsForScene_Adjustments,"---> end of inserted keyframes")}for(var i=0;i<g.length;i++){p=g[i];if(p.startKeyframe!=j){debugMessage(kDebugShowController_CreateAnimationsForScene_Adjustments,"---> insert keyframe at "+(p.startKeyframe-e)+" to close gap between "+j+" and "+p.startKeyframe);this.createAnimationRuleForKeyframe(s,p.startKeyframe-e,h,r,"linear");debugMessage(kDebugShowController_CreateAnimationsForScene_Adjustments,"---> end of inserted keyframe")}if(h=="rotationEmphasis"){this.emphasisTransformOrigin=p.from.rotationEmphasis[0]+"px "+p.from.rotationEmphasis[1]+"px"}else{this.emphasisTransformOrigin=""}var a=this.createTimingFunctionForAction(p);this.createAnimationRuleForKeyframe(s,p.startKeyframe,h,p.from,a);this.createAnimationRuleForKeyframe(s,p.endKeyframe-(p.endKeyframe==100?0:e),h,p.to,"linear");r=p.to;j=p.endKeyframe}if(j!=100){debugMessage(kDebugShowController_CreateAnimationsForScene_Adjustments,"---> inserting keyframes at "+(j)+" and 100 because last keyframe in list ("+j+") is not 100");this.createAnimationRuleForKeyframe(s,j,h,r,"linear");this.createAnimationRuleForKeyframe(s,100,h,r,"linear");debugMessage(kDebugShowController_CreateAnimationsForScene_Adjustments,"---> end of inserted keyframes")}}debugMessage(kDebugShowController_CreateAnimationsForScene,"- }")}}this.sceneIndexOfPrebuiltAnimations=l;debugStopTimer(n)},clearExistingAnimations:function(){this.clearExistingAnimationFrom(this.stageManager.stage)},clearExistingAnimationFrom:function(b){b.style.removeProperty(kAnimationNamePropertyName);b.style.removeProperty(kAnimationDurationPropertyName);for(var a=0;a<b.childNodes.length;a++){var c=b.childNodes[a];this.clearExistingAnimationFrom(c)}},applyAnimationsForScene:function(){debugStopTimer(this.debugTimerAdvanceToBuild_to_ApplyAnimations);var m=new DebugTimer(kDebugTimer_ApplyAnimationsForScene);debugMessage(kDebugShowController_ApplyAnimationsForScene);debugMessage(kDebugShowController_ApplyAnimationsForScene,"-------------------------------------------------");debugMessage(kDebugShowController_ApplyAnimationsForScene,"- a p p l y A n i m a t i o n s F o r S c e n e -");debugMessage(kDebugShowController_ApplyAnimationsForScene,"-------------------------------------------------");var c=false;for(var w in this.textureAnimations){var s=this.textureAnimations[w];var n=escapeTextureId(w);debugMessage(kDebugShowController_ApplyAnimationsForScene,"- texture: "+w+" (escaped: "+n+")");var r=document.getElementById(n+"-root");if(r==null){debugWarning(kDebugShowController_ApplyAnimationsForScene,"could not find texture '"+w+"' - ignoring...");continue}r.style.visibility="visible";var h=false;for(var g in s.keyAnimations){var p=s.keyAnimations[g];var f=p.keyActions;var v=f[f.length-1];var i=n+"-"+escapeTextureId(g)+"-"+this.currentSceneIndex;var k=this.cssPropertyNameForAction(g);var u=this.cssPropertyValueForActionValue(g,v.to);var t=p.latestEndTime-p.earliestBeginTime;var j="";var q=false;switch(g){case"opacityMultiplier":j=n;break;case"hidden":k="opacity";if(u=="hidden"){u=0}else{u=1}case"zOrderHint":case"transform.translation.z":j=n+"-root";break;case"isPlaying":j=n+"-movieObject";q=true;c=true;break;case"position":h=true;case"transform.scale":case"transform.scale.x":case"transform.scale.y":default:j=n+"-"+escapeTextureId(g);break}debugMessage(kDebugShowController_ApplyAnimationsForScene,"- keyName: "+g);debugMessage(kDebugShowController_ApplyAnimationsForScene,"- animationName: "+i);debugMessage(kDebugShowController_ApplyAnimationsForScene,"- elementId: "+j);debugMessage(kDebugShowController_ApplyAnimationsForScene,"- earliestBeginTime: "+p.earliestBeginTime);debugMessage(kDebugShowController_ApplyAnimationsForScene,"- duration: "+this.overallEndTime);debugMessage(kDebugShowController_ApplyAnimationsForScene,"- propertyName: "+k);debugMessage(kDebugShowController_ApplyAnimationsForScene,"- final value: "+u);var b=document.getElementById(j);if(b){if(q&&(g=="isPlaying")){if(gMode==kModeMobile){debugMessage(kDebugShowController_ApplyAnimationsForScene,"- this animation is an 'isPlaying' one, but we're on the phone so don't start the movie...")}else{if(p.earliestBeginTime>0){debugMessage(kDebugShowController_ApplyAnimationsForScene,"- this animation is an 'isPlaying' one, and it has a non-zero begin time, so start the movie after a delay of "+p.earliestBeginTime+"...");var l=this;setTimeout(function(){l.startMoviePlaying(j,u)},p.earliestBeginTime*1000)}else{debugMessage(kDebugShowController_ApplyAnimationsForScene,"- this animation is an 'isPlaying' one, start the movie...");this.startMoviePlaying(j,u)}this.updateNavigationButtons()}}else{if(g=="anchorPoint"){var d={};d.x=v.to.pointX;d.y=v.to.pointY;var e=this.anchorPointOffset(s.originalTextureId,d);k=kTransformPropertyName;u="translateX("+e.x+"px) translateY("+e.y+"px)";debugMessage(kDebugShowController_ApplyAnimationsForScene,"- this is an anchorPoint, special case, change property name and value to:");debugMessage(kDebugShowController_ApplyAnimationsForScene,"- propertyName: "+k);debugMessage(kDebugShowController_ApplyAnimationsForScene,"- final value: "+u)}else{if(g=="rotationEmphasis"){var a=s.anchorPoint;debugMessage(kDebugShowController_ApplyAnimationsForScene,"- applying squirreled away anchor point of "+a.x+","+a.y+" for texture "+w);b.style.setProperty(kTransformOriginPropertyName,a.x+" "+a.y)}}debugMessage(kDebugShowController_ApplyAnimationsForScene,"- setting "+k+" of "+j+" to "+u);b.style.setProperty(k,u);debugMessage(kDebugShowController_ApplyAnimationsForScene,"- applying animation "+i+" with duration "+this.overallEndTime+"s");b.style.setProperty(kAnimationNamePropertyName,i);b.style.setProperty(kAnimationDurationPropertyName,this.overallEndTime+"s")}}}if(h){debugMessage(kDebugShowController_ApplyAnimationsForScene,"- clearing out 'initial state' transform");var o=document.getElementById(n+"-root");o.style.setProperty(kTransformPropertyName,"")}}debugStopTimer(m);return c},startMoviePlaying:function(c,b){if(gMode==kModeDesktop){debugMessage(kDebugShowController_StartMoviePlaying,"escapedTextureId: "+c+" isPlaying: "+b+" - delaying movie start by 1s to allow video element to load...");var a=this;setTimeout(function(){a.startMoviePlaying_partTwo(c,b)},1000)}else{this.startMoviePlaying_partTwo(c,b)}},startMoviePlaying_partTwo:function(b,a){if(gIpad){this.startMoviePlaying_iPadVersion(b,a)}else{this.startMoviePlaying_normalVersion(b,a)}},startMoviePlaying_normalVersion:function(d,c){debugMessage(kDebugShowController_StartMoviePlaying,"escapedTextureId: "+d+" isPlaying: "+c);var b=document.getElementById(d);if(b){if(c==true){if(b.play){debugMessage(kDebugShowController_StartMoviePlaying,"- movieObject.play() is valid, invoking...");debugMessage(kDebugShowController_StartMoviePlaying,"- movieObject's src: "+b.src);var a=this;b.addEventListener("play",function(e){a.handleMovieDidStart(e,d)});b.addEventListener("ended",function(e){a.handleMovieDidEnd(e,d)});b.addEventListener("error",function(e){a.handleMovieError(e,d)});b.muted=this.muted;b.play();debugMessage(kDebugShowController_StartMoviePlaying,"- movie should be playing now")}else{debugMessage(kDebugShowController_StartMoviePlaying,"- movieObject.play() is null, that can't be good")}}else{if(b.pause){debugMessage(kDebugShowController_StartMoviePlaying,"- movieObject.pause() is valid, invoking...");var a=this;b.pause();debugMessage(kDebugShowController_StartMoviePlaying,"- movie should be paused now")}else{debugMessage(kDebugShowController_StartMoviePlaying,"- movieObject.pause() is null, that can't be good")}}}else{debugMessage(kDebugShowController_StartMoviePlaying,"- could not find movie object by ID!")}},startMoviePlaying_iPadVersion:function(e,d){debugMessage(kDebugShowController_StartMoviePlaying,"iPad Version! escapedTextureId: "+e+" isPlaying: "+d);var c=e.substring(0,e.length-5);var g=document.getElementById(e);var f=g.parentNode;debugMessage(kDebugShowController_StartMoviePlaying,"- truncatedId: "+c);debugMessage(kDebugShowController_StartMoviePlaying,"- creating new video element...");var b=document.createElement("video");debugMessage(kDebugShowController_StartMoviePlaying,"- setting properties on new video element...");b.id=c;b.src=g.src;b.muted=this.muted;b.poster=g.poster;b.controls=true;b.style.visibility="visible";b.style.position=kPositionAbsolutePropertyValue;b.style.top="0px";b.style.left="0px";b.style.width=g.style.width;b.style.height=g.style.height;b.style.opacity=g.opacity;debugMessage(kDebugShowController_StartMoviePlaying,"- inserting new video element to DOM...");f.appendChild(b);debugMessage(kDebugShowController_StartMoviePlaying,"- starting movie...");var a=this;b.addEventListener("play",function(h){a.handleMovieDidStart(h,c)});b.addEventListener("ended",function(h){a.handleMovieDidEnd(h,c)});b.addEventListener("error",function(h){a.handleMovieError(h,c)});b.play()},removeMovieObjectClone:function(a){debugMessage(kDebugShowController_StartMoviePlaying)},handleMovieDidStart:function(b,c){debugMessage(kDebugShowController_HandleMovieDidStart,"textureId: "+c);if(gMode==kModeDesktop){var a=this;this.setMuted(!this.muted);this.setMuted(!this.muted);setTimeout(function(){a.hidePosterFrame(c)},1)}},hidePosterFrame:function(c){var b=c.substring(0,c.indexOf("-movieObject"));debugMessage(kDebugShowController_HandleMovieDidStart,"- posterFrameId: '"+b+"'");var a=document.getElementById(b);a.style.height="0px"},handleMovieDidEnd:function(a,b){debugMessage(kDebugShowController_HandleMovieDidEnd,"textureId: "+b)},handleMovieError:function(a,b){debugMessage(kDebugShowController_HandleMovieError,"textureId: "+b)},createHyperlinks:function(l){if(l==-1){debugMessage(kDebugShowController_CreateHyperlinks,"hyperlinkSceneIndex is -1, nothing to do");return}debugMessage(kDebugShowController_CreateHyperlinks);debugMessage(kDebugShowController_CreateHyperlinks,"- state: "+this.state);debugMessage(kDebugShowController_CreateHyperlinks,"- currentSceneIndex: "+this.currentSceneIndex);debugMessage(kDebugShowController_CreateHyperlinks,"- nextSceneIndex: "+this.nextSceneIndex);debugMessage(kDebugShowController_CreateHyperlinks,"- hyperlinkSceneIndex: "+l);var m=this.script.eventTimelines[l];if(m==null){debugMessage(kDebugShowController_CreateHyperlinks,"eventTimeLine for the specified scene index is null!");return}var g=m.hyperlinks;if(g==null){debugMessage(kDebugShowController_CreateHyperlinks,"hyperlinks property for the specified scene index is null!");return}var p=g.length;var j;debugMessage(kDebugShowController_CreateHyperlinks,"- iterating over "+p+" hyperlinks...");var b=150;var v=50;var d=this.displayManager.showWidth;var k=this.displayManager.showHeight;for(j=0;j<p;j++){var f=g[j];var u=f.targetRectangle;var r={targetRectangle:u,url:f.url};var t=u.x;var i=u.y;var w=d-(u.x+u.width);var o=k-(u.y+u.top);debugMessage(kDebugShowController_CreateHyperlinks,"- "+j+": (x:"+u.x+", y:"+u.y+", w:"+u.width+", h:"+u.height+")");if(gMode==kModeMobile){if(u.width<b){var q=b-u.width;var c=q/2;var e=q/2;debugMessage(kDebugShowController_CreateHyperlinks,"- width too small by: "+q);if(t<c){c=t}else{if(w<e){c=c+(e-w)}}r.targetRectangle.x-=c;r.targetRectangle.width+=q}if(u.height<v){var s=v-u.height;var n=s/2;var h=s/2;debugMessage(kDebugShowController_CreateHyperlinks,"- height too small by: "+s);if(i<n){n=i}else{if(o<h){n=n+(e-w)}}r.targetRectangle.y-=n;r.targetRectangle.height+=s}}debugMessage(kDebugShowController_CreateHyperlinks,"- adding hyperlink to stage...");this.stageManager.addHyperlink(r.targetRectangle);debugMessage(kDebugShowController_CreateHyperlinks,"- adding hyperlink struct to array...");this.activeHyperlinks[j]=r}if(this.movieHyperlinks.length>0){debugMessage(kDebugShowController_CreateHyperlinks,"- appending movie hyperlinks...");for(var a=0;a<this.movieHyperlinks.length;a++){var x=this.movieHyperlinks[a];debugMessage(kDebugShowController_CreateHyperlinks,"- "+a+": "+x.url);this.stageManager.addHyperlink(x.targetRectangle);this.activeHyperlinks[j++]=x}}else{debugMessage(kDebugShowController_CreateHyperlinks,"- there are no movie hyperlinks...")}debugMessage(kDebugShowController_CreateHyperlinks,"finished.")},updateNavigationButtons:function(){var f=this.currentSceneIndex;if(this.state==kShowControllerState_IdleAtFinalState){f++}var h=document.URL.split("?");var a=h[0].split("#");window.history.replaceState(null,"Keynote",a[0]+"#"+f+(h[1]?"?"+h[1]:""));debugMessage(kDebugShowController_UpdateNavigationButtons);debugMessage(kDebugShowController_UpdateNavigationButtons,"- state: "+this.state);debugMessage(kDebugShowController_UpdateNavigationButtons,"- loopSlideshow: "+this.script.loopSlideshow);debugMessage(kDebugShowController_UpdateNavigationButtons,"- currentSceneIndex: "+this.currentSceneIndex);debugMessage(kDebugShowController_UpdateNavigationButtons,"- sceneIndexToUse: "+f);debugMessage(kDebugShowController_UpdateNavigationButtons,"- lastSceneIndex: "+this.script.lastSceneIndex);debugMessage(kDebugShowController_UpdateNavigationButtons,"- currentSlideIndex: "+this.currentSlideIndex);var b=false;var e=false;if(this.script.lastSceneIndex==-1){debugMessage(kDebugShowController_UpdateNavigationButtons,"- this slideshow has only 1 slide with no builds, both buttons are disabled");e=false;b=false}else{if(this.script.loopSlideshow){debugMessage(kDebugShowController_UpdateNavigationButtons,"- this is a looping slideshow, both buttons are ALWAYS enabled");e=true;b=true}else{if(f>0){debugMessage(kDebugShowController_UpdateNavigationButtons,"- sceneIndexToUse > 0, so enable backward button");b=true}if(f==0&&this.script.lastSceneIndex==0){debugMessage(kDebugShowController_UpdateNavigationButtons,"- sceneIndexToUse & lastSceneIndex are both 0 - show with 1 slide with 1 build, so enable forward button");e=true}else{if(this.currentSceneIndex<this.script.lastSceneIndex){debugMessage(kDebugShowController_UpdateNavigationButtons,"- currentSceneIndex < lastSceneIndex, so enable forward button");e=true}else{if(this.currentSceneIndex==this.script.lastSceneIndex){if(this.state==kShowControllerState_IdleAtInitialState){debugMessage(kDebugShowController_UpdateNavigationButtons,"- currentSceneIndex == lastSceneIndex, but we're at the intitial state, so enable forward button");e=true}else{debugMessage(kDebugShowController_UpdateNavigationButtons,"- currentSceneIndex == lastSceneIndex, and we're at the final state, so disable forward button");e=false}}else{debugMessage(kDebugShowController_UpdateNavigationButtons,"- currentSceneIndex > lastSceneIndex, show with 1 slide and no builds, so disable forward button");e=false}}}}}debugMessage(kDebugShowController_UpdateNavigationButtons,"- backward button should be: "+(b?"enabled":"disabled"));debugMessage(kDebugShowController_UpdateNavigationButtons,"- forward button should be: "+(e?"enabled":"disabled"));var d=this.stageManager.anyVideoElementsOnStage();var c=(this.soundTrackPlayer!=null);debugMessage(kDebugShowController_UpdateNavigationButtons,"- any Video: "+(d?"yes":"no"));debugMessage(kDebugShowController_UpdateNavigationButtons,"- any Audio: "+(c?"yes":"no"));var g=((d||c)?kMuteButtonState_Enabled:kMuteButtonState_Disabled)|(this.muted?kMuteButtonState_Muted:kMuteButtonState_NotMuted);this.displayManager.setPreviousButtonEnabled(b);this.displayManager.setNextButtonEnabled(e);this.displayManager.setHudMuteButtonState(g);if(gEmbedded){this.displayManager.setEmbeddedRestartButtonEnabled(f!=0)}},setCurrentSceneIndexTo:function(a){debugMessage(kDebugShowController_SetCurrentSceneIndexTo,"changing it from "+this.currentSceneIndex+" to "+a);this.currentSceneIndex=a;this.assignNextSceneIndex();this.updateSlideNumber();this.updateNavigationButtons()},displayScene:function(z,B){debugMessageAlways(kDebugShowController_DisplayScene,"YAHOOO!!!!! sceneIndex: "+z);var F=this.scriptManager.slideIndexFromSceneIndex(z);var f=new Array();var j=new DebugTimer(kDebugTimer_DisplayScene);var m=z<this.currentSceneIndex;debugMessage(kDebugShowController_DisplayScene,"sceneIndex: "+z+(m?" (going backwards)":""));if(z==-1){debugMessageAlways(kDebugShowController_DisplayScene,"- sceneIndex is -1, ignoring...");return}this.setCurrentSceneIndexTo(z);var r=this.script.eventTimelines[z];var v=r.eventInitialStates;var u=v.length;var q=0;var w;kDebugDisplayScene="";debugMessage(kDebugShowController_DisplayScene,"eventTimeline: "+r);for(var E in r){debugMessage(kDebugShowController_DisplayScene,"- "+E+": "+r[E])}debugMessage(kDebugShowController_DisplayScene,"precessing hyperlinks...");debugMessage(kDebugShowController_DisplayScene,"- hyperlinkSceneOffset: "+B);debugMessage(kDebugShowController_DisplayScene,"determing which existig textures to remove from stage... (remove everything but leave movies in place)");var h=this.stageManager.stage;var b={};for(w=0;w<h.childNodes.length;w++){var l=h.childNodes[w];var y=l.id;var e=true;var i="";debugMessage(kDebugShowController_DisplayScene,"- "+w+": "+y);if(l&&typeof l!="undefined"&&typeof y!="undefined"&&y!=""){if(this.isMovie(y)&&!m){var C=y.substring(0,y.indexOf("-root"));debugMessage(kDebugShowController_DisplayScene,"- this one's a movie, id: "+C+" -- check if it's in this scene...");if(this.scriptManager.isMovieInScene(z,C,this.textureManager)){debugMessage(kDebugShowController_DisplayScene,"- it is! leave it in...");var d=unEscapeTextureId(C);debugMessage(kDebugShowController_DisplayScene,"- unEscapedMovieId: "+d);var c=this.movieCanvasObjectIdToTextureIdTable[d];debugMessage(kDebugShowController_DisplayScene,"- originalTextureId: "+c);if(c){i=this.textureManager.urlForMovie(unEscapeTextureId(c));debugMessage(kDebugShowController_DisplayScene,"- movieUrl: "+i);e=false}else{debugMessageAlways(kDebugShowController_DisplayScene,"- not really in next scene, skip it")}}}}if(e){debugMessage(kDebugShowController_DisplayScene,"- add it to list of textures to remove");f.push(l)}else{debugMessage(kDebugShowController_DisplayScene,"- add it to list of movies left in scene");b[i]=true}}debugMessage(kDebugShowController_DisplayScene,"- iterating over list of movies we're keeping...");for(movieTextureId in b){debugMessage(kDebugShowController_DisplayScene,"- "+movieTextureId)}debugMessage(kDebugShowController_DisplayScene,"- iterating over list of textures to remove...");for(w=0;w<f.length;w++){var l=f[w];var y=l.id;debugMessage(kDebugShowController_DisplayScene,"- "+w+": "+y);this.stageManager.removeTexture(l)}this.clearMovieHyperlinks();debugMessage(kDebugShowController_DisplayScene,"- processing "+u+" textures...");this.stageManager.resetMovieCount();for(w=0;w<u;w++){var k=v[w];var y=k.texture;var c=y;if(this.isMovie(y)){y="movieCanvasObject."+F+"."+k.canvasObjectID}var g=this.textureAnimations[y];debugMessage(kDebugShowController_DisplayScene,"- textureAnimation: "+g);var G=escapeTextureId(y)+"-root";debugMessage(kDebugShowController_DisplayScene,"- "+w+": "+y+" ("+G+")");var a=false;if(this.isMovie(y)){debugMessage(kDebugShowController_DisplayScene,"- it's a movie, check to see if it's already on the stage...");var i=this.textureManager.urlForMovie(c);debugMessage(kDebugShowController_DisplayScene,"- url: "+i);if(b[i]){debugMessage(kDebugShowController_DisplayScene,"- this movie was in the last scene, no need to add it again");a=true}else{debugMessage(kDebugShowController_DisplayScene,"- no it isn't, add it now")}}var I=0;if(g!=null){I=g.numRequiredDivs}var o=(k.hidden==0?"visible":"hidden");var H=k.opacity;var A=k.opacityMultiplier;var D="";var p=this.script.textures[c];var J=p.width;var t=p.height;var n=true;q=k.zIndex;if((n==true)&&(typeof k.transform!="undefined")){D="matrix3D("+k.transform+")"}else{D="matrix("+k.affineTransform+")"}debugMessage(kDebugShowController_DisplayScene,"- opacity: "+H);debugMessage(kDebugShowController_DisplayScene,"- opacityMultiplier: "+A);debugMessage(kDebugShowController_DisplayScene,"- visibility: "+o);debugMessage(kDebugShowController_DisplayScene,"- nativeWidth: "+J);debugMessage(kDebugShowController_DisplayScene,"- nativeHeight: "+t);debugMessage(kDebugShowController_DisplayScene,"- transform: "+D);debugMessage(kDebugShowController_DisplayScene,"- zOrder: "+q);debugMessage(kDebugShowController_DisplayScene,"- num Divs: "+I);if(A>0){H*=A;debugMessage(kDebugShowController_DisplayScene,"- opacityMultiplier specified, changing opacity to "+H)}var x=new Array();if(g){debugMessage(kDebugShowController_DisplayScene,"- adding keyNames to divNames...");for(var s in g.keyAnimations){if((s!="isPlaying")&&(s!="opacityMultiplier")&&(s!="zOrderHint")&&(s!="hidden")){debugMessage(kDebugShowController_DisplayScene,"- "+s);x.push(s)}else{debugMessage(kDebugShowController_DisplayScene,"- "+s+" (no div required for this key)")}}}this.stageManager.addTextureToStage(z,y,J,t,o,H,q,D,x,k,a)}this.updateNavigationButtons();if(gEmbedded==true){setTimeout(function(){document.getElementById("background").style.visibility="visible"},1000)}debugMessage(kDebugShowController_DisplayScene,"complete.");debugStopTimer(j)},isMovie:function(a){return(a.indexOf("movie")!=-1)},setupWaitForSceneToLoadPoller:function(b){debugMessage(kDebugShowController_SetupWaitForSceneToLoadPoller,"sceneIndex: "+b.sceneToLoad+" setting up timeout function to poll...");this.waitForSceneToLoadPollCount=0;this.pollingSpinnerVisiblie=false;var a=this;setTimeout(function(){a.pollForSceneToLoad(b)},kSceneLoadPollInterval)},pollForSceneToLoad:function(b){this.waitForSceneToLoadPollCount++;debugMessageAlways(kDebugShowController_PollForSceneToLoad,"sceneIndex: "+b.sceneToLoad+" querying TextureManager to see if scene is loaded yet... poll count: "+this.waitForSceneToLoadPollCount);if(this.textureManager.isScenePreloaded(b.sceneToLoad)){debugMessageAlways(kDebugShowController_PollForSceneToLoad,"scene "+b.sceneToLoad+" is now loaded, stop polling");this.handleSceneDidLoad(b)}else{if(this.waitForSceneToLoadPollCount>kSceneLoadGiveUpPollCount){debugMessageAlways(kDebugShowController_PollForSceneToLoad,"scene "+b.sceneToLoad+" has taken too long to load, give up");this.handleSceneDidNotLoad(b)}else{if(this.waitForSceneToLoadPollCount>kSceneLoadDisplaySpinnerPollCount){if(this.pollingSpinnerVisiblie==false){debugMessageAlways(kDebugShowController_PollForSceneToLoad,"scene "+b.sceneToLoad+" is taking a long time to load, display spinner...");this.displayManager.showWaitingIndicator();this.pollingSpinnerVisiblie=true}}var a=this;setTimeout(function(){a.pollForSceneToLoad(b)},kSceneLoadPollInterval)}}},handleSceneDidLoad:function(a){debugMessage(kDebugShowController_HandleSceneDidLoad,"sceneIndex: "+a.sceneToLoad+" took "+this.waitForSceneToLoadPollCount+" polls");this.displayManager.setNextButtonEnabled(this.currentSceneIndex<(this.script.pageCount-1));switch(this.state){case kShowControllerState_WaitingToJump:debugMessage(kDebugShowController_HandleSceneDidLoad,"- we were waiting to jump, jumping to it now...");this.changeState(kShowControllerState_ReadyToJump);this.jumpToScene_partTwo(a.sceneToLoad,a.playAnimationsAfterLoading);break;default:debugWarning(kDebugShowController_HandleSceneDidLoad,"we were NOT waiting for a scene to load, how did we get here? hmmm... what to do?");break}},handleSceneDidNotLoad:function(a){debugMessageAlways(kDebugShowController_HandleSceneDidNotLoad,"sceneIndex: "+a.sceneToLoad+" - purging cache...");this.queuedUserAction=null;var b=this.promptUserToTryAgain(kUnableToReachiWorkTryAgain);if(b){kDebugTextureManager_LoadScene="TextureManager_LoadScene";gDebugOnMobile=true;debugMessageAlways(kDebugShowController_HandleSceneDidNotLoad,"- restarting player with sceneIndex: "+a.sceneToLoad);var d=window.location.href;var f;debugMessage(kDebugShowController_HandleSceneDidNotLoad,"- currentUrl: "+d);var e=d.indexOf("&restartingSceneIndex");if(e==-1){f=d}else{f=d.substring(0,e);debugMessage(kDebugShowController_HandleSceneDidNotLoad,"- croppedUrl: "+f)}var c=f+"&restartingSceneIndex="+a.sceneToLoad;debugMessage(kDebugShowController_HandleSceneDidNotLoad,"- new URL: "+c);window.location.replace(c)}else{debugMessageAlways(kDebugShowController_HandleSceneDidNotLoad,"- user elected to NOT try again");this.changeState(kShowControllerState_IdleAtFinalState);this.autoAdvance=false}}});