From 9b1bdfc1e64e881ffbc4f8bd5fab4649628c2ccd Mon Sep 17 00:00:00 2001 From: artunit Date: Fri, 10 Sep 2010 21:02:17 +0000 Subject: [PATCH] syncing js files git-svn-id: svn://svn.open-ils.org/ILS-Contrib/conifer/branches/rel_1_6_1@983 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- web/opac/skin/uwin/js/adv_global.js | 6 +- web/opac/skin/uwin/js/copy_details.js | 49 +++- web/opac/skin/uwin/js/depth_selector.js | 11 +- web/opac/skin/uwin/js/myopac.js | 215 +++++++---------- web/opac/skin/uwin/js/rdetail.js | 406 ++++++++------------------------ web/opac/skin/uwin/js/result_common.js | 117 ++++++++- web/opac/skin/uwin/js/rresult.js | 6 +- web/opac/skin/uwin/js/search_bar.js | 11 + 8 files changed, 373 insertions(+), 448 deletions(-) diff --git a/web/opac/skin/uwin/js/adv_global.js b/web/opac/skin/uwin/js/adv_global.js index a8a0a1413d..74edd3fe61 100644 --- a/web/opac/skin/uwin/js/adv_global.js +++ b/web/opac/skin/uwin/js/adv_global.js @@ -121,6 +121,10 @@ function initSearchBoxes() { var types = getObjectKeys(search.searches); + // if we have browser cached data, clear it before populating from cookie + if (search.searches[types[0]].term) + clearSearchBoxes(); + /* pre-add the needed rows */ while($('adv_global_tbody').getElementsByTagName('tr').length - 1 < types.length) advAddGblRow(); @@ -307,7 +311,7 @@ function advBuildSearchBlob() { string = string.replace(/\s*$/,''); //searches[stype].term = string; if(searches) searches += ' '; - searches += stype + ':'+ string; + searches += stype + ': '+ string; } } diff --git a/web/opac/skin/uwin/js/copy_details.js b/web/opac/skin/uwin/js/copy_details.js index 762b13ee18..9d3b4070f2 100644 --- a/web/opac/skin/uwin/js/copy_details.js +++ b/web/opac/skin/uwin/js/copy_details.js @@ -2,8 +2,15 @@ var cpdTemplate; var cpdCounter = 0; var cpdNodes = {}; +/* showDueDate will show the due date in the OPAC */ +var showDueDate = false; +/* showDueTime will show the due time (hours and minutes) in the OPAC; + if showDueDate is false, then showDueTime has no effect +*/ +var showDueTime = false; + function cpdBuild( contextTbody, contextRow, record, callnumber, orgid, depth, copy_location ) { -var i = cpdCheckExisting(contextRow); + var i = cpdCheckExisting(contextRow); if(i) return i; var counter = cpdCounter++; @@ -25,6 +32,9 @@ var i = cpdCheckExisting(contextRow); unHideMe($n(templateRow, 'age_protect_label')); unHideMe($n(templateRow, 'create_date_label')); unHideMe($n(templateRow, 'holdable_label')); + } + + if (isXUL() || showDueDate) { unHideMe($n(templateRow, 'due_date_label')); } @@ -177,6 +187,9 @@ function cpdDrawCopies(r) { unHideMe($n(copyrow, 'age_protect_value')); unHideMe($n(copyrow, 'create_date_value')); unHideMe($n(copyrow, 'copy_holdable_td')); + } + + if(isXUL() || showDueDate) { unHideMe($n(copyrow, 'copy_due_date_td')); } @@ -219,6 +232,30 @@ function cpdDrawCopy(r) { ); } + /* show the book now link */ + l = $n(row, 'copy_reserve_link'); + unHideMe(l); + l.onclick = function() { + // XXX FIXME this duplicates things in cat/util.js + // Also needs i18n + dojo.require("fieldmapper.Fieldmapper"); + var r = fieldmapper.standardRequest( + ["open-ils.booking", + "open-ils.booking.resources.create_from_copies"], + [G.user.session, [copy.id()]] + ); + if (!r) { + alert("No response from server!"); + } else if (r.ilsevent != undefined) { + alert("Error from server:\n" + js2JSON(r)); + } else { + xulG.auth = {"session": {"key": G.user.session}}; + xulG.bresv_interface_opts = {"booking_results": r}; + location.href = "/eg/booking/reservation"; + } + } + + if( copy.age_protect() ) appendClear($n(row, 'age_protect_value'), text(copy.age_protect().name())); @@ -236,15 +273,21 @@ function cpdDrawCopy(r) { } else { $n(row, 'copy_is_holdable').appendChild(text(no)); } + } + if (isXUL() || showDueDate) { var circ; if( copy.circulations() ) { circ = copy.circulations()[0]; if( circ ) { - $n(row, 'copy_due_date').appendChild(text(circ.due_date().replace(/[T ].*/,''))); + var due_time = dojo.date.stamp.fromISOString(circ.due_date().replace(/(T\d\d:\d\d:\d\d)([+-]\d\d)(\d)/, "$1$2:$3")); + if( showDueTime ) { + $n(row, 'copy_due_date').appendChild(text(dojo.date.locale.format(due_time, {"formatLength": "medium"}))); + } else { + $n(row, 'copy_due_date').appendChild(text(dojo.date.locale.format(due_time, {"selector": "date", "formatLength": "medium"}))); + } } } - } r.args.copy = copy; diff --git a/web/opac/skin/uwin/js/depth_selector.js b/web/opac/skin/uwin/js/depth_selector.js index 1bd983ee48..6bd4b0ef7d 100644 --- a/web/opac/skin/uwin/js/depth_selector.js +++ b/web/opac/skin/uwin/js/depth_selector.js @@ -78,6 +78,7 @@ function buildLocationSelector(newLoc) { var type; if (location) type = findOrgType(location.ou_type()); + var orgHiding = checkOrgHiding(); while( type && location ) { var n = node.cloneNode(true); n.setAttribute("value", type.depth()); @@ -85,8 +86,14 @@ function buildLocationSelector(newLoc) { n.appendChild(text(type.opac_label())); selector.appendChild(n); location = findOrgUnit(location.parent_ou()); - if(location) type = findOrgType(location.ou_type()); - else type = null; + if(location) { + type = findOrgType(location.ou_type()); + if (orgHiding && orgHiding.depth > type.depth()) { + type = null; + } + } else { + type = null; + } } selector.appendChild(node); diff --git a/web/opac/skin/uwin/js/myopac.js b/web/opac/skin/uwin/js/myopac.js index 3eccb251eb..3e4ca8a0b0 100644 --- a/web/opac/skin/uwin/js/myopac.js +++ b/web/opac/skin/uwin/js/myopac.js @@ -8,6 +8,10 @@ var fleshedContainers = {}; var holdCache = {}; var holdStatusCache = {}; var allowPendingAddr = false; +var preventRenewOverdue = false; +var myopacEnableRefWorks = true; +var myopacRefWorksHost = 'http://refworks.scholarsportal.info'; + function clearNodes( node, keepArray ) { if(!node) return; @@ -165,19 +169,42 @@ function myOPACDrawCheckedOutSlim(r) { return; } + var totalAsync = checked.overdue.length + checked.out.length; + var fetchedCircs = []; + var collectCircs = function(r) { + var circ = r.getResultObject(); + circ._od = r.od; + fetchedCircs.push(circ); + if(fetchedCircs.length < totalAsync) return; + + // sort by due date, oldest to newest + fetchedCircs = fetchedCircs.sort( + function(a, b) { + if(a.due_date() > b.due_date()) return 1; + return -1; + } + ) + + dojo.forEach(fetchedCircs, + function(circ) { + myOPACDrawCheckedItem(circ, tbody); + } + ); + } + for( var i = 0; i < checked.overdue.length; i++ ) { var req = new Request(FETCH_CIRC_BY_ID, G.user.session, checked.overdue[i]); - req.request.tbody = tbody; + //req.request.tbody = tbody; req.request.od = true; - req.callback(myOPACDrawCheckedItem); + req.callback(collectCircs); req.send(); } for( var i = 0; i < checked.out.length; i++ ) { var req = new Request(FETCH_CIRC_BY_ID, G.user.session, checked.out[i]); - req.request.tbody = tbody; - req.callback(myOPACDrawCheckedItem); + //req.request.tbody = tbody; + req.callback(collectCircs); req.send(); } @@ -193,13 +220,14 @@ function myOPACDrawCheckedOutSlim(r) { } -function myOPACDrawCheckedItem(r) { +//function myOPACDrawCheckedItem(r) { +function myOPACDrawCheckedItem(circ, tbody) { - var circ = r.getResultObject(); - var tbody = r.tbody; + //var circ = r.getResultObject(); + //var tbody = r.tbody; var row = checkedRowTemplate.cloneNode(true); row.id = 'myopac_checked_row_ ' + circ.id(); - row.setAttribute('circid', circ.id()); + row.setAttribute('circid', circ.id()); var due = _trimTime(circ.due_date()); @@ -208,7 +236,7 @@ function myOPACDrawCheckedItem(r) { //var rnlink = $n( row, "myopac_checked_renew_link" ); //if( r.od ) due = elem('b', {style:'color:red;font-size:110%'},due); - if( r.od ) { + if( circ._od ) { due = elem('b', null, due); addCSSClass(due, 'overdue'); } else { @@ -221,7 +249,8 @@ function myOPACDrawCheckedItem(r) { //rnlink.setAttribute('href', 'javascript:myOPACRenewCirc("'+circ.id()+'");'); circsCache.push(circ); - if( circ.renewal_remaining() < 1 ) { + // Disable renewals if no renewals left or item already overdue + if( circ.renewal_remaining() < 1 || (preventRenewOverdue && circ._od)) { $n(row, 'selectme').disabled = true; if(!__can_renew_one) $('mo_renew_button').disabled = true; @@ -370,7 +399,7 @@ function myOPACDrawHolds(r) { var exp_date; if(h.expire_time()) { - exp_date = dojo.date.stamp.fromISOString(h.expire_time()); + exp_date = dojo.date.stamp.fromISOString(h.expire_time().replace(/(T\d\d:\d\d:\d\d)([+-]\d\d)(\d)/, "$1$2:$3")); $n(row, 'myopac_hold_expire_time').appendChild( text(dojo.date.locale.format(exp_date, {selector:'date'}))); } @@ -560,6 +589,7 @@ function _finesFormatNumber(num) { //function _trimTime(time) { if(!time) return ""; return time.replace(/\ .*/,""); } function _trimTime(time) { if(!time) return ""; + time = time.replace(/(T\d\d:\d\d:\d\d)([+-]\d\d)(\d)/, "$1$2:$3"); var d = dojo.date.stamp.fromISOString(time); if(!d) return ""; /* date parse failed */ return d.iso8601Format('YMD'); @@ -567,7 +597,7 @@ function _trimTime(time) { function _trimSeconds(time) { if(!time) return ""; - var d = dojo.date.stamp.fromISOString(time); + var d = dojo.date.stamp.fromISOString(time.replace(/(T\d\d:\d\d:\d\d)([+-]\d\d)(\d)/, "$1$2:$3")); if(!d) return ""; /* date parse failed */ return d.iso8601Format('YMDHM',null,true,true); } @@ -665,8 +695,7 @@ function myOPACShowCircTransaction(trans, record, circ) { $n(row,'myopac_circ_trans_start'). appendChild(text(_trimTime(trans.xact_start()))); - - var due = _trimTime(circ.due_date()); + var due = _trimTime(circ.due_date()); var checkin = _trimTime(circ.stop_fines_time()); $n(row,'myopac_circ_trans_due').appendChild(text(due)) @@ -1063,7 +1092,7 @@ function myOPACUpdateEmail() { var req = new Request(UPDATE_EMAIL, G.user.session, email ); req.send(true); if(req.result()) { - G.user.usrname(email); + G.user.email(email); hideMe($('myopac_update_email_row')); userShown = false; alertId('myopac_email_success'); @@ -1147,7 +1176,23 @@ function myOPACShowBookbags(force) { link = $n(row, 'myopac_bb_make_unpublished'); link.setAttribute('href', 'javascript:myOPACMakeBBPublished("'+cont.id()+'", true);'); unHideMe(link); - + + var RW = $n(row, 'myopac_bb_exp_refworks'); + if (RW && myopacEnableRefWorks) { + var here = (findOrgUnit(getLocation())).name(); + var org_name = here.replace(" ", "+"); + var cgi = new CGI(); + + RW.setAttribute('href', + myopacRefWorksHost + '/express/expressimport.asp?vendor=' + + org_name + + '&filter=MARC+Format&database=All+MARC+Formats&encoding=65001&url=http%3A%2F%2F' + + cgi.server_name + '/opac/extras/feed/bookbag/marctxt-full/' + + cont.id() + ); + RW.setAttribute('target', 'RefWorksMain'); + unHideMe($n(row, 'myopac_bb_exp_refworks')); + } } else { unHideMe($n(row, 'myopac_bb_published_no')); var link = $n(row, 'myopac_bb_make_published'); @@ -1347,7 +1392,7 @@ function myOPACDrawNonCatCirc(r) { duration = parseInt(duration + '000'); var dtf = circ.circ_time(); - var start = dojo.date.stamp.fromISOString(circ.circ_time()); + var start = dojo.date.stamp.fromISOString(circ.circ_time().replace(/(T\d\d:\d\d:\d\d)([+-]\d\d)(\d)/, "$1$2:$3")); var due = new Date( start.getTime() + duration ); appendClear($n(row, 'circ_time'), text(due.iso8601Format('YMDHM', null, true, true))); } @@ -1391,120 +1436,36 @@ var __renew_circs = []; /* true if 1 renewal succeeded */ var __success_count = 0; -/* - holdBlock - checking for holds before allowing renewals +/* renews all selected circulations */ +function myOPACRenewSelected() { + var rows = myopacGetCheckedOutRows(); + if(!confirm($('myopac_renew_confirm').innerHTML)) return; + __success_count = 0; -*/ -function holdBlock(r) { - var rec = r.getResultObject(); - var circ = r.circ; - - //this may be inefficient, but go this route to snag needed title id - var new_req = new Request( FETCH_BIB_ID_BY_BARCODE, rec.barcode() ); - new_req.send(true); - - if (new_req) { - var record = new_req.result(); - - if (record){ - //alert(HOLDSU + ' start for ' + circ.id() + ' - ' + rec.barcode()); - /* - var init_request = new Request( LOGIN_INIT, HOLDSU ); - init_request.send(true); - var seed = init_request.result(); - - var args = { - password : hex_md5(seed + hex_md5(HOLDSP)), - type : "opac", - org : getOrigLocation(), - username : HOLDSU - }; - - var auth_request = new Request( LOGIN_COMPLETE, args ); - - auth_request.request.alertEvent = false; - auth_request.send(true); - var auth_result = auth_request.result(); - - if(!auth_result) { - alertId('problem with renewing'); - return null; - } - - var temp_session = auth_result.payload.authtoken; - */ - - //if you needed a special session for this, would use the above - //and pass it in the call, however, this doesn't seem to matter - //for this call - /* - new_req = new Request( "open-ils.circ:open-ils.circ.open_holds.retrieve", - temp_session, record, 'T', getOrigLocation() ); - */ - - //make the call with user's credentials - new_req = new Request( "open-ils.circ:open-ils.circ.open_holds.retrieve", - G.user.session, record, 'T', getOrigLocation() ); - - new_req.send(true); - - //we would clean up session right away if we had created one - /* - var sess_req = new Request(LOGIN_DELETE, temp_session); - sess_req.send(true); - try { sess_req.result(); } catch(E){} - */ - - if (new_req) { - record = new_req.result(); - if (record.length > 0) { - var renewTitle = __circ_titles[circ.id()]; - if (renewTitle) { - alert('Sorry, someone has requested \"' + renewTitle + - '\", it can not be renewed, please return this title to the library.'); - }//if renewTitle - return null; - } else { - //alert('renew for ' + circ.id()); - moRenewCirc( circ.target_copy(), G.user.id(), circ ); - }//if record - }//if new_req - - }//if record - }//if new_req - -}//holdBlock + for( var i = 0; i < rows.length; i++ ) { + var row = rows[i]; + if( ! $n(row, 'selectme').checked ) continue; + var circ_id = row.getAttribute('circid'); -/* renews all selected circulations */ -function myOPACRenewSelected() { + var circ; + for( var j = 0; j != circsCache.length; j++ ) + if(circsCache[j].id() == circ_id) + circ = circsCache[j]; - var rows = myopacGetCheckedOutRows(); - if(!confirm($('myopac_renew_confirm').innerHTML)) return; - __success_count = 0; - - for( var i = 0; i < rows.length; i++ ) { - - var row = rows[i]; - if( ! $n(row, 'selectme').checked ) continue; - var circ_id = row.getAttribute('circid'); - - var circ; - for( var j = 0; j != circsCache.length; j++ ) { - if(circsCache[j].id() == circ_id) { - circ = circsCache[j]; - var cp = circ.target_copy(); - if (cp) { - var hold_req = new Request(FETCH_FLESHED_COPY, - circ.target_copy() ); - hold_req.request.circ = circ; - hold_req.callback(holdBlock); - hold_req.send(); - }//if cp - }//if circsCache - }//for j - }//for i -}//myOPACRenewSelected + __renew_circs.push(circ); + } + + if( __renew_circs.length == 0 ) return; + + unHideMe($('my_renewing')); + moClearCheckedTable(); + + for( var i = 0; i < __renew_circs.length; i++ ) { + var circ = __renew_circs[i]; + moRenewCirc( circ.target_copy(), G.user.id(), circ ); + } +} /* renews a single circulation */ diff --git a/web/opac/skin/uwin/js/rdetail.js b/web/opac/skin/uwin/js/rdetail.js index e75eed5f87..7f59e6d37f 100644 --- a/web/opac/skin/uwin/js/rdetail.js +++ b/web/opac/skin/uwin/js/rdetail.js @@ -10,15 +10,11 @@ attachEvt("rdetail", "recordDrawn", rdetailGetPageIds); var rdetailLocalOnly = true; var rdetailShowLocal = true; var rdetailShowCopyLocation = true; -var rdetailGoogleBookPreview = false; +var rdetailGoogleBookPreview = true; var rdetailDisplaySerialHoldings = true; -var rdetailEnableRefWorks = true; +var rdetailEnableRefWorks = false; var rdetailRefWorksHost = 'http://refworks.scholarsportal.info'; - -/* threshold for paging */ -var rdetailBreakUpLargeSets = true; //flag for paging support -var pgThreshold = 15; //the number of items to invoke paging -var pgDisplay = 10; //number of items to display at a time +var enableHoldsOnAvailable = false; /* vars vars vars */ var record = null; @@ -49,6 +45,8 @@ var rdetailEnd = null; /* serials are currently the only use of Dojo strings in the OPAC */ if (rdetailDisplaySerialHoldings) { + dojo.require("dijit.Menu"); + dojo.require("dijit.form.Button"); dojo.requireLocalization("openils.opac", "opac"); opac_strings = dojo.i18n.getLocalization("openils.opac", "opac"); } @@ -134,6 +132,17 @@ function rdetailDraw() { var req = new Request(FETCH_MFHD_SUMMARY, getRid()); req.callback(_holdingsDraw); req.send(); + if (isXUL()) { + var here = findOrgUnit(getLocation()); + dojo.place("
" + + dojo.place("
" + dojo.string.substitute(opac_strings.HOLDINGS_TABLE_CAPTION, [hloc]) + "
", "rdetail_details_table", "after" @@ -279,10 +300,20 @@ function _holdingsDrawMFHD(holdings, entryNum) { if (isXUL()) { dojo.require('openils.Event'); dojo.require('openils.PermaCrud'); - dojo.place(" - " + opac_strings.EDIT_LABEL + "", - "mfhdHoldingsCaption", "last" - ); + var mfhd_edit = new dijit.Menu({}); + new dijit.MenuItem({onClick: function(){loadMarcEditor(holdings.id())}, label:opac_strings.EDIT_MFHD_RECORD}).placeAt(mfhd_edit, "first"); + new dijit.MenuItem({onClick:function(){ + var pcrud = new openils.PermaCrud({"authtoken": G.user.session}); + var mfhd_rec = pcrud.retrieve("sre", holdings.id()); + if (mfhd_rec) { + pcrud.eliminate(mfhd_rec); + alert(dojo.string.substitute(opac_strings.DELETED_MFHD_RECORD, [holdings.id()])); + } + }, label:opac_strings.DELETE_MFHD}).placeAt(mfhd_edit, "last"); + // new dijit.MenuItem({onClick:function(){alert("Edit properties " + holdings.id());}, label:opac_strings.EDIT_PROPERTIES}).placeAt(mfhd_edit, "last"); + var mfhd_mb = new dijit.form.DropDownButton({dropDown: mfhd_edit, label:opac_strings.EDIT_MFHD_MENU, style:"float:right"}); + mfhd_mb.placeAt("mfhdHoldingsCaption" + entryNum, "last"); + mfhd_edit.startup(); } } @@ -298,14 +329,7 @@ function _rdetailDraw(r) { G.ui.rdetail.title.appendChild(text(record.title())); buildSearchLink(STYPE_AUTHOR, record.author(), G.ui.rdetail.author); -// G.ui.rdetail.isbn.appendChild(text(cleanISBN(record.isbn()))); - var isbnText= text(cleanISBN(record.isbn())); - if (isbnText != null){ - if (isbnText.length > 0){ - G.ui.rdetail.isbn.appendChild(isbnText); - unHideMe($('rdetail_isbn_row')); - } - } + G.ui.rdetail.isbn.appendChild(text(cleanISBN(record.isbn()))); G.ui.rdetail.edition.appendChild(text(record.edition())); G.ui.rdetail.pubdate.appendChild(text(record.pubdate())); G.ui.rdetail.publisher.appendChild(text(record.publisher())); @@ -317,6 +341,13 @@ function _rdetailDraw(r) { } G.ui.rdetail.abstr.appendChild(text(record.synopsis())); + if (enableHoldsOnAvailable) { + unHideMe($('rdetail_place_hold')); + } else { + hideMe($('rdetail_place_hold')); + rdetailCheckAvailable(); + } + try{ if(record.isbn()) { if(ENABLE_ADDED_CONTENT_ATTRIB_LINKS) { @@ -359,7 +390,10 @@ function _rdetailDraw(r) { displayLabel = note; } } - $('rdetail_online').appendChild(elem('a', {href:href,'class':'classic_link'}, displayLabel)); + // IE in quirks mode doesn't render CSS styling for links where the class attribute + // comes after the href attribute, apparently; we can use Dojo to ensure the class + // attribute comes first + dojo.place('' + displayLabel + '', dojo.byId('rdetail_online')); if (note && note != displayLabel) { $('rdetail_online').appendChild(elem('span', {'class':'url_note'}, ' - ' + note)); } @@ -398,6 +432,7 @@ function _rdetailDraw(r) { ); RW.setAttribute('target', 'RefWorksMain'); + unHideMe($('rdetail_exp_refworks_span')); } @@ -410,6 +445,7 @@ function _rdetailDraw(r) { runEvt("rdetail", "recordDrawn"); recordsCache.push(record); + var breq = new Request(FETCH_BRE, [getRid()]); breq.callback( rdetailCheckDeleted ); breq.send(); @@ -420,11 +456,32 @@ function _rdetailDraw(r) { // grab added content acCollectData(cleanISBN(record.isbn()), rdetailhandleAC); - - rdetailShowCustomizedMARCs (); } +function rdetailCheckAvailable() { + var loc = getLocation(); + var rid = getRid(); + var req = new Request( 'open-ils.search:open-ils.search.biblio.record.copy_count', loc, rid ); + req.callback(rdetailEnableHold); + req.send(); +} +/* + * Display the "Place Hold" link if: + * * the current location holds at least one copy and + * * none of those copies are available + */ +function rdetailEnableHold(r) { + var ccDepths = r.getResultObject(); + if ( + ((ccDepths[(ccDepths.length - 1)].available) > 0) || + ((ccDepths[(ccDepths.length - 1)].count) == 0) + ) { + hideMe($('rdetail_place_hold')); + } else { + unHideMe($('rdetail_place_hold')); + } +} function rdetailCheckDeleted(r) { var br = r.getResultObject()[0]; @@ -675,58 +732,21 @@ function rdetailShowTOC(r) { } } -function sortOutCopies(loc_id, rec_id, form_id) { - var copies = 0; - var recreq = new Request(FETCH_R_COPY_COUNTS, loc_id, rec_id, form_id); - recreq.send(true); - if (recreq) { - var copy_info = recreq.result(); - for (var i in copy_info) { - //alert(loc_id + ' - ' + i + ' - ' + copy_info[i].available); - if (loc_id == copy_info[i].org_unit) - return copy_info[i].available; - }//for - }//if - - return copies; -} - - function rdetailBuildInfoRows() { var req; var method = FETCH_COPY_COUNTS_SUMMARY; - var cpCnt = 0; - - //we figure out the number of copies - if (rdetailBreakUpLargeSets) - cpCnt = sortOutCopies(getLocation(), getRid(), getForm()); - - if (rdetailShowCopyLocation && cpCnt < pgThreshold) + if (rdetailShowCopyLocation) method = FETCH_COPY_LOCATION_COUNTS_SUMMARY; if( rdetailShowLocal ) req = new Request(method, record.doc_id(), getLocation(), getDepth()) else req = new Request(method, record.doc_id()); - - if (rdetailBreakUpLargeSets && cpCnt >= pgThreshold) { - rdetailLocalOnly = true; - req.request.rec_id = record.doc_id(); - req.request.cpCnt = cpCnt; - //remove the location options for paged sets - try { - /* - hideMe(G.ui.rdetail.cp_info_local); - hideMe(G.ui.rdetail.cp_info_all); - */ - } catch(e) { } - req.callback(_rdetailBuildInfoPagedRows); - } else - req.callback(_rdetailBuildInfoRows); + req.callback(_rdetailBuildInfoRows); req.send(); } -function _rdetailRows(node, summaryStart, pgSize, summarySize, tot_copies) { +function _rdetailRows(node) { if( rdetailShowLocal && getLocation() != globalOrgTree.id() ) { var loc = findOrgUnit(getLocation()); @@ -755,7 +775,6 @@ function _rdetailRows(node, summaryStart, pgSize, summarySize, tot_copies) { var row = copyRow.cloneNode(true); row.id = "cp_info_" + node.id(); - //alert(row.id); var libtd = findNodeByName( row, config.names.rdetail.lib_cell ); var cntd = findNodeByName( row, config.names.rdetail.cn_cell ); @@ -764,7 +783,6 @@ function _rdetailRows(node, summaryStart, pgSize, summarySize, tot_copies) { var p = libtd.getElementsByTagName('a')[0]; libtd.insertBefore(text(node.name()), p); - libtd.setAttribute("style", "padding-left: " + ((findOrgDepth(node) - 1) * 9) + "px;"); if(!findOrgType(node.ou_type()).can_have_vols()) { @@ -777,19 +795,14 @@ function _rdetailRows(node, summaryStart, pgSize, summarySize, tot_copies) { libtd.setAttribute("colspan", numStatuses + 3 ); libtd.colSpan = numStatuses + 3; addCSSClass(row, 'copy_info_region_row'); - if (summaryStart!= undefined && pgSize!=undefined && - summarySize != undefined && tot_copies != undefined) - { - fillOutLinks(libtd, summaryStart, pgSize, summarySize, tot_copies); - } //if summaryStart - }//if + } copyRowParent.appendChild(row); } else { node = globalOrgTree; } for( var c in node.children() ) - _rdetailRows(node.children()[c], summaryStart, pgSize, summarySize, tot_copies); + _rdetailRows(node.children()[c]); } function rdetailCNPrint(orgid, cn) { @@ -802,216 +815,6 @@ function rdetailCNPrint(orgid, cn) { var localCNFound = false; var ctr = 0; -function _rdetailCL(r) { - if (!r) return; - var cl = r.getResultObject(); - if (cl) { - //alert(r.arrVal + " - " + cl.location().name()); - rdetailApplyStatuses(r.rowNode, r.cpc_temp, r.statuses); - - var isLocal = false; - if( orgIsMine( findOrgUnit(getLocation()), r.thisOrg ) ) { - isLocal = true; - if(!localCNFound) { - localCNFound = true; - defaultCN = r.arrVal; - } - } - - //if(isLocal) unHideMe(rowNode); - unHideMe(r.rowNode); - - rdetailSetPath( r.thisOrg, isLocal); - rdetailBuildBrowseInfo( r.rowNode, r.arrVal, isLocal, r.thisOrg, - cl.location().name()); - }//cl -} -function _rdetailFL(r) { - if (!r) return; - var fl = r.getResultObject(); - if (fl) { - var cp_request = new Request(FETCH_FLESHED_COPY, fl); - - cp_request.request.rowNode = r.rowNode; - cp_request.request.cpc_temp = r.cpc_temp; - cp_request.request.statuses = r.statuses; - cp_request.request.arrVal = r.arrVal; - cp_request.request.thisOrg = r.thisOrg; - cp_request.callback(_rdetailCL); - cp_request.send(); - }//fl -} - -/* - callsortfn - sorting an array of call numbers - - This probably won't work for every instance, but assumes last - number is a year. Anyway, this is how to get into the - array values, it could be refined, though a better way - will be to set up a special opensrf that can apply - postgres goodness to this. -*/ -function callsortfn(a,b) { - var callno1 = a[1]; - var callno2 = b[1]; - var callnum1 = 0; - var callnum2 = 0; - - var marker = callno1.lastIndexOf(' '); - if (marker != -1) - callnum1 = parseInt(callno1.substring(marker)); - marker = callno2.lastIndexOf(' '); - if (marker != -1) - callnum2 = parseInt(callno2.substring(marker)); - - //window.status = 'comparing ' + callnum1 + ' to ' + callnum2; - - if (callnum1 < callnum2) return -1; - if (callnum1 > callnum2) return 1; - return 0; -} - -function fillOutLinks(node, cpstart, cpsize, ssize, pieces) { - if (node) { - var theLink = document.location + ""; - var marker = theLink.indexOf("&cstart"); - if (marker > 0) - theLink = theLink.substring(0,marker); - - var summaryStmt = '(' + (cpstart + 1) + ' to ' + ssize + ' of ' + pieces; - node.appendChild(document.createTextNode(summaryStmt)); - if ((cpstart + 1) > cpsize) { - node.appendChild(document.createTextNode(' ')); - var pglink = document.createElement("a"); - pglink.appendChild(document.createTextNode('Start')); - pglink.setAttribute('href',theLink + '&cstart=0' + - '&csize=' + cpsize); - pglink.setAttribute('class','classic_link'); - node.appendChild(pglink); - node.appendChild(document.createTextNode(' ')); - var pglink = document.createElement("a"); - pglink.appendChild(document.createTextNode('<<')); - pglink.setAttribute('href',theLink + '&cstart=' + - (cpstart - cpsize) + '&csize=' + cpsize); - pglink.setAttribute('class','classic_link'); - node.appendChild(pglink); - node.appendChild(document.createTextNode(' ')); - /* - */ - } - if (ssize < pieces) { - node.appendChild(document.createTextNode(' ')); - var pglink = document.createElement("a"); - pglink.appendChild(document.createTextNode('>>')); - pglink.setAttribute('href',theLink + '&cstart=' + - ssize + '&csize=' + cpsize); - pglink.setAttribute('class','classic_link'); - node.appendChild(pglink); - node.appendChild(document.createTextNode(' ')); - var pglink = document.createElement("a"); - pglink.appendChild(document.createTextNode('End')); - pglink.setAttribute('href',theLink + '&cstart=' + - (pieces - cpsize) + '&csize=' + cpsize); - pglink.setAttribute('class','classic_link'); - node.appendChild(pglink); - /* - */ - } - node.appendChild(document.createTextNode(')')); - /* - */ - }//if node -} - -function _rdetailBuildInfoPagedRows(r) { - - //alert(r.getText()); - if (!r) return; - /* - */ - var summary = r.getResultObject(); - if(!summary) return; - - summary.sort(callsortfn); - if (rdetailShowCopyLocation) - unHideMe( $n( $('rdetail_copy_info_table'), 'rdetail_copylocation_header' ) ); - - removeChildren(copyRowParent); - - var rec_id = r.rec_id; - //var tot_copies = r.cpCnt; - var tot_copies = summary.length; - var cgi = new CGI(); - var parm = cgi.param("cstart"); - if (parm == undefined) - parm = 0; - var summaryStart = parseInt(parm); - parm = cgi.param("csize"); - if (parm == undefined) - parm = pgDisplay; - var summarySize = parseInt(parm) + summaryStart; - if (summarySize > tot_copies) - summarySize = tot_copies; - var pgSize = parseInt(parm); - - _rdetailRows(null,summaryStart, pgSize, summarySize, tot_copies); - var found = false; - - for( var i = summaryStart; i < summary.length && i < summarySize; i++ ) { - var arr = summary[i]; - globalCNCache[arr[1]] = 1; - var thisOrg = findOrgUnit(arr[0]); - var rowNode = $("cp_info_" + thisOrg.id()); - if(!rowNode) continue; - - if(rowNode.getAttribute("used")) { - - if( rowNode.nextSibling ) { - sib = rowNode.nextSibling; - o ='cp_info_'+thisOrg.id()+'_'; - /* push the new row on as the last row for this org unit */ - while( sib && sib.id.match(o) ) { - sib = sib.nextSibling; - } - if(sib) - rowNode = copyRowParent.insertBefore(copyRow.cloneNode(true), sib); - else - rowNode = copyRowParent.appendChild(copyRow.cloneNode(true)); - } else { - rowNode = copyRowParent.appendChild(copyRow.cloneNode(true)); - } - - var n = findNodeByName( rowNode, config.names.rdetail.lib_cell ); - n.appendChild(text(thisOrg.name())); - n.setAttribute("style", "padding-left: " + ((findOrgDepth(thisOrg) - 1) * 9) + "px;"); - rowNode.id = "cp_info_" + thisOrg.id() + '_' + (++ctr); - - } else { - rowNode.setAttribute("used", "1"); - } - - var cpc_temp = rowNode.removeChild( - findNodeByName(rowNode, config.names.rdetail.cp_count_cell)); - - var statuses = arr[2]; - var cl = ''; - - var recreq = new Request( FETCH_COPIES_FROM_VOLUME, rec_id, arr[1], arr[0]); - recreq.request.rowNode = rowNode; - recreq.request.cpc_temp = cpc_temp; - recreq.request.statuses = statuses; - recreq.request.arrVal = arr[1]; - recreq.request.thisOrg = thisOrg; - recreq.callback(_rdetailFL); - recreq.send(); - - - if( i == summary.length - 1 && !defaultCN) defaultCN = arr[1]; - } - - if(!found) unHideMe(G.ui.rdetail.cp_info_none); -} - function _rdetailBuildInfoRows(r) { if (rdetailShowCopyLocation) @@ -1023,19 +826,9 @@ function _rdetailBuildInfoRows(r) { var summary = r.getResultObject(); if(!summary) return; - var cgi = new CGI(); - var parm = cgi.param("cstart"); - if (parm == undefined) - parm = 0; - var summaryStart = parseInt(parm); - parm = cgi.param("csize"); - if (parm == undefined) - parm = 25; - var summarySize = parseInt(parm); var found = false; - //for( var i = 0; i < summary.length; i++ ) { - for( var i = summaryStart; i < summary.length && i < summarySize; i++ ) { + for( var i = 0; i < summary.length; i++ ) { var arr = summary[i]; globalCNCache[arr[1]] = 1; @@ -1126,9 +919,9 @@ function rdetailBuildBrowseInfo(row, cn, local, orgNode, cl) { _debug('setting action clicks for cn ' + cn); var dHref = 'javascript:rdetailVolumeDetails('+ - '{copy_location : "'+cl+'", rowid : "'+row.id+'", cn :"'+cn+'", depth:"'+depth+'", org:"'+orgNode.id()+'", local: '+local+'});'; + '{copy_location : "'+cl.replace(/\"/g, '\\"')+'", rowid : "'+row.id+'", cn :"'+cn.replace(/\"/g, '\\"')+'", depth:"'+depth+'", org:"'+orgNode.id()+'", local: '+local+'});'; - var bHref = 'javascript:rdetailShowCNBrowse("' + cn + '", '+orgNode.id()+', "'+depth+'");'; + var bHref = 'javascript:rdetailShowCNBrowse("' + cn.replace(/\"/g, '\\"') + '", '+orgNode.id()+', "'+depth+'");'; unHideMe( $n(row, 'details') ) $n(row, 'details').setAttribute('href', dHref); @@ -1154,7 +947,6 @@ function rdetailBuildBrowseInfo(row, cn, local, orgNode, cl) { function rdetailSetPath(org, local) { if( findOrgDepth(org) == 0 ) return; var row = $("cp_info_" + org.id()); - //alert("cp_info_" + org.id() + " - " + row.id + " - " + row.innerHTML); row.setAttribute("hasinfo", "1"); unHideMe(row); rdetailSetPath(findOrgUnit(org.parent_ou()), local); @@ -1275,15 +1067,15 @@ function GBPreviewCallback(GBPBookInfo) { } // Add a button below the book cover image to load the preview. -// GBPBadge = document.createElement( 'img' ); -// GBPBadge.src = 'http://books.google.com/intl/en/googlebooks/images/gbs_preview_button1.gif'; -// GBPBadge.title = $('rdetail_preview_badge').innerHTML; -// GBPBadge.style.border = 0; -// GBPBadgelink = document.createElement( 'a' ); -// GBPBadgelink.href = 'javascript:rdetailShowExtra("preview");'; -// GBPBadgelink.appendChild( GBPBadge ); -// $('rdetail_image_cell').appendChild( GBPBadgelink ); -// $('rdetail_preview_div').style.height = 600; + GBPBadge = document.createElement( 'img' ); + GBPBadge.src = 'http://books.google.com/intl/en/googlebooks/images/gbs_preview_button1.gif'; + GBPBadge.title = $('rdetail_preview_badge').innerHTML; + GBPBadge.style.border = 0; + GBPBadgelink = document.createElement( 'a' ); + GBPBadgelink.href = 'javascript:rdetailShowExtra("preview");'; + GBPBadgelink.appendChild( GBPBadge ); + $('rdetail_image_cell').appendChild( GBPBadgelink ); + $('rdetail_preview_div').style.height = 600; /* Display the "Preview" tab in the Extras section */ unHideMe( $('rdetail_preview_link' ) ); diff --git a/web/opac/skin/uwin/js/result_common.js b/web/opac/skin/uwin/js/result_common.js index 65faf8fdad..56411ef7d8 100644 --- a/web/opac/skin/uwin/js/result_common.js +++ b/web/opac/skin/uwin/js/result_common.js @@ -5,6 +5,27 @@ var lowHitCount = 4; var isbnList = ''; var googleBooksLink = false; var enableHoldsOnAvailable = false; +var enableExtraSearchesLowHits = false; +var localProxyPrefix = ''; + +/* 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; @@ -12,7 +33,8 @@ 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.recordReceived.push(resultDisplayRecord, resultAddCopyCounts); + G.evt.result.recordReceived.push(resultDisplayRecord); G.evt.result.copyCountsReceived.push(resultDisplayCopyCounts); G.evt.result.allRecordsReceived.push(resultBuildCaches, resultDrawSubjects, resultDrawAuthors, resultDrawSeries, function(){unHideMe($('result_info_2'))}, @@ -211,6 +233,10 @@ function resultLowHits() { resultSuggestSearchClass(); + if (enableExtraSearchesLowHits) { + resultSuggestExtraSearches(); + } + if(getTerm()) resultExpandSearch(); /* advanced search */ } @@ -250,12 +276,15 @@ function resultZeroHits() { showCanvas(); unHideMe($('result_low_hits')); unHideMe($('result_zero_hits_msg')); + //if(getTerm()) resultExpandSearch(); /* advanced search */ } function resultExpandSearch() { var top = findOrgDepth(globalOrgTree); - if(getDepth() == top) return; + + /* 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')); @@ -272,6 +301,33 @@ function resultExpandSearch() { } } +/* 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("
" + + esItem.description + ": " + extraSearchStuff.displayTerms + "
", "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; @@ -430,6 +486,23 @@ function unhideGoogleBooksLink (data) { } } +/* riff on buildTitleDetailLink from opac_utils */ +function buildResultTitleDetailLink(rec, link) { + if(!rec) return; + link.appendChild(text(normalize(truncate(rec.title(), 500)))); + var args = {}; + args.page = RDETAIL; + args[PARAM_RID] = rec.doc_id(); + // in IE, if the link text contains a '@', it replaces the innerHTML text + // with the value of the href attribute. Wait, what? Yes. Capture the + // innerHTML and put it back into place after the href is set + var linkText = link.innerHTML; // IE + link.setAttribute("href", buildOPACLink(args)); + link.innerHTML = linkText; // IE +} + + + /* 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) { @@ -498,19 +571,36 @@ function resultDisplayRecord(rec, pos, is_mr) { } else { buildunAPISpan($n(r,'unapi'), 'biblio-record_entry', rec.doc_id()); - buildTitleDetailLink(rec, title_link); + buildResultTitleDetailLink(rec, title_link); var args = {}; args.page = RDETAIL; args[PARAM_OFFSET] = 0; args[PARAM_RID] = rec.doc_id(); pic.parentNode.setAttribute("href", buildOPACLink(args)); + //don't bother with holds at this point + /* 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 - (and stolen again from lul :-)) + 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); @@ -651,7 +741,8 @@ function resultAddCopyCounts(rec, pagePosition) { ccheadcell = ccrow.removeChild($n(ccrow, "result_thead_ccell")); var t = ccheadcell.cloneNode(true); lastheadcell = t; - t.appendChild(text(type.opac_label())); + //t.appendChild(text(type.opac_label())); + t.appendChild(text(" ")); ccrow.appendChild(t); resultCCHeaderApplied = true; } @@ -738,8 +829,20 @@ function resultDisplayCopyCounts(rec, pagePosition, copy_counts) { while(copy_counts[i] != null) { var cell = $("copy_count_cell_" + i +"_" + pagePosition); var cts = copy_counts[i]; - cell.appendChild(text(cts.available + " / " + cts.count)); + var availMess = "Available"; + if (cts.count >= cts.available && cts.available > 1) + availMess = cts.available + " of " + cts.count + " Available"; + if (cts.count > cts.available && cts.available == 0) + availMess = "Checked Out"; + if (cts.count == 0 && cts.available == 0) + availMess = "Online"; + + //cell.appendChild(text(cts.available + " / " + cts.count)); + cell.appendChild(text(availMess)); + + //don't bother with holds at this point + /* if (!enableHoldsOnAvailable && (i == (copy_counts.length - 1))) { var resultTBody = findParentByNodeName(cell, 'TBODY'); if (cts.available == 0 && cts.count > 0 && !metarecords) { @@ -748,12 +851,13 @@ function resultDisplayCopyCounts(rec, pagePosition, copy_counts) { 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) { + if(cts.transcendant == null && cts.unshadow == 0) { _debug("found an opac-shadowed record: " + rec.doc_id()); var row = cell.parentNode.parentNode.parentNode.parentNode.parentNode; if( cts.count == 0 ) @@ -767,4 +871,3 @@ function resultDisplayCopyCounts(rec, pagePosition, copy_counts) { } } - diff --git a/web/opac/skin/uwin/js/rresult.js b/web/opac/skin/uwin/js/rresult.js index d93aa45471..4a7fb35957 100644 --- a/web/opac/skin/uwin/js/rresult.js +++ b/web/opac/skin/uwin/js/rresult.js @@ -30,7 +30,11 @@ function rresultDoSearch() { function rresultCollectIds() { var ids; - switch(getRtype()) { + var rtype = getRtype(); + if (rtype.indexOf('|') > -1) + rtype = rtype.substring(0,rtype.indexOf('|')); + + switch(rtype) { case RTYPE_COOKIE: ids = JSON2js(cookieManager.read(COOKIE_RIDS)); diff --git a/web/opac/skin/uwin/js/search_bar.js b/web/opac/skin/uwin/js/search_bar.js index 37dc49eaf6..67369f3425 100644 --- a/web/opac/skin/uwin/js/search_bar.js +++ b/web/opac/skin/uwin/js/search_bar.js @@ -34,6 +34,11 @@ function searchBarInit() { setSelector(_ts, getStype()); setSelector(_fs, getForm()); + /* If searching for journal title, set it to journal title */ + if (getStype() == 'title' && getBibLevel() == 's') { + dojo.byId('jtitle').selected = true; + } + depthSelInit(); @@ -74,6 +79,12 @@ function searchBarSubmit(isFilterSort) { args[PARAM_DEPTH] = d; args[PARAM_FORM] = _fs.options[_fs.selectedIndex].value; + /* Set the bib level to 's' for serials if the magic "Journal title" has ben chosen */ + if (_ts.options[_ts.selectedIndex].id == 'jtitle') { + args[PARAM_BIBLEVEL] = 's'; + } + + if($('opac.result.limit2avail')) { args[PARAM_AVAIL] = ($('opac.result.limit2avail').checked) ? 1 : ''; if( (val = getSelectorVal($('opac.result.sort'))) ) { -- 2.11.0