From 4c78497b0642e2c2a5eb89a18dd3a340fbbccbc3 Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 4 Jun 2009 20:35:49 +0000 Subject: [PATCH] added support for reading zip code db and alerting when alert msg is present git-svn-id: svn://svn.open-ils.org/ILS/trunk@13319 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/ui/default/actor/user/register.js | 31 +++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/Open-ILS/web/js/ui/default/actor/user/register.js b/Open-ILS/web/js/ui/default/actor/user/register.js index a23e2b2aa8..943500246e 100644 --- a/Open-ILS/web/js/ui/default/actor/user/register.js +++ b/Open-ILS/web/js/ui/default/actor/user/register.js @@ -243,10 +243,13 @@ function fleshFMRow(row, fmcls, args) { return widget; } -function findWidget(wtype, fmfield) { +function findWidget(wtype, fmfield, callback) { return widgetPile.filter( function(i){ - return (i._wtype == wtype && i._fmfield == fmfield); + if(i._wtype == wtype && i._fmfield == fmfield) { + if(callback) return callback(i); + return true; + } } ).pop(); } @@ -285,6 +288,30 @@ function attachWidgetEvents(fmcls, fmfield, widget) { ); } } + + if(fmclass = 'aua') { + switch(fmfield) { + case 'post_code': + dojo.connect(widget.widget, 'onChange', + function(e) { + fieldmapper.standardRequest( + ['open-ils.search', 'open-ils.search.zip'], + { async: true, + params: [e], + oncomplete : function(r) { + var res = openils.Util.readResponse(r); + var callback = function(w) { return w._addr == widget._addr; }; + if(res.city) findWidget('aua', 'city', callback).widget.attr('value', res.city); + if(res.state) findWidget('aua', 'state', callback).widget.attr('value', res.state); + if(res.county) findWidget('aua', 'county', callback).widget.attr('value', res.county); + if(res.alert) alert(res.alert); + } + } + ); + } + ); + } + } } function getByName(node, name) { -- 2.11.0