'use strict'; /* jshint eqnull: true, shadow: false, quotmark: single, undef: true, eqeqeq: true, unused: true, strict: true, curly: false, funcscope: true, globalstrict: true */ /* global HTMLElement, console, window, document, StaticLib */ window.LoadingScreenTaskTypes={'app':1,'api':2};window.LoadingTaskSTRUCT=function(obj){this.Type=0;this.TaskID='';this.IsStub=false;this.IsComplete=false;this.TaskDescription='';this.Priority=0;if((typeof(obj)!=='undefined')&&(obj!==null)){if((typeof(obj.Type)!=='undefined')&&(typeof(obj.Type)!=='number'))throw new Error('LoadingTaskSTRUCT.Type expects an Integer');if((typeof(obj.TaskID)!=='undefined')&&(typeof(obj.TaskID)!=='string'))throw new Error('LoadingTaskSTRUCT.TaskID expects a String');if((typeof(obj.IsStub)!=='undefined')&&(typeof(obj.IsStub)!=='boolean'))throw new Error('LoadingTaskSTRUCT.IsStub expects a Boolean');if((typeof(obj.IsComplete)!=='undefined')&&(typeof(obj.IsComplete)!=='boolean'))throw new Error('LoadingTaskSTRUCT.IsComplete expects a Boolean');if((typeof(obj.TaskDescription)!=='undefined')&&(typeof(obj.TaskDescription)!=='string'))throw new Error('LoadingTaskSTRUCT.TaskDescription expects a String');if((typeof(obj.Priority)!=='undefined')&&(typeof(obj.Priority)!=='number'))throw new Error('LoadingTaskSTRUCT.Priority expects an Integer');StaticLib.SetProps(this,obj);}};window.LoadingScreenPropSTRUCT=function(obj){this.TaskList=[];this.UncompletedTaskIndex=[];this.CompletedTaskIndex=[];this.AllTasksIndex={};this.TotalTasks=0;this.TasksRemaining=0;this.TaskStatuses={};this.CurrentTask=null;this.IsDisplayed=false;this.ParentContainer=null;if((typeof(obj)!=='undefined')&&(obj!==null)){if((typeof(obj.TaskList)!=='undefined')&&(typeof(obj.TaskList)!=='object')&&(obj.TaskList!==null))throw new Error('LoadingScreenPropSTRUCT.TaskList expects an Object');if((typeof(obj.UncompletedTaskIndex)!=='undefined')&&(typeof(obj.UncompletedTaskIndex)!=='object')&&(obj.UncompletedTaskIndex!==null))throw new Error('LoadingScreenPropSTRUCT.UncompletedTaskIndex expects an Object');if((typeof(obj.CompletedTaskIndex)!=='undefined')&&(typeof(obj.CompletedTaskIndex)!=='object')&&(obj.CompletedTaskIndex!==null))throw new Error('LoadingScreenPropSTRUCT.CompletedTaskIndex expects an Object');if((typeof(obj.AllTasksIndex)!=='undefined')&&(typeof(obj.AllTasksIndex)!=='object')&&(obj.AllTasksIndex!==null))throw new Error('LoadingScreenPropSTRUCT.AllTasksIndex expects an Object');if((typeof(obj.TotalTasks)!=='undefined')&&(typeof(obj.TotalTasks)!=='number'))throw new Error('LoadingScreenPropSTRUCT.TotalTasks expects an Integer');if((typeof(obj.TasksRemaining)!=='undefined')&&(typeof(obj.TasksRemaining)!=='number'))throw new Error('LoadingScreenPropSTRUCT.TasksRemaining expects an Integer');if((typeof(obj.TaskStatuses)!=='undefined')&&(typeof(obj.TaskStatuses)!=='object')&&(obj.TaskStatuses!==null))throw new Error('LoadingScreenPropSTRUCT.TaskStatuses expects an Object');if((typeof(obj.CurrentTask)!=='undefined')&&(typeof(obj.CurrentTask)!=='object')&&(obj.CurrentTask!==null))throw new Error('LoadingScreenPropSTRUCT.CurrentTask expects an Object');if((typeof(obj.IsDisplayed)!=='undefined')&&(typeof(obj.IsDisplayed)!=='boolean'))throw new Error('LoadingScreenPropSTRUCT.IsDisplayed expects a Boolean');if((typeof(obj.ParentContainer)!=='undefined')&&(typeof(obj.ParentContainer)!=='object')&&(obj.ParentContainer!==null))throw new Error('LoadingScreenPropSTRUCT.ParentContainer expects an Object');StaticLib.SetProps(this,obj);}};window.LoadingScreen=function(LoadingStruct){if((typeof(LoadingStruct)!=='undefined')&&(StaticLib.Empty(LoadingStruct))){return null;}this.FormObjects={OuterDiv:null,TaskDescription:null,CompletionBar:null,CompletionNum:null};this.prop=new window.LoadingScreenPropSTRUCT(LoadingStruct,{autobind:true,parent:this});this.vars={IsLoading:true};this.ctorInternal=function(){if(this.prop.TaskList!==null){if(this.prop.TaskList.length>0){var tasks=this.prop.TaskList;this.prop.TaskList=[];for(var count=0;count0){if(this.prop.IsDisplayed!==true){this.ShowLoadingScreen();}else{this.ShowCurrentTask();}}return;}if(this.prop.CompletedTaskIndex===null)this.prop.CompletedTaskIndex=[];if(this.prop.UncompletedTaskIndex===null)this.prop.UncompletedTaskIndex=[];if(newTask.IsComplete){orderedTasks=this.prop.CompletedTaskIndex;}else{orderedTasks=this.prop.UncompletedTaskIndex;}for(var count=0;count<=orderedTasks.length;count++){if(countcurrentTask.Priority){break;}}else{currentTaskLocation=orderedTasks.length;}}tasks=this.prop.TaskList;if(tasks===null)tasks=[];var newIndex=tasks.length;tasks.push(newTask);this.prop.TaskList=tasks;this.prop.TotalTasks++;tasks=this.prop.TaskStatuses;if(tasks===null)tasks=[];tasks[newTask.TaskID]=newTask.IsComplete;this.prop.TaskStatuses=tasks;tasks=this.prop.AllTasksIndex;if(tasks===null)tasks={};tasks[newTask.TaskID]=newIndex;this.prop.AllTasksIndex=tasks;if(newTask.IsComplete){tasks=this.prop.CompletedTaskIndex;if(tasks===null)tasks=[];tasks.splice(count,0,newIndex);this.prop.CompletedTaskIndex=tasks;}else{tasks=this.prop.UncompletedTaskIndex;if(tasks===null)tasks=[];tasks.splice(count,0,newIndex);this.prop.UncompletedTaskIndex=tasks;this.prop.TasksRemaining++;if(this.vars.IsLoading!==true){if(this.prop.IsDisplayed!==true){this.ShowLoadingScreen();}}}};this.HasTask=function(TaskID){var index=this.prop.AllTasksIndex[TaskID];return(index!==-1);};this.CompleteTask=function(TaskID){var index=this.prop.AllTasksIndex[TaskID];if(index===-1)return;if(typeof(index)==='undefined')return;if(this.prop.TaskStatuses[TaskID]===true){return true;}var tasks=this.prop.UncompletedTaskIndex;var uncompletedIndex=tasks.indexOf(index);this.prop.TaskStatuses[TaskID]=true;this.prop.TaskList[index].IsComplete=true;tasks.splice(uncompletedIndex,1);this.prop.UncompletedTaskIndex=tasks;this.prop.TasksRemaining=tasks.length;if(this.prop.TasksRemaining>0){if(this.prop.CurrentTask.TaskID===TaskID){this.ShowCurrentTask();}else{this.ShowCurrentCompletion();}}else{this.ClearLoadingScreen();}};this.ShowCurrentTask=function(){var orderedTasks=this.prop.UncompletedTaskIndex;if(orderedTasks.length<=0){return;}var count=0;var nextIndex=orderedTasks[count];var nextTask=this.prop.TaskList[nextIndex];while((nextTask.IsStub)&&(count