AlkantarClanX12
Current Path : /home/thanudqk/siampokernew.org/wp-content/plugins/wp-optimize/js/ |
Current File : //home/thanudqk/siampokernew.org/wp-content/plugins/wp-optimize/js/wposmush-3-1-4.min.js |
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 console.log("WPO: JSON re-parse successful"),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 console.log("WPO: JSON re-parse successful"),t}catch(o){throw o}}}throw"WPO: could not parse the JSON"}jQuery(document).ready(function(s){WP_Optimize_Smush=WP_Optimize_Smush()});var WP_Optimize_Smush=function(){function s(){var s=0==I('input[type="checkbox"]:checked',U).length;C.prop("disabled",s),T.prop("disabled",s)}function e(s,i){if(G){var a=I("#smush-information-modal-cancel-btn .smush-information");O("mark_all_as_uncompressed",{restore_backup:s?1:0,delete_only_backups_meta:i?1:0},function(i){if(G)return i.hasOwnProperty("error")?(y(I("#smush-information-modal"),I.unblockUI),I("#smush-information-modal .smush-information").text(i.error),void o()):void(i.completed?(y(I("#smush-information-modal"),I.unblockUI),I("#smush-information-modal .smush-information").text(i.message),o()):(a.text(i.message),e(s)))})}}function o(e){var e="undefined"==typeof e||e,o={use_cache:e};console.log("Loading information about uncompressed images."),P.html("..."),z.hide(),f(!0),O("get_ui_update",o,function(e){console.log("Information about uncompressed images loaded."),x(e,r),g(),f(!1),s()})}function a(){I("#wpo_smush_images_grid input:checked").each(function(){image={attachment_id:I(this).val(),blog_id:I(this).data("blog")},B.push(image)}),data={optimization_id:"smush",selected_images:B,smush_options:{compression_server:I("input[name='compression_server']:checked").val(),image_quality:I("#image_quality").val(),lossy_compression:I("#smush-lossy-compression").is(":checked"),back_up_original:I("#smush-backup-original").is(":checked"),preserve_exif:I("#smush-preserve-exif").is(":checked")}},u(),O("process_bulk_smush",data)}function n(){if(I("#wp-optimize-wrap").length){I("#wpo_smush_images_save_options_spinner").show().delay(3e3).fadeOut(),I("#enable_custom_compression").is(":checked")?(image_quality=I("#custom_compression_slider").val(),lossy_compression=image_quality<100):(image_quality=I("#enable_lossy_compression").is(":checked")?90:100,lossy_compression=image_quality<100);var s={compression_server:I("input[name='compression_server']:checked").val(),image_quality:image_quality,lossy_compression:lossy_compression,back_up_original:I("#smush-backup-original").is(":checked"),back_up_delete_after:I("#smush-backup-delete").is(":checked"),back_up_delete_after_days:I("#smush-backup-delete-days").val(),preserve_exif:I("#smush-preserve-exif").is(":checked"),autosmush:I("#smush-automatically").is(":checked"),show_smush_metabox:I("#smush-show-metabox").is(":checked")};O("update_smush_options",s,function(s){I("#wpo_smush_images_save_options_spinner").hide(),s.hasOwnProperty("saved")&&s.saved?(I("#wpo_smush_images_save_options_done").show().delay(3e3).fadeOut(),q.hide()):(I("#wpo_smush_images_save_options_fail").show().delay(3e3).fadeOut(),q.show())})}}function t(){X=!0,R++,seconds=R%60+""<10?"0"+R%60:R%60,minutes=parseInt(R/60)+""<10?"0"+parseInt(R/60):parseInt(R/60),I("#smush_stats_timer").text(minutes+":"+seconds),m(R)}function m(s){0==s%3&&_(),0==s%60&&O("process_pending_images",{},function(s){x(s,c)})}function _(s){data={update_ui:!0,use_cache:!1},O("get_ui_update",data,function(s){x(s,c)})}function r(s){if(U.html(""),s&&s.hasOwnProperty("unsmushed_images")){s.unsmushed_images,s.pending_tasks;0==s.unsmushed_images.length&&0==s.pending_tasks&&U.text(wposmush.all_images_compressed).wrapInner("<div class='wpo-fieldgroup'> </div>"),0!=s.pending_tasks&&z.show().find(".red").text(s.pending);var e="post.php?post=",o="&action=edit";for(blog_id in s.unsmushed_images)for(i in s.unsmushed_images[blog_id])s.unsmushed_images[blog_id].hasOwnProperty(i)&&(image=s.unsmushed_images[blog_id][i],d(image,blog_id,s.admin_urls[blog_id]+e+image.id+o))}}function u(){X||(y(I("#wpo_smush_images_information_container")),service=I('.compression_server input[type="radio"]:checked + label small').text(),I("#wpo_smush_images_information_server").html(service),I("#smush_stats_pending_images").html("..."),I("#smush_stats_completed_images").html("..."),I("#smush_stats_bytes_saved").html("..."),I("#smush_stats_percent_saved").html("..."),I("#smush_stats_timer").html("..."),Z=window.setInterval(t,1e3),f(!0))}function c(s){I("#smush_stats_pending_images").html(s.pending_tasks),I("#smush_stats_completed_images").html(s.completed_task_count),I("#smush_stats_bytes_saved").html(s.bytes_saved),I("#smush_stats_percent_saved").html(s.percent_saved),1==s.smush_complete&&setTimeout(l,1500)}function l(){data={update_ui:!0,use_cache:!1,image_list:B},O("get_ui_update",data,function(s){summary=s.session_stats,0!=s.completed_task_count&&(summary+="<hr>"+s.summary),p(summary)})}function p(s){F||(I("#summary-message").html(s),h(),y(I("#smush-complete-summary")),F=!0)}function h(){R=0,X=!1,F=!1,B=[],window.clearInterval(Z),f(!1)}function d(s,e,o){var i=["wpo_smush_",e,"_",s.id].join("");image_html='<div class="wpo_smush_image" data-filesize="'+s.filesize+'">',image_html+='<a class="button" href="'+o+'" target="_blank"> '+wposmush.view_image+" </a>",image_html+='<input id="'+i+'" type="checkbox" data-blog="'+e+'" class="wpo_smush_image__input" value="'+s.id+'">',image_html+='<label for="'+i+'"></a>',image_html+='<div class="thumbnail">',image_html+='<img class="lazyload" src="'+s.thumb_url+'">',image_html+="</div></label></div>",U.append(image_html)}function g(){features=wposmush.features,service=I("input[name^='compression_server']:checked").val();for(feature in features[service])I("."+feature).prop("disabled",!features[service][feature]);I(".wpo_smush_image").each(function(){I(this).data("filesize")>wposmush.features[service].max_filesize?I(this).hide():I(this).show()})}function f(s){I.each([C,J,N,q,S,j,T],function(e,o){o.prop("disabled",s)}),s?(I("#wpo_smush_images_refresh").hide(),I(".wpo_smush_images_loader").show()):(I("#wpo_smush_images_refresh").show(),I(".wpo_smush_images_loader").hide())}function w(s,e){0!=s.length&&(data={selected_image:s,smush_options:e},y(wposmush.compress_single_image_dialog),O("compress_single_image",data,function(s){x(s,k)}))}function b(s,e){if(0!=e.length){y(wposmush.please_wait,I.unblockUI);var o={blog_id:s,selected_image:e};O("restore_single_image",o,function(s){x(s,k)})}}function k(s){if(s.hasOwnProperty("success")&&s.success){I(".smush-information").text(s.summary),y(I("#smush-information-modal"),I.unblockUI),I(".wpo-toggle-advanced-options.wpo_smush_single_image").removeClass("opened"),v(s.operation,s.summary,s.restore_possible);var e=s.blog_id||s.options.blog_id,o=s.image||s.options.attachment_id;H.hasOwnProperty(e)||(H[e]={}),H[e].hasOwnProperty(o)||(H[e][o]={}),"compress"==s.operation?H[e][o]={operation:s.operation,summary:s.summary,restore_possible:s.restore_possible}:H[e][o]={operation:s.operation}}else I(".smush-information").text(s.error_message),y(I("#smush-information-modal"),I.unblockUI)}function v(s,e,o){var i=I("#smush_info").closest("#smush-metabox-inside-wrapper");"compress"==s?(I(".wpo_smush_single_image").hide(),I(".wpo_restore_single_image").show(),I("#smush_info").text(e),I(".wpo_smush_mark_single_image").hide(),o?I(".restore_possible").show():I(".restore_possible").hide()):(I(".wpo_smush_single_image").show(),I(".wpo_restore_single_image").hide(),I(".wpo_smush_mark_single_image").show(),I(".wpo_smush_unmark_single_image",i).hide())}function y(s,e){I.blockUI({message:s,onOverlayClick:e,baseZ:160001,css:{width:"400px",padding:"20px",cursor:"pointer"}})}function x(s,e){s&&s.hasOwnProperty("status")&&s.status?e&&e(s):(alert(wposmush.error_unexpected_response),console.log(s))}function O(s,e,o,i){i="undefined"==typeof i||i,e=I.isEmptyObject(e)?{use_cache:!1}:e;var a={action:"updraft_smush_ajax",subaction:s,nonce:wposmush.smush_ajax_nonce,data:e},n={type:"POST",url:ajaxurl,data:a,success:function(s){if(i){try{var e=wpo_parse_json(s)}catch(a){console.log("smush_manager_send_command JSON parse error"),console.log(a),console.log(s),alert(wposmush.error_unexpected_response)}"undefined"!=typeof o&&o(e)}else"undefined"!=typeof o&&o(s)},error:function(s,e,i){console.log("smush_manager_send_command AJAX parse error: "+e+" ("+i+")"),"undefined"!=typeof o?o(s):(console.log(s),alert(wposmush.error_unexpected_response))},dataType:"text"};I.ajax(n)}var I=jQuery,U=(I("#wp-optimize-images-nav-tab-smush"),I("#wpo_smush_images_grid")),P=I("#smush_info_images"),z=I("#wpo_smush_images_pending_tasks_container"),j=I("#wpo_smush_images_pending_tasks_button"),q=I(".wpo-fieldgroup #wpo_smush_images_save_options_button"),S=I("#wpo_smush_images_refresh"),J=I("#wpo_smush_images_select_all"),N=I("#wpo_smush_images_select_none"),W=I("#wpo_smush_clear_stats_btn"),C=I("#wpo_smush_images_btn"),T=I("#wpo_smush_mark_as_compressed"),A=(I(".wpo_smush_single_image .button"),I(".wpo_restore_single_image .button"),I("#wpo_smush_mark_all_as_uncompressed_btn")),E=I("#wpo_smush_restore_all_compressed_images_btn"),Q=I(".wpo_smush_get_logs"),D=I("#wpo_smush_delete_backup_btn"),L=I(".compression_server"),R=0,X=!1,Z=0,B=[],F=!1,G=!1,H={};I("#wp-optimize-nav-tab-wrapper__wpo_images .nav-tab").on("click",function(){I(this).is("#wp-optimize-nav-tab-wpo_images-smush")&&o()}),I("#wp-optimize-wrap").on("page-change",function(s,e){"wpo_images"==e.page&&I("#wp-optimize-nav-tab-wrapper__wpo_images .nav-tab-active").is("#wp-optimize-nav-tab-wpo_images-smush")&&o()}),I("#smush-metabox").length>0&&g(),U.on("change",'input[type="checkbox"]',function(){s()}),s(),L.on("change",function(s){g(),n()}),C.off().on("click",function(){return 0==I('#wpo_smush_images_grid input[type="checkbox"]:checked').length?(I("#smush-information-modal .smush-information").text(wposmush.please_select_images),void y(I("#smush-information-modal"),I.unblockUI)):(I("#smush-information-modal .smush-information").text(wposmush.server_check),y(I("#smush-information-modal")),data={server:I("input[name='compression_server']:checked").val()},void O("check_server_status",data,function(s){s.online?a():(s.error?(error_message=s.error+"<br>"+wposmush.server_error,I("#smush-information-modal .smush-information").html(error_message)):I("#smush-information-modal .smush-information").text(wposmush.server_error),y(I("#smush-information-modal"),I.unblockUI))}))}),T.off().on("click",function(){if(0==I('#wpo_smush_images_grid input[type="checkbox"]:checked').length)return I("#smush-information-modal .smush-information").text(wposmush.please_select_compressed_images),void y(I("#smush-information-modal"),I.unblockUI);var s,e=[];I("#wpo_smush_images_grid input:checked").each(function(){s={attachment_id:I(this).val(),blog_id:I(this).data("blog")},e.push(s)}),y(wposmush.please_updating_images_info),O("mark_as_compressed",{selected_images:e},function(s){I("#smush-information-modal .smush-information").text(s.summary),y(I("#smush-information-modal"),I.unblockUI),o()})}),A.on("click",function(){if(confirm(wposmush.mark_all_images_uncompressed)){var s=confirm(wposmush.restore_images_from_backup);y(I("#smush-information-modal-cancel-btn")),I("#smush-information-modal-cancel-btn .smush-information").text(wposmush.please_wait),G=!0,e(s)}}),E.on("click",function(){confirm(wposmush.restore_all_compressed_images)&&(y(I("#smush-information-modal-cancel-btn")),I("#smush-information-modal-cancel-btn .smush-information").text(wposmush.please_wait),G=!0,e(!0,!0))}),I('#smush-information-modal-cancel-btn input[type="button"]').on("click",function(){G=!1,o(),I.unblockUI()}),S.off().on("click",function(){o()}),J.off().on("click",function(){I('#wpo_smush_images_grid input[type="checkbox"]').prop("checked",!0),s()}),N.off().on("click",function(){I('#wpo_smush_images_grid input[type="checkbox"]').prop("checked",!1),s()}),Q.off().on("click",function(){I("#log-panel").text("Please wait, fetching logs."),O("get_smush_logs",{},function(s){I.blockUI({message:I("#smush-log-modal"),onOverlayClick:I.unblockUI(),css:{width:"80%",height:"80%",top:"15%",left:"15%"}}),I("#log-panel").html("<pre>"+s+"</pre>"),download_link=ajaxurl+"?action=updraft_smush_ajax&subaction=get_smush_logs&nonce="+wposmush.smush_ajax_nonce,I("#smush-log-modal a").attr("href",download_link),console.log(download_link)},!1)}),D.on("click",function(){if(confirm(wposmush.delete_image_backup_confirm)){D.prop("disabled",!0);var s=I("#wpo_smush_delete_backup_spinner"),e=I("#wpo_smush_delete_backup_done");s.show(),O("clean_all_backup_images",{},function(){s.hide(),D.prop("disabled",!1),e.css("display","inline-block").delay(3e3).fadeOut()})}}),q.off().on("click",function(s){n()}),W.off().on("click",function(s){I("#wpo_smush_images_clear_stats_spinner").show().delay(3e3).fadeOut(),O("clear_smush_stats",{},function(s){I("#wpo_smush_images_clear_stats_spinner").hide(),I("#wpo_smush_images_clear_stats_done").show().delay(3e3).fadeOut()})}),j.off().on("click",function(s){I("#smush-information-modal .smush-information").text(wposmush.server_check),y(I("#smush-information-modal"),I.unblockUI),data={server:I("input[name='compression_server']:checked").val()},O("check_server_status",data,function(s){s.online?(u(),O("process_pending_images",{},function(s){x(s,c)})):(s.error?(error_message=s.error+"<br>"+wposmush.server_error,I("#smush-information-modal .smush-information").html(error_message)):I("#smush-information-modal .smush-information").text(wposmush.server_error),y(I("#smush-information-modal"),I.unblockUI))})}),I("body").on("click","#wpo_smush_images_pending_tasks_cancel_button",function(s){O("clear_pending_images",{},function(s){I.unblockUI(),s.status?(o(),h()):console.log("Cancelling pending images apparently failed.",s)})}),I("body").on("click",".wpo_smush_single_image .button",function(){image={attachment_id:I(this).data("id"),blog_id:I(this).data("blog")},I("#enable_custom_compression").is(":checked")?(image_quality=I("#custom_compression_slider").val(),lossy_compression=image_quality<100):(image_quality=I("#enable_lossy_compression").is(":checked")?90:100,lossy_compression=image_quality<100),smush_options={compression_server:I("input[name='compression_server_"+image.attachment_id+"']:checked").val(),image_quality:image_quality,lossy_compression:lossy_compression,back_up_original:I("#smush_backup_"+image.attachment_id).is(":checked"),preserve_exif:I("#smush_exif_"+image.attachment_id).is(":checked")},console.log("Compressing Image : "+image.attachment_id),data={server:I("input[name='compression_server_"+I(this).attr("id").substring(15)+"']:checked").val()},y(wposmush.server_check),O("check_server_status",data,function(s){s.online?w(image,smush_options):s.error?(error_message=s.error+"<br>"+wposmush.server_error,y(error_message,I.unblockUI)):y(wposmush.server_error,I.unblockUI)})}),I("body").on("click",".wpo_restore_single_image .button",function(){var s=I(this);blog_id=s.data("blog"),image_id=s.data("id"),image_id&&blog_id&&(console.log("Restoring Image : "+image_id),b(blog_id,image_id))}),I("body").on("click",".wpo_smush_mark_single_image .button",function(){var s={attachment_id:I(this).data("id"),blog_id:I(this).data("blog")},e=I(this).closest("#smush-metabox-inside-wrapper");y(wposmush.please_updating_images_info),O("mark_as_compressed",{selected_images:[s]},function(s){I("#smush-information-modal .smush-information").text(s.summary),y(I("#smush-information-modal"),I.unblockUI),s.status&&(I(".wpo_smush_single_image",e).hide(),I(".wpo-toggle-advanced-options",e).removeClass("opened"),I(".wpo_smush_mark_single_image",e).hide(),I(".wpo_smush_unmark_single_image",e).show(),I(".wpo_restore_single_image",e).show(),I("#smush_info",e).text(s.info))})}),I("body").on("click",".wpo_smush_unmark_single_image .button",function(){var s={attachment_id:I(this).data("id"),blog_id:I(this).data("blog")},e=I(this).closest("#smush-metabox-inside-wrapper");y(wposmush.please_updating_images_info),O("mark_as_compressed",{selected_images:[s],unmark:!0},function(s){I("#smush-information-modal .smush-information").text(s.summary),y(I("#smush-information-modal"),I.unblockUI),s.status&&(I(".wpo_smush_single_image",e).show(),I(".wpo_smush_mark_single_image",e).show(),I(".wpo_smush_unmark_single_image",e).hide(),I(".wpo_restore_single_image",e).hide(),I("#smush_info",e).text(""))})}),I("body").on("click","#smush-log-modal .close, #smush-information-modal .information-modal-close",function(){I.unblockUI()}),I("body").on("click",".wpo_smush_stats_cta_btn, .wpo_smush_get_logs, #smush-complete-summary .close",function(){I.unblockUI(),o(),setTimeout(h,500)}),I("body").on("click",".wpo-toggle-advanced-options",function(s){s.preventDefault(),I(this).toggleClass("opened")}),I(".wpo-fieldgroup .autosmush input, .wpo-fieldgroup .compression_level, .wpo-fieldgroup .image_options, #smush-show-metabox").on("change",function(s){n()}),I("body").on("change",".smush-options.compression_level",function(){I("#enable_custom_compression").is(":checked")?I(".smush-options.custom_compression").show():I(".smush-options.custom_compression").hide()}),I("body").on("change",'.smush-advanced input[type="radio"]',function(){g()}),I(document).on("admin-metabox-smush-loaded",function(){var s=I('.wpo_restore_single_image input[type="button"]').first().data();if(s&&H.hasOwnProperty(s.blog)&&H[s.blog].hasOwnProperty(s.id)){var e=H[s.blog][s.id];"compress"==e.operation?v(e.operation,e.summary,e.restore_possible):v(e.operation)}})};