Skip to content

Commit

Permalink
Demo enhancements (#2764)
Browse files Browse the repository at this point in the history
* Demo enhancements

* Update Demo portal

* Cleaning up auto generated, not very relevant archetype contents

* pom.xml ordering

* Cleanuping up unwanted changes

* Cleanuping up unwanted changes

* Update README

* Demo enhancements

* Updates after migration to Soy

Co-authored-by: Aravind <penmetsaa@google.com>
  • Loading branch information
tvislavski and penmetsaa authored Dec 6, 2022
1 parent 70a58d0 commit 8db6fc7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ public String genHtml() {
.setExtension(number.getExtension())
.setCountryCodeSource(number.getCountryCodeSource().toString())
.setItalianLeadingZero(number.isItalianLeadingZero())
.setRawInput(number.getRawInput());
.setNumberOfLeadingZeros(number.getNumberOfLeadingZeros())
.setRawInput(number.getRawInput())
.setPreferredDomesticCarrierCode(number.getPreferredDomesticCarrierCode());

boolean isNumberValid = phoneUtil.isValidNumber(number);
boolean hasDefaultCountry = !defaultCountry.isEmpty() && !defaultCountry.equals("ZZ");
Expand Down Expand Up @@ -104,7 +106,11 @@ public String genHtml() {
.setOutOfCountryFormatFromUs(
isNumberValid ? phoneUtil.formatOutOfCountryCallingNumber(number, "US") : "invalid")
.setOutOfCountryFormatFromCh(
isNumberValid ? phoneUtil.formatOutOfCountryCallingNumber(number, "CH") : "invalid");
isNumberValid ? phoneUtil.formatOutOfCountryCallingNumber(number, "CH") : "invalid")
.setMobileDiallingFormatFromUs(
isNumberValid ? phoneUtil.formatNumberForMobileDialing(number, "US", true) : "invalid")
.setNationalDiallingFormatWithPreferredCarrierCode(
isNumberValid ? phoneUtil.formatNationalNumberWithCarrierCode(number, "") : "invalid");

// Get As You Type Formatter Table
List<List<String>> rows = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
{@param extension: string}
{@param countryCodeSource: string}
{@param italianLeadingZero: bool}
{@param numberOfLeadingZeros: int}
{@param rawInput: string}
{@param preferredDomesticCarrierCode: string}

{@param isPossibleNumber: bool}
{@param isValidNumber: bool}
Expand All @@ -29,6 +31,8 @@
{@param internationalFormat: string}
{@param outOfCountryFormatFromUs: string}
{@param outOfCountryFormatFromCh: string}
{@param mobileDiallingFormatFromUs: string}
{@param nationalDiallingFormatWithPreferredCarrierCode: string}

{@param rows: list<list<string>>}

Expand Down Expand Up @@ -74,10 +78,18 @@
<TH>italian_leading_zero</TH>
<TD>{$italianLeadingZero}</TD>
</TR>
<TR>
<TH>number_of_leading_zeros</TH>
<TD>{$numberOfLeadingZeros}</TD>
</TR>
<TR>
<TH>raw_input</TH>
<TD>{$rawInput}</TD>
</TR>
<TR>
<TH>preferred_domestic_carrier_code</TH>
<TD>{$preferredDomesticCarrierCode}</TD>
</TR>
</TABLE>
</DIV>
<DIV>
Expand Down Expand Up @@ -189,6 +201,14 @@
<TH>Out-of-country format from CH</TH>
<TD>{$outOfCountryFormatFromCh}</TD>
</TR>
<TR>
<TH>Format for mobile dialing (calling from US)</TH>
<TD>{$mobileDiallingFormatFromUs}</TD>
</TR>
<TR>
<TH>Format for national dialing with preferred carrier code and empty fallback carrier code</TH>
<TD>{$nationalDiallingFormatWithPreferredCarrierCode}</TD>
</TR>
</TABLE>
</DIV>

Expand Down
10 changes: 10 additions & 0 deletions javascript/i18n/phonenumbers/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,16 @@ function phoneNumberParser() {
output.append(
phoneUtil_.formatNationalNumberWithCarrierCode(number, carrierCode));
}
output.append('\nFormat for mobile dialing (calling from US): ');
output.append(
isNumberValid ?
phoneUtil_.formatNumberForMobileDialing(number, 'US', true) :
'invalid');
output.append('\nFormat for national dialing with preferred carrier code and empty fallback carrier code: ');
output.append(
isNumberValid ?
phoneUtil_.formatNationalNumberWithPreferredCarrierCode(number, '') :
'invalid');
output.append('\n\n****AsYouTypeFormatter Results****');
var formatter = new i18n.phonenumbers.AsYouTypeFormatter(regionCode);
var phoneNumberLength = phoneNumber.length;
Expand Down

0 comments on commit 8db6fc7

Please sign in to comment.