Checkpoint commit/test for Add Person

This commit is contained in:
Rick Falkvinge
2014-12-04 14:15:49 +01:00
parent 433d8dfe22
commit 215cb44a1c
4 changed files with 80 additions and 56 deletions
@@ -117,30 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Country_AC" xml:space="preserve">
<value>Ascension Island</value>
</data>
<data name="Country_AD" xml:space="preserve">
<value>Andorra</value>
</data>
<data name="Country_AT" xml:space="preserve">
<value>Austria</value>
</data>
<data name="Country_AU" xml:space="preserve">
<value>Australia</value>
</data>
<data name="Country_BR" xml:space="preserve">
<value>Brazil</value>
</data>
<data name="Country_DE" xml:space="preserve">
<value>Germany</value>
</data>
<data name="Country_DK" xml:space="preserve">
<value>Denmark</value>
</data>
<data name="Country_ES" xml:space="preserve">
<value>Spain</value>
</data>
<data name="Country_FI" xml:space="preserve">
<value>Finland</value>
</data>
@@ -150,24 +129,9 @@
<data name="Country_NO" xml:space="preserve">
<value>Norway</value>
</data>
<data name="Country_PL" xml:space="preserve">
<value>Poland</value>
</data>
<data name="Country_SE" xml:space="preserve">
<value>Sweden</value>
</data>
<data name="Country_SK" xml:space="preserve">
<value>Slovak Republic</value>
</data>
<data name="Country_SM" xml:space="preserve">
<value>San Marino</value>
</data>
<data name="Country_UK" xml:space="preserve">
<value>United Kingdom</value>
</data>
<data name="Country_US" xml:space="preserve">
<value>United States</value>
</data>
<data name="EasternEurope" xml:space="preserve">
<value>Eastern Europe</value>
<comment>(East of southern tip of Sweden, appx)</comment>
+9 -1
View File
@@ -33,6 +33,7 @@ namespace Swarmops.Frontend.Automation
List<GeographyData> geographyArray = new List<GeographyData>();
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;
}
+64 -19
View File
@@ -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;
</script>
</asp:Content>
@@ -109,14 +154,14 @@
<asp:Label ID="LabelExpiry" runat="server" Text="YYYY-MM-DD" />&#8203;<br/>
</div>
<div class="entryLabels">
Name (First Last)<br />
Name<br />
Country<br />
Mail<br />
Phone<br />
<h2>ADDRESS</h2>
Street 1<br />
Street 2<br />
Postal Code, City<br />
<span id="spanLabelPostal">Postal Code, </span>City<br />
<span id="SpanGeoDetected">Geography detected</span><span id="SpanGeoSelect" style="display:none">Select Geograhpy</span><br />
<h2>STATISTICAL DATA</h2>
Date of Birth<br />
+7
View File
@@ -61,7 +61,14 @@ namespace Swarmops.Frontend.Pages.v5.Swarm
{
// TODO
this.InfoBoxLiteral = "<strong>Work in progress</strong>";
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";
}
}
}