Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
feat(auto-search): improve case of no results when using `available o…
Browse files Browse the repository at this point in the history
…nly` filter
  • Loading branch information
KaiSchwarz-cnic committed Jan 2, 2020
1 parent 758832d commit 40d149b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
1 change: 1 addition & 0 deletions modules/addons/ispapidomaincheck/lang/english.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
$_ADDONLANG['label_descr_taken'] = "This domain name is already registered. You might get the specific reason by mouseover.";
$_ADDONLANG['label_descr_backorder'] = "This domain name is already registered. Through our backorder service we will then try to register the domain for you as soon as possible, when the domain's current registration term comes to its end. You will only be charged for this service in case of success.";
$_ADDONLANG['label_descr_whois'] = "Click this label to fetch the Whois Information.";
$_ADDONLANG['noresults'] = "No results available matching your search criteria.";
$_ADDONLANG['legend_label'] = "Help";
$_ADDONLANG['bttn_cancel'] = "Cancel";
$_ADDONLANG['modalboaddtitle'] = "Create Domain Backorder";
Expand Down
1 change: 1 addition & 0 deletions modules/addons/ispapidomaincheck/lang/german.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
$_ADDONLANG['label_descr_taken'] = "Dieser Domainname ist reserviert / bereits vergeben. Per Mouseover wird der spezifische Grund genannt.";
$_ADDONLANG['label_descr_backorder'] = "Dieser Domainname ist bereits vergeben. Über unseren Backorder-Dienst versuchen wir den Domainnamen für Sie zu registrieren, sobald dessen aktueller Registrierungszeitraum endet. Dieser Dienst wird nur im Erfolgsfall berechnet.";
$_ADDONLANG['label_descr_whois'] = "Klicken sie hierauf um Whois Informationen abzurufen.";
$_ADDONLANG['noresults'] = "Keine Ergebnisse gefunden, die zu Ihren Sucheinstellungen passen.";
$_ADDONLANG['legend_label'] = "Hilfe";
$_ADDONLANG['bttn_cancel'] = "Abbrechen";
$_ADDONLANG['modalboaddtitle'] = "Domain Backorder anlegen";
Expand Down
36 changes: 32 additions & 4 deletions modules/addons/ispapidomaincheck/lib/Client/assets/domainsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ DomainSearch.prototype.generate = async function (d, statusText, currencychanged
if (d.lookupprovider !== 'ispapi') {
// show error just in case we have not canceled it
if (!/^abort$/i.test(statusText)) {
$('#loading, #resultsarea').hide()
$('#loading, #resultsarea, #errorcont').hide()
$('#searchresults').empty()
$.growl.error({
title: `${translations.error_occured}!`,
Expand All @@ -308,7 +308,7 @@ DomainSearch.prototype.generate = async function (d, statusText, currencychanged
if (!Object.prototype.hasOwnProperty.call(d, 'categories')) {
// show error just in case we have not canceled it
if (!/^abort$/i.test(statusText)) {
$('#loading, #resultsarea').hide()
$('#loading, #resultsarea, #errorcont').hide()
$('#searchresults').empty()
$.growl.error({
title: `${translations.error_occured}!`,
Expand Down Expand Up @@ -605,6 +605,7 @@ DomainSearch.prototype.filter = function (key, val) {
this.searchResults.forEach(function (sr) {
this.checkTaken(sr, val)
}.bind(this))
this.checkAllTaken()
break
}
}
Expand All @@ -624,7 +625,7 @@ DomainSearch.prototype.requestGroupCheck = function (group) {
data.pc.push(row.PC)
data.registrars.push(row.registrar)
})
$.ajax({
return $.ajax({
url: '?action=checkdomains',
type: 'POST',
data: JSON.stringify(data),
Expand All @@ -637,21 +638,48 @@ DomainSearch.prototype.requestGroupCheck = function (group) {
})
}

DomainSearch.prototype.checkAllTaken = function () {
if (
!this.searchResults.length ||
ds.searchStore.showTakenDomains === '1'
) {
$('#errorcont').hide()
return
}
for (let i = 0; i < this.searchResults.length; i++) {
const row = this.searchResults[i].data
if (row.isSearchString || row.status !== 'TAKEN') {
return // we found a row not being TAKEN
}
}
if (this.searchGroups.finished) {
if (!$('div.domainbox.clickable').length) {
$('#errorcont').show()
}
} else {
this.search()
}
}

DomainSearch.prototype.search = async function () {
const search = this.searchStore.domain
if (!search.length) {
return
}
const groups = await this.getSearchGroups(search)
const promises = []
$('#resultsarea').show()
$('#errorcont').hide()
groups.forEach((grp) => {
// keep in mind if replacing that fat-arrow fn with
// this.requestGroupCheck then this context will be window
ds.requestGroupCheck(grp)
promises.push(ds.requestGroupCheck(grp))
})
if (this.searchGroups.finished) {
$('#loadmorebutton').hide()
} else {
$('#loadmorebutton').show()
}
await Promise.all(promises) // wait for requests to finish
this.checkAllTaken()
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
</div>
</div>
<div id="loading"><span><i class="fas fa-sync fa-spin"></i></span></div>
<div id="errorcont" style="display:none"><p align="center"><b>{$_lang.noresults}</b></p></div>
<div class="result-item" id="resultsarea" style="display:none;">
<form id="domainform" action="cart.php?a=add&domain=register" method="post">
<div class="row row1 search-results" id="searchresults"></div>
Expand Down
Binary file modified whmcs-ispapi-domainchecker-latest.zip
Binary file not shown.

0 comments on commit 40d149b

Please sign in to comment.