update.min.js
2.99 KB
var stat_total=0,stat_files=0,stat_inbytes=0,stat_outbytes=0;function error_callback(t){alert("ERROR:\n"+t)}function empty(t){var r;if(""===t||0===t||"0"===t||null===t||!1===t||void 0===t)return!0;if("object"==typeof t){for(r in t)return!1;return!0}return!1}function is_array(t){var r,e,s="";if(!t)return!1;if(this.php_js=this.php_js||{},this.php_js.ini=this.php_js.ini||{},"object"==typeof t){if(this.php_js.ini["phpjs.objectsAsArrays"]&&(this.php_js.ini["phpjs.objectsAsArrays"].local_value.toLowerCase&&"off"===this.php_js.ini["phpjs.objectsAsArrays"].local_value.toLowerCase()||0===parseInt(this.php_js.ini["phpjs.objectsAsArrays"].local_value,10)))return t.hasOwnProperty("length")&&!t.propertyIsEnumerable("length")&&"String"!==(r=t.constructor,(e=/\W*function\s+([\w\$]+)\s*\(/.exec(r))?e[1]:"(Anonymous)");if(t.hasOwnProperty)for(s in t)if(!1===t.hasOwnProperty(s))return!1;return!0}return!1}doEncryptedAjax=function(t,r,e){var s=JSON.stringify(t);joomlaupdate_password.length>0&&(s=AesCtr.encrypt(s,joomlaupdate_password,128));var a={type:"POST",url:joomlaupdate_ajax_url,cache:!1,data:{json:s},timeout:6e5,success:function(t,s){var a="";if(-1==(n=t.indexOf("###")))return t="Invalid AJAX data:\n"+t,void(null==e?null!=error_callback&&error_callback(t):e(t));0!=n?(t.substr(0,n),a=t.substr(n)):a=t;var n=(a=a.substr(3)).lastIndexOf("###");a=a.substr(0,n);var o=null;if(joomlaupdate_password.length>0)try{o=JSON.parse(a)}catch(t){a=AesCtr.decrypt(a,joomlaupdate_password,128)}try{empty(o)&&(o=JSON.parse(a))}catch(r){t=r.message+"\n<br/>\n<pre>\n"+a+"\n</pre>";return void(null==e?null!=error_callback&&error_callback(t):e(t))}r(o)},error:function(t){var r="AJAX Loading Error: "+t.statusText;null==e?null!=error_callback&&error_callback(r):e(r)}};jQuery.ajax(a)},pingExtract=function(){this.stat_files=0,this.stat_inbytes=0,this.stat_outbytes=0;this.doEncryptedAjax({task:"ping"},function(t){startExtract(t)})},startExtract=function(){this.stat_files=0,this.stat_inbytes=0,this.stat_outbytes=0;this.doEncryptedAjax({task:"startRestore"},function(t){stepExtract(t)})},stepExtract=function(t){0!=t.status?(empty(t.Warnings),empty(t.factory)||(extract_factory=t.factory),t.done?finalizeUpdate():(stat_inbytes+=t.bytesIn,stat_percent=100*stat_inbytes/joomlaupdate_totalsize,stat_outbytes+=t.bytesOut,stat_files+=t.files,stat_percent<100?jQuery("#progress-bar").css("width",stat_percent+"%").attr("aria-valuenow",stat_percent):stat_percent>100?(stat_percent=100,jQuery("#progress-bar").css("width",stat_percent+"%").attr("aria-valuenow",stat_percent)):jQuery("#progress-bar").removeClass("bar-success"),jQuery("#extpercent").text(stat_percent.toFixed(1)+"%"),jQuery("#extbytesin").text(stat_inbytes),jQuery("#extbytesout").text(stat_outbytes),jQuery("#extfiles").text(stat_files),post={task:"stepRestore",factory:t.factory},doEncryptedAjax(post,function(t){stepExtract(t)}))):error_callback(t.message)},finalizeUpdate=function(){var t={task:"finalizeRestore",factory:window.factory};doEncryptedAjax(t,function(t){window.location=joomlaupdate_return_url})};