PageSourceSearch

https://www.vaisulweb.com/wp-content/plugins/wp-domain-checker/assets/js/wdc-style-2.js

js vaisulweb.com collected 2026-10-09 00:12:16 UTC 20,566 bytes, 434 lines download raw bytes

1/**
2 * WP Domain Checker - Style 2 Dedicated AJAX Script
3 * Complete AJAX functionality specifically for Style 2
4 */
5
6jQuery(document).ready(function() {
7    'use strict';
8
9    // Responsive handling for Style 2
10    var form = jQuery('[id="wdc-slider"]');
11    if (jQuery(form).length > 0) {
12        jQuery.each(form, function(x, y) {
13            if (jQuery(y).width() < 500) {
14                jQuery(y).addClass('wdc-resp');
15            }
16        });
17    }
18
19    // Main form submission handler for Style 2 - Updated for theme system
20    jQuery("div[class*='wdc-form'][data-wdc-style='2']").on("submit", function() {
21        var form = this;
22        var z = jQuery(".g-recaptcha-response", form).attr('id');
23        
24        // Hide error messages
25        jQuery(".req-domain-text", form).hide();
26        jQuery(".recaptcha-text", form).hide();
27
28        if (z !== undefined) {
29            z = z.match(/\d+/);
30            if (z === null) {
31                z = 0;
32            } else {
33                z = z[0];
34            }
35        }
36
37        // Check if domain field is empty
38        if (jQuery("input[name='domain']", form).val() === "") {
39            jQuery(".req-domain-text", form).css("display", "block");
40            return false;
41        }
42
43        var enable = jQuery('.g-recaptcha', form).length;
44        var invis = jQuery("div[id='wdc-recaptcha']", form).attr('data-size');
45        
46        // Handle reCAPTCHA validation
47        if (enable > 0 && invis === 'invisible' && grecaptcha.getResponse(z) === '') {
48            grecaptcha.execute(z);
49            return false;
50        } else if (enable > 0) {
51            var action = 'wdc_recaptcha';
52            var recaptcha_response = jQuery("textarea[name='g-recaptcha-response']", form).val();
53            if (recaptcha_response === '') {
54                jQuery(".recaptcha-text", form).show();
55                return false;
56            }
57
58            var recaptcha_data = {
59                'action': action,
60                'response': recaptcha_response,
61                'security': wdc_ajax.wdc_nonce
62            };
63
64            jQuery.ajax({
65                type: "GET",
66                url: wdc_ajax.ajaxurl,
67                action: action,
68                data: recaptcha_data,
69                success: function(response_y) {
70                    var y = JSON.parse(response_y);
71
72                    if (y.success === false && y["error-codes"] === '') {
73                        jQuery("div[id='loading']", form).hide();
74                        jQuery(".recaptcha-text", form).show();
75                        return eval(grecaptcha.reset(z));
76                    } else if (y.success === false && y["error-codes"] == 'missing-input-secret') {
77                        jQuery("div[id='loading']", form).hide();
78                        jQuery("div[id='results']", form).html('<p class="not-available">The secret parameter is missing.</p>');
79                        return eval(grecaptcha.reset(z));
80                    } else if (y.success === false && y["error-codes"] == 'invalid-input-secret') {
81                        jQuery("div[id='loading']", form).hide();
82                        jQuery("div[id='results']", form).html('<p class="not-available">The secret parameter is invalid or malformed.</p>');
83                        return eval(grecaptcha.reset(z));
84                    } else if (y.success === false && y["error-codes"] == 'missing-input-response') {
85                        jQuery("div[id='loading']", form).hide();
86                        jQuery("div[id='results']", form).html('<p class="not-available">The response parameter is missing.</p>');
87                        return eval(grecaptcha.reset(z));
88                    } else if (y.success === false && y["error-codes"] == 'invalid-input-response') {
89                        jQuery("div[id='loading']", form).hide();
90                        jQuery("div[id='results']", form).html('<p class="not-available">The response parameter is invalid or malformed.</p>');
91                        return eval(grecaptcha.reset(z));
92                    }
93                    
94                    if (wdcWhoisLookupOnlyStyle2(form)) {
95                        return false;
96                    } else {
97                        wdcAjaxCheckDomainStyle2(form);
98                        jQuery("div[id='loading']", form).show();
99                    }
100                    return false;
101                }
102            });
103        } else {
104            if (wdcWhoisLookupOnlyStyle2(form)) {
105                return false;
106            } else {
107                wdcAjaxCheckDomainStyle2(form);
108                jQuery("div[id='loading']", form).show();
109            }
110        }
111
112        // Show loading and disable button
113        // jQuery("div[id='loading']", form).show();
114        jQuery("#Submit", form).prop("disabled", true);
115
116        if (enable > 0) {
117            eval(grecaptcha.reset(z));
118        }
119        return false;
120    });
121});
122
123/**
124 * WHOIS lookup function for Style 2
125 */
126function wdcWhoisLookupOnlyStyle2(form) {
127    var domain = jQuery("input[name='domain']", form).val();
128    if (jQuery("input[name='whoislookuponly']", form).val() === "yes") {
129        jQuery("div[id='loading']", form).show();
130        jQuery("div[id='results'] pre[id='wdc-whois']", form).hide();
131        var data = {
132            'action': 'wdc_whois_domain',
133            'domain': domain,
134            'security': wdc_ajax.wdc_nonce
135        };
136        jQuery.post(wdc_ajax.ajaxurl, data, function(r) {
137            var response = r.data;
138            var whois = response.whois;
139            var resultsContainer = jQuery("div[id='results']", form);
140            
141            jQuery("h3[class='wdc-result-subhead']", form).hide();
142            resultsContainer.show();
143            
144            if (typeof whois === 'object') {
145                var whoisHTML = wdcRenderWhois(whois);
146                resultsContainer.html(whoisHTML);
147            } else {
148                // Fallback for plain text whois
149                resultsContainer.html('<div class="wdc-whois-section"><h3>Whois Information</h3><div class="wdc-whois-grid"><pre>' + whois + '</pre></div></div>');
150            }
151        }).always(function() {
152            // Smooth transition for WHOIS results
153            jQuery("div[id='loading']", form).fadeOut(200, function() {
154                jQuery("div[class='wdc-container wdc-mt-5 wdc-mb-5']", form).fadeIn(200);
155            });
156            jQuery("#Submit", form).removeAttr('disabled');
157        });
158        return true;
159    }
160    return false;
161}
162
163/**
164 * Main AJAX domain check function for Style 2
165 */
166function wdcAjaxCheckDomainStyle2(form) {
167    var domain = jQuery("input[name='domain']", form).val();
168    var item_id = jQuery("input[name='item_id']", form).val();
169    var url = jQuery("input[name='url']", form).val();
170    var allowed_tld = jQuery("input[name='allowed_tld']", form).val();
171    var integration = jQuery("input[name='integration']", form).val();
172    var available_msg = jQuery("input[name='available_msg']", form).val();
173    var unavailable_msg = jQuery("input[name='unavailable_msg']", form).val();
174    var whois_button = jQuery("input[name='whois_button']", form).val();
175    var custom_price = jQuery("input[name='custom_price']", form).val();
176    var tld = jQuery("input[name='tld']", form).val();
177    var multiple_tld = jQuery("input[name='multiple_tld']", form).val();
178
179    if (url.length > 0) {
180        item_id = url;
181    }
182    
183    jQuery("div[class='wdc-heading']", form).show('slow');
184    jQuery("span[class='wdc-heading-query']", form).text(jQuery("input[name='domain']", form).val());
185    jQuery("div[id='results']", form).hide().html('');
186
187    var data = {
188        'action': 'wdc_check_domain',
189        'domain': domain,
190        'item_id': item_id,
191        'allowed_tld': allowed_tld,
192        'multiple_tld': multiple_tld,
193        'tld': tld,
194        'security': wdc_ajax.wdc_nonce
195    };
196
197    jQuery.post(wdc_ajax.ajaxurl, data, function(response) {
198        response = response.data;
199        jQuery("#Submit", form).removeAttr('disabled');
200
201        jQuery.each(response.ascii_tld, function(i, data) {
202            var x = data;
203            var pre_result = '<div id="wdc-tld-' + x + '" class="wdc-domain-result__list"></div>';
204            jQuery("div[id='results']", form).append(pre_result);
205
206            // Show results container on first iteration
207            if (i === 0) {
208                jQuery("div[id='results']", form).fadeIn(200);
209                
210            }
211
212            domain = response.domain + '.' + data;
213            idn = response.idn + '.' + response.tld[i];
214            
215            var data = {
216                'action': 'wdc_display',
217                'domain': domain,
218                'idn': idn,
219                'item_id': item_id,
220                'allowed_tld': allowed_tld,
221                'tld': tld,
222                'punny_tld': response.tld[i],
223                'security': wdc_ajax.wdc_nonce,
224                'integration': integration,
225                'available_msg': wdcEscapeHTMLStyle2(available_msg),
226                'unavailable_msg': wdcEscapeHTMLStyle2(unavailable_msg),
227                'whois_button': wdcEscapeHTMLStyle2(whois_button),
228                'custom_price': custom_price
229            };
230
231            jQuery.post(wdc_ajax.ajaxurl, data, function(r) {
232                response = r.data;
233                var ascii_tld = response.ascii_tld;
234                var result_text = wdcTemplateStyle2(response);
235
236                // Smooth transition: fade in result as it's added
237                var $resultContainer = jQuery("div[id='results'] div[id='wdc-tld-" 
237+ ascii_tld + "']", form);
238                $resultContainer.append(result_text);
239
240                // Fade in the new result item smoothly
241                $resultContainer.find('.wdc-domain-result__button:last').hide().fadeIn(300);
242            }).always(function() {
243                jQuery("div[id='loading']", form).fadeOut(50);
244                // Ensure container is visible and button is re-enabled
245                jQuery("div[class='wdc-container wdc-mt-5 wdc-mb-5']", form).fadeIn(200);
246
247                // Re-enable button
248                jQuery("#Submit", form).removeAttr('disabled');
249            });
250        });
251    });
252}
253
254/**
255 * Template function specifically for Style 2
256 */
257function wdcTemplateStyle2(response) {
258    var result_text = '';
259    var sld = response.domain.split('.');
260
261    if (response.status === 0) {
262        // Domain is taken/unavailable
263        result_text = '<div name="button" class="wdc-domain-result__button"><div protocol="' + response.protocol + '" class="wdc-row wdc-grid">    <div class="wdc-col-6 wdc-grid-item wdc-text-left"><span class="wdc-domain-name">' + sld[0] + '.<strong>' + response.tld + '</strong></span>    </div>    <div class="wdc-col-6 wdc-grid-item wdc-grid-price wdc-text-right"><span class="wdc-domain-price">' + response.result_text + '</span> <a href="' + response.additional_button.url + '" target="' + (response.additional_button.newtab ? '_blank' : '_self') + '" class="'+response.additional_button.class+' wdc-domain-unavailable"><button type="button" class="btn">' + response.additional_button.text + '</button></a>    </div></div></div>';
264
265    } else if (response.status === 1) {
266        // Domain is available
267        result_text = '<div name="button" class="wdc-domain-result__button"><div protocol="' + response.protocol + '" class="wdc-row wdc-grid">    <div class="wdc-col-6 wdc-grid-item wdc-text-left"><span class="wdc-domain-name">' + sld[0] + '.<strong>' + response.tld + '</strong></span>    </div>    <div class="wdc-col-6 wdc-grid-item wdc-grid-price wdc-text-right">      <span class="wdc-domain-price">' + response.result_text + ' ' + response.additional_button.price + '</span>' + response.whmcs + '      <a href="' + response.additional_button.url + '" data-product_id="' + response.additional_button.product_id + '" data-domain="' + response.domain + '" class="'+(response.additional_button.text.length ? '' : 'icon-only') + ' wdc-domain-available ' + response.additional_button.class + '" ' + response.additional_button.attribute + ' target="' + (response.additional_button.newtab ? '_blank' : '_self') + '"><button type="button" class="btn">'+wdc_config_js.buy_button_icon+'<span>' + response.additional_button.text + '</span></button></a>    </div></div></div>';
268
269    } else if (response.status === 2) {
270        // Domain not found or error
271        result_text = '<div name="button" class="wdc-domain-result__button"><div protocol="' + response.protocol + '" class="wdc-row wdc-grid">    <div class="wdc-col-6 wdc-grid-item wdc-text-left"><span class="wdc-domain-name">' + response.result_text + '</span>    </div>   <!-- <div class="wdc-col-6 wdc-grid-item wdc-text-right"><span class="wdc-domain-price">' + response.result_text + '</span>    </div> --></div></div>';
272
273    } else if (response.status === 3) {
274        // General error
275        // result_text = '<div name="button" class="wdc-domain-result__button"><div protocol="' + response.protocol + '" class="wdc-row wdc-grid">    <div class="wdc-col-6 wdc-grid-item wdc-text-left"><span class="wdc-domain-name">' + response.result_text + '</span>    </div>   <!-- <div class="wdc-col-6 wdc-grid-item wdc-text-right"><span class="wdc-domain-price">' + response.result_text + '</span>    </div>--></div></div>';
276    }
277    
278    return result_text;
279}
280
281/**
282 * Input validation for Style 2
283 */
284jQuery("input[id*='Search']").each(function() {
285    // Only apply to Style 2 forms
286    if (jQuery(this).closest('[data-wdc-style="2"]').length === 0) {
287        return;
288    }
289    
290    jQuery(this).keypress(function(e) {
291        if (e.keyCode === 8) {
292            return true;
293        }
294        var regex = new RegExp("^[\x7f-\xffa-z\u0400-\u04FFA-Z0-9\-\.]+$");
295        var str = String.fromCharCode(!e.charCode ? e.which : e.charCode);
296        if (regex.test(str)) {
297            return true;
298        }
299        if (e.which == 13) {
300            jQuery(this).submit();
301            return false;
302        }
303
304        e.preventDefault();
305        return false;
306    });
307
308    jQuery(this).bind('change', function(){
309        jQuery(this).val(function(_, v){
310            var ipv4v6 = new RegExp("^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:)))(%.+)?\s*$");
311
312            if (ipv4v6.test(v)) {
313                return v;
314            }
315            
316            return v.replace(/[\s+!@#$%^&*()_+=\[\]\{\}\;\'\\\:\"\|\,\/\<\?\"\>]/g, '');
317        });
318    });
319});
320
321/**
322 * HTML escape function for Style 2
323 */
324const wdcEscapeHTMLStyle2 = str => str.replace(/['"]/g,
325  tag => ({
326      "'": '&#39;',
327      '"': '&quot;'
328    }[tag]));
329
330function wdcRenderWhois(whoisData) {
331    var html = '<div class="wdc-whois-container">';
332    
333    if(whoisData == null){
334        html += '<div class="wdc-style-1-clean-error-message req-domain-text show" style="display: block;">Unable to retrieve WHOIS information at the moment. Please try again later.</div>';
335        html += '</div>';
336        return html;
337    }
338
339    if(whoisData.registrar_info.length === 0){
340        html += '<div class="wdc-style-1-clean-error-message req-domain-text show" style="display: block;"> Looks like this domain has not been registered yet.</div>';
341        html += '</div>';
342        return html;
343    }
344
345    // Helper function to render a section
346    function renderSection(title, data) {
347        if (!data || Object.keys(data).length === 0) return '';
348
349        var sectionHtml = '<div class="wdc-whois-section">';
350        sectionHtml += '<h3>' + title + '</h3>';
351        sectionHtml += '<div class="wdc-whois-grid">';
352
353        for (var key in data) {
354            if (data.hasOwnProperty(key)) {
355                var value = data[key];
356                if (typeof value === 'object' && value !== null) {
357                    // Handle nested objects (like contacts)
358                    sectionHtml += '<div class="wdc-whois-grid-item full-width">';
359                    sectionHtml += '<h4>' + key + '</h4>';
360                    sectionHtml += '<div class="wdc-whois-grid nested">';
361                    for (var subKey in value) {
362                        if (value.hasOwnProperty(subKey)) {
363                            sectionHtml += '<div class="wdc-whois-grid-item">';
364                            sectionHtml += '<span class="wdc-whois-label">' + subKey + '</span>';
365                            sectionHtml += '<span class="wdc-whois-value">' + value[subKey] + '</span>';
366                            sectionHtml += '</div>';
367                        }
368                    }
369                    sectionHtml += '</div></div>';
370                } else {
371                    sectionHtml += '<div class="wdc-whois-grid-item">';
372                    sectionHtml += '<span class="wdc-whois-label">' + key + '</span>';
373                    sectionHtml += '<span class="wdc-whois-value">' + value + '</span>';
374                    sectionHtml += '</div>';
375                }
376            }
377        }
378        sectionHtml += '</div></div>';
379        return sectionHtml;
380    }
381
382    // Helper function for rendering Nameservers
383    function renderNameservers(title, data) {
384        if (!data || data.length === 0) return '';
385
386        var sectionHtml = '<div class="wdc-whois-section">';
387        sectionHtml += '<h3>' + title + '</h3>';
388        sectionHtml += '<div class="wdc-whois-nameservers">';
389		
390        data.forEach(function(server) {
391            sectionHtml += '<div class="wdc-whois-nameserver-item">';
392            sectionHtml += '<span class="wdc-whois-value">' + server.hostname + '</span>';
393            sectionHtml += '</div>';
394        });
395
396        sectionHtml += '</div></div>';
397        return sectionHtml;
398    }
399    
400    // Render all sections
401    html += renderSection('Registrar Information', whoisData.registrar_info);
402
403    // Render registrar contacts, which is an object of objects
404    if (whoisData.registrar_contacts && Object.keys(whoisData.registrar_contacts).length > 0) {
405        var registrarContactsHtml = '<div class="wdc-whois-section"><h3>Registrar Contacts</h3>';
406        for (var contactName in whoisData.registrar_contacts) {
407            if (whoisData.registrar_contacts.hasOwnProperty(contactName)) {
408                registrarContactsHtml += renderSection(contactName, whoisData.registrar_contacts[contactName]);
409            }
410        }
411        registrarContactsHtml += '</div>';
412        html += registrarContactsHtml.replace(/<h3>.*?<\/h3>/, ''); // Remove redundant sub-headings
413    }
414    
415    // Render domain contacts
416    if (whoisData.domain_contacts && Object.keys(whoisData.domain_contacts).length > 0) {
417        var domainContactsHtml = '<div class="wdc-whois-section"><h3>Domain Contacts</h3>';
418        for (var contactName in whoisData.domain_contacts) {
419            if (whoisData.domain_contacts.hasOwnProperty(contactName)) {
420                domainContactsHtml += renderSection(contactName, whoisData.domain_contacts[contactName]);
421            }
422        }
423        domainContactsHtml += '</div>';
424        html += domainContactsHtml.replace(/<h3>.*?<\/h3>/, ''); // Remove redundant sub-headings
425    }
426
427    html += renderSection('Basic Information', whoisData.basic_info);
428    html += renderSection('Important Dates', whoisData.important_dates);
429    html += renderNameservers('Nameservers', whoisData.nameservers);
430
431
432    html += '</div>';
433    return html;
434}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.