| 1 |
import getStepsUpgradeStatus from './tools/database/upgrade'; |
| 2 |
import createIndexes from './tools/database/create_indexs'; |
| 3 |
import reUpgradeDB from './tools/database/re-upgrade-db'; |
| 4 |
import cleanDatabases from './tools/database/clean_database'; |
| 5 |
|
| 6 |
( function( $ ) { |
| 7 |
const $doc = $( document ); |
| 8 |
|
| 9 |
const clearHardCache = function clearHardCache( e ) { |
| 10 |
e.preventDefault(); |
| 11 |
const $button = $( this ); |
| 12 |
|
| 13 |
if ( $button.hasClass( 'disabled' ) ) { |
| 14 |
return; |
| 15 |
} |
| 16 |
|
| 17 |
$button.addClass( 'disabled' ).html( $button.data( 'cleaning-text' ) ); |
| 18 |
$.ajax( { |
| 19 |
url: $button.attr( 'href' ), |
| 20 |
data: {}, |
| 21 |
success( response ) { |
| 22 |
$button.removeClass( 'disabled' ).html( $button.data( 'text' ) ); |
| 23 |
}, |
| 24 |
error() { |
| 25 |
$button.removeClass( 'disabled' ).html( $button.data( 'text' ) ); |
| 26 |
}, |
| 27 |
} ); |
| 28 |
}; |
| 29 |
|
| 30 |
const toggleHardCache = function toggleHardCache() { |
| 31 |
$.ajax( { |
| 32 |
url: 'admin.php?page=lp-toggle-hard-cache-option', |
| 33 |
data: { v: this.checked ? 'yes' : 'no' }, |
| 34 |
success( response ) { |
| 35 |
}, |
| 36 |
error() { |
| 37 |
}, |
| 38 |
} ); |
| 39 |
}; |
| 40 |
|
| 41 |
$( function() { |
| 42 |
getStepsUpgradeStatus(); |
| 43 |
createIndexes(); |
| 44 |
reUpgradeDB(); |
| 45 |
cleanDatabases(); |
| 46 |
$doc.on( 'click', '#learn-press-clear-cache', clearHardCache ) |
| 47 |
.on( 'click', 'input[name="enable_hard_cache"]', toggleHardCache ); |
| 48 |
} ); |
| 49 |
}( jQuery ) ); |
| 50 |
|