| 1 |
/* eslint complexity: ["error", 100] */ |
| 2 |
jQuery(document).on('click', '.item.extension-inactive', function () { |
| 3 |
jQuery('#mainwp-install-extensions-promo-modal').modal('show'); |
| 4 |
return false; |
| 5 |
} ); |
| 6 |
|
| 7 |
jQuery(document).on('click', '.mainwp-extensions-add-menu', function () { |
| 8 |
var extensionSlug = jQuery(this).parents('.plugin-card').attr('extension_slug'); |
| 9 |
var data = mainwp_secure_data({ |
| 10 |
action: 'mainwp_extension_add_menu', |
| 11 |
slug: extensionSlug |
| 12 |
}); |
| 13 |
|
| 14 |
jQuery.post(ajaxurl, data, function (response) { |
| 15 |
if (response.result == 'SUCCESS') |
| 16 |
location.reload(); |
| 17 |
else if (response.error) { |
| 18 |
alert(response.error); |
| 19 |
} |
| 20 |
}, 'json'); |
| 21 |
|
| 22 |
return false; |
| 23 |
}); |
| 24 |
|
| 25 |
jQuery(document).on('click', '.mainwp-extensions-remove-menu', function () { |
| 26 |
var extensionSlug = jQuery(this).parents('.plugin-card').attr('extension_slug'); |
| 27 |
var data = mainwp_secure_data({ |
| 28 |
action: 'mainwp_extension_remove_menu', |
| 29 |
slug: extensionSlug |
| 30 |
}); |
| 31 |
|
| 32 |
jQuery.post(ajaxurl, data, function (response) { |
| 33 |
if (response.result == 'SUCCESS') |
| 34 |
location.reload(); |
| 35 |
}, 'json'); |
| 36 |
|
| 37 |
return false; |
| 38 |
}); |
| 39 |
|
| 40 |
jQuery(document).ready(function () { |
| 41 |
jQuery(document).on('click', '.mainwp-manage-extension-license', function () { |
| 42 |
var currentCard = jQuery(this).closest(".card"); |
| 43 |
currentCard.find("#mainwp-extensions-api-form").toggle(); |
| 44 |
if (jQuery(this).attr('api-actived') == '0') { |
| 45 |
extensions_activate_next(currentCard, false); |
| 46 |
} |
| 47 |
return false; |
| 48 |
}); |
| 49 |
|
| 50 |
jQuery(document).on('click', '.extension-privacy-info-link', function () { |
| 51 |
var slug = jQuery(this).attr('base-slug'); |
| 52 |
var title = ''; |
| 53 |
if (jQuery('#mainwp-extensions-privacy-info').find("input[base-slug='" + slug + "']").length > 0) { |
| 54 |
title = jQuery('#mainwp-extensions-privacy-info').find("input[base-slug='" + slug + "']").attr('extension_title'); |
| 55 |
} else { |
| 56 |
title = jQuery(this).closest('.ui.card').attr('extension-title'); |
| 57 |
} |
| 58 |
var privacy = jQuery('#mainwp-extensions-privacy-info').find("input[base-slug='" + slug + "']").attr('privacy'); |
| 59 |
var integration = jQuery('#mainwp-extensions-privacy-info').find("input[base-slug='" + slug + "']").attr('integration'); |
| 60 |
var integration_url = jQuery('#mainwp-extensions-privacy-info').find("input[base-slug='" + slug + "']").attr('integration_url'); |
| 61 |
var integration_owner = jQuery('#mainwp-extensions-privacy-info').find("input[base-slug='" + slug + "']").attr('integration_owner'); |
| 62 |
var integration_owner_pp = jQuery('#mainwp-extensions-privacy-info').find("input[base-slug='" + slug + "']").attr('integration_owner_pp'); |
| 63 |
|
| 64 |
jQuery('#mainwp-privacy-info-modal').modal({ |
| 65 |
allowMultiple: true, |
| 66 |
onShow: function () { |
| 67 |
jQuery('#mainwp-privacy-info-modal').find('.header').html(title + ' Privacy Info'); |
| 68 |
if (0 == privacy) { |
| 69 |
jQuery('#mainwp-privacy-info-modal').find('.content').html('Standalone Extension. This Extension does not use any 3rd party plugins or API\'s to integrate with your Dashboard. This extension falls under the <a href="https://mainwp.com/mainwp-plugin-privacy-policy/" target="_blank">MainWP Plugin Privacy Policy</a>.'); |
| 70 |
} else if (1 == privacy) { |
| 71 |
if (slug == 'advanced-uptime-monitor-extension') { |
| 72 |
jQuery('#mainwp-privacy-info-modal').find('.content').html('<strong>Extension integrates with a 3rd party API.</strong>'); |
| 73 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<div class="ui hidden divider"></div>'); |
| 74 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Integrates with: <a href="' + integration_url + '" target="_blank">' + integration + '</a>'); |
| 75 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<br/>'); |
| 76 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Owned by: <a href="' + integration_owner_pp + '" target="_blank">' + integration_owner + '</a>'); |
| 77 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<div class="ui hidden divider"></div>'); |
| 78 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Integrates with: <a href="https://betteruptime.com/" target="_blank">Better Uptime API</a>'); |
| 79 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<br/>'); |
| 80 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Owned by: <a href="https://betterstack.com/privacy" target="_blank">Better Stack, Inc.</a>'); |
| 81 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<div class="ui hidden divider"></div>'); |
| 82 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Integrates with: <a href="https://nodeping.com" target="_blank">NodePing API</a>'); |
| 83 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<br/>'); |
| 84 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Owned by: <a href="https://nodeping.com/privacy.html" target="_blank">NodePing LLC</a>'); |
| 85 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<div class="ui hidden divider"></div>'); |
| 86 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Integrates with: <a href="https://www.site24x7.com/" target="_blank">Site24x7 API</a>'); |
| 87 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<br/>'); |
| 88 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Owned by: <a href="https://www.zoho.com/privacy.html" target="_blank">Zoho Corporation Pvt. Ltd.</a>'); |
| 89 |
} else if (slug == 'mainwp-vulnerability-checker-extension') { |
| 90 |
jQuery('#mainwp-privacy-info-modal').find('.content').html('<strong>Extension integrates with a 3rd party API.</strong>'); |
| 91 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<div class="ui hidden divider"></div>'); |
| 92 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Integrates with: <a href="' + integration_url + '" target="_blank">' + integration + '</a>'); |
| 93 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<br/>'); |
| 94 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Owned by: <a href="' + integration_owner_pp + '" target="_blank">' + integration_owner + '</a>'); |
| 95 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<div class="ui hidden divider"></div>'); |
| 96 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Integrates with: <a href="https://nvd.nist.gov/" target="_blank">NVD NIST API</a>'); |
| 97 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<br/>'); |
| 98 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Owned by: <a href="https://www.nist.gov/privacy-policy" target="_blank">National Institute of Standards and Technology</a>'); |
| 99 |
} else if (slug == 'mainwp-api-backups-extension') { |
| 100 |
jQuery('#mainwp-privacy-info-modal').find('.content').html('<strong>Extension integrates with a 3rd party API.</strong>'); |
| 101 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<div class="ui hidden divider"></div>'); |
| 102 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Integrates with: <a href="' + integration_url + '" target="_blank">' + integration + '</a>'); |
| 103 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<br/>'); |
| 104 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Owned by: <a href="' + integration_owner_pp + '" target="_blank">' + integration_owner + '</a>'); |
| 105 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<div class="ui hidden divider"></div>'); |
| 106 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Integrates with: <a href="https://gridpane.com/" target="_blank">GridPane API</a>'); |
| 107 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<br/>'); |
| 108 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Owned by: <a href="https://gridpane.com/privacy/" target="_blank">GridPane Inc.</a>'); |
| 109 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<div class="ui hidden divider"></div>'); |
| 110 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Integrates with: <a href="https://www.digitalocean.com/" target="_blank">Digital Ocean API</a>'); |
| 111 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<br/>'); |
| 112 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Owned by: <a href="https://www.digitalocean.com/legal/privacy-policy" target="_blank">DigitalOcean, LLC.</a>'); |
| 113 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<div class="ui hidden divider"></div>'); |
| 114 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Integrates with: <a href="https://www.linode.com/" target="_blank">Linode API</a>'); |
| 115 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<br/>'); |
| 116 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Owned by: <a href="https://www.linode.com/legal-privacy/" target="_blank">Akamai Technologies</a>'); |
| 117 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<div class="ui hidden divider"></div>'); |
| 118 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Integrates with: <a href="https://www.vultr.com/" target="_blank">Vultr API</a>'); |
| 119 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<br/>'); |
| 120 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Owned by: <a href="https://www.vultr.com/legal/privacy/" target="_blank">Constant Company, LLC.</a>'); |
| 121 |
} else { |
| 122 |
jQuery('#mainwp-privacy-info-modal').find('.content').html('<strong>Extension integrates with a 3rd party API.</strong>'); |
| 123 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<div class="ui hidden divider"></div>'); |
| 124 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Integrates with: <a href="' + integration_url + '" target="_blank">' + integration + '</a>'); |
| 125 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<br/>'); |
| 126 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Owned by: <a href="' + integration_owner_pp + '" target="_blank">' + integration_owner + '</a>'); |
| 127 |
} |
| 128 |
} else if (2 == privacy) { |
| 129 |
jQuery('#mainwp-privacy-info-modal').find('.content').html('<strong>Extension integrates with a 3rd party Plugin.</strong>'); |
| 130 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<div class="ui hidden divider"></div>'); |
| 131 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Integrates with: <a href="' + integration_url + '" target="_blank">' + integration + '</a>'); |
| 132 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<br/>'); |
| 133 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Owned by: <a href="' + integration_owner_pp + '" target="_blank">' + integration_owner + '</a>'); |
| 134 |
} else { |
| 135 |
if (slug == 'mainwp-page-speed-extension') { |
| 136 |
jQuery('#mainwp-privacy-info-modal').find('.content').html('<strong>Extension integrates with a 3rd party Plugin.</strong>'); |
| 137 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<div class="ui hidden divider"></div>'); |
| 138 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Integrates with: <a href="https://wordpress.org/plugins/google-pagespeed-insights/" target="_blank">Insights from Google PageSpeed</a>'); |
| 139 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('<br/>'); |
| 140 |
jQuery('#mainwp-privacy-info-modal').find('.content').append('Owned by: <a href="https://mattkeys.me/" target="_blank">Matt Keys</a>'); |
| 141 |
} else { |
| 142 |
jQuery('#mainwp-privacy-info-modal').find('.content').html('<strong>This extension is not developed by MainWP. Privacy info is not available.</strong>'); |
| 143 |
} |
| 144 |
} |
| 145 |
}, |
| 146 |
onHide: function () { |
| 147 |
jQuery('#mainwp-privacy-info-modal').find('.header').html(''); |
| 148 |
jQuery('#mainwp-privacy-info-modal').find('.content').html(''); |
| 149 |
}, |
| 150 |
}).modal('show'); |
| 151 |
|
| 152 |
return false; |
| 153 |
}); |
| 154 |
|
| 155 |
jQuery(document).on('click', '.extension-the-plugin-action', function () { |
| 156 |
var parent = jQuery(this).closest(".card"); |
| 157 |
var slug = jQuery(parent).attr('extension-slug'); |
| 158 |
var loadingEl = parent.find(".action-feedback"); |
| 159 |
var whatAct = jQuery(this).attr("plugin-action"); |
| 160 |
|
| 161 |
loadingEl.show(); |
| 162 |
loadingEl.find('.message').removeClass('red green'); |
| 163 |
|
| 164 |
var msg = __('Deactivating...'); |
| 165 |
if (whatAct == 'active') { |
| 166 |
msg = __('Activating...'); |
| 167 |
} else if (whatAct == 'remove') { |
| 168 |
msg = __('Removing...'); |
| 169 |
} |
| 170 |
|
| 171 |
loadingEl.find('.message').html('<i class="notched circle loading icon"></i> ' + msg); |
| 172 |
|
| 173 |
var data = mainwp_secure_data({ |
| 174 |
action: 'mainwp_extension_plugin_action', |
| 175 |
slug: slug, |
| 176 |
what: whatAct, |
| 177 |
}); |
| 178 |
|
| 179 |
jQuery(this).attr('disabled', true); |
| 180 |
jQuery.post(ajaxurl, data, function (response) { |
| 181 |
jQuery(this).attr('disabled', false); |
| 182 |
var success = false; |
| 183 |
if (response) { |
| 184 |
if (response.result == 'SUCCESS') { |
| 185 |
loadingEl.find('.message').addClass('green'); |
| 186 |
msg = __('Extension deactivated.'); |
| 187 |
if (whatAct == 'active') { |
| 188 |
msg = __('Extension activated.'); |
| 189 |
} else if (whatAct == 'remove') { |
| 190 |
msg = __('Extension removed.'); |
| 191 |
} |
| 192 |
loadingEl.find('.message').html(msg); |
| 193 |
success = true; |
| 194 |
} else if (response.error) { |
| 195 |
loadingEl.find('.message').addClass('red'); |
| 196 |
loadingEl.find('.message').html(response.error); |
| 197 |
} else { |
| 198 |
loadingEl.find('.message').addClass('red'); |
| 199 |
loadingEl.find('.message').html(__('Undefined error. ')); |
| 200 |
} |
| 201 |
} else { |
| 202 |
loadingEl.find('.message').addClass('red'); |
| 203 |
loadingEl.find('.message').html(__('Undefined error. ')); |
| 204 |
} |
| 205 |
|
| 206 |
if (success) { |
| 207 |
setTimeout(function () { |
| 208 |
location.href = 'admin.php?page=Extensions'; |
| 209 |
}, 2000); |
| 210 |
} |
| 211 |
}, 'json'); |
| 212 |
return false; |
| 213 |
}); |
| 214 |
}); |
| 215 |
|
| 216 |
jQuery(document).on('click', '.mainwp-extensions-activate', function () { |
| 217 |
mainwp_extensions_activate(this, false); |
| 218 |
}); |
| 219 |
|
| 220 |
function mainwp_extensions_activate(pObj, retring) { |
| 221 |
var apiEl = jQuery(pObj).closest(".card"); |
| 222 |
var statusEl = apiEl.find(".activate-api-status"); |
| 223 |
var loadingEl = apiEl.find(".api-feedback"); |
| 224 |
|
| 225 |
loadingEl.hide(); |
| 226 |
|
| 227 |
if (jQuery(pObj).attr('license-status') == 'activated') { |
| 228 |
loadingEl.show(); |
| 229 |
loadingEl.find('.message').html(__('Already activated.')); |
| 230 |
return; |
| 231 |
} |
| 232 |
|
| 233 |
if (retring == true) { |
| 234 |
loadingEl.show(); |
| 235 |
loadingEl.find('.message').html(__('Connection error detected. The Verify Certificate option has been switched to NO. Retrying...')); |
| 236 |
} else { |
| 237 |
var extensionSlug = jQuery(apiEl).attr('extension-slug'); |
| 238 |
var key = apiEl.find('input[type="text"].extension-api-key').val(); |
| 239 |
var email = apiEl.find('input[type="text"].extension-api-email').val(); |
| 240 |
|
| 241 |
if (key == '') |
| 242 |
return; |
| 243 |
|
| 244 |
var data = mainwp_secure_data({ |
| 245 |
action: 'mainwp_extension_api_activate', |
| 246 |
slug: extensionSlug, |
| 247 |
key: key, |
| 248 |
email: email |
| 249 |
}); |
| 250 |
} |
| 251 |
|
| 252 |
loadingEl.show(); |
| 253 |
loadingEl.find('.message').removeClass('red green'); |
| 254 |
loadingEl.find('.message').html('<i class="notched circle loading icon"></i>' + __('Activating...')); |
| 255 |
|
| 256 |
jQuery.post(ajaxurl, data, function (response) { |
| 257 |
|
| 258 |
var success = false; |
| 259 |
|
| 260 |
if (response) { |
| 261 |
if (response.result == 'SUCCESS') { |
| 262 |
loadingEl.find('.message').addClass('green'); |
| 263 |
loadingEl.find('.message').html(__('License activated. ')); |
| 264 |
statusEl.html('<i class="green check icon"></i> License'); |
| 265 |
success = true; |
| 266 |
} else if (response.error) { |
| 267 |
loadingEl.find('.message').addClass('red'); |
| 268 |
loadingEl.find('.message').html(response.error); |
| 269 |
} else if (response.retry_action && response.retry_action == 1) { |
| 270 |
jQuery("#mainwp_api_sslVerifyCertificate").val(0); |
| 271 |
mainwp_extensions_activate(pObj, true); |
| 272 |
return false; |
| 273 |
} else { |
| 274 |
loadingEl.find('.message').addClass('red'); |
| 275 |
loadingEl.find('.message').html(__('Undefined error. ')); |
| 276 |
} |
| 277 |
} else { |
| 278 |
loadingEl.find('.message').addClass('red'); |
| 279 |
loadingEl.find('.message').html(__('Undefined error. ')); |
| 280 |
} |
| 281 |
|
| 282 |
if (success) { |
| 283 |
setTimeout(function () { |
| 284 |
location.href = 'admin.php?page=Extensions'; |
| 285 |
}, 2000); |
| 286 |
} |
| 287 |
}, 'json'); |
| 288 |
return false; |
| 289 |
} |
| 290 |
|
| 291 |
jQuery(document).on('click', '.mainwp-extensions-deactivate', function () { |
| 292 |
var apiEl = jQuery(this).closest(".card"); |
| 293 |
var statusEl = apiEl.find(".activate-api-status"); |
| 294 |
var loadingEl = apiEl.find(".api-feedback"); |
| 295 |
|
| 296 |
if (!apiEl.find('.mainwp-extensions-deactivate-chkbox').is(':checked')) |
| 297 |
return false; |
| 298 |
|
| 299 |
loadingEl.hide(); |
| 300 |
|
| 301 |
var extensionSlug = jQuery(apiEl).attr('extension-slug'); |
| 302 |
var extensionApiKey = jQuery(apiEl).find('.extension-api-key').val(); |
| 303 |
var data = mainwp_secure_data({ |
| 304 |
action: 'mainwp_extension_deactivate', |
| 305 |
slug: extensionSlug, |
| 306 |
api_key: extensionApiKey |
| 307 |
}); |
| 308 |
|
| 309 |
loadingEl.show(); |
| 310 |
loadingEl.find('.message').removeClass('red green'); |
| 311 |
loadingEl.find('.message').html('<i class="notched circle loading icon"></i>' + __('Deactivating...')); |
| 312 |
|
| 313 |
jQuery.post(ajaxurl, data, function (response) { |
| 314 |
|
| 315 |
if (response) { |
| 316 |
if (response.result == 'SUCCESS') { |
| 317 |
loadingEl.find('.message').addClass('green'); |
| 318 |
loadingEl.find('.message').html(__('License deactivated.')); |
| 319 |
statusEl.html('<i class="green check icon"></i> License'); |
| 320 |
success = true; |
| 321 |
} else if (response.error) { |
| 322 |
loadingEl.find('.message').addClass('red'); |
| 323 |
loadingEl.find('.message').html(response.error); |
| 324 |
} else { |
| 325 |
loadingEl.find('.message').addClass('red'); |
| 326 |
loadingEl.find('.message').html(__('Undefined error. ')); |
| 327 |
} |
| 328 |
} else { |
| 329 |
loadingEl.find('.message').addClass('red'); |
| 330 |
loadingEl.find('.message').html(__('Undefined error. ')); |
| 331 |
} |
| 332 |
|
| 333 |
setTimeout(function () { |
| 334 |
location.href = 'admin.php?page=Extensions'; |
| 335 |
}, 2000); |
| 336 |
}, 'json'); |
| 337 |
return false; |
| 338 |
}); |
| 339 |
|
| 340 |
|
| 341 |
// Verify mainwp.com login credentials |
| 342 |
jQuery(document).on('click', '#mainwp-extensions-savelogin', function () { |
| 343 |
mainwp_extensions_savelogin(this, false); |
| 344 |
}); |
| 345 |
|
| 346 |
function mainwp_extensions_savelogin(pObj, retring) { |
| 347 |
var grabingEl = jQuery("#mainwp-extensions-api-fields"); |
| 348 |
var api_key = grabingEl.find('#mainwp_com_api_key').val(); |
| 349 |
var statusEl = jQuery(".mainwp-extensions-api-loading"); |
| 350 |
var data = mainwp_secure_data({ |
| 351 |
action: 'mainwp_extension_saveextensionapilogin', |
| 352 |
api_key: api_key, |
| 353 |
saveLogin: jQuery('#extensions_api_savemylogin_chk').is(':checked') ? 1 : 0 |
| 354 |
}); |
| 355 |
|
| 356 |
if ( retring == true ) { |
| 357 |
statusEl.find( '.text' ).html(__("Connection error detected. The Verify Certificate option has been switched to NO. Retrying...")).fadeIn(); |
| 358 |
} else { |
| 359 |
|
| 360 |
statusEl.find( '.text' ).html( __( 'Validating...' ) ); |
| 361 |
} |
| 362 |
|
| 363 |
statusEl.show(); |
| 364 |
|
| 365 |
jQuery.post(ajaxurl, data, function (response) { |
| 366 |
var undefError = false; |
| 367 |
if (response) { |
| 368 |
if (response.saved) { |
| 369 |
statusEl.find( '.text' ).html( 'Your API license key has been successfully saved!' ); |
| 370 |
} else if (response.result == 'SUCCESS') { |
| 371 |
statusEl.find( '.text' ).html('API license key verification successful!'); |
| 372 |
} else if ( response.error ) { |
| 373 |
statusEl.find( '.text' ).html(response.error); |
| 374 |
} else if (response.retry_action && response.retry_action == 1) { |
| 375 |
jQuery("#mainwp_api_sslVerifyCertificate").val(0); |
| 376 |
statusEl.fadeOut(); |
| 377 |
mainwp_extensions_savelogin(pObj, true); |
| 378 |
return false; |
| 379 |
} else { |
| 380 |
undefError = true; |
| 381 |
} |
| 382 |
} else { |
| 383 |
undefError = true; |
| 384 |
} |
| 385 |
|
| 386 |
if (undefError) { |
| 387 |
statusEl.find( '.text' ).html( __( 'Undefined error. Please try again.' ) ); |
| 388 |
} |
| 389 |
setTimeout( function () { |
| 390 |
statusEl.fadeOut(); |
| 391 |
}, 3000 ); |
| 392 |
|
| 393 |
}, 'json'); |
| 394 |
return false; |
| 395 |
} |
| 396 |
|
| 397 |
var maxActivateThreads = 8; |
| 398 |
var totalActivateThreads = 0; |
| 399 |
var currentActivateThreads = 0; |
| 400 |
var finishedActivateThreads = 0; |
| 401 |
var countSuccessActivation = 0; |
| 402 |
|
| 403 |
// Bulk grab API keys |
| 404 |
jQuery(document).on('click', '#mainwp-extensions-grabkeys', function () { |
| 405 |
mainwp_extensions_grabkeys(false); |
| 406 |
}); |
| 407 |
|
| 408 |
function mainwp_extensions_grabkeys(retring) { |
| 409 |
var grabingEl = jQuery("#mainwp-extensions-api-fields"); |
| 410 |
var master_api_key = grabingEl.find('#mainwp_com_api_key').val(); |
| 411 |
var statusEl = jQuery(".mainwp-extensions-api-loading"); |
| 412 |
var data = mainwp_secure_data({ |
| 413 |
action: 'mainwp_extension_testextensionapilogin', |
| 414 |
master_api_key: master_api_key |
| 415 |
}); |
| 416 |
|
| 417 |
if (master_api_key == '') { |
| 418 |
statusEl.find('.text').html(__("Main API Key is required.")); |
| 419 |
statusEl.addClass('yellow'); |
| 420 |
statusEl.fadeOut(); |
| 421 |
setTimeout(function () { |
| 422 |
statusEl.fadeOut(); |
| 423 |
}, 3000); |
| 424 |
} else { |
| 425 |
if (retring == true) { |
| 426 |
statusEl.find('.text').html(__("Connection error detected. The Verify Certificate option has been switched to NO. Retrying...")).fadeIn(); |
| 427 |
} else { |
| 428 |
statusEl.removeClass('red'); |
| 429 |
statusEl.removeClass('yellow'); |
| 430 |
statusEl.removeClass('green'); |
| 431 |
statusEl.find('.text').html( __('Validating. Please wait...')).show(); |
| 432 |
} |
| 433 |
statusEl.show(); |
| 434 |
jQuery.post(ajaxurl, data, function (response) { |
| 435 |
var undefError = false; |
| 436 |
if (response) { |
| 437 |
if (response.result == 'SUCCESS') { |
| 438 |
statusEl.addClass('green'); |
| 439 |
statusEl.find('.text').html('MainWP Main API Key is valid!').fadeIn(); |
| 440 |
setTimeout(function () { |
| 441 |
statusEl.fadeOut(); |
| 442 |
}, 3000); |
| 443 |
totalActivateThreads = jQuery('#mainwp-extensions-list .card[status="queue"]').length; |
| 444 |
console.log(totalActivateThreads); |
| 445 |
if (totalActivateThreads > 0) |
| 446 |
extensions_loop_next(); |
| 447 |
} else if (response.error) { |
| 448 |
statusEl.addClass('red'); |
| 449 |
statusEl.find('.text').html(response.error).fadeIn(); |
| 450 |
} else if (response.retry_action && response.retry_action == 1) { |
| 451 |
jQuery("#mainwp_api_sslVerifyCertificate").val(0); |
| 452 |
mainwp_extensions_grabkeys(true); |
| 453 |
return false; |
| 454 |
} else { |
| 455 |
undefError = true; |
| 456 |
} |
| 457 |
} else { |
| 458 |
undefError = true; |
| 459 |
} |
| 460 |
if (undefError) { |
| 461 |
statusEl.addClass('red'); |
| 462 |
statusEl.find('.text').html(__('Undefined error. Please try again.')).fadeIn(); |
| 463 |
} |
| 464 |
|
| 465 |
setTimeout(function () { |
| 466 |
statusEl.fadeOut(); |
| 467 |
}, 3000); |
| 468 |
}, 'json'); |
| 469 |
} |
| 470 |
return false; |
| 471 |
} |
| 472 |
|
| 473 |
extensions_loop_next = function () { |
| 474 |
while ((extToActivate = jQuery('#mainwp-extensions-list .card[status="queue"]:first')) && (extToActivate.length > 0) && (currentActivateThreads < maxActivateThreads)) { |
| 475 |
extensions_activate_next(extToActivate, true); |
| 476 |
} |
| 477 |
if ((finishedActivateThreads == totalActivateThreads) && (countSuccessActivation == totalActivateThreads)) { |
| 478 |
setTimeout(function () { |
| 479 |
location.href = 'admin.php?page=Extensions'; |
| 480 |
}, 2000); |
| 481 |
} |
| 482 |
}; |
| 483 |
|
| 484 |
extensions_activate_next = function (pObj, bulkAct) { |
| 485 |
|
| 486 |
var grabingEl = jQuery("#mainwp-extensions-api-fields"); |
| 487 |
var apiEl = pObj; |
| 488 |
var statusEl = apiEl.find(".activate-api-status"); |
| 489 |
var loadingEl = apiEl.find(".api-feedback"); |
| 490 |
|
| 491 |
var master_api_key = grabingEl.find('#mainwp_com_api_key').val(); |
| 492 |
|
| 493 |
apiEl.attr("status", "running"); |
| 494 |
|
| 495 |
var extensionSlug = apiEl.attr('extension-slug'); |
| 496 |
var data = mainwp_secure_data({ |
| 497 |
action: 'mainwp_extension_grabapikey', |
| 498 |
master_api_key: master_api_key, |
| 499 |
slug: extensionSlug |
| 500 |
}); |
| 501 |
|
| 502 |
currentActivateThreads++; |
| 503 |
|
| 504 |
loadingEl.show(); |
| 505 |
loadingEl.find('.message').removeClass('red green'); |
| 506 |
loadingEl.find('.message').html('<i class="notched circle loading icon"></i>' + __('Activating...')); |
| 507 |
|
| 508 |
if (apiEl.attr('license-status') == 'activated') { |
| 509 |
finishedActivateThreads++; |
| 510 |
currentActivateThreads--; |
| 511 |
loadingEl.find('.message').addClass('green'); |
| 512 |
loadingEl.find('.message').html(__('Already activated.')); |
| 513 |
countSuccessActivation++; |
| 514 |
if (bulkAct) { |
| 515 |
extensions_loop_next(); |
| 516 |
} |
| 517 |
return; |
| 518 |
} |
| 519 |
|
| 520 |
jQuery.post(ajaxurl, data, function (response) { |
| 521 |
finishedActivateThreads++; |
| 522 |
currentActivateThreads--; |
| 523 |
|
| 524 |
if (response) { |
| 525 |
if (response.result == 'SUCCESS') { |
| 526 |
countSuccessActivation++; |
| 527 |
loadingEl.find('.message').addClass('green'); |
| 528 |
loadingEl.find('.message').html(__('License activated.')); |
| 529 |
statusEl.html('<i class="green check icon"></i> License'); |
| 530 |
apiEl.find('.mainwp-extensions-deactivate-chkbox').attr('checked', false); |
| 531 |
if (!bulkAct) { |
| 532 |
setTimeout(function () { |
| 533 |
location.href = 'admin.php?page=Extensions'; |
| 534 |
}, 2000); |
| 535 |
} |
| 536 |
} else if (response.error) { |
| 537 |
loadingEl.find('.message').addClass('red'); |
| 538 |
loadingEl.find('.message').html(response.error); |
| 539 |
} else { |
| 540 |
loadingEl.find('.message').addClass('red'); |
| 541 |
loadingEl.find('.message').html(__('Undefined error. ')); |
| 542 |
} |
| 543 |
} else { |
| 544 |
loadingEl.find('.message').addClass('red'); |
| 545 |
loadingEl.find('.message').html(__('Undefined error. ')); |
| 546 |
} |
| 547 |
if (bulkAct) { |
| 548 |
extensions_loop_next(); |
| 549 |
} |
| 550 |
}, 'json'); |
| 551 |
}; |
| 552 |
|
| 553 |
jQuery(document).on('click', '#mainwp-extensions-bulkinstall', function () { |
| 554 |
var grabingEl = jQuery("#mainwp-extensions-api-fields"); |
| 555 |
var api_key = grabingEl.find('#mainwp_com_api_key').val().trim(); |
| 556 |
if (api_key == '') { |
| 557 |
mainwp_extension_grab_org_extensions(this); |
| 558 |
} else { |
| 559 |
mainwp_extension_grab_purchased(this, false); |
| 560 |
} |
| 561 |
}) |
| 562 |
|
| 563 |
mainwp_extension_grab_purchased = function (pObj, retring) { |
| 564 |
|
| 565 |
var grabingEl = jQuery("#mainwp-extensions-api-fields"); |
| 566 |
var api_key = grabingEl.find('#mainwp_com_api_key').val().trim(); |
| 567 |
|
| 568 |
var statusEl = jQuery(".mainwp-extensions-api-loading"); |
| 569 |
var data = mainwp_secure_data({ |
| 570 |
action: 'mainwp_extension_getpurchased', |
| 571 |
api_key: api_key |
| 572 |
}); |
| 573 |
|
| 574 |
|
| 575 |
if ( api_key == '' ) { |
| 576 |
statusEl.find('.text').html( __( "Main API Key is required." ) ); |
| 577 |
statusEl.show(); |
| 578 |
setTimeout(function () { |
| 579 |
statusEl.fadeOut(); |
| 580 |
}, 3000); |
| 581 |
} else { |
| 582 |
if ( retring == true ) { |
| 583 |
statusEl.find('.text').html( __( "Connection error detected. The Verify Certificate option has been switched to NO. Retrying..." ) ); |
| 584 |
setTimeout(function () { |
| 585 |
statusEl.fadeOut(); |
| 586 |
}, 3000); |
| 587 |
} else { |
| 588 |
statusEl.show(); |
| 589 |
statusEl.find( '.text' ).html( __( 'Loading extensions info...' ) ); |
| 590 |
jQuery.post(ajaxurl, data, function (response) { |
| 591 |
var undefError = false; |
| 592 |
if (response) { |
| 593 |
if (response.result == 'SUCCESS') { |
| 594 |
statusEl.hide(); |
| 595 |
jQuery('#mainwp-get-purchased-extensions-modal').modal({ |
| 596 |
allowMultiple: true, |
| 597 |
closable: false, |
| 598 |
onHide: function () { |
| 599 |
location.href = 'admin.php?page=Extensions'; |
| 600 |
} |
| 601 |
}).modal('show'); |
| 602 |
jQuery('#mainwp-get-purchased-extensions-modal').find('.content').html(response.data); |
| 603 |
if (jQuery('#extension_install_ext_slug').length > 0) { |
| 604 |
mainwp_extension_select_to_install(); |
| 605 |
} |
| 606 |
} else if (response.error) { |
| 607 |
statusEl.find( '.text' ).html(response.error); |
| 608 |
} else if (response.retry_action && response.retry_action == 1) { |
| 609 |
jQuery("#mainwp_api_sslVerifyCertificate").val(0); |
| 610 |
statusEl.fadeOut(); |
| 611 |
mainwp_extension_grab_purchased(pObj, true); |
| 612 |
return false; |
| 613 |
} else { |
| 614 |
undefError = true; |
| 615 |
} |
| 616 |
} else { |
| 617 |
undefError = true; |
| 618 |
} |
| 619 |
if ( undefError ) { |
| 620 |
statusEl.find( '.text' ).html( __( 'Undefined error occurred. Please try again.' ) ); |
| 621 |
} |
| 622 |
setTimeout(function () { |
| 623 |
statusEl.fadeOut(); |
| 624 |
}, 3000); |
| 625 |
}, 'json'); |
| 626 |
} |
| 627 |
} |
| 628 |
return false; |
| 629 |
} |
| 630 |
|
| 631 |
mainwp_extension_select_to_install = function () { |
| 632 |
var inst_ext = jQuery('.item.extension[slug="' + jQuery('#extension_install_ext_slug').val() + '"]'); |
| 633 |
console.log(inst_ext); |
| 634 |
if (jQuery(inst_ext).length > 0) { |
| 635 |
jQuery('mainwp-installing-extensions .ui.tab').removeClass('active'); |
| 636 |
var curtab = jQuery(inst_ext[0]).closest('.ui.tab').attr('data-tab'); |
| 637 |
jQuery('#mainwp-install-extensions-menu .item[data-tab=' + curtab + ']').trigger('click'); |
| 638 |
var install_chk = jQuery(inst_ext).find('input[type=checkbox]'); |
| 639 |
if (install_chk.length > 0) { |
| 640 |
jQuery(install_chk[0]).trigger('click'); |
| 641 |
} |
| 642 |
} |
| 643 |
} |
| 644 |
|
| 645 |
mainwp_extension_grab_org_extensions = function () { |
| 646 |
|
| 647 |
var statusEl = jQuery(".mainwp-extensions-api-loading"); |
| 648 |
var data = mainwp_secure_data({ |
| 649 |
action: 'mainwp_extension_getpurchased', |
| 650 |
}); |
| 651 |
|
| 652 |
statusEl.removeClass('green'); |
| 653 |
statusEl.removeClass('yellow'); |
| 654 |
statusEl.show(); |
| 655 |
statusEl.find('.text').html( __('Running. Please wait...')); |
| 656 |
jQuery.post(ajaxurl, data, function (response) { |
| 657 |
var undefError = false; |
| 658 |
if (response) { |
| 659 |
if (response.result == 'SUCCESS') { |
| 660 |
jQuery('#mainwp-get-purchased-extensions-modal').modal({ |
| 661 |
allowMultiple: true, |
| 662 |
closable: false, |
| 663 |
onHide: function () { |
| 664 |
location.href = 'admin.php?page=Extensions'; |
| 665 |
} |
| 666 |
}).modal('show'); |
| 667 |
jQuery('#mainwp-get-purchased-extensions-modal').find('.content').html(response.data); |
| 668 |
if (jQuery('#extension_install_ext_slug').length > 0) { |
| 669 |
mainwp_extension_select_to_install(); |
| 670 |
} |
| 671 |
statusEl.hide(); |
| 672 |
} else if (response.error) { |
| 673 |
statusEl.addClass('red'); |
| 674 |
statusEl.find('.text').html(response.error).fadeIn(); |
| 675 |
} else { |
| 676 |
undefError = true; |
| 677 |
} |
| 678 |
} else { |
| 679 |
undefError = true; |
| 680 |
} |
| 681 |
|
| 682 |
if (undefError) { |
| 683 |
statusEl.addClass('red'); |
| 684 |
statusEl.find('.text').html(__('Undefined error. Please try again.')).fadeIn(); |
| 685 |
} |
| 686 |
setTimeout(function () { |
| 687 |
statusEl.fadeOut(); |
| 688 |
}, 3000); |
| 689 |
}, 'json'); |
| 690 |
|
| 691 |
return false; |
| 692 |
} |
| 693 |
|
| 694 |
|
| 695 |
jQuery(document).on('click', '#mainwp-extensions-installnow', function () { |
| 696 |
mainwp_extension_bulk_install(); |
| 697 |
return false; |
| 698 |
}) |
| 699 |
|
| 700 |
bulkExtensionsMaxThreads = mainwpParams['maximumInstallUpdateRequests'] == undefined ? 3 : mainwpParams['maximumInstallUpdateRequests']; |
| 701 |
bulkExtensionsCurrentThreads = 0; |
| 702 |
bulkExtensionsTotal = 0; |
| 703 |
bulkExtensionsFinished = 0; |
| 704 |
bulkExtensionsRunning = false; |
| 705 |
|
| 706 |
mainwp_extension_bulk_install = function () { |
| 707 |
if (bulkExtensionsRunning) |
| 708 |
return; |
| 709 |
|
| 710 |
jQuery('.mainwp-installing-extensions input[type="checkbox"][status="queue"]:not(:checked)').closest('.extension-to-install').find('.installing-extension[status="queue"]').html('<span data-tooltip="Skipped" data-position="left center" data-inverted=""><i class="stop circle outline grey icon"></i></span>'); |
| 711 |
|
| 712 |
bulkExtensionsTotal = jQuery('.mainwp-installing-extensions input[type="checkbox"][status="queue"]:checked').length; |
| 713 |
|
| 714 |
if (bulkExtensionsTotal == 0) |
| 715 |
return false; |
| 716 |
|
| 717 |
jQuery('.mainwp-installing-extensions input[type="checkbox"][status="queue"]:checked').closest('.extension-to-install').find('.installing-extension[status="queue"]').html('<i class="clock outline icon"></i> ' + __('Queued')); |
| 718 |
|
| 719 |
mainwp_extension_bulk_install_next(); |
| 720 |
} |
| 721 |
|
| 722 |
mainwp_extension_bulk_install_next = function () { |
| 723 |
while ((extToInstall = jQuery('.mainwp-installing-extensions input[type="checkbox"][status="queue"]:checked:first').closest('.extension-to-install')) && (extToInstall.length > 0) && (bulkExtensionsCurrentThreads < bulkExtensionsMaxThreads)) { |
| 724 |
mainwp_extension_bulk_install_specific(extToInstall); |
| 725 |
} |
| 726 |
|
| 727 |
if ((bulkExtensionsTotal > 0) && (bulkExtensionsFinished == bulkExtensionsTotal)) { |
| 728 |
mainwp_extension_bulk_activate(); |
| 729 |
} |
| 730 |
} |
| 731 |
|
| 732 |
mainwp_extension_bulk_install_specific = function (pExtToInstall) { |
| 733 |
bulkExtensionsRunning = true; |
| 734 |
pExtToInstall.find('input[type="checkbox"]').attr('status', 'running'); |
| 735 |
bulkExtensionsCurrentThreads++; |
| 736 |
|
| 737 |
var statusEl = pExtToInstall.find('.installing-extension'); |
| 738 |
|
| 739 |
statusEl.html('<span data-tooltip="Installing extension. Please wait..." data-position="left center" data-inverted=""><i class="notched circle loading icon"></i></span>'); |
| 740 |
|
| 741 |
var data = mainwp_secure_data({ |
| 742 |
action: 'mainwp_extension_downloadandinstall', |
| 743 |
download_link: pExtToInstall.attr('download-link'), |
| 744 |
plugin_slug: pExtToInstall.attr('plugin-slug') |
| 745 |
}); |
| 746 |
|
| 747 |
jQuery.ajax({ |
| 748 |
type: 'POST', |
| 749 |
url: ajaxurl, |
| 750 |
data: data, |
| 751 |
success: function () { |
| 752 |
return function (res_data) { |
| 753 |
bulkExtensionsCurrentThreads--; |
| 754 |
bulkExtensionsFinished++; |
| 755 |
|
| 756 |
statusEl.html(''); |
| 757 |
|
| 758 |
var reg = new RegExp('<mainwp>(.*)</mainwp>'); |
| 759 |
var matches = reg.exec(res_data); |
| 760 |
var response = ''; |
| 761 |
|
| 762 |
if (matches) { |
| 763 |
response_json = matches[1]; |
| 764 |
response = JSON.parse(response_json); |
| 765 |
} |
| 766 |
|
| 767 |
if (response != '') { |
| 768 |
if (response.result == 'SUCCESS') { |
| 769 |
statusEl.html('<span data-tooltip="' + response.output + '" data-inverted="" data-position="left center"><i class="check green icon"></i></span>'); |
| 770 |
jQuery('.mainwp-installing-extensions').append('<span class="extension-installed-success" slug="' + response.slug + '"></span>') |
| 771 |
} else if (response.error) { |
| 772 |
statusEl.html('<span data-tooltip="' + response.error + '" data-inverted="" data-position="left center"><i class="times red icon"></i></span>'); |
| 773 |
} else { |
| 774 |
statusEl.html('<span data-tooltip="Undefined error occured. Please try again." data-inverted="" data-position="left center"><i class="times red icon"></i></span>'); |
| 775 |
} |
| 776 |
} else { |
| 777 |
statusEl.html('<span data-tooltip="Undefined error occured. Please try again." data-inverted="" data-position="left center"><i class="times red icon"></i></span>'); |
| 778 |
} |
| 779 |
|
| 780 |
mainwp_extension_bulk_install_next(); |
| 781 |
} |
| 782 |
}() |
| 783 |
}); |
| 784 |
|
| 785 |
return false; |
| 786 |
} |
| 787 |
|
| 788 |
mainwp_extension_bulk_activate = function () { |
| 789 |
var plugins = []; |
| 790 |
|
| 791 |
jQuery('.extension-installed-success').each(function () { |
| 792 |
plugins.push(jQuery(this).attr('slug')); |
| 793 |
}); |
| 794 |
|
| 795 |
if (plugins.length == 0) { |
| 796 |
mainwp_extension_bulk_install_done(); |
| 797 |
return; |
| 798 |
} |
| 799 |
|
| 800 |
var data = mainwp_secure_data({ |
| 801 |
action: 'mainwp_extension_bulk_activate', |
| 802 |
plugins: plugins |
| 803 |
}); |
| 804 |
|
| 805 |
var statusEl = jQuery('#mainwp-bulk-activating-extensions-status'); |
| 806 |
|
| 807 |
statusEl.html('<i class="notched circle loading icon"></i>' + __('Activating extensions. Please wait...')).show(); |
| 808 |
jQuery.post(ajaxurl, data, function (response) { |
| 809 |
statusEl.html(''); |
| 810 |
if (response == 'SUCCESS') { |
| 811 |
statusEl.addClass('green'); |
| 812 |
statusEl.html(__('Extensions have been activated successfully!')); |
| 813 |
statusEl.fadeOut(3000); |
| 814 |
} |
| 815 |
mainwp_extension_bulk_install_done(); |
| 816 |
}); |
| 817 |
} |
| 818 |
|
| 819 |
mainwp_extension_bulk_install_done = function () { |
| 820 |
bulkExtensionsRunning = false; |
| 821 |
|
| 822 |
var statusEl = jQuery('#mainwp-bulk-activating-extensions-status'); |
| 823 |
|
| 824 |
statusEl.addClass('green'); |
| 825 |
statusEl.html(__("Installation completed successfully. Page will reload automatically in 3 seconds.")).show(); |
| 826 |
if (jQuery('.extension-installed-success').length == bulkExtensionsFinished) { |
| 827 |
setTimeout(function () { |
| 828 |
location.href = 'admin.php?page=Extensions'; |
| 829 |
}, 3000); |
| 830 |
} |
| 831 |
} |
| 832 |
|
| 833 |
|
| 834 |
// Is this function still in use??? |
| 835 |
jQuery(document).on('click', '#mainwp-extensions-api-sslverify-certificate', function () { |
| 836 |
|
| 837 |
var parent = jQuery(this).closest(".extension_api_sslverify_loading"); |
| 838 |
var statusEl = parent.find('span.status'); |
| 839 |
var loadingEl = parent.find("i"); |
| 840 |
|
| 841 |
var data = mainwp_secure_data({ |
| 842 |
action: 'mainwp_extension_apisslverifycertificate', |
| 843 |
api_sslverify: jQuery("#mainwp_api_sslVerifyCertificate").val() |
| 844 |
}); |
| 845 |
|
| 846 |
statusEl.hide(); |
| 847 |
loadingEl.show(); |
| 848 |
jQuery.post(ajaxurl, data, function (response) { |
| 849 |
loadingEl.hide(); |
| 850 |
var undefError = false; |
| 851 |
if (response) { |
| 852 |
if (response.saved) { |
| 853 |
statusEl.css('color', '#0074a2'); |
| 854 |
statusEl.html('MainWP Main API Key saved!').fadeIn(); |
| 855 |
setTimeout(function () { |
| 856 |
statusEl.fadeOut(); |
| 857 |
}, 3000); |
| 858 |
} else if (response.error) { |
| 859 |
statusEl.css('color', 'red'); |
| 860 |
statusEl.html(response.error).fadeIn(); |
| 861 |
} else { |
| 862 |
undefError = true; |
| 863 |
} |
| 864 |
} else { |
| 865 |
undefError = true; |
| 866 |
} |
| 867 |
|
| 868 |
if (undefError) { |
| 869 |
statusEl.css('color', 'red'); |
| 870 |
statusEl.html('<i class="exclamation circle icon"></i> Undefined error!').fadeIn(); |
| 871 |
} |
| 872 |
}, 'json'); |
| 873 |
return false; |
| 874 |
}); |
| 875 |
|
| 876 |
jQuery(document).ready(function ($) { |
| 877 |
jQuery(document).on('click', '#mainwp-check-all-sync-ext', function () { |
| 878 |
$('.sync-ext-row').find("input:checkbox").each(function () { |
| 879 |
$(this).attr('checked', true); |
| 880 |
}); |
| 881 |
}); |
| 882 |
jQuery(document).on('click', '#mainwp-uncheck-all-sync-ext', function () { |
| 883 |
$('.sync-ext-row').find("input:checkbox").each(function () { |
| 884 |
$(this).attr('checked', false); |
| 885 |
}); |
| 886 |
}); |
| 887 |
|
| 888 |
jQuery(document).on('click', '.mainwp-show-extensions', function () { |
| 889 |
$('a.mainwp-show-extensions').removeClass('mainwp_action_down'); |
| 890 |
$(this).addClass('mainwp_action_down'); |
| 891 |
|
| 892 |
var gr = $(this).attr('group'); |
| 893 |
var selectedEl = $('#mainwp-available-extensions-list .mainwp-availbale-extension-holder.group-' + gr); |
| 894 |
var installedGroup = $('.installed-group-exts'); |
| 895 |
installedGroup.hide(); |
| 896 |
|
| 897 |
if (gr == 'all') { |
| 898 |
$('#mainwp-available-extensions-list .mainwp-availbale-extension-holder').fadeIn(500); |
| 899 |
} else { |
| 900 |
$('#mainwp-available-extensions-list .mainwp-availbale-extension-holder').hide(); |
| 901 |
if (selectedEl.length > 0) { |
| 902 |
selectedEl.fadeIn(500); |
| 903 |
} else { |
| 904 |
installedGroup.fadeIn(500); |
| 905 |
} |
| 906 |
} |
| 907 |
|
| 908 |
return false; |
| 909 |
}); |
| 910 |
}); |
| 911 |
|