text: /*!
   * This source file is part of the open source project
   * ExpressionEngine (https://expressionengine.com)
   *
   * @link      https://expressionengine.com/
   * @copyright Copyright (c) 2003-2019, EllisLab Corp. (https://ellislab.com)
   * @license   https://expressionengine.com/license Licensed under Apache License, Version 2.0
   */
  EE.cp.DbBackup={buttons:$(".form-btns input.btn:visible"),init:function(){EE.cp.DbBackup._init()},_init:function(){this._bindButton()},_bindButton:function(){var e=this;this.buttons.on("click",function(t){t.preventDefault(),e._disableButton(!0),e._sendAjaxRequest()})},_disableButton:function(e){this.buttons.attr("disabled",!0),e?this.buttons.addClass("work"):this.buttons.addClass("disable")},_enableButton:function(){this.buttons.attr("disabled",!1).removeClass("work").removeClass("disable")},_sendAjaxRequest:function(e,t,n){var r={},s=new XMLHttpRequest,o=this;void 0!==e&&(r={table_name:e,offset:t,file_path:n}),r=Object.keys(r).map(function(e){return encodeURIComponent(e)+"="+encodeURIComponent(r[e])}).join("&"),s.open("POST",EE.db_backup.endpoint,!0),s.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),s.setRequestHeader("X-CSRF-TOKEN",EE.CSRF_TOKEN),s.onload=function(){try{var e=JSON.parse(s.responseText)}catch(t){return void o._presentError(t)}if(s.status>=200&&s.status<400){if(void 0==e.status)return void o._presentError(e);if("error"==e.status)return void o._presentError(e.message);if("finished"==e.status)return o._updateProgress(100),void(window.location=EE.db_backup.base_url);var n=document.createEvent("HTMLEvents");n.initEvent("mousemove",!0,!1),document.dispatchEvent(n),o._updateProgress(o._getPercentageForResponse(e)),o._sendAjaxRequest(e.table_name,e.offset,e.file_path)}else{if("error"==e.status)return void o._presentError(e.message);o._presentError(e)}},s.onerror=function(){o._presentError(response)},s.send(r)},_getPercentageForResponse:function(e){var t=0,n=EE.db_backup.table_counts;for(var r in n)if(n.hasOwnProperty(r)){if(r==e.table_name){t+=parseInt(e.offset);break}t+=parseInt(n[r])}return t=Math.round(t/EE.db_backup.total_rows*100),t>100?100:t},_updateProgress:function(e){var t=document.querySelectorAll(".progress")[0];t.style.width=e+"%"},_presentError:function(e){var t=EE.db_backup.backup_ajax_fail_banner.replace("%body%",e),n=document.createElement("div"),r=document.querySelectorAll(".form-standard form")[0];n.innerHTML=t,r.insertBefore(n,r.firstChild),this._enableButton(),this._disableButton()}},"loading"!=document.readyState?EE.cp.DbBackup.init():document.addEventListener("DOMContentLoaded",EE.cp.DbBackup.init);