Re: [IUG] Are you using Adam Brin's SMS code in your OPAC?


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
At 09:55 PM 8/17/2009, Valentina Mayz wrote:
We finally got with the times and took advantage of a neat code written by
Adam Brin, which lets you click on a button to send yourself a txt message
with the item's title, location, and call# -- right from your OPAC.

I have been implementing Joshua Kiela's php version (SMS
<http://innovativeusers.org/iug_clearinghouse-app?qfdo=Full+Record&id=183&ti
tle=SMS%20Message%20from%20Web%20OPAC%20%28PHP%20script%29&browsetype=Browse
%20by%20Module&searchtext=11> Message from Web OPAC (PHP script) ) of
Adam's Perl script, and have hit a snag - if you have or are using this
code, please read on and give me your thoughts off list.

The option for SMS should not display in records for which there is no call
number - for example: ebooks and online journals. I searched Adam's OPAC
for KW "Perl" and indeed, the SMS feature is present if you drill down to a
book, but it is not present if you drill down to an ebook record. However,
on our end the icon shows up regardless, but if you click on the SMS button
inside an ebook record, that's when it disappears.
. . .
My point is that, although I am not an experienced programmer, I believe
the logic of whether to show or hide the div that displays the SMS buttons
depends on the JavaScript finding a call# in the record; if there is a
call#, the div is visible and functional; if there isn't a call#, then it
applies the "visibility:hidden;display:none" attributes to the 'sms' div.

If anyone out there has seen this before and found a workaround, please
email me!


The script isn't looking for a call number per se -- it's looking for the existence of an HTML anchor element in the middle cell of a 3-column table that has the id attribute "bib_items". There's a little script in bib_display.html that disappears the button if there's no such table (that's what the try/catch piece is doing), but there's nothing in there that disappears the button if there's no middle cell with an anchor. So if you just copy the part of the sms.js script that looks for the anchor tag into the bib_display.html script block into another try/catch statement, you should get what you want.

Translation: add the following to the script block in bib_display.html, just after the catch :

try {
var itms = document.getElementById('bib_items');
var tr = itms.getElementsByTagName('TR');
for(i = 1; i < tr.length; i++) {
var xcells=tr[i].getElementsByTagName('TD');
if (xcells.length == 3) {
var callLinks = vmx[1].getElementsByTagName("a");
var call = callLinks[0].innerHTML.replace(/(<([^>]+)>|&nbsp;)/ig,"");
}
}

} catch (e) {
document.getElementById('smsfeatures').style.visibility='hidden';
document.getElementById('smsfeatures').style.display='none';
}


There may be a more elegant way to do this, but this works in our system.

Note if you're not Valentina: the above reflects the variable names in Nova's scripts; they may not be the same in your implementation.

Bob Duncan


~!~!~!~!~!~!~!~!~!~!~!~!~
Robert E. Duncan
Systems Librarian
Editor of IT Communications
Lafayette College
Easton, PA 18042
duncanr at lafayette dot edu
http://library.lafayette.edu/

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.