Файл: WHMCS TEMPLATE/cloudmewhmcs/js/domainchecker.js
Строк: 218
<?php
/**
* Javascript functions used in the domain checker to power
* search, suggestions and whois functionality.
*
* @file WHMCS Domain Checker Javascript Functions
* @copyright Copyright 2015 WHMCS Limited
*/
jQuery('#frmDomainChecker').submit(function (e) {
e.preventDefault();
var invalidDomainCharacters = /[s=_!"#%&'*{},/:;?()[]@\$^*+<>~`u00a1u00a7u00b6u00b7u00bfu037eu0387u055a-u055fu0589u05c0u05c3u05c6u05f3u05f4u0609u060au060cu060du061bu061eu061fu066a-u066du06d4u0700-u070du07f7-u07f9u0830-u083eu085eu0964u0965u0970u0af0u0df4u0e4fu0e5au0e5bu0f04-u0f12u0f14u0f85u0fd0-u0fd4u0fd9u0fdau104a-u104fu10fbu1360-u1368u166du166eu16eb-u16edu1735u1736u17d4-u17d6u17d8-u17dau1800-u1805u1807-u180au1944u1945u1a1eu1a1fu1aa0-u1aa6u1aa8-u1aadu1b5a-u1b60u1bfc-u1bffu1c3b-u1c3fu1c7eu1c7fu1cc0-u1cc7u1cd3u2016u2017u2020-u2027u2030-u2038u203b-u203eu2041-u2043u2047-u2051u2053u2055-u205eu2cf9-u2cfcu2cfeu2cffu2d70u2e00u2e01u2e06-u2e08u2e0bu2e0e-u2e16u2e18u2e19u2e1bu2e1eu2e1fu2e2a-u2e2eu2e30-u2e39u3001-u3003u303du30fbua4feua4ffua60d-ua60fua673ua67eua6f2-ua6f7ua874-ua877ua8ceua8cfua8f8-ua8faua92eua92fua95fua9c1-ua9cdua9deua9dfuaa5c-uaa5fuaadeuaadfuaaf0uaaf1uabebufe10-ufe16ufe19ufe30ufe45ufe46ufe49-ufe4cufe50-ufe52ufe54-ufe57ufe5f-ufe61ufe68ufe6aufe6buff01-uff03uff05-uff07uff0auff0cuff0euff0fuff1auff1buff1fuff20uff3cuff61uff64uff65]+/g;
var invalidDomainError = jQuery("#invalidDomainError");
var stepResults = jQuery("#stepResults");
var pricingTable = jQuery("#pricingTable");
var primarySearchResults = jQuery("#primarySearchResults");
var currencyChoice = jQuery('.currencychooser');
var reCaptchaValue = jQuery('#g-recaptcha-response');
var captchaValue = jQuery('#inputCaptcha');
var captchaImage = jQuery('#inputCaptchaImage');
var captchaResponse = '';
var domainInput = jQuery("#inputDomain").val()
.replace(/^s+|s+$/, '')
.toLocaleLowerCase();
invalidDomainCharacters.lastIndex = undefined;
// validate domain input
if (!domainInput) {
showDomainWarning("#searchTermRequired");
return;
} else if (invalidDomainCharacters.test(domainInput)) {
showDomainWarning("#invalidChars");
return;
}
if (reCaptchaValue.length) {
captchaResponse = "&g-recaptcha-response=" + reCaptchaValue.val();
} else if (captchaValue.length) {
captchaResponse = "&code=" + captchaValue.val();
}
jQuery("#btnCheckAvailability").html('<i class="fa fa-spinner fa-spin"></i>');
// perform spin
jQuery.post(
"domainchecker.php",
"responseType=json&token=" + csrfToken + "&domain=" + domainInput + captchaResponse,
function(data) {
jQuery("#btnCheckAvailability").html(langSearch);
var hasError = false;
if (!data.validDomain) {
// domain was invalid
invalidDomainError.html(data.errorMsg);
showDomainWarning("#invalidDomainError");
primarySearchResults.hide();
hasError = true;
}
if (data.output) {
if (!hasError) {
jQuery(".domain-checker-error").slideUp();
}
stepResults.html(data.output);
currencyChoice.hide();
pricingTable.hide();
if (!stepResults.is(":visible")) {
stepResults.hide().removeClass('hidden').fadeIn("slow");
}
}
if (typeof grecaptcha !== 'undefined' && reCaptchaValue.val() != '') {
grecaptcha.reset();
}
if (captchaImage.length) {
captchaImage.attr("src", "includes/verifyimage.php?timestamp=" + new Date().getTime());
captchaValue.val('');
}
},
'json'
);
});
jQuery(document).ready(function() {
var inputBulkDomains = jQuery('#inputBulkDomains');
if (inputBulkDomains.val() === '') {
inputBulkDomains.val(langBulkPlaceholder)
.css('color', '#ccc');
}
inputBulkDomains.focus(function() {
if (jQuery(this).val() === langBulkPlaceholder) {
jQuery(this).val('')
.css('color', '#000');
}
});
inputBulkDomains.blur(function() {
if (jQuery(this).val() === '') {
jQuery(this).val(langBulkPlaceholder)
.css('color', '#ccc');
}
});
});
function addToCart(clickedBtn, performAvailabilityCheck, orderType, years) {
var selectedDomain = jQuery(clickedBtn).closest('tr')
.find('td:first strong')
.html();
var appendYears = '';
if (typeof years != "undefined") {
clickedBtn = jQuery(clickedBtn).closest('div')
.find('button:first');
appendYears = '®_period=' + years;
}
var cartDropDown = jQuery(clickedBtn).closest('div')
.find('button.additional-options');
if (typeof cartDropDown != "undefined") {
jQuery(cartDropDown).attr('disabled', 'disabled');
}
jQuery(clickedBtn).attr('disabled', 'disabled')
.html('<span class="glyphicon glyphicon-shopping-cart"></span> ' + langAdding + '...');
jQuery.post(
"domainchecker.php",
"addtocart=1&check=" + performAvailabilityCheck + "&token=" + csrfToken + "&domain=" + selectedDomain + "&orderType=" + orderType + appendYears,
function(data) {
if (data == 1) {
jQuery("#cartItemCount").html(((jQuery("#cartItemCount").html() * 1) + 1));
jQuery(clickedBtn).html('<span class="glyphicon glyphicon-shopping-cart"></span> ' + langAdded);
jQuery("#btnCheckout").fadeIn();
} else if (data == 2) {
jQuery("#modalCheckUnavailable").modal('show');
jQuery(clickedBtn).html(langUnavailable);
} else if (data == 3) {
jQuery("#modalAlreadyInCart").modal('show');
} else {
jQuery("#modalAddToCartError").modal('show');
}
});
}
function showMoreSuggestions() {
showCount = 0;
jQuery("#suggestionResults tbody tr").each(function(index) {
if (jQuery(this).hasClass('hidden')) {
if (showCount < 10) {
jQuery(this).hide().removeClass('hidden').fadeIn();
showCount++;
}
}
});
if (!jQuery("#suggestionResults tbody tr").hasClass('hidden')) {
jQuery("#trNoMoreSuggestions").fadeIn();
jQuery("#btnMoreSuggestions").fadeOut();
}
}
function showDomainWarning(id) {
if (jQuery(".domain-checker-error").is(":visible")) {
jQuery(".domain-checker-error").hide();
jQuery(id).removeClass("hidden").show();
} else {
if (!jQuery(id).is(":visible")) {
jQuery(id).hide()
.removeClass("hidden")
.fadeIn("fast");
}
}
}
function viewWhois(domain) {
jQuery("#modalWhoisLoader").removeClass('hidden').show();
jQuery("#modalWhoisBody").hide();
jQuery("#whoisDomainName").html(domain);
jQuery("#modalWhois").modal('show');
jQuery.post("whois.php", "domain=" + domain,
function(data) {
jQuery("#modalWhoisBody").html(data);
jQuery("#modalWhoisLoader").hide();
jQuery("#modalWhoisBody").show();
});
}
?>