PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.1.7.3
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.1.7.3
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / assets / js / dist / admin / pages / sync-data.min.js

sync-data.min.js in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.1.7.3, at assets/js/dist/admin/pages/sync-data.min.js

1 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 !function(s){const e={id:"sync-base",syncing:!1,items:!1,completed:!1,callback:null,methodGetItems:"",itemsKey:"",chunkSize:50,sync(s){if(!this.syncing){if(this.callback=s,!1===this.items)this.get_items();else if(!this.dispatch())return this.completed=!0,void this.callToCallback();this.syncing=!0}},init(){this.syncing=!1,this.items=!1,this.completed=!1},is_completed(){return this.completed},dispatch(){const e=this,t=!!this.items&&this.items.splice(0,this.chunkSize);return!(!t||0===t.length||(s.ajax({url:"",data:{"lp-ajax":this.id,sync:t},method:"post",success(s){s=LP.parseJSON(s),e.syncing=!1,"success"!==s.result&&(e.completed=!0),e.callToCallback(),e.is_completed()||e.sync(e.callback)}}),0))},callToCallback(){this.callback&&this.callback.call(this)},get_items(){const e=this;s.ajax({url:"",data:{"lp-ajax":this.id,sync:this.methodGetItems},success(s){e.syncing=!1,(s=LP.parseJSON(s))[e.itemsKey]?(e.items=s[e.itemsKey],e.sync(e.callback)):(e.completed=!0,e.items=[],e.callToCallback())}})}},t=s.extend({},e,{id:"sync-course-orders",methodGetItems:"get-courses",itemsKey:"courses"}),n=s.extend({},e,{id:"sync-user-courses",methodGetItems:"get-users",itemsKey:"users",chunkSize:500}),c=s.extend({},e,{id:"sync-user-orders",methodGetItems:"get-users",itemsKey:"users",chunkSize:500}),i=s.extend({},e,{id:"sync-course-final-quiz",methodGetItems:"get-courses",itemsKey:"courses",chunkSize:500}),l=s.extend({},e,{id:"sync-remove-older-data",methodGetItems:"remove-older-data",itemsKey:"_nothing_here",chunkSize:500}),o=s.extend({},e,{id:"sync-calculate-course-results",methodGetItems:"get-users",itemsKey:"users",chunkSize:1});window.LP_Sync_Data={syncs:[],syncing:0,options:{},start(e){if(this.syncs=[],this.options=s.extend({onInit(){},onStart(){},onCompleted(){},onCompletedAll(){}},e||{}),this.get_syncs()){this.reset(),this.options.onInit.call(this);var t=this,n=0,c=this.syncs.length,i=function(s){if(s.is_completed()){if(n++,t.options.onCompleted.call(t,s),n>=c)return void t.options.onCompletedAll.call(t);t.sync(n,i)}};this.sync(n,i)}},reset(){for(const s in this.syncs)try{this[this.syncs[s]].init()}catch(s){}},sync(s,e){const t=this,n=this[this.syncs[s]];t.options.onStart.call(t,n),n.sync((function(){e.call(t,n)}))},get_syncs(){const e=s('input[name^="lp-repair"]:checked').serializeJSON()["lp-repair"];if(!e)return!1;for(let s in e)"yes"===e[s]&&(s=s.replace(/[-]+/g,"_"),this[s]&&this.syncs.push(s));return this.syncs},get_sync(s){return this[s=s.replace(/[-]+/g,"_")]},sync_course_orders:t,sync_user_orders:c,sync_user_courses:n,sync_course_final_quiz:i,sync_remove_older_data:l,sync_calculate_course_results:o},s(document).ready((function(){!function(){const e=s("#learn-press-check-all-syncs"),t=s("#learn-press-syncs").find('[name^="lp-repair"]');e.on("click",(function(){t.prop("checked",this.checked)})),t.on("click",(function(){e.prop("checked",t.filter(":checked").length===t.length)}))}()})).on("click",".lp-button-repair",(function(){function e(e){return s("ul#learn-press-syncs").find('input[name*="'+e+'"]')}LP_Sync_Data.start({onInit(){s("ul#learn-press-syncs").children().removeClass("syncing synced"),s(".lp-button-repair").prop("disabled",!0)},onStart(s){e(s.id).closest("li").addClass("syncing")},onCompleted(s){e(s.id).closest("li").removeClass("syncing").addClass("synced")},onCompletedAll(){s("ul#learn-press-syncs").children().removeClass("syncing synced"),s(".lp-button-repair").prop("disabled",!1)}})}))}(jQuery);