FR.softwareUpdatePanel=new Ext.Panel({title:FR.T("Step 1:")+" "+FR.T("Check for updates"),layout:"fit",cls:"fr-admin-panel",autoScroll:true,html:FR.T("Your current software version is %1").replace("%1","<strong>"+FR.currentVersion+"</strong>"),tbar:[{id:"updates-restart-btn",text:"Start again",iconCls:"fa-reply",hidden:true,handler:function(){this.ownerCt.ownerCt.setTitle(FR.T("Step 1:")+" "+FR.T("Check for updates"));this.ownerCt.ownerCt.update("");this.hide();Ext.getCmp("updates-install-btn").hide();Ext.getCmp("updates-check-btn").show()}},{id:"updates-check-btn",text:"Check for updates",cls:"fr-btn-primary",iconCls:"fa-refresh",handler:function(){this.ownerCt.ownerCt.el.mask("Checking for updates...");Ext.Ajax.request({url:FR.URLRoot+"/?module=software_update&section=cpanel&page=check",success:function(originalRequest){this.el.unmask();var response=eval("("+originalRequest.responseText+")");this.update(response.msg);if(response.rs){this.setTitle(FR.T("Step 2:")+" "+FR.T("Download update"));Ext.getCmp("updates-download-btn").show();Ext.getCmp("updates-check-btn").hide();FR.updateDownloadURL=response.url;FR.updateDownloadSize=response.size}},failure:function(){},scope:this.ownerCt.ownerCt})}},{id:"updates-download-btn",text:"Download update",cls:"fr-btn-primary",iconCls:"fa-download",hidden:true,handler:function(){this.ownerCt.ownerCt.el.mask("Downloading update...");Ext.Ajax.request({url:FR.URLRoot+"/?module=software_update&section=cpanel&page=download",params:{downloadURL:FR.updateDownloadURL,downloadSize:FR.updateDownloadSize},success:function(originalRequest){this.el.unmask();var response=eval("("+originalRequest.responseText+")");this.update(response.msg);if(response.success){this.setTitle(FR.T("Step 3:")+" "+FR.T("Install update"));Ext.getCmp("updates-install-btn").show();Ext.getCmp("updates-download-btn").hide()}},failure:function(){},scope:this.ownerCt.ownerCt})}},{id:"updates-install-btn",text:"Install update",cls:"fr-btn-primary",iconCls:"fa-flash",hidden:true,handler:function(){this.ownerCt.ownerCt.el.mask("Installing update...");Ext.getCmp("updates-restart-btn").show();Ext.Ajax.request({url:FR.URLRoot+"/?module=software_update&section=cpanel&page=install",success:function(originalRequest){this.el.unmask();this.update("<pre>"+originalRequest.responseText+"</pre>")},failure:function(){},scope:this.ownerCt.ownerCt})}},"->",{iconCls:"fa-upload",tooltip:"Manually upload update package",handler:function(){if(!this.flow){this.flow=new Flow({target:"?module=software_update&section=cpanel&page=upload",singleFile:true,startOnSubmit:true,chunkSize:FR.uploadChunkSize,resumeLargerThan:31457280,maxChunkRetries:3,validateChunkResponse:function(status,message){if(status!="200"){return"retry"}try{var rs=Ext.util.JSON.decode(message)}catch(er){return"retry"}if(rs){if(rs.success){return"success"}else{return"error"}}}});this.flow.on("filesSubmitted",function(){FR.softwareUpdatePanel.update(FR.T("Upload starting..."))});this.flow.on("progress",function(flow){var percent=Math.floor(flow.getProgress()*100);FR.softwareUpdatePanel.update(FR.T("Uploading...%1%").replace("%1",percent))});this.flow.on("fileSuccess",function(file,message){try{var rs=Ext.util.JSON.decode(message)}catch(er){FR.feedback("Unexpected server reply: "+message,"error")}if(rs&&rs.msg){FR.softwareUpdatePanel.update(rs.msg);if(rs.success){FR.softwareUpdatePanel.setTitle(FR.T("Step 3:")+" "+FR.T("Install update"));Ext.getCmp("updates-check-btn").hide();Ext.getCmp("updates-install-btn").show()}}});this.flow.on("fileError",function(file,message){try{var rs=Ext.util.JSON.decode(message)}catch(er){FR.feedback("Unexpected server reply: "+message,"error")}if(rs&&rs.msg){new Ext.ux.prompt({text:rs.msg})}})}this.flow.removeAll();this.flow.browseFiles()}}]});Ext.getCmp("appTab").add(FR.softwareUpdatePanel);Ext.getCmp("appTab").doLayout();