﻿function GetUserDeskTopApp(){var Ajax=new BlueAjax();function Init(){Ajax.URL="../AjaxServer/DeskTop.aspx";Ajax.Method="POST";Ajax.AddData("Method","GetUserDeskTopApp");Ajax.AddData("FairyID",HostFairyID);Ajax.onLoaded=Loaded;Ajax.Execute()}function Loaded(){try{BlueTaskBar.CreateTaskBar();BlueDesk.DeskIcons=[];BlueDesk.CreateDeskArea();BlueDesk.options.TitleColor=DeskIconTitleColor;var ResultData=eval("("+Ajax.ResponseText+")");var FileList=[];if(ResultData.State=="success"&&ResultData.Data!="NoData"){FileList=ResultData.Data;for(var i=0;i<FileList.length;i++){if(FileList[i].OpenInfo.url.indexOf("?{fairyid}")!=-1)FileList[i].OpenInfo.url=FileList[i].OpenInfo.url.replace("\?{fairyid}","?FairyID="+HostFairyID);ShowFile(FileList[i])}}else if(ResultData.State=="success"&&ResultData.Data=="NoData"){FileList=[];SetAutoDeskTop()}}catch(err){}BlueDesk.ShowIcons()}Init()}function SetAutoDeskTop(){var Ajax=new BlueAjax();function Init(){Ajax.URL="../AjaxServer/DeskTop.aspx";Ajax.Method="POST";Ajax.AddData("Method","SetAutoDeskTop");Ajax.AddData("FairyID",HostFairyID);Ajax.onLoaded=Loaded;Ajax.Execute()}function Loaded(){try{var ResultData=eval("("+Ajax.ResponseText+")");if(ResultData.State=="success"){GetUserDeskTopApp()}}catch(err){}}Init()}function ShowFile(FileItem){var Icon=null;var Opt=FileItem.OpenInfo;Opt.title=FileItem.Name;if(Opt.openmodal==false)Opt.id=null;if(FileItem.Window!=null){checkloadjscssfile(FileItem.Window.StyleUrl,"css");Opt.classname=FileItem.Window.ClassName}if(FileItem.Status!=null){checkloadjscssfile(FileItem.Status.StyleUrl,"css");Opt.statusclassname=FileItem.Status.ClassName}if(FileItem.IconUrl!=null){var url=FileItem.IconUrl;url=url.replace(/\/Icons/,"");Icon=new DeskIcon({Src:url,Title:Opt.title,WinOptions:Opt,DeskTop_ID:FileItem.DeskTop_ID,x:FileItem.XPoint,y:FileItem.YPoint})}BlueDesk.InsertIcon({icon:Icon})}function DeleteDeskTopApp(DespTopIconID,IconID){var Result=false;var Ajax=new BlueAjax();function Init(){Ajax.URL="../AjaxServer/DeskTop.aspx";Ajax.Method="POST";Ajax.AddData("Method","DeleteDespTopIcon");Ajax.AddData("FairyID",HostFairyID);Ajax.AddData("IconID",DespTopIconID);Ajax.onLoaded=Loaded;Ajax.Execute()}function Loaded(){try{var ResultData=eval("("+Ajax.ResponseText+")");if(ResultData.State=="success")BlueDesk.RemoveIcon(IconID)}catch(err){}}Init()}function CreateDeskShutIcon(DespTopIconID){var Result=false;var Ajax=new BlueAjax();function Init(){Ajax.URL="../AjaxServer/DeskTop.aspx";Ajax.Method="POST";Ajax.AddData("Method","CreateDeskShutIcon");Ajax.AddData("FairyID",HostFairyID);Ajax.AddData("IconID",DespTopIconID);Ajax.onLoaded=Loaded;Ajax.Execute()}function Loaded(){try{var ResultData=eval("("+Ajax.ResponseText+")");if(ResultData.State=="success")GetUserDeskTopApp()}catch(err){}}Init()}function GetUserApplicationItem(AppItem){var Result=false;var Ajax=new BlueAjax();function Init(){Ajax.URL="../AjaxServer/DeskTop.aspx";Ajax.Method="POST";Ajax.AddData("Method","AppToDeskTop");Ajax.AddData("FairyID",HostFairyID);Ajax.AddData("AppID",AppItem.ID);Ajax.onLoaded=Loaded;Ajax.Execute()}function Loaded(){try{var ResultData=eval("("+Ajax.ResponseText+")");if(ResultData.State=="success")GetUserDeskTopApp()}catch(err){}}Init()}var Icons=[];function UpdatePosition(){var TempAddressList=[];Icons=BlueDesk.DeskIcons.concat(TempAddressList);TempUpdatePosition()}function TempUpdatePosition(){var Ajax=new BlueAjax();function Init(){Ajax.URL="../AjaxServer/DeskTop.aspx";Ajax.Method="POST";Ajax.AddData("Method","UpdatePosition");Ajax.AddData("FairyID",HostFairyID);Ajax.AddData("IconID",Icons[0].DeskTop_ID);Ajax.AddData("X",Icons[0].x);Ajax.AddData("Y",Icons[0].y);Ajax.onLoaded=Loaded;Ajax.Execute()}function Loaded(){try{var ResultData=eval("("+Ajax.ResponseText+")");if(ResultData.State=="success"&&Icons.length!=0){Icons.splice(0,1);TempUpdatePosition()}}catch(err){}}Init()}function SetDeskIconPosition(){var Icons=BlueDesk.DeskIcons;for(var i=0;i<Icons.length;i++){Icons[i].x=-1;Icons[i].y=-1}BlueDesk.ShowIcons()}
