[open-ils-commits] r988 - in conifer/branches/rel_1_6_1/web/opac/skin/lul: js xml xml/result (dbs)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Sep 13 15:41:07 EDT 2010
Author: dbs
Date: 2010-09-13 15:41:02 -0400 (Mon, 13 Sep 2010)
New Revision: 988
Added:
conifer/branches/rel_1_6_1/web/opac/skin/lul/js/result_common.js
conifer/branches/rel_1_6_1/web/opac/skin/lul/xml/result/
conifer/branches/rel_1_6_1/web/opac/skin/lul/xml/result/result_table.xml
Log:
Add UPEI-style callnumber / online resources to search results page
Added: conifer/branches/rel_1_6_1/web/opac/skin/lul/js/result_common.js
===================================================================
--- conifer/branches/rel_1_6_1/web/opac/skin/lul/js/result_common.js (rev 0)
+++ conifer/branches/rel_1_6_1/web/opac/skin/lul/js/result_common.js 2010-09-13 19:41:02 UTC (rev 988)
@@ -0,0 +1,840 @@
+
+var recordsHandled = 0;
+var recordsCache = [];
+var lowHitCount = 4;
+var isbnList = '';
+var googleBooksLink = false;
+var enableHoldsOnAvailable = false;
+var enableExtraSearchesLowHits = true;
+var localProxyPrefix = 'http://librweb.laurentian.ca/login?url=';
+
+/* an array of the extra services to which we want to direct people, in order of priority:
+Properties:
+ url: will be proxied via localProxyPrefix
+ description: will be used in the OPAC display
+ termTransform: a function name that transforms Evergreen compiled searches to the target search format
+*/
+var externalSearchServices = [
+ {
+ "url": "http://books.scholarsportal.info/search.html?searchField=All+Fields&limit=full_text&sortBy=relevance&collection=all&searchTerm=",
+ "description": "Search ScholarsPortal ebooks",
+ "termTransform": "allKeywords"
+ },
+ {
+ "url": "http://scholar.google.com/scholar?q=",
+ "description": "Search Google Scholar",
+ "termTransform": "allKeywords"
+ }
+];
+
+var resultFetchAllRecords = false;
+var resultCompiledSearch = null;
+
+/* set up the event handlers */
+if( findCurrentPage() == MRESULT || findCurrentPage() == RRESULT ) {
+ G.evt.result.hitCountReceived.push(resultSetHitInfo);
+ G.evt.result.recordReceived.push(resultDisplayRecord, resultAddCopyCounts);
+ G.evt.result.copyCountsReceived.push(resultDisplayCopyCounts);
+ G.evt.result.allRecordsReceived.push(resultBuildCaches, resultDrawSubjects,
+ resultDrawAuthors, resultDrawSeries, function(){unHideMe($('result_info_2'))},
+ fetchGoogleBooksLink);
+
+ attachEvt('result','lowHits',resultLowHits);
+ attachEvt('result','zeroHits',resultZeroHits);
+ attachEvt( "common", "locationUpdated", resultSBSubmit );
+ /* do this after we have ID's so the rank for mr pages will be correct */
+ attachEvt("result", "preCollectRecords", resultPaginate);
+}
+
+function resultSBSubmit(){searchBarSubmit();}
+
+/* returns the last 'index' postion ocurring in this page */
+function resultFinalPageIndex() {
+ if(getHitCount() < (getOffset() + getDisplayCount()))
+ return getHitCount() - 1;
+ return getOffset() + getDisplayCount() - 1;
+}
+
+
+
+
+/* generic search method */
+function resultCollectSearchIds( type, method, handler ) {
+
+ var sort = (getSort() == SORT_TYPE_REL) ? null : getSort();
+ var sortdir = (sort) ? ((getSortDir()) ? getSortDir() : SORT_DIR_ASC) : null;
+
+ var item_type;
+ var item_form;
+ var args = {};
+
+ if( type ) {
+ var form = parseForm(getForm());
+ item_type = form.item_type;
+ item_form = form.item_form;
+
+ } else {
+ item_type = (getItemType()) ? getItemType().split(/,/) : null;
+ item_form = (getItemForm()) ? getItemForm().split(/,/) : null;
+ }
+
+ var limit = (resultFetchAllRecords) ? 1000 : getDisplayCount();
+
+ if( getOffset() > 0 ) {
+ if( getHitCount() > 0 && (getOffset() + getDisplayCount()) > getHitCount() )
+ limit = getHitCount() - getOffset();
+ }
+
+ var lasso = getLasso();
+
+ if (lasso) args.org_unit = -lasso;
+ else args.org_unit = getLocation();
+
+ args.depth = getDepth();
+ args.limit = limit;
+ args.offset = getOffset();
+ args.visibility_limit = 3000;
+ args.default_class = getStype();
+
+ if(sort) args.sort = sort;
+ if(sortdir) args.sort_dir = sortdir;
+ if(item_type) args.item_type = item_type;
+ if(item_form) args.item_form = item_form;
+ if(getAvail()) args.available = 1;
+
+
+ if(getAudience()) args.audience = getAudience().split(/,/);
+ if(getLitForm()) args.lit_form = getLitForm().split(/,/);
+ if(getLanguage()) args.language = getLanguage().split(/,/);
+ if(getBibLevel()) args.bib_level = getBibLevel().split(/,/);
+ if(getCopyLocs()) args.locations = getCopyLocs().split(/,/);
+ if(getPubdBefore()) args.before = getPubdBefore();
+ else if(getPubdAfter()) args.after = getPubdAfter();
+ else if(getPubdBetween()) args.between = getPubdBetween().split(/,/);
+
+ _debug('Search args: ' + js2JSON(args));
+ _debug('Raw query: ' + getTerm());
+
+ var req = new Request(method, args, getTerm(), 1);
+ req.callback(handler);
+ req.send();
+}
+
+
+
+
+
+/* set the search result info, number of hits, which results we're
+ displaying, links to the next/prev pages, etc. */
+function resultSetHitInfo() {
+
+ var lasso = getLasso();
+ if (!lasso) {
+ /* tell the user where the results are coming from */
+ var baseorg = findOrgUnit(getLocation());
+ var depth = getDepth();
+ var mydepth = findOrgDepth(baseorg);
+ if( findOrgDepth(baseorg) != depth ) {
+ var tmporg = baseorg;
+ while( mydepth > depth ) {
+ mydepth--;
+ tmporg = findOrgUnit(tmporg.parent_ou());
+ }
+ unHideMe($('including_results_for'));
+ $('including_results_location').appendChild(text(tmporg.name()));
+ }
+ }
+
+
+ try{searchTimer.stop()}catch(e){}
+
+ //if( findCurrentPage() == MRESULT ) {
+ if( findCurrentPage() == MRESULT ||
+
+ (findCurrentPage() == RRESULT &&
+ (
+ getRtype() == RTYPE_TITLE ||
+ getRtype() == RTYPE_AUTHOR ||
+ getRtype() == RTYPE_SUBJECT ||
+ getRtype() == RTYPE_SERIES ||
+ getRtype() == RTYPE_KEYWORD
+ )
+
+ ) ) {
+
+ if(getHitCount() <= lowHitCount && getTerm())
+ runEvt('result', 'lowHits');
+ }
+
+ if(getHitCount() == 0) {
+ runEvt('result', 'zeroHits');
+ return;
+ }
+
+
+ var pages = getHitCount() / getDisplayCount();
+ if(pages % 1) pages = parseInt(pages) + 1;
+
+
+
+ var cpage = (getOffset()/getDisplayCount()) + 1;
+
+ G.ui.result.current_page.appendChild(text(cpage));
+ G.ui.result.num_pages.appendChild(text(pages + ")")); /* the ) is dumb */
+
+ $('current_page2').appendChild(text(cpage));
+ $('num_pages2').appendChild(text(pages + ")")); /* the ) is dumb */
+
+ /* set the offsets */
+ var offsetEnd = getDisplayCount() + getOffset();
+ if( getDisplayCount() > (getHitCount() - getOffset()))
+ offsetEnd = getHitCount();
+
+ G.ui.result.offset_end.appendChild(text(offsetEnd));
+ G.ui.result.offset_start.appendChild(text(getOffset() + 1));
+
+ $('offset_end2').appendChild(text(offsetEnd));
+ $('offset_start2').appendChild(text(getOffset() + 1));
+
+ G.ui.result.result_count.appendChild(text(getHitCount()));
+ unHideMe(G.ui.result.info);
+
+ $('result_count2').appendChild(text(getHitCount()));
+ unHideMe($('result_info_div2'));
+}
+
+function resultLowHits() {
+ showCanvas();
+ unHideMe($('result_low_hits'));
+ if(getHitCount() > 0)
+ unHideMe($('result_low_hits_msg'));
+
+ var words = [];
+ for(var key in resultCompiledSearch.searches)
+ words.push(resultCompiledSearch.searches[key].term);
+
+ var sreq = new Request(CHECK_SPELL, words.join(' '));
+ sreq.callback(resultSuggestSpelling);
+ sreq.send();
+
+ for(var key in resultCompiledSearch.searches) {
+ var areq = new Request(FETCH_CROSSREF, key, resultCompiledSearch.searches[key].term);
+ areq.callback(resultLowHitXRef);
+ areq.send();
+ }
+
+ if( !(getForm() == null || getForm() == 'all' || getForm() == "") ) {
+ var a = {};
+ a[PARAM_FORM] = "all";
+ $('low_hits_remove_format_link').setAttribute('href',buildOPACLink(a));
+ unHideMe($('low_hits_remove_format'));
+ }
+
+ resultSuggestSearchClass();
+
+ if (enableExtraSearchesLowHits) {
+ resultSuggestExtraSearches();
+ }
+
+ if(getTerm()) resultExpandSearch(); /* advanced search */
+}
+
+var lowHitsXRefSet = {};
+var lowHitsXRefLink;
+var lowHitsXRefLinkParent;
+function resultLowHitXRef(r) {
+ if(!lowHitsXRefLink){
+ lowHitsXRefLinkParent = $('low_hits_xref_link').parentNode;
+ lowHitsXRefLink = lowHitsXRefLinkParent.removeChild($('low_hits_xref_link'));
+ }
+ var res = r.getResultObject();
+ var arr = res.from;
+ arr.concat(res.also);
+ if(arr && arr.length > 0) {
+ unHideMe($('low_hits_cross_ref'));
+ var word;
+ var c = 0;
+ while( word = arr.shift() ) {
+
+ if (lowHitsXRefSet[word] == 1) continue;
+ lowHitsXRefSet[word] = 1;
+
+ if(c++ > 20) break;
+ var a = {};
+ a[PARAM_TERM] = word;
+ var template = lowHitsXRefLink.cloneNode(true);
+ template.setAttribute('href',buildOPACLink(a));
+ template.appendChild(text(word));
+ lowHitsXRefLinkParent.appendChild(template);
+ lowHitsXRefLinkParent.appendChild(text(' '));
+ }
+ }
+}
+
+function resultZeroHits() {
+ showCanvas();
+ unHideMe($('result_low_hits'));
+ unHideMe($('result_zero_hits_msg'));
+
+ //if(getTerm()) resultExpandSearch(); /* advanced search */
+}
+
+function resultExpandSearch() {
+ var top = findOrgDepth(globalOrgTree);
+
+ /* We don't want to expand the scope to Everywhere in Conifer, that's just confusing */
+ if(getDepth() == top || getDepth() - 1 == top) return;
+ unHideMe($('low_hits_expand_range'));
+ var par = $('low_hits_expand_link').parentNode;
+ var template = par.removeChild($('low_hits_expand_link'));
+
+ var bottom = getDepth();
+ while( top < bottom ) {
+ var a = {};
+ a[PARAM_DEPTH] = top;
+ var temp = template.cloneNode(true);
+ temp.appendChild(text(findOrgTypeFromDepth(top).opac_label()))
+ temp.setAttribute('href',buildOPACLink(a));
+ par.appendChild(temp);
+ top++;
+ }
+}
+
+/* Generate links to our extra search services */
+function resultSuggestExtraSearches() {
+ dojo.forEach(externalSearchServices, function(esItem) {
+ var extraSearchStuff = this[esItem.termTransform].apply(this, [esItem.url]);
+ dojo.place("<div style='text-align: center; width: 100%; margin-left: auto; margin-right: auto;'><strong>" +
+ esItem.description + "</strong>: <a class='classic_link' href='" +
+ extraSearchStuff.searchTerms + "'>" + extraSearchStuff.displayTerms + "</a><div>", "result_low_hits", "child"
+ );
+ });
+}
+
+/* Transform everything in the Evergreen search to plain old keywords */
+function allKeywords(esUrl) {
+ var ebook_search = localProxyPrefix + esUrl;
+ var ebook_terms = '';
+ for (var key in resultCompiledSearch.searches) {
+ ebook_search += resultCompiledSearch.searches[key].term + '+';
+ ebook_terms += resultCompiledSearch.searches[key].term + ' ';
+ }
+ ebook_search = ebook_search.replace(/ /g, '+');
+ ebook_search = ebook_search.replace(/\%20/g, '+');
+ ebook_search = ebook_search.replace(/\+$/g, '');
+ ebook_terms = ebook_terms.replace(/ $/g, '');
+ var extraSuggestion = {"displayTerms": ebook_terms, "searchTerms": ebook_search};
+ return extraSuggestion;
+}
+
+function resultSuggestSearchClass() {
+ var stype = getStype();
+ if(stype == STYPE_KEYWORD) return;
+ var a = {}; var ref;
+ unHideMe($('low_hits_search_type'));
+ if(stype != STYPE_TITLE) {
+ ref = $('low_hits_title_search');
+ unHideMe(ref);
+ a[PARAM_STYPE] = STYPE_TITLE;
+ ref.setAttribute('href',buildOPACLink(a));
+ }
+ if(stype != STYPE_AUTHOR) {
+ ref = $('low_hits_author_search');
+ unHideMe(ref);
+ a[PARAM_STYPE] = STYPE_AUTHOR;
+ ref.setAttribute('href',buildOPACLink(a));
+ }
+ if(stype != STYPE_SUBJECT) {
+ ref = $('low_hits_subject_search');
+ unHideMe(ref);
+ a[PARAM_STYPE] = STYPE_SUBJECT;
+ ref.setAttribute('href',buildOPACLink(a));
+ }
+ if(stype != STYPE_KEYWORD) {
+ ref = $('low_hits_keyword_search');
+ unHideMe(ref);
+ a[PARAM_STYPE] = STYPE_KEYWORD;
+ ref.setAttribute('href',buildOPACLink(a));
+ }
+ if(stype != STYPE_SERIES) {
+ ref = $('low_hits_series_search');
+ unHideMe(ref);
+ a[PARAM_STYPE] = STYPE_SERIES;
+ ref.setAttribute('href',buildOPACLink(a));
+ }
+}
+
+function resultSuggestSpelling(r) {
+ var res = r.getResultObject();
+ var phrase = getTerm();
+ var words = phrase.split(/ /);
+
+ var newterm = "";
+
+ for( var w = 0; w < words.length; w++ ) {
+ var word = words[w];
+ var blob = grep(res, function(i){return (i.word == word);});
+ if( blob ) blob = blob[0];
+ else continue;
+ if( blob.word == word ) {
+ if( blob.suggestions && blob.suggestions[0] ) {
+ newterm += " " + blob.suggestions[0];
+ unHideMe($('did_you_mean'));
+ } else {
+ newterm += " " + word;
+ }
+ }
+ }
+
+ var arg = {};
+ arg[PARAM_TERM] = newterm;
+ $('spell_check_link').setAttribute('href', buildOPACLink(arg));
+ $('spell_check_link').appendChild(text(newterm));
+}
+
+
+function resultPaginate() {
+ var o = getOffset();
+
+ if( !( ((o) + getDisplayCount()) >= getHitCount()) ) {
+
+ var args = {};
+ args[PARAM_OFFSET] = o + getDisplayCount();
+ args[PARAM_SORT] = SORT;
+ args[PARAM_SORT_DIR] = SORT_DIR;
+ args[PARAM_RLIST] = new CGI().param(PARAM_RLIST);
+
+ G.ui.result.next_link.setAttribute("href", buildOPACLink(args));
+ addCSSClass(G.ui.result.next_link, config.css.result.nav_active);
+
+ $('next_link2').setAttribute("href", buildOPACLink(args));
+ addCSSClass($('next_link2'), config.css.result.nav_active);
+
+ args[PARAM_OFFSET] = getHitCount() - (getHitCount() % getDisplayCount());
+
+ /* when hit count is divisible by display count, we have to adjust */
+ if( getHitCount() % getDisplayCount() == 0 )
+ args[PARAM_OFFSET] -= getDisplayCount();
+
+ /*
+ G.ui.result.end_link.setAttribute("href", buildOPACLink(args));
+ addCSSClass(G.ui.result.end_link, config.css.result.nav_active);
+
+ $('end_link2').setAttribute("href", buildOPACLink(args));
+ addCSSClass($('end_link2'), config.css.result.nav_active);
+ */
+ }
+
+ if( o > 0 ) {
+
+ var args = {};
+ args[PARAM_SORT] = SORT;
+ args[PARAM_SORT_DIR] = SORT_DIR;
+ args[PARAM_RLIST] = new CGI().param(PARAM_RLIST);
+
+ args[PARAM_OFFSET] = o - getDisplayCount();
+ G.ui.result.prev_link.setAttribute( "href", buildOPACLink(args));
+ addCSSClass(G.ui.result.prev_link, config.css.result.nav_active);
+
+ $('prev_link2').setAttribute( "href", buildOPACLink(args));
+ addCSSClass($('prev_link2'), config.css.result.nav_active);
+
+ args[PARAM_OFFSET] = 0;
+ G.ui.result.home_link.setAttribute( "href", buildOPACLink(args));
+ addCSSClass(G.ui.result.home_link, config.css.result.nav_active);
+
+ $('search_home_link2').setAttribute( "href", buildOPACLink(args));
+ addCSSClass($('search_home_link2'), config.css.result.nav_active);
+ }
+
+ if(getDisplayCount() < getHitCount()) {
+ unHideMe($('start_end_links_span'));
+ unHideMe($('start_end_links_span2'));
+ }
+
+ showCanvas();
+ try{searchTimer.stop()}catch(e){}
+}
+
+function buildunAPISpan (span, type, id) {
+ var cgi = new CGI();
+ var d = new Date();
+
+ addCSSClass(span,'unapi-id');
+
+ span.setAttribute(
+ 'title',
+ 'tag:' + cgi.server_name + ',' +
+ d.getFullYear() +
+ ':' + type + '/' + id
+ );
+}
+
+function unhideGoogleBooksLink (data) {
+ for ( var i in data ) {
+ //if (data[i].preview == 'noview') continue;
+
+ var gbspan = $n(document.documentElement, 'googleBooksLink-' + i);
+ var gba = $n(gbspan, "googleBooks-link");
+
+ gba.setAttribute(
+ 'href',
+ data[i].info_url
+ );
+ removeCSSClass( gbspan, 'hide_me' );
+ }
+}
+
+/* display the record info in the record display table 'pos' is the
+ zero based position the record should have in the display table */
+function resultDisplayRecord(rec, pos, is_mr) {
+
+ if(rec == null) rec = new mvr(); /* so the page won't die if there was an error */
+ recordsHandled++;
+ recordsCache.push(rec);
+
+ var r = table.rows[pos + 1];
+ var currentISBN = cleanISBN(rec.isbn());
+
+ if (googleBooksLink) {
+ var gbspan = $n(r, "googleBooksLink");
+ if (currentISBN) {
+ gbspan.setAttribute(
+ 'name',
+ gbspan.getAttribute('name') + '-' + currentISBN
+ );
+
+ if (isbnList) isbnList += ', ';
+ isbnList += currentISBN;
+ }
+ }
+
+/*
+ try {
+ var rank = parseFloat(ranks[pos + getOffset()]);
+ rank = parseInt( rank * 100 );
+ var relspan = $n(r, "relevancy_span");
+ relspan.appendChild(text(rank));
+ unHideMe(relspan.parentNode);
+ } catch(e){ }
+*/
+
+ var pic = $n(r, config.names.result.item_jacket);
+ pic.setAttribute("src", buildISBNSrc(currentISBN));
+
+ var title_link = $n(r, config.names.result.item_title);
+ var author_link = $n(r, config.names.result.item_author);
+
+ if( is_mr ) {
+ var onlyrec = onlyrecord[ getOffset() + pos ];
+ if(onlyrec) {
+ buildunAPISpan($n(r,'unapi'), 'biblio-record_entry', onlyrec);
+
+ var args = {};
+ args.page = RDETAIL;
+ args[PARAM_OFFSET] = 0;
+ args[PARAM_RID] = onlyrec;
+ args[PARAM_MRID] = rec.doc_id();
+ pic.parentNode.setAttribute("href", buildOPACLink(args));
+ title_link.setAttribute("href", buildOPACLink(args));
+ title_link.appendChild(text(normalize(truncate(rec.title(), 65))));
+
+ } else {
+ buildunAPISpan($n(r,'unapi'), 'metabib-metarecord', rec.doc_id());
+
+ buildTitleLink(rec, title_link);
+ var args = {};
+ args.page = RRESULT;
+ args[PARAM_OFFSET] = 0;
+ args[PARAM_MRID] = rec.doc_id();
+ pic.parentNode.setAttribute("href", buildOPACLink(args));
+ }
+
+ } else {
+ buildunAPISpan($n(r,'unapi'), 'biblio-record_entry', rec.doc_id());
+
+ buildTitleDetailLink(rec, title_link);
+ var args = {};
+ args.page = RDETAIL;
+ args[PARAM_OFFSET] = 0;
+ args[PARAM_RID] = rec.doc_id();
+ pic.parentNode.setAttribute("href", buildOPACLink(args));
+
+ if (enableHoldsOnAvailable) {
+ unHideMe($n(r,'place_hold_span'));
+ }
+
+ $n(r,'place_hold_link').setAttribute(
+ 'href','javascript:holdsDrawEditor({record:"'+rec.doc_id()+'",type:"T"});');
+
+ // Stolen from trunk
+ var here = findOrgUnit(getLocation());
+ dojo.require('openils.BibTemplate');
+ var l_cn_list = $n(r,'local_callnumber_list');
+ var onlyrec = rec.doc_id();
+
+ dojo.addOnLoad(function () {
+ new openils.BibTemplate({
+ root : l_cn_list,
+ record : '' + onlyrec,
+ org_unit : here.shortname()
+ }).render();
+ unHideMe(l_cn_list);
+ });
+
+ }
+
+ buildSearchLink(STYPE_AUTHOR, rec.author(), author_link);
+
+ if(! is_mr ) {
+
+ if(!isNull(rec.edition())) {
+ unHideMe( $n(r, "result_table_extra_span"));
+ $n(r, "result_table_edition_span").appendChild( text( rec.edition()) );
+ }
+ if(!isNull(rec.pubdate())) {
+ unHideMe( $n(r, "result_table_extra_span"));
+ unHideMe($n(r, "result_table_pub_span"));
+ $n(r, "result_table_pub_span").appendChild( text( rec.pubdate() ));
+ }
+ if(!isNull(rec.publisher()) ) {
+ unHideMe( $n(r, "result_table_extra_span"));
+ unHideMe($n(r, "result_table_pub_span"));
+ $n(r, "result_table_pub_span").appendChild( text( " " + rec.publisher() ));
+ }
+
+ if(!isNull(rec.physical_description()) ) {
+ unHideMe( $n(r, "result_table_extra_span"));
+ var t = " " + rec.physical_description();
+ //$n(r, "result_table_phys_span").appendChild( text(t.replace(/:.*/g,'')));
+ $n(r, "result_table_phys_span").appendChild( text(t));
+ }
+
+ }
+
+ resultBuildFormatIcons( r, rec, is_mr );
+
+ unHideMe(r);
+
+ runEvt("result", "recordDrawn", rec.doc_id(), title_link);
+
+ /*
+ if(resultPageIsDone()) {
+ runEvt('result', 'allRecordsReceived', recordsCache);
+ }
+ */
+}
+
+function _resultFindRec(id) {
+ for( var i = 0; i != recordsCache.length; i++ ) {
+ var rec = recordsCache[i];
+ if( rec && rec.doc_id() == id )
+ return rec;
+ }
+ return null;
+}
+
+
+function resultBuildFormatIcons( row, rec, is_mr ) {
+
+ var ress = rec.types_of_resource();
+
+ for( var i in ress ) {
+
+ var res = ress[i];
+ if(!res) continue;
+
+ var link = $n(row, res + "_link");
+ link.title = res;
+ var img = link.getElementsByTagName("img")[0];
+ removeCSSClass( img, config.css.dim );
+
+ var f = getForm();
+ if( f != "all" ) {
+ if( f == modsFormatToMARC(res) )
+ addCSSClass( img, "dim2_border");
+ }
+
+ var args = {};
+ args[PARAM_OFFSET] = 0;
+
+ if(is_mr) {
+ args.page = RRESULT;
+ args[PARAM_TFORM] = modsFormatToMARC(res);
+ args[PARAM_MRID] = rec.doc_id();
+
+ } else {
+ args.page = RDETAIL
+ args[PARAM_RID] = rec.doc_id();
+ }
+
+ link.setAttribute("href", buildOPACLink(args));
+
+ }
+}
+
+function fetchGoogleBooksLink () {
+ if (isbnList && googleBooksLink) {
+ var scriptElement = document.createElement("script");
+ scriptElement.setAttribute("id", "jsonScript");
+ scriptElement.setAttribute("src",
+ "http://books.google.com/books?bibkeys=" +
+ escape(isbnList) + "&jscmd=viewapi&callback=unhideGoogleBooksLink");
+ scriptElement.setAttribute("type", "text/javascript");
+ // make the request to Google Book Search
+ document.documentElement.firstChild.appendChild(scriptElement);
+ }
+}
+
+function resultPageIsDone(pos) {
+
+ return (recordsHandled == getDisplayCount()
+ || recordsHandled + getOffset() == getHitCount());
+}
+
+var resultCCHeaderApplied = false;
+
+/* -------------------------------------------------------------------- */
+/* dynamically add the copy count rows based on the org type 'countsrow'
+ is the row into which we will add TD's to hold the copy counts
+ This code generates copy count cells with an id of
+ 'copy_count_cell_<depth>_<pagePosition>' */
+function resultAddCopyCounts(rec, pagePosition) {
+
+ var r = table.rows[pagePosition + 1];
+ var countsrow = $n(r, config.names.result.counts_row );
+ var ccell = $n(countsrow, config.names.result.count_cell);
+
+ var nodes = orgNodeTrail(findOrgUnit(getLocation()));
+ var node = nodes[0];
+ var type = findOrgType(node.ou_type());
+ ccell.id = "copy_count_cell_" + type.depth() + "_" + pagePosition;
+ ccell.title = type.opac_label();
+ //addCSSClass(ccell, config.css.result.cc_cell_even);
+
+ var lastcell = ccell;
+ var lastheadcell = null;
+
+ var cchead = null;
+ var ccheadcell = null;
+ if(!resultCCHeaderApplied && !getLasso()) {
+ ccrow = $('result_thead_row');
+ ccheadcell = ccrow.removeChild($n(ccrow, "result_thead_ccell"));
+ var t = ccheadcell.cloneNode(true);
+ lastheadcell = t;
+ t.appendChild(text(type.opac_label()));
+ ccrow.appendChild(t);
+ resultCCHeaderApplied = true;
+ }
+
+ if(nodes[1]) {
+
+ var x = 1;
+ var d = findOrgDepth(nodes[1]);
+ var d2 = findOrgDepth(nodes[nodes.length -1]);
+
+ for( var i = d; i <= d2 ; i++ ) {
+
+ ccell = ccell.cloneNode(true);
+
+ //if((i % 2)) removeCSSClass(ccell, "copy_count_cell_even");
+ //else addCSSClass(ccell, "copy_count_cell_even");
+
+ var node = nodes[x++];
+ var type = findOrgType(node.ou_type());
+
+ ccell.id = "copy_count_cell_" + type.depth() + "_" + pagePosition;
+ ccell.title = type.opac_label();
+ countsrow.insertBefore(ccell, lastcell);
+ lastcell = ccell;
+
+ if(ccheadcell) {
+ var t = ccheadcell.cloneNode(true);
+ t.appendChild(text(type.opac_label()));
+ ccrow.insertBefore(t, lastheadcell);
+ lastheadcell = t;
+ }
+ }
+ }
+
+ unHideMe($("search_info_table"));
+}
+
+/* collect copy counts for a record using method 'methodName' */
+function resultCollectCopyCounts(rec, pagePosition, methodName) {
+ if(rec == null || rec.doc_id() == null) return;
+
+ var loc = getLasso();
+ if (loc) loc = -loc;
+ else loc= getLocation();
+
+ var req = new Request(methodName, loc, rec.doc_id(), getForm() );
+ req.request.userdata = [ rec, pagePosition ];
+ req.callback(resultHandleCopyCounts);
+ req.send();
+}
+
+function resultHandleCopyCounts(r) {
+ runEvt('result', 'copyCountsReceived', r.userdata[0], r.userdata[1], r.getResultObject());
+}
+
+
+/* XXX Needs to understand Lasso copy counts... */
+/* display the collected copy counts */
+function resultDisplayCopyCounts(rec, pagePosition, copy_counts) {
+ if(copy_counts == null || rec == null) return;
+
+ if (getLasso()) {
+ var copy_counts_lasso = {
+ transcendant : null,
+ count : 0,
+ unshadow : 0,
+ available : 0,
+ depth : -1,
+ org_unit : getLasso()
+ };
+
+ for (var i in copy_counts) {
+ copy_counts_lasso.transcendant = copy_counts[i].transcendant;
+ copy_counts_lasso.count += parseInt(copy_counts[i].count);
+ copy_counts_lasso.unshadow += parseInt(copy_counts[i].unshadow);
+ copy_counts_lasso.available += parseInt(copy_counts[i].available);
+ }
+
+ copy_counts = [ copy_counts_lasso ];
+ }
+
+ var i = 0;
+ var metarecords = (findCurrentPage() == MRESULT);
+ while(copy_counts[i] != null) {
+ var cell = $("copy_count_cell_" + i +"_" + pagePosition);
+ var cts = copy_counts[i];
+ cell.appendChild(text(cts.available + " / " + cts.count));
+
+ if (!enableHoldsOnAvailable && (i == (copy_counts.length - 1))) {
+ var resultTBody = findParentByNodeName(cell, 'TBODY');
+ if (cts.available == 0 && cts.count > 0 && !metarecords) {
+ dojo.query('[name="place_hold_span"]', resultTBody).removeClass('hide_me');
+ } else {
+ dojo.query('[name="place_hold_span"]', resultTBody).addClass('hide_me');
+ }
+ }
+
+ if(isXUL()) {
+ /* here we style opac-invisible records for xul */
+
+ if( cts.depth == 0 ) {
+ if(!cts.transcendant && !cts.unshadow) {
+ _debug("found an opac-shadowed record: " + rec.doc_id());
+ var row = cell.parentNode.parentNode.parentNode.parentNode.parentNode;
+ if( cts.count == 0 )
+ addCSSClass( row, 'no_copies' );
+ else
+ addCSSClass( row, 'shadowed' );
+ }
+ }
+ }
+ i++;
+ }
+}
+
Added: conifer/branches/rel_1_6_1/web/opac/skin/lul/xml/result/result_table.xml
===================================================================
--- conifer/branches/rel_1_6_1/web/opac/skin/lul/xml/result/result_table.xml (rev 0)
+++ conifer/branches/rel_1_6_1/web/opac/skin/lul/xml/result/result_table.xml 2010-09-13 19:41:02 UTC (rev 988)
@@ -0,0 +1,293 @@
+<!-- Search results are spit into this table -->
+
+<div id='result_table_div' xmlns:xi="http://www.w3.org/2001/XInclude">
+
+ <table id='res_table'>
+
+ <!-- for some reason, this is the only way i can force the cell widths -->
+ <thead id='result_thead'>
+ <tr>
+ <td class='result_table_pic_header'></td>
+ <td> </td>
+ </tr>
+ </thead>
+
+ <tbody id='result_table'>
+ <tr>
+
+ <td class='result_table_row'>
+ <!--#include virtual="result_info.xml"-->
+ </td>
+ </tr>
+
+ <!-- Template for displaying a search result. This row template is cloned and inserted
+ for each result returned -->
+
+ <tr id='result_table_template' class='hide_me'>
+
+ <!-- Jacket image goes here -->
+
+ <td class='result_table_row' align='left'>
+ <table class='result_table_subtable'>
+ <tbody class='result_table_subtbody'>
+
+ <tr style='height: 1em' name='counts_row'>
+
+ <td rowspan='5' class='result_table_pic_header'>
+ <a><img name='item_jacket' class='result_table_pic'/></a>
+ </td>
+
+ <td class='result_table_title_cell' name='result_table_title_cell'>
+ <!-- Title goes here -->
+ <a title="&result.table.keyword;" name='item_title' class='search_link'>
+ <!-- Title goes here -->
+ </a>
+ </td>
+
+ <!-- Copy this td for each copy count appended -->
+ <td rowspan='5' nowrap='nowrap' name="copy_count_cell" class='copy_count_cell'>
+ </td>
+
+ </tr>
+
+ <tr style='height: 1em' >
+ <td class='result_table_author_cell'>
+ <a title="&result.table.author;" name='item_author' class='search_link'>
+ <!-- Author goes here -->
+ </a>
+ <div>
+ <span name='result_table_extra_span' class='hide_me'>
+ <span name='result_table_pub_box' style='padding-left: 10px;'>
+ <span name='result_table_edition_span' style='padding-left: 10px;'></span> |
+ <span name='result_table_pub_span'> </span> |
+ <span name='result_table_phys_span'> </span>
+ </span>
+ </span>
+ </div>
+ </td>
+ </tr>
+
+ <tr name="local_callnumber_list" class="result_table_title_cell hide_me">
+ <td colspan="2">&result.localCallNumbers;
+ <!-- Prevent records with dozens of items attached from filling the screen -->
+ <span type='opac/slot-data+marcxml-full' query='volumes'>
+ <span class='hide_me' debug='true' type='opac/slot-format'><![CDATA[
+ var item_cnt = 0;
+ var max_items = 4;
+
+ var output = dojo.create('span');
+ dojo.query('volume', item).forEach(function(vol) {
+ if (item_cnt >= max_items) {
+ return output.innerHTML;
+ }
+ dojo.query('copy', vol).forEach(function (cp) {
+ if (cp.getAttribute('deleted') == 't') {
+ return;
+ }
+ var loc_id;
+ var vol_appended = false;
+ dojo.query('location', cp).forEach(function (location) {
+ loc_id = parseInt(location.getAttribute('ident'));
+ if (loc_id != 8 && loc_id != 20) {
+ if (!vol_appended) {
+ dojo.create('b', { "innerHTML": vol.getAttribute('label') }, output);
+ vol_appended = true;
+ }
+ var pfx = dojo.doc.createTextNode(' - ');
+ output.appendChild(pfx);
+ dojo.create('b', { "innerHTML": dojox.xml.parser.textContent(location) }, output);
+ }
+ });
+ if (loc_id == 8 || loc_id == 20) {
+ return;
+ }
+ dojo.query('status', cp).forEach(function (status) {
+ var pfx = dojo.doc.createTextNode(' (');
+ output.appendChild(pfx);
+ dojo.create('b', { "innerHTML": dojox.xml.parser.textContent(status) }, output);
+ var sfx = dojo.doc.createTextNode(')');
+ output.appendChild(sfx);
+ });
+ dojo.create('br', null, output);
+
+ item_cnt++;
+ if (item_cnt >= max_items) {
+ output.appendChild(dojo.doc.createTextNode('... more items in full record'));
+ }
+ });
+ });
+ return output.innerHTML;
+ ]]></span>
+ </span>
+
+ <!-- Be lenient in what we accept -->
+ <span type='opac/slot-data+marcxml-full' query='volumes volume uris uri'>
+ <span class='hide_me' type='opac/slot-format'><![CDATA[
+ var output = dojo.create('span');
+ var uri = new Object;
+ uri.href = item.getAttribute('href');
+ uri.label = item.getAttribute('label');
+ uri.use = item.getAttribute('use_restriction');
+ if (uri.href == uri.label) {
+ if (uri.use && uri.use != uri.label) {
+ uri.label = uri.use;
+ uri.use = null;
+ }
+ }
+ var link = dojo.create('a', {"class":"search_link", "href": uri.href});
+ var link_text = dojo.doc.createTextNode(uri.label);
+ link.appendChild(link_text);
+ output.appendChild(link);
+
+ if (uri.use) {
+ var use_text = dojo.doc.createTextNode(' (' + uri.use + ')');
+ output.appendChild(use_text);
+ }
+ dojo.create('br', null, output);
+ return output.innerHTML;
+ ]]></span>
+ </span>
+
+ </td>
+ </tr>
+
+ <tr style='height:1em;' >
+ <td name='result_table_format_cell' class='result_table_format_cell'>
+
+ <a name='text_link' class='search_link'>
+ <img src='../../../../images/tor/text.jpg' class='dim tor_pic' />
+ </a>
+
+ <a name='sound recording-nonmusical_link' class='search_link'>
+ <img src='../../../../images/tor/sound recording-nonmusical.jpg' class='dim tor_pic' />
+ </a>
+
+ <a name='moving image_link' class='search_link'>
+ <img src='../../../../images/tor/moving image.jpg' class='dim tor_pic' />
+ </a>
+
+ <a name='software, multimedia_link' class='search_link'>
+ <img src='../../../../images/tor/software, multimedia.jpg' class='dim tor_pic' />
+ </a>
+
+ <a name='sound recording-musical_link' class='search_link'>
+ <img src='../../../../images/tor/sound recording-musical.jpg' class='dim tor_pic' />
+ </a>
+
+ <a name='cartographic_link' class='search_link'>
+ <img src='../../../../images/tor/cartographic.jpg' class='dim tor_pic' />
+ </a>
+
+ <a name='mixed material_link' class='search_link'>
+ <img src='../../../../images/tor/mixed material.jpg' class='dim tor_pic' />
+ </a>
+
+ <a name='notated music_link' class='search_link'>
+ <img src='../../../../images/tor/notated music.jpg' class='dim tor_pic' />
+ </a>
+
+ <a name='sound recording_link' class='search_link'>
+ <img src='../../../../images/tor/sound recording.jpg' class='dim tor_pic' />
+ </a>
+
+ <a name='still image_link' class='search_link'>
+ <img src='../../../../images/tor/still images.jpg' class='dim tor_pic' />
+ </a>
+
+ <a name='three dimensional object_link' class='search_link'>
+ <img src='../../../../images/tor/three dimensional object.jpg' class='dim tor_pic' />
+ </a>
+
+ <span class='hide_me'
+ style='color: #9999FF; padding-left: 10px; font-size: 7pt; font-weight: 300;'>
+ <span>&common.relevancy; </span><span name='relevancy_span'> </span>
+ </span>
+
+ <span class='hide_me' name='place_hold_span'>
+ <a style='padding-left: 8px;' href='javascript:void(0);'
+ class='classic_link' name='place_hold_link'>&opac.holds.placeHold;</a>
+ </span>
+
+ <!-- Empty span used for creating unAPI links -->
+ <abbr style='padding-left: 8px;' name="unapi" class="unapi-id">
+ <!-- unAPI URI goes here -->
+ </abbr>
+
+ <!-- Empty span used for creating Google Book Search-->
+ <span name="googleBooksLink" class="hide_me">
+ <a style='padding-left: 8px;' class='classic_link' name="googleBooks-link">&result.googleBooks.browse;</a>
+ </span>
+
+
+ </td>
+ </tr>
+
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+
+ <!-- ====================== -->
+ <table style='width: 100%; margin-top: 12px;' id='result_info_2' class='hide_me'>
+ <tbody>
+
+ <tr class='color_4' style='height: 1em;'>
+
+ <td style='vertical-align: top;' id='next_prev_links2'>
+
+ <span class='hide_me' id='result_info_div2' style='font-size: 9pt;'>
+ <span> &common.results; </span>
+ <b id='offset_start2'> </b>
+ <span> - </span>
+ <b id='offset_end2'> </b>
+ <span> &common.ofAtLeast; </span>
+ <b id='result_count2'> </b>
+ <span style='padding-left: 6px;'> (page </span>
+ <span id='current_page2'> </span>
+ <span> &common.of; </span>
+ <span id='num_pages2'> </span>
+ </span>
+
+ <span id='start_end_links_span2' class='hide_me'
+ style='padding-left: 40px;' >
+ <a class='search_page_nav_link' id='search_home_link2'
+ title="&rdetail.page.results;">&rdetail.start;</a><a class='search_page_nav_link'
+ id='prev_link2' title='&rdetail.page.previous;'>&rdetail.page.previous.symbol;</a>
+
+ <span class='search_page_nav_link' id='page_numbers2'> </span>
+ <a class='search_page_nav_link' id='next_link2'
+ title='&rdetail.page.next;'>&rdetail.page.next.symbol;</a>
+ <!--
+ <a class='search_page_nav_link'
+ id='end_link2' title="&rdetail.page.last;">&rdetail.end;</a>
+ -->
+ </span>
+
+ </td>
+
+ <td colspan='5'
+ style='padding-bottom: 4px; text-align:center; vertical-align: top; border-bottom: 1px solid #E0E0E0;'>
+ <!--
+ <span id='search_info_table2' style='font-size: 8pt;'>
+ <b>Available copies / Total copies </b>
+ </span>
+ -->
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <!-- ====================== -->
+
+
+ <script language='javascript' type='text/javascript'>
+ config.names.result.format_cell = 'result_table_format_cell';
+ config.names.result.format_link = 'resource_link'
+ config.names.result.format_pic = 'format_pic'
+ </script>
+
+</div>
+
+
More information about the open-ils-commits
mailing list