| 1 |
jQuery(document).ready((function(t){"use strict";var e=t("#bbp-converter-message"),r=t("#bbp-converter-stop"),n=t("#bbp-converter-start"),s=t("#_bbp_converter_restart"),a=t("#bbp-converter-status"),o=t("#bbp-converter-spinner"),i=t("#bbp-converter-settings"),_=t("#_bbp_converter_db_pass"),c=t(".bbp-db-pass-toggle"),p=t("#bbp-converter-step-percentage"),v=t("#bbp-converter-total-percentage"),B=i.find("table:first-of-type input, table:first-of-type select");function u(){var e;t.post(ajaxurl,(e={},t.each(i.serializeArray(),(function(t,r){e[r.name]=r.value})),e._bbp_converter_restart&&s.removeAttr("checked"),e._bbp_converter_delay_time&&(BBP_Converter.state.delay=1e3*parseInt(e._bbp_converter_delay_time,10)),e.action="bbp_converter_process",e._ajax_nonce=BBP_Converter.ajax_nonce,e),(function(t){try{var e=t.data;!0===t.success?function(t){if(!BBP_Converter.state.running)return;C(t.progress),e=t.step_percent,r=t.total_percent,p.width(e+"%"),void v.width(r+"%"),function(t){var e=parseInt(BBP_Converter.state.delay,10)/1e3;a.text(BBP_Converter.strings.status_counting.replace("%s",e)),clearInterval(BBP_Converter.state.status),BBP_Converter.state.status=setInterval((function(){e--,a.text(BBP_Converter.strings.status_counting.replace("%s",e)),e<=0&&(clearInterval(BBP_Converter.state.status),parseInt(t.current_step,10)<parseInt(t.final_step,10)?a.text(BBP_Converter.strings.status_up_next.replace("%s",t.current_step)):a.text(BBP_Converter.strings.status_complete))}),1e3)}(t),function(){if(clearTimeout(BBP_Converter.state.running),!BBP_Converter.state.running)return;BBP_Converter.state.running=setTimeout((function(){u()}),parseInt(BBP_Converter.state.delay,10))}(),t.current_step===t.final_step&&l(BBP_Converter.strings.button_start,BBP_Converter.strings.import_complete);var e,r}(e):l()}catch(t){l()}}),"json")}function l(t,e){clearTimeout(BBP_Converter.state.running),clearInterval(BBP_Converter.state.status),BBP_Converter.state.running=!1,BBP_Converter.state.status=!1,t||(t=BBP_Converter.strings.button_continue),e||(e=BBP_Converter.strings.status_stopped),b(t,e,BBP_Converter.strings.status_stopped),n.show(),r.hide(),o.css("visibility","hidden"),B.prop("readonly",!1)}function b(t,e,r){n.val(t),C(e),a.text(r)}function C(t){t="<p>"+t+"</p>",e.prepend(t)}c.on("click",(function(t){var e="password"===_.attr("type")?"text":"password";_.attr("type",e),c.toggleClass("password").toggleClass("text"),t.preventDefault()})),n.on("click",(function(t){!function(){clearTimeout(BBP_Converter.state.running),clearInterval(BBP_Converter.state.status),BBP_Converter.state.running=!0;var t=BBP_Converter.strings.start_continue;!1===BBP_Converter.state.started&&(t=BBP_Converter.strings.start_start,BBP_Converter.state.started=!0),b(BBP_Converter.strings.button_continue,t,BBP_Converter.strings.status_starting),e.addClass("started"),n.hide(),r.show(),o.css("visibility","visible"),B.prop("readonly",!0),u()}(),t.preventDefault()})),t(r).on("click",(function(t){l(BBP_Converter.strings.button_continue,BBP_Converter.strings.import_stopped_user),t.preventDefault()}))})); |