function wpo_parse_json(s){if("object"==typeof s)return s;try{var e=JSON.parse(s);return e}catch(o){console.log("WPO: Exception when trying to parse JSON (1) - will attempt to fix/re-parse"),console.log(s)}var i=s.indexOf("{"),a=s.lastIndexOf("}");if(i>-1&&a>-1){var n=s.slice(i,a+1);try{var t=JSON.parse(n);return t}catch(o){console.log("WPO: Exception when trying to parse JSON (2) - will attempt to fix/re-parse based upon bracket counting");for(var m=i,_=0,r="",u=!1;(_>0||m==i)&&m<=a;){var c=s.charAt(m);u||"{"!=c?u||"}"!=c?'"'==c&&"\\"!=r&&(u=!u):_--:_++,r=c,m++}console.log("Started at cursor="+i+", ended at cursor="+m+" with result following:"),console.log(s.substring(i,m));try{var t=JSON.parse(s.substring(i,m));return t}catch(o){throw o}}}throw"WPO: could not parse the JSON"}jQuery(function(s){WP_Optimize_Smush=WP_Optimize_Smush()});var WP_Optimize_Smush=function(){function s(){var s=0==U('input[type="checkbox"]:checked',z).length;K.prop("disabled",s),M.prop("disabled",s)}function e(s,o){if(H){var i=U("#smush-information-modal-cancel-btn .smush-information");I("mark_all_as_uncompressed",{restore_backup:s?1:0,delete_only_backups_meta:o?1:0},function(o){if(H)return o.hasOwnProperty("error")?(x(U("#smush-information-modal"),U.unblockUI),U("#smush-information-modal .smush-information").text(o.error),void a()):void(o.completed?(x(U("#smush-information-modal"),U.unblockUI),U("#smush-information-modal .smush-information").text(o.message),a()):(i.text(o.message),e(s)))})}}function o(){U(this).toggleClass("opened"),U(this).hasClass("opened")?U(this).text(wposmush.less):U(this).text(wposmush.more)}function a(e){var e="undefined"==typeof e||e,o={use_cache:e};P.html("..."),j.hide(),w(!0),I("get_ui_update",o,function(e){O(e,u),f(),w(!1),s()})}function n(){U("#wpo_smush_images_grid input:checked").each(function(){image={attachment_id:U(this).val(),blog_id:U(this).data("blog")},F.push(image)}),data={optimization_id:"smush",selected_images:F,smush_options:{compression_server:U("input[name='compression_server']:checked").val(),image_quality:U("#image_quality").val(),lossy_compression:U("#smush-lossy-compression").is(":checked"),back_up_original:U("#smush-backup-original").is(":checked"),preserve_exif:U("#smush-preserve-exif").is(":checked")}},c(),I("process_bulk_smush",data)}function t(){if(U("#wp-optimize-wrap").length){U("#wpo_smush_images_save_options_spinner").show().delay(3e3).fadeOut(),U("#enable_custom_compression").is(":checked")?(image_quality=U("#custom_compression_slider").val(),lossy_compression=image_quality<100):(image_quality=U("#enable_lossy_compression").is(":checked")?90:100,lossy_compression=image_quality<100);var s={compression_server:U("input[name='compression_server']:checked").val(),image_quality:image_quality,lossy_compression:lossy_compression,back_up_original:U("#smush-backup-original").is(":checked"),back_up_delete_after:U("#smush-backup-delete").is(":checked"),back_up_delete_after_days:U("#smush-backup-delete-days").val(),preserve_exif:U("#smush-preserve-exif").is(":checked"),autosmush:U("#smush-automatically").is(":checked"),show_smush_metabox:U("#smush-show-metabox").is(":checked"),webp_conversion:U("#enable_webp_conversion").is(":checked")};I("update_smush_options",s,function(s){U("#wpo_smush_images_save_options_spinner").hide(),s.hasOwnProperty("saved")&&s.saved?(U("#wpo_smush_images_save_options_done").show().delay(3e3).fadeOut(),S.hide()):(U("#wpo_smush_images_save_options_fail").show().delay(3e3).fadeOut(),S.show())})}}function m(){Z=!0,X++,seconds=X%60+""<10?"0"+X%60:X%60,minutes=parseInt(X/60)+""<10?"0"+parseInt(X/60):parseInt(X/60),U("#smush_stats_timer").text(minutes+":"+seconds),_(X)}function _(s){0==s%3&&r(),0==s%60&&I("process_pending_images",{},function(s){O(s,l)})}function r(s){data={update_ui:!0,use_cache:!1},I("get_ui_update",data,function(s){O(s,l)})}function u(s){if(z.html(""),s&&s.hasOwnProperty("unsmushed_images")){s.unsmushed_images,s.pending_tasks;0==s.unsmushed_images.length&&0==s.pending_tasks&&z.text(wposmush.all_images_compressed).wrapInner("
"),0!=s.pending_tasks&&j.show().find(".red").text(s.pending);var e="post.php?post=",o="&action=edit";for(blog_id in s.unsmushed_images){s.unsmushed_images[blog_id].sort(function(s,e){return s.id-e.id});for(i in s.unsmushed_images[blog_id])s.unsmushed_images[blog_id].hasOwnProperty(i)&&(image=s.unsmushed_images[blog_id][i],g(image,blog_id,s.admin_urls[blog_id]+e+image.id+o))}}}function c(){Z||(x(U("#wpo_smush_images_information_container")),service=U('.compression_server input[type="radio"]:checked + label small').text(),U("#wpo_smush_images_information_server").html(service),U("#smush_stats_pending_images").html("..."),U("#smush_stats_completed_images").html("..."),U("#smush_stats_bytes_saved").html("..."),U("#smush_stats_percent_saved").html("..."),U("#smush_stats_timer").html("..."),B=window.setInterval(m,1e3),w(!0))}function l(s){U("#smush_stats_pending_images").html(s.pending_tasks),U("#smush_stats_completed_images").html(s.completed_task_count),U("#smush_stats_bytes_saved").html(s.bytes_saved),U("#smush_stats_percent_saved").html(s.percent_saved),1==s.smush_complete&&setTimeout(p,1500)}function p(){data={update_ui:!0,use_cache:!1,image_list:F},I("get_ui_update",data,function(s){summary=s.session_stats,0!=s.completed_task_count&&(summary+=""+s.summary),h(summary)})}function h(s){G||(U("#summary-message").html(s),d(),x(U("#smush-complete-summary")),G=!0)}function d(){X=0,Z=!1,G=!1,F=[],window.clearInterval(B),w(!1)}function g(s,e,o){var i=["wpo_smush_",e,"_",s.id].join("");image_html='