| Server IP : 35.201.19.92 / Your IP : 216.73.216.212 Web Server : nginx System : Linux pod-200961 6.8.0-1055-gke #61-Ubuntu SMP Tue May 26 22:57:42 UTC 2026 x86_64 User : fpm200098 ( 200098) PHP Version : 8.2.34 Disable Function : apache_child_terminate,apache_get_modules,apache_get_version,apache_getenv,apache_note,apache_setenv,disk_free_space,disk_total_space,diskfreespace,dl,exec,fastcgi_finish_request,link,opcache_compile_file,opcache_get_configuration,opcache_invalidate,opcache_is_script_cached,opcache_reset,passthru,pclose,pcntl_exec,popen,posix_getpid,posix_getppid,posix_getpwuid,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_uname,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,realpath_cache_get,shell_exec,show_source,symlink,system MySQL : OFF | cURL : ON | WGET : OFF | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /nas/content/live/questfamilyday/wp-content/mu-plugins/wpe-cache-plugin/js/ |
Upload File : |
import LastClearedText from './components/LastClearedText';
import LastErrorText from './components/LastErrorText';
import ErrorToast from './components/ErrorToast';
import ClearAllCacheBtn from './components/ClearAllCacheBtn';
import ClearAllCacheIcon from './components/ClearAllCacheIcon';
import CachePluginApiService from './services/CachePluginApiService';
import DateTime from './utils/DateTime';
import CachePluginWindowModifier from './services/CachePluginWindowModifier';
import CacheTimesFormReferField from './components/CacheTimesFormReferField';
import QueryParameters from './services/CachePluginQueryParams';
(function ($) {
'use strict';
$(document).ready(function () {
const removeNotificationParamFromPathname = () => {
const windowModifier = new CachePluginWindowModifier(window);
const updatedWindowPath =
windowModifier.stripQueryParamFromPathname(
QueryParameters.notification
);
windowModifier.replaceWindowState(updatedWindowPath);
const cacheTimesFormReferField = new CacheTimesFormReferField();
cacheTimesFormReferField.replaceRefer(updatedWindowPath);
};
const getPreviousCacheClearResult = (
mostRecentRateLimitedDate,
lastClearedAt
) => {
return mostRecentRateLimitedDate.getTime() ===
new Date(Date.parse(lastClearedAt)).getTime()
? 'success'
: 'error';
};
const updateUIWithPreviousCacheClearResult = (
previousCacheClearResult
) => {
if (previousCacheClearResult === 'error') {
clearCacheIcon.setErrorIcon();
lastErrorText.setLastErrorText(mostRecentRateLimitedDate);
} else {
clearCacheIcon.setSuccessIcon();
lastClearedText.setLastClearedText(mostRecentRateLimitedDate);
}
};
const rootPath = wpApiSettings.root; // this root path contains the base api path for the REST Routes
const nonce = wpApiSettings.nonce; // this is the nonce field
const clearAllCachesPath = `${rootPath}${WPECachePlugin.clear_all_caches_path}`;
const lastClearedAt = WPECachePlugin?.clear_all_cache_last_cleared;
const lastErroredAt =
WPECachePlugin?.clear_all_cache_last_cleared_error;
const cachePluginApiService = new CachePluginApiService(nonce, {
clearAllCachesPath,
});
const lastErrorText = new LastErrorText();
const errorToast = new ErrorToast();
const lastClearedText = new LastClearedText();
const clearAllCacheBtn = new ClearAllCacheBtn(cachePluginApiService);
const clearCacheIcon = new ClearAllCacheIcon();
removeNotificationParamFromPathname();
const mostRecentRateLimitedDate = DateTime.mostRecentRateLimitedDate(
lastErroredAt,
lastClearedAt
);
if (mostRecentRateLimitedDate) {
updateUIWithPreviousCacheClearResult(
getPreviousCacheClearResult(
mostRecentRateLimitedDate,
lastClearedAt
)
);
}
clearAllCacheBtn.attachSubmit({
onSuccess: (dateTime) => {
lastErrorText.hide();
lastClearedText.setLastClearedText(dateTime);
clearCacheIcon.setSuccessIcon();
errorToast.hideToast();
},
onError: (errorTime) => {
lastClearedText.hide();
lastErrorText.setLastErrorText(errorTime);
clearCacheIcon.setErrorIcon();
errorToast.showToast();
},
});
});
})(jQuery);