var LiveGap =(typeof LiveGap =="undefined") ? {} : LiveGap;
LiveGap.System=(typeof LiveGap.System =="undefined") ? {Id:"LiveGap OS"} : LiveGap.System;
LiveGap.System.Version='0.0.0.1';
LiveGap.System.Domain='charts.livegap.com';
LiveGap.System.Http='https';
//------------------------System Log
// Define The log object.
function Gap_Log(MyObject,MyEvent,Description)
{
this.MyObject=MyObject;
this.MyEvent=MyEvent;
this.Description=Description;
this.Element="Log";
this.CalTime=function () {return new Date()};
this.Time=this.CalTime();
this.CalLife=function ()
{
//try{y=this.Time.getTime()-(LiveGap.Log[0].Time.getTime())}
//catch(err){y=0}
y=0
return y
};
this.Life=this.CalLife();
}
//Update The log File
function Gap_log_Update()
{ TheLogfile= "";
GLNumber = ((Number($("span#GapLogNumber").text())));
for (i in LiveGap.Log)
{ if (i>=GLNumber)
{
TheLogfile+=GapConvertTime(LiveGap.Log[i].Life)+" "+LiveGap.Log[i].MyObject+" - "+LiveGap.Log[i].MyObject.Id+":"+LiveGap.Log[i].MyEvent+"
"
$("span#GapLogNumber").text(Number(i)+1);
}
}
$("div#GAPLog").append(TheLogfile);
}
function GapConvertTime(MilliSecondTime)
{
Millisecond =(MilliSecondTime)%1000;
TotalinSecond=(MilliSecondTime-Millisecond)/1000;
Seconds=(TotalinSecond)%60;
Totalinminute=(TotalinSecond-Seconds)/60;
Minutes=(Totalinminute)%60;
TotalinHour=(Totalinminute-Minutes)/60;
Hour=(TotalinHour)%24;
//for dislay 00 before number less than 10 or 100
DMillisecond=""
if(Millisecond<10){DMillisecond+="0"};
if(Millisecond<100){DMillisecond+="0"};
DMillisecond+=Millisecond;
DSeconds=""
if(Seconds<10){DSeconds+="0"};
DSeconds+=Seconds;
DMinutes=""
if(Minutes<10){DMinutes+="0"};
DMinutes+=Minutes;
DHour=""
if(Hour<10){DHour+="0"};
DHour+=Hour;
All=DHour+":"+DMinutes+":"+DSeconds+":"+DMillisecond;
return All;
}
// Create the log File
function Gap_log_Create()
{
if(GAP_CheckFiles())
{
$(document.body).append("
0
");
Gap_log_Update()
$("div#GAPLog").dialog({autoOpen: false,title: 'Log File',width: 500,height: 300})
//Create the Shortcut Keyboard for the LOG
/*
$(document).keypress(function(e){
if (e.which == 126 || e.keyCode == 126 || window.event.keyCode == 126)
{$("div#GAPLog").dialog( "open" ).show('drop') };
});
*/
//----------------------------------------
}
}
//Start The Log System Or Reloaded
if(typeof LiveGap.Log !="undefined")
{
LiveGap.Log.push(new Gap_Log(LiveGap.System,"Reload","LiveGap is reloaded again"));
Gap_log_Update();
};
if(typeof LiveGap.Log =="undefined")
{
LiveGap.Log=[new Gap_Log(LiveGap.System,"Start","LiveGap is Starting")]
};
//------------------------files
// Define The file object.
function Gap_Files(URL,Type,Id,Group)
{
this.Id=Id;
this.URL=URL;
this.Type=Type;
this.Element="File";
this.Group=Group;
this.Isloaded=(typeof this.Isloaded =="undefined") ? false : true;
this.IsAdded=(typeof this.IsAdded =="undefined") ? false : true;
this.AddFile=GapAddFile;
this.GAP_OnLoad=GAP_Events;
}
function Gap_GroupOfFiles(Id)
{
this.Id=Id;
this.Element="GroupOfFile";
this.Files=new Array();
for (Gap_File in LiveGap.Files) {
if(LiveGap.Files[Gap_File].Group==Id ){this.Files.push(LiveGap.Files[Gap_File])}
}
this.AddFiles=GapAddGroupOfFile;
}
//----- Add The File to The Page
function GapAddFile()
{
if(!this.IsAdded)
{
this.IsAdded=true;
var GL_Object=this;
var headID = document.getElementsByTagName("head")[0];
LiveGap.Log.push(new Gap_Log(this,"Loading","------" ));
// For Not duplicate
if (this.Type=="Script" )
{
var newScript = document.createElement("script");
newScript.type = "text/javascript";
newScript.src =this.URL;
headID.appendChild(newScript);
newScript.onreadystatechange= function () {if ((this.readyState === "loaded" || this.readyState === "complete") && GL_Object.Isloaded==false) {GL_Object.Isloaded=true;GL_Object.GAP_OnLoad("Complete")}};
newScript.onload= function(){if (GL_Object.Isloaded==false){GL_Object.Isloaded=true;GL_Object.GAP_OnLoad("Complete")};
}}
if (this.Type=="CSS")
{
var cssNode = document.createElement("link");
cssNode.type = "text/css";
cssNode.rel = "stylesheet";
cssNode.href = this.URL;
cssNode.media = "screen";
headID.appendChild(cssNode);
var Html = document.getElementsByTagName('html')[0];
var CssImg = document.createElement('img');
CssImg.style.display="none";
CssImg.onerror = function(){GL_Object.Isloaded=true;GL_Object.GAP_OnLoad("Complete");document.body.removeChild(CssImg);}
CssImg.src = GL_Object.URL;
document.body.appendChild(CssImg);
}
if (this.Type=="Images")
{
var Html = document.getElementsByTagName('html')[0];
var Gap_Img = document.createElement('img');
Gap_Img.src = GL_Object.URL;
Gap_Img.style.display="none";
Gap_Img.onload = function(){GL_Object.Isloaded=true;GL_Object.GAP_OnLoad("Complete");document.body.removeChild(Gap_Img);}
document.body.appendChild(Gap_Img);
}
}
}
//Chech if All Files is loaded.
function GAP_CheckFiles(Group)
{
if(Group !=undefined){
for (Gap_File in LiveGap.Files) {
if(!LiveGap.Files[Gap_File].Isloaded && LiveGap.Files[Gap_File].Group==Group.Id ){return false}
}
LiveGap.Log.push(new Gap_Log(Group,"Complete","finish loading Groups of Files" ));
return true;
}
if(Group ==undefined)
{
for (Gap_File in LiveGap.Files) {
if(!LiveGap.Files[Gap_File].Isloaded){return false}
}
return true;
}
}
//--------------------------------------
// Load a group of files
function GapAddGroupOfFile()
{
LiveGap.LoadingGroup=this.Id;
LiveGap.Log.push(new Gap_Log(this,"Add Group Of files ","------" ));
for (Gap_File in LiveGap.Files) {
// check if fancybox is loaded before in this page not duplicated it
/*
if(LiveGap.Files[Gap_File]==LiveGap.Files.FancyBox && LiveGap.Files[Gap_File].Group==this.Id)
{
alert("fancyBox is Checked:"+LiveGap.Files[Gap_File].Id);
if(typeof $.fancybox == 'function')
{
alert("fancyBox is loaded before");
LiveGap.Files[Gap_File].IsAdded=true;
LiveGap.Files[Gap_File].IsLoaded=true;
}
};
*/
//---------------------------------------------------------------------
if(!LiveGap.Files[Gap_File].IsAdded && LiveGap.Files[Gap_File].Group==this.Id ){LiveGap.Files[Gap_File].AddFile();}
}
}
function GAP_CheckGroupsOfFiles()
{
if(LiveGap.LoadingGroup==LiveGap.groupsOfFiles[LiveGap.groupsOfFiles.length-1].Id && GAP_CheckFiles(LiveGap.groupsOfFiles[LiveGap.groupsOfFiles.length-1])){
if (typeof waitForUserAction === 'undefined') {Gap_Login();}
if (typeof waitForUserAction !== 'undefined') {
if( waitForUserAction=="Ready"){Gap_Login();}
if( waitForUserAction=="loading"){waitForUserAction="Ready"}
if( waitForUserAction=="UserClick-Loading"){Gap_Login();}
}
}
for(i=LiveGap.groupsOfFiles.length-2;i>=0;i--)
{if(LiveGap.LoadingGroup==LiveGap.groupsOfFiles[i].Id && GAP_CheckFiles(LiveGap.groupsOfFiles[i])){LiveGap.LoadingGroup=LiveGap.groupsOfFiles[i+1].Id;LiveGap.groupsOfFiles[i+1].AddFiles();}}
}
function GAP_Events_Files(GAP_File,MyEvent)
{
if( MyEvent=="Complete"){
if(GAP_File.Isloaded ){LiveGap.Log.push(new Gap_Log(GAP_File,MyEvent,"-------" ));}
//Check The loading image is loaded or still not.
if(GAP_File.Isloaded && GAP_File.Id=="LoadingSite" && GAP_File.Type=="Images")
{
if((document.domain) && document.domain.indexOf("livegap.")==-1)
{
// add the image
var Html = document.getElementsByTagName('html')[0];
var Gap_Img = document.createElement('img');
Gap_Img.src = LiveGap.Files.loading.URL;
Gap_Img.id="LoadingLogoImage";
Gap_Img.style.display="block";
Gap_Img.style.position="absolute";
Gap_Img.style.left="10%";
Gap_Img.style.top="10%";
//Gap_Img.style.zIndex="99999999";
document.body.appendChild(Gap_Img);
} }
}
}
function Gap_Login()
{
document.body.innerHTML=HtmlEditor;
MainFile=new GapFile(location.href,"text/html","index").add();
checkChartLibrary();
}
if(typeof LiveGap.Files =="undefined") {
LiveGap.Files = {
JqueryUITheme:new Gap_Files(LiveGap.System.Http+"://"+LiveGap.System.Domain+"/css/themes/base/jquery-ui.min.css","CSS","JqueryUITheme","MainFile"),
MainCSS:new Gap_Files(LiveGap.System.Http+"://"+LiveGap.System.Domain+"/v2/css/main.css","CSS","MainCSS","MainFile"),
HandsontableCSS:new Gap_Files(LiveGap.System.Http+"://"+LiveGap.System.Domain+"/v2/css/handsontable.css","CSS","HandsontableCSS","MainFile"),
Jquery:new Gap_Files("//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js","Script","Jquery","MainFile"),
HandsontableJs:new Gap_Files(LiveGap.System.Http+"://"+LiveGap.System.Domain+"/v2/js/handsontable.js","Script","HandsontableJs","MainFile2"),
JqueryUI:new Gap_Files("//ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/jquery-ui.min.js","Script","JqueryUI","MainFile2"),
MainJs:new Gap_Files(LiveGap.System.Http+"://"+LiveGap.System.Domain+"/v2/js/v2.js","Script","MainJs","MainFile3"),
VueJs:new Gap_Files("https://cdnjs.cloudflare.com/ajax/libs/vue/2.7.14/vue.min.js","Script","VueJs","MainFile2"),
Vuetify:new Gap_Files("https://cdnjs.cloudflare.com/ajax/libs/vuetify/2.6.15/vuetify.min.js","Script","Vuetify","MainFile3"),
MaterialCSS:new Gap_Files("https://cdn.jsdelivr.net/npm/@mdi/font@6.x/css/materialdesignicons.min.css","CSS","MaterialCSS","MainFile2"),
VuetifyCSS:new Gap_Files("https://cdnjs.cloudflare.com/ajax/libs/vuetify/2.6.15/vuetify.min.css","CSS","VuetifyCSS","MainFile3")
}
LiveGap.groupsOfFiles=[new Gap_GroupOfFiles("MainFile"),new Gap_GroupOfFiles("MainFile2"),new Gap_GroupOfFiles("MainFile3")];
LiveGap.groupsOfFiles[0].AddFiles();
} ;
function GAP_Events(MyEvent)
{
if(this.Element="File"){GAP_Events_Files(this,MyEvent);}
GAP_CheckGroupsOfFiles();
Gap_log_Create();
}
// if Page is loaded Before
if (GAP_CheckFiles()){Gap_Login()};