var isEdition=getQueryString("isEdition");var sh=new sqlHelper(gui.App.dataPath,"360doc.db");var pkg=require('../package.json');var updater=require('node-webkit-updater');var upd=new updater(pkg);var copyPath,execPath;var progressTimer;var tpe;if(GetOSInfo()=="Mac"){tpe=1}else{tpe=0};var strRequestUrl=cv.post+"/ajax/users.ashx?ver=0.01&os=windows&op=getrenewmes2&type="+tpe;var sign="&sign="+getSign.sign(strRequestUrl);ajax_method(strRequestUrl+sign,null,"post",function(result){var data=eval("("+result+")");if(data.status==1){var exec=require('child_process').exec,child;if(GetOSInfo()=="Mac"){child=exec('rm -rf '+process.cwd()+'/app',myCallback)}else{child=exec('rd /s /q "'+process.cwd()+'\\app\\"',myCallback)};$("#upgrade_title").text(data.title);$("#upgrade_Content").html(data.Content);var version=data.version;var versionid=data.versionid;$(".upgrade").show();var filename=data.url;var url=filename.split(",");var startC=parseInt(Math.floor(Math.random()+1)*3);$('.progressBar span').width(startC+'%');progressTimer=setInterval(function(){startC+=Math.random()*2;if(startC>=95){clearInterval(progressTimer);startC=95};$('.progressBar span').width(startC+'%');$('.progress span').html(startC.toFixed(0)+'%')},1000);upd.options.temporaryDirectory=process.cwd();function myCallback(){pkg.version=version;pkg.versionId=versionid;var params={"version":version,"versionId":versionid};changeJson(0,params,function(){download(0)})};function download(num){if(num==url.length){clearInterval(progressTimer);$('.progressBar span').width('100%');$('.progress').html('正在解压安装...');unpack(0);return false};var zipUrl=url[num];var zipName=zipUrl;var index=zipName.lastIndexOf("\/");zipName=zipName.substring(index+1);downloadZip(zipUrl,zipName,function(){download(num+1)})};function unpack(num){if(num==url.length){sh.batchData('UpdateInfo',' version="'+version+'",versionid="'+versionid+'"',null,function(){});$('.progress').hide();$(".upgradeComplete,.upgradeComplete-btn").show();$("#upgradeClose").addClass("close");$("#upgradeAfter-sure,#upgradeAfter-cancel,#upgradeClose").click(function(){var new_win=gui.Window.open("/app/open.html",{position:'center',frame:false,width:0,height:0,show:false,always_on_top:true,});win.close(true)});return false};var zipUrl=url[num];var zipName=zipUrl;var index=zipName.lastIndexOf("\/");zipName=zipName.substring(index+1);var name=process.cwd()+"/"+zipName;upd.unpack(name,function(error,newAppPath){unpack(num+1)},upd.manifest)}}});function openChildWindow(url,id){sh.checkData('usersInfo','*',"UserID = '"+id+"'",function(info,err){if(info.isWinFull==1){var winOpen=gui.Window.open(url,{position:'center',frame:false,width:1000,height:600,min_width:880,min_height:500,})}else{var winOpen=gui.Window.open(url,{position:'center',frame:false,width:info.winWidth,height:info.winHeight,min_width:880,min_height:500,})};win.close(true)})}