SPAM: Re: [OPEN-ILS-DEV] searching from remote form

Graham Fawcett graham.fawcett at gmail.com
Tue Oct 7 20:00:02 EDT 2008


Hi Grant,

On Tue, Oct 7, 2008 at 6:08 PM, Grant Johnson <fgjohnson at upei.ca> wrote:
> Hey,
>
> We just discovered that something like o'grady searched from LibX, or our Webpage, doesn't strip out the "comma" and  I get zero results.
>
> Any idea's other than putting a whole load of javascript on each "remote" form to make the catalogue more usable?
> I expect it functions in a similar fashion with other punctuation.
>
> See this in action by searching for o'grady on the "Find Books and Other Resources" section at http://library.upei.ca

It's totally cheating, but you could get away with one long line of
JavaScript instead of a whole bunch. This works for me on the O'Grady
search, executing it in the context of your search-page via Firebug:

$('div.content form').submit(function () {var t =
$('input[type="text"]', $(this)); t.val(t.val().replace(/[\',.:;]/g, '
')); return true; });

In other words, on all forms in the main content DIV, before they are
submitted, take the first text-input field, and replace all
occurrences of certain punctuation characters ( ' , . : ; ) with a
space. (It uses the jquery library, which you've already loaded on
that page.) The space seems to be an adequate replacement for the
apostrophe, at least in an O'Grady search.

What you'd actually put in your HTML (if you were crazy enough to try
it!) would be

<script type="text/javascript">
$(function () { $('div.content form').submit(function () {var t =
$('input[type="text"]', $(this)); t.val(t.val().replace(/[\',.:;]/g, '
')); return true; }); });
</script>

...telling jquery to register the punctuation-fixing onsubmit handlers
after the page is loaded.

I'm sure a better fix awaits on the server-side. And of course this
hack is specific to the page at http://library.upei.ca/ so it's of
very limited use!

Best,
Graham


More information about the Open-ils-dev mailing list