This commit is contained in:
User A0264400
2026-04-19 17:13:54 +03:00
parent c19df05b57
commit 75fa754dba
192 changed files with 39819 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
(function() {
tinymce.create('tinymce.plugins.Wpfc', {
wpfcNotHTML : '',
url: '',
init : function(ed, url) {
var self = this;
self.setUrl(url);
self.setWpfcNotHTML();
ed.addButton('wpfc', {
title : 'Block caching for this page',
cmd : 'wpfc',
image : self.url + "/icon.png"
});
ed.addCommand('wpfc', function() {
ed.execCommand('mceInsertContent', 0, self.wpfcNotHTML);
});
self._handleWpfcNOT(ed, url);
},
setUrl: function(url){
this.url = url.replace("../js","../images");
},
setWpfcNotHTML: function(){
this.wpfcNotHTML = '<img src="' + this.url + "/tinymce-wpfcnot.jpg" + '" class="mce-wp-wpfcnot" style="margin-right:95%;" />';
},
_handleWpfcNOT : function(ed, url) {
var self = this;
ed.onPostRender.add(function() {
if (ed.theme.onResolveName) {
ed.theme.onResolveName.add(function(th, o) {
if (o.node.nodeName == 'IMG') {
if ( ed.dom.hasClass(o.node, 'mce-wp-wpfcnot') ){
o.name = 'wpfcnot';
}
}
});
}
});
ed.onBeforeSetContent.add(function(ed, o) {
if ( o.content ) {
o.content = o.content.replace(/<\!--\s*\[wpfcNOT\]\s*-->/, self.wpfcNotHTML);
}
});
ed.onPostProcess.add(function(ed, o) {
if (o.get){
o.content = o.content.replace(/<img[^>]+>/g, function(im) {
if (im.indexOf('class="mce-wp-wpfcnot') !== -1) {
im = '<!--[wpfcNOT]-->';
}
return im;
});
}
});
}
});
tinymce.PluginManager.add( 'wpfc', tinymce.plugins.Wpfc );
})();

View File

@@ -0,0 +1,435 @@
var WpfcCDN = {
values: {"name" : "", "cdnurl" : "", "originurl" : "", "file_types" : "", "keywords" : "", "excludekeywords" : ""},
id : "",
nonce: "",
template_url : "",
content : "",
interval : false,
init: function(obj){
this.set_params(obj);
this.open_wizard();
},
check_conditions: function(action, current_page_number){
var self = this;
if(action == "next"){
if(current_page_number == 2){
self.check_url_exist();
}else{
return true;
}
}
},
set_params: function(obj){
this.id = obj.id;
this.nonce = obj.nonce;
this.template_url = obj.template_main_url + "/" + this.id + ".php";
if(obj.values){
this.values = obj.values;
}
},
open_wizard: function(){
var self = this;
if(jQuery("#wpfc-modal-" + self.id).length == 0){
self.load_template(function(){
self.fill_integration_fields();
self.set_buttons_action();
self.click_event_add_new_keyword_button();
self.add_new_keyword_keypress();
if(self.id == "other" || self.id == "cloudflare"){
self.show_page("next");
self.hide_button("back");
}
});
}
},
insert_keywords: function(modal, classname, keywords){
var self = this;
if(keywords){
jQuery.each(keywords.split(","), function( index, value ) {
jQuery('<li class="' + classname + '"><a class="keyword-label">' + value + '</a></li>').insertBefore(modal.find(".wpfc-add-new-keyword").closest("." + classname)).click(function(){
jQuery(this).remove();
});
});
}
},
fill_integration_fields: function(){
var self = this;
var modal;
jQuery(self.values).each(function(i, e){
modal = jQuery("#wpfc-wizard-" + e.id);
modal.find("input#cdn-url").val(e.cdnurl);
modal.find("select#cdn-url").val(e.cdnurl);
modal.find("#origin-url").val(e.originurl);
self.insert_keywords(modal, "keyword-item", e.keywords);
self.insert_keywords(modal, "keyword-item-exclude", e.excludekeywords);
if(e.file_types){
modal.find(".wpfc-checkbox-list input[type='checkbox']").attr("checked", false);
jQuery.each(e.file_types.split(","), function( index, value ) {
modal.find("#file-type-" + value).attr("checked", true);
});
}
});
},
add_new_keyword_keypress: function(){
jQuery(".wpfc-textbox-con .fixed-search input").keypress(function(e){
if(e.keyCode == 13){
var keyword = jQuery(e.target).val();
var keyword_type_class = jQuery(e.target).closest("li[class*='keyword-item']").attr("class");
jQuery(".wpfc-textbox-con").hide();
jQuery(e.target).val("");
jQuery('<li class="' + keyword_type_class + '"><a class="keyword-label">' + keyword + '</a></li>').insertBefore(jQuery(e.target).closest("." + keyword_type_class)).click(function(){
jQuery(this).remove();
});
}
});
},
click_event_add_new_keyword_button: function(){
jQuery(".wpfc-add-new-keyword").click(function(){
jQuery(this).next(".wpfc-textbox-con").show();
jQuery(this).next(".wpfc-textbox-con").find(".fixed-search input").focus();
});
},
set_buttons_action: function(){
var self = this;
var action = "";
var current_page, next_page, current_page_number;
var modal = jQuery("#wpfc-modal-" + self.id);
self.buttons();
modal.find("button.wpfc-dialog-buttons").click(function(e){
action = modal.find(e.currentTarget).attr("action");
current_page_number = modal.find(".wpfc-cdn-pages-container div.wiz-cont:visible").attr("wpfc-cdn-page");
if(action == "next"){
if(self.check_conditions("next", current_page_number)){
self.show_page("next");
}
}else if(action == "back"){
self.show_page("back");
}else if(action == "finish"){
self.save_integration();
}else if(action == "close"){
Wpfc_Dialog.remove();
}else if(action == "remove"){
self.remove_integration();
}else if(action == "pause"){
self.pause_integration();
}else if(action == "start"){
self.start_integration();
}
});
},
start_integration: function(){
var self = this;
var modal = jQuery("#wpfc-modal-" + self.id);
self.disable_button("start");
jQuery.ajax({
type: 'POST',
dataType: "json",
url: ajaxurl,
data : {"action": "wpfc_start_cdn_integration", "id" : self.id, "nonce" : self.nonce},
success: function(res){
self.show_button("pause");
self.enable_button("pause");
self.hide_button("start");
jQuery("div[wpfc-cdn-name='" + self.id + "']").find("div.meta").removeClass("pause");
},
error: function(e) {
self.enable_button("start");
alert("unknown error");
}
});
},
pause_integration: function(){
var self = this;
var modal = jQuery("#wpfc-modal-" + self.id);
self.disable_button("pause");
jQuery.ajax({
type: 'POST',
dataType: "json",
url: ajaxurl,
data : {"action": "wpfc_pause_cdn_integration", "id" : self.id, "nonce" : self.nonce},
success: function(res){
self.show_button("start");
self.enable_button("start");
self.hide_button("pause");
jQuery("div[wpfc-cdn-name='" + self.id + "']").find("div.meta").addClass("pause");
},
error: function(e) {
self.enable_button("pause");
alert("unknown error");
}
});
},
remove_integration: function(){
var self = this;
var modal = jQuery("#wpfc-modal-" + self.id);
self.disable_button("remove");
jQuery.ajax({
type: 'POST',
dataType: "json",
url: ajaxurl,
data : {"action": "wpfc_remove_cdn_integration", "id" : self.id, "nonce" : self.nonce},
success: function(res){
self.values = jQuery.grep(self.values, function (e, i) {
if(e.id == self.id){
return false;
}
return true;
});
self.enable_button("remove");
jQuery("div.tab7 div[wpfc-cdn-name='" + self.id + "']").find("div.meta").removeClass("isConnected");
Wpfc_Dialog.remove();
console.log(res);
},
error: function(e) {
self.enable_button("remove");
alert("unknown error");
}
});
},
save_integration: function(){
var self = this;
var modal = jQuery("#wpfc-modal-" + self.id);
self.buttons();
self.values = {};
self.values.id = self.id;
self.disable_button("finish");
if(modal.find("input#cdn-url").length == 1){
self.values.cdnurl = modal.find("input#cdn-url").val();
}else if(modal.find("select#cdn-url").length == 1){
self.values.cdnurl = modal.find("select#cdn-url").val();
}
self.values.originurl = modal.find("input#origin-url").val();
self.values.file_types = modal.find(".wpfc-checkbox-list input[type='checkbox']:checked").map(function(){return this.value;}).get().join(",");
self.values.keywords = modal.find(".keyword-item-list li.keyword-item a.keyword-label").map(function(){return this.text;}).get().join(",");
self.values.excludekeywords = modal.find(".keyword-item-list li.keyword-item-exclude a.keyword-label").map(function(){return this.text;}).get().join(",");
jQuery.ajax({
type: 'POST',
dataType: "json",
url: ajaxurl,
data : {"action": "wpfc_save_cdn_integration", "nonce" : self.nonce, "values" : self.values, "file_types" : self.values.file_types, "keywords" : self.values.keywords, "excludekeywords" : self.values.excludekeywords},
success: function(res){
jQuery("div[wpfc-cdn-name='" + self.id + "']").find("div.meta").addClass("isConnected");
self.enable_button("finish");
self.show_page("next");
console.log(res);
},
error: function(e) {
self.enable_button("finish");
alert("unknown error");
}
});
},
enable_button: function(button_type){
clearInterval(this.interval);
let self = this;
let modal = jQuery("#wpfc-modal-" + self.id);
let button = modal.find(".wpfc-dialog-buttons[action='" + button_type + "']");
button.attr("disabled", false);
button.text(button.text().replace(/\.+$/, ""));
},
disable_button: function(button_type){
let self = this;
let modal = jQuery("#wpfc-modal-" + self.id);
let button = modal.find(".wpfc-dialog-buttons[action='" + button_type + "']");
let text = button.text();
let dot = 0;
button.attr("disabled", true);
button.text(text + ".");
self.interval = setInterval(function(){
text = button.text();
dot = text.match(/\./g);
console.log(dot);
console.log(button);
if(dot){
if(dot.length < 3){
button.text(text + ".");
}else{
button.text(text.replace(/\.+$/, ""));
}
}else{
button.text(text + ".");
}
}, 300);
},
check_url_exist: function(){
var self = this;
var modal = jQuery("#wpfc-modal-" + self.id);
var cdn_url = modal.find("#cdn-url").val();
var origin_url = modal.find("#origin-url").val();
if(!cdn_url || !origin_url){
if(!cdn_url){
modal.find("#cdn-url").css("background-color", "red");
}else{
modal.find("#cdn-url").css("background-color", "white");
}
if(!origin_url){
modal.find("#origin-url").css("background-color", "red");
}else{
modal.find("#origin-url").css("background-color", "white");
}
return;
}else{
modal.find("#cdn-url").css("background-color", "white");
modal.find("#origin-url").css("background-color", "white");
}
modal.find("#cdn-url-loading").show();
modal.find(".wpfc-cdn-pages-container div.wiz-cont:visible #cdn-url").nextAll("label").html("");
jQuery.ajax({
type: 'GET',
dataType: "json",
url: ajaxurl,
data : {"action": "wpfc_check_url", "url" : cdn_url, "origin_url" : origin_url, "type" : WpfcCDN.id, "nonce" : self.nonce},
success: function(res){
modal.find("#cdn-url-loading").hide();
if(res.success){
self.show_page("next");
modal.find("#cdn-url").css("background-color", "white");
modal.find("#origin-url").css("background-color", "white");
}else{
if(WpfcCDN.id == "cloudflare"){
modal.find("label.wiz-error-msg").html(res.error_message);
}else{
modal.find(".wpfc-cdn-pages-container div.wiz-cont:visible #cdn-url").nextAll("label").html(res.error_message);
}
}
},
error: function(e) {
modal.find("#cdn-url-loading").hide();
alert("unknown error");
}
});
},
show_page: function(type){
var current_page = jQuery("#wpfc-modal-" + this.id).find(".wpfc-cdn-pages-container div.wiz-cont:visible");
current_page.hide();
if(type == "next"){
current_page.next().show();
}else if(type == "back"){
current_page.prev().show();
}
this.buttons();
},
buttons: function(){
var self = this;
var current_page, next_pages;
current_page = jQuery("#wpfc-modal-" + this.id).find(".wpfc-cdn-pages-container div.wiz-cont:visible");
next_pages = current_page.nextAll(".wiz-cont");
jQuery(".wpfc-dialog-buttons[action]").hide();
jQuery(self.values).each(function(i, e){
if(e.id == self.id){
self.show_button("remove");
if(typeof e.status != "undefined" && e.status == "pause"){
self.show_button("start");
}else{
self.show_button("pause");
}
}
});
if(next_pages.length){
if(next_pages.length > 1){
self.show_button("next");
}else if(next_pages.length == 1){
self.show_button("finish");
}
if(jQuery("#wpfc-modal-" + this.id).find(".wpfc-cdn-pages-container div.wiz-cont:visible").attr("wpfc-cdn-page") > 1){
if(current_page.attr("wpfc-cdn-page") == 2){
if(self.id == "maxcdn"){
self.show_button("back");
}
}else{
self.show_button("back");
}
}
}else{
self.show_button("close");
}
},
show_button: function(type){
jQuery("#wpfc-modal-" + this.id + " .wpfc-dialog-buttons[action='" + type + "']").show();
},
hide_button: function(type){
jQuery("#wpfc-modal-" + this.id + " .wpfc-dialog-buttons[action='" + type + "']").hide();
},
load_template: function(callbak){
var self = this;
jQuery.ajax({
type: 'POST',
dataType: "json",
url: ajaxurl,
data : {"action": "wpfc_cdn_template", "id": self.id},
success: function(res){
jQuery("body").append(res.content);
Wpfc_Dialog.dialog("wpfc-modal-" + self.id);
callbak();
jQuery("#revert-loader-toolbar").hide();
},
error: function(e) {
alert("CDN Template Error");
}
});
}
};

View File

@@ -0,0 +1 @@
Silence is golden.

View File

@@ -0,0 +1,43 @@
if(window.attachEvent) {
window.attachEvent('onload', wpfc_column_button_action);
} else {
if(window.onload) {
var curronload_1 = window.onload;
var newonload_1 = function(evt) {
curronload_1(evt);
wpfc_column_button_action(evt);
};
window.onload = newonload_1;
} else {
window.onload = wpfc_column_button_action;
}
}
function wpfc_column_button_action(){
jQuery(document).ready(function(){
jQuery("a[id^='wpfc-clear-cache-link']").click(function(e){
var post_id = jQuery(e.target).attr("data-id");
var nonce = jQuery(e.target).attr("data-nonce");
jQuery("#wpfc-clear-cache-link-" + post_id).css('cursor', 'wait');
jQuery.ajax({
type: 'GET',
url: ajaxurl,
data : {"action": "wpfc_clear_cache_column", "id" : post_id, "nonce" : nonce},
dataType : "json",
cache: false,
success: function(data){
jQuery("#wpfc-clear-cache-link-" + post_id).css('cursor', 'pointer');
if(typeof data.success != "undefined" && data.success == true){
//
}else{
alert("Clear Cache Error");
}
}
});
return false;
});
});
}

View File

@@ -0,0 +1,141 @@
var WpfcDB = {
init: function(){
var self = this;
jQuery("#wpfc-db").change(function(e){
jQuery("#revert-loader-toolbar").show();
self.update();
});
if(jQuery(".tab8").is(":visible")){
jQuery("#revert-loader-toolbar").show();
self.update();
}
jQuery(function(){
self.update();
});
self.click_event_for_warnings();
self.click_event_for_auto_cleanup();
},
click_event_for_auto_cleanup: function(){
jQuery("#wpfc-auto-cleanup-option").change(function(){
let status = jQuery(this).val();
let nonce = jQuery("#wpfc-auto-cleanup-nonce").val();
jQuery("#revert-loader-toolbar").show();
jQuery.ajax({
type: 'POST',
url: ajaxurl,
dataType : "json",
data : {"action": "wpfc_db_set_auto_cleanup", "status" : status, "nonce" : nonce},
cache: false,
success: function(data){
if(typeof data.status != "undefined"){
jQuery("#wpfc-auto-cleanup-option").val(data.status);
}else{
jQuery("#wpfc-auto-cleanup-option").val("off");
}
jQuery("#revert-loader-toolbar").hide();
console.log(data);
}
});
});
},
click_event_for_warnings: function(){
var self = this;
jQuery("div.tab8 div[wpfc-db-name]").click(function(e){
jQuery("#revert-loader-toolbar").show();
jQuery.ajax({
type: 'GET',
url: ajaxurl,
dataType : "json",
data : {"action": "wpfc_db_fix", "type": jQuery(this).attr("wpfc-db-name"), "nonce" : wpfc_nonce},
cache: false,
success: function(data){
if(data.success){
self.update();
}else{
jQuery("#revert-loader-toolbar").hide();
if(data.showupdatewarning){
Wpfc_New_Dialog.dialog("wpfc-modal-updatenow", {close: function(){
Wpfc_New_Dialog.clone.find("div.window-content input").each(function(){
if(jQuery(this).attr("checked")){
var id = jQuery(this).attr("action-id");
jQuery("div.tab1 div[template-id='wpfc-modal-updatenow'] div.window-content input#" + id).attr("checked", true);
}
});
Wpfc_New_Dialog.clone.remove();
}});
}else{
if(typeof data.message != "undefined" && data.message){
alert(data.message);
}else{
alert("DB Error");
}
}
}
}
});
});
},
update: function(){
var self = this;
jQuery.ajax({
type: 'GET',
url: ajaxurl,
dataType : "json",
data : {"action": "wpfc_db_statics", "nonce" : wpfc_nonce},
cache: false,
success: function(data){
jQuery.each(data, function(key, value){
jQuery(".tab8 div[wpfc-db-name='" + key + "'] span.db-number").css({'color': (value > 0) ? "red" : "#6BC359"});
jQuery(".tab8 div[wpfc-db-name='" + key + "'] span.db-number").text("(" + value + ")");
jQuery(".tab8 div[wpfc-db-name='" + key + "'] div.meta").attr('class', (value > 0) ? "meta warning" : "meta success");
});
if(data.all_warnings > 0){
jQuery("label[for='wpfc-db']").text("DB (" + data.all_warnings + ")");
}else{
jQuery("label[for='wpfc-db']").text("DB");
}
jQuery("#revert-loader-toolbar").hide();
}
});
}
};
// if(window.attachEvent) {
// window.attachEvent('onload', WpfcDB_init);
// } else {
// if(window.onload) {
// var curronload = window.onload;
// var newonload = function(evt) {
// curronload(evt);
// WpfcDB_init(evt);
// };
// window.onload = newonload;
// } else {
// window.onload = WpfcDB_init;
// }
// }
if(window.attachEvent){
window.attachEvent('onload', WpfcDB_init);
}else if(window.addEventListener){
window.addEventListener('load', WpfcDB_init, false);
}
function WpfcDB_init(){WpfcDB.init();}

View File

@@ -0,0 +1,48 @@
var Wpfc_Dialog = {
id : "",
buttons: [],
dialog: function(id, buttons){
var self = this;
self.id = id;
self.buttons = buttons;
jQuery("#" + id).show();
jQuery("#" + id).draggable({
stop: function(){
jQuery(this).height("auto");
}
});
jQuery("#" + id).position({my: "center", at: "center", of: window});
jQuery(".close-wiz").click(function(e){
jQuery(e.target).closest("div[id^='wpfc-modal-']").remove();
});
self.show_buttons();
},
remove: function(clone_modal_id){
if(typeof clone_modal_id != "undefined"){
jQuery("#" + clone_modal_id).remove();
}else{
var self = this;
jQuery("#" + self.id).remove();
}
},
show_buttons: function(){
var self = this;
if(typeof self.buttons != "undefined"){
jQuery.each(self.buttons, function( index, value ) {
jQuery("#" + self.id + " button[action='" + index + "']").show();
jQuery("#" + self.id + " button[action='" + index + "']").click(function(e){
if(index == "close"){
jQuery(e.target).closest("div[id^='wpfc-modal-']").remove();
}else{
value();
}
});
});
}
}
};

View File

@@ -0,0 +1,249 @@
var Wpfc_New_Dialog = {
template_id: "",
id : "",
buttons: [],
clone: "",
current_page_number: 1,
total_page_number: 0,
interval : {},
enable_button: function(button_type){
clearInterval(this.interval[this.id]);
let self = this;
let modal = jQuery("#" + self.id);
let button = modal.find(".wpfc-dialog-buttons[action='" + button_type + "']");
button.attr("disabled", false);
button.text(button.text().replace(/\.+$/, ""));
},
disable_button: function(button_type){
let self = this;
let modal = jQuery("#" + self.id);
let button = modal.find(".wpfc-dialog-buttons[action='" + button_type + "']");
let text = button.text();
let dot = 0;
button.attr("disabled", true);
button.text(text + ".");
self.interval[self.id] = setInterval(function(){
if(jQuery("#" + self.id).length === 0){
clearInterval(self.interval);
}
text = button.text();
dot = text.match(/\./g);
console.log(self.interval);
if(dot){
if(dot.length < 3){
button.text(text + ".");
}else{
button.text(text.replace(/\.+$/, ""));
}
}else{
button.text(text + ".");
}
}, 300);
},
dialog: function(id, buttons, callback){
var self = this;
self.clone = jQuery("div[template-id='" + id + "']").clone();
self.total_page_number = self.clone.find("div[wpfc-page]").length;
self.total_page_number = self.total_page_number > 0 ? self.total_page_number : self.clone.find("div[wpfc-cdn-page]").length;
self.template_id = id;
self.id = id + "-" + new Date().getTime();
self.buttons = buttons;
self.clone.attr("id", self.id);
self.clone.removeAttr("template-id");
jQuery("body").append(self.clone);
self.clone.show();
self.clone.draggable({
stop: function(){
jQuery(this).height("auto");
}
});
self.clone.position({my: "center", at: "center", of: window});
self.clone.find(".close-wiz").click(function(){
self.remove(this);
});
self.update_ids_for_label();
self.show_buttons();
if(typeof callback != "undefined"){
if(typeof callback == "function"){
callback(self);
}
}
self.click_event_add_new_keyword_button();
self.add_new_keyword_keypress();
},
remove: function(button){
jQuery(button).closest("div[id^='wpfc-modal-']").remove();
},
show_buttons: function(){
var self = this;
if(typeof self.buttons != "undefined"){
jQuery.each(self.buttons, function( index, value ) {
self.clone.find("button[action='" + index + "']").click(function(){
if(value == "default"){
if(index == "next"){
self.default_next_action();
}
if(index == "back"){
self.default_back_action();
}
if(index == "close"){
self.default_close_action();
}
}else{
value(this);
}
});
});
}
},
default_next_action: function(){
this.current_page_number = this.current_page_number + 1;
this.show_page(this.current_page_number);
this.show_button("back");
if(this.total_page_number == this.current_page_number){
this.hide_button("next");
this.show_button("finish");
}
},
default_back_action: function(){
this.current_page_number = this.current_page_number - 1;
this.show_page(this.current_page_number);
this.show_button("next");
this.hide_button("finish");
if(this.current_page_number == 1){
this.hide_button("back");
}
},
default_close_action: function(){
Wpfc_New_Dialog.clone.remove();
},
show_button: function(index){
this.clone.find("button[action='" + index + "']").show();
},
hide_button: function(index){
this.clone.find("button[action='" + index + "']").hide();
},
show_page: function(number){
this.clone.find("div[wpfc-page], div[wpfc-cdn-page]").hide();
this.clone.find("div[wpfc-page='" + number + "'], div[wpfc-cdn-page='" + number + "']").show();
this.current_page_number = number;
},
update_ids_for_label: function(){
var self = this;
var input;
var id = "";
self.clone.find("div.window-content div.wiz-input-cont").each(function(){
input = jQuery(this).find("label.mc-input-label input");
if(input.length){
id = input.attr("id") + self.id;
jQuery(this).find("label.mc-input-label input").attr("id", id);
jQuery(this).find("label").last().attr("for", id);
}
});
},
set_values_from_tmp_to_real: function(){
var self = this;
Wpfc_New_Dialog.clone.find("div.window-content input, div.window-content select").each(function(){
if(jQuery(this).prop("tagName") == "SELECT"){
jQuery("div.tab1 div[template-id='" + self.template_id + "'] div.window-content select[name='" + jQuery(this).attr("name") + "']").val(jQuery(this).val());
}else if(jQuery(this).prop("tagName") == "INPUT"){
if(jQuery(this).attr("type") == "checkbox"){
if(jQuery(this).is(':checked')){
jQuery("div.tab1 div[template-id='" + self.template_id + "'] div.window-content input[name='" + jQuery(this).attr("name") + "']").attr("checked", true);
}else{
jQuery("div.tab1 div[template-id='" + self.template_id + "'] div.window-content input[name='" + jQuery(this).attr("name") + "']").attr("checked", false);
}
}else{
//toDo
}
}
});
},
add_new_keyword_keypress: function() {
const $clone = Wpfc_New_Dialog.clone;
const $input = $clone.find(".wpfc-textbox-con .fixed-search input");
const $textboxCon = $clone.find(".wpfc-textbox-con");
const insertKeywordItem = function(){
let keyword = $input.val().replace(/[\s,]/g, "");
$textboxCon.hide();
$input.val("");
if (keyword.length > 0) {
const $newKeywordItem = jQuery('<li class="keyword-item"><a class="keyword-label">' + keyword + '</a></li>').click(function() {
jQuery(this).remove();
});
$newKeywordItem.insertBefore($clone.find(".wpfc-add-new-keyword").closest(".keyword-item"));
}
};
$input.keydown(function(e) {
if (e.keyCode === 8) {
let keyword = $input.val().replace(/[\s,]/g, "");
if (keyword.length === 0) {
$textboxCon.hide();
}
} else if (e.keyCode === 13) {
insertKeywordItem();
}
});
$input.bind("blur", function() {
insertKeywordItem();
});
},
click_event_add_new_keyword_button: function(){
Wpfc_New_Dialog.clone.find(".wpfc-add-new-keyword").click(function(){
Wpfc_New_Dialog.clone.find(".wpfc-textbox-con").show();
Wpfc_New_Dialog.clone.find(".wpfc-textbox-con .fixed-search input").focus();
});
},
insert_keywords: function(id, keywords){
if(keywords){
jQuery.each(keywords.split(","), function( index, value ) {
jQuery('<li class="keyword-item"><a class="keyword-label">' + value + '</a></li>').insertBefore(jQuery("div[id^='" + id + "']").find(".wpfc-add-new-keyword").closest(".keyword-item")).click(function(){
jQuery(this).remove();
});
});
}
},
};

View File

@@ -0,0 +1 @@
Silence is golden.

View File

@@ -0,0 +1,37 @@
window.wpfc = {};
window.wpfc.translate = function(word){
return (typeof window.wpfc.dictionary != "undefined" && typeof window.wpfc.dictionary[word] != "undefined" && window.wpfc.dictionary[word]) ? window.wpfc.dictionary[word] : word;
};
jQuery.fn.extend({
wpfclang: function(){
var dictionary = window.wpfc.dictionary || {};
var el = jQuery(this);
var text = el.attr("type") == "submit" ? el.val().trim() : el.text().trim();
var converted = typeof dictionary[text] == "undefined" ? text : dictionary[text];
if(typeof converted != "undefined" && converted){
if(el.attr("type") == "submit"){
el.val(converted);
}else{
el.html(converted);
}
}
}
});
var Wpfclang = {
language : "",
init: function(language){
this.language = language;
this.translate();
},
translate: function(){
if(typeof window.wpfc != "undefined" && typeof window.wpfc.dictionary != "undefined"){
var self = this;
jQuery('#wpfc-read-tutorial span, #wpfc-plugin-setup-warning h3, #just-h1, #get-now-h1, #new-features-h1, div.wpfc-premium-step-footer ul li a, div.wpfc-premium-step-footer p, div.wpfc-premium-step-content, #wpbody-content label, div.question, .questionCon input[type="submit"], #message p, .wrap h2, #nextVerAct, select option, th, #rule-help-tip h4, #rule-help-tip label, .omni_admin_sidebar h3, #message p, #wpfc-image-static-panel span, #wpfc-statics-right div, #wpfc-image-static-panel p, #container-show-hide-image-list span, #wpfc-image-list th').each(function(){
if(jQuery(this).children().length === 0){
jQuery(this).wpfclang();
}
});
}
}
};

View File

@@ -0,0 +1,65 @@
var WpfcSchedule = {
id: "#wpfc-server-time",
serverTime : "", //milliseconds
dropdowns: "#wpFastestCacheTimeOutHour, #wpFastestCacheTimeOutMinute, #wpFastestCacheTimeOut",
init: function(){
if(jQuery("form[id='wpfc-schedule-panel']").length){
this.setServerTime();
this.clock();
this.setDropdownEvent();
this.setDeleteCronEvent();
jQuery("#wpfc-schedule-panel input[type='submit']").bind("click", this, this.submitButtonEvent);
}
},
setDeleteCronEvent: function(){
jQuery("#deleteCron").click(function(){
jQuery("#wpFastestCacheTimeOut").val("");
jQuery("form#wpfc-schedule-panel").submit();
});
},
setDropdownEvent: function(){
jQuery(this.dropdowns).change(function(e){
var e = jQuery(e.currentTarget);
if(e.attr("value")){
e.css("background-color", "");
}
/* if(e.attr("id") == "wpFastestCacheTimeOut"){
if(e.val() == "hourly"){
jQuery("#wpFastestCacheTimeOutHour, #wpFastestCacheTimeOutMinute").prop('disabled', true);
}else{
jQuery("#wpFastestCacheTimeOutHour, #wpFastestCacheTimeOutMinute").prop('disabled', false);
}
}*/
});
},
setServerTime: function(){
this.serverTime = new Date(jQuery(this.id).text()).getTime();
},
clock: function(){
var self = this;
var newDate;
setInterval(function(){
newDate = new Date(self.serverTime);
jQuery(self.id).text(newDate.getFullYear() + "-" + (newDate.getMonth() + 1) + "-" + newDate.getDate() + " " + newDate.getHours() + ":" + newDate.getMinutes() + ":" + newDate.getSeconds());
self.serverTime = self.serverTime + 1000;
}, 1000);
},
submitButtonEvent: function(self){
var error_count = 0;
jQuery(self.data.dropdowns).each(function(i, e){
if(jQuery(e).attr("value")){
jQuery(e).css("background-color", "");
}else{
error_count++;
jQuery(e).css("background-color", "red");
}
});
return error_count > 0 ? false : true;
}
};
WpfcSchedule.init();

View File

@@ -0,0 +1,122 @@
var WPFC_TOOLBAR = {
ajax_url: false,
init: function(){
var self = this;
if(typeof ajaxurl != "undefined" || typeof wpfc_ajaxurl != "undefined"){
self.ajax_url = (typeof ajaxurl != "undefined") ? ajaxurl : wpfc_ajaxurl;
}else{
alert("AjaxURL has NOT been defined");
}
jQuery("body").append('<div id="revert-loader-toolbar"></div>');
jQuery("#wp-admin-bar-wpfc-toolbar-parent-default li").click(function(e){
var id = (typeof e.target.id != "undefined" && e.target.id) ? e.target.id : jQuery(e.target).parent("li").attr("id");
var action = "";
if(id == "wp-admin-bar-wpfc-toolbar-parent-settings"){
if(jQuery("div[id^='wpfc-modal-toolbarsettings-']").length === 0){
self.open_settings();
}
}else{
if(id == "wp-admin-bar-wpfc-toolbar-parent-delete-cache"){
action = "wpfc_delete_cache";
}else if(id == "wp-admin-bar-wpfc-toolbar-parent-delete-cache-and-minified"){
action = "wpfc_delete_cache_and_minified";
}else if(id == "wp-admin-bar-wpfc-toolbar-parent-clear-cache-of-this-page"){
action = "wpfc_delete_current_page_cache";
}else if(id == "wp-admin-bar-wpfc-toolbar-parent-clear-cache-of-allsites"){
action = "wpfc_clear_cache_of_allsites";
}
WPFC_TOOLBAR.send({"action": action, "path" : window.location.pathname});
}
});
},
open_settings: function(){
var self = this;
jQuery("#revert-loader-toolbar").show();
jQuery.ajax({
type: 'GET',
url: self.ajax_url,
data : {"action": "wpfc_toolbar_get_settings", "path" : window.location.pathname},
dataType : "json",
cache: false,
success: function(data){
if(data.success){
var data_json = {"action": "wpfc_toolbar_save_settings", "path" : window.location.pathname, "roles" : {}};
Wpfc_New_Dialog.dialog("wpfc-modal-toolbarsettings", {
close: function(){
Wpfc_New_Dialog.clone.remove();
},
finish: function(){
jQuery("#" + Wpfc_New_Dialog.id).find("input[type='checkbox']:checked").each(function(i, e){
data_json.roles[jQuery(e).attr("name")] = 1;
});
WPFC_TOOLBAR.send(data_json);
Wpfc_New_Dialog.clone.remove();
}}, function(dialog){
jQuery("#" + Wpfc_New_Dialog.id).find("input[type='checkbox']").each(function(i, e){
if(typeof data.roles[jQuery(e).attr("name")] != "undefined"){
jQuery(e).attr('checked', true);
}
});
Wpfc_New_Dialog.show_button("close");
Wpfc_New_Dialog.show_button("finish");
setTimeout(function(){
jQuery("#revert-loader-toolbar").hide();
}, 500);
});
}else{
alert("Toolbar Settings Error!")
}
}
});
},
send: function(data_json){
var self = this;
if(typeof wpfc_nonce != "undefined" && wpfc_nonce){
data_json.nonce = wpfc_nonce;
}
jQuery("#revert-loader-toolbar").show();
jQuery.ajax({
type: 'GET',
url: self.ajax_url,
data : data_json,
dataType : "json",
cache: false,
success: function(data){
if(data[1] == "error"){
if(typeof data[2] != "undefined" && data[2] == "alert"){
alert(data[0]);
}else{
Wpfc_New_Dialog.dialog("wpfc-modal-permission", {close: "default"});
Wpfc_New_Dialog.show_button("close");
}
}
if(typeof WpFcCacheStatics != "undefined"){
WpFcCacheStatics.update();
}else{
jQuery("#revert-loader-toolbar").hide();
}
}
});
}
};
window.addEventListener('load', function(){
jQuery(document).ready(function(){
WPFC_TOOLBAR.init();
});
});