PageSourceSearch

https://parsvds.com/wp-content/themes/bink/js/CheckDomain.js?ver=23222222323232

js parsvds.com collected 2026-10-05 18:13:23 UTC 14,198 bytes, 427 lines download raw bytes

1(function ($) {
2    "use strict";
3  
4    const popularDomains = ["blog", "com", "net", "org", "info"];
5    const offerDomains = ["xyz", "shop", "cfd", "sbs", "cyou"];
6  
7 
8
9const domainPrice = {
10  ir: "119,000",
11  com: "2,999,000",
12  sbs: "699,000",
13  cyou: "699,000",
14  shop: "649,000",
15  cfd: "699,000",
16  xyz: "899,000",
17  info: "1,499,000",
18  net: "3,730,000",
19  world: "13,325,000",
20  org: "3,730,000",
21  wiki: "11,375,000",
22  trade: "8,775,000",
23  website: "9,750,000",
24  site: "13,800,000",
25  link: "2,760,000",
26  app: "5,850,000",
27  fans: "3,575,000",
28  blog: "8,125,000",
29  cafe: "16,900,000",
30  cheap: "12,000,000",
31  club: "6,980,000",
32  lol: "10,620,000",
33  click: "3,000,000",
34  email: "10,560,000",
35  band: "10,700,000",
36  futbol: "5,850,000",
37  group: "8,770,000",
38  icu: "6,825,000",
39  help: "10,725,000",
40  dev: "5,000,000",
41  land: "12,350,000",
42  makeup: "5,720,000",
43  marketing: "13,975,000",
44  market: "14,450,000",
45  me: "8,125,000",
46  name: "3,300,000",
47  one: "12,600,000",
48  online: "13,800,000",
49  pw: "7,960,000",
50  monster: "5,550,000",
51  quest: "5,720,000",
52  skin: "5,720,000",
53  video: "12,000,000",
54  vip: "7,897,000",
55  co: "12,675,000",
56  work: "4,460,000",
57  blue: "8,600,000",
58  asia: "4,550,000"
59};
60  
61  
62    const allDomains = [
63      "ir", "com", "net", "org", "info", "monster", "website", "site", "link",
64      "app", "asia", "fans", "blog", "blue", "cafe", "cheap", "club", "co",
65      "cyou", "email", "band", "futbol", "group", "help", "icu", "land",
66      "makeup", "marketing", "market", "my", "name", "online", "pw", "quest",
67      "sbs", "shop", "skin", "support", "top", "video", "vip", "wiki", "work",
68      "xyz", "trade", "lol", "cfd", "world"
69    ];
70  
71    const ALLOWED_TLDS = new Set(allDomains);
72    const SEARCH_ENDPOINT = "/custom/CheckDomain/CheckDomain.php";
73    const SPECIAL_ENDPOINT = "/custom/SpecialDomains/SpecialDomains.php";
74  
75    function normalizeLabel(input) {
76      return String(input || "").trim().normalize("NFC").toLowerCase();
77    }
78  
79    function isValidDomainLabel(label) {
80      // 3-63 chars, letters/numbers/hyphen, no leading/trailing hyphen
81      return /^[a-z0-9](?:[a-z0-9-]{1,61}[a-z0-9])?$/.test(label);
82    }
83  
84    function parseDomainInput(value) {
85      const raw = normalizeLabel(value);
86  
87      if (!raw || raw.length < 3 || raw.length > 127) {
88        return { valid: false, error: "کلمه وارد شده معتبر نیست" };
89      }
90  
91      if (/\s/.test(raw)) {
92        return { valid: false, error: "کلمه وارد شده باید انگلیسی و بدون فاصله باشد" };
93      }
94  
95      const parts = raw.split(".");
96      if (parts.length === 1) {
97        if (!isValidDomainLabel(parts[0])) {
98          return { valid: false, error: "کلمه وارد شده باید انگلیسی و بدون فاصله باشد" };
99        }
100        return { valid: true, domain: parts[0], postfix: null };
101      }
102  
103      if (parts.length === 2) {
104        const [domain, postfix] = parts;
105        if (!isValidDomainLabel(domain) || !/^[a-z]{2,20}$/.test(postfix)) {
106          return { valid: false, error: "دامنه وارد شده معتبر نیست" };
107        }
108        return { valid: true, domain, postfix };
109      }
110  
111      return { valid: false, error: "فرمت دامنه معتبر نیست" };
112    }
113  
114    function safeJson(result) {
115      if (Array.isArray(result)) return result;
116      if (typeof result === "string") {
117        try {
118          return JSON.parse(result);
119        } catch {
120          return [];
121        }
122      }
123      return [];
124    }
125  
126    function clearElement(el) {
127      while (el.firstChild) el.removeChild(el.firstChild);
128    }
129  
130    function createText(tag, className, text) {
131      const el = document.createElement(tag);
132      if (className) el.className = className;
133      el.textContent = text;
134      return el;
135    }
136  
137    function createDomainCard(domainName, priceText, available) {
138      const wrapper = document.createElement("div");
139      wrapper.className = "popularDomainInstance";
140  
141      const imageContainer = document.createElement("div");
142      imageContainer.className = "imageDomainContainer";
143  
144      const img = document.createElement("img");
145      img.className = "iconInsideOverlay";
146      img.src = "https://parsvds.com/wp-content/uploads/2021/07/wDomainIcon.png";
147      img.alt = "";
148  
149      const name = createText("span", "domainName", domainName);
150  
151      imageContainer.appendChild(img);
152      imageContainer.appendChild(name);
153  
154      const price = document.createElement("span");
155      price.className = "domainPrice";
156      const bold = document.createElement("b");
157      bold.textContent = priceText || "-";
158      price.appendChild(bold);
159      price.appendChild(document.createTextNode(" هزارتومان"));
160  
161      const link = document.createElement("a");
162      if (available) {
163        link.className = "purchaseDomainLinkStyle";
164        link.href = "https://my.parsvds.com/cart.php?a=add&domain=register&query=" + encodeURIComponent(domainName);
165        link.textContent = "ثبت دامنه";
166        link.rel = "noopener noreferrer";
167      } else {
168        link.className = "notAviablaeDomainLinkStyle";
169        link.href = "#";
170        link.textContent = "موجود نیست";
171        link.addEventListener("click", function (e) {
172          e.preventDefault();
173        });
174      }
175  
176      wrapper.appendChild(imageContainer);
177      wrapper.appendChild(price);
178      wrapper.appendChild(link);
179  
180      return wrapper;
181    }
182  
183    function setAvailabilityMessage(available) {
184      const el = document.getElementById("availabilitySpecificDomain");
185      if (!el) return;
186  
187      el.classList.remove("notAvailableDomain", "availableDomain", "hiddenTool");
188  
189      if (available) {
190        el.textContent = "تبریک ! دامنه مورد نظر شما موجود است";
191        el.classList.add("availableDomain");
192      } else {
193        el.textContent = "در حال حاضر این دامنه موجود نیست سایر پسوندها همین نام را در زیر مشاهده نمایید ⚠️";
194        el.classList.add("notAvailableDomain");
195      }
196    }
197  
198    function toggleLoading(show) {
199      $(".spinnerLoading1").toggleClass("hiddenTool", !show);
200    }
201  
202    function hideInitialContainers() {
203      $("#domainToolContainer").attr("class", "hiddenTool");
204      $("#domainSearchContainer").attr("class", "hiddenTool");
205      $("#specialDomainContainer").attr("class", "hiddenTool");
206    }
207  
208    function renderGroupedResults(results, targetId) {
209      const target = document.getElementById(targetId);
210      if (!target) return;
211  
212      clearElement(target);
213  
214      const popularBox = document.createElement("div");
215      popularBox.className = "popularDomainsContainer";
216      popularBox.appendChild(createText("div", "headerDomainSearch", ""));
217      popularBox.firstChild.appendChild(createText("h3", "", "دامنه‌های محبوب"));
218      popularBox.appendChild(createText("div", "divider", ""));
219  
220      const offerBox = document.createElement("div");
221      offerBox.className = "offerDomainsContainer";
222      offerBox.appendChild(createText("div", "headerDomainSearch", ""));
223      offerBox.firstChild.appendChild(createText("h3", "", "دامنه‌های تخفیفی"));
224      offerBox.appendChild(createText("div", "divider", ""));
225  
226      results.forEach(function (item) {
227        const domainName = normalizeLabel(item.domain);
228        const status = String(item.status) === "True";
229        const parts = domainName.split(".");
230        const tld = parts[1] || "";
231        const price = domainPrice[tld] || "-";
232  
233        if (popularDomains.includes(tld)) {
234          popularBox.appendChild(createDomainCard(domainName, price, status));
235        }
236        if (offerDomains.includes(tld)) {
237          offerBox.appendChild(createDomainCard(domainName, price, status));
238        }
239      });
240  
241      target.appendChild(popularBox);
242      target.appendChild(offerBox);
243    }
244  
245    function renderSpecificResults(results) {
246      const target = document.getElementById("specificSearchResult");
247      if (!target) return;
248  
249      clearElement(target);
250  
251      const box = document.createElement("div");
252      box.className = "popularDomainsContainer";
253  
254      let foundAvailable = false;
255  
256      results.forEach(function (item) {
257        const domainName = normalizeLabel(item.domain);
258        const status = String(item.status) === "True";
259        const tld = domainName.split(".")[1] || "";
260        const price = domainPrice[tld] || "-";
261  
262        if (status) foundAvailable = true;
263        box.appendChild(createDomainCard(domainName, price, status));
264      });
265  
266      target.appendChild(box);
267      setAvailabilityMessage(foundAvailable);
268    }
269  
270    function ajaxJson(url, payload, onSuccess) {
271      $.ajax({
272        type: "POST",
273        url: url,
274        data: payload ? JSON.stringify(payload) : undefined,
275        dataType: "json",
276        contentType: "application/json",
277        success: function (result) {
278          onSuccess(safeJson(result));
279        },
280        error: function () {
281          toggleLoading(false);
282          alert("خطا در ارتباط با سرور");
283        }
284      });
285    }
286  
287    function domainSearch() {
288      const inputValue = $('input[name="route_no"]').val();
289      const parsed = parseDomainInput(inputValue);
290  
291      $("#availabilitySpecificDomain").removeClass("notAvailableDomain hiddenTool availableDomain");
292  
293      if (!parsed.valid) {
294        alert(parsed.error);
295        return;
296      }
297  
298      if (parsed.postfix) {
299        domainSearchWithSpecificPostfix(parsed.domain, parsed.postfix);
300      } else {
301        domainSearchWithoutSpecificPostfix(parsed.domain, true);
302      }
303    }
304  
305    function domainSearchWithSpecificPostfix(domain, postfix) {
306      if (!ALLOWED_TLDS.has(postfix)) {
307        domainSearchWithoutSpecificPostfix(domain, true);
308        return;
309      }
310  
311      toggleLoading(true);
312      hideInitialContainers();
313      $("#specificDomainSearchContainer").removeClass("hiddenTool");
314  
315      ajaxJson(SEARCH_ENDPOINT, { domain, domains: [postfix] }, function (results) {
316        toggleLoading(false);
317        $(".domainGraphic").css({ opacity: "0", display: "none" });
318  
319        renderSpecificResults(results);
320        domainSearchWithoutSpecificPostfix(domain, false);
321      });
322    }
323  
324    function domainSearchWithoutSpecificPostfix(domain, withoutPostfix) {
325      toggleLoading(true);
326  
327      $("#domainToolContainer").attr("class", "hiddenTool");
328      $("#domainSearchContainer").attr("class", "hiddenTool");
329  
330      if (withoutPostfix) {
331        $("#specificDomainSearchContainer").attr("class", "hiddenTool");
332      }
333  
334      ajaxJson(SEARCH_ENDPOINT, {
335        domain,
336        domains: popularDomains.concat(offerDomains)
337      }, function (results) {
338        toggleLoading(false);
339        $(".domainGraphic").css({ opacity: "0", display: "none" });
340        renderGroupedResults(results, "result");
341      });
342    }
343  
344    function pressed(e) {
345      if (e.keyCode === 13 && $("#route_no").is(":focus")) {
346        domainSearch();
347      }
348    }
349  
350    function initSpecialDomains() {
351      $("#specialdomain").on("click", function (evt) {
352        evt.preventDefault();
353  
354        $(".spinnerLoading").removeClass("hiddenTool");
355        $("#specialDomainContainer").removeClass("hiddenTool");
356        $("#specialdomain").addClass("selectedDomainTab");
357  
358        $("#domainToolContainer").attr("class", "hiddenTool");
359        $("#fastSearchContainer").attr("class", "hiddenTool");
360        $("#domainToolSimilarContainer").attr("class", "hiddenTool");
361        $("#specificDomainSearchContainer").attr("class", "hiddenTool");
362        $("#domainSearchContainer").attr("class", "hiddenTool");
363        $("#fastSearchLink").removeClass("selectedDomainTab");
364        $("#domainMaker").removeClass("selectedDomainTab");
365  
366        const resultsContainer = document.getElementById("specialDomainResult");
367        clearElement(resultsContainer);
368  
369        ajaxJson(SPECIAL_ENDPOINT, null, function (data) {
370          $(".spinnerLoading").addClass("hiddenTool");
371  
372          let count = 1;
373          data.forEach(function (slide) {
374            if (String(slide.status) !== "True") return;
375  
376            const domainName = normalizeLabel(slide.domain);
377            if (!/^[a-z0-9-]+\.[a-z]{2,20}$/.test(domainName)) return;
378  
379            const row = document.createElement("tr");
380            const cell1 = createText("td", "", String(count));
381            const cell2 = createText("td", "", domainName);
382            const cell3 = createText("td", "", "۶۹.۰۰۰ تومان ");
383            const cell4 = document.createElement("td");
384  
385            const link = document.createElement("a");
386            link.href = "https://my.parsvds.com/cart.php?a=add&domain=register&query=" + encodeURIComponent(domainName);
387            link.textContent = "ثبت";
388            link.className = "register-domain-btn-table";
389            link.rel = "noopener noreferrer";
390  
391            cell4.appendChild(link);
392            row.appendChild(cell1);
393            row.appendChild(cell2);
394            row.appendChild(cell3);
395            row.appendChild(cell4);
396            resultsContainer.appendChild(row);
397  
398            count += 1;
399          });
400        });
401      });
402    }
403  
404    $(document).ready(function () {
405      $(document).on("keypress", pressed);
406      $("#search").on("click", domainSearch);
407  
408      initSpecialDomains();
409  
410      const params = new URLSearchParams(window.location.search);
411      const sentdomain = params.get("domain");
412  
413      if (sentdomain) {
414        const parsed = parseDomainInput(sentdomain);
415        if (parsed.valid) {
416          if (parsed.postfix) {
417            domainSearchWithSpecificPostfix(parsed.domain, parsed.postfix);
418          } else {
419            domainSearchWithoutSpecificPostfix(parsed.domain, true);
420          }
421        }
422      }
423  
424      const cleanUrl = window.location.origin + window.location.pathname + window.location.hash;
425      window.history.replaceState({}, document.title, cleanUrl);
426    });
427  })(jQuery);

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.