();
PostalCodes codes = PostalCodes.ForCountry(countryCode);
Country country = Country.FromCode(countryCode);
+ int maxPostalCodeLength = 0;
foreach (PostalCode code in codes)
{
@@ -42,6 +43,11 @@ namespace Swarmops.Frontend.Automation
CityId = code.CityId
};
+ if (code.PostalCode.Length > maxPostalCodeLength)
+ {
+ maxPostalCodeLength = code.PostalCode.Length;
+ }
+
postalCodeArray.Add(dataPoint);
}
@@ -75,7 +81,8 @@ namespace Swarmops.Frontend.Automation
PostalCodes = postalCodeArray.ToArray(),
CityNames = cityArray.ToArray(),
Geographies = geographyArray.ToArray(),
- PostalCodeLength = country.PostalCodeLength
+ PostalCodeLength = country.PostalCodeLength,
+ PostalCodeLengthCheck = maxPostalCodeLength
};
return result;
@@ -118,4 +125,5 @@ public class PostalCodesCities
public CityData[] CityNames { get; set; }
public GeographyData[] Geographies { get; set; }
public int PostalCodeLength;
+ public int PostalCodeLengthCheck;
}
\ No newline at end of file
diff --git a/Site5/Pages/v5/Swarm/AddPerson.aspx b/Site5/Pages/v5/Swarm/AddPerson.aspx
index 73c6623e..fb884bd4 100644
--- a/Site5/Pages/v5/Swarm/AddPerson.aspx
+++ b/Site5/Pages/v5/Swarm/AddPerson.aspx
@@ -8,32 +8,68 @@
$('#<%=this.TextPostal.ClientID%>').on('input', function() {
if (CheckPostalCode()) {
- $('#<%=this.TextDateOfBirth.ClientID%>').focus();
+ if ($('#<%=this.TextPostal.ClientID%>').val().length == postalCodeLength) {
+ $('#<%=this.TextDateOfBirth.ClientID%>').focus();
+ }
}
});
+ $('#<%=this.TextCity.ClientID%>').on('input', function () {
+ CheckPostalCity();
+ });
});
+ function CheckPostalCity() {
+ var currentCity = $('#<%=this.TextCity.ClientID%>').val().toLowerCase();
+ if (currentCity in cityNameLookup) {
+ var geoId = cityNameLookup[currentCity];
+ $('#spanDetectedGeo').text(geographyIdLookup[geoId]);
+ } else {
+ $('#spanDetectedGeo').text('');
+ }
+ }
+
function CheckPostalCode() {
- var currentPostalCode = $('#<%=this.TextPostal.ClientID%>').val();
+ var currentPostalCode = $('#<%=this.TextPostal.ClientID%>').val().toLowerCase();
+ if (currentPostalCode.length > postalCodeLengthCheck) {
+ currentPostalCode = currentPostalCode.substring(0, postalCodeLengthCheck);
+ }
if (currentPostalCode in postalCodeLookup) {
var cityId = postalCodeLookup[currentPostalCode];
- $('#<%=this.TextCity.ClientID%>').attr("disabled", "disabled").val(cityNameLookup[cityId].Name);
- $('#spanDetectedGeo').text(geographyNameLookup[cityNameLookup[cityId].GeoId]);
+ $('#<%=this.TextCity.ClientID%>').attr("disabled", "disabled").val(cityIdLookup[cityId].Name);
+ $('#spanDetectedGeo').text(geographyIdLookup[cityIdLookup[cityId].GeoId]);
+ postalCodeIdentified = true;
return true;
- } else {
+ } else if (postalCodeIdentified) {
$('#<%=this.TextCity.ClientID%>').removeAttr("disabled").val('');
$('#spanDetectedGeo').text('');
+ postalCodeIdentified = false;
}
return false;
}
function AnimatePostalCodeLength() {
- var postalTargetLength = postalCodeLength * 15 - 5;
- var cityTargetLength = 235 - 15 * postalCodeLength;
+ if (postalCodeLength > 0) {
+ var postalTargetLength = postalCodeLength * 15 - 5;
+ var cityTargetLength = 235 - 15 * postalCodeLength;
- $('#<%=this.TextPostal.ClientID%>').animate({ width: postalTargetLength + "px" });
- $('#<%=this.TextCity.ClientID%>').animate({ width: cityTargetLength + "px" });
+ $('#<%=this.TextPostal.ClientID%>').animate({ width: postalTargetLength + "px" });
+ $('#<%=this.TextCity.ClientID%>').animate({ width: cityTargetLength + "px" });
+ if (!postalCodeVisible) {
+ setTimeout(function() {
+ $('#<%=this.TextPostal.ClientID%>').fadeIn(200);
+ }, 100);
+ postalCodeVisible = true;
+ }
+
+ } else if (postalCodeVisible) {
+ // Remove postal code altogether, if visible now
+
+ $('#<%=this.TextPostal.ClientID%>').animate({ width: 0 }, 200).fadeOut(100);
+ $('#<%=this.TextCity.ClientID%>').animate({ width: "255px" }, 600);
+
+ postalCodeVisible = false;
+ }
}
function UpdatePostalPrefix(oldValue, newValue) {
@@ -54,20 +90,24 @@
dataType: "json",
success: function (msg) {
postalCodeLookup = {};
+ cityIdLookup = {};
cityNameLookup = {};
- geographyNameLookup = {};
+ geographyIdLookup = {};
postalCodeLength = msg.d.PostalCodeLength;
+ postalCodeLengthCheck = msg.d.PostalCodeLengthCheck;
+ $('#<%=TextPostal.ClientID%>').attr('maxlength', postalCodeLength);
msg.d.PostalCodes.forEach(function (element, index, array) {
- postalCodeLookup[element.Code] = element.CityId;
+ postalCodeLookup[element.Code.toLowerCase()] = element.CityId;
});
msg.d.CityNames.forEach(function(element, index, array) {
- cityNameLookup[element.Id] = {};
- cityNameLookup[element.Id].Name = element.Name;
- cityNameLookup[element.Id].GeoId = element.GeographyId;
+ cityIdLookup[element.Id] = {};
+ cityIdLookup[element.Id].Name = element.Name;
+ cityIdLookup[element.Id].GeoId = element.GeographyId;
+ cityNameLookup[element.Name.toLowerCase()] = element.GeographyId;
});
msg.d.Geographies.forEach(function(element, index, array) {
- geographyNameLookup[element.Id] = element.Name;
+ geographyIdLookup[element.Id] = element.Name;
});
AnimatePostalCodeLength();
@@ -75,17 +115,22 @@
},
error: function (msg) {
console.log(msg);
- geographyNameLookup = {};
+ geographyIdLookup = {};
postalCodeLookup = {};
+ cityIdLookup = {};
cityNameLookup = {};
}
});
}
var postalCodeLookup = {};
+ var cityIdLookup = {};
var cityNameLookup = {};
- var geographyNameLookup = {};
+ var geographyIdLookup = {};
var postalCodeLength = 0;
+ var postalCodeLengthCheck = 0;
+ var postalCodeVisible = true;
+ var postalCodeIdentified = false;
@@ -109,14 +154,14 @@
- Name (First Last)
+ Name
Country
Mail
Phone
ADDRESS
Street 1
Street 2
- Postal Code, City
+ Postal Code, City
Geography detectedSelect Geograhpy
STATISTICAL DATA
Date of Birth
diff --git a/Site5/Pages/v5/Swarm/AddPerson.aspx.cs b/Site5/Pages/v5/Swarm/AddPerson.aspx.cs
index 1c2535fb..c0285777 100644
--- a/Site5/Pages/v5/Swarm/AddPerson.aspx.cs
+++ b/Site5/Pages/v5/Swarm/AddPerson.aspx.cs
@@ -61,7 +61,14 @@ namespace Swarmops.Frontend.Pages.v5.Swarm
{
// TODO
+ this.InfoBoxLiteral = "Work in progress";
+
this.TextDateOfBirth.Attributes["placeholder"] = Resources.Global.Global_DateFormatShort;
+ this.TextName.Attributes["placeholder"] = "Joe Smith";
+ this.TextMail.Attributes["placeholder"] = "joe@example.com";
+ this.TextPhone.Attributes["placeholder"] = "+1 263 151 1341";
+ this.TextStreet1.Attributes["placeholder"] = "78 West Avenue";
+ this.TextPostal.Attributes["placeholder"] = "123456";
}
}
}
\ No newline at end of file