first commit

This commit is contained in:
User A0264400
2026-04-01 23:20:16 +03:00
commit a766acdc90
23071 changed files with 4933189 additions and 0 deletions

View File

@@ -0,0 +1,139 @@
/**
*
* @author Webcraftic <wordpress.webraftic@gmail.com>
* @copyright (c) 04.02.2020, Webcraftic
* @version 1.0
*/
//wfCircularProgress
jQuery.fn.wfCircularProgress = function (options) {
jQuery(this).each(function () {
var creationOptions;
try {
creationOptions = JSON.parse(jQuery(this).data('wfCircularProgressOptions'));
} catch (e) { /* Ignore */
}
if (typeof creationOptions !== 'object') {
creationOptions = {};
}
var opts = jQuery.extend({}, jQuery.fn.wfCircularProgress.defaults, creationOptions, options);
var center = Math.floor(opts.diameter / 2);
var insetRadius = center - opts.strokeWidth * 2;
var circumference = 2 * insetRadius * Math.PI;
var finalOffset = -(circumference * (1 - opts.endPercent));
var initialOffset = -(circumference);
var terminatorRadius = Math.floor(opts.strokeWidth * 1.5);
var terminatorDiameter = 2 * terminatorRadius;
var finalTerminatorX = center - insetRadius * Math.cos(Math.PI * 2 * (opts.endPercent - 0.25));
var finalTerminatorY = center + insetRadius * Math.sin(Math.PI * 2 * (opts.endPercent - 0.25));
var initialTerminatorX = center - insetRadius * Math.cos(Math.PI * 2 * (opts.startPercent - 0.25));
var initialTerminatorY = center + insetRadius * Math.sin(Math.PI * 2 * (opts.startPercent - 0.25));
var terminatorSVG = "m 0,-" + terminatorRadius + " a " + terminatorRadius + "," + terminatorRadius + " 0 1 1 0," + terminatorDiameter + " a " + terminatorRadius + "," + terminatorRadius + " 0 1 1 0,-" + terminatorDiameter;
jQuery(this).data('wfCircularProgressOptions', JSON.stringify(opts));
jQuery(this).css('width', opts.diameter + 'px');
jQuery(this).css('height', opts.diameter + 'px');
var svg = jQuery(this).find('svg');
if (svg.length === 0) {
svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
jQuery(this).append(svg);
}
var inactivePath = jQuery(this).find('.wclearfy-status-circle-inactive-path');
if (inactivePath.length === 0) {
inactivePath = document.createElementNS("http://www.w3.org/2000/svg", "path");
jQuery(inactivePath).addClass('wclearfy-status-circle-inactive-path');
jQuery(svg).append(inactivePath);
}
var activePath = jQuery(this).find('.wclearfy-status-circle-active-path');
if (activePath.length === 0) {
activePath = document.createElementNS("http://www.w3.org/2000/svg", "path");
jQuery(activePath).addClass('wclearfy-status-circle-active-path');
jQuery(svg).append(activePath);
}
var terminator = jQuery(this).find('.wclearfy-status-circle-terminator');
if (terminator.length === 0) {
terminator = document.createElementNS("http://www.w3.org/2000/svg", "path");
jQuery(terminator).addClass('wclearfy-status-circle-terminator');
jQuery(svg).append(terminator);
}
var text = jQuery(this).find('.wclearfy-status-circle-text');
if (text.length === 0) {
text = jQuery('<div class="wclearfy-status-circle-text"></div>');
jQuery(this).append(text);
}
var pendingOverlay = jQuery(this).find('.wf-status-overlay-text');
if (pendingOverlay.length === 0 && opts.pendingMessage.length !== 0) {
pendingOverlay = jQuery('<div class="wclearfy-status-overlay-text"></div>');
jQuery(this).append(pendingOverlay);
}
jQuery(svg).attr('viewBox', '0 0 ' + opts.diameter + ' ' + opts.diameter);
jQuery(svg).css('display', opts.css_display);
jQuery(svg).css('width', opts.diameter + 'px');
jQuery(svg).css('height', opts.diameter + 'px');
jQuery(inactivePath).attr('d', 'M ' + center + ',' + center + ' m 0,-' + insetRadius + ' a ' + insetRadius + ',' + insetRadius + ' 0 1 1 0,' + (2 * insetRadius) + ' a ' + insetRadius + ',' + insetRadius + ' 0 1 1 0,-' + (2 * insetRadius));
jQuery(inactivePath).attr('stroke', opts.inactiveColor);
jQuery(inactivePath).attr('stroke-width', opts.strokeWidth);
jQuery(inactivePath).attr('fill-opacity', 0);
jQuery(activePath).attr('d', 'M ' + center + ',' + center + ' m 0,-' + insetRadius + ' a ' + insetRadius + ',' + insetRadius + ' 0 1 1 0,' + (2 * insetRadius) + ' a ' + insetRadius + ',' + insetRadius + ' 0 1 1 0,-' + (2 * insetRadius));
jQuery(activePath).attr('stroke', opts.color);
jQuery(activePath).attr('stroke-width', opts.strokeWidth);
jQuery(activePath).attr('stroke-dasharray', circumference + ',' + circumference);
jQuery(activePath).attr('stroke-dashoffset', initialOffset);
jQuery(activePath).attr('fill-opacity', 0);
jQuery(terminator).attr('d', 'M ' + initialTerminatorX + ',' + initialTerminatorY + ' ' + terminatorSVG);
jQuery(terminator).attr('stroke', opts.color);
jQuery(terminator).attr('stroke-width', opts.strokeWidth);
jQuery(terminator).attr('fill', '#ffffff');
jQuery(pendingOverlay).html(opts.pendingMessage);
jQuery(pendingOverlay).animate({
opacity: opts.pendingOverlay ? 1.0 : 0.0,
}, {
duration: 500,
step: function (value) {
var opacity = 1.0 - (value * 0.8);
jQuery(svg).css('opacity', opacity);
jQuery(text).css('opacity', opacity);
},
complete: function () {
jQuery(svg).css('opacity', opts.pendingOverlay ? 0.2 : 1.0);
jQuery(text).css('opacity', opts.pendingOverlay ? 0.2 : 1.0);
}
});
jQuery(activePath).animate({
"stroke-dashoffset": finalOffset + 'px'
}, {
duration: 500,
step: function (value) {
var percentage = 1 + value / circumference;
var x = center - insetRadius * Math.cos(Math.PI * 2 * (percentage - 0.25));
var y = center + insetRadius * Math.sin(Math.PI * 2 * (percentage - 0.25));
jQuery(terminator).attr('d', 'M ' + x + ',' + y + ' ' + terminatorSVG);
text.html(Math.round(percentage * 100));
},
complete: function () {
text.html(Math.round(opts.endPercent * 100));
}
});
});
};
jQuery.fn.wfCircularProgress.defaults = {
startPercent: 0,
endPercent: 1,
color: '#16bc9b',
inactiveColor: '#ececec',
strokeWidth: 3,
diameter: 100,
pendingOverlay: false,
pendingMessage: 'Note: Status will update when changes are saved',
css_display: 'block',
};

View File

@@ -0,0 +1,308 @@
/**
* General
* @author Webcraftic <wordpress.webraftic@gmail.com>
* @copyright (c) 10.09.2017, Webcraftic
* @version 1.0
*/
(function($) {
'use strict';
var general = {
init: function() {
this.qickStartAssistent();
this.importOptions();
/*$.wfactory_480.hooks.add('core/components/pre_activate', function(button) {
// Выполняем код ниже, только на страницах плагина с интерфейсом Clearfy
if( !$('#WBCR').length ) {
return false;
}
if( button.closest('.wbcr-clr-new-component').length ) {
button.closest('.wbcr-clr-new-component').remove();
}
if( button.closest('.wbcr-clearfy-fake-image-optimizer-board').length ) {
button.remove();
window.location.reload();
}
});*/
/*$.wfactory_480.hooks.add('core/components/updated', function(button, data, response) {
// Выполняем код ниже, только на страницах плагина с интерфейсом Clearfy
if( !($('#WBCR').length && $.wbcr_factory_templates_134) ) {
return false;
}
if( response.data.need_rewrite_rules && !$('.wbcr-clr-need-rewrite-rules-message').length ) {
$.wbcr_factory_templates_134.app.showNotice(response.data.need_rewrite_rules, 'warning');
}
});*/
},
qickStartAssistent: function() {
var self = this;
$('.wbcr-clearfy-button-activate-mode').click(function() {
var switcher = $(this).closest('.wbcr-clearfy-switch'),
modeName = switcher.data('mode'),
modeOptions = switcher.data('mode-options');
if( switcher.hasClass('wbcr-clearfy-loading') || switcher.hasClass('wbcr-clearfy-active') ) {
return false;
}
self.showConfirmationPopup(modeName, modeOptions);
return false;
});
$('.wbcr-clearfy-popup-button-cancel').click(function() {
self.hideConfirmationPopup();
});
/*$('.wbcr-clearfy-button-deativate-mode').click(function() {
var $this = $(this),
switcher = $(this).closest('.wbcr-clearfy-switch'),
modeName = switcher.data('mode');
if( switcher.hasClass('wbcr-clearfy-loading') ) {
return false;
}
switcher.addClass('wbcr-clearfy-loading');
self.sendRequest({
action: 'wbcr_clearfy_configurate',
mode: modeName,
cancel_mode: true
}, function(data) {
switcher.removeClass('wbcr-clearfy-loading');
if( data && data.export_options ) {
$('#wbcr-clearfy-import-export').html(data.export_options);
}
},
function() {
if( modeName != 'reset' ) {
switcher.removeClass('wbcr-clearfy-active');
}
});
return false;
});*/
$('.wbcr-clearfy-popup-button-ok').click(function() {
var $this = $(this), modeName = $this.closest('.wbcr-clearfy-confirm-popup').data('mode'),
switcher = $('div[data-mode="' + modeName + '"]', '#wbcr-clearfy-quick-mode-board'),
modeArgs = switcher.data('mode-args'),
flushRedirect = modeArgs && modeArgs.flush_redirect;
self.hideConfirmationPopup();
switcher.addClass('wbcr-clearfy-loading');
self.sendRequest({
action: 'wbcr_clearfy_configurate',
mode: modeName,
flush_redirect: flushRedirect
}, function(data) {
if( !flushRedirect ) {
switcher.removeClass('wbcr-clearfy-loading');
}
if( !data || data.error ) {
/**
* Хук выполняет проивольную функцию, после того как получен ajax ответ о том, что в
* результате конфигурации произошла ошибка Реализация системы фильтров и хуков в файле
* libs/clearfy/admin/assests/js/global.js Пример регистрации хука
* $.wbcr_factory_templates_134.hooks.add('wbcr/factory_templates_134/updated',
* function(noticeId) {});
* @param {string} modeName - имя режима конфигурации
* @param {object} data
*/
$.wbcr_factory_templates_134.hooks.run('clearfy/quick_start/configurated_error', [
modeName,
data
]);
return;
}
if( data.export_options ) {
$('#wbcr-clearfy-import-export').html(data.export_options);
}
},
function(data) {
/**
* Хук выполняет проивольную функцию, после того как получен ajax ответ об успешном выполнении
* конфигурации Реализация системы фильтров и хуков в файле
* libs/clearfy/admin/assests/js/global.js Пример регистрации хука
* $.wbcr_factory_templates_134.hooks.add('wbcr/factory_templates_134/updated', function(noticeId)
* {});
* @param {string} modeName - имя режима конфигурации
* @param {object} data
*/
$.wbcr_factory_templates_134.hooks.run('clearfy/quick_start/configurated', [modeName, data]);
if( modeName !== 'reset' ) {
switcher.addClass('wbcr-clearfy-active');
return;
}
$('.wbcr-clearfy-switch').removeClass('wbcr-clearfy-active');
});
return false;
});
},
showConfirmationPopup: function(modeName, options) {
var self = this;
if( !$('.wbcr-clearfy-layer').length ) {
var layer = $('<div></div>').addClass('wbcr-clearfy-layer');
layer.prependTo('#wpbody');
layer.fadeIn();
} else {
$('.wbcr-clearfy-layer').fadeIn();
}
var popupElem = $('.wbcr-clearfy-confirm-popup');
popupElem.data('mode', modeName);
popupElem.fadeIn();
if( modeName !== 'reset' ) {
var printOptTitles = '';
if( options ) {
for( var opt in options ) {
if( !options.hasOwnProperty(opt) ) {
continue;
}
printOptTitles += '<li>' + options[opt] + '</li>';
}
$('.wbcr-clearfy-list-options').html(printOptTitles);
popupElem.addClass('wbcr-clearfy-default-warning-options');
}
return;
}
popupElem.addClass('wbcr-clearfy-reset-warning-options');
},
hideConfirmationPopup: function() {
$('.wbcr-clearfy-layer').fadeOut(100);
var popupElem = $('.wbcr-clearfy-confirm-popup');
popupElem.fadeOut(100, function() {
popupElem.removeClass('wbcr-clearfy-default-warning-options');
popupElem.removeClass('wbcr-clearfy-reset-warning-options');
});
},
importOptions: function() {
var self = this;
$('.wbcr-clearfy-import-options-button').click(function() {
var settings = $('#wbcr-clearfy-import-export').val(),
$this = $(this);
if( !settings ) {
$.wbcr_factory_templates_134.app.showNotice('Import options is empty!', 'danger');
return false;
}
if( void 0 === wbcr_clearfy_ajax || !wbcr_clearfy_ajax.import_options_nonce ) {
$.wbcr_factory_templates_134.app.showNotice('Unknown Javascript error, most likely the wbcr_clearfy_ajax variable does not exist!', 'danger');
return false;
}
$(this).prop('disabled', true);
self.sendRequest({
action: 'wbcr-clearfy-import-settings',
_wpnonce: wbcr_clearfy_ajax.import_options_nonce,
settings: settings
}, function(response) {
$this.prop('disabled', false);
if( response.data.update_notice ) {
if( !$('.wbcr-clr-update-package').length ) {
$.wbcr_factory_templates_134.app.showNotice(response.data.update_notice);
}
} else {
if( $('.wbcr-clr-update-package').length ) {
$('.wbcr-clr-update-package').closest('.wbcr-factory-warning-notice').remove();
}
}
});
return false;
});
},
sendRequest: function(request_data, beforeValidateCallback, successCallback) {
var self = this;
if( wbcr_clearfy_ajax === undefined ) {
console.log('Undefinded wbcr_clearfy_ajax object.');
return;
}
if( typeof request_data === 'object' ) {
request_data.security = wbcr_clearfy_ajax.ajax_nonce;
}
$.ajax(ajaxurl, {
type: 'post',
dataType: 'json',
data: request_data,
success: function(data, textStatus, jqXHR) {
var noticeId;
beforeValidateCallback && beforeValidateCallback(data);
if( !data || data.error ) {
console.log(data);
if( data ) {
noticeId = $.wbcr_factory_templates_134.app.showNotice(data.error_message, 'danger');
} else {
if( void 0 !== wbcr_clearfy_ajax ) {
noticeId = $.wbcr_factory_templates_134.app.showNotice(wbcr_clearfy_ajax.i18n.unknown_error, 'danger');
}
}
setTimeout(function() {
$.wbcr_factory_templates_134.app.hideNotice(noticeId);
}, 5000);
return;
}
successCallback && successCallback(data);
if( !request_data.flush_redirect ) {
if( void 0 !== wbcr_clearfy_ajax ) {
noticeId = $.wbcr_factory_templates_134.app.showNotice(wbcr_clearfy_ajax.i18n.success_update_settings, 'success');
setTimeout(function() {
$.wbcr_factory_templates_134.app.hideNotice(noticeId);
}, 5000);
}
return;
}
window.location.href = wbcr_clearfy_ajax.flush_cache_url;
// открыть уведомление
},
error: function(xhr, ajaxOptions, thrownError) {
console.log(xhr.status);
console.log(xhr.responseText);
console.log(thrownError);
var noticeId = $.wbcr_factory_templates_134.app.showNotice('Error: [' + thrownError + '] Status: [' + xhr.status + '] Error massage: [' + xhr.responseText + ']', 'danger');
}
});
}
};
$(document).ready(function() {
general.init();
});
})(jQuery);

View File

@@ -0,0 +1,286 @@
/**
* General
* @author Webcraftic <wordpress.webraftic@gmail.com>
* @copyright (c) 10.09.2017, Webcraftic
* @version 1.0
*/
(function($) {
'use strict';
var general = {
init: function() {
this.qickStartAssistent();
this.importOptions();
/*$.wfactory_000.hooks.add('core/components/pre_activate', function(button) {
// Выполняем код ниже, только на страницах плагина с интерфейсом Clearfy
if( !$('#WBCR').length ) {
return false;
}
if( button.closest('.wbcr-clr-new-component').length ) {
button.closest('.wbcr-clr-new-component').remove();
}
if( button.closest('.wbcr-clearfy-fake-image-optimizer-board').length ) {
button.remove();
window.location.reload();
}
});*/
/*$.wfactory_000.hooks.add('core/components/updated', function(button, data, response) {
// Выполняем код ниже, только на страницах плагина с интерфейсом Clearfy
if( !($('#WBCR').length && $.wbcr_factory_templates_000) ) {
return false;
}
if( response.data.need_rewrite_rules && !$('.wbcr-clr-need-rewrite-rules-message').length ) {
$.wbcr_factory_templates_000.app.showNotice(response.data.need_rewrite_rules, 'warning');
}
});*/
},
qickStartAssistent: function() {
var self = this;
$('.wbcr-clearfy-button-activate-mode').click(function() {
var modeName = $(this).data('mode'),
modeOptions = $(this).data('mode-options');
if( $(this).hasClass('wbcr-clearfy-loading') || $(this).hasClass('wbcr-clearfy-active') ) {
return false;
}
self.showConfirmationPopup(modeName, modeOptions);
return false;
});
$('.wbcr-clearfy-popup-button-cancel').click(function() {
self.hideConfirmationPopup();
});
$('.wbcr-clearfy-popup-button-ok').click(function() {
var $this = $(this), modeName = $this.closest('.wbcr-clearfy-confirm-popup').data('mode'),
switcher = $('div[data-mode="' + modeName + '"]', '#wbcr-clearfy-quick-mode-board'),
modeArgs = switcher.data('mode-args'),
flushRedirect = modeArgs && modeArgs.flush_redirect;
self.hideConfirmationPopup();
switcher.addClass('wbcr-clearfy-loading');
self.sendRequest({
action: 'wbcr_clearfy_configurate',
mode: modeName,
flush_redirect: flushRedirect
}, function(data) {
if( !flushRedirect ) {
switcher.removeClass('wbcr-clearfy-loading');
}
if( !data || data.error ) {
/**
* Хук выполняет проивольную функцию, после того как получен ajax ответ о том, что в
* результате конфигурации произошла ошибка Реализация системы фильтров и хуков в файле
* libs/clearfy/admin/assests/js/global.js Пример регистрации хука
* $.wbcr_factory_templates_000.hooks.add('wbcr/factory_templates_000/updated',
* function(noticeId) {});
* @param {string} modeName - имя режима конфигурации
* @param {object} data
*/
$.wbcr_factory_templates_000.hooks.run('clearfy/quick_start/configurated_error', [
modeName,
data
]);
return;
}
if( data.export_options ) {
$('#wbcr-clearfy-import-export').html(data.export_options);
}
},
function(data) {
/**
* Хук выполняет проивольную функцию, после того как получен ajax ответ об успешном выполнении
* конфигурации Реализация системы фильтров и хуков в файле
* libs/clearfy/admin/assests/js/global.js Пример регистрации хука
* $.wbcr_factory_templates_000.hooks.add('wbcr/factory_templates_000/updated', function(noticeId)
* {});
* @param {string} modeName - имя режима конфигурации
* @param {object} data
*/
$.wbcr_factory_templates_000.hooks.run('clearfy/quick_start/configurated', [modeName, data]);
if( modeName !== 'reset' ) {
switcher.addClass('wbcr-clearfy-active');
return;
}
$('.wbcr-clearfy-switch').removeClass('wbcr-clearfy-active');
});
return false;
});
},
showConfirmationPopup: function(modeName, options) {
var self = this;
if( !$('.wbcr-clearfy-layer').length ) {
var layer = $('<div></div>').addClass('wbcr-clearfy-layer');
layer.prependTo('#wpbody');
layer.fadeIn();
} else {
$('.wbcr-clearfy-layer').fadeIn();
}
var popupElem = $('.wbcr-clearfy-confirm-popup');
popupElem.data('mode', modeName);
popupElem.fadeIn();
if( modeName !== 'reset' ) {
var printOptTitles = '';
if( options ) {
for( var opt in options ) {
if( !options.hasOwnProperty(opt) ) {
continue;
}
printOptTitles += '<li>' + options[opt] + '</li>';
}
$('.wbcr-clearfy-list-options').html(printOptTitles);
popupElem.addClass('wbcr-clearfy-default-warning-options');
}
return;
}
popupElem.addClass('wbcr-clearfy-reset-warning-options');
},
hideConfirmationPopup: function() {
$('.wbcr-clearfy-layer').fadeOut(100);
var popupElem = $('.wbcr-clearfy-confirm-popup');
popupElem.fadeOut(100, function() {
popupElem.removeClass('wbcr-clearfy-default-warning-options');
popupElem.removeClass('wbcr-clearfy-reset-warning-options');
});
},
importOptions: function() {
var self = this;
$('.wbcr-clearfy-import-options-button').click(function() {
var settings = $('#wbcr-clearfy-import-export').val(),
$this = $(this);
if( !settings ) {
$.wbcr_factory_templates_000.app.showNotice('Import options is empty!', 'danger');
return false;
}
if( void 0 === wbcr_clearfy_ajax || !wbcr_clearfy_ajax.import_options_nonce ) {
$.wbcr_factory_templates_000.app.showNotice('Unknown Javascript error, most likely the wbcr_clearfy_ajax variable does not exist!', 'danger');
return false;
}
$(this).prop('disabled', true);
self.sendRequest({
action: 'wbcr-clearfy-import-settings',
_wpnonce: wbcr_clearfy_ajax.import_options_nonce,
settings: settings
}, function(response) {
$this.prop('disabled', false);
if( response.data.update_notice ) {
if( !$('.wbcr-clr-update-package').length ) {
$.wbcr_factory_templates_000.app.showNotice(response.data.update_notice);
}
} else {
if( $('.wbcr-clr-update-package').length ) {
$('.wbcr-clr-update-package').closest('.wbcr-factory-warning-notice').remove();
}
}
});
return false;
});
},
sendRequest: function(request_data, beforeValidateCallback, successCallback) {
var self = this;
if( wbcr_clearfy_ajax === undefined ) {
console.log('Undefinded wbcr_clearfy_ajax object.');
return;
}
if( typeof request_data === 'object' ) {
request_data.security = wbcr_clearfy_ajax.ajax_nonce;
}
$.ajax(ajaxurl, {
type: 'post',
dataType: 'json',
data: request_data,
success: function(data, textStatus, jqXHR) {
var noticeId;
beforeValidateCallback && beforeValidateCallback(data);
if( !data || data.error ) {
console.log(data);
if( data ) {
noticeId = $.wbcr_factory_templates_000.app.showNotice(data.error_message, 'danger');
} else {
if( void 0 !== wbcr_clearfy_ajax ) {
noticeId = $.wbcr_factory_templates_000.app.showNotice(wbcr_clearfy_ajax.i18n.unknown_error, 'danger');
}
}
setTimeout(function() {
$.wbcr_factory_templates_000.app.hideNotice(noticeId);
}, 5000);
return;
}
successCallback && successCallback(data);
if( !request_data.flush_redirect ) {
if( void 0 !== wbcr_clearfy_ajax ) {
noticeId = $.wbcr_factory_templates_000.app.showNotice(wbcr_clearfy_ajax.i18n.success_update_settings, 'success');
setTimeout(function() {
$.wbcr_factory_templates_000.app.hideNotice(noticeId);
}, 5000);
}
return;
}
window.location.href = wbcr_clearfy_ajax.flush_cache_url;
// открыть уведомление
},
error: function(xhr, ajaxOptions, thrownError) {
console.log(xhr.status);
console.log(xhr.responseText);
console.log(thrownError);
var noticeId = $.wbcr_factory_templates_000.app.showNotice('Error: [' + thrownError + '] Status: [' + xhr.status + '] Error massage: [' + xhr.responseText + ']', 'danger');
}
});
}
};
$(document).ready(function() {
general.init();
});
})(jQuery);

View File

@@ -0,0 +1,148 @@
/**
* Setup master
* @author Webcraftic <wordpress.webraftic@gmail.com>
* @copyright (c) 12.08.2020, Webcraftic
* @version 1.0
*/
(function($) {
'use strict';
window.wclearfy_fetch_google_pagespeed_audit = function(nonce, flush_cache) {
let data = {
action: 'wclearfy-google-pagespeed-audit-results',
flush_cache: flush_cache,
_wpnonce: nonce,
};
$.ajax(ajaxurl, {
type: 'post',
dataType: 'json',
data: data,
success: function(response) {
console.log(response);
if( !response || !response.success ) {
if( response.data ) {
console.log(response.data.error);
$('.wclearfy-gogle-page-speed-audit__errors').text(response.data.error).show();
} else {
console.log(response);
}
return;
}
//$('.wclearfy-quick-start__google-page-speed-audit').show();
if( response.data ) {
if( response.data.before ) {
if( !response.data.before.fake ) {
$('.wclearfy-quick-start__g-audit-overlay', '#wclearfy-quick-start__g-audit-before').hide();
$('.wclearfy-quick-start__g-audit-preloader', '#wclearfy-quick-start__g-audit-before').hide();
} //else {
//$('#wclearfy-quick-start__g-audit-warging-text-1').show();
//$('.wclearfy-quick-start__g-audit-preloader', '#wclearfy-quick-start__g-audit-after').hide();
//}
$('.wclearfy-quick-start__g-audit-desktop-score-circle', '#wclearfy-quick-start__g-audit-before').wfCircularProgress({
endPercent: (response.data.before.desktop.performance_score / 100),
color: get_color(response.data.before.desktop.performance_score),
inactiveColor: '#ececec',
strokeWidth: 3,
diameter: 100,
});
$('.wclearfy-quick-start__g-audit-mobile-score-circle', '#wclearfy-quick-start__g-audit-before').wfCircularProgress({
endPercent: (response.data.before.mobile.performance_score / 100),
color: get_color(response.data.before.mobile.performance_score),
inactiveColor: '#ececec',
strokeWidth: 3,
diameter: 100,
});
// DESKTOP
$('.wclearfy-quick-start__g-audit-statistic--desktop-first-contentful-paint', '#wclearfy-quick-start__g-audit-before')
.text(response.data.before.desktop.performance_score);
$('.wclearfy-quick-start__g-audit-statistic--desktop-speed-index', '#wclearfy-quick-start__g-audit-before')
.text(response.data.before.desktop.speed_index);
$('.wclearfy-quick-start__g-audit-statistic--desktop-interactive', '#wclearfy-quick-start__g-audit-before')
.text(response.data.before.desktop.interactive);
// MOBILE
$('.wclearfy-quick-start__g-audit-statistic--mobile-first-contentful-paint', '#wclearfy-quick-start__g-audit-before')
.text(response.data.before.mobile.performance_score);
$('.wclearfy-quick-start__g-audit-statistic--mobile-speed-index', '#wclearfy-quick-start__g-audit-before')
.text(response.data.before.mobile.speed_index);
$('.wclearfy-quick-start__g-audit-statistic--mobile-interactive', '#wclearfy-quick-start__g-audit-before')
.text(response.data.before.mobile.interactive);
}
if( response.data.after ) {
if( !response.data.after.fake ) {
$('.wclearfy-quick-start__g-audit-overlay', '#wclearfy-quick-start__g-audit-after').hide();
$('.wclearfy-quick-start__g-audit-preloader', '#wclearfy-quick-start__g-audit-after').hide();
} //else {
//$('#wclearfy-quick-start__g-audit-warging-text-2').show();
//$('.wclearfy-quick-start__g-audit-preloader', '#wclearfy-quick-start__g-audit-after').hide();
//}
$('.wclearfy-quick-start__g-audit-desktop-score-circle', '#wclearfy-quick-start__g-audit-after').wfCircularProgress({
endPercent: (response.data.after.desktop.performance_score / 100),
color: get_color(response.data.after.desktop.performance_score),
inactiveColor: '#ececec',
strokeWidth: 3,
diameter: 100,
});
$('.wclearfy-quick-start__g-audit-mobile-score-circle', '#wclearfy-quick-start__g-audit-after').wfCircularProgress({
endPercent: (response.data.after.mobile.performance_score / 100),
color: get_color(response.data.after.mobile.performance_score),
inactiveColor: '#ececec',
strokeWidth: 3,
diameter: 100,
});
// DESKTOP
$('.wclearfy-quick-start__g-audit-statistic--desktop-first-contentful-paint', '#wclearfy-quick-start__g-audit-after')
.text(response.data.after.desktop.performance_score);
$('.wclearfy-quick-start__g-audit-statistic--desktop-speed-index', '#wclearfy-quick-start__g-audit-after')
.text(response.data.after.desktop.speed_index);
$('.wclearfy-quick-start__g-audit-statistic--desktop-interactive', '#wclearfy-quick-start__g-audit-after')
.text(response.data.after.desktop.interactive);
// MOBILE
$('.wclearfy-quick-start__g-audit-statistic--mobile-first-contentful-paint', '#wclearfy-quick-start__g-audit-after')
.text(response.data.after.mobile.performance_score);
$('.wclearfy-quick-start__g-audit-statistic--mobile-speed-index', '#wclearfy-quick-start__g-audit-after')
.text(response.data.after.mobile.speed_index);
$('.wclearfy-quick-start__g-audit-statistic--mobile-interactive', '#wclearfy-quick-start__g-audit-after')
.text(response.data.after.mobile.interactive);
}
}
},
error: function(xhr, ajaxOptions, thrownError) {
$('.wclearfy-gogle-page-speed-audit__preloader').hide();
console.log(xhr.status);
console.log(xhr.responseText);
console.log(thrownError);
$('.wclearfy-gogle-page-speed-audit__errors').text('Status: ' + xhr.status + 'Error:' + xhr.responseText).show();
}
});
function get_color(score) {
let desktopColor;
if( score > 70 ) {
desktopColor = '#a8d207';
} else if( score > 40 ) {
desktopColor = '#f18727';
} else {
desktopColor = '#cd2727';
}
return desktopColor;
}
}
})(jQuery);

View File

@@ -0,0 +1,2 @@
<?php
// Silence is golden.

View File

@@ -0,0 +1,94 @@
/**
* Этот файл содержит скрипт исполняелся во время процедур с формой лицензирования.
* Его основная роль отправка ajax запросов на проверку, активацию, деактивацию лицензии
* и вывод уведомлений об ошибка или успешно выполнении проверок.
*
* @author Webcraftic <wordpress.webraftic@gmail.com>
* @copyright (c) 05.10.2018, Webcraftic
* @version 1.1
* @since 1.4.0
*/
jQuery(function($) {
var allNotices = [];
$(document).on('click', '.wcl-control-btn', function() {
// Скрываем все открытые этим событием уведомления
// Глобальные уведомления не трогаем
for( i = 0; i < allNotices.length; i++ ) {
$.wbcr_factory_templates_134.app.hideNotice(allNotices[i]);
}
$('.wcl-control-btn').hide();
var wrapper = $('#wcl-license-wrapper'),
loader = wrapper.data('loader');
$(this).after('<img class="wcl-loader" src="' + loader + '">');
var data = {
action: 'wbcr-clearfy-check-license',
_wpnonce: $('#_wpnonce').val(),
license_action: $(this).data('action'),
licensekey: ''
};
if( $(this).data('action') == 'activate' ) {
data.licensekey = $('#license-key').val();
}
$.ajax(ajaxurl, {
type: 'post',
dataType: 'json',
data: data,
success: function(response) {
var noticeId;
if( !response || !response.success ) {
$('.wcl-control-btn').show();
$('.wcl-loader').remove();
if( response.data ) {
console.log(response.data.error_message);
noticeId = $.wbcr_factory_templates_134.app.showNotice('Error: [' + response.data.error_message + ']', 'danger');
allNotices.push(noticeId);
} else {
console.log(response);
}
return;
}
if( response.data && response.data.message ) {
noticeId = $.wbcr_factory_templates_134.app.showNotice(response.data.message, 'success');
allNotices.push(noticeId);
// todo: доработать генерацию формы, вместо перезагрузки страницы
window.location.reload();
}
},
error: function(xhr, ajaxOptions, thrownError) {
$('.wcl-control-btn').show();
$('.wcl-loader').remove();
console.log(xhr.status);
console.log(xhr.responseText);
console.log(thrownError);
var noticeId = $.wbcr_factory_templates_134.app.showNotice('Error: [' + thrownError + '] Status: [' + xhr.status + '] Error massage: [' + xhr.responseText + ']', 'danger');
allNotices.push(noticeId);
}
});
return false;
});
});

View File

@@ -0,0 +1,95 @@
/**
* Setup master
* @author Webcraftic <wordpress.webraftic@gmail.com>
* @copyright (c) 12.08.2020, Webcraftic
* @version 1.0
*/
(function($) {
'use strict';
window.wclearfy_fetch_google_pagespeed_audit = function(nonce, flush_cache) {
let data = {
action: 'wclearfy-fetch-google-pagespeed-audit',
flush_cache: flush_cache,
_wpnonce: nonce,
};
$.ajax(ajaxurl, {
type: 'post',
dataType: 'json',
data: data,
success: function(response) {
console.log(response);
$('.wclearfy-gogle-page-speed-audit__preloader').hide();
if( !response || !response.success ) {
if( response.data ) {
console.log(response.data.error);
$('.wclearfy-gogle-page-speed-audit__errors').text(response.data.error).show();
} else {
console.log(response);
}
return;
}
$('.wclearfy-gogle-page-speed-audit').show();
if( response.data && response.data.desktop ) {
$('#wclearfy-desktop-score__circle').wfCircularProgress({
endPercent: (response.data.desktop.performance_score / 100),
color: get_color(response.data.desktop.performance_score),
inactiveColor: '#ececec',
strokeWidth: 5,
diameter: 150,
});
$('#wclearfy-statistic__desktop-first-contentful-paint').text(response.data.desktop.performance_score);
$('#wclearfy-statistic__desktop-speed-index').text(response.data.desktop.speed_index);
$('#wclearfy-statistic__desktop-interactive').text(response.data.desktop.interactive);
}
if( response.data && response.data.mobile ) {
$('#wclearfy-mobile-score__circle').wfCircularProgress({
endPercent: (response.data.mobile.performance_score / 100),
color: get_color(response.data.mobile.performance_score),
inactiveColor: '#ececec',
strokeWidth: 5,
diameter: 150,
});
$('#wclearfy-statistic__mobile-first-contentful-paint').text(response.data.desktop.performance_score);
$('#wclearfy-statistic__mobile-speed-index').text(response.data.desktop.speed_index);
$('#wclearfy-statistic__mobile-interactive').text(response.data.desktop.interactive);
}
},
error: function(xhr, ajaxOptions, thrownError) {
$('.wclearfy-gogle-page-speed-audit__preloader').hide();
console.log(xhr.status);
console.log(xhr.responseText);
console.log(thrownError);
$('.wclearfy-gogle-page-speed-audit__errors').text('Status: ' + xhr.status + 'Error:' + xhr.responseText).show();
}
});
function get_color(score) {
let desktopColor;
if( score > 70 ) {
desktopColor = '#a8d207';
} else if( score > 40 ) {
desktopColor = '#f18727';
} else {
desktopColor = '#cd2727';
}
return desktopColor;
}
}
})(jQuery);

View File

@@ -0,0 +1,37 @@
jQuery(function($) {
function subscribeWidget() {
var form = $('#wbcr-factory-subscribe-widget-form');
form.submit(function(ev) {
ev.preventDefault();
var agree = form.find('[name=agree_terms]:checked');
if( agree.length === 0 ) {
return;
}
$.ajax({
method: "POST",
url: "https://clearfy.pro/wp-json/mailerlite/v1/subscribe/",
data: {email: $('.wbcr-factory-subscribe-widget-field').val()},
success: function(data) {
if( !data.message ) {
if( data.subscribed ) {
$(".wbcr-factory-subscribe-widget-msg.success").show();
} else {
$(".wbcr-factory-subscribe-widget-msg.success2").show();
}
} else {
alert('Something went wrong :(');
console.error(data.message);
}
},
error: function(error) {
console.log(error);
}
});
});
}
subscribeWidget();
});