Skip to content

Javascript locationChanged

James Cobban edited this page Apr 26, 2020 · 14 revisions

function locationChanged(event)

Up: Location Services

The function locationChanged is the change event handler for fields which contain the text representation of a Location. This method is invoked with this a reference to the <input> tag, and is passed an instance of a change Event object as a parameter.

The function performs a number of operations on the value of the <input> element:

  1. "1/2" is replaced by "½" if it occurs immediately before a non-digit, which includes a space.
  2. Spaces are inserted to separate alphabetic and numeric tokens except for a few exceptional situations. For example "125King St" is corrected to "125 King St", but "3rd Ave" is not changed. A numeric token consists entirely of the digits 0 through 9 plus "½" to support addresses such as "127½ King St W, Hamilton, ON, CA".
  3. Most words are capitalized. For example "london, middlesex, ontario, canada" is changed to "London, Middlesex, Ontario, Canada".
  4. A set of common words are treated as abbreviations and replaced. This is used to speed up data entry, for example the stand-alone letter "E" is replaced by "England". This is also used for words which are not capitalized or are completely capitalized in location names. For example "Lot" is replaced by "lot", and "Mb" is replaced by "MB".
  5. To avoid creating unnecessary alternate versions of rural addresses if the concession portion precedes the lot portion they are swapped. For example "con 4 lot 12" is replaced by "lot 12 con 4".
  6. If the location starts with the word "House" or "Residence" then the beginning of the location, up to and including the first comma, is separated from the remainder and passed as a separate parameter to the server. This avoids creating unhelpful addresses such as "House of Bride's Father, xxxx" while validating the remainder of the address.

Once these normalizations have been completed on the input value, the database is searched using /FamilyTree/getLocationJSON.php to find matching instances of Location.

Next: function gotLocationJSON(object)

Clone this wiki locally