From: Jeff Godin Date: Sat, 16 May 2015 16:41:45 +0000 (-0700) Subject: WIP: JSPAC first pass at removing xml and js files X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4b63b547a61045203934f36acf30ba41f786814f;p=working%2FEvergreen.git WIP: JSPAC first pass at removing xml and js files Signed-off-by: Jeff Godin --- diff --git a/Open-ILS/web/opac/common/xml/item_lang_options.xml b/Open-ILS/web/opac/common/xml/item_lang_options.xml deleted file mode 100644 index 90ee666424..0000000000 --- a/Open-ILS/web/opac/common/xml/item_lang_options.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/Open-ILS/web/opac/skin/default/js/adv_global.js b/Open-ILS/web/opac/skin/default/js/adv_global.js deleted file mode 100644 index daf3e677ff..0000000000 --- a/Open-ILS/web/opac/skin/default/js/adv_global.js +++ /dev/null @@ -1,337 +0,0 @@ - -attachEvt("common", "run", advgInit); -attachEvt("common", "locationChanged", advSyncCopyLocLink ); - -var COOKIE_NOGROUP_RECORDS = 'grpt'; -var advSelectedOrg = null; - -function advgInit() { - - /* XXX */ - dojo.require('dojo.cookie'); - if( dojo.cookie(COOKIE_NOGROUP_RECORDS) || SHOW_MR_DEFAULT ) - $('adv_group_titles').checked = true; - - $n($('adv_global_tbody'), 'term').focus(); - - var ctypes = ["bib_level", "item_form", "item_type", "audience", "lit_form"]; - - var req = new Request('open-ils.fielder:open-ils.fielder.ccvm.atomic', {"cache":1,"query":{"ctype":ctypes, "opac_visible":"t", "is_simple":"f"}}); - req.callback(advDrawBibExtras); - req.request.ctypes = ctypes; - req.send(); - - var input = $n($('adv_global_trow'), 'term'); - input.focus(); - - var rows = $('adv_global_tbody').getElementsByTagName('tr'); - for(var t = 0; t < rows.length; t++) { - if($n(rows[t], 'term')) { - setEnterFunc($n(rows[t], 'term'), advSubmitGlobal); - } - } - - if(getSort() && getSortDir()) { - setSelector($('adv_global_sort_by'), getSort()); - setSelector($('adv_global_sort_dir'), getSortDir()); - if(getSort() != 'rel') - $('adv_global_sort_dir').disabled = false; - } - - if(getAvail()) - $('opac.result.limit2avail').checked = true; - - // not sure we want to propogate the pubdate filter, - // since other filters are not propogated - //advInitPubFilter(); - - if(!new CGI().param(PARAM_NOPERSIST_SEARCH)) - initSearchBoxes(); - advSyncCopyLocLink(getLocation()); -} - -function advInitPubFilter() { - var i1 = $('adv_global_pub_date_1'); - var i2 = $('adv_global_pub_date_2'); - var sel = $('adv_global_pub_date_type'); - if(getPubdBefore()) { - i1.value = getPubdBefore(); - setSelector(sel, 'before'); - } else if(getPubdAfter()) { - i1.value = getPubdAfter(); - setSelector(sel, 'after'); - } else if(getPubdBetween()) { - var values = getPubdBetween().split(','); - i1.value = values[0] - if(values[0] == values[1]) { - setSelector(sel, 'equals'); - } else { - setSelector(sel, 'between'); - i2.value = values[1]; - } - } -} - -function advSyncCopyLocLink(org) { - // display the option to filter by copy location - advLocationsLoaded = false; - advSelectedOrg = org; - removeChildren($('adv_copy_location_filter_select')); - - if(isTrue(findOrgType(findOrgUnit(org).ou_type()).can_have_vols())) { - unHideMe($('adv_copy_location_filter_row')); - advLoadCopyLocations(org); - } else { - hideMe($('adv_copy_location_filter_row')); - } - -} - -function clearSearchBoxes() { - var rows = $('adv_global_tbody').getElementsByTagName('tr'); - for(var t = 0; t < rows.length; t++) { - if($n(rows[t], 'term')) { - $n(rows[t], 'term').value = ''; - setSelector($n(rows[t], 'contains'), 'contains'); - setSelector($n(rows[t], 'type'), 'keyword'); - } - } - $n(rows[0], 'term').focus(); -} - - -function initSearchBoxes() { - /* loads the compiled search from the search cookie - and sets the widgets accordingly */ - - search = dojo.cookie(COOKIE_SEARCH); - if(!search) return; - _debug("loaded compiled search cookie: " + search); - - search = JSON2js(search); - if(!search) return; - - 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(); - - var rows = $('adv_global_tbody').getElementsByTagName('tr'); - - for(var t = 0; t < types.length; t++) { - var row = rows[t]; - setSelector($n(row, 'type'), types[t]); - var term = search.searches[types[t]].term; - - /* if this is a single - search, set the selector to nocontains */ - if(match = term.match(/^-(\w+)$/)) { - term = match[1]; - setSelector($n(row, 'contains'), 'nocontains'); - } - $n(row, 'term').value = term; - } -} - -function advAddGblRow() { - var tbody = $("adv_global_tbody"); - var newrow = $("adv_global_trow").cloneNode(true); - tbody.insertBefore(newrow, $("adv_global_addrow")); - var input = $n(newrow, "term"); - input.value = ""; - setEnterFunc(input, advSubmitGlobal); - $n(newrow, 'type').focus(); -} - -function advDrawBibExtras(r) { - var data = r.getResultObject(); - var ctypes = r.ctypes - dojo.forEach(ctypes, - function(ctype) { - var sel = $('adv_global_' + ctype); - var ctypeData = dojo.filter(data, function(item) { return item.ctype == ctype } ); - ctypeData = ctypeData.sort( - function(a,b) { /* sort alphabetically */ - return ((a.search_label ? a.search_label : a.value) < (b.search_label ? b.search_label : b.value)) ? -1 : 1; - } - ); - dojo.forEach(ctypeData, - function(thing) { - var opt = insertSelectorVal(sel, -1, (thing.search_label ? thing.search_label : thing.value), thing.code); - opt.setAttribute('title', (thing.search_label ? thing.search_label : thing.value)); - } - ); - } - ); -} - -function advSelToStringList(sel) { - var list = getSelectedList(sel); - var vals = []; - for( var i = 0; i < list.length; i++ ) { - var str = list[i]; - for( var j = 0; j < str.length; j++ ) { - //if(str.charAt(j) == ' ') continue; - vals.push(str.charAt(j)); - } - } - return vals.toString(); -} - -function advGetVisSelectorVals(id) { - var basic = id + '_basic'; - if(! $(id).className.match(/hide_me/)) - return advSelToStringList($(id)); - return advSelToStringList($(basic)); -} - -function advSubmitGlobal() { - - var sortdir = getSelectorVal($('adv_global_sort_dir')); - var sortby = getSelectorVal($('adv_global_sort_by')); - - var litforms = advGetVisSelectorVals('adv_global_lit_form'); - var itemforms = advGetVisSelectorVals('adv_global_item_form'); - var itemtypes = advGetVisSelectorVals('adv_global_item_type'); - var audiences = advGetVisSelectorVals('adv_global_audience'); - var biblevels = advGetVisSelectorVals('adv_global_bib_level'); - var locations = getSelectedList($('adv_copy_location_filter_select')) + ''; - var languages = getSelectedList($('adv_global_lang')) + ''; - var limit2avail = $('opac.result.limit2avail').checked ? 1 : '' - - var searches = advBuildSearchBlob(); - if(!searches) return; - - clearSearchParams(); - - var args = {}; - args.page = MRESULT; - args[PARAM_ITEMFORM] = itemforms; - args[PARAM_ITEMTYPE] = itemtypes; - args[PARAM_BIBLEVEL] = biblevels; - args[PARAM_LITFORM] = litforms; - args[PARAM_AUDIENCE] = audiences; - args[PARAM_LANGUAGE] = languages; - args[PARAM_COPYLOCS] = locations; - //args[PARAM_SEARCHES] = js2JSON(searches); /* break these out */ - args[PARAM_DEPTH] = depthSelGetDepth(); - args[PARAM_LOCATION] = depthSelGetNewLoc(); - args[PARAM_SORT] = sortby; - args[PARAM_SORT_DIR] = sortdir; - args[PARAM_ADVTYPE] = ADVTYPE_MULTI; - args[PARAM_STYPE] = ""; - args[PARAM_TERM] = searches; - args[PARAM_AVAIL] = limit2avail; - - // publicate year filtering - var pub1; - if( (pub1 = $('adv_global_pub_date_1').value) && (''+pub1).match(/\d{4}/)) { - switch(getSelectorVal($('adv_global_pub_date_type'))) { - case 'equals': - args[PARAM_PUBD_BETWEEN] = pub1+','+pub1; - break; - case 'before': - args[PARAM_PUBD_BEFORE] = pub1; - break; - case 'after': - args[PARAM_PUBD_AFTER] = pub1; - break; - case 'between': - var pub2 = $('adv_global_pub_date_2').value; - if((''+pub2).match(/\d{4}/)) - args[PARAM_PUBD_BETWEEN] = pub1+','+pub2; - break; - } - } - - /* pubdate sorting causes a record (not metarecord) search */ - if( sortby == SORT_TYPE_PUBDATE || !$('adv_group_titles').checked ) { - args.page = RRESULT; - args[PARAM_RTYPE] = RTYPE_MULTI; - } - - if($('adv_group_titles').checked ) - dojo.cookie(COOKIE_NOGROUP_RECORDS,'1'); - else - dojo.cookie(COOKIE_NOGROUP_RECORDS,null,{'expires':-1}); - - - goTo(buildOPACLink(args)); -} - - -function advBuildSearchBlob() { - - var searches = ''; - var tbody = $('adv_global_tbody'); - var rows = tbody.getElementsByTagName('tr'); - - for( var i = 0; i < rows.length; i++ ) { - - var row = rows[i]; - if(!(row && typeof row == 'object')) continue; - if(!row.getAttribute('type')) continue; - - var stype = getSelectorVal($n(row, 'type')); - var contains = getSelectorVal($n(row, 'contains')); - var term = $n(row, 'term').value; - if(!term) continue; - - var string = ""; - switch(contains) { - case 'contains' : - string += " " + term; - break; - - case 'nocontains' : { - // Normalize spaces so we don't get "- " embedded in the query - var words = term.replace(/\s+/g,' ').replace(/^\s*/,'').replace(/\s*$/,'').split(" "); - for( var j in words ) - string += " -" + words[j]; - } - break; - - case 'exact' : - if(term.indexOf('"') > -1) string += " " + term; - else string += " \"" + term + "\""; - break; - } - if(string) { - string = string.replace(/\\/g,' '); - string = string.replace(/^\s*/,''); - string = string.replace(/\s*$/,''); - //searches[stype].term = string; - if(searches) searches += ' '; - searches += stype + ': '+ string; - } - } - - _debug("created search query " + searches); - return searches; -} - - -// retrieves the shelving locations -var advLocationsLoaded = false; -function advLoadCopyLocations(org) { - if(org == null) - org = advSelectedOrg; - var req = new Request(FETCH_COPY_LOCATIONS, org); - req.callback(advShowCopyLocations); - req.send(); - advLocationsLoaded = true; -} - -// inserts the shelving locations into the multi-select -function advShowCopyLocations(r) { - var locations = r.getResultObject(); - var sel = $('adv_copy_location_filter_select'); - for(var i = 0; i < locations.length; i++) - insertSelectorVal(sel, -1, locations[i].name(), locations[i].id()); -} - - diff --git a/Open-ILS/web/opac/skin/default/js/advanced.js b/Open-ILS/web/opac/skin/default/js/advanced.js deleted file mode 100644 index cd48919e5f..0000000000 --- a/Open-ILS/web/opac/skin/default/js/advanced.js +++ /dev/null @@ -1,212 +0,0 @@ -/* advanced search interface */ - -attachEvt("common", "run", advInit); - -function advInit() { - - /* propogate these? */ - - depthSelInit(); - authoritySelInit(); - setEnterFunc( $n( $('advanced.marc.tbody'), 'advanced.marc.value'), advMARCRun ); - - unHideMe($('adv_quick_search_sidebar')); - - /* - if(isXUL()) - setSelector($('adv_quick_type'), 'tcn'); */ - - setEnterFunc($('adv_quick_text'), advGenericSearch); - setEnterFunc($('authority_browse_term'), advAuthorityBrowse); - - unHideMe($('adv_marc_search_sidebar')); - unHideMe($('adv_authority_browse_sidebar')); -} - - -function authoritySelInit() { - dojo.require("openils.Util"); - fieldmapper.standardRequest( - ["open-ils.supercat", "open-ils.supercat.authority.browse_axis_list"], { - "params": [true /* whole objects */], - "async": true, - "oncomplete": function(r) { - if ((r = openils.Util.readResponse(r))) { - dojo.empty("authority_browse_axis"); - dojo.forEach(r, function(axis) { - dojo.create("option", {"innerHTML": axis.name(), "value": axis.code()}, "authority_browse_axis"); - }); - } - } - } - ); -} - -function advAddMARC() { - var newt = $('adv_sdbar_table').cloneNode(true); - newt.id = ""; - unHideMe($n(newt, 'crow')); - $n(newt, 'advanced.marc.tag').value = ""; - $n(newt, 'advanced.marc.subfield').value = ""; - $n(newt, 'advanced.marc.value').value = ""; - $('adv_marc_search_sidebar').insertBefore(newt, $('adv_marc_submit')); -} - -function advMARCRun() { - - clearSearchParams(); - - var div = $('adv_marc_search_sidebar'); - var tbodies = div.getElementsByTagName('tbody'); - var searches = []; - - for( var i = 0; i < tbodies.length; i++ ) { - var tbody = tbodies[i]; - var val = advExtractMARC(tbody); - if(val) searches.push(val); - } - - if(searches.length == 0) return; - - var arg = {}; - arg.page = RRESULT; - arg[PARAM_FORM] = 'all' - arg[PARAM_RTYPE] = RTYPE_MARC; - arg[PARAM_OFFSET] = 0; - arg[PARAM_DEPTH] = depthSelGetDepth(); - arg[PARAM_LOCATION] = depthSelGetNewLoc(); - arg[PARAM_SEARCHES] = js2JSON(searches); - arg[PARAM_ADVTYPE] = ADVTYPE_MARC; - arg[PARAM_TERM] = ""; - - goTo(buildOPACLink(arg)); -} - - -/* EXAMPLE => {"term":"0516011901","restrict":[{"tag":"020","subfield":"a"}]} */ -function advExtractMARC(tbody) { - if(!tbody) return null; - var term = $n(tbody, 'advanced.marc.value').value; - if(!term) return null; - - var subfield = $n(tbody, 'advanced.marc.subfield').value; - if(!subfield) subfield = "_"; - - var tag = $n(tbody, 'advanced.marc.tag').value; - if(!tag) return null; - - return { 'term' : term.toLowerCase(), 'restrict' : [ { 'tag' : tag, 'subfield' : subfield } ] }; -} - -function advGenericSearch() { - clearSearchParams(); - var type = getSelectorVal($('adv_quick_type')); - - var term = $('adv_quick_text').value; - if(!term) return; - - var arg = {}; - - switch(type) { - - case 'isbn' : - arg.page = RRESULT; - arg[PARAM_STYPE] = ""; - arg[PARAM_TERM] = ""; - arg[PARAM_RTYPE] = RTYPE_ISBN; - arg[PARAM_OFFSET] = 0; - arg[PARAM_ADVTERM] = term.toLowerCase(); - break; - - case 'issn' : - arg.page = RRESULT; - arg[PARAM_STYPE] = ""; - arg[PARAM_TERM] = ""; - arg[PARAM_ADVTERM] = term.toLowerCase(); - arg[PARAM_OFFSET] = 0; - arg[PARAM_RTYPE] = RTYPE_ISSN; - break; - - case 'tcn' : - arg.page = RRESULT; - arg[PARAM_STYPE] = ""; - arg[PARAM_TERM] = ""; - arg[PARAM_ADVTERM] = term; - arg[PARAM_OFFSET] = 0; - arg[PARAM_RTYPE] = RTYPE_TCN; - break; - - case 'barcode': - advFindBarcode(term); - break; - - - case 'cn': - arg.page = CNBROWSE; - arg[PARAM_CN] = term; - arg[PARAM_DEPTH] = depthSelGetDepth(); - arg[PARAM_LOCATION] = depthSelGetNewLoc(); - break; - - case 'lccn': - arg.page = RRESULT; - arg[PARAM_FORM] = 'all' - arg[PARAM_RTYPE] = RTYPE_MARC; - arg[PARAM_OFFSET] = 0; - arg[PARAM_DEPTH] = depthSelGetDepth(); - arg[PARAM_LOCATION] = depthSelGetNewLoc(); - arg[PARAM_SEARCHES] = js2JSON([{ 'term' : term.toLowerCase(), - 'restrict' : [ { 'tag' : '010', 'subfield' : '_' } ] }]); - arg[PARAM_ADVTYPE] = ADVTYPE_MARC; - arg[PARAM_TERM] = ""; - break; - - - default: alert('not done'); - } - - if(arg.page) goTo(buildOPACLink(arg)); -} - - -function advFindBarcode(barcode) { - var req = new Request(FETCH_BIB_IDS_BY_BARCODE, barcode); - req.callback(advDrawBarcode); - req.request.alertEvent = false; - req.send(); -} - -function advDrawBarcode(r) { - var title_ids = r.getResultObject(); - if(checkILSEvent(title_ids)) { - alertId('myopac.copy.not.found'); - return; - } - if(!title_ids) return; - if (title_ids[0] == -1) { // pre-cat record - alertId('myopac.copy.not.cataloged'); - return; - } - - var args = {}; - if (title_ids.length == 1) { - args.page = RDETAIL; - args[PARAM_RID] = title_ids[0]; - } else { - args.page = RRESULT; - args[PARAM_RTYPE] = RTYPE_LIST; - args[PARAM_RLIST] = title_ids; - } - location.href = buildOPACLink(args); -} - -function advAuthorityBrowse() { - var selector = dojo.byId("authority_browse_axis"); - var args = {"page": AUTHBROWSE}; - args[PARAM_AUTHORITY_BROWSE_AXIS] = - selector.options[selector.selectedIndex].value; - args[PARAM_AUTHORITY_BROWSE_TERM] = - dojo.byId("authority_browse_term").value; - location.href = buildOPACLink(args); -} - diff --git a/Open-ILS/web/opac/skin/default/js/authbrowse.js b/Open-ILS/web/opac/skin/default/js/authbrowse.js deleted file mode 100644 index ff4c10da34..0000000000 --- a/Open-ILS/web/opac/skin/default/js/authbrowse.js +++ /dev/null @@ -1,262 +0,0 @@ -dojo.require("openils.CGI"); -dojo.require("openils.Util"); -dojo.require("MARC.FixedFields"); -dojo.require("openils.AuthorityControlSet"); -var cgi, acs_helper, last_fetched_length = 0; - -attachEvt("common", "init", doAuthorityBrowse); - -/* repeatable, supports all args or no args */ -function doAuthorityBrowse(axis, term, page, per_page) { - swapCanvas(dojo.byId("loading_alt")); - - if (!axis) { - if (!cgi) cgi = new openils.CGI(); - axis = cgi.param(PARAM_AUTHORITY_BROWSE_AXIS); - term = cgi.param(PARAM_AUTHORITY_BROWSE_TERM); - page = cgi.param(PARAM_AUTHORITY_BROWSE_PAGE) || 0; - per_page = cgi.param(PARAM_AUTHORITY_BROWSE_PER_PAGE) || 21; - } - - var url = '/opac/extras/browse/marcxml/authority.' - + axis - + '/1' /* this will be OU if OU ever means anything for authorities */ - + '/' + term /* FIXME urlescape or however it's spelt */ - + '/' + page - + '/' + per_page - ; - dojo.xhrGet({ - "url": url, - "handleAs": "xml", - "content": {"format": "marcxml"}, - "preventCache": true, - "load": function(doc) { - displayAuthorityRecords(axis, doc); - setPagingLinks(axis, term, page, per_page); - } - }); -} - -function setPagingLinks(axis, term, page, per_page) { - var up_page = Number(page) - 1; - var down_page = Number(page) + 1; - - unHideMe(dojo.byId("authority-page-up")); - dojo.attr( - "authority-page-up", "onclick", function() { - doAuthorityBrowse(axis, term, up_page, per_page); - } - ); - - /* XXX In theory this would generally stop the "next page" link from - * showing up when it's unwanted, but in practice the supercat/unapi - * call we make doesn't return the number of records it's supposed to. - */ -// if (last_fetched_length == per_page) { - unHideMe(dojo.byId("authority-page-down")); - dojo.attr( - "authority-page-down", "onclick", function() { - doAuthorityBrowse(axis, term, down_page, per_page); - } - ); -// } else { -// hideMe(dojo.byId("authority-page-down")); -// } -} - -function renderAuthorityTagContent(m, af) { - /* XXX This doesn't take into account possible tag repeatability -- a - * bona fide library scientist could probably improve this. :-) - */ - if (af.tag() && af.sf_list()) { - return dojo.filter( - dojo.map( - af.sf_list().split(""), - function(code) { - var result = m.subfield(af.tag(), code); - return (typeof(result[1]) == "undefined") ? "" : result[1]; - } - ), function(datum) { return datum.length > 0; } - ).join(" "); - } else { - return ""; - } -} - -function renderAuthoritySubEntry(m, field, tbody) { - var content = - openils.Util.trimString(renderAuthorityTagContent(m, field)); - if (!content.length) return; /* don't display empty tags */ - - var tr = dojo.create("tr", null, tbody); - dojo.create("td", {"style": {"width": "2em"}, "innerHTML": ""}, tr); - dojo.create( - "td", { - "className": "authority-tag-label", - "innerHTML": field.name() + ":", - "title": field.description() || "" - }, tr - ); - dojo.create( - "td", { - "className": "authority-tag-content authority-record-right", - "innerHTML": content - }, tr - ); - - if (field.sub_entries() && field.sub_entries().length) { - /* I *think* this shouldn't happen with good data? */ - console.log("I, too, have " + field.sub_entries().length + - "sub_entries"); - } -} - -function renderAuthorityMainEntry(m, field, tbody) { - var content = - openils.Util.trimString(renderAuthorityTagContent(m, field)); - if (!content.length) return; /* don't display empty tags */ - - var tr = dojo.create("tr", null, tbody); - var content_holder = dojo.create( - "td", { - "className": "authority-tag-content authority-record-main", - "colspan": 2 - }, tr - ); - dojo.create( - "span", - {"className":"authority-content", "innerHTML": content}, - content_holder - ); - dojo.create("span", {"className":"authority-count-holder"}, content_holder); - dojo.create( - "td", { - "className": "authority-tag-label authority-record-right", - "innerHTML": field.name(), - "title": field.description() || "" - }, tr - ); - - if (field.sub_entries()) { - dojo.forEach( - field.sub_entries(), - function(f) { renderAuthoritySubEntry(m, f, tbody); } - ); - } -} - -function renderAuthorityRecord(m, control_set, auth_id) { - var main_entries = openils.Util.objectSort( - dojo.filter( - control_set.authority_fields(), - function(o) { return o.main_entry() == null; } - ), "tag" - ); - - var table = dojo.create("table", {"className": "authority-record"}); - var tbody = dojo.create("tbody", {"id": "authority_" + auth_id}, table); - - - dojo.forEach( - main_entries, function(af) { renderAuthorityMainEntry(m, af, tbody); } - ); - - return table; -} - -/* displayAuthorityRecords: given a DOM document object that contains marcxml - * records, display each one in a table using the apporiate control set to - * determine which fields to show. - */ -function displayAuthorityRecords(axis, doc) { - if (!acs_helper) - acs_helper = new openils.AuthorityControlSet(); - - /* XXX I wanted to use bibtemplate here, but now I'm not sure it makes - * sense: the template itself would have to be dynamic, as it would vary - * from record to record when different control sets were in use. - */ - var auth_ids = []; - - dojo.empty("authority-record-holder"); - - var records = dojo.query("record", doc); - last_fetched_length = records.length; - - dojo.forEach( - records, - function(record) { - var m = new MARC.Record({"xml": record}); - - var auth_id = m.subfield("901","c")[1]; - auth_ids.push(auth_id); - - /* best guess */ - var t = m.field(/^1/); - if (dojo.isArray(t)) t = t[0]; - - var cs = acs_helper.findControlSetsForAuthorityTag( t.tag ); - if (dojo.isArray(cs)) cs = cs[0]; - - acs_helper.controlSetId( cs ); - - dojo.place( - renderAuthorityRecord(m, acs_helper.controlSet().raw, auth_id), - "authority-record-holder" - ); - } - ); - displayRecordCounts(axis, auth_ids); - swapCanvas(dojo.byId("canvas_main")); -} - -function displayRecordCounts(axis, auth_ids) { - fieldmapper.standardRequest( - ["open-ils.cat", "open-ils.cat.authority.records.count_linked_bibs"], { - "params": [auth_ids], - "async": true, - "oncomplete": function(r) { - if ((r = openils.Util.readResponse(r))) { - dojo.forEach(r, function(blob) { - if (blob.bibs > 0) { - displayRecordCount(axis, blob.authority, blob.bibs); - } - }); - } - } - } - ); -} - -function displayRecordCount(axis, id, count) { - /* 1) put record count where we can see it */ - dojo.query("#authority_" + id + " .authority-count-holder")[0].innerHTML = - "(" + count + ")"; /* XXX i18n ? */ - - /* 2) also, provide a link to show those records */ - var span = dojo.query("#authority_" + id + " .authority-content")[0]; - - var args = {}; - args.page = RRESULT; - args[PARAM_DEPTH] = depthSelGetDepth(); - args[PARAM_FORM] = "all"; - args[PARAM_LOCATION] = depthSelGetNewLoc(); - args[PARAM_STYPE] = "keyword"; - args[PARAM_RTYPE] = "keyword"; - args[PARAM_TERM] = "identifier|authority_id[" + id + "]"; - - var axis_obj = acs_helper.browseAxisByCode(axis); - if (axis_obj.sorter()) - args[PARAM_TERM] += " sort(" + axis_obj.sorter() + ")"; - - dojo.create( - "a", { - "innerHTML": span.innerHTML, - "href": buildOPACLink(args), - "className": "authority-content", - "title": "Show related bibliographic holdings" /* XXX i18n! */ - }, - span, "replace" - ); -} - diff --git a/Open-ILS/web/opac/skin/default/js/cn_browse.js b/Open-ILS/web/opac/skin/default/js/cn_browse.js deleted file mode 100644 index 4d1f59fe14..0000000000 --- a/Open-ILS/web/opac/skin/default/js/cn_browse.js +++ /dev/null @@ -1,145 +0,0 @@ -var cnOffset = 0; -var cnCount = 9; -var cnBrowseCN; -var cnBrowseOrg; - -if( findCurrentPage() == CNBROWSE ) { - attachEvt("common", "run", cnBrowseLoadSearch); - attachEvt( "common", "locationUpdated", cnBrowseResubmit ); - attachEvt( "common", "depthChanged", cnBrowseResubmit ); -} - - -function cnBrowseLoadSearch() { - unHideMe($('cn_browse')); - cnBrowseGo(getCallnumber(), getLocation(), getDepth()); -} - - -function cnBrowseResubmit() { - var args = {} - args[PARAM_CN] = cnBrowseCN; - args[PARAM_DEPTH] = depthSelGetDepth(); - args[PARAM_LOCATION] = getNewSearchLocation(); - goTo(buildOPACLink(args)); -} - - - -function cnBrowseGo(cn, org, depth) { - if(depth == null) depth = getDepth(); - - org = findOrgUnit(org); - cnOffset = 0; - - do { - var t = findOrgType(org.ou_type()); - if( t.depth() > depth ) - org = findOrgUnit(org.parent_ou()); - else break; - } while(true); - - cnBrowseOrg = org; - cnBrowseCN = cn; - - _cnBrowseGo( cn, org ); - appendClear($('cn_browse_where'), text(org.name())); -} - - -function _cnBrowseGo( cn, org ) { - var req = new Request( FETCH_CNBROWSE, cn, org.id(), cnCount, cnOffset ); - req.callback( cnBrowseDraw ); - req.send(); -} - -function cnBrowseNext() { - cnOffset++; - _cnBrowseGo( cnBrowseCN, cnBrowseOrg ); -} - -function cnBrowsePrev() { - cnOffset--; - _cnBrowseGo( cnBrowseCN, cnBrowseOrg ); -} - - -function cnBrowseDraw( r ) { - var list = r.getResultObject(); - _cnBrowseDraw(list); -} - - -var cnTbody; -var cnRowT; -var cnTdT; -function _cnBrowseDraw( list ) { - - if(!cnTbody) { - cnTbody = $('cn_tbody'); - cnRowT = $('cn_browse_row'); - cnTdT = cnRowT.removeChild($('cn_browse_td')); - cnTbody.removeChild(cnRowT); - } - removeChildren(cnTbody); - - var counter = 1; - var currentRow = cnRowT.cloneNode(true); - cnTbody.appendChild(currentRow); - - for( var idx in list ) { - - - var currentTd = cnTdT.cloneNode(true); - currentRow.appendChild(currentTd); - - var td = cnTdT.cloneNode(true); - - var obj = list[idx]; - var cn = obj.cn; - var mods = obj.mods; - - var cn_td = $n(currentTd, 'cn_browse_cn'); - var lib_td = $n(currentTd, 'cn_browse_lib'); - var title_td = $n(currentTd, 'cn_browse_title'); - var author_td = $n(currentTd, 'cn_browse_author'); - var pic_td = $n(currentTd, 'cn_browse_pic'); - - if (parseInt(cn.prefix().id()) > -1) { - cn_td.appendChild(text(cn.prefix().label())); - cn_td.appendChild(text(' ')); - } - - cn_td.appendChild(text(cn.label())); - - if (parseInt(cn.suffix().id()) > -1) { - cn_td.appendChild(text(' ')); - cn_td.appendChild(text(cn.suffix().label())); - } - - lib_td.appendChild(text(findOrgUnit(cn.owning_lib()).name())); - cnBrowseDrawTitle(mods, title_td, author_td, pic_td); - - if( counter++ % 3 == 0 ) { - counter = 1; - currentRow = cnRowT.cloneNode(true); - cnTbody.appendChild(currentRow); - } - } -} - - -function cnBrowseDrawTitle(mods, title_td, author_td, pic_td) { - - buildTitleDetailLink(mods, title_td); - buildSearchLink(STYPE_AUTHOR, mods.author(), author_td); - pic_td.setAttribute("src", buildJacketSrc(mods.doc_id())); - - var args = {}; - args.page = RDETAIL; - args[PARAM_OFFSET] = 0; - args[PARAM_RID] = mods.doc_id(); - args[PARAM_MRID] = 0; - pic_td.parentNode.setAttribute("href", buildOPACLink(args)); -} - diff --git a/Open-ILS/web/opac/skin/default/js/container.js b/Open-ILS/web/opac/skin/default/js/container.js deleted file mode 100644 index c8f10281c0..0000000000 --- a/Open-ILS/web/opac/skin/default/js/container.js +++ /dev/null @@ -1,69 +0,0 @@ - -function containerDoRequest( req, callback, args ) { - - if( callback ) { - req.callback( callback ); - req.request.args = args; - req.send(); - return null; - } - - req.send(true); - return req.result(); -} - - -function containerFetchAll( callback, args ) { - var req = new Request( - FETCH_CONTAINERS, G.user.session, G.user.id(), 'biblio', 'bookbag' ); - return containerDoRequest( req, callback, args ); -} - -function containerFlesh( id, callback, args ) { - var req = new Request( FLESH_CONTAINER, G.user.session, 'biblio', id ); - return containerDoRequest( req, callback, args ); -} - -function containerDelete( id, callback, args ) { - var req = new Request( DELETE_CONTAINER, G.user.session, 'biblio', id ); - return containerDoRequest(req, callback, args ); -} - - -function containerCreate( name, pub, callback, args ) { - - fieldmapper.IDL.load(['cbreb']); - var container = new cbreb(); - container.btype('bookbag'); - container.owner( G.user.id() ); - container.name( name ); - if(pub) container.pub('t'); - else container.pub('f'); - - var req = new Request( - CREATE_CONTAINER, G.user.session, 'biblio', container ); - return containerDoRequest( req, callback, args ); -} - -function containerUpdate( container, callback, args ) { - var req = new Request(UPDATE_CONTAINER, G.user.session, 'biblio', container); - return containerDoRequest(req, callback, args); -} - -function containerCreateItem( containerId, target, callback, args ) { - - fieldmapper.IDL.load(['cbrebi']); - var item = new cbrebi(); - item.target_biblio_record_entry(target); - item.bucket(containerId); - - var req = new Request( CREATE_CONTAINER_ITEM, - G.user.session, 'biblio', item ); - - return containerDoRequest( req, callback, args ); -} - -function containerRemoveItem( id, callback, args ) { - var req = new Request( DELETE_CONTAINER_ITEM, G.user.session, 'biblio', id ); - return containerDoRequest( req, callback, args ); -} diff --git a/Open-ILS/web/opac/skin/default/js/copy_details.js b/Open-ILS/web/opac/skin/default/js/copy_details.js deleted file mode 100644 index 253e671fd2..0000000000 --- a/Open-ILS/web/opac/skin/default/js/copy_details.js +++ /dev/null @@ -1,483 +0,0 @@ -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, already_fetched_copies, peer_types ) { - var i = cpdCheckExisting(contextRow); - if(i) return i; - - var counter = cpdCounter++; - - /* yank out all of the template rows */ - if(!cpdTemplate) cpdTemplate = $('rdetail_volume_details_row'); - var templateRow = cpdTemplate.cloneNode(true); - templateRow.id = 'cpd_row_' + counter; - - /* shove a dummy a tag in before the context previous sibling */ - /* - contextTbody.insertBefore( - elem('a',{name:'slot_'+templateRow.id}), contextRow.previousSibling); - goTo('#slot_'+templateRow.id); - */ - - if(isXUL()) { - /* unhide before we unhide/clone the parent */ - unHideMe($n(templateRow, 'age_protect_label')); - unHideMe($n(templateRow, 'create_date_label')); - unHideMe($n(templateRow, 'active_date_label')); - unHideMe($n(templateRow, 'holdable_label')); - } - - if (isXUL() || showDueDate) { - unHideMe($n(templateRow, 'due_date_label')); - } - - unHideMe(templateRow); - - var print = $n(templateRow,'print'); - print.onclick = function() { cpdBuildPrintPane( - contextRow, record, callnumber, orgid, depth) }; - if (callnumber == null) { - addCSSClass(print,'hide_me'); - } - - var mainTbody = $n(templateRow, 'copies_tbody'); - var extrasRow = mainTbody.removeChild($n(mainTbody, 'copy_extras_row')); - - var request_args = { - peer_types : peer_types, /* indexed the same as already_fetched_copies */ - contextTbody : contextTbody, /* tbody that holds the contextrow */ - contextRow : contextRow, /* the row our new row will be inserted after */ - record : record, - callnumber : callnumber, - orgid : orgid, - depth : depth, - templateRow : templateRow, /* contains everything */ - copy_location : copy_location, - mainTbody : mainTbody, /* holds the copy rows */ - extrasRow : extrasRow, /* wrapper row for all extras */ - counter : counter - } - - if (! already_fetched_copies) { - var req = new Request(FETCH_COPIES_FROM_VOLUME, record.doc_id(), callnumber, orgid); - req.callback(cpdDrawCopies); - - req.request.args = request_args; - - req.send(); - } else { - setTimeout( - function() { - delete request_args['copy_location']; - cpdDrawCopies({ - 'args' : request_args, - 'getResultObject' : function() { return already_fetched_copies; } - }); - }, 0 - ); - } - - if( contextRow.nextSibling ) - contextTbody.insertBefore( templateRow, contextRow.nextSibling ); - else - contextTbody.appendChild( templateRow ); - _debug('creating new details row with id ' + templateRow.id); - cpdNodes[templateRow.id] = { templateRow : templateRow }; - return templateRow.id; -} - - -function cpdBuildPrintWindow(record, orgid) { - var div = $('rdetail_print_details').cloneNode(true); - div.id = ""; - - $n(div, 'lib').appendChild(text(findOrgUnit(orgid).name())); - $n(div, 'title').appendChild(text(record.title())); - $n(div, 'author').appendChild(text(record.author())); - $n(div, 'edition').appendChild(text(record.edition())); - $n(div, 'pubdate').appendChild(text(record.pubdate())); - $n(div, 'publisher').appendChild(text(record.publisher())); - $n(div, 'phys').appendChild(text(record.physical_description())); - - return div; -} - -function cpdStylePopupWindow(div) { - var tds = div.getElementsByTagName('td'); - for( var i = 0; i < tds.length ; i++ ) { - var td = tds[i]; - var sty = td.getAttribute('style'); - if(!sty) sty = ""; - td.setAttribute('style', sty + 'padding: 2px; border: 1px solid #F0F0E0;'); - if( td.className && td.className.match(/hide_me/) ) - td.parentNode.removeChild(td); - } -} - - -/* builds a friendly print window for this CNs data */ -function cpdBuildPrintPane(contextRow, record, cn, orgid, depth) { - - var div = cpdBuildPrintWindow( record, orgid); - - var whole_cn_text = (cn[0] ? cn[0] + ' ' : '') + cn[1] + (cn[2] ? ' ' + cn[2] : ''); - $n(div, 'cn').appendChild(text(whole_cn_text)); - - unHideMe($n(div, 'copy_header')); - - var subtbody = $n(contextRow.nextSibling, 'copies_tbody'); - var rows = subtbody.getElementsByTagName('tr'); - - for( var r = 0; r < rows.length; r++ ) { - var row = rows[r]; - if(!row) continue; - var name = row.getAttribute('name'); - if( name.match(/extras_row/) ) continue; /* hide the copy notes, stat-cats */ - var clone = row.cloneNode(true); - var links = clone.getElementsByTagName('a'); - for( var i = 0; i < links.length; i++ ) - links[i].style.display = 'none'; - - $n(div, 'tbody').appendChild(clone); - } - - cpdStylePopupWindow(div); - openWindow( div.innerHTML); -} - - - -/* hide any open tables and if we've already - fleshed this cn, just unhide it */ -function cpdCheckExisting( contextRow ) { - - var existingid; - var next = contextRow.nextSibling; - - if( next && next.getAttribute('templateRow') ) { - var obj = cpdNodes[next.id]; - if(obj.templateRow.className.match(/hide_me/)) - unHideMe(obj.templateRow); - else hideMe(obj.templateRow); - existingid = next.id; - } - - if(existingid) _debug('row exists with id ' + existingid); - - for( var o in cpdNodes ) { - var node = cpdNodes[o]; - if( existingid && o == existingid ) continue; - hideMe(node.templateRow); - removeCSSClass(node.templateRow.previousSibling, 'rdetail_context_row'); - } - - addCSSClass(contextRow, 'rdetail_context_row'); - if(existingid) return existingid; - return null; -} - -/* -function cpdFetchCopies(r) { - var args = r.args; - args.cn = r.getResultObject(); - var req = new Request(FETCH_COPIES_FROM_VOLUME, args.cn.id()); - req.request.args = args; - req.callback(cpdDrawCopies); - req.send(); -} -*/ - -function cpdDrawCopies(r) { - - var copies = r.getResultObject(); - var args = r.args; - var copytbody = $n(args.templateRow, 'copies_tbody'); - var copyrow = copytbody.removeChild($n(copytbody, 'copies_row')); - - if(isXUL()) { - /* unhide before we unhide/clone the parent */ - unHideMe($n(copyrow, 'age_protect_value')); - unHideMe($n(copyrow, 'create_date_value')); - unHideMe($n(copyrow, 'active_date_value')); - unHideMe($n(copyrow, 'copy_holdable_td')); - } - - if(isXUL() || showDueDate) { - unHideMe($n(copyrow, 'copy_due_date_td')); - } - - for( var i = 0; i < copies.length; i++ ) { - var row = copyrow.cloneNode(true); - var copyid = copies[i]; - var pt; if (args.peer_types) pt = args.peer_types[i]; - if (typeof copyid != 'object') { - var req = new Request(FETCH_FLESHED_COPY, copyid); - req.callback(cpdDrawCopy); - req.request.args = r.args; - req.request.row = row; - req.send(); - } else { - setTimeout( - function(copy,row,pt) { - return function() { - cpdDrawCopy({ - 'getResultObject' : function() { return copy; }, - 'args' : r.args, - 'peer_type' : pt, - 'row' : row - }); - }; - }(copies[i],row,pt), 0 - ); - } - copytbody.appendChild(row); - } -} - -function cpdDrawCopy(r) { - var copy = r.getResultObject(); - var row = r.row; - var pt = r.peer_type; - var trow = r.args.templateRow; - - if (r.args.copy_location && copy.location().name() != r.args.copy_location) { - hideMe(row); - return; - } - - // Make barcode more useful for staff client usage - if(isXUL()) { - var my_a = document.createElement('a'); - my_a.appendChild(text(copy.barcode())); - my_a.setAttribute("href","javascript:void(0);"); - my_a.onclick = function() { - xulG.new_tab(xulG.urls.XUL_COPY_STATUS, {}, {'from_item_details_new': true, 'barcodes': [copy.barcode()]}); - }; - $n(row, 'barcode').appendChild(my_a); - } - else { - $n(row, 'barcode').appendChild(text(copy.barcode())); - } - - /* show the peer type*/ - if (pt) { - $n(row, 'barcode').appendChild(text(' :: ' + pt)); - } - - $n(row, 'location').appendChild(text(copy.location().name())); - $n(row, 'status').appendChild(text(copy.status().name())); - - // append comma-separated list of part this copy is linked to - if(copy.parts() && copy.parts().length) { - unHideMe($n(trow, 'copy_part_label')); - unHideMe($n(row, 'copy_part')); - for(var i = 0; i < copy.parts().length; i++) { - var part = copy.parts()[i]; - var node = $n(row, 'copy_part'); - if(i > 0) node.appendChild(text(',')); - node.appendChild(text(part.label())); - } - } - - /* show the other bibs link */ - if (copy.peer_record_maps().length > 0) { - var l = $n(row, 'copy_multi_home'); - unHideMe(l); - var link_args = {}; - link_args.page = RRESULT; - link_args[PARAM_RTYPE] = RTYPE_LIST; - link_args[PARAM_RLIST] = new Array(); - for (var i = 0; i < copy.peer_record_maps().length; i++) { - link_args[PARAM_RLIST].push( copy.peer_record_maps()[i].peer_record() ); - } - l.setAttribute('href',buildOPACLink(link_args)); - } - - if(isXUL()) { - /* show the hold link */ - var l = $n(row, 'copy_hold_link'); - unHideMe(l); - l.onclick = function() { - holdsDrawEditor( - { - type : 'C', - copyObject : copy, - onComplete : function(){} - } - ); - } - - /* 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())); - - var cd = copy.create_date(); - cd = cd.replace(/T.*/, ''); - $n(row, 'create_date_value').appendChild(text(cd)); - - var ad = copy.active_date(); - if(ad) { - ad = ad.replace(/T.*/, ''); - $n(row, 'active_date_value').appendChild(text(ad)); - } - - var yes = $('rdetail.yes').innerHTML; - var no = $('rdetail.no').innerHTML; - - if( isTrue(copy.holdable()) && - isTrue(copy.location().holdable()) && - isTrue(copy.status().holdable()) ) { - $n(row, 'copy_is_holdable').appendChild(text(yes)); - } else { - $n(row, 'copy_is_holdable').appendChild(text(no)); - } - } - - if (isXUL() || showDueDate) { - var circ; - if( copy.circulations() ) { - circ = copy.circulations()[0]; - if( circ ) { - var due_time = dojo.date.stamp.fromISOString(circ.due_date()); - 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; - r.args.copyrow = row; - cpdShowNotes(copy, r.args) - cpdShowStats(copy, r.args); - -} - -function _cpdExtrasInit(args) { - - var newrid = 'extras_row_' + args.copy.barcode(); - var newrow = $(newrid); - if(!newrow) newrow = args.extrasRow.cloneNode(true); - var tbody = $n(newrow, 'extras_tbody'); - var rowt = $n(tbody, 'extras_row'); - newrow.id = newrid; - - var cr = args.copyrow; - var nr = cr.nextSibling; - var np = args.mainTbody; - - /* insert the extras row into the main table */ - if(nr) np.insertBefore( newrow, nr ); - else np.appendChild(newrow); - - var link = $n(args.copyrow, 'details_link'); - var link2 = $n(args.copyrow, 'less_details_link'); - var id = newrow.id; - link.id = id + '_morelink'; - link2.id = id + '_lesslink'; - unHideMe(link); - hideMe(link2); - - link.setAttribute('href', - 'javascript:unHideMe($("'+link2.id+'")); hideMe($("'+link.id+'"));unHideMe($("'+newrow.id+'"));'); - - link2.setAttribute('href', - 'javascript:unHideMe($("'+link.id+'")); hideMe($("'+link2.id+'"));hideMe($("'+newrow.id+'"));'); - - return [ tbody, rowt ]; -} - -function cpdShowNotes(copy, args) { - var notes = copy.notes(); - if(!notes || notes.length == 0) return; - - var a = _cpdExtrasInit(args); - var tbody = a[0]; - var rowt = a[1]; - - for( var n in notes ) { - var note = notes[n]; - if(!isTrue(note.pub())) continue; - var row = rowt.cloneNode(true); - $n(row, 'key').appendChild(text(note.title())); - $n(row, 'value').appendChild(text(note.value())); - unHideMe($n(row, 'note')); - unHideMe(row); - tbody.appendChild(row); - } -} - - -function cpdShowStats(copy, args) { - var entries = copy.stat_cat_entry_copy_maps(); - if(!entries || entries.length == 0) return; - - var visibleStatCat = false; - - /* - check all copy stat cats; if we find one that's OPAC visible, - set the flag and break the loop. If we've found one, or we're - in the staff client, build the table. if not, we return doing - nothing, as though the stat_cat_entry_copy_map was empty or null - */ - - for( var n in entries ) - { - var entry = entries[n]; - if(isTrue(entry.stat_cat().opac_visible())) - { - visibleStatCat = true; - break; - } - } - - if(!(isXUL() || visibleStatCat)) return; - - var a = _cpdExtrasInit(args); - var tbody = a[0]; - var rowt = a[1]; - - for( var n in entries ) { - var entry = entries[n]; - if(!(isXUL() || isTrue(entry.stat_cat().opac_visible()))) continue; - var row = rowt.cloneNode(true); - $n(row, 'key').appendChild(text(entry.stat_cat().name())); - $n(row, 'value').appendChild(text(entry.stat_cat_entry().value())); - unHideMe($n(row, 'cat')); - unHideMe(row); - tbody.appendChild(row); - } -} - diff --git a/Open-ILS/web/opac/skin/default/js/depth_selector.js b/Open-ILS/web/opac/skin/default/js/depth_selector.js deleted file mode 100644 index 6bd4b0ef7d..0000000000 --- a/Open-ILS/web/opac/skin/default/js/depth_selector.js +++ /dev/null @@ -1,129 +0,0 @@ - -attachEvt( "common", "locationChanged", updateLoc ); - -var _ds; -var _libselspan; -var _libselslink; -var _dselspan; -var _newlocation = null; - -function depthSelInit() { - _ds = $('depth_selector'); - _ds.onchange = depthSelectorChanged; - _libselspan = $('lib_selector_span'); - _libsellink = $('lib_selector_link'); - _dselspan = $('depth_selector_span'); - - if( getLocation() == globalOrgTree.id() ) { - unHideMe( _libselspan ); - _libsellink.onclick = _opacHandleLocationTagClick; - } else { - unHideMe( _dselspan ); - buildLocationSelector(); - } - - setSelector(_ds, getDepth()); - _newlocation = getLocation(); -} - - -var orgTreeIsBuilt = false; -function _opacHandleLocationTagClick() { - - swapCanvas(G.ui.common.org_container); - - if(!orgTreeIsBuilt) { - drawOrgTree(); - orgTreeIsBuilt = true; - } - -} - -function depthSelGetDepth() { - var depth = parseInt(_ds.options[_ds.selectedIndex].value); - if(isNaN(depth)) depth = 0; - return depth; -} - -function depthSelectorChanged() { - var i = _ds.selectedIndex; - if( i == _ds.options.length - 1 ) { - setSelector( _ds, getDepth() ); - _opacHandleLocationTagClick(); - } else { - /* this re-submits the search when they change the search range - disabled for testing... - */ - /*runEvt('common', 'depthChanged');*/ - } -} - -var chooseAnotherNode; -function buildLocationSelector(newLoc) { - - var loc; - if(newLoc != null) loc = newLoc; - else loc = getLocation(); - - if( loc == globalOrgTree.id() ) return; - - var selector = _ds; - if(!chooseAnotherNode) - chooseAnotherNode = selector.removeChild( - selector.getElementsByTagName("option")[0]); - var node = chooseAnotherNode; - removeChildren(selector); - - var location = findOrgUnit(loc); - 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()); - removeChildren(n); - n.appendChild(text(type.opac_label())); - selector.appendChild(n); - location = findOrgUnit(location.parent_ou()); - if(location) { - type = findOrgType(location.ou_type()); - if (orgHiding && orgHiding.depth > type.depth()) { - type = null; - } - } else { - type = null; - } - } - - selector.appendChild(node); -} - -function getNewSearchDepth() { return newSearchDepth; } -function getNewSearchLocation() { return (isNull(_newlocation)) ? LOCATION : _newlocation; } -function depthSelGetNewLoc() { return getNewSearchLocation(); } - -function updateLoc(location, depth) { - if( depth != null ) { - if(depth != 0 ){ - _libsellink.onclick = _opacHandleLocationTagClick; - if( location == globalOrgTree.id() ) { - hideMe( _dselspan ); - unHideMe( _libselspan ); - } else { - buildLocationSelector(location); - hideMe( _libselspan ); - unHideMe( _dselspan ); - } - } - - setSelector(_ds, depth); - newSearchDepth = depth; - } - - _newlocation = location; - runEvt('common','locationUpdated', location); -} - - - diff --git a/Open-ILS/web/opac/skin/default/js/holds.js b/Open-ILS/web/opac/skin/default/js/holds.js deleted file mode 100644 index 60487c26d0..0000000000 --- a/Open-ILS/web/opac/skin/default/js/holds.js +++ /dev/null @@ -1,1188 +0,0 @@ -var holdsOrgSelectorBuilt = false; -var holdArgs; - -/* -note: metarecord holds have a holdable_formats field that contains -item_type(s)-item_forms(s)-language -item_form and language are optional - if language exist and no -item_form is specified, use item_type(s)--language -*/ - -var noEmailMessage; -var noEmailMessageXUL; - -var holdTargetTypeMap = { - M : 'metarecord', - T : 'record', - V : 'volume', - I : 'issuance', - C : 'copy', - P : 'part' -}; - - - -function holdsHandleStaff() { - - // if we know the recipient's barcode, use it - if(xulG.patron_barcode) return _holdsHandleStaff(); - - swapCanvas($('xulholds_box')); - $('xul_recipient_barcode').focus(); - $('xul_recipient_barcode').onkeypress = function(evt) - {if(userPressedEnter(evt)) { _holdsHandleStaff(); } }; - $('xul_recipient_barcode_submit').onclick = _holdsHandleStaff; - $('xul_recipient_me').onclick = _holdsHandleStaffMe; - - $('xul_recipient_barcode').onkeyup = function(evt) { - if($('xul_recipient_barcode').value == '') - $('xul_recipient_me').disabled = false; - else - $('xul_recipient_me').disabled = true; - }; -} - -$('holds_frozen_thaw_input').onchange = - function(){holdsVerifyThawDateUI('holds_frozen_thaw_input');} -$('holds_frozen_thaw_input').onkeyup = - function(){holdsVerifyThawDateUI('holds_frozen_thaw_input');} - -function _holdsHandleStaffMe() { - holdArgs.recipient = G.user; - holdsDrawEditor(); -} - -function _holdsHandleStaff() { - var barcode = xulG.patron_barcode; - if(!barcode) { - barcode = $('xul_recipient_barcode').value; - if(xulG.get_barcode) { - // We have a "complete the barcode" function, call it (actor = users only) - var new_barcode = xulG.get_barcode(window, 'actor', barcode); - // If we got a result (boolean false is "no result") check it - if(new_barcode) { - // user_false string means they picked "None of the above" - // Abort before any other events can fire - if(new_barcode == "user_false") return; - // No error means we have a (hopefully valid) completed barcode to use. - // Otherwise, fall through to other methods of checking - if(typeof new_barcode.ilsevent == 'undefined') - barcode = new_barcode.barcode; - } - } - } - var user = grabUserByBarcode( G.user.session, barcode ); - - var evt; - if(evt = checkILSEvent(user)) { - alertILSEvent(user); - return; - } - - if(!barcode || !user) { - alertId('holds_invalid_recipient', barcode); - return - } - - grabUserPrefs(user); - - holdArgs.recipient = user; - holdsDrawEditor(); -} - - - -/** args: - * record, volume, copy (ids) - * request, recipient, editHold (objects) - */ - -function holdsDrawEditor(args) { - - holdArgs = (args) ? args : holdArgs; - - if(!noEmailMessage) - noEmailMessage = $('holds_email').removeChild($('holds.no_email')); - - if(!noEmailMessageXUL) - noEmailMessageXUL = $('holds_email').removeChild($('holds.no_email.xul')); - - if(isXUL() && holdArgs.recipient == null - && holdArgs.editHold == null) { - holdsHandleStaff(); - return; - } - - if(!holdArgs.recipient) holdArgs.recipient = G.user; - if(!holdArgs.requestor) holdArgs.requestor = G.user; - - if(!(holdArgs.requestor && holdArgs.requestor.session)) { - detachAllEvt('common','locationChanged'); - attachEvt('common','loggedIn', holdsDrawEditor) - initLogin(); - return; - } - - if(holdArgs.editHold) // flesh the args with the existing hold - holdArgsFromHold(holdArgs.editHold, holdArgs); - - removeCSSClass($('holds_parts_selector'), 'parts-warning'); - holdArgs.partsSuggestionMade = false; - - holdsDrawWindow(); -} - - -// updates the edit window with the existing hold's data -function _holdsUpdateEditHold() { - - var hold = holdArgs.editHold; - var qstats = holdArgs.status; - - var orgsel = $('holds_org_selector'); - var frozenbox = $('holds_frozen_chkbox'); - - setSelector(orgsel, hold.pickup_lib()); - - if( hold.capture_time() || qstats.status > 2 ) { - frozenbox.disabled = true; - $('holds_frozen_thaw_input').disabled = true; - if(qstats.status == 3) { - // no pickup lib changes while in-transit - orgsel.disabled = true; - } else { - var orgs = fetchPermOrgs('UPDATE_PICKUP_LIB_FROM_HOLDS_SHELF'); - if(orgs[0] == -1) - orgsel.disabled = true; - } - } else { - orgsel.disabled = false; - frozenbox.disabled = false; - } - - - $('holds_submit').onclick = holdsEditHold; - $('holds_update').onclick = holdsEditHold; - - if(hold.phone_notify()) { - $('holds_enable_phone').checked = true; - $('holds_phone').value = hold.phone_notify(); - - } else { - $('holds_phone').disabled = true; - $('holds_enable_phone').checked = false; - } - - if(isTrue(hold.email_notify())) { - $('holds_enable_email').checked = true; - - } else { - $('holds_enable_email').checked = false; - } - - dijit.byId('holds_expire_time').setValue(dojo.date.stamp.fromISOString(hold.expire_time())); - - /* populate the hold freezing info */ - if(!frozenbox.disabled && isTrue(hold.frozen())) { - frozenbox.checked = true; - unHideMe($('hold_frozen_thaw_row')); - if(hold.thaw_date()) { - dijit.byId('holds_frozen_thaw_input').setValue(dojo.date.stamp.fromISOString(hold.thaw_date())); - } else { - dijit.byId('holds_frozen_thaw_input').setValue(''); - } - } else { - frozenbox.checked = false; - dijit.byId('holds_frozen_thaw_input').setValue(''); - hideMe($('hold_frozen_thaw_row')); - } -} - -function holdsEditHold() { - var hold = holdsBuildHoldFromWindow(); - if(!hold) return; - holdsUpdate(hold); - showCanvas(); - if(holdArgs.onComplete) - holdArgs.onComplete(hold); -} - -function holdArgsFromHold(hold, oargs) { - var args = (oargs) ? oargs : {}; - args.type = hold.hold_type(); - var target = hold.target(); - args[holdTargetTypeMap[args.type]] = target; - return args; -} - -function holdFetchObjects(hold, doneCallback) { - - var args = (hold) ? holdArgsFromHold(hold) : holdArgs; - - var type = args.type; - - if( type == 'C' ) { - - if( args.copyObject ) { - - args.copy = args.copyObject.id(); - args.volume = args.copyObject.call_number(); - _h_set_vol(args, doneCallback); - - } else { - var creq = new Request(FETCH_COPY, args.copy); - - creq.callback( - function(r) { - var cp = r.getResultObject(); - args.copyObject = cp; - args.volume = args.copyObject.call_number(); - _h_set_vol(args, doneCallback); - } - ); - creq.send(); - } - } else { - if( type == 'V' ) { - _h_set_vol(args, doneCallback); - - } else if( type == 'I' ) { - _h_set_issuance(args, doneCallback); - - } else if( type == 'P' ) { - _h_set_parts(args, doneCallback); - - } else { - if( type == 'T') { - _h_set_rec(args, doneCallback); - } else { - _h_set_rec_descriptors(args, doneCallback); - } - } - } - - return args; -} - -function _h_set_parts(args, doneCallback) { - - var preq = new Request( - 'open-ils.fielder:open-ils.fielder.bmp.atomic', - {"cache":1, "fields":["label", "record"],"query": {"id":args.part}} - ); - - preq.callback( - function(r) { - var part = r.getResultObject()[0]; - args.record = part.record; - args.partObject = part; - _h_set_rec(args, doneCallback); - } - ); - - preq.send(); -} - -function _h_set_vol(args, doneCallback) { - - if( args.volumeObject ) { - args.volume = args.volumeObject.id(); - args.record = args.volumeObject.record(); - _h_set_rec(args, doneCallback); - - } else { - - var vreq = new Request(FETCH_VOLUME, args.volume); - vreq.callback( - function(r) { - var vol = r.getResultObject(); - args.volumeObject = vol; - args.record = vol.record(); - _h_set_rec(args, doneCallback); - } - ); - vreq.send(); - } -} - -function _h_set_issuance(args, doneCallback) { - - if( args.issuanceObject ) { - args.issuance = args.issuanceObject.id(); - args.record = args.issuanceObject.subscription().record_entry(); - _h_set_rec(args, doneCallback); - - } else { - - var vreq = new Request(FETCH_ISSUANCE, [args.issuance]); - vreq.callback( - function(r) { - var issuance = r.getResultObject()[0]; - args.issuanceObject = issuance; - args.record = issuance.subscription().record_entry(); - _h_set_rec(args, doneCallback); - } - ); - vreq.send(); - } -} - -function _h_set_rec(args, doneCallback) { - - if(args.recordObject) - args.record = args.recordObject.doc_id(); - else - args.recordObject = findRecord( args.record, 'T' ); - - if( args.type == 'T' || args.type == 'M' ) { - _h_set_rec_descriptors(args, doneCallback); - //} else if(args.type == 'P') { - //_h_get_parts(args, doneCallback); - } else { - if(doneCallback) doneCallback(args); - } -} - - -function _h_set_rec_descriptors(args, doneCallback) { - - if( ! args.pickup_lib ) - args.pickup_lib = getSelectorVal($('holds_org_selector')); - - if(args.pickup_lib === null) - args.pickup_lib = args.recipient.home_ou(); - - // grab the list of record desciptors attached to this records metarecord - if( ! args.recordDescriptors ) { - var params = { pickup_lib: args.pickup_lib }; - - if (args.type == 'M') { - if( !args.metarecord && args.record) { - params.metarecord = args.metarecord = args.record; - delete(args.record); - } else { - params.metarecord = args.metarecordObject.doc_id(); - } - } else { - params.record = args.record; - } - - if( ! args.record ) { - if( args.metarecord ) - params.metarecord = args.metarecord; - else - params.metarecord = args.metarecordObject.doc_id(); - } - - var req = new Request(FETCH_MR_DESCRIPTORS, params ); - req.callback( - function(r) { - var data = r.getResultObject(); - args.recordDescriptors = args.recordDescriptors = data.descriptors; - args.metarecord = args.metarecord = data.metarecord; - if( args.type == 'M' && ! args.metarecordObject) - args.metarecordObject = args.metarecordObject = findRecord(args.metarecord, 'M'); - - _h_get_parts(args, doneCallback); - } - ); - req.send(); - - } else { - _h_get_parts(args, doneCallback); - } - - return args; -} - -function _h_get_parts(args, doneCallback) { - - if(args.type == 'M' || args.editHold || args.holdParts) { - if(doneCallback) - doneCallback(args); - - } else { - - var req = new Request( - 'open-ils.search:open-ils.search.biblio.record_hold_parts', - {pickup_lib: args.pickup_lib, record: args.record} - ); - - req.callback( - function(r) { - args.recordParts = r.getResultObject(); - if(doneCallback) - doneCallback(args); - } - ); - req.send(); - } -} - - - -function holdsDrawWindow() { - swapCanvas($('holds_box')); - $('holds_cancel').onclick = function(){ runEvt('common', 'holdUpdateCanceled'), showCanvas() }; - $('holds_submit').onclick = function(){holdsPlaceHold(holdsBuildHoldFromWindow())}; - $('holds_update').onclick = function(){holdsPlaceHold(holdsBuildHoldFromWindow())}; - holdFetchObjects(null, - function(){ - __holdsDrawWindow(); - - if(holdArgs.editHold) { - hideMe($('holds_submit')); - unHideMe($('holds_update')); - var req = new Request(FETCH_HOLD_STATUS, - G.user.session, holdArgs.editHold.id()); - req.send(true); - holdArgs.status = req.result(); - _holdsUpdateEditHold(); - } - } - ); -} - -function __holdsDrawWindow() { - - var rec = holdArgs.recordObject; - var vol = holdArgs.volumeObject; - var copy = holdArgs.copyObject; - var mr = holdArgs.metarecordObject; - - rec = (rec) ? rec : mr; - - if(!holdsOrgSelectorBuilt) { - holdsBuildOrgSelector(null,0); - holdsOrgSelectorBuilt = true; - var selector = $('holds_org_selector'); - - /* - var o_loc = findOrgUnit(getOrigLocation()); - var t = findOrgType(o_loc.ou_type()); - if( t.can_have_users() ) - setSelector(selector, o_loc.id()); - else - */ - - setSelector(selector, holdArgs.recipient.home_ou()); - - } - - var pref = holdArgs.recipient.prefs[PREF_DEF_PICKUP]; - if(pref) { - setSelector(selector, pref); - } - - /* - if(isXUL()) { - var dsel = $('holds_depth_selector'); - unHideMe($('holds_depth_selector_row')); - if(dsel.getElementsByTagName('option').length == 0) { - var types = globalOrgTypes; - var depth = findOrgDepth(G.user.ws_ou()); - iterate(types, - function(t) { - if(t.depth() > depth) return; - insertSelectorVal(dsel, -1, t.opac_label(), t.depth()); - } - ); - } - } - */ - - appendClear($('holds_recipient'), text( - holdArgs.recipient.family_name() + ', ' + - holdArgs.recipient.first_given_name())); - appendClear($('holds_title'), text(rec.title())); - appendClear($('holds_author'), text(rec.author())); - - if( holdArgs.type == 'I' ) { - unHideMe($('holds_type_row')); - unHideMe($('holds_is_issuance')); - unHideMe($('holds_issuance_row')); - appendClear($('holds_issuance_label'), text(holdArgs.issuanceObject.label())); - - } else if( holdArgs.type == 'V' || holdArgs.type == 'C' ) { - - unHideMe($('holds_type_row')); - unHideMe($('holds_cn_row')); - appendClear($('holds_cn'), text(holdArgs.volumeObject.label())); - - if( holdArgs.type == 'V' ) { - unHideMe($('holds_is_cn')); - hideMe($('holds_is_copy')); - - } else { - hideMe($('holds_is_cn')); - unHideMe($('holds_is_copy')); - unHideMe($('holds_copy_row')); - appendClear($('holds_copy'), text(holdArgs.copyObject.barcode())); - } - - } else { - hideMe($('holds_type_row')); - hideMe($('holds_copy_row')); - hideMe($('holds_cn_row')); - hideMe($('holds_issuance_row')); - } - - if(holdArgs.recordParts && holdArgs.recordParts.length) { - var selector = $('holds_parts_selector'); - unHideMe($('holds_parts_row')); - unHideMe(selector); - - var nodeList = []; - dojo.forEach(selector.options, - function(node) { if(node.value != '') nodeList.push(node) } ); - - dojo.forEach(nodeList, function(node) { selector.removeChild(node); }); - - dojo.forEach( - holdArgs.recordParts, - function(part) { - insertSelectorVal(selector, -1, part.label, part.id); - } - ); - - } else if(holdArgs.type == 'P') { - unHideMe($('holds_parts_row')); - unHideMe($('holds_parts_label')); - appendClear( $('holds_parts_label'), text(holdArgs.partObject.label)); - } - - removeChildren($('holds_format')); - - var mods_formats = rec.types_of_resource(); - var formats; - - if (holdArgs.recordDescriptors && holdArgs.recordDescriptors.length) - formats = holdArgs.recordDescriptors[0].item_type(); - - if( holdArgs.type == 'T' ) { - var desc = grep( holdArgs.recordDescriptors, - function(i) { - return (i.record() == holdArgs.record); - } - ); - if (desc) { - formats = desc[0].item_type(); - } - } - - if( holdArgs.type == 'M' ) { - var mr_formats; - if(holdArgs.editHold){ - mr_formats = holdArgs.editHold.holdable_formats(); - }else{ - mr_formats = ''; // collect the item_type()s from all holdArgs.recordDescriptors - for(var desc in holdArgs.recordDescriptors){ - if (!holdArgs.recordDescriptors[desc].item_type()) continue; - mr_formats += holdArgs.recordDescriptors[desc].item_type(); - } - - var first_form = 1; - for(var desc in holdArgs.recordDescriptors){ - if (!holdArgs.recordDescriptors[desc].item_form()) continue; - if (first_form) { - mr_formats += '-'; - first_form = 0; - } - mr_formats += holdArgs.recordDescriptors[desc].item_form(); - } - - - } - - var data = holdsParseMRFormats(mr_formats); - mods_formats = data.mods_formats; - formats = data.formats; - } - - - for( var i in mods_formats ) { - var res = mods_formats[i]; - var img = elem("img"); - setResourcePic(img, res); - $('holds_format').appendChild(img); - if(formats) - $('holds_format').appendChild(text(' '+ MARCTypeToFriendly(formats[i]) +' ')); - else - $('holds_format').appendChild(text(' '+ mods_formats[i] +' ')); - $('holds_format').appendChild(elem('br')); - } - - - $('holds_phone').value = (holdArgs.recipient.day_phone() ? holdArgs.recipient.day_phone() : ''); - var pref = holdArgs.recipient.prefs[PREF_DEF_PHONE]; - if(pref) $('holds_phone').value = pref; - appendClear( $('holds_email'), text(holdArgs.recipient.email())); - - pref = holdArgs.recipient.prefs[PREF_HOLD_NOTIFY]; - - if(pref) { - if( ! pref.match(/email/i) ) { - $('holds_enable_email').checked = false; - } else { - $('holds_enable_email').checked = true; - } - - if( ! pref.match(/phone/i) ) { - $('holds_phone').disabled = true; - $('holds_enable_phone').checked = false; - } else { - $('holds_phone').disabled = false; - $('holds_enable_phone').checked = true; - } - } - - if(!holdArgs.recipient.email()) { - $('holds_enable_email').checked = false; - $('holds_enable_email').disabled = true; - var message; - if(isXUL()) { - message = noEmailMessageXUL.cloneNode(true); - appendClear($('holds_email'), message); - } else { - message = noEmailMessage.cloneNode(true); - appendClear($('holds_email'), message); - $('holds.no_email.my_account').setAttribute('href', buildOPACLink({page:MYOPAC},null,true)); - } - unHideMe(message); - } - - if(!$('holds_phone').value) - $('holds_enable_phone').checked = false; - - appendClear($('holds_physical_desc'), text(rec.physical_description())); - - if(holdArgs.type == 'M') hideMe($('hold_physical_desc_row')); - - holdsSetFormatSelector(); - - $('holds_frozen_chkbox').checked = false; - hideMe($('hold_frozen_thaw_row')); - - var interval = fetchOrgSettingDefault(holdArgs.recipient.home_ou(), 'circ.hold_expire_interval'); - var secs = 0; - if(interval) { - secs = interval_to_seconds(interval); - var expire = new Date(); - expire.setTime(expire.getTime() + Number(secs + '000')); - dijit.byId('holds_expire_time').setValue(expire); - } -} - -function holdsParseMRFormats(str) { - var data = str.split(/-/); - - var formats = []; - var mods_formats = []; - - for( var i = 0; i < data[0].length; i++ ) { - formats.push( data[0].charAt(i) ); - mods_formats.push( MARCFormatToMods( formats[i] ) ); - } - - formats = uniquify(formats); - mods_formats = uniquify(mods_formats); - - return { - formats : formats, - mods_formats : mods_formats, - lang : data[2], - largeprint : data[1] - }; -} - - -function holdsSetFormatSelector() { - var type = holdArgs.type; - if( type == 'C' || type == 'V' || type == "I" || holdArgs.editHold ) return; - - var data = holdsGetFormats(); - var avail_formats = data.avail_formats; - var sel_formats = data.sel_formats; - holdArgs.language = data.lang; - if( type=='M'){ - hideMe($('holds_alt_formats_row_extras')); - unHideMe($('holds_alt_formats_row')); - }else{ - unHideMe($('holds_alt_formats_row_extras')); - } - - var selector = $('hold_alt_form_selector'); - - for( var i = 0; i < selector.options.length; i++ ) { - if (selector.options[i].className.indexOf('hide_me') == -1) - hideMe(selector.options[i]); - selector.options[i].disabled = true; - } - - for( var i = 0; i < avail_formats.length; i++ ) { - var form = avail_formats[i]; - var opt = findFormatSelectorOptByParts(selector,form); - if (!opt) continue; - if(type=='M') opt.selected=true; - unHideMe(opt); - opt.disabled = false; - } - - // If the user selects a format, P-type holds are no longer an option - // disable and reset the P-type form control - selector.onchange = function() { - var partsSel = $('holds_parts_selector'); - for(var i = 0; i < selector.options.length; i++) { - if(selector.options[i].selected) { - partsSel.selectedIndex = 0; // none selected - partsSel.disabled = true; - return; - } - } - partsSel.disabled = false; - } -} - -function findFormatSelectorOptByParts( sel, val ) { - var parts = val.split('-'); - for( var i = 0; i < sel.options.length; i++ ) { - var opt = sel.options[i]; - var oval = opt.value; - var oparts = oval.split('-'); - if( oparts[0].indexOf(parts[0]) > -1 && (!parts[1] || oparts[1].indexOf(parts[1]) > -1) ) return opt; - } - return null; -} - -function holdsGetFormats() { - - var lang; - var formats = []; - var sformats = []; // selected formats - - var type = holdArgs.type; - var desc = holdArgs.recordDescriptors; - var rec = holdArgs.record; - var mrec = holdArgs.metarecord; - - - if( type == 'T') { - - for( var i = 0; i < desc.length; i++ ) { - var d = desc[i]; - if( d.record() == holdArgs.record ) { - lang = d.item_lang(); - holdArgs.myFormat = _t_f_2_format(d.item_type(), d.item_form()); - sformats.push(holdArgs.myFormat); - break; - } - } - - for( var i = 0; i < desc.length; i++ ) { - var d = desc[i]; - if( type == 'T' && d.item_lang() != lang ) continue; - formats.push( _t_f_2_format(d.item_type(), d.item_form())); - } - - } else if( type =='M') { - - // All available formats are selected by default in MR holds - for( var i = 0; i < desc.length; i++ ) { - var d = desc[i]; - var _tmp_f = _t_f_2_format(d.item_type(), d.item_form()); - formats.push( _tmp_f ); - sformats.push( _tmp_f ); - } - } - - formats = uniquify(formats); - sformats = uniquify(sformats); - - return { - lang : lang, - avail_formats : formats, - sel_formats : sformats - }; -} - - - -function _t_f_2_format(type, form) { - if( (type == 'a' || type == 't') && form == 's' ) return 'at-s'; - if( form == 'd' ) return 'at-d'; - return (type == 'a' || type == 't') ? 'at' : type; -} - -function holdsSetSelectedFormats() { - - var cn = $('holds_alt_formats_row').className; - if( cn && cn.match(/hide_me/) ) return; - - var selector = $('hold_alt_form_selector'); - var vals = getSelectedList(selector); - - if(vals.length == 0) return; - - var fstring = ""; - - if( contains(vals, 'at-d') || contains(vals, 'at-s') || contains(vals, 'at')) { - if( contains(vals, 'at') ) { - fstring = 'at'; - } else if (contains(vals, 'at-s') && contains(vals, 'at-d')) { - fstring = 'at-sd'; - } else if (!contains(vals, 'at-s')) { - fstring = 'at-d'; - } else { - fstring = 'at-s'; - } - } - - for( var i = 0; i < vals.length; i++ ) { - var val = vals[i]; - if( !val.match(/at/) ) fstring = val + fstring; - } - - if( holdArgs.language ) { - if( fstring.match(/-/) ) - fstring = fstring + '-' + holdArgs.language; - else - fstring = fstring + '--' + holdArgs.language; - } - - - return fstring; -} - - -function holdsCheckPossibility(pickuplib, hold, recurse) { - - var args = { - titleid : holdArgs.record, - mrid : holdArgs.metarecord, - volume_id : holdArgs.volume, - issuanceid : holdArgs.issuance, - copy_id : holdArgs.copy, - hold_type : holdArgs.type, - holdable_formats : holdArgs.holdable_formats, - patronid : holdArgs.recipient.id(), - depth : 0, - pickup_lib : pickuplib, - partid : holdArgs.part - }; - - if(recurse) { - /* if we're calling create again (recursing), - we know that the hold possibility check already succeeded */ - holdHandleCreateResponse({_recurse:true, _hold:hold}, true ); - - } else { - _debug("hold possible args = "+js2JSON(args)); - - var req = new Request(CHECK_HOLD_POSSIBLE, G.user.session, args ); - - req.request.alertEvent = false; - req.request._hold = hold; - req.request._recurse = recurse; - req.callback(holdHandleCreateResponse); - req.send(); - } -} - - -function holdsBuildOrgSelector(node) { - - if(!node) node = globalOrgTree; - if(!isTrue(node.opac_visible()) && !isXUL()) return; - - var render_this_org = true; - var orgHiding = checkOrgHiding(); // value here is cached so not too painful with the recursion - if (orgHiding) { - if (node.id() == globalOrgTree.id()) { - node = orgHiding.org; // top of tree = org hiding context org - } - if ( ! orgIsMine( orgHiding.org, node, orgHiding.depth ) ) { - render_this_org = false; - } - } - - if (render_this_org) { - var selector = $('holds_org_selector'); - var index = selector.options.length; - - var type = findOrgType(node.ou_type()); - var indent = type.depth() - 1; - - var opt = setSelectorVal( selector, index, node.name(), node.id(), null, indent ); - if(!type.can_have_users()) { - opt.disabled = true; - addCSSClass(opt, 'disabled_option'); - } - } - - for( var i in node.children() ) { - var child = node.children()[i]; - if(child) holdsBuildOrgSelector(child); - } -} - -function holdsBuildHoldFromWindow() { - - var org = getSelectorVal($('holds_org_selector')); - var node = findOrgUnit(org); - var ntype = findOrgType(node.ou_type()); - if(!ntype.can_have_users()) { - alertId('holds_pick_good_org'); - return; - } - - fieldmapper.IDL.load(['ahr']); - var hold = new ahr(); - if(holdArgs.editHold) { - hold = holdArgs.editHold; - holdArgs.editHold = null; - } - - if( $('holds_enable_phone').checked ) { - var phone = $('holds_phone').value; - if( !phone || !phone.match(REGEX_PHONE) ) { - alert($('holds_bad_phone').innerHTML); - return null; - } - hold.phone_notify(phone); - - } else { - hold.phone_notify(""); - } - - if( $('holds_enable_email').checked ) - hold.email_notify(1); - else - hold.email_notify(0); - - var part = getSelectorVal($('holds_parts_selector')); - if(part) { - holdArgs.type = 'P'; - holdArgs.part = part; - } - - var target = holdArgs[holdTargetTypeMap[holdArgs.type]]; - - // a mono part is selected - - hold.pickup_lib(org); - //hold.request_lib(org); - hold.requestor(holdArgs.requestor.id()); - hold.usr(holdArgs.recipient.id()); - hold.target(target); - hold.hold_type(holdArgs.type); - - var expDate = dijit.byId('holds_expire_time').getValue(); - if(expDate) { - var expireDate = dojo.date.stamp.toISOString(expDate); - expireDate = holdsVerifyThawDate(expireDate); - if(expireDate) - hold.expire_time(expireDate); - else - return; - } - - // see if this hold should be frozen and for how long - if($('holds_frozen_chkbox').checked) { - hold.frozen('t'); - unHideMe($('hold_frozen_thaw_row')); - var thawDate = dijit.byId('holds_frozen_thaw_input').attr('value'); - if(thawDate) { - thawDate = dojo.date.stamp.toISOString(thawDate); - thawDate = holdsVerifyThawDate(thawDate); - if(thawDate) - hold.thaw_date(thawDate); - else - return; - } else { - hold.thaw_date(null); - } - } else { - hold.frozen('f'); - hold.thaw_date(null); - } - - //check for alternate hold formats - var fstring = holdsSetSelectedFormats(); - if(fstring) { - hold.hold_type('M'); - hold.holdable_formats(fstring); - if (fstring) - holdArgs.holdable_formats = fstring; - hold.target(holdArgs.metarecord); - } - return hold; -} - -function holdsPlaceHold(hold, recurse) { - if(!hold) return; - swapCanvas($('check_holds_box')); - holdsCheckPossibility(hold.pickup_lib(), hold, recurse); -} - - -function holdHandleCreateResponse(r, recurse) { - - if(!recurse) { - var res = r.getResultObject(); - var place_anyway = false; - if(checkILSEvent(res) || res.success != 1) { - if(res.success != 1) { - if(res.age_protected_copy == 1) { - // There is at least one copy that *could* fill the hold, if it were not age-protected. - if( confirm($('hold_age_protected_override').innerHTML) ) { - place_anyway = true; - } else { - swapCanvas($('holds_box')); - return; - } - } else if(res.place_unfillable == 1) { - if( confirm($('hold_place_unfillable_override').innerHTML) ) { - place_anyway = true; - } else { - swapCanvas($('holds_box')); - return; - } - } - } - if(!place_anyway) { - if(res.success != 1) { - - if(!holdArgs.partsSuggestionMade && holdArgs.recordParts && - holdArgs.recordParts.length && holdArgs.type == 'T') { - // T holds on records that have parts are OK, but if the record has no non-part - // copies, the hold will ultimately fail. Suggest selecting a part to the user. - addCSSClass($('holds_parts_selector'), 'parts-warning'); - holdArgs.partsSuggestionMade = true; - alert($('hold_has_parts').innerHTML); - } else { - alert($('hold_not_allowed').innerHTML); - } - } else { - if( res.textcode == 'PATRON_BARRED' ) { - alertId('hold_failed_patron_barred'); - } else { - alert($('hold_not_allowed').innerHTML); - } - } - swapCanvas($('holds_box')); - return; - } - } - r._hold.selection_depth(res.depth); - } - - holdCreateHold(r._recurse, r._hold); -} - - -function holdCreateHold( recurse, hold ) { - var method = CREATE_HOLD; - if(recurse) method = CREATE_HOLD_OVERRIDE; - var req = new Request( method, holdArgs.requestor.session, hold ); - req.request.alertEvent = false; - req.send(true); - var res = req.result(); - holdProcessResult(hold, res, recurse); - - showCanvas(); - - runEvt('common', 'holdUpdated'); -} - - -function holdProcessResult( hold, res, recurse ) { - - if( res && res > -1 ) { - alert($('holds_success').innerHTML); - holdArgs = null; - if(isXUL() && typeof xulG.opac_hold_placed == 'function') - xulG.opac_hold_placed(res); - - } else { - - if( recurse ) { - alert($('holds_failure').innerHTML); - return; - } - - if( grep(res, function(e) { return (e.textcode == 'HOLD_EXISTS'); }) ) { - if( fetchPermOrgs('HOLD_EXISTS.override')[0] != -1 ) { - if( confirm($('hold_dup_exists_override').innerHTML) ) { - return holdsPlaceHold(hold, true); - } - return; - - } else { - return alert($('hold_dup_exists').innerHTML); - } - } - - if( grep(res, function(e) { return (e.textcode == 'HOLD_ITEM_CHECKED_OUT'); }) ) { - if( fetchPermOrgs('HOLD_ITEM_CHECKED_OUT.override')[0] != -1 ) { - if( confirm($('hold_checked_out_override').innerHTML) ) { - return holdsPlaceHold(hold, true); - } - return; - - } else { - return alert($('hold_checked_out').innerHTML); - } - } - - - alert($('holds_failure').innerHTML); - } -} - - -function holdsCancel(holdid, user) { - if(!user) user = G.user; - var req = new Request(CANCEL_HOLD, user.session, holdid, /* Patron via OPAC */ 6); - req.send(true); - return req.result(); - runEvt('common', 'holdUpdated'); -} - -function holdsUpdate(hold, user) { - if(!user) user = G.user; - var req = new Request(UPDATE_HOLD, user.session, hold); - req.send(true); - var x = req.result(); // cause an exception if there is one - runEvt('common', 'holdUpdated'); -} - -/* verify that the thaw date is valid and after today */ -function holdsVerifyThawDate(dateString, isGreater) { - thawDate = dojo.date.stamp.fromISOString(dateString); - if(thawDate) { - if(isGreater) { - if(dojo.date.compare(thawDate) > 0) { - return dojo.date.stamp.toISOString(thawDate); - } - } else { - return dojo.date.stamp.toISOString(thawDate); - } - } - return null; -} - -function holdsVerifyThawDateUI(element) { - value = dojo.date.stamp.toISOString(dijit.byId(element).getValue()); - - if(!value) { - removeCSSClass($(element), 'invalid_field'); - return; - } - - if(!holdsVerifyThawDate(value, true)) { - addCSSClass($(element), 'invalid_field'); - } else { - removeCSSClass($(element), 'invalid_field'); - } -} - diff --git a/Open-ILS/web/opac/skin/default/js/mresult.js b/Open-ILS/web/opac/skin/default/js/mresult.js deleted file mode 100644 index c6c548b594..0000000000 --- a/Open-ILS/web/opac/skin/default/js/mresult.js +++ /dev/null @@ -1,141 +0,0 @@ -//var records = {}; -var records = []; -var ranks = []; -var onlyrecord = {}; -var table; -var mresultPreCache = 200; -var searchTimer; -var resultFacetKey; - -attachEvt("common", "unload", mresultUnload); -attachEvt("common", "run", mresultDoSearch); -attachEvt("result", "idsReceived", mresultSetRecords); -attachEvt("result", "idsReceived", mresultCollectRecords); - -function mresultUnload() { removeChildren(table); table = null;} - -hideMe($('copyright_block')); - -function mresultDoSearch() { - - - TFORM = null; /* clear the rresult tform var so it's not propogated */ - - swapCanvas($('loading_alt')); - table = G.ui.result.main_table; - - var holdTarget = new CGI().param('hold_target'); - if(holdTarget != null) { - mresultHandlePlaceHold(holdTarget); - return; - } - - - while( table.parentNode.rows.length <= (getDisplayCount() + 1) ) - table.appendChild(G.ui.result.row_template.cloneNode(true)); - - if( (getSearches() || getAdvTerm()) && !getTerm() ) { - if(getAdvType() == ADVTYPE_MULTI ) mresultCollectAdvIds(); - - } else { - _mresultCollectIds(); - ADVTERM = ""; - ADVTYPE = ""; - } -} - -function _mresultCollectIds() { - resultCollectSearchIds(true, SEARCH_MRS_QUERY, mresultHandleMRIds ); -} - -function mresultCollectAdvIds() { - resultCollectSearchIds(false, SEARCH_MRS_QUERY, mresultHandleMRIds ); -} - -function mresultHandleMRIds(r) { - var res = r.getResultObject(); - resultFacetKey = res.facet_key; - resultCompiledSearch = res.compiled_search; - dojo.require('dojo.cookie'); - dojo.cookie(COOKIE_SEARCH, js2JSON(res.compiled_search)); - if(res.count != null) { - if( getOffset() == 0 ) HITCOUNT = res.count; - runEvt('result', 'hitCountReceived'); - } - runEvt('result', 'idsReceived', res.ids); -} - - - -function mresultSetRecords(idstruct) { - if(!idstruct) return; - var o = getOffset(); - for( var x = o; x < idstruct.length + o; x++ ) { - if( idstruct[x-o] != null ) { - var r = parseInt(idstruct[x - o][0]); - var ra = parseFloat(idstruct[x - o][1]); - var or = parseInt(idstruct[x - o][2]); - if(!isNull(r) && !isNaN(r)) records[x] = r; - if(!isNull(ra) && !isNaN(ra)) ranks[x] = ra; - if(!isNull(or) && !isNaN(or)) onlyrecord[x] = or; - } - } - - TOPRANK = ranks[getOffset()]; -} - - - -var recsReceivedCalled = false; -function mresultCollectRecords() { - if(getHitCount() > 0 ) runEvt("result", "preCollectRecords"); - var i = 0; - for( var x = getOffset(); x!= getDisplayCount() + getOffset(); x++ ) { - if(isNull(records[x])) break; - if(isNaN(records[x])) continue; - var req = new Request(FETCH_MRMODS, records[x]); - - req.request.userdata = i++; - - /* wait at most 10 seconds for the mods rec to come back */ - /* this needs more testing */ - req.request.timeout(10); - req.request.abortCallback( - function(){ - recordsHandled++; - if(resultPageIsDone() && !recsReceivedCalled) { - recsReceivedCalled = true; - runEvt('result', 'allRecordsReceived', recordsCache); - unHideMe($('copyright_block')); - } - } - ); - - req.callback(mresultHandleMods); - req.send(); - } -} - -function mresultHandleMods(r) { - var rec = r.getResultObject(); - var pagePosition = r.userdata; - runEvt('result', 'recordReceived', rec, pagePosition, true); - if(rec) resultCollectCopyCounts(rec, pagePosition, FETCH_MR_COPY_COUNTS); - if(resultPageIsDone()) { - runEvt('result', 'allRecordsReceived', recordsCache); - unHideMe($('copyright_block')); /* *** */ - } -} - - -function mresultHandlePlaceHold(target) { - function reload() { - location.href = location.href.replace(/&hold_target=\d+/, ''); - } - attachEvt("common", "holdUpdated", reload); - attachEvt("common", "holdUpdateCanceled", reload); - attachEvt("common", "loginCanceled", reload); - holdsDrawEditor({record:target, type: 'M'}); -} - - diff --git a/Open-ILS/web/opac/skin/default/js/myopac.js b/Open-ILS/web/opac/skin/default/js/myopac.js deleted file mode 100644 index 7378106771..0000000000 --- a/Open-ILS/web/opac/skin/default/js/myopac.js +++ /dev/null @@ -1,1738 +0,0 @@ - -attachEvt("common", "run", myOPACInit ); -//attachEvt("common", "loggedIn", myOPACInit ); -attachEvt('common','locationUpdated', myopacReload ); - -dojo.requireLocalization("openils.opac", "opac"); - -var opac_strings = dojo.i18n.getLocalization("openils.opac", "opac"); -var fleshedUser = null; -var fleshedContainers = {}; -var holdCache = {}; -var holdStatusCache = {}; -var showHoldQueuePosition = false; -var allowPendingAddr = false; -var myopacEnableRefWorks = false; -var myopacRefWorksHost = 'http://www.refworks.com'; - -function clearNodes( node, keepArray ) { - if(!node) return; - for( var n in keepArray ) node.removeChild(keepArray[n]); - removeChildren(node); - for( var n in keepArray ) node.appendChild(keepArray[n]); -} - -function myOPACInit() { - - fieldmapper.IDL.load(['mous']); - - var orgHiding = checkOrgHiding(); - if (orgHiding) { - hideMe($('prefs_def_location_row')); - hideMe($('prefs_def_range_row')); - } - - if(!(G.user && G.user.session)) { - initLogin(); - - } else { - - allowPendingAddr = fetchOrgSettingDefault(G.user.home_ou(), 'opac.allow_pending_address'); - if(allowPendingAddr) - unHideMe($('myopac_pending_addr_td')); - myOPACChangePage( "summary" ); - } - - $('myopac_holds_thaw_date_input').onkeyup = - function(){holdsVerifyThawDateUI('myopac_holds_thaw_date_input'); } - $('myopac_holds_thaw_date_input').onchange = - function(){holdsVerifyThawDateUI('myopac_holds_thaw_date_input'); } - -} - -function myopacReload() { - //swapCanvas($('myopac_reloading')); - var a = {}; - a[PARAM_LOCATION] = getNewSearchLocation(); - a[PARAM_DEPTH] = getNewSearchDepth(); - hideMe($('canvas_main')); - goTo(buildOPACLink(a, true)); -} - - -function myOPACChangePage( page ) { - showCanvas(); - - var s = $("myopac_summary_td"); - var c = $("myopac_checked_td"); - var f = $("myopac_fines_td"); - var h = $("myopac_holds_td"); - var p = $("myopac_prefs_td"); - var b = $('myopac_bookbag_td'); - - var ss = $("myopac_summary_div"); - var cc = $("myopac_checked_div"); - var ff = $("myopac_fines_div"); - var hh = $("myopac_holds_div"); - var pp = $("myopac_prefs_div"); - var bb = $('myopac_bookbag_div'); - - var cls = "myopac_link"; - var acls = "myopac_link_active"; - - hideMe(ss); - hideMe(cc); hideMe(ff); - hideMe(hh); hideMe(pp); - hideMe(bb); - - removeCSSClass(s, acls ); - removeCSSClass(c, acls ); - removeCSSClass(f, acls ); - removeCSSClass(h, acls ); - removeCSSClass(p, acls ); - removeCSSClass(b, acls ); - - switch( page ) { - - case "summary": - unHideMe(ss); - addCSSClass(s, acls ); - myOPACShowSummary(); - break; - - case "checked": - unHideMe(cc); - addCSSClass(c, acls ); - myOPACShowChecked(); - break; - - case "holds": - unHideMe(hh); - addCSSClass(h, acls ); - myOPACShowHolds(); - break; - - case "fines": - unHideMe(ff); - addCSSClass(f, acls ); - myOPACShowFines(); - break; - - case "prefs": - unHideMe(pp); - addCSSClass(p, acls ); - myOPACShowPrefs(); - break; - - case 'bookbag': - unHideMe(bb); - addCSSClass(b, acls); - myOPACShowBookbags(); - break; - } -} - -function myOPACShowChecked() { - if(checkedDrawn) return; - var req = new Request(FETCH_CHECKED_OUT_SUM, G.user.session, G.user.id()); - req.callback(myOPACDrawCheckedOutSlim); - req.send(); - - var nreq = new Request(FETCH_NON_CAT_CIRCS, G.user.session); - nreq.callback(myOPACDrawNonCatCircs); - nreq.send(); -} - - -var checkedRowTemplate; -var circsCache = new Array(); -var checkedDrawn = false; - -function moClearCheckedTable() { - var tbody = $("myopac_checked_tbody"); - var loading = $("myopac_checked_loading"); - var none = $("myopac_checked_none"); - clearNodes( tbody, [ loading, none ] ); -} - -var __can_renew_one = false; - -function myOPACDrawCheckedOutSlim(r) { - - var checked = r.getResultObject(); - var tbody = $("myopac_checked_tbody"); - var loading = $("myopac_checked_loading"); - var none = $("myopac_checked_none"); - - __can_renew_one = false; - - if(checkedDrawn) return; - checkedDrawn = true; - if(!checkedRowTemplate) - checkedRowTemplate = tbody.removeChild($("myopac_checked_row")); - - moClearCheckedTable(); - - hideMe(loading); /* remove all children and start over */ - if(!(checked && (checked.out || checked.overdue))) { - unHideMe(none); - 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.od = true; - 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(collectCircs); - req.send(); - } - - appendClear($('mo_items_out_count'), - text(new String( parseInt(checked.overdue.length) + parseInt(checked.out.length) )) ); - - if( checked.overdue.length > 0 ) { - addCSSClass($('mo_items_overdue_count'), 'overdue'); - appendClear($('mo_items_overdue_count'), - text(new String( parseInt(checked.overdue.length) )) ); - } - -} - - -//function myOPACDrawCheckedItem(r) { -function myOPACDrawCheckedItem(circ, 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()); - - var due = _trimTime(circ.due_date()); - - var dlink = $n( row, "myopac_checked_due" ); - var rlink = $n( row, "myopac_checked_renewals" ); - //var rnlink = $n( row, "myopac_checked_renew_link" ); - - //if( r.od ) due = elem('b', {style:'color:red;font-size:110%'},due); - if( circ._od ) { - due = elem('b', null, due); - addCSSClass(due, 'overdue'); - } else { - due = text(due); - } - - dlink.appendChild(due); - rlink.appendChild(text(circ.renewal_remaining())); - unHideMe(row); - //rnlink.setAttribute('href', 'javascript:myOPACRenewCirc("'+circ.id()+'");'); - circsCache.push(circ); - - if( circ.renewal_remaining() < 1 ) { - $n(row, 'selectme').disabled = true; - if(!__can_renew_one) - $('mo_renew_button').disabled = true; - } else { - __can_renew_one = true; - $('mo_renew_button').disabled = false; - $n(row, 'selectme').disabled = false; - } - - tbody.appendChild(row); - - var req = new Request(FETCH_MODS_FROM_COPY, circ.target_copy() ); - req.request.alertEvent = false; - req.request.circ = circ.id(); - req.request.copy = circ.target_copy(); - req.callback(myOPACDrawCheckedTitle); - req.send(); -} - -var __circ_titles = {}; - -function myOPACDrawCheckedTitle(r) { - var record = r.getResultObject(); - var circid = r.circ; - - /* Draw pre-cataloged items */ - if(!record || checkILSEvent(record) || !(record.title() || record.author())) { - var req = new Request( FETCH_COPY, r.copy ); - req.request.circ = circid; - req.callback(myOPACDrawPreCatalogedItem); - req.send(); - return; - } - - var row = $('myopac_checked_row_ ' + circid); - var tlink = $n( row, "myopac_checked_title_link" ); - var alink = $n( row, "myopac_checked_author_link" ); - - buildTitleDetailLink(record, tlink); - buildSearchLink(STYPE_AUTHOR, record.author(), alink); - __circ_titles[circid] = record.title(); -} - -function myOPACDrawPreCatalogedItem(r) { - var copy = r.getResultObject(); - var circid = r.circ; - - var row = $('myopac_checked_row_ ' + circid); - var tlink = $n( row, "myopac_checked_title_link" ); - var alink = $n( row, "myopac_checked_author_link" ); - - tlink.parentNode.appendChild(text(copy.dummy_title())); - alink.parentNode.appendChild(text(copy.dummy_author())); - __circ_titles[circid] = copy.dummy_title(); -} - - -/* -function myOPACRenewCirc(circid) { - - var circ; - for( var i = 0; i != circsCache.length; i++ ) - if(circsCache[i].id() == circid) - circ = circsCache[i]; - - if(!confirm($('myopac_renew_confirm').innerHTML)) return; - - var req = new Request(RENEW_CIRC, G.user.session, - { patron : G.user.id(), copyid : circ.target_copy(), opac_renewal : 1 } ); - req.request.alertEvent = false; - req.send(true); - var res = req.result(); - - if(checkILSEvent(res) || checkILSEvent(res[0])) { - alertId('myopac_renew_fail'); - return; - } - - alert($('myopac_renew_success').innerHTML); - checkedDrawn = false; - myOPACShowChecked(); -} -*/ - - - -function myOPACShowHolds() { - var req = new Request(FETCH_HOLDS, G.user.session, G.user.id()); - req.callback(myOPACDrawHolds); - req.send(); - $('myopac_holds_actions_none').selected = true; -} - -var holdsTemplateRowOrig; -var holdsTemplateRow; -var myopacForceHoldsRedraw = false; -function myOPACDrawHolds(r) { - - var tbody = $("myopac_holds_tbody"); - if(holdsTemplateRow && !myopacForceHoldsRedraw) return; - myopacForceHoldsRedraw = false; - - if(holdsTemplateRowOrig) { - holdsTemplateRow = holdsTemplateRowOrig; - removeChildren(tbody); - } else { - holdsTemplateRow = tbody.removeChild($("myopac_holds_row")); - holdsTemplateRowOrig = holdsTemplateRow; - } - - hideMe($('myopac_holds_loading')); - - var holds = r.getResultObject(); - - if(!holds || holds.length < 1) unHideMe($('myopac_holds_none')); - for( var i = 0; i != holds.length; i++ ) { - - var h = holds[i]; - holdCache[h.id()] = h; - - var row = holdsTemplateRow.cloneNode(true); - row.id = "myopac_holds_row_" + h.id(); - - var form = $n(row, "myopac_holds_formats"); - form.id = "myopac_holds_form_" + h.id(); - - var orglink = $n(row, "myopac_holds_location"); - orglink.appendChild(text(findOrgUnit(h.pickup_lib()).name())); - - tbody.appendChild(row); - - $n(row,'myopac_holds_edit_link').setAttribute( - 'href','javascript:myOPACEditHold("'+ h.id()+'");'); - - if(isTrue(h.frozen())) { - hideMe($n(row, 'myopac_hold_unfrozen_true')) - unHideMe($n(row, 'myopac_hold_unfrozen_false')) - if(h.thaw_date()) { - var d = dojo.date.stamp.fromISOString(h.thaw_date()); - $n(row, 'myopac_holds_frozen_until').appendChild(text(dojo.date.locale.format(d, {selector: 'date', fullYear: true}))); - } - } else { - unHideMe($n(row, 'myopac_hold_unfrozen_true')) - hideMe($n(row, 'myopac_hold_unfrozen_false')) - } - - $n(row, 'myopac_holds_selected_chkbx').checked = false; - - var exp_date; - if(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'}))); - } - - unHideMe(row); - - var interval = fetchOrgSettingDefault(G.user.home_ou(), 'circ.hold_expire_alert_interval'); - if(interval && exp_date) { - secs = interval_to_seconds(interval) * 1000; - var diff = exp_date.getTime() - new Date().getTime(); - if(diff < secs) - addCSSClass($n(row, 'myopac_hold_expire_time'), 'hold_expire_warning'); - } - - myOPACDrawHoldTitle(h); - myOPACDrawHoldStatus(h); - } -} - -function myOPACEditHold(holdid) { - var hold = holdCache[holdid]; - - holdsDrawEditor( - { - editHold : hold, - onComplete : function(){ - holdsTemplateRow = null; - myOPACShowHolds(); - } - } - ); -} - - -function myOPACDrawHoldStatus(hold) { - var req = new Request(FETCH_HOLD_STATUS, G.user.session, hold.id() ); - req.callback(myOShowHoldStatus); - req.request.hold = hold; - req.send(); -} - -var myopacShowHoldEstimate = false; -function myOShowHoldStatus(r) { - - var hold = r.hold; - var qstats = r.getResultObject(); - holdStatusCache[hold.id()] = qstats; - - var row = $("myopac_holds_row_" + r.hold.id()); - - // A note: estimated_wait may be -1 under some circumstances where it shouldn't be shown. - if((qstats.estimated_wait && qstats.estimated_wait > 0) || myopacShowHoldEstimate) { - myopacShowHoldEstimate = true; - if(qstats.estimated_wait) { - // wait is currently returned in seconds, but displayed in days - var wait = Math.ceil(qstats.estimated_wait / 86400); - $n(row, 'myopac_holds_estimated_wait').appendChild(text(wait)); - } - unHideMe($('myopac_holds_estimated_wait_column')); - unHideMe($n(row, 'myopac_holds_estimated_wait')); - } - - if( qstats.status == 4 ) { - unHideMe($n(row, 'hold_status_available')); - hideMe($n(row, 'myopac_holds_cancel_link')); - } - - if( qstats.status == 7 ) { - unHideMe($n(row, 'hold_status_suspended')); - } else if (showHoldQueuePosition) { - var node = $n(row, 'hold_qstats'); - if (qstats.potential_copies == 1) { - node.appendChild(text(dojo.string.substitute(opac_strings.HOLD_STATUS_SINGULAR, [qstats.queue_position, qstats.total_holds, qstats.potential_copies]))); - } else { - node.appendChild(text(dojo.string.substitute(opac_strings.HOLD_STATUS_PLURAL, [qstats.queue_position, qstats.total_holds, qstats.potential_copies]))); - } - unHideMe(node); - - } else { - if( qstats.status < 3 ) - unHideMe($n(row, 'hold_status_waiting')); - - if( qstats.status == 3 || qstats.status == 8 ) - unHideMe($n(row, 'hold_status_transit')); - } -} - - -function myOPACDrawHoldTitle(hold) { - var method; - - if( hold.hold_type() == 'T' || hold.hold_type() == 'M') { - if(hold.hold_type() == "M") method = FETCH_MRMODS; - if(hold.hold_type() == "T") method = FETCH_RMODS; - var req = new Request(method, hold.target()); - req.callback(myOPACFleshHoldTitle); - req.request.hold = hold; - req.request.alertEvent = false; - req.send(); - - } else { - holdFetchObjects(hold, - function(a) { _myOPACFleshHoldTitle(hold, a);}); - } -} - -function myOPACFleshHoldTitle(r) { - var rec = r.getResultObject(); - _myOPACFleshHoldTitle(r.hold, {recordObject: rec}); -} - -function _myOPACFleshHoldTitle(hold, holdObjects) { - - var record = holdObjects.recordObject; - var volume = holdObjects.volumeObject; - var copy = holdObjects.copyObject; - - var row = $("myopac_holds_row_" + hold.id()); - var title_link = $n(row, "myopac_holds_title_link"); - var author_link = $n(row, "myopac_holds_author_link"); - - if(!record || checkILSEvent(record) ) { - addCSSClass(row, 'invalid_hold'); - $n(row, 'myopac_holds_edit_link').setAttribute('href', 'javascript:void(0);'); - $n(row, 'myopac_holds_edit_link').onclick = function(){alertId('invalid_hold');}; - return; - } - - buildTitleDetailLink(record, title_link); - buildSearchLink(STYPE_AUTHOR, record.author(), author_link); - - if(hold.hold_type() == 'P') { - unHideMe($n(row, 'vol_copy')); - $n(row, 'part').appendChild(text(holdObjects.partObject.label)); - } - - if( volume ) { - $n(row, 'volume').appendChild(text(volume.label())); - unHideMe($n(row, 'vol_copy')); - if(copy) $n(row, 'copy').appendChild(text(copy.barcode())); - } - - var form = $("myopac_holds_form_" + hold.id()); - - if(form) { - var mods_formats = record.types_of_resource(); - - if( hold.hold_type() == 'M' ) { - var data = holdsParseMRFormats(hold.holdable_formats()); - mods_formats = data.mods_formats; - } - - for( var i = 0; i < mods_formats.length; i++ ) { - var img = elem("img"); - setResourcePic(img, mods_formats[i]); - form.appendChild(img); - } - } -} - -var finesShown = false; -function myOPACShowFines() { - if(finesShown) return; finesShown = true; - var req = new Request(FETCH_FINES_SUMMARY, G.user.session, G.user.id() ); - req.callback(_myOPACShowFines); - req.send(); -} - -function _myOPACShowFines(r) { - hideMe($('myopac_fines_summary_loading')); - unHideMe($('myopac_fines_summary_row')); - - var summary = r.getResultObject(); - var total = "0.00"; /* localization? */ - var paid = "0.00"; - var balance = "0.00"; - if( instanceOf(summary,mous) ) { - - total = _finesFormatNumber(summary.total_owed()); - paid = _finesFormatNumber(summary.total_paid()); - balance = _finesFormatNumber(summary.balance_owed()); - - var req = new Request(FETCH_TRANSACTIONS, G.user.session, G.user.id() ); - req.callback(myOPACShowTransactions); - req.send(); - } - - $('myopac_fines_summary_total').appendChild(text(total)); - $('myopac_fines_summary_paid').appendChild(text(paid)); - $('myopac_fines_summary_balance').appendChild(text(balance)); -} - -function _finesFormatNumber(num) { - if(isNull(num)) num = 0; - num = num + ""; - if(num.length < 2 || !num.match(/\./)) num += ".00"; - if(num.match(/\./) && num.charAt(num.length-2) == '.') num += "0"; - return 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 dojo.date.locale.format(d, {"formatLength": "medium"}); -} - -function _trimSeconds(time) { - if(!time) return ""; - 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 dojo.date.locale.format(d, { "timePattern" : "h:ma", "formatLength" : "medium" }); -} - -function myOPACShowTransactions(r) { - - if(myopacGenericTransTemplate || myopacCircTransTemplate) return; - - var transactions = r.getResultObject(); - - for( var idx in transactions ) { - - var trans = transactions[idx].transaction; - var record = transactions[idx].record; - var circ = transactions[idx].circ; - - if(trans.xact_type() == 'circulation') - myOPACShowCircTransaction(trans, record, circ); - - else if(trans.xact_type() == 'grocery' ) - myopacShowGenericTransaction( trans ); - -/* XXX need to copy circulation output function here - else if(trans.xact_type() == 'reservation' ) - myopacShowReservationTransaction( trans ); -*/ - - } -} - -var myopacGenericTransTemplate; -function myopacShowGenericTransaction( trans ) { - var tbody = $('myopac_trans_tbody'); - - if(!myopacGenericTransTemplate) { - myopacGenericTransTemplate = - tbody.removeChild($('myopac_trans_row')); - removeChildren(tbody); - } - - var row = myopacGenericTransTemplate.cloneNode(true); - - $n(row,'myopac_trans_start').appendChild( - text(_trimSeconds(trans.xact_start()))); - - $n(row,'myopac_trans_last_payment').appendChild( - text(_trimSeconds(trans.last_payment_ts()))); - - $n(row,'myopac_trans_init_amount').appendChild( - text(_finesFormatNumber(trans.total_owed()))); - - $n(row,'myopac_trans_total_paid').appendChild( - text(_finesFormatNumber(trans.total_paid()))); - - $n(row,'myopac_trans_balance').appendChild( - text(_finesFormatNumber(trans.balance_owed()))); - - var req = new Request(FETCH_MONEY_BILLING, G.user.session, trans.id()); - req.send(true); - var bills = req.result(); - if(bills && bills[0]) - $n(row,'myopac_trans_bill_type').appendChild( - text(bills[0].billing_type())); - - tbody.appendChild(row); - unHideMe($('myopac_trans_div')); -} - - - -/* draws a circulation transaction summary */ -var myopacCircTransTemplate; -function myOPACShowCircTransaction(trans, record, circ) { - var tbody = $('myopac_circ_trans_tbody'); - - if(!myopacCircTransTemplate) { - myopacCircTransTemplate = tbody.removeChild($('myopac_circ_trans_row')); - removeChildren(tbody); - } - - var row = myopacCircTransTemplate.cloneNode(true); - - if(record) { - buildTitleDetailLink(record, $n(row,'myopac_circ_trans_title')); - - $n(row,'myopac_circ_trans_author').appendChild(text( - normalize(truncate(record.author(), 65)))); - - } else { - - var req = new Request( FETCH_COPY, circ.target_copy() ); - req.alertEvents = false; - req.send(true); - var copy = req.result(); - if( copy ) { - $n(row,'myopac_circ_trans_title').appendChild(text(copy.dummy_title())); - $n(row,'myopac_circ_trans_author').appendChild(text(copy.dummy_author())); - } - } - - - $n(row,'myopac_circ_trans_start'). - appendChild(text(_trimTime(trans.xact_start()))); - var due = _trimTime(circ.due_date()); - var checkin = _trimTime(circ.checkin_time()); - - $n(row,'myopac_circ_trans_due').appendChild(text(due)) - if(checkin) - appendClear($n(row,'myopac_circ_trans_finished'), text(checkin)); - if(circ.stop_fines() == 'LOST') - appendClear($n(row,'myopac_circ_trans_finished'), text(circ.stop_fines())); - if(circ.stop_fines() == 'CLAIMSRETURNED') - appendClear($n(row,'myopac_circ_trans_finished'), text("")); - - - $n(row,'myopac_circ_trans_balance'). - appendChild(text(_finesFormatNumber(trans.balance_owed()))); - - tbody.appendChild(row); - unHideMe($('myopac_circ_trans_div')); -} - - -function myOPACSavePrefs() { - G.user.prefs[PREF_HITS_PER] = getSelectorVal($('prefs_hits_per')); - G.user.prefs[PREF_DEF_FONT] = getSelectorVal($('prefs_def_font')); - G.user.prefs[PREF_HOLD_NOTIFY] = getSelectorVal($('prefs_hold_notify')); - G.user.prefs[PREF_DEF_DEPTH] = getSelectorVal($('prefs_def_range')); - - if( $('myopac_pref_home_lib').checked == true ) - G.user.prefs[PREF_DEF_LOCATION] = null; - else - G.user.prefs[PREF_DEF_LOCATION] = getSelectorVal($('prefs_def_location')); - - if(commitUserPrefs()) - alert($('prefs_update_success').innerHTML); - else alert($('prefs_update_failure').innerHTML); -} - - -function myOPACShowDefFont() { - var font; - if(G.user.prefs[PREF_DEF_FONT]) - font = G.user.prefs[PREF_DEF_FONT]; - else font = "regular"; - setSelector($('prefs_def_font'), font); -} - -function myOPACShowHoldNotify() { - var pref = G.user.prefs[PREF_HOLD_NOTIFY]; - - if(pref) { - if(pref.match(/email/i) && pref.match(/phone/i)) { - setSelector($('prefs_hold_notify'), 'phone:email'); - } else if( pref.match(/email/i) ) { - setSelector($('prefs_hold_notify'), 'email'); - } else if( pref.match(/phone/i) ) { - setSelector($('prefs_hold_notify'), 'phone'); - } - - } else { - setSelector($('prefs_hold_notify'), 'phone:email'); - } -} - -function myOPACShowPrefs() { - grabUserPrefs(); - myOPACShowHitsPer(); - myOPACShowDefFont(); - myOPACShowHoldNotify(); - myOPACShowDefLocation(); - hideMe($('myopac_prefs_loading')); -} - -var defSearchLocationDrawn = false; -var defDepthIndex = 0; -function myOPACShowDefLocation() { - - var selector = $('prefs_def_location'); - var rsel = $('prefs_def_range'); - - if(!defSearchLocationDrawn) { - - defSearchLocationDrawn = true; - - var org = G.user.prefs[PREF_DEF_LOCATION]; - - if(!org) { - $('myopac_pref_home_lib').checked = true; - $('prefs_def_location').disabled = true; - org = G.user.home_ou(); - } - - buildOrgSel(selector, globalOrgTree, 0); - - globalOrgTypes = globalOrgTypes.sort( - function(a, b) { - if( a.depth() < b.depth() ) return -1; - return 1; - } - ); - - iterate(globalOrgTypes, - function(t) { - if( t.depth() <= findOrgDepth(org) ) { - setSelectorVal(rsel, defDepthIndex++, t.opac_label(), t.depth()); - if( t.depth() == findOrgDepth(org) ) - setSelector(rsel, t.depth()); - } - } - ); - } - - setSelector(selector, org); -} - -function myOPACShowHitsPer() { - var hits = 10; - if(G.user.prefs[PREF_HITS_PER]) - hits = G.user.prefs[PREF_HITS_PER]; - var hitsSel = $('prefs_hits_per'); - setSelector(hitsSel, hits); -} - -var userShown = false; -function myOPACShowSummary() { - if(userShown) return; userShown = true; - var req = new Request(FETCH_FLESHED_USER,G.user.session, G.user.id()); - req.callback(_myOPACSummaryShowUer); - req.send(); -} - -var addrRowTemplate; -var notesTemplate; -function _myOPACSummaryShowUer(r) { - - var user = r.getResultObject(); - fleshedUser = user; - if(!user) return; - - var expireDate = dojo.date.stamp.fromISOString(user.expire_date()); - if( expireDate < new Date() ) { - appendClear($('myopac.expired.date'), dojo.date.locale.format(expireDate, { "formatLength" : "medium", "selector" : "date" })); - unHideMe($('myopac.expired.alert')); - } - - var iv1 = ''; - if (user.ident_value()) { - iv1 = user.ident_value()+''; - if (iv1.length > 4 && iv1.match(/\d{4}/)) iv1 = iv1.substring(0,4) + '***********'; - } - - appendClear($('myopac_summary_prefix'),text(user.prefix())); - appendClear($('myopac_summary_first'),text(user.first_given_name())); - appendClear($('myopac_summary_middle'),text(user.second_given_name())); - appendClear($('myopac_summary_dayphone'),text(user.day_phone())); - appendClear($('myopac_summary_eveningphone'),text(user.evening_phone())); - appendClear($('myopac_summary_otherphone'),text(user.other_phone())); - appendClear($('myopac_summary_last'),text(user.family_name())); - appendClear($('myopac_summary_suffix'),text(user.suffix())); - appendClear($('myopac_summary_username'),text(user.usrname())); - appendClear($('myopac_summary_email'),text(user.email())); - appendClear($('myopac_summary_barcode'),text(user.card().barcode())); - appendClear($('myopac_summary_ident1'),text(iv1)); - appendClear($('myopac_summary_homelib'),text(findOrgUnit(user.home_ou()).name())); - appendClear($('myopac_summary_create_date'),text(_trimTime(user.create_date()))); - - var req = new Request( - FETCH_USER_NOTES, G.user.session, {pub:1, patronid:G.user.id()}); - req.callback(myopacDrawNotes); - req.send(); - - r = fetchOrgSettingDefault(G.user.home_ou(), 'opac.lock_usernames'); - if(r) { - // No changing username - Policy Lock - hideMe($('myopac_summary_username_change')); - } else { - r = fetchOrgSettingDefault(G.user.home_ou(), 'opac.unlimit_usernames'); - if(!r) { - r = fetchOrgSettingDefault(G.user.home_ou(), 'opac.barcode_regex'); - if(r) REGEX_BARCODE = new RegExp(r); - - if(!user.usrname().match(REGEX_BARCODE)) { - // No changing username - You already have one! - hideMe($('myopac_summary_username_change')); - } - } - } - - var tbody = $('myopac_addr_tbody'); - var template; - - if(addrRowTemplate) { - template = addrRowTemplate; - } else { - template = tbody.removeChild($('myopac_addr_row')); - addrRowTemplate = template; - } - removeChildren(tbody); - - var addrs = user.addresses(); - for( var a in addrs ) { - var addr = addrs[a]; - if(!allowPendingAddr && isTrue(addr.pending())) - continue; - if(addr.replaces() != null) continue; - var row = template.cloneNode(true); - myOPACDrawAddr(row, addr, addrs); - tbody.appendChild(row); - } -} - - -function myopacDrawNotes(r) { - var notes = r.getResultObject(); - var tbody = $('myopac.notes.tbody'); - if(!notesTemplate) - notesTemplate = tbody.removeChild($('myopac.notes.tr')); - removeChildren(tbody); - - iterate(notes, - function(note) { - unHideMe($('myopac.notes.div')); - var row = notesTemplate.cloneNode(true); - $n(row, 'title').appendChild(text(note.title())); - $n(row, 'value').appendChild(text(note.value())); - tbody.appendChild(row); - } - ); -} - - - -function myOPACDrawAddr(row, addr, addrs) { - appendClear($n(row, 'myopac_addr_type'),text(addr.address_type())); - appendClear($n(row, 'myopac_addr_street'),text(addr.street1())); - appendClear($n(row, 'myopac_addr_street2'),text(addr.street2())); - appendClear($n(row, 'myopac_addr_city'),text(addr.city())); - appendClear($n(row, 'myopac_addr_county'),text(addr.county())); - appendClear($n(row, 'myopac_addr_state'),text(addr.state())); - appendClear($n(row, 'myopac_addr_country'),text(addr.country())); - appendClear($n(row, 'myopac_addr_zip'),text(addr.post_code())); - - if(!isTrue(addr.valid())) - unHideMe($n(row, 'myopac_invalid_addr_row')); - - if(!allowPendingAddr) return; - - $n(row, 'myopac_addr_edit_link').onclick = function(){myopacEditAddress(addr)}; - unHideMe($n(row, 'myopac_addr_edit_td')); - - /* if we have a replacement address, plop it into the table next to this addr */ - var repl = grep(addrs, - function(a) { - return a.replaces() == addr.id(); - } - ); - - $n(row, 'myopac_pending_addr_td').id = 'myopac_pending_addr_td_' + addr.id(); - - if(repl) { - hideMe($n(row, 'myopac_addr_edit_td')); // hide the edit link - repl = repl[0]; - myopacSetAddrInputs(row, repl); - } -} - -function myopacEditAddress(addr) { - var td = $('myopac_pending_addr_td_' + addr.id()); - var row = td.parentNode; - myopacSetAddrInputs(row, addr); -} - -function myopacSetAddrInputs(row, addr, prefix) { - unHideMe($n(row, 'myopac_pending_addr_td')); - $n(row, 'myopac_pending_addr_type').value = addr.address_type(); - $n(row, 'myopac_pending_addr_street').value = addr.street1(); - $n(row, 'myopac_pending_addr_street2').value = addr.street2(); - $n(row, 'myopac_pending_addr_city').value = addr.city(); - $n(row, 'myopac_pending_addr_county').value = addr.county(); - $n(row, 'myopac_pending_addr_state').value = addr.state(); - $n(row, 'myopac_pending_addr_country').value = addr.country(); - $n(row, 'myopac_pending_addr_zip').value = addr.post_code(); - $n(row, 'myopac_pending_addr_edit_link').onclick = function(){myopacSaveAddress(row, addr)}; - $n(row, 'myopac_pending_addr_del_link').onclick = function(){myopacSaveAddress(row, addr, true)}; -} - -// if no pending addr exists, this is called with the original address -function myopacSaveAddress(row, addr, deleteMe) { - - if(addr.replaces() == null) { - // we are editing a non-pending address. create a pending address to manage that - var repl = new aua(); - repl.usr(addr.usr()); - repl.address_type(addr.address_type()); - repl.within_city_limits(addr.within_city_limits()); - repl.replaces(addr.id()); - repl.pending('t'); - repl.isnew(true); - repl.id(null); - addr = repl; - } - - if(deleteMe) { - if(addr.id() == null) { - hideMe($n(row, 'myopac_pending_addr_td')); - return; - } - addr.isdeleted(true); - } else { - addr.address_type($n(row, 'myopac_pending_addr_type').value); - addr.street1($n(row, 'myopac_pending_addr_street').value); - addr.street2($n(row, 'myopac_pending_addr_street2').value); - addr.city($n(row, 'myopac_pending_addr_city').value); - addr.county($n(row, 'myopac_pending_addr_county').value); - addr.state($n(row, 'myopac_pending_addr_state').value); - addr.country($n(row, 'myopac_pending_addr_country').value); - addr.post_code($n(row, 'myopac_pending_addr_zip').value); - } - - var req = new Request( - 'open-ils.actor:open-ils.actor.user.address.pending.cud', - G.user.session, addr); - - req.callback( - function(r) { - var resp = r.getResultObject(); - - if(addr.isnew()) { - // new, add to list of addrs - addr.id(resp); - fleshedUser.addresses().push(addr); - - } else { - // deleted, remove from list of addrs - if(addr.isdeleted()) { - hideMe($n(row, 'myopac_pending_addr_td')); - var addrs = []; - for(var i in fleshedUser.addresses()) { - var a = fleshedUser.addresses()[i]; - if(a.id() != addr.id()) - addrs.push(a); - } - fleshedUser.addresses(addrs); - } - } - alertId('myopac_addr_changes_saved'); - } - ); - req.send(); -}; - - -function myOPACUpdateUsername() { - var username = $('myopac_new_username').value; - var curpassword = $('myopac_username_current_password').value; - if(username == null || username == "") { - alert($('myopac_username_error').innerHTML); - return; - } - - if( username.match(/.*\s.*/) ) { - alert($('myopac_invalid_username').innerHTML); - return; - } - - r = fetchOrgSettingDefault(G.user.home_ou(), 'opac.barcode_regex'); - if(r) REGEX_BARCODE = new RegExp(r); - - if(username.match(REGEX_BARCODE)) { - alert($('myopac_invalid_username').innerHTML); - return; - } - - r = fetchOrgSettingDefault(G.user.home_ou(), 'opac.username_regex'); - if(r) { - if(!username.match(new RegExp(r))) { - alert($('myopac_invalid_username').innerHTML); - return; - } - } - - /* first see if the requested username is taken */ - var req = new Request(CHECK_USERNAME, G.user.session, username); - req.send(true); - var res = req.result(); - /* If the username does not already exist, res will be null; - * we can move on to updating the username. - * - * If the username does exist, then res will be the user ID. - * G.user.id() gives us the currently authenticated user ID. - * If res == G.user.id(), we try to update the username anyways. - */ - if( res !== null && res != G.user.id() ) { - alertId('myopac_username_dup'); - return; - } - - var req = new Request(UPDATE_USERNAME, G.user.session, username, curpassword ); - req.send(true); - if(req.result()) { - - var evt; - var res = req.result(); - if(evt = checkILSEvent(res)) { - alertILSEvent(res); - return; - } - - G.user.usrname(username); - hideMe($('myopac_update_username_row')); - userShown = false; - alertId('myopac_username_success'); - myOPACShowSummary(); - return; - } - - alert($('myopac_username_failure').innerHTML); -} - -function myOPACUpdateEmail() { - var email = $('myopac_new_email').value; - var curpassword = $('myopac_email_current_password').value; - if(email == null || email == "") { - alert($('myopac_email_error').innerHTML); - return; - } - - var req = new Request(UPDATE_EMAIL, G.user.session, email, curpassword ); - req.send(true); - if(req.result()) { - G.user.email(email); - hideMe($('myopac_update_email_row')); - userShown = false; - alertId('myopac_email_success'); - myOPACShowSummary(); - return; - } - - alert($('myopac_email_failure').innerHTML); -} - - -function myOPACUpdatePassword() { - var curpassword = $('myopac_current_password').value; - var password = $('myopac_new_password').value; - var password2 = $('myopac_new_password2').value; - - if( curpassword == null || curpassword == "" || - password == null || password == "" || - password2 == null || password2 == "" || password != password2 ) { - alert($('myopac_password_error').innerHTML); - return; - } - - if(!strongPassword(password, true)) return; - - var req = new Request(UPDATE_PASSWORD, G.user.session, password, curpassword ); - req.send(true); - if(req.result()) { - hideMe($('myopac_update_password_row')); - userShown = false; - alertId('myopac_password_success'); - myOPACShowSummary(); - return; - } - - alert($('myopac_password_failure').innerHTML); -} - - - - -var containerTemplate; -function myOPACShowBookbags(force) { - - var tbody =$('myopac_bookbag_tbody') ; - - if(!containerTemplate) - containerTemplate = tbody.removeChild($('myopac_bookbag_tr')); - else if(!force) return; - - removeChildren(tbody); - - var containers = containerFetchAll(); - - var found = false; - for( var i in containers ) { - found = true; - var cont = containers[i]; - var row = containerTemplate.cloneNode(true); - row.id = 'myopac_bookbag_row_' + cont.id(); - var link = $n(row, 'myopac_expand_bookbag'); - var dlink = $n(row, 'myopac_container_delete'); - link.appendChild( text(cont.name()) ); - link.setAttribute('href', - 'javascript:myOPACExpandBookbag("' + cont.id() + '","' + cont.name() + '");'); - myOPACFetchBBItems( cont.id(), row ); - dlink.setAttribute('href', 'javascript:myOPACDeleteBookbag("'+cont.id()+'");'); - - if( isTrue(cont.pub()) ) { - unHideMe($n(row, 'myopac_bb_published_yes')); - var link = $n(row, 'myopac_bb_published_view'); - link.setAttribute('href', buildExtrasLink( 'feed/bookbag/html-full/'+cont.id(), false)); - link.setAttribute('target', '_blank' ); - unHideMe(link); - - link = $n(row, 'myopac_bb_published_atom'); - link.setAttribute('href', buildExtrasLink( 'feed/bookbag/rss2-full/'+cont.id(), false)); - link.setAttribute('target', '_blank' ); - unHideMe(link); - - 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'); - link.setAttribute('href', 'javascript:myOPACMakeBBPublished("'+cont.id()+'");'); - unHideMe(link); - } - - tbody.appendChild(row); - } - - if(!found) unHideMe($('myopac_bookbags_none')); - else unHideMe($('myopac_bookbag_table')); -} - -function myOPACMakeBBPublished(bbid, hideme) { - - var bb = fleshedContainers[bbid]; - - if(hideme) { - if(!confirm($('myopac_make_unpublished_confirm').innerHTML)) return; - bb.pub('f'); - } else { - if(!confirm($('myopac_make_published_confirm').innerHTML)) return; - bb.pub('t'); - } - - var result = containerUpdate(bb); - - var code = checkILSEvent(result); - if(code) { alertILSEvent(result); return; } - - alert($('myopac_bb_update_success').innerHTML); - myOPACShowBookbags(true); -} - - - -function myOPACDeleteBookbag(id) { - if( confirm( $('myopac_delete_bookbag_warn').innerHTML ) ) { - var result = containerDelete(id); - var code = checkILSEvent(result); - if(code) { alertILSEvent(result); return; } - alert($('myopac_bb_update_success').innerHTML); - hideMe($('myopac_bookbag_items_table')); - hideMe($('myopac_bookbag_items_name')); - hideMe($('myopac_bookbag_no_items')); - myOPACShowBookbags(true); - } -} - -function myOPACFetchBBItems( id, row, block ) { - if(!block) { - containerFlesh( id, _myOPACSetBBItems, { row: row } ); - } else { - var cont = containerFlesh(id); - myOPACSetBBItems( cont, row ); - } -} - -function _myOPACSetBBItems(r) { myOPACSetBBItems( r.getResultObject(), r.args.row ); } - -function myOPACSetBBItems( container, row ) { - fleshedContainers[container.id()] = container; - var node = $n(row, 'myopac_bookbag_item_count'); - removeChildren(node); - node.appendChild( text(container.items().length) ); -} - -var BBItemsRow; -function myOPACExpandBookbag( id, name ) { - - var tbody = $('myopac_bookbag_items_tbody'); - if(!BBItemsRow) BBItemsRow = tbody.removeChild($('myopac_bookbag_items_row')); - removeChildren(tbody); - removeChildren($('myopac_bookbag_items_name')); - - $('myopac_bookbag_items_name').appendChild(text(name)); - - if( fleshedContainers[id] ) { - var len = fleshedContainers[id].items().length; - - if( len == 0 ) { - unHideMe($('myopac_bookbag_no_items')); - hideMe($('myopac_bookbag_items_table')); - return; - } - - hideMe($('myopac_bookbag_no_items')); - unHideMe($('myopac_bookbag_items_table')); - - for( var i = 0; i != len; i++ ) { - var row = BBItemsRow.cloneNode(true); - found = true; - - var item = fleshedContainers[id].items()[i]; - var tlink = $n(row,'myopac_bookbag_items_title'); - var alink = $n(row,'myopac_bookbag_items_author'); - - var req = new Request( FETCH_RMODS, item.target_biblio_record_entry() ); - req.request.tlink = tlink; - req.request.alink = alink; - req.callback(myOPACShowBBItem); - req.send(); - - var clink = $n(row, 'myopac_bookbag_items_remove'); - clink.setAttribute('href', 'javascript:myOPACRemoveBBItem("'+item.id()+'","'+id+'","'+name+'");'); - - tbody.appendChild(row); - } - } -} - -function myOPACRemoveBBItem( id, containerid, container_name ) { - if(!confirm($('myopac_remove_bb_item_confirm').innerHTML)) return; - var stat = containerRemoveItem( id ); - if(stat) alert($('myopac_bb_update_success').innerHTML); - myOPACFetchBBItems( containerid, $('myopac_bookbag_row_' + containerid), true); - myOPACExpandBookbag( containerid, container_name ); -} - -function myOPACShowBBItem(r) { - var record = r.getResultObject(); - buildTitleDetailLink(record, r.tlink); - buildSearchLink(STYPE_AUTHOR, record.author(), r.alink); -} - -function myOPACCreateBookbag() { - var name = $('myopac_bookbag_new_name').value; - if(!name) return; - - var exists = false; - for( var c in fleshedContainers ) { exists = true; break; } - - /* let them know what they are getting into... */ - if(!exists) if(!confirm($('bb_create_warning').innerHTML)) return; - - var result = containerCreate( name, $('bb_public_yes').checked ); - var code = checkILSEvent(result); - if(code) { alertILSEvent(result); return; } - if(result) alert($('myopac_bb_update_success').innerHTML); - myOPACShowBookbags(true); -} - - -/* ---------------------------------------------------------------------- */ -/* Non cat circs */ -/* ---------------------------------------------------------------------- */ - -var nonCatCircIds; -var nonCatTypes; -/* if we have some circs, grab the non-cat types */ -function myOPACDrawNonCatCircs(r) { - var ids = r.getResultObject(); - if(ids.length == 0) return; - nonCatCircIds = ids; - unHideMe($('non_cat_circs_div')); - var req = new Request(FETCH_NON_CAT_TYPES, G.user.home_ou()); - req.callback(myOPACDrawNonCatCircs2); - req.send(); -} - - -/* now we have circs and the types.. draw each one */ -var nonCatTbody; -var nonCatRow; -function myOPACDrawNonCatCircs2(r) { - nonCatTypes = r.getResultObject(); - nonCatTbody = $('non_cat_circs_tbody'); - if(!nonCatRow) nonCatRow = - nonCatTbody.removeChild($('non_cat_circs_row')); - removeChildren(nonCatTbody); - for( var i in nonCatCircIds ) { - var req = new Request(FETCH_NON_CAT_CIRC, G.user.session, nonCatCircIds[i]); - req.callback(myOPACDrawNonCatCirc); - req.send(); - } -} - - -/* draw a single circ */ -function myOPACDrawNonCatCirc(r) { - var circ = r.getResultObject(); - - - var type = grep(nonCatTypes, - function(i){ - return (i.id() == circ.item_type()); - } - )[0]; - - - var row = nonCatTbody.appendChild(nonCatRow.cloneNode(true)); - appendClear($n(row, 'circ_lib'), text(findOrgUnit(circ.circ_lib()).name())); - appendClear($n(row, 'item_type'), text(type.name())); - - appendClear( - $n(row, 'circ_time'), - text(dojo.date.locale.format( - dojo.date.stamp.fromISOString(circ.duedate()), - {format : 'short'} - )) - ); -} - - - - -function myopacSelectAllChecked() { - __myopacSelectChecked(true); -} - -function myopacSelectNoneChecked() { - __myopacSelectChecked(false); -} - -function __myopacSelectChecked(value) { - var rows = myopacGetCheckedOutRows(); - for( var i = 0; i < rows.length; i++ ) { - var row = rows[i]; - var box = $n(row, 'selectme'); - if( box && ! box.disabled ) - box.checked = value; - } -} - -function myopacGetCheckedOutRows() { - var rows = []; - var tbody = $('myopac_checked_tbody'); - var children = tbody.childNodes; - for( var i = 0; i < children.length; i++ ) { - var child = children[i]; - if( child.nodeName.match(/^tr$/i) ) - if( $n(child, 'selectme') ) - rows.push(child); - } - return rows; -} - -var __renew_circs = []; - -/* true if 1 renewal succeeded */ -var __success_count = 0; - -/* renews all selected circulations */ -function myOPACRenewSelected() { - 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]; - - __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 */ -function moRenewCirc(copy_id, user_id, circ) { - - _debug('renewing circ ' + circ.id() + ' with copy ' + copy_id); - var req = new Request(RENEW_CIRC, G.user.session, - { patron : user_id, - copyid : copy_id, - opac_renewal : 1 - } - ); - - req.request.alertEvent = false; - req.callback(myHandleRenewResponse); - req.request.circ = circ; - req.send(); -} - - - -/* handles the circ renew results */ -function myHandleRenewResponse(r) { - var res = r.getResultObject(); - var circ = r.circ; - - /* remove this circ from the list of circs to renew */ - __renew_circs = grep(__renew_circs, function(i) { return (i.id() != circ.id()); }); - - _debug("handling renew result for " + circ.id()); - - if(checkILSEvent(res) || checkILSEvent(res[0])) - alertIdText('myopac_renew_fail', __circ_titles[circ.id()]); - else __success_count++; - - if(__renew_circs) return; /* more to come */ - - __renew_circs = []; - - if( __success_count > 0 ) - alertIdText('myopac_renew_success', __success_count); - - hideMe($('my_renewing')); - checkedDrawn = false; - myOPACShowChecked(); -} - -/** ---- batch hold processing ------------ */ - - -/* myopac_holds_checkbx */ -function myopacSelectAllHolds() { - var rows = getTableRows($("myopac_holds_tbody")); - for(var i = 0; i < rows.length; i++) { - cb = $n(rows[i], 'myopac_holds_selected_chkbx'); - if(cb) cb.checked = true; - } -} - -function myopacSelectNoneHolds() { - var rows = getTableRows($("myopac_holds_tbody")); - for(var i = 0; i < rows.length; i++) { - cb = $n(rows[i], 'myopac_holds_selected_chkbx'); - if(cb) cb.checked = false; - } -} - -function myopacSelectedHoldsRows() { - var r = []; - var rows = getTableRows($("myopac_holds_tbody")); - for(var i = 0; i < rows.length; i++) { - cb = $n(rows[i], 'myopac_holds_selected_chkbx'); - if(cb && cb.checked) - r.push(rows[i]); - } - return r; -} - -var myopacProcessedHolds = 0; -var myopacHoldsToProcess = 0; -function myopacDoHoldAction() { - - var selectedRows = myopacSelectedHoldsRows(); - action = getSelectorVal($('myopac_holds_actions')); - $('myopac_holds_actions_none').selected = true; - if(selectedRows.length == 0) return; - - myopacProcessedHolds = 0; - - if(!confirmId('myopac.holds.'+action+'.confirm')) return; - myopacSelectNoneHolds(); /* clear the selection */ - - - /* first, let's collect the holds that actually need processing and - collect the full process count while we're at it */ - var holds = []; - for(var i = 0; i < selectedRows.length; i++) { - hold = holdCache[myopacHoldIDFromRow(selectedRows[i])]; - var qstats = holdStatusCache[hold.id()]; - switch(action) { - case 'cancel': - holds.push(hold); - break; - case 'thaw_date': - case 'thaw': - if(isTrue(hold.frozen())) - holds.push(hold); - break; - case 'freeze': - if(!isTrue(hold.frozen()) && qstats.status < 3) - holds.push(hold); - break; - } - } - myopacHoldsToProcess = holds; - if(myopacHoldsToProcess.length == 0) return; - - if(action == 'thaw_date' || action == 'freeze') - myopacDrawHoldThawDateForm(); - else - myopacProcessHolds(action); -} - - -function myopacProcessHolds(action, thawDate) { - - myopacShowHoldProcessing(); - /* now we process them */ - for(var i = 0; i < myopacHoldsToProcess.length; i++) { - - hold = myopacHoldsToProcess[i]; - - var req; - switch(action) { - - case 'cancel': - req = new Request(CANCEL_HOLD, G.user.session, hold.id(), /* Patron via OPAC */ 6); - break; - - case 'thaw': - hold.frozen('f'); - hold.thaw_date(null); - req = new Request(UPDATE_HOLD, G.user.session, hold); - break; - - case 'thaw_date': - case 'freeze': - hold.frozen('t'); - hold.thaw_date(thawDate); - req = new Request(UPDATE_HOLD, G.user.session, hold); - break; - //thawDate = prompt($('myopac.holds.freeze.select_thaw').innerHTML); - - } - - req.callback(myopacBatchHoldCallback); - req.send(); - req = null; - } -} - -function myopacDrawHoldThawDateForm() { - hideMe($('myopac_holds_main_table')); - unHideMe($('myopac_holds_thaw_date_form')); - $('myopac_holds_thaw_date_input').focus(); -} - -function myopacApplyThawDate() { - var dateString = dijit.byId('myopac_holds_thaw_date_input').getValue(); - if(dateString) { - dateString = dojo.date.stamp.toISOString(dateString); - if(dateString) { - dateString = holdsVerifyThawDate(dateString); - if(!dateString) return; - } else { - dateString = null; - } - } - myopacProcessHolds('freeze', dateString); -} - -function myopacHoldIDFromRow(row) { - return row.id.replace(/.*_(\d+)$/, '$1'); -} - -function myopacShowHoldProcessing() { - unHideMe($('myopac_holds_processing')); - hideMe($('myopac_holds_main_table')); -} - -function myopacHideHoldProcessing() { - hideMe($('myopac_holds_processing')); - unHideMe($('myopac_holds_main_table')); - hideMe($('myopac_holds_thaw_date_form')); -} - -function myopacBatchHoldCallback(r) { - if(r) /* force load any exceptions */ - r.getResultObject(); - if(++myopacProcessedHolds >= myopacHoldsToProcess.length) { - myopacHideHoldProcessing(); - holdCache = {}; - holdStatusCache = {}; - myopacForceHoldsRedraw = true; - myOPACShowHolds(); - } -} - diff --git a/Open-ILS/web/opac/skin/default/js/password_reset.js b/Open-ILS/web/opac/skin/default/js/password_reset.js deleted file mode 100644 index 83db2721d9..0000000000 --- a/Open-ILS/web/opac/skin/default/js/password_reset.js +++ /dev/null @@ -1,114 +0,0 @@ -dojo.require('dojo.parser'); -dojo.require('dijit.Dialog'); -dojo.require('dijit.form.Button'); -dojo.require('dijit.form.TextBox'); - -dojo.requireLocalization("openils.opac", "opac"); -opac_strings = dojo.i18n.getLocalization("openils.opac", "opac"); - -dojo.addOnLoad(function() { - - // Create the password reset dialog - var pwResetFormDlg = createResetDialog(); - dojo.parser.parse(); - - // Connect the buttons to submit / cancel events that override - // the default actions associated with the buttons to do - // pleasing Ajax things - dojo.connect(dijit.byId("pwCancel"), "onClick", function(event) { - event.preventDefault(); - event.stopPropagation(); - pwResetFormDlg.hide(); - dijit.byId('pwUsername').attr('value', null); - dijit.byId('pwBarcode').attr('value', null); - }); - dojo.connect(dijit.byId("pwSubmit"), "onClick", function(event) { - event.preventDefault(); - event.stopPropagation(); - var xhrArgs = { - form: dojo.byId("requestReset"), - handleAs: "text", - load: function(data) { - pwResetFormDlg.hide(); - passwordSubmission(opac_strings.PWD_RESET_SUBMIT_SUCCESS); - dijit.byId('pwUsername').attr('value', null); - dijit.byId('pwBarcode').attr('value', null); - }, - error: function(error) { - pwResetFormDlg.hide(); - passwordSubmission(opac_strings.PWD_RESET_SUBMIT_ERROR); - } - } - var deferred = dojo.xhrPost(xhrArgs); - }); - dojo.place("", config.ids.login.tbody); - dojo.query("#pwResetLink").attr("innerHTML", opac_strings.PWD_RESET_FORGOT_PROMPT); - -}); - -function passwordSubmission( msg ) { - var responseDialog = new dijit.Dialog({ - title: opac_strings.PWD_RESET_RESPONSE_TITLE, - style: "width: 35em" - }); - responseDialog.startup(); - var requestStatusDiv = dojo.create("div", { style: "width: 30em" }); - var requestStatusMsg = dojo.create("div", { innerHTML: msg }, requestStatusDiv); - var okButton = new dijit.form.Button({ - id: "okButton", - type: "submit", - label: opac_strings.OK - }).placeAt(requestStatusDiv); - responseDialog.attr("content", requestStatusDiv); - responseDialog.show(); - dojo.connect(dijit.byId("okButton"), "onClick", responseDialog, "hide"); -} - -function createResetDialog() { - var pwResetFormDlg = new dijit.Dialog({ - id: "pwResetFormDlg", - title: opac_strings.PWD_RESET_FORM_TITLE, - style: "width: 35em" - }); - pwResetFormDlg.startup(); - - // Instantiate the form - var pwResetFormURL = "/opac/password/" + (OpenSRF.locale || "en-US") + "/"; - var pwResetFormDiv = dojo.create("form", { id: "requestReset", style: "width: 30em", method: "post", action: pwResetFormURL }); - dojo.create("p", { innerHTML: opac_strings.PWD_RESET_SUBMIT_PROMPT }, pwResetFormDiv); - var pwResetFormTable = dojo.create("table", null, pwResetFormDiv); - var pwResetFormTbody = dojo.create("tbody", null, pwResetFormTable); - var pwResetFormRow = dojo.create("tr", null, pwResetFormTbody); - var pwResetFormCell = dojo.create("td", null, pwResetFormRow); - var pwResetFormLabel = dojo.create("label", null, pwResetFormCell); - dojo.attr(pwResetFormCell, { innerHTML: opac_strings.BARCODE_PROMPT }); - pwResetFormCell = dojo.create("td", null, pwResetFormRow); - var barcodeText = new dijit.form.TextBox({ - id: "pwBarcode", - name: "barcode" - }).placeAt(pwResetFormCell); - pwResetFormRow = dojo.create("tr", {}, pwResetFormTbody); - pwResetFormCell = dojo.create("td", {}, pwResetFormRow); - dojo.attr(pwResetFormCell, { innerHTML: opac_strings.USERNAME_PROMPT }); - pwResetFormCell = dojo.create("td", {}, pwResetFormRow); - var usernameText = new dijit.form.TextBox({ - id: "pwUsername", - name: "username" - }).placeAt(pwResetFormCell); - dojo.create("br", null, pwResetFormDiv); - var submitButton = new dijit.form.Button({ - id: "pwSubmit", - type: "submit", - label: opac_strings.SUBMIT_BUTTON_LABEL - }).placeAt(pwResetFormDiv); - var cancelButton = new dijit.form.Button({ - id: "pwCancel", - type: "cancel", - label: opac_strings.CANCEL_BUTTON_LABEL - }).placeAt(pwResetFormDiv); - - // Set the content of the Dialog to the pwResetForm - pwResetFormDlg.attr("content", pwResetFormDiv); - return pwResetFormDlg; -} - diff --git a/Open-ILS/web/opac/skin/default/js/rdetail.js b/Open-ILS/web/opac/skin/default/js/rdetail.js deleted file mode 100644 index 596c0c23ce..0000000000 --- a/Open-ILS/web/opac/skin/default/js/rdetail.js +++ /dev/null @@ -1,1409 +0,0 @@ - -/* */ - -detachAllEvt('common', 'run'); -attachEvt("common", "run", rdetailDraw); -attachEvt("rdetail", "recordDrawn", rdetailBuildStatusColumns); -attachEvt("rdetail", "recordDrawn", rdetailBuildInfoRows); -attachEvt("rdetail", "recordDrawn", rdetailGetPageIds); - -/* Per-skin configuration settings */ -var rdetailLocalOnly = true; -var rdetailShowLocal = true; -var rdetailShowCopyLocation = true; -var rdetailGoogleBookPreview = true; -var rdetailDisplaySerialHoldings = true; -var rdetailEnableRefWorks = false; -var rdetailRefWorksHost = 'http://www.refworks.com'; - -/* vars vars vars */ -var record = null; -var cp_statuses = null; -var recordsCache = []; - -var copyRowParent = null; -var copyRow = null; -var statusRow = null; -var numStatuses = null; -var defaultCN; -var callnumberCache = {}; -var globalCNCache = {}; -var localTOC; -var cachedRecords; -var _statusPositions = {}; -var opac_strings; - -var nextContainerIndex; - -var nextRecord; -var prevRecord; - -var rdetailPrev = null; -var rdetailNext = null; -var rdetailStart = null; -var rdetailEnd = null; -var rdetailBackToResults = null; - -var mfhdDetails = []; -var orgHiding = false; - -if(location.href.match(/&place_hold=1/) || location.href.match(/&show_login=1/)) { - // prevent load flicker between canvases - hideMe(dojo.byId('canvas_main')); -} - -dojo.require("dijit.Dialog"); -dojo.require("dijit.form.TextBox"); - -/* 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"); -} - -function rdetailReload() { - var args = {}; - args[PARAM_LOCATION] = getNewSearchLocation(); - args[PARAM_DEPTH] = depthSelGetDepth(); - goTo(buildOPACLink(args)); -} - -/* looks to see if we have a next and/or previous record in the - record cache, if so, set up the nav links */ -function rdetailSetPaging(ids) { - - cachedRecords = {}; - cachedRecords.ids = ids; - - for( var i = 0; i < cachedRecords.ids.length; i++ ) { - var rec = cachedRecords.ids[i]; - if( rec == getRid() ) { - if( i > 0 ) prevRecord = cachedRecords.ids[i-1]; - if( i < cachedRecords.ids.length - 1 ) - nextRecord = cachedRecords.ids[i+1]; - break; - } - } - var cgi = new CGI(); // add the offset if we're not on the first page of results - var offset = parseInt(cgi.param('o')); - if (offset) - i = i + offset; - - $('np_offset').appendChild(text(i + 1)); - $('np_count').appendChild(text(getHitCount())); - - if(prevRecord) { - unHideMe($('np_table')); - unHideMe($('np_prev')); - unHideMe($('np_start')); - rdetailPrev = function() { _rdetailNav(prevRecord); }; - rdetailStart = function() { _rdetailNav(cachedRecords.ids[0]); }; - } - - if(nextRecord) { - unHideMe($('np_table')); - unHideMe($('np_next')); - unHideMe($('np_end')); - rdetailNext = function() { _rdetailNav(nextRecord); }; - rdetailEnd = function() { _rdetailNav(cachedRecords.ids[cachedRecords.ids.length-1]); }; - } - rdetailBackToResults = function() { location.href = prevRResults(); }; - - runEvt('rdetail', 'nextPrevDrawn', i, cachedRecords.ids.length); -} - - -function _rdetailNav(id, offset) { - var args = {}; - args[PARAM_RID] = id; - goTo(buildOPACLink(args)); -} - -function rdetailHandlePlaceHold() { - function reload() { - location.href = location.href.replace(/&place_hold=1/, ''); - } - attachEvt("common", "holdUpdated", reload); - attachEvt("common", "holdUpdateCanceled", reload); - attachEvt("common", "loginCanceled", reload); - holdsDrawEditor({record:getRid(), type: 'T'}); -} - -function rdetailDraw() { - - if(new CGI().param('place_hold')) { - rdetailHandlePlaceHold(); - return; - } - - detachAllEvt('common','depthChanged'); - detachAllEvt('common','locationUpdated'); - attachEvt('common','depthChanged', rdetailReload); - attachEvt('common','locationUpdated', rdetailReload); - attachEvt('common','holdUpdated', rdetailReload); - attachEvt('common','holdUpdateCanceled', rdetailReload); - - copyRowParent = G.ui.rdetail.cp_info_row.parentNode; - copyRow = copyRowParent.removeChild(G.ui.rdetail.cp_info_row); - statusRow = G.ui.rdetail.cp_status.parentNode; - statusRow.id = '__rdsrow'; - - G.ui.rdetail.cp_info_local.onclick = rdetailShowLocalCopies; - G.ui.rdetail.cp_info_all.onclick = rdetailShowAllCopies; - - if(getLocation() == globalOrgTree.id()) - hideMe(G.ui.rdetail.cp_info_all); - - if(getRid()) { - - var req = new Request(FETCH_RMODS, getRid()); - req.callback(_rdetailDraw); - req.send(); - - } else { // No record ID was specified - - // If we have an ISBN in the URL, let's try to find that record - // This allows direct linking by ISBN. - // Note, this uses the first record it finds - if(getRtype() == RTYPE_ISBN) { - var req = new Request(FETCH_ADV_ISBN_RIDS, getAdvTerm() ); - req.callback( - function(r) { - var blob = r.getResultObject(); - if(blob && blob.count > 0) - RID = blob.ids[0]; - var req2 = new Request(FETCH_RMODS, getRid()); - req2.callback(_rdetailDraw); - req2.send(); - } - ); - req.send(); - } - } - - - if (rdetailDisplaySerialHoldings && ( - isXUL() || !fetchOrgSettingDefault( - getLocation(), "opac.fully_compressed_serial_holdings") - ) - ) { - var req = new Request(FETCH_MFHD_SUMMARY, getRid()); - req.callback(_holdingsDraw); - req.send(); - if (isXUL()) { - var here = findOrgUnit(getLocation()); - dojo.place("
", "rdetail_details_table", "after"); - var mfhd_add = new dijit.Menu({style:"float: right;"}); - new dijit.MenuItem({onClick:function(){ - var bibReq = new Request(FETCH_BRE, [getRid()]); - bibReq.send(true); - var bib = bibReq.result()[0]; - var sourceReq = new Request(FETCH_BIB_SOURCE, G.user.session, bib.source()); - sourceReq.send(true); - var source = sourceReq.result(); - if (source && source.can_have_copies() == 'f') { - alert(dojo.string.substitute(opac_strings.SOURCE_CANNOT_HAVE_COPIES, [source.source()])); - } else { - var req = new Request(CREATE_MFHD_RECORD, G.user.session, 1, here.id(), getRid()); - var res = req.send(); - alert(dojo.string.substitute(opac_strings.CREATED_MFHD_RECORD, [here.name()])); - } - }, label:opac_strings.CREATE_MFHD}).placeAt(mfhd_add); - mfhd_add.placeAt(mfhd_ad_menu); - } - } - - detachAllEvt("result", "idsReceived"); - G.evt.result.hitCountReceived = []; - G.evt.result.recordReceived = []; - G.evt.result.copyCountsReceived = []; - G.evt.result.allRecordsReceived = []; - - if(isXUL()) - unHideMe($('rdetail_show_orders')); -} - -function rdetailGetPageIds() { - attachEvt("result", "idsReceived", rdetailSetPaging ); - resultFetchAllRecords = true; - rresultCollectIds(true); -} - - -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 rdetailViewMarc(r,id) { - hideMe($('rdetail_extras_loading')); - $('rdetail_view_marc_box').innerHTML = r.getResultObject(); - - var div = elem('div', { "class" : 'hide_me' }); - var span = div.appendChild( elem('abbr') ); - - buildunAPISpan( span, 'biblio-record_entry', record.doc_id() ); - - $('rdetail_view_marc_box').insertBefore(span, $('rdetail_view_marc_box').firstChild); -} - -function rdetailForeignItems(r,id) { - hideMe($('rdetail_extras_loading')); - var tbody = $('rdetail_foreign_items_tbody'); - - var robj = r.getResultObject(); /* mvr list with foreign_copy_maps fleshed */ - - for (var i = 0; i < robj.length; i++) { - var args = {}; - args.page = RDETAIL; - args[PARAM_OFFSET] = 0; - args[PARAM_RID] = robj[i].doc_id(); - var row = elem('tr'); tbody.appendChild(row); - var td1 = elem('td'); row.appendChild(td1); - var title = elem( - 'a', - { - 'href' : buildOPACLink(args), - 'class' : 'classic_link' - }, - robj[i].title() - ); - td1.appendChild(title); - var td2 = elem('td',{},robj[i].author()); row.appendChild(td2); - var td3 = elem('td'); row.appendChild(td3); - var details = elem( - 'a', - { - 'href' : 'javascript:void(0)', - 'class' : 'classic_link' - }, - 'Copy Details' - ); - details.onclick = function(idx,context_row){ - return function() { - cpdBuild( - tbody, - context_row, - robj[idx], - null, - 1, - 0, - 1, - dojo.map( - robj[idx].foreign_copy_maps(), - function(x){ return x.target_copy(); } - ), - dojo.map( - robj[idx].foreign_copy_maps(), - function(x){ return x.peer_type().name(); } - ) - ); - }; - }(i,row); - td3.appendChild(details); - } -} - - - -function rdetailShowLocalCopies() { - rdetailShowLocal = true; - rdetailBuildInfoRows(); - hideMe(G.ui.rdetail.cp_info_local); - unHideMe(G.ui.rdetail.cp_info_all); - hideMe(G.ui.rdetail.cp_info_none); -} - -function rdetailShowAllCopies() { - - rdetailShowLocal = false; - rdetailBuildInfoRows(); - hideMe(G.ui.rdetail.cp_info_all); - unHideMe(G.ui.rdetail.cp_info_local); - hideMe(G.ui.rdetail.cp_info_none); -} - -function OpenMarcEditWindow(pcrud, rec) { - /* - To run in Firefox directly, must set signed.applets.codebase_principal_support - to true in about:config - */ - win = window.open('/xul/server/cat/marcedit.xul','','chrome'); // XXX version? - dojo.require('openils.PermaCrud'); - - win.xulG = { - "record": {"marc": rec.marc(), "rtype": "sre"}, - "save": { - "label": opac_strings.SAVE_MFHD_LABEL, - "func": function(xmlString) { - rec.marc(xmlString); - rec.edit_date('now'); - rec.ischanged(true); - pcrud.update(rec); - } - }, - 'lock_tab' : typeof xulG != 'undefined' ? (typeof xulG['lock_tab'] != 'undefined' ? xulG.lock_tab : undefined) : undefined, - 'unlock_tab' : typeof xulG != 'undefined' ? (typeof xulG['unlock_tab'] != 'undefined' ? xulG.unlock_tab : undefined) : undefined - }; -} - -function loadMarcEditor(recId) { - var pcrud = new openils.PermaCrud({"authtoken": G.user.session}); - var rec = pcrud.retrieve("sre", recId); - if (rec) { - OpenMarcEditWindow(pcrud, rec); - } -} - -/* - * This function could be written much more intelligently - * Limited brain power means that I'm brute-forcing it for now - */ -function _holdingsDraw(h) { - holdings = h.getResultObject(); - - if (holdings) { - // Only draw holdings within our OU scope - var here = findOrgUnit(getLocation()); - var entryNum = 0; - var depth = getDepth(); - dojo.forEach(holdings, function (item) { - if (orgIsMine(here, findOrgUnit(item.owning_lib()), depth)) { - _holdingsDrawMFHD(item, entryNum); - entryNum++; - } - }); - } - - // Populate (or unpopulate) XUL menus - if (isXUL()) { - runEvt('rdetail','MFHDDrawn'); - } -} - -function _holdingsDrawMFHD(holdings, entryNum) { - var hb = holdings.basic_holdings(); - var hba = holdings.basic_holdings_add(); - var hs = holdings.supplement_holdings(); - var hsa = holdings.supplement_holdings_add(); - var hi = holdings.index_holdings(); - var hia = holdings.index_holdings_add(); - var ho = holdings.online(); - var hm = holdings.missing(); - var hinc = holdings.incomplete(); - var hloc = holdings.location() || 'MFHD'; - - if ( hb.length == 0 && hba.length == 0 && hs.length == 0 && - hsa.length == 0 && hi.length == 0 && hia.length == 0 && - ho.length == 0 && hm.length == 0 && hinc.length == 0 - ) { - - if (isXUL()) { - /* - * If we have a record, but nothing to show for it, then the - * record is likely empty or corrupt. This gives cataloguers a - * chance to add holdings or correct the record - */ - hb = ['PLACEHOLDER']; - } else { - return null; - } - } - - // Show entryNum + 1 in staff client for better menu correlation - // Maybe this should be holdings.sre_id() instead? (which could get long after time) - var entryNumString = ''; - if (isXUL()) { - var entryNumInc = entryNum + 1; - entryNumString = ' [Entry #'+entryNumInc+'] '; - } - - var refNode; - if (entryNum > 0) { - refNode = 'rdetail_holdings_table_' + (entryNum - 1); - } else { - refNode = 'rdetail_details_table'; - } - - dojo.place("
" + - dojo.string.substitute(opac_strings.HOLDINGS_TABLE_CAPTION, [hloc]) + entryNumString + - "
", refNode, "after" - ); - if (hb.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.BASIC_HOLDINGS, hb); } - if (hba.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.BASIC_HOLDINGS_ADD, hba); } - if (hs.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.SUPPLEMENT_HOLDINGS, hs); } - if (hsa.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.SUPPLEMENT_HOLDINGS_ADD, hsa); } - if (hi.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.INDEX_HOLDINGS, hi); } - if (hia.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.INDEX_HOLDINGS_ADD, hia); } - if (ho.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.ONLINE_VOLUMES, ho); } - if (hm.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.MISSING_VOLUMES, hm); } - if (hinc.length > 0) { _holdingsDrawMFHDEntry(entryNum, opac_strings.INCOMPLETE_VOLUMES, hinc); } - - if (isXUL() && holdings.sre_id() != -1) { // -1 indicates in-DB only holdings, so no button or menu entries for MFHD - mfhdDetails.push({ 'id' : holdings.sre_id(), 'label' : hloc, 'entryNum' : entryNum, 'owning_lib' : holdings.owning_lib() }); - dojo.require('openils.Event'); - dojo.require('openils.PermaCrud'); - var mfhd_edit = new dijit.Menu({}); - new dijit.MenuItem({onClick: function(){loadMarcEditor(holdings.sre_id())}, label:opac_strings.EDIT_MFHD_RECORD}).placeAt(mfhd_edit, "first"); - new dijit.MenuItem({onClick:function(){ - // Avoid accidental deletion of MFHD records - if (!confirm(opac_strings.DELETE_MFHD_CONFIRM)) { - return; - } - var pcrud = new openils.PermaCrud({"authtoken": G.user.session}); - var mfhd_rec = pcrud.retrieve("sre", holdings.sre_id()); - if (mfhd_rec) { - pcrud.eliminate(mfhd_rec); - alert(dojo.string.substitute(opac_strings.DELETED_MFHD_RECORD, [holdings.sre_id()])); - } - }, label:opac_strings.DELETE_MFHD}).placeAt(mfhd_edit, "last"); - // new dijit.MenuItem({onClick:function(){alert("Edit properties " + holdings.sre_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(); - } -} - -function _holdingsDrawMFHDEntry(entryNum, entryName, entry) { - var flatEntry = entry.toString().replace(/,/g, ', '); - dojo.place(" " + entryName + "" + flatEntry + "", "rdetail_holdings_tbody_" + entryNum, "last"); -} - -function _rdetailDraw(r) { - record = r.getResultObject(); - - runEvt('rdetail', 'recordRetrieved', record.doc_id()); - - 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()))); - G.ui.rdetail.edition.appendChild(text(record.edition())); - G.ui.rdetail.pubdate.appendChild(text(record.pubdate())); - G.ui.rdetail.publisher.appendChild(text(record.publisher())); - $('rdetail_physical_desc').appendChild(text(record.physical_description())); - r = record.types_of_resource(); - if(r) { - G.ui.rdetail.tor.appendChild(text(r[0])); - setResourcePic( G.ui.rdetail.tor_pic, r[0]); - } - G.ui.rdetail.abstr.appendChild(text(record.synopsis())); - - try{ - if(record.isbn()) { - if(ENABLE_ADDED_CONTENT_ATTRIB_LINKS) { - unHideMe($('rdetail.jacket_attrib_div')); - var href = $('rdetail.jacket_attrib_link').getAttribute('href') +cleanISBN(record.isbn()); - $('rdetail.jacket_attrib_link').setAttribute('href', href); - } - rdetailCheckForGBPreview(); - - } else { - if(!record.doc_id()) { - hideMe($("rdetail.jacket_attrib_div")); - hideMe($("rdetail_img_link")); - } - } - } catch(E) {} - - - // see if the record has any external links - var links = record.online_loc(); - for( var i = 0; links && links.length > 0 && i < links.length; i = i + 3 ) { - var href = links[i]; - // avoid matching "HTTP: The Complete Reference" - if( href.match(/https?:\/|ftps?:\/|mailto:/i) ) { - unHideMe($('rdetail_online_row')); - // MODS can contain a display label (used for the text of the link) - // as well as a note about the URL; many legacy systems conflate the - // two and generate MARC records that expect the note to be used as - // the text of the link, with no display label; here's the canonical - // format: - // - // 856 40 $uhttp://localhost$yDisplay label$zPublic note - // - // Note that the MARC21slim2MODS XSL concatenates $3 and $y together - // (as $y was defined later in MARC21's life as the display label) - var displayLabel = '' + links[i+1]; - var note = '' + links[i+2]; - if(!displayLabel || displayLabel.match(/https?:\/|ftps?:\/|mailto:/i)) { - if(!note || note.match(/https?:\/|ftps?:\/|mailto:/i)) { - displayLabel = href; - } else { - displayLabel = note; - } - } - $('rdetail_online').appendChild(elem('a', {href:href,'class':'classic_link'}, displayLabel)); - if (note && note != displayLabel) { - $('rdetail_online').appendChild(elem('span', {'class':'url_note'}, ' - ' + note)); - } - $('rdetail_online').appendChild(elem('br')); - } - } - - // Fill in our unAPI ID, if anyone cares - var abbrs = document.getElementsByTagName('abbr'); - var span; - for (var i = 0; i < abbrs.length; i++) { - if (abbrs[i].getAttribute('name') == 'unapi') { - span = abbrs[i]; - break; - } - } - buildunAPISpan( span, 'biblio-record_entry', record.doc_id() ); - - $('rdetail_place_hold').onclick = function() { - var src = location.href; - - if(forceLoginSSL && src.match(/^http:/)) { - - src = src.replace(/^http:/, 'https:'); - - if(!src.match(/&place_hold=1/)) { - src += '&place_hold=1'; - } - - location.href = src; - - } else { - holdsDrawEditor({record:record.doc_id(), type:'T'}); - } - } - - - var RW = $('rdetail_exp_refworks'); - if (RW && rdetailEnableRefWorks) { - - var here = (findOrgUnit(getLocation())).name(); - var org_name = here.replace(" ", "+"); - var cgi = new CGI(); - - RW.setAttribute( - 'href', - rdetailRefWorksHost + '/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/supercat/marctxt/record/' - + record.doc_id() - ); - - RW.setAttribute('target', 'RefWorksMain'); - - unHideMe($('rdetail_exp_refworks_span')); - } - - $('rdetail_img_link').setAttribute('href', buildJacketSrc(record.doc_id()), 'large')); - G.ui.rdetail.image.setAttribute("src", buildJacketSrc(record.doc_id())); - runEvt("rdetail", "recordDrawn"); - recordsCache.push(record); - - rdetailSetExtrasSelector(); - - var breq = new Request(FETCH_BRE, [getRid()]); - breq.callback( rdetailCheckDeleted ); - breq.send(); - - //resultBuildCaches( [ record ] ); - //resultDrawSubjects(); - //resultDrawSeries(); - - // grab added content - - // Proxied through Evergreen AddedContent module - acCollectData(cleanISBN(record.isbn()), rdetailhandleAC); - - var currentISBN = cleanISBN(record.isbn()); - - // Not proxied, cross-site javascript - - // ChiliFresh - if (chilifresh && chilifresh != '(none)' && currentISBN) { - $('chilifreshReviewLink').setAttribute('id','isbn_'+currentISBN); - $('chilifreshReviewResult').setAttribute('id','chili_review_'+currentISBN); - unHideMe($('rdetail_reviews_link')); - unHideMe($('rdetail_chilifresh_reviews')); - try { - chili_init(); - } catch(E) { - console.log(E + '\n'); - hideMe($('rdetail_reviews_link')); - hideMe($('rdetail_chilifresh_reviews')); - } - } - - // Novelist - if (novelist && currentISBN) { - unHideMe($('rdetail_novelist_link')); - } - - // Multi-Home / Foreign Items / Peer Bibs - var req = new Request( TEST_PEER_BIBS, record.doc_id() ); - req.callback(function(r){ - var test = r.getResultObject(); - if (test == "1") { - unHideMe($('rdetail_foreign_items_link')); - } - }); - req.send(); -} - - - -function rdetailCheckDeleted(r) { - var br = r.getResultObject()[0]; - if( isTrue(br.deleted()) ) { - hideMe($('rdetail_place_hold')); - $('rdetail_more_actions_selector').disabled = true; - unHideMe($('rdetail_deleted_exp')); - } -} - -function rdetailSetExtrasSelector() { - if(!grabUser()) return; - unHideMe($('rdetail_more_actions')); - - var req = new Request( - FETCH_CONTAINERS, G.user.session, G.user.id(), 'biblio', 'bookbag' ); - req.callback(rdetailAddBookbags); - req.send(); -} - -function rdetailAddBookbags(r) { - - var containers = r.getResultObject(); - var selector = $('rdetail_more_actions_selector'); - var found = false; - var index = 3; - doSelectorActions(selector); - - for( var i = 0; i < containers.length; i++ ) { - found = true; - var container = containers[i]; - insertSelectorVal( selector, index++, container.name(), - "container_" + container.id(), rdetailAddToBookbag, 1 ); - } - - nextContainerIndex = index; -} - -var _actions = {}; -/** - * Adds a new bookbag and exits. - * - * exitstatus should be 0 if the status is to be read. - */ -function finishBookbag(exitstatus) { - var name = bbName.attr('value'); - - newBBDialog.hide(); - bbName.attr("value", ""); // Do this after hide so the text doesn't disappear. - - if(exitstatus != 0) return; // If the user canceled, just drop off here. - - var id; - - if( id = containerCreate( name ) ) { - alert( $('rdetail_bb_success').innerHTML ); - var selector = $('rdetail_more_actions_selector'); - insertSelectorVal( selector, nextContainerIndex++, name, - "container_" + id, rdetailAddToBookbag, 1 ); - setSelector( selector, 'start' ); - } -} - -/** - * Creates a new Bookbag for the user. - */ -function rdetailNewBookbag() { - newBBDialog.show(); // Show the bookbag dialog. - dojo.connect(dijit.byId('newBBDialog'), 'onKeyPress', function(evt) { - if (evt.keyCode == dojo.keys.ENTER) { - finishBookbag(0); - } - }); -} - -function rdetailAddToBookbag() { - var selector = $('rdetail_more_actions_selector'); - var id = selector.options[selector.selectedIndex].value; - setSelector( selector, 'start' ); - - if( containerCreateItem( id.substring(10), record.doc_id() )) { - alert($('rdetail_bb_item_success').innerHTML); - } -} - - -var rdetailMarcFetched = false; -var rdetailForeignItemsFetched = false; -function rdetailShowExtra(type, args) { - - hideMe($('rdetail_copy_info_div')); - hideMe($('rdetail_summary_div')); - hideMe($('rdetail_reviews_div')); - hideMe($('rdetail_toc_div')); - hideMe($('rdetail_anotes_div')); - hideMe($('rdetail_excerpt_div')); - hideMe($('rdetail_preview_div')); - hideMe($('rdetail_marc_div')); - hideMe($('cn_browse')); - hideMe($('rdetail_cn_browse_div')); - hideMe($('rdetail_novelist_div')); - hideMe($('rdetail_foreign_items_div')); - hideMe($('rdetail_notes_div')); - - removeCSSClass($('rdetail_copy_info_link'), 'rdetail_extras_selected'); - removeCSSClass($('rdetail_viewcn_link'), 'rdetail_extras_selected'); - removeCSSClass($('rdetail_summary_link'), 'rdetail_extras_selected'); - removeCSSClass($('rdetail_reviews_link'), 'rdetail_extras_selected'); - removeCSSClass($('rdetail_toc_link'), 'rdetail_extras_selected'); - removeCSSClass($('rdetail_excerpt_link'), 'rdetail_extras_selected'); - removeCSSClass($('rdetail_preview_link'), 'rdetail_extras_selected'); - removeCSSClass($('rdetail_anotes_link'), 'rdetail_extras_selected'); - removeCSSClass($('rdetail_annotation_link'), 'rdetail_extras_selected'); - removeCSSClass($('rdetail_viewmarc_link'), 'rdetail_extras_selected'); - removeCSSClass($('rdetail_novelist_link'), 'rdetail_extras_selected'); - removeCSSClass($('rdetail_foreign_items_link'), 'rdetail_extras_selected'); - - switch(type) { - - case "copyinfo": - unHideMe($('rdetail_copy_info_div')); - addCSSClass($('rdetail_copy_info_link'), 'rdetail_extras_selected'); - break; - - case "summary": - addCSSClass($('rdetail_summary_link'), 'rdetail_extras_selected'); - unHideMe($('rdetail_summary_div')); - break; - - case "reviews": - addCSSClass($('rdetail_reviews_link'), 'rdetail_extras_selected'); - unHideMe($('rdetail_reviews_div')); - break; - - case "excerpt": - addCSSClass($('rdetail_excerpt_link'), 'rdetail_extras_selected'); - unHideMe($('rdetail_excerpt_div')); - break; - - case "preview": - addCSSClass($('rdetail_preview_link'), 'rdetail_extras_selected'); - unHideMe($('rdetail_preview_div')); - rdetailDisplayGBPreview(); - break; - - case "anotes": - addCSSClass($('rdetail_anotes_link'), 'rdetail_extras_selected'); - unHideMe($('rdetail_anotes_div')); - break; - - case "toc": - addCSSClass($('rdetail_toc_link'), 'rdetail_extras_selected'); - unHideMe($('rdetail_toc_div')); - break; - - case "marc": - addCSSClass($('rdetail_viewmarc_link'), 'rdetail_extras_selected'); - unHideMe($('rdetail_marc_div')); - if(rdetailMarcFetched) return; - unHideMe($('rdetail_extras_loading')); - rdetailMarcFetched = true; - var req = new Request( FETCH_MARC_HTML, record.doc_id() ); - req.callback(rdetailViewMarc); - req.send(); - break; - - case "novelist": - addCSSClass($('rdetail_novelist_link'), 'rdetail_extras_selected'); - unHideMe($('rdetail_novelist_div')); - break; - - case "foreign_items": - addCSSClass($('rdetail_foreign_items_link'), 'rdetail_extras_selected'); - unHideMe($('rdetail_foreign_items_div')); - if(rdetailForeignItemsFetched) return; - unHideMe($('rdetail_extras_loading')); - rdetailForeignItemsFetched = true; - var req = new Request( FETCH_PEER_BIBS, record.doc_id() ); - req.callback(rdetailForeignItems); - req.send(); - break; - - case 'cn': - addCSSClass($('rdetail_viewcn_link'), 'rdetail_extras_selected'); - unHideMe($('rdetail_cn_browse_div')); - rdetailShowCNBrowse(defaultCN[1], getLocation(), null, true); - break; - - } -} - -function rdetailVolumeDetails(args) { - var row = $(args.rowid); - var tbody = row.parentNode; - cpdBuild( tbody, row, record, [args.cn_prefix, args.cn, args.cn_suffix], args.org, args.depth, args.copy_location ); - return; -} - -function rdetailBuildCNList() { - - var select = $('cn_browse_selector'); - var index = 0; - var arr = []; - for( var cn_json in callnumberCache ) arr.push( cn_json ); - arr.sort(); - - if( arr.length == 0 ) { - hideMe($('rdetail_cn_browse_select_div')); - return; - } - - for( var i = 0; i < arr.length; i++ ) { - var cn_json = arr[i]; - var cn = JSON2js(cn_json); - var whole_cn_text = (cn[0] ? cn[0] + ' ' : '') + cn[1] + (cn[2] ? ' ' + cn[2] : ''); - var opt = new Option(whole_cn_text,cn_json); - select.options[index++] = opt; - } - select.onchange = rdetailGatherCN; -} - -function rdetailGatherCN() { - var cn = getSelectorVal($('cn_browse_selector')); - rdetailShowCNBrowse( JSON2js(cn), getLocation(), getDepth(), true ); - setSelector( $('cn_browse_selector'), cn ); -} - - -function rdetailShowCNBrowse( cn, loc, depth, fromOnclick ) { - - if(!cn) { - unHideMe($('cn_browse_none')); - hideMe($('rdetail_cn_browse_select_div')); - return; - } - - unHideMe($('rdetail_cn_browse_select_div')); - rdetailBuildCNList(); - setSelector( $('cn_browse_selector'), js2JSON(cn) ); - hideMe($('rdetail_copy_info_div')); - hideMe($('rdetail_reviews_div')); - hideMe($('rdetail_summary_div')); - hideMe($('rdetail_toc_div')); - hideMe($('rdetail_marc_div')); - unHideMe($('rdetail_cn_browse_div')); - unHideMe($('cn_browse')); - if( !rdetailLocalOnly && ! fromOnclick ) depth = findOrgDepth(globalOrgTree); - cnBrowseGo(cn, loc, depth); -} - -function rdetailhandleAC(data) { - - if( data.summary.html ) { - $('rdetail_summary_div').innerHTML = data.summary.html; - unHideMe($('rdetail_summary_link')); - } - - if( data.reviews.html ) { - $('rdetail_review_container').innerHTML = data.reviews.html; - unHideMe($('rdetail_reviews_link')); - } - - if( data.toc.html ) { - $('rdetail_toc_div').innerHTML = data.toc.html; - unHideMe($('rdetail_toc_link')); - } - - if( data.excerpt.html ) { - $('rdetail_excerpt_div').innerHTML = data.excerpt.html; - unHideMe($('rdetail_excerpt_link')); - } - - if( data.anotes.html ) { - $('rdetail_anotes_div').innerHTML = data.anotes.html; - unHideMe($('rdetail_anotes_link')); - } -} - -function rdetailShowReviews(r) { - hideMe($('rdetail_extras_loading')); - var res = r.getResultObject(); - var par = $('rdetail_reviews_div'); - var template = par.removeChild($('rdetail_review_template')); - if( res && res.length > 0 ) { - unHideMe($('rdetail_reviews_link')); - for( var i = 0; i < res.length; i++ ) { - var rev = res[i]; - if( rev.text && rev.info ) { - var node = template.cloneNode(true); - $n(node, 'review_header').appendChild(text(rev.info)); - $n(node, 'review_text').appendChild(text(rev.text)); - par.appendChild(node); - } - } - } -} - - -function rdetailShowTOC(r) { - hideMe($('rdetail_extras_loading')); - var resp = r.getResultObject(); - if(resp) { - unHideMe($('rdetail_toc_link')); - $('rdetail_toc_div').innerHTML = resp; - } -} - -function rdetailBuildInfoRows() { - var req; - var method = FETCH_COPY_COUNTS_SUMMARY; - 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()); - req.callback(_rdetailBuildInfoRows); - req.send(); -} - -function _rdetailRows(node) { - - if( rdetailShowLocal && getLocation() != globalOrgTree.id() ) { - var loc = findOrgUnit(getLocation()); - if( node ) { - if( !orgIsMine(node, loc) && !orgIsMine(loc,node) ) return; - } else { - var kids = globalOrgTree.children(); - if (kids) { - for( var i = 0; i < kids.length; i++ ) { - var org = findOrgUnit(kids[i]); - if( orgIsMine(org, loc) ) { - node = org; - break; - } - } - } - } - } - - if(!node && findOrgType(globalOrgTree.ou_type()).can_have_vols()) - node = globalOrgTree; - - - /* don't show hidden orgs */ - - if(node) { - - if(!isXUL() && !isTrue(node.opac_visible())) return; - - if (orgHiding) { - if (isTrue( findOrgType(node.ou_type()).can_have_vols() )) { - if ( ! orgIsMine( orgHiding.org, node, orgHiding.depth ) ) { - return; - } - } - } - - var row = copyRow.cloneNode(true); - row.id = "cp_info_" + node.id(); - - var libtd = findNodeByName( row, config.names.rdetail.lib_cell ); - var cntd = findNodeByName( row, config.names.rdetail.cn_cell ); - var cpctd = findNodeByName( row, config.names.rdetail.cp_count_cell ); - var actions = $n(row, 'rdetail_actions_cell'); - - 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()) { - - row.removeChild(cntd); - row.removeChild(cpctd); - row.removeChild(actions); - row.setAttribute('novols', '1'); - - libtd.setAttribute("colspan", numStatuses + 3 ); - libtd.colSpan = numStatuses + 3; - addCSSClass(row, 'copy_info_region_row'); - } - - copyRowParent.appendChild(row); - - } else { node = globalOrgTree; } - - var kids = node.children(); - if (kids) { - for( var c = 0; c < kids.length; c++ ) - _rdetailRows(kids[c]); - } -} - -function rdetailCNPrint(orgid, cn) { - var div = cpdBuildPrintWindow( record, orgid); - var template = div.removeChild($n(div, 'cnrow')); - var rowNode = $("cp_info_" + orgid); - cpdStylePopupWindow(div); - openWindow(div.innerHTML); -} - -var localCNFound = false; -var ctr = 0; -function _rdetailBuildInfoRows(r) { - - if (rdetailShowCopyLocation) - unHideMe( $n( $('rdetail_copy_info_table'), 'rdetail_copylocation_header' ) ); - - removeChildren(copyRowParent); - - orgHiding = checkOrgHiding(); - - _rdetailRows(); - - var summary = r.getResultObject(); - if(!summary) return; - - var found = false; - for( var i = 0; i < summary.length; i++ ) { - - var arr = summary[i]; - globalCNCache[js2JSON([arr[1],arr[2],arr[3]])] = 1; // prefix, label, suffix. FIXME - Am I used anywhere? - 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[4]; - var cl = ''; - if (rdetailShowCopyLocation) { - cl = arr[4]; - statuses = arr[5]; - } - - - rdetailApplyStatuses(rowNode, cpc_temp, statuses); - - var isLocal = false; - if( orgIsMine( findOrgUnit(getLocation()), thisOrg ) ) { - found = true; - isLocal = true; - if(!localCNFound) { - localCNFound = true; - defaultCN = [arr[1],arr[2],arr[3]]; // prefix, label, suffix - } - } - - //if(isLocal) unHideMe(rowNode); - unHideMe(rowNode); - - rdetailSetPath( thisOrg, isLocal ); - rdetailBuildBrowseInfo( rowNode, [arr[1],arr[2],arr[3]], isLocal, thisOrg, cl ); - - if( i == summary.length - 1 && !defaultCN) defaultCN = [arr[1],arr[2],arr[3]]; // prefix, label, suffix - } - - if(!found) unHideMe(G.ui.rdetail.cp_info_none); -} - -function rdetailBuildBrowseInfo(row, cn, local, orgNode, cl) { - - var whole_cn_json = js2JSON(cn); - var whole_cn_text = (cn[0] ? cn[0] + ' ' : '') + cn[1] + (cn[2] ? ' ' + cn[2] : ''); - - if(local) { - var cache = callnumberCache[whole_cn_json]; - if( cache ) cache.count++; - else callnumberCache[whole_cn_json] = { count : 1 }; - } - - var depth = getDepth(); - if( !local ) depth = findOrgDepth(globalOrgTree); - - $n(row, 'rdetail_callnumber_cell').appendChild(text(whole_cn_text)); - - if (rdetailShowCopyLocation) { - var cl_cell = $n(row, 'rdetail_copylocation_cell'); - cl_cell.appendChild(text(cl)); - unHideMe(cl_cell); - } - - _debug('setting action clicks for cn ' + whole_cn_text); - - var dHref = 'javascript:rdetailVolumeDetails('+ - '{copy_location : "'+cl.replace(/\"/g, '\\"')+'", rowid : "'+row.id+'", cn_prefix :"'+cn[0].replace(/\"/g, '\\"')+'",cn :"'+cn[1].replace(/\"/g, '\\"')+'",cn_suffix :"'+cn[2].replace(/\"/g, '\\"')+'", depth:"'+depth+'", org:"'+orgNode.id()+'", local: '+local+'});'; - - var bHref = 'javascript:rdetailShowCNBrowse("'+cn[1].replace(/\"/g, '\\"') + '", '+orgNode.id()+', "'+depth+'");'; - - unHideMe( $n(row, 'details') ) - $n(row, 'details').setAttribute('href', dHref); - unHideMe( $n(row, 'browse') ) - $n(row, 'browse').setAttribute('href', bHref); - - if(isXUL()) { - unHideMe($n(row, 'hold_div')); - $n(row, 'hold').onclick = function() { - var req = new Request(FETCH_VOLUME_BY_INFO, cn, record.doc_id(), orgNode.id()); - req.callback( - function(r) { - var vol = r.getResultObject(); - holdsDrawEditor({type: 'V', volumeObject : vol}); - } - ); - req.send(); - }; - } -} - -// sets the path to org as 'active' and displays the path if it's local -function rdetailSetPath(org, local) { - if( findOrgDepth(org) == 0 ) return; - var row = $("cp_info_" + org.id()); - row.setAttribute("hasinfo", "1"); - unHideMe(row); - rdetailSetPath(findOrgUnit(org.parent_ou()), local); -} - -//Append all the statuses for a given summary to the -//copy summary table -function rdetailApplyStatuses( row, template, statuses ) { - for( var j in _statusPositions ) { - var stat = _statusPositions[j]; - var val = statuses[stat.id()]; - var nn = template.cloneNode(true); - if(val) nn.appendChild(text(val)); - else nn.appendChild(text(0)); - row.appendChild(nn); - } -} - -//Add one td (creating a new column) to the copy summary -//table for each opac_visible copy status -function rdetailBuildStatusColumns() { - - rdetailGrabCopyStatuses(); - var parent = statusRow; - var template = parent.removeChild(G.ui.rdetail.cp_status); - - var i = 0; - for( i = 0; i < cp_statuses.length; i++ ) { - - var c = cp_statuses[i]; - if( c && isTrue(c.opac_visible()) ) { - var name = c.name(); - _statusPositions[i] = c; - var node = template.cloneNode(true); - var data = findNodeByName( node, config.names.rdetail.cp_status); - - data.appendChild(text(name)); - parent.appendChild(node); - } - } - - numStatuses = 0; - for(x in _statusPositions) numStatuses++; -} - -function rdetailGrabCopyStatuses() { - if(cp_statuses) return cp_statuses; - var req = new Request(FETCH_COPY_STATUSES); - req.send(true); - cp_statuses = req.result(); - cp_statuses = cp_statuses.sort(_rdetailSortStatuses); -} - -function _rdetailSortStatuses(a, b) { - return parseInt(a.id()) - parseInt(b.id()); -} - -/** - * Check for a Google Book preview after the main page loads - */ -function rdetailCheckForGBPreview() { - if (!rdetailGoogleBookPreview) return; - dojo.addOnLoad(function() { - searchForGBPreview( cleanISBN(record.isbn()) ); - }); -} - -/** - * - * @param {DOM object} isbn The form element containing the input parameters "isbns" - */ -function searchForGBPreview( isbn ) { - dojo.require("dojo.io.script"); - dojo.io.script.get({"url": "https://www.google.com/jsapi"}); - dojo.io.script.get({"url": "https://www.googleapis.com/books/v1/volumes", "content": { "q": "isbn:" + isbn, "callback": "GBPreviewCallback"}}); -} - -/** - * This function is the call-back function for the JSON scripts which - * executes a Google book search response. - * - * XXX I18N of text needed - * - * @param {JSON} GBPBookInfo is the JSON object pulled from the Google books service. - */ -function GBPreviewCallback(GBPBookInfo) { - if (GBPBookInfo.totalItems < 1) return; - - var accessInfo = GBPBookInfo.items[0].accessInfo; - if ( !accessInfo ) { - return; - } - - if ( accessInfo.embeddable ) { - // Add a button below the book cover image to load the preview. - GBPBadge = document.createElement( 'img' ); - GBPBadge.src = 'https://www.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' ) ); - } -} - -/** - * This is called when the user clicks on the 'Preview' link. We assume - * a preview is available from Google if this link was made visible. - * - * XXX I18N of Google Book Preview language attribute needed - */ -function rdetailDisplayGBPreview() { - unHideMe($('rdetail_extras_loading')); - GBPreviewPane = $('rdetail_preview_div'); - if ( GBPreviewPane.getAttribute('loaded') == null || - GBPreviewPane.getAttribute('loaded') == "false" ) { - google.load("books", "0", {"callback" : rdetailGBPViewerLoadCallback, "language": "en"} ); - GBPreviewPane.setAttribute('loaded', 'true'); - } -} - -function rdetailGBPViewerLoadCallback() { - hideMe($('rdetail_extras_loading')); - var GBPViewer = new google.books.DefaultViewer(document.getElementById('rdetail_preview_div')); - GBPViewer.load('ISBN:' + cleanISBN(record.isbn()) ); - -} - -function rdetailDrawExpandedHoldings(anchor, bibid, type) { - var offsets = {"basic": 0, "index": 0, "supplement": 0}; - var limit = 10; /* XXX give user control over this? */ - var target_id = "holding_type_" + type; - var target = dojo.byId(target_id); - - anchor.innerHTML = "[-]"; - anchor.oldonclick = anchor.onclick; - anchor.onclick = function() { - anchor.onclick = anchor.oldonclick; - anchor.innerHTML = "[+]"; - dojo.empty(target); - }; - - function _load() { - dojo.empty(target); - fieldmapper.standardRequest( - ["open-ils.serial", - "open-ils.serial.received_siss.retrieve.by_bib.atomic"], { - "params": [bibid, {"offset": offsets[type], "limit": limit}], - "async": true, - "oncomplete": function(r) { - try { - if (msg = r.recv().content()) { /* sic, assignment */ - if (!msg.length) return; - offsets[type] += msg.length; - var table = dojo.create("table", null, target); - dojo.forEach( - msg, function(o) { - var tr = dojo.create("tr", null, table); - dojo.create( - "td", { - "innerHTML": o.issuance.label(), - "style": {"paddingLeft": "3em"} - }, tr - ); - - if (!o.has_units) return; - /* can't place holds if no units */ - var td = dojo.create("td", null, tr); - dojo.create( - "a", { - "href":"javascript:void(0);", - "style": {"marginLeft": "1.5em"}, - "onclick": function() { - holdsDrawEditor({ - "type": "I", - "issuance": o.issuance.id() - }); - }, - "innerHTML": "[" + - opac_strings.PLACE_HOLD + "]" - }, td - ); - } - ); - if (msg.length == limit) { - dojo.create("br", null, target); - dojo.create( - "a", { - "href": "javascript:void(0);", - "innerHTML": - "[" + opac_strings.MORE + "]", - "onclick": _load - }, target - ); - } - } - } catch (E) { - void(0); - } - } - } - ); - } - _load(); -} diff --git a/Open-ILS/web/opac/skin/default/js/result_common.js b/Open-ILS/web/opac/skin/default/js/result_common.js deleted file mode 100644 index c3d4764085..0000000000 --- a/Open-ILS/web/opac/skin/default/js/result_common.js +++ /dev/null @@ -1,995 +0,0 @@ -dojo.require('openils.BibTemplate'); -dojo.requireLocalization("openils.opac", "opac"); -var opac_strings = dojo.i18n.getLocalization("openils.opac", "opac"); - -var recordsHandled = 0; -var recordsCache = []; -var lowHitCount = 4; -var isbnList = new Array(); -var googleBooksLink = true; -var OpenLibraryLinks = true; - -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( function(){unHideMe($('result_info_2'))}, fetchOpenLibraryLinks, fetchGoogleBooksLink, fetchChiliFreshReviews); - - 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(getFacet()) args.facets = getFacet(); - - 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 my_ou = findOrgUnit(args.org_unit); - if (my_ou && my_ou.shortname()) { - var atomfeed = "/opac/extras/opensearch/1.1/" + my_ou.shortname() + "/atom-full/" + getStype() + '?searchTerms=' + getTerm(); - if (args.facets) { atomfeed += ' ' + args.facets; } - if (sort) { atomfeed += '&searchSort=' + sort; } - if (sortdir) { atomfeed += '&searchSortDir=' + sortdir; } - dojo.create('link', {"rel":"alternate", "href":atomfeed, "type":"application/atom+xml"}, dojo.query('head')[0]); - } - - 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(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); - if(getDepth() == 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++; - } -} - -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.found && 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 = 0; i < data.items.length; i++) { - var item = data.items[i]; - - var gbspan; - for (var j = 0; j < item.volumeInfo.industryIdentifiers.length; j++) { - // XXX: As of 11-17-2011, some items do not return their own ISBN - // as an identifier, so this code fails. For example: - // https://www.googleapis.com/books/v1/volumes?q=isbn:0743243560&callback=unhideGoogleBooksLink - // It seems the only way around this would be doing a separate - // search for each result rather than one search for the whole - // page. Informal testing seems to indicate that these books - // are generally Google-unfriendly (no previews, not embeddable), - // so we will live without them for now. - var ident = item.volumeInfo.industryIdentifiers[j].identifier; - gbspan = $n(document.documentElement, 'googleBooksLink-' + ident); - if (gbspan) break; - } - if (!gbspan) continue; - - var gba = $n(gbspan, "googleBooks-link"); - - gba.setAttribute( - 'href', - item.volumeInfo.infoLink - // XXX: we might consider constructing the above link ourselves, - // as the link provided populates the search box with our original - // multi-item search. Something like: - // 'http://books.google.com/books?id=' + item.id - // Postive: cleaner display - // Negative: more fragile (link format subject to change; likely - // enough to matter?) - ); - 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) { - - fieldmapper.IDL.load(['mvr']); - 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 (currentISBN) { - isbnList.push(currentISBN); - if (OpenLibraryLinks) { - var olspan = $n(r, 'openLibraryLink'); - olspan.setAttribute('name', olspan.getAttribute('name') + - '-' + currentISBN - ); - } - - if (googleBooksLink) { - var gbspan = $n(r, "googleBooksLink"); - // Google never has dashes in the ISBN, records sometimes do; - // remove them to match results list - // XXX: consider making part of cleanISBN(), or we can work around - // this if we move to one request per record - gbspan.setAttribute( - 'name', - gbspan.getAttribute('name') + '-' + currentISBN.toString().replace(/-/g,"") - ); - - } - } - - if (currentISBN && chilifresh && chilifresh != '(none)') { - var cfrow = $n(r, "chilifreshReview"); - if (cfrow) { - removeCSSClass( cfrow, 'hide_me' ); - } - var cflink = $n(r, "chilifreshReviewLink"); - if (cflink) { - cflink.setAttribute( - 'id', - 'isbn_' + currentISBN - ); - } - var cfdiv = $n(r, "chilifreshReviewResult"); - if (cfdiv) { - cfdiv.setAttribute( - 'id', - 'chili_review_' + 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); - if (rec.doc_id()) { - pic.setAttribute("src", buildJacketSrc(rec.doc_id())); - } else { - pic.setAttribute("src", "/opac/images/blank.png"); - } - - var title_link = $n(r, config.names.result.item_title); - var author_link = $n(r, config.names.result.item_author); - - var onlyrec; - if( is_mr ) { - 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)); - } - - unHideMe($n(r,'place_hold_span')); - $n(r,'place_hold_link').onclick = function() { resultDrawHoldsWindow(rec.doc_id(), 'M'); } - - - } else { - onlyrec = rec.doc_id(); - 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)); - - unHideMe($n(r,'place_hold_span')); - $n(r,'place_hold_link').onclick = function() { resultDrawHoldsWindow(rec.doc_id(), 'T'); } - } - - 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 ); - - var bt_params = { - sync : false, - root : r, - subObjectLimit : 10, - org_unit : findOrgUnit(getLocation()).shortname(), - depth : getDepth() - }; - - if (!is_mr) { - bt_params = dojo.mixin( bt_params, { record : onlyrec } ); - } else { - bt_params = dojo.mixin( bt_params, { metarecord : onlyrec } ); - } - - if (findOrgType(findOrgUnit(getLocation()).ou_type()).can_have_vols()) - unHideMe($n(r,'local_callnumber_list')); - - new openils.BibTemplate( bt_params ).render(); - - unHideMe(r); - - runEvt("result", "recordDrawn", rec.doc_id(), title_link); - - /* - if(resultPageIsDone()) { - runEvt('result', 'allRecordsReceived', recordsCache); - } - */ -} - -function resultDrawHoldsWindow(hold_target, hold_type) { - var src = location.href; - - if(forceLoginSSL && src.match(/^http:/)) { - - src = src.replace(/^http:/, 'https:'); - - if(src.match(/&hold_target=/)) { - src.replace(/&hold_target=(\d+)/, hold_target); - - } else { - src += '&hold_target=' + hold_target; - } - - location.href = src; - - } else { - holdsDrawEditor({record:hold_target, type:hold_type}); - } -} - - - -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 fetchOpenLibraryLinks() { - if (isbnList.length > 0 && OpenLibraryLinks) { - /* OpenLibrary supports a number of different identifiers: - * ISBN: isbn: - * LCCN: lccn: - * OpenLibrary ID: olid: - * - * We'll just fire off ISBNs for now. - */ - - var isbns = ''; - dojo.forEach(isbnList, function(isbn) { - isbns += 'isbn:' + isbn + '|'; - }); - isbns = isbns.replace(/.$/, ''); - } - - dojo.xhrGet({ - "url": "/opac/extras/ac/proxy/json/" + isbns, - "handleAs": "json", - "load": function (data) { renderOpenLibraryLinks(data); } - }); - -} - -function renderOpenLibraryLinks(response) { - var ol_ebooks = {}; - - /* Iterate over each identifier we requested */ - for (var item_id in response) { - - var isbn = item_id.replace(/^isbn:/, ''); - /* Iterate over each matching item; OpenLibrary supplies access info: - * * match: "exact" or "similar" - * * status: "full access" or "lendable" - */ - dojo.forEach(response[item_id].items, function(item) { - ol_ebooks[isbn] = {}; - if (item.match == 'exact') { - if (item.status == 'full access') { - ol_ebooks[isbn]['exact_full'] = item.itemURL; - } else { - ol_ebooks[isbn]['exact_lendable'] = item.itemURL; - } - } else { - if (item.status == 'full access') { - ol_ebooks[isbn]['similar_full'] = item.itemURL; - } else { - ol_ebooks[isbn]['similar_lendable'] = item.itemURL; - } - } - }); - - /* If there are no books to read or borrow, move on */ - if (!ol_ebooks[isbn]) { - continue; - } - - /* Now populate the results page with our ebook goodness*/ - /* Go for the jugular - exact match with full access */ - if (ol_ebooks[isbn]['exact_full']) { - createOpenLibraryLink( - isbn, ol_ebooks[isbn]['exact_full'], 'Read online' - ); - continue; - } - - /* Fall back to slightly less palatable options */ - else if (ol_ebooks[isbn]['exact_lendable']) { - createOpenLibraryLink( - isbn, ol_ebooks[isbn]['exact_lendable'], 'Borrow online' - ); - } - - if (ol_ebooks[isbn]['similar_full']) { - createOpenLibraryLink( - isbn, ol_ebooks[isbn]['similar_full'], 'Read similar online' - ); - } else if (ol_ebooks[isbn]['similar_lendable']) { - createOpenLibraryLink( - isbn, ol_ebooks[isbn]['similar_lendable'], 'Borrow similar online' - ); - } - } -} - -function createOpenLibraryLink(isbn, url, text) { - var ol_span = $n(document.documentElement, 'openLibraryLink-' + isbn); - - var ol_a_span = dojo.create('a', { - "href": url, - "class": "classic_link" - }, ol_span - ); - dojo.create('img', { - "src": "/opac/images/openlibrary.gif" - }, ol_a_span - ); - dojo.create('br', null, ol_a_span); - ol_a_span.appendChild(dojo.doc.createTextNode(text)); - dojo.removeClass(ol_span, 'hide_me'); -} - -function fetchGoogleBooksLink () { - if (isbnList.length > 0 && googleBooksLink) { - var scriptElement = document.createElement("script"); - scriptElement.setAttribute("id", "jsonScript"); - scriptElement.setAttribute("src", - "https://www.googleapis.com/books/v1/volumes?q=" + - encodeURIComponent('isbn:' + isbnList.join(' | isbn:')) + "&callback=unhideGoogleBooksLink"); - scriptElement.setAttribute("type", "text/javascript"); - // make the request to Google Book Search - document.documentElement.firstChild.appendChild(scriptElement); - } -} - -function fetchChiliFreshReviews() { - if (chilifresh && chilifresh != '(none)') { - try { chili_init(); } catch(E) { console.log(E + '\n'); } - } -} - -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__' */ -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 start_here = 0; - var orgHiding = checkOrgHiding(); - if (orgHiding) { - for (var i = 0; i < nodes.length; i++) { - if (orgHiding.depth == findOrgDepth(nodes[i])) { - start_here = i; - } - } - } - - var node = nodes[start_here]; - 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[start_here+1]) { - - var x = start_here+1; - var d = findOrgDepth(nodes[start_here+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; - while(copy_counts[i] != null) { - var cell = $("copy_count_cell_" + i +"_" + pagePosition); - if (cell) { - var cts = copy_counts[i]; - cell.appendChild(text(cts.available + " / " + cts.count)); - - if(isXUL()) { - /* here we style opac-invisible records for xul */ - - if( cts.depth == 0 ) { - 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 ) - addCSSClass( row, 'no_copies' ); - else - addCSSClass( row, 'shadowed' ); - } - } - } - } - i++; - } -} - - diff --git a/Open-ILS/web/opac/skin/default/js/rresult.js b/Open-ILS/web/opac/skin/default/js/rresult.js deleted file mode 100644 index 6dccc497ec..0000000000 --- a/Open-ILS/web/opac/skin/default/js/rresult.js +++ /dev/null @@ -1,359 +0,0 @@ -var records = new Array(); -var table; -var rowtemplate; -var rresultLimit = 200; -var resultFacetKey; - -var rresultIsPaged = false; - -function rresultUnload() { removeChildren(table); table = null;} - -attachEvt("common", "unload", rresultUnload); -attachEvt("common", "run", rresultDoSearch); -attachEvt("result", "idsReceived", rresultCollectRecords); -attachEvt("result", "recordDrawn", rresultLaunchDrawn); - -hideMe($('copyright_block')); - -function rresultDoSearch() { - - swapCanvas($('loading_alt')); - - table = G.ui.result.main_table; - hideMe(G.ui.result.row_template); - if( table && table.parentNode ) { - while( table.parentNode.rows.length <= (getDisplayCount() +1) ) - hideMe(table.appendChild(G.ui.result.row_template.cloneNode(true))); - } - rresultCollectIds(); -} - -function rresultCollectIds() { - var ids; - - - var holdTarget = new CGI().param('hold_target'); - if(holdTarget != null) { - rresultHandlePlaceHold(holdTarget); - return; - } - - var rtype = getRtype(); - if (rtype && rtype.indexOf('|') > -1) - rtype = rtype.substring(0,rtype.indexOf('|')); - - switch(rtype) { - - case RTYPE_COOKIE: - ids = JSON2js(dojo.cookie(COOKIE_RIDS)); - _rresultHandleIds( ids, ids.length ); - break; - - case RTYPE_TITLE: - case RTYPE_AUTHOR: - case RTYPE_SUBJECT: - case RTYPE_SERIES: - case RTYPE_KEYWORD: - rresultDoRecordSearch(); - break; - - case RTYPE_MULTI: - rresultDoRecordMultiSearch(); - break; - - case RTYPE_LIST : - rresultHandleList(); - break; - - case RTYPE_MARC : - rresultCollectMARCIds(); - break; - - case RTYPE_ISBN : - rresultCollectISBNIds(); - break; - - case RTYPE_TCN : - rresultCollectTCNIds(); - break; - - case RTYPE_ISSN : - rresultCollectISSNIds(); - break; - - - case RTYPE_MRID : - case null : - case "" : - default: - var form = rresultGetForm(); - var args = { format : form, org : getLocation(), depth : rresultGetDepth() }; - - var lasso = getLasso(); - if (lasso) args.org = -lasso; - - var req = new Request(FETCH_RIDS, getMrid(), args); - req.callback( rresultHandleRIds ); - req.send(); - - if( rresultGetDepth() != findOrgDepth(globalOrgTree) ) { - var link = $('rresult_show_all_link'); - if(link) { - unHideMe($('rresult_show_all')); - link.appendChild( text( - findOrgType(globalOrgTree.ou_type()).opac_label())); - } - - } else { - if( rresultGetDepth() != getDepth() ) { /* inside a limited display */ - var link = $('rresult_show_here_link'); - if(link) { - link.appendChild( text( - findOrgType(findOrgUnit(getLocation()).ou_type()).opac_label())); - unHideMe($('rresult_show_here')); - } - } - } - } -} - -function rresultExpandSearch() { - var args = {}; - args[PARAM_RDEPTH] = findOrgDepth(globalOrgTree); - goTo(buildOPACLink(args)); -} - -function rresultContractSearch() { - var args = {}; - RDEPTH = null; - args[PARAM_OFFSET] = 0; - goTo(buildOPACLink(args)); -} - - -function rresultGetDepth() { - if( getRdepth() != null) return getRdepth(); - return getDepth(); -} - - -function rresultGetForm() { - var form; - - if(getTform()) /* did the user select a format from the icon list (temporary) */ - form = (getTform() == 'all') ? null : getTform(); - else /* did the use select a format from simple search dropdown */ - form = (getForm() == 'all') ? null : getForm(); - - if(!form) { /* did the user select a format from the advanced search */ - form = getItemType(); - var f = getItemForm(); - - if(form) { - form = form.replace(/,/,''); - if(f) form += '-' + f; - } else { - if(f) form = '-' + f; - } - } - - return form; -} - - -function rresultCollectMARCIds() { - - var args = {}; - args.searches = JSON2js(getSearches()); - args.limit = 200; - args.org_unit = globalOrgTree.id(); - args.depth = 0; - - rresultIsPaged = true; - var req = new Request(FETCH_ADV_MARC_MRIDS, args, getDisplayCount(), getOffset()); - req.callback(rresultHandleRIds); - req.request.noretry = true; - req.send(); -} - - -function rresultCollectISBNIds() { - var req = new Request(FETCH_ADV_ISBN_RIDS, getAdvTerm() ); - req.callback( - function(r) { - var blob = r.getResultObject(); - _rresultHandleIds(blob.ids, blob.count); - } - ); - req.send(); -} - -function rresultCollectTCNIds() { - var req = new Request(FETCH_ADV_TCN_RIDS, getAdvTerm() ); - req.callback( - function(r) { - var blob = r.getResultObject(); - _rresultHandleIds(blob.ids, blob.count); - } - ); - req.send(); -} - -function rresultCollectISSNIds() { - var req = new Request(FETCH_ADV_ISSN_RIDS, getAdvTerm() ); - req.callback( - function(r) { - var blob = r.getResultObject(); - _rresultHandleIds(blob.ids, blob.count); - } - ); - req.send(); -} - -function rresultHandleList() { - var ids = new CGI().param(PARAM_RLIST); - var count; - if(!dojo.isArray(ids)) { - count = 1; - ids = [ids]; - } else { - count = ids.length; - } - if(ids) _rresultHandleIds(ids, count); -} - -var rresultTries = 0; -function rresultHandleRIds(r) { - var res = r.getResultObject(); - - if(!res) res = {count:0,ids:[]}; - - if( res.count == 0 && rresultTries == 0 && ! r.noretry) { - - rresultTries++; - var form = rresultGetForm(); - var args = { format : form, org : getLocation(), depth : findOrgDepth(globalOrgTree) }; - - var lasso = getLasso(); - if (lasso) args.org = -lasso; - - var req = new Request(FETCH_RIDS, getMrid(), args ); - req.callback( rresultHandleRIds ); - req.send(); - unHideMe($('no_formats')); - hideMe($('rresult_show_all')); - - } else { - - _rresultHandleIds(res.ids, res.count); - } -} - -function _rresultHandleIds(ids, count) { - //var json = js2JSON({ids:ids,count:count}); - /* - dojo.cookie(COOKIE_SRIDS, json, {'expires':1}); - */ - - HITCOUNT = parseInt(count); - runEvt('result', 'hitCountReceived'); - runEvt('result', 'idsReceived', ids, getOffset()); -} - -/* -function rresultCollectRecords(ids) { - runEvt("result", "preCollectRecords"); - var x = 0; - for( var i = getOffset(); i!= getDisplayCount() + getOffset(); i++ ) { - if(ids[i] == null) break; - var req = new Request(FETCH_RMODS, parseInt(ids[i])); - req.callback(rresultHandleMods); - req.request.userdata = x++; - req.send(); - } -} -*/ - - -function rresultCollectRecords(ids, base) { - runEvt("result", "preCollectRecords"); - var x = 0; - - // don't perform rdetail redirect if user was on rdetail and cliecked Back - if(findCurrentPage() == RRESULT && isXUL()) { - if(ids.length == 1 && !xulG.fromBack) { - var args = {}; - args.page = RDETAIL; - args[PARAM_OFFSET] = 0; - args[PARAM_RID] = ids[0]; - location.href = buildOPACLink(args); - } - } - - if (!base) base = 0; - if( rresultIsPaged ) base = 0; - - for( var i = base; i!= getDisplayCount() + base; i++ ) { - if(ids[i] == null) break; - var req = new Request(FETCH_RMODS, parseInt(ids[i])); - req.callback(rresultHandleMods); - req.request.userdata = x++; - req.send(); - } -} - - -var recsReceivedCalled = false; -function rresultHandleMods(r) { - var rec = r.getResultObject(); - runEvt('result', 'recordReceived', rec, r.userdata, false); - resultCollectCopyCounts(rec, r.userdata, FETCH_R_COPY_COUNTS); - if(resultPageIsDone() && !recsReceivedCalled) { - recsReceivedCalled = true; - runEvt('result', 'allRecordsReceived', recordsCache); - unHideMe($('copyright_block')); - } -} - -function rresultLaunchDrawn(id, node) { - runEvt("rresult", "recordDrawn", id, node); -} - - -function rresultDoRecordSearch() { - rresultIsPaged = true; - resultCollectSearchIds(true, SEARCH_RS_QUERY, rresultFilterSearchResults ); -} - -function rresultDoRecordMultiSearch() { - rresultIsPaged = true; - resultCollectSearchIds(false, SEARCH_RS_QUERY, rresultFilterSearchResults ); -} - - -function rresultFilterSearchResults(r) { - var result = r.getResultObject(); - var ids = []; - if( result.count > 0 ) { - for( var i = 0; i != result.ids.length; i++ ) - ids.push(result.ids[i][0]); - } - - resultFacetKey = result.facet_key; - resultCompiledSearch = result.compiled_search; - dojo.require('dojo.cookie'); - dojo.cookie(COOKIE_SEARCH, js2JSON(result.compiled_search)); - _rresultHandleIds( ids, result.count ); -} - - -function rresultHandlePlaceHold(target) { - function reload() { - location.href = location.href.replace(/&hold_target=\d+/, ''); - } - attachEvt("common", "holdUpdated", reload); - attachEvt("common", "holdUpdateCanceled", reload); - attachEvt("common", "loginCanceled", reload); - holdsDrawEditor({record:target, type: 'T'}); -} - diff --git a/Open-ILS/web/opac/skin/default/js/search_bar.js b/Open-ILS/web/opac/skin/default/js/search_bar.js deleted file mode 100644 index be0239eba1..0000000000 --- a/Open-ILS/web/opac/skin/default/js/search_bar.js +++ /dev/null @@ -1,128 +0,0 @@ -var searchBarExpanded = false; -/* our search selector boxes */ -var _ts, _fs; - - -var isFrontPage = false; - - -G.evt.common.init.push(searchBarInit); - -/* if set by the org selector, this will be the location used the - next time the search is submitted */ -var newSearchLocation; -var newSearchDepth = null; - -function autoSuggestInit() { - var org_unit_getter = null; - var global_flag = fieldmapper.standardRequest( - ["open-ils.fielder", "open-ils.fielder.cgf.atomic"], [{ - "query": {"name": "opac.use_autosuggest"}, - "fields": ["enabled", "value"] - }] - ).shift(); /* XXX do we want to use caching here? a cookie? */ - - if (!global_flag || !isTrue(global_flag.enabled)) - return; - else if (global_flag.value && global_flag.value.match(/opac_visible/)) - org_unit_getter = depthSelGetNewLoc; - - dojo.require("openils.widget.AutoSuggest"); - - /* See comments in openils.AutoSuggestStore, esp. near the constructor, - * to find out what you can control with the store_args object. */ - var widg = new openils.widget.AutoSuggest( - { - "store_args": { - "org_unit_getter": org_unit_getter - }, - "type_selector": G.ui.searchbar.type_selector, - "submitter": searchBarSubmit, - "style": {"width": dojo.style("search_box", "width")}, - "value": ((getTerm() != null) ? getTerm() : "") - }, "search_box" - ); - - G.ui.searchbar.text = widg.textbox; - setTimeout(function() { widg.focus(); }, 1000);/* raise chance of success */ -} - -function searchBarInit() { - - _ts = G.ui.searchbar.type_selector; - _fs = G.ui.searchbar.form_selector; - - try{G.ui.searchbar.text.focus();}catch(e){} - G.ui.searchbar.text.onkeydown = - function(evt) {if(userPressedEnter(evt)) { searchBarSubmit(); } }; - _ts.onkeydown = - function(evt) {if(userPressedEnter(evt)) { searchBarSubmit(); } }; - _fs.onkeydown = - function(evt) {if(userPressedEnter(evt)) { searchBarSubmit(); } }; - - G.ui.searchbar.submit.onclick = searchBarSubmit; - - /* set up the selector objects, etc */ - G.ui.searchbar.text.value = (getTerm() != null) ? getTerm() : ""; - if (!isFrontPage) G.ui.searchbar.facets.value = (getFacet() != null) ? getFacet() : ""; - setSelector(_ts, getStype()); - setSelector(_fs, getItemType()); - - depthSelInit(); - - - if(!isFrontPage && (findCurrentPage() != MYOPAC)) { - attachEvt('common','depthChanged', searchBarSubmit); - } - - if( (limit = $('opac.result.limit2avail')) ) { - if(getAvail()) limit.checked = true; - if(getSort() && getSortDir()) - setSelector($('opac.result.sort'), getSort()+'.'+getSortDir()); - } - - autoSuggestInit(); -} - -function searchBarSubmit(isFilterSort) { - - var text = G.ui.searchbar.text.value; - var facet_text = isFrontPage ? '' : G.ui.searchbar.facets.value; - - if (!isFilterSort) { - clearSearchParams(); - } - - if(!text || text == "") return; - - var d = (newSearchDepth != null) ? newSearchDepth : depthSelGetDepth(); - if(isNaN(d)) d = 0; - - var args = {}; - - if(SHOW_MR_DEFAULT || findCurrentPage() == MRESULT) { - args.page = MRESULT; - } else { - args.page = RRESULT; - args[PARAM_RTYPE] = _ts.options[_ts.selectedIndex].value; - } - - args[PARAM_STYPE] = _ts.options[_ts.selectedIndex].value; - args[PARAM_TERM] = text; - args[PARAM_FACET] = facet_text; - args[PARAM_LOCATION] = depthSelGetNewLoc(); - args[PARAM_DEPTH] = d; - args[PARAM_FORM] = _fs.options[_fs.selectedIndex].value; - - if($('opac.result.limit2avail')) { - args[PARAM_AVAIL] = ($('opac.result.limit2avail').checked) ? 1 : ''; - if( (val = getSelectorVal($('opac.result.sort'))) ) { - args[PARAM_SORT] = val.split('.')[0] - args[PARAM_SORT_DIR] = val.split('.')[1] - } - } - - goTo(buildOPACLink(args)); -} - - diff --git a/Open-ILS/web/opac/skin/default/js/sidebar.js b/Open-ILS/web/opac/skin/default/js/sidebar.js deleted file mode 100644 index 02d18aca89..0000000000 --- a/Open-ILS/web/opac/skin/default/js/sidebar.js +++ /dev/null @@ -1,240 +0,0 @@ -/* set up the colors in the sidebar - Disables/Enables certain components based on various state data */ - -attachEvt("common", "init", initSideBar); -attachEvt("common", "init", setSidebarLinks); - -attachEvt("common", "unload", sidebarTreesFree ); - -function prevRResults() { - return buildOPACLink({ page : RRESULT }); -} - -function prevMResults() { - return buildOPACLink({ page : MRESULT }); -} - -function initSideBar() { - var page = findCurrentPage(); - - if( page == MRESULT ) - unHideMe($("sidebar_results_wrapper")); - - if( page == RRESULT ) { - unHideMe($("sidebar_results_wrapper")); - unHideMe(G.ui.sidebar[MRESULT]); - if( getRtype() == RTYPE_MRID ) - $("sidebar_title_group_results").setAttribute("href", prevMResults()); - else hideMe($("sidebar_title_group_results").parentNode); - } - - if( page == RDETAIL ) { - unHideMe($("sidebar_results_wrapper")); - - - unHideMe(G.ui.sidebar[MRESULT]); - if(getRtype()) - $("sidebar_title_results").setAttribute("href", prevRResults()); - unHideMe(G.ui.sidebar[RRESULT]); - - if( getRtype() == RTYPE_MRID ) - $("sidebar_title_group_results").setAttribute("href", prevMResults()); - else hideMe($("sidebar_title_group_results").parentNode); - } - - unHideMe(G.ui.sidebar[page]); - addCSSClass(G.ui.sidebar[page], "sidebar_item_active"); - - /* if we're logged in, show it and replace the Login link with the Logout link */ - if(grabUser()) { - G.ui.sidebar.username_dest.appendChild(text(G.user.usrname())); - unHideMe(G.ui.sidebar.logoutbox); - unHideMe(G.ui.sidebar.logged_in_as); - hideMe(G.ui.sidebar.loginbox); - } - - if(G.ui.sidebar.login) G.ui.sidebar.login.onclick = initLogin; - if(G.ui.sidebar.logout) G.ui.sidebar.logout.onclick = doLogout; - - if(isXUL()) hideMe( G.ui.sidebar.logoutbox ); -} - -/* sets up the login ui components */ -var loginBoxVisible = false; - -function loginDance() { - - if(doLogin(true)) { - - if(!strongPassword( G.ui.login.password.value ) ) { - - dojo.require('dojo.cookie'); - dojo.cookie(COOKIE_SES, ""); - hideMe($('login_table')); - unHideMe($('change_pw_table')); - $('change_pw_current').focus(); - $('change_pw_button').onclick = changePassword; - setEnterFunc($('change_pw_2'), changePassword); - - } else { - loggedInOK(); - } - } -} - -function loggedInOK() { - if (!location.href.match(/&show_login=1/)) { - showCanvas(); - G.ui.sidebar.username_dest.appendChild(text(G.user.usrname())); - unHideMe(G.ui.sidebar.logoutbox); - unHideMe(G.ui.sidebar.logged_in_as); - hideMe(G.ui.sidebar.loginbox); - } - runEvt( 'common', 'loggedIn'); - - var org = G.user.prefs[PREF_DEF_LOCATION]; - if(!org) org = G.user.home_ou(); - - var depth = G.user.prefs[PREF_DEF_DEPTH]; - if(! ( depth && depth <= findOrgDepth(org)) ) - depth = findOrgDepth(org); - - runEvt( "common", "locationChanged", org, depth); - if (location.href.match(/&show_login=1/)) { - // this redirect should only happen if the runEvt above didn't already - // trigger one - goTo(location.href.replace(/&show_login=1/, '')); - } -} - - -function changePassword() { - - var pc = $('change_pw_current').value; - var p1 = $('change_pw_1').value; - var p2 = $('change_pw_2').value; - - if( p1 != p2 ) { - alert($('pw_no_match').innerHTML); - return; - } - - if(!strongPassword(p2, true) ) return; - - var req = new Request(UPDATE_PASSWORD, G.user.session, p2, pc ); - req.send(true); - if(req.result()) { - alert($('pw_update_successful').innerHTML); - loggedInOK(); - } -} - -var pwRegexSetting; -function strongPassword(pass, alrt) { - - /* first, let's see if there is a configured regex */ - if(!pwRegexSetting) { - var regex = fetchOrgSettingDefault(G.user.home_ou(), 'global.password_regex'); - if(regex) { - if(pass.match(new RegExp(regex))) { - return true; - } else { - if(alrt) - alert($('pw_not_strong').innerHTML); - return false; - } - } - } - - /* no regex configured, use the default */ - - var good = false; - - do { - - if(pass.length < 7) break; - if(!pass.match(/.*\d+.*/)) break; - if(!pass.match(/.*[A-Za-z]+.*/)) break; - good = true; - - } while(0); - - if(!good && alrt) alert($('pw_not_strong').innerHTML); - return good; -} - -function initLogin() { - var src = location.href; - if(forceLoginSSL && src.match(/^http:/)) { - src = src.replace(/^http:/, 'https:'); - if(!src.match(/&show_login=1/)) { - src += '&show_login=1'; - } - goTo(src); - return false; - } - - swapCanvas(G.ui.login.box); - try{G.ui.login.username.focus();} catch(e) {} - - G.ui.login.cancel.onclick = function(evt) { - G.ui.login.form.setAttribute('action', - 'javascript:showCanvas();runEvt("common", "loginCanceled");'); - }; - - if(findCurrentPage() == MYOPAC) { - G.ui.login.cancel.onclick = function(evt) { - G.ui.login.form.setAttribute('action','javascript:goHome();'); }; - } -} - -function setSidebarLinks() { - G.ui.sidebar.home_link.setAttribute("href", buildOPACLink({page:HOME})); - G.ui.sidebar.advanced_link.setAttribute("href", buildOPACLink({page:ADVANCED})); - G.ui.sidebar.myopac_link.setAttribute("href", buildOPACLink({page:MYOPAC}, false, true)); -} - -function sidebarTreesFree() { -/* - removeChildren($(subjectSidebarTree.rootid)); - removeChildren($(authorSidebarTree.rootid)); - removeChildren($(seriesSidebarTree.rootid)); - subjectSidebarTree = null; - authorSidebarTree = null; - seriesSidebarTree = null; -*/ -} - - - - -/* --------------------------------------------------------------------------------- */ -/* Code to support GALILEO links for PINES. Fails gracefully -/* --------------------------------------------------------------------------------- */ -attachEvt('common', 'init', buildEGGalLink); -function buildEGGalLink() { - - /* we're in a lib, nothing to do here */ - if( getOrigLocation() ) return; - if(!$('eg_gal_link')) return; - - //var link = 'http://demo.galib.uga.edu/express?pinesid='; - var link = 'http://www.galileo.usg.edu/express?pinesid='; - if(grabUser()) { - $('eg_gal_link').setAttribute('href', link + G.user.session); - return; - } - - $('eg_gal_link').setAttribute('href', 'javascript:void(0);'); - $('eg_gal_link').setAttribute('target', ''); - $('eg_gal_link').onclick = function() { - /* we're not logged in. go ahead and login */ - detachAllEvt('common','locationChanged'); - detachAllEvt('common','loggedIn'); - attachEvt('common','loggedIn', function() { goTo(link + G.user.session); }) - initLogin(); - }; -} -/* --------------------------------------------------------------------------------- */ - - diff --git a/Open-ILS/web/opac/skin/default/js/sidebar_extras.js b/Open-ILS/web/opac/skin/default/js/sidebar_extras.js deleted file mode 100644 index cb35d886d3..0000000000 --- a/Open-ILS/web/opac/skin/default/js/sidebar_extras.js +++ /dev/null @@ -1,243 +0,0 @@ - -/* captures extraneous info from each record */ - -var subjectCache = {}; -var authorCache = {}; -var seriesCache = {}; - -function resultBuildCaches(records) { - for( var r in records ) { - var rec = records[r]; - for( var s in rec.subject() ) - subjectCache[s] == null ? subjectCache[s] = 1 : subjectCache[s]++; - authorCache[rec.author()] = 1; - for( var s in rec.series() ) seriesCache[rec.series()[s]] = 1; - } -} - -function resultSortSubjects(a, b) { return -(a.count - b.count); } /* sort in reverse */ -function resultDrawSubjects() { - - var subjs = []; - for( var s in subjectCache ) - subjs.push( { sub : s, count : subjectCache[s] } ); - subjs.sort(resultSortSubjects); - - var ss = []; - for( var s in subjs ) ss.push(subjs[s].sub); - - resultDrawSidebarTrees( - STYPE_SUBJECT, - "subjectSidebarTree", ss, - $("subject_tree_sidebar"), - $("subject_sidebar_tree_div") ); -} - -function resultDrawAuthors() { - var auths = new Array(); - for( var s in authorCache ) auths.push(s); - - resultDrawSidebarTrees( - STYPE_AUTHOR, - "authorSidebarTree", auths.sort(), - $("author_tree_sidebar"), - $("author_sidebar_tree_div") ); -} - -function resultDrawSeries() { - var sers = new Array(); - for( var s in seriesCache ) sers.push(s); - resultDrawSidebarTrees( - STYPE_SERIES, - "seriesSidebarTree", sers.sort(), - $("series_tree_sidebar"), - $("series_sidebar_tree_div") ); -} - -var IESux = true; - -function resultDrawSidebarTrees( stype, treeName, items, wrapperNode, destNode ) { - eval("tree = " + treeName); - - var xrefCache = []; - var found = false; - var x = 0; - for( var i in items ) { - - if(isNull(items[i])) continue; - - /* again, IE is a turd */ - if(IE) { if(x++ > 5) break; } - else { if(x++ > 7) break; } - - found = true; - - var item = normalize(truncate(items[i], 65)); - var args = {}; - var href = resultQuickLink( items[i], stype ); - tree.addNode( stype + "_" + items[i], treeName + 'Root', item, href ); - -// if( !IE ) resultFireXRefReq(treeName, stype, items[i]); - - var a = {}; - a.type = stype; - a.term = item; - xrefCache.push(a); - } - - if(found) { - unHideMe(wrapperNode); -// if(IE) resultFireXRefSingle(treeName, xrefCache, stype); - /* XXX */ // disabled auth lookups for now - - if( DO_AUTHORITY_LOOKUPS ) { - resultFireXRefBatch(treeName, xrefCache, stype); - } - } -} - -/* XXX */ -function resultFireXRefBatch(treeName, xrefCache, stype) { - var query = []; - for( var i = 0; i != xrefCache.length; i++ ) { - var topic = xrefCache[i]; - query.push( [ topic.type, topic.term ] ); - } - var req = new Request(FETCH_CROSSREF_BATCH, query); - var tree; - eval('tree=' + treeName); - req.request._tree = tree; - req.request._stype = stype; - req.callback(resultRenderXRefTree); - req.send(); -} - -var xrefCacheIndex = {}; -xrefCacheIndex['subject'] = 0; -xrefCacheIndex['author'] = 0; -xrefCacheIndex['series'] = 0; - -function resultHandleXRefResponse(r) { - resultFireXRefSingle( r._treename, r._cache, r._stype ); - resultAppendCrossRef(r); -} - - -function resultFireXRefSingle( treeName, xrefCache, stype ) { - var i = xrefCacheIndex[stype]++; - if(xrefCache[i] == null) return; - var item = xrefCache[i].term; - var tree; - eval('tree=' + treeName); - var req = new Request(FETCH_CROSSREF, stype, item); - req.request._tree = tree; - req.request._item = item; - req.request._stype = stype; - req.request._cache = xrefCache; - req.request._treename = treeName; - req.callback(resultHandleXRefResponse); - req.send(); -} - -function resultFireXRefReq( treeName, stype, item ) { - var tree; - eval('tree=' + treeName); - var req = new Request(FETCH_CROSSREF, stype, item); - req.request._tree = tree; - req.request._item = item; - req.request._stype = stype; - req.callback(resultAppendCrossRef); - req.send(); -} - - -function resultQuickLink( term, type ) { - var args = {}; - if(SHOW_MR_DEFAULT) { - args.page = MRESULT; - } else { - args.page = RRESULT; - args[PARAM_RTYPE] = type; - } - args[PARAM_OFFSET] = 0; - args[PARAM_TERM] = term; - args[PARAM_STYPE] = type; - return buildOPACLink(args); -} - -/* XXX */ -function resultRenderXRefTree(r) { - var tree = r._tree; - var res = r.getResultObject(); - var stype = r._stype; - - for( var c in res ) { - var cls = res[c]; - for( var t in cls ) { - var term = res[c][t]; - var froms = term['from']; - var alsos = term['also']; - var total = 0; - - for( var i = 0; (total++ < 5 && i < froms.length); i++ ) { - var string = normalize(truncate(froms[i], 45)); - if($(stype + '_' + froms[i])) continue; - tree.addNode(stype + '_' + froms[i], - stype + '_' + t, string, resultQuickLink(froms[i],stype)); - } - for( var i = 0; (total++ < 10 && i < alsos.length); i++ ) { - var string = normalize(truncate(alsos[i], 45)); - if($(stype + '_' + alsos[i])) continue; - tree.addNode(stype + '_' + alsos[i], - stype + '_' + t, string, resultQuickLink(alsos[i],stype)); - } - } - } -} - - -/* Addes the see-from/see-also entries for this subject item */ -function resultAppendCrossRef(r) { - var tree = r._tree - var item = r._item - var stype = r._stype; - var result = r.getResultObject(); - if(!result) return; - var froms = result['from']; - var alsos = result['also']; - - var total = 0; - - for( var i = 0; (total++ < 5 && i < froms.length); i++ ) - resultAddXRefItem( tree, item, stype, froms, i ); - - for( var i = 0; (total++ < 10 && i < alsos.length); i++ ) - resultAddXRefItem( tree, item, stype, alsos, i ); -} - -/** - * Adds a single entry into the see-from/also sidebar tree - */ -var collectedStrings = []; -function resultAddXRefItem(tree, rootItem, stype, arr, idx) { - - var string = normalize(truncate(arr[idx], 45)); - - if( string == rootItem ) return; - - if( grep( collectedStrings, - function(a) { return (a == string); }) ) return; - - if($(stype + '_' + arr[idx])) return; - - tree.addNode(stype + '_' + arr[idx], - stype + '_' + rootItem, string, resultQuickLink(arr[idx],stype)); - - collectedStrings.push(string); -} - - - - - - diff --git a/Open-ILS/web/opac/skin/default/js/tips.js b/Open-ILS/web/opac/skin/default/js/tips.js deleted file mode 100644 index 48fa83a539..0000000000 --- a/Open-ILS/web/opac/skin/default/js/tips.js +++ /dev/null @@ -1,19 +0,0 @@ -attachEvt('result', 'allRecordsReceived', insertTip); - -/* -var user_tips = [ - 'Click on a folder icon in the sidebar to access related quick searches', - "If you don't find what you want try expanding your search using the range selector at the right of the search bar" -]; -*/ - -function insertTip () { - var tip_div = document.getElementById('tips'); - if (tip_div) { - var tips = tip_div.getElementsByTagName('div')[0].getElementsByTagName('span'); - var index = Math.floor(Math.random() * tips.length); - try { tip_div.appendChild( tips[index] ); } catch(E) {} - removeCSSClass(tip_div, 'hide_me'); - } -} - diff --git a/Open-ILS/web/opac/skin/default/xml/advanced/adv_global_row.xml b/Open-ILS/web/opac/skin/default/xml/advanced/adv_global_row.xml deleted file mode 100644 index f5c5ca7dd9..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/advanced/adv_global_row.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/Open-ILS/web/opac/skin/default/xml/advanced/advanced_global.xml b/Open-ILS/web/opac/skin/default/xml/advanced/advanced_global.xml deleted file mode 100644 index 865aa59ff8..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/advanced/advanced_global.xml +++ /dev/null @@ -1,309 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Open-ILS/web/opac/skin/default/xml/advanced/advanced_marc.xml b/Open-ILS/web/opac/skin/default/xml/advanced/advanced_marc.xml deleted file mode 100644 index 46fe2879ed..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/advanced/advanced_marc.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -
&opac.advanced.marc.title;
- &opac.advanced.marc.tag;: - - - &opac.advanced.marc.subfield;: - - - &opac.advanced.marc.value;: - - - -
- - - - -
diff --git a/Open-ILS/web/opac/skin/default/xml/advanced/advanced_quick.xml b/Open-ILS/web/opac/skin/default/xml/advanced/advanced_quick.xml deleted file mode 100644 index 3f7da6ff5e..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/advanced/advanced_quick.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - -
&opac.advanced.quick.title;
- &common.call.number.label; - - - - &common.isbn.label; - - - - &common.issn.label; - - -
diff --git a/Open-ILS/web/opac/skin/default/xml/body.xml b/Open-ILS/web/opac/skin/default/xml/body.xml deleted file mode 100644 index 3325a26b80..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/body.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - -
- - - -
- - - - - - - - - - - -
-
- -
- -
-
- ; -
&common.googlechromeframe.why;
- - -
-
- - - - - - diff --git a/Open-ILS/web/opac/skin/default/xml/common/altcanvas.xml b/Open-ILS/web/opac/skin/default/xml/common/altcanvas.xml deleted file mode 100644 index 97448daa77..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/common/altcanvas.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - -
-
- -
-
- -
diff --git a/Open-ILS/web/opac/skin/default/xml/common/cn_browse.xml b/Open-ILS/web/opac/skin/default/xml/common/cn_browse.xml deleted file mode 100644 index aea7fa171f..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/common/cn_browse.xml +++ /dev/null @@ -1,34 +0,0 @@ -
-
&common.cn.loading;
-
- - -
- &common.cn.browsing; -
- - - - - - - - - - - - - -
&common.cn.previous;&common.cn.shelf;&common.cn.next;
- -
- - -
-
-
-
diff --git a/Open-ILS/web/opac/skin/default/xml/common/fonts.xml b/Open-ILS/web/opac/skin/default/xml/common/fonts.xml deleted file mode 100644 index c7ebef3801..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/common/fonts.xml +++ /dev/null @@ -1,25 +0,0 @@ -
- -
- &common.textsize.title; - &common.textsize.regular; - &common.textsize.separator; - &common.textsize.large; -  |  - &common.language; - - - -
- -
diff --git a/Open-ILS/web/opac/skin/default/xml/common/format_selector.xml b/Open-ILS/web/opac/skin/default/xml/common/format_selector.xml deleted file mode 100644 index 6d329a9a3c..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/common/format_selector.xml +++ /dev/null @@ -1,11 +0,0 @@ - - diff --git a/Open-ILS/web/opac/skin/default/xml/common/holds.xml b/Open-ILS/web/opac/skin/default/xml/common/holds.xml deleted file mode 100644 index ff72572347..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/common/holds.xml +++ /dev/null @@ -1,253 +0,0 @@ -
-
-
- - - - - - - - - - -
&opac.holds.xulRecipient;:
-
-
- -
-


- &common.hold.check; -
- -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
&common.hold.create;
&opac.holds.recipient;:
&common.title.label;
&common.author;
&common.format;
&common.physical.label;
&common.mono_parts.label; - - -
&common.call.number.label;
&common.copy.barcode.label;
&common.issuance_label.label;
&common.hold.type.label;&common.hold.volume;&common.hold.copy;&common.hold.issuance;
&opac.holds.contactPhone;: - - &common.phone.format; -
&common.phone.enable; - -
&opac.holds.contactEmail;: - - &common.email.none;
- &common.email.set; -
- - &common.email.none; - - -
&common.email.enable; - -
&opac.holds.pickupLocation; - -
&opac.holds.expire_time; - -
- &opac.holds.freeze; - &common.help; - - -
- - &opac.holds.freeze.thaw_date; - - -
- -
-
- &common.format.alternatives; - &common.help; -
-
&common.control.click;
-
- -
- - - - -
- -
&opac.holds.success;
-
&opac.holds.failure;
- - &common.phone.format.help; - - - - &common.hold.failed; - - &opac.hold.has_parts; - -
- - - &opac.search.books; - &opac.search.largePrint; - &opac.search.audioBooks; - &opac.search.videoRecordings; - &opac.search.music; - &opac.search.electronic; - - - &holds.advanced_options; - - &common.hold.delivery; - - &common.hold.exists; - &common.hold.checked_out; - - &common.hold.exists.override; - &common.hold.checked_out.override; - &common.hold.age_protect.override; - &common.hold.place_unfillable.override; - - &common.hold.barred; - - &common.hold.item.invalid; - - &common.hold.patron.invalid; - -
diff --git a/Open-ILS/web/opac/skin/default/xml/common/ilsevents.xml b/Open-ILS/web/opac/skin/default/xml/common/ilsevents.xml deleted file mode 100644 index dcef13f28b..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/common/ilsevents.xml +++ /dev/null @@ -1,14 +0,0 @@ - - &ilsevent.1000; - &ilsevent.1001; - &ilsevent.1002; - &ilsevent.1200; - &ilsevent.5000; - &ilsperm.CREATE_HOLD; - - - &opac.session_expiring; - &opac.session_expired; - &common.user_not_found; - - diff --git a/Open-ILS/web/opac/skin/default/xml/common/libselect.xml b/Open-ILS/web/opac/skin/default/xml/common/libselect.xml deleted file mode 100644 index 45a7da780c..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/common/libselect.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - &library.select; - - - - - &library.select.help; - - - diff --git a/Open-ILS/web/opac/skin/default/xml/common/login.xml b/Open-ILS/web/opac/skin/default/xml/common/login.xml deleted file mode 100644 index e59ba2985e..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/common/login.xml +++ /dev/null @@ -1,115 +0,0 @@ - -
- - - - -
- - - -
- -
- - - - - - - - - - - - - - - -
- -
- - - -

- - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
&login.password;
- &login.first.time; - &common.password_criteria; -
&login.password.current.enter;
&login.password.new.enter;
&login.password.new.reenter;

- -
- - &login.password.nomatch; - &login.password.success; - - - &login.password.strength; - &common.password_criteria; - - - &login.barcode.inactive; - - &login.account.inactive; - - &login.failed; - -
- - diff --git a/Open-ILS/web/opac/skin/default/xml/common/logo.xml b/Open-ILS/web/opac/skin/default/xml/common/logo.xml deleted file mode 100644 index fffec7f2ce..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/common/logo.xml +++ /dev/null @@ -1,4 +0,0 @@ -
- - -
diff --git a/Open-ILS/web/opac/skin/default/xml/common/orgtree.xml b/Open-ILS/web/opac/skin/default/xml/common/orgtree.xml deleted file mode 100644 index d4008d3f68..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/common/orgtree.xml +++ /dev/null @@ -1,27 +0,0 @@ - - -
- - - -

&common.org.loading;
-
-
&common.org.note; - &common.org.notetext; -
-
-
-
-
diff --git a/Open-ILS/web/opac/skin/default/xml/common/searchbar.xml b/Open-ILS/web/opac/skin/default/xml/common/searchbar.xml deleted file mode 100644 index 1638370e78..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/common/searchbar.xml +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - diff --git a/Open-ILS/web/opac/skin/default/xml/common/sidebar.xml b/Open-ILS/web/opac/skin/default/xml/common/sidebar.xml deleted file mode 100644 index f15fc273dc..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/common/sidebar.xml +++ /dev/null @@ -1,196 +0,0 @@ - - - - - diff --git a/Open-ILS/web/opac/skin/default/xml/common/statusbar.xml b/Open-ILS/web/opac/skin/default/xml/common/statusbar.xml deleted file mode 100644 index 237be6264b..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/common/statusbar.xml +++ /dev/null @@ -1,28 +0,0 @@ - -
- - - - - - - - -
- - - - - &status.results; - - - - - -
- - - -
diff --git a/Open-ILS/web/opac/skin/default/xml/common/stypes_selector.xml b/Open-ILS/web/opac/skin/default/xml/common/stypes_selector.xml deleted file mode 100644 index 588030c63a..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/common/stypes_selector.xml +++ /dev/null @@ -1,8 +0,0 @@ - - diff --git a/Open-ILS/web/opac/skin/default/xml/common/tips.xml b/Open-ILS/web/opac/skin/default/xml/common/tips.xml deleted file mode 100644 index 84919f54e1..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/common/tips.xml +++ /dev/null @@ -1,8 +0,0 @@ - -
-
- &common.tips.tip1; - &common.tips.tip2; -
- &tips.label; -
diff --git a/Open-ILS/web/opac/skin/default/xml/footer.xml b/Open-ILS/web/opac/skin/default/xml/footer.xml deleted file mode 100644 index 71d77c306c..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/footer.xml +++ /dev/null @@ -1,33 +0,0 @@ - diff --git a/Open-ILS/web/opac/skin/default/xml/header.xml b/Open-ILS/web/opac/skin/default/xml/header.xml deleted file mode 100644 index 3f312b4836..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/header.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - &<!--#echo var="OILS_TITLE"-->; - - - - - - - - diff --git a/Open-ILS/web/opac/skin/default/xml/home/homesearch.xml b/Open-ILS/web/opac/skin/default/xml/home/homesearch.xml deleted file mode 100644 index 30ca9a3481..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/home/homesearch.xml +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - - - diff --git a/Open-ILS/web/opac/skin/default/xml/home/index_body.xml b/Open-ILS/web/opac/skin/default/xml/home/index_body.xml deleted file mode 100644 index d65a6f74e4..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/home/index_body.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - -
- -
- - - - - - - - - - -
-
- - -
-
- -
-
- -
&common.googlechromeframe.why;
- - -
-
- - - - - - - diff --git a/Open-ILS/web/opac/skin/default/xml/html_xsl.xml b/Open-ILS/web/opac/skin/default/xml/html_xsl.xml deleted file mode 100644 index f22332079d..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/html_xsl.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - diff --git a/Open-ILS/web/opac/skin/default/xml/index.xml b/Open-ILS/web/opac/skin/default/xml/index.xml deleted file mode 100644 index f3e84e5f10..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/index.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - -]> - - - - - - - - - - - diff --git a/Open-ILS/web/opac/skin/default/xml/myopac/myopac_bookbags.xml b/Open-ILS/web/opac/skin/default/xml/myopac/myopac_bookbags.xml deleted file mode 100644 index d4c6d3f3d3..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/myopac/myopac_bookbags.xml +++ /dev/null @@ -1,136 +0,0 @@ - -
- - - -
- &myopac.delete.bookbag; -
- -
&myopac.no.bookbags;
- -
- &myopac.bookbags.title; - -
- - - - - - - - - - - - - - - - -
&common.name;&myopac.bookbag.items;&myopac.bookbag.shared;&myopac.bookbag.toggle;&myopac.bookbag.delete;
- - &myopac.items; - &common.no; - &common.yes; - &myopac.view; - - &myopac.atom.feed; - -
&myopac.bookbag.refworks; -
- &myopac.bookbag.hide; - &myopac.bookbag.share; - - &myopac.delete; -
- - - - - - - - - - - - - -
&myopac.bookbag.create;
- &myopac.bookbag.naming; - -
- &myopac.bookbag.share; - &common.help; - &common.yes; - &common.no; - -
- - -
- -
&myopac.bookbag.no.items;
- - - - - - - - - - - - - -
&common.title; &common.authors; &myopac.bookbag.remove;
&myopac.remove.link;
- - - - &myopac.publish.text; - - - - &myopac.item.confirm; - - - - &myopac.publish.confirm; - - - - &myopac.unpublish.confirm; - - - - &myopac.update.success; - - - - &myopac.create.warning; - - - - &myopac.describe.bookbags; - - - - &myopac.updated.success; - - -
- - diff --git a/Open-ILS/web/opac/skin/default/xml/myopac/myopac_checked.xml b/Open-ILS/web/opac/skin/default/xml/myopac/myopac_checked.xml deleted file mode 100644 index 2849ffdc1a..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/myopac/myopac_checked.xml +++ /dev/null @@ -1,104 +0,0 @@ - -
- - - - - - - - -
- - &myopac.checked.out; 0 / - &myopac.checked.overdue; 0 - - -
&myopac.checked.renewing;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
&common.title;&common.author;&myopac.fines.due;&myopac.checked.renew.remaining;&common.select; - (&common.all;/&common.none;) -
&myopac.checked.noitems;
&common.loading;
- - - -
- -
-
-
&myopac.common.other.circ;
- - - - - - - - - - - - -
&myopac.checked.circ.lib;&myopac.checked.item.type;&myopac.checked.circ.time;
- - -
-
- -
&myopac.checked.renew.success;
- - &myopac.checked.renew.confirm; - - &myopac.checked.renew.fail; - - &myopac.checked.renew.fail2; - -
- - diff --git a/Open-ILS/web/opac/skin/default/xml/myopac/myopac_fines.xml b/Open-ILS/web/opac/skin/default/xml/myopac/myopac_fines.xml deleted file mode 100644 index db129c0162..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/myopac/myopac_fines.xml +++ /dev/null @@ -1,101 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - -
&myopac.fines.title;
&myopac.fines.owed;&myopac.fines.paid;&myopac.fines.balance;
&myopac.fines.status;
&common.currency;&common.currency;&common.currency;
- - - - - -
-


- - - - - - - - - - - - - - - - - - - - - - -
&myopac.fines.overdue;
&common.title;&common.author;&myopac.fines.checkout;&myopac.fines.due;&myopac.fines.returned;&myopac.fines.balance;
&myopac.fines.accruing; - &common.currency; -
-
- - -
-


- - - - - - - - - - - - - - - - - - - - - - - -
&myopac.fines.other;
&myopac.fines.time.start;&myopac.fines.time.paid;&myopac.fines.owed.initial;&myopac.fines.paid.amount;&myopac.fines.balance;&myopac.fines.type;
&common.currency;&common.currency; - * - &common.currency; -
-
- -
- -
- - diff --git a/Open-ILS/web/opac/skin/default/xml/myopac/myopac_holds.xml b/Open-ILS/web/opac/skin/default/xml/myopac/myopac_holds.xml deleted file mode 100644 index 5a07d9ed07..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/myopac/myopac_holds.xml +++ /dev/null @@ -1,124 +0,0 @@ - -
- - - - - - -
- -
- - &myopac.holds.cancel.confirm; - &myopac.holds.freeze.confirm; - &myopac.holds.thaw.confirm; - &myopac.holds.thaw_date.confirm; - &myopac.holds.freeze.select_thaw; - - - -
&myopac.holds.processing;
- -
-
&myopac.holds.freeze.select_thaw;
-

- -

-

- -

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
&common.title;&common.author;&myopac.holds.formats;&myopac.holds.location;&common.status;&myopac.holds.estimated_wait;&myopac.holds.unfrozen;&myopac.holds.frozen.until;&opac.holds.expire_time;&common.select; - (&common.all;/&common.none;) - &myopac.holds.edit;
&myopac.holds.status.none;
&myopac.loading;
- -
-
-
-
-
-
- - - &myopac.holds.status.suspended; - &myopac.holds.status.waiting; - &myopac.holds.status.intransit; - &myopac.holds.status.available; - - - - - - &common.no; - &common.yes; - - &myopac.holds.edit; -
- - - &myopac.holds.verify; - - -
- - diff --git a/Open-ILS/web/opac/skin/default/xml/myopac/myopac_prefs.xml b/Open-ILS/web/opac/skin/default/xml/myopac/myopac_prefs.xml deleted file mode 100644 index 0687aa6294..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/myopac/myopac_prefs.xml +++ /dev/null @@ -1,105 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- &myopac.prefs.title; -
&myopac.loading;
&myopac.prefs.hits; - -
&myopac.prefs.font; - -
- &myopac.prefs.holds.notify; - &common.help; - - -
&myopac.prefs.search.location; -
- &myopac.prefs.search.home; -
- -
&myopac.prefs.search.range; - -

- -
- -
&myopac.prefs.save.success;
-
&myopac.prefs.save.failed;
- - &myopac.prefs.help; - - -
- - diff --git a/Open-ILS/web/opac/skin/default/xml/myopac/myopac_summary.xml b/Open-ILS/web/opac/skin/default/xml/myopac/myopac_summary.xml deleted file mode 100644 index 821f870db7..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/myopac/myopac_summary.xml +++ /dev/null @@ -1,311 +0,0 @@ - -
- - -
- - - - - - -
- &myopac.summary.expired; -
-
- -
- - - - - - - - - - - -
&myopac.summary.notes;
- : -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
&common.name; - - - - - -
&myopac.summary.phone.day;
&myopac.summary.phone.evening;
&myopac.summary.phone.other;
&common.username; &myopac.summary.change;
- - - - - - - - - - -
&myopac.summary.password.current;
&myopac.summary.username.enter;
- - - - - - - -
&common.password;&myopac.summary.password.text;&myopac.summary.change;
- - - - - - - - - - - - - - -
&myopac.summary.password.current;
&myopac.summary.password.new;
&myopac.summary.password.reenter;
- - - - - - - -
&myopac.summary.email; &myopac.summary.change;
- - - - - - - - - - -
&myopac.summary.password.current;
&myopac.summary.email.new;
- - - - - - - -
&myopac.summary.id.primary;
&myopac.summary.barcode;
&myopac.summary.home;
&myopac.summary.genesis;
- - -


- - - - - - - - - - - - - - -
&myopac.summary.addresses;&myopac.summary.addresses.pending;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
&myopac.summary.address.type;
&myopac.summary.address.street;
&myopac.summary.address.street;
&myopac.summary.address.city;
&myopac.summary.address.county;
&myopac.summary.address.state;
&myopac.summary.address.country;
&myopac.summary.address.zip;
&myopac.summary.address.invalid;
- &myopac.summary.address.edit; -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
&myopac.summary.address.type;
&myopac.summary.address.street;
&myopac.summary.address.street;
&myopac.summary.address.city;
&myopac.summary.address.county;
&myopac.summary.address.state;
&myopac.summary.address.country;
&myopac.summary.address.zip;
- Save Changes - Discard Pending Address -
-
- -
&myopac.summary.username.error;
-
- &myopac.summary.username.dup; -
-
&myopac.summary.username.success;
-
&myopac.summary.username.failure;
- -
&myopac.summary.email.error;
-
&myopac.summary.email.success;
-
&myopac.summary.email.failed;
- -
&myopac.summary.password.error;
-
&myopac.summary.password.success;
-
&myopac.summary.password.failure;
- &myopac.summary.username.invalid; - Address Saved -
- - diff --git a/Open-ILS/web/opac/skin/default/xml/page_advanced.xml b/Open-ILS/web/opac/skin/default/xml/page_advanced.xml deleted file mode 100644 index 0218dfb8d2..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/page_advanced.xml +++ /dev/null @@ -1,14 +0,0 @@ -
- - - - - -
- -
-
- - diff --git a/Open-ILS/web/opac/skin/default/xml/page_authbrowse.xml b/Open-ILS/web/opac/skin/default/xml/page_authbrowse.xml deleted file mode 100644 index f8c8897792..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/page_authbrowse.xml +++ /dev/null @@ -1,13 +0,0 @@ -
- - - - -
- - -
diff --git a/Open-ILS/web/opac/skin/default/xml/page_cnbrowse.xml b/Open-ILS/web/opac/skin/default/xml/page_cnbrowse.xml deleted file mode 100644 index cc2c4a4dcd..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/page_cnbrowse.xml +++ /dev/null @@ -1,6 +0,0 @@ -
- - -
- - diff --git a/Open-ILS/web/opac/skin/default/xml/page_mresult.xml b/Open-ILS/web/opac/skin/default/xml/page_mresult.xml deleted file mode 100644 index b507d425ae..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/page_mresult.xml +++ /dev/null @@ -1,9 +0,0 @@ -
- - - - - - -
- diff --git a/Open-ILS/web/opac/skin/default/xml/page_myopac.xml b/Open-ILS/web/opac/skin/default/xml/page_myopac.xml deleted file mode 100644 index e7d86acd0e..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/page_myopac.xml +++ /dev/null @@ -1,67 +0,0 @@ -
- - - - -
&common.loading;
- - - -
- - - - - - - - - - - - - - - - - - -
- -
- -
- - - - - - -
- -
- - diff --git a/Open-ILS/web/opac/skin/default/xml/page_rdetail.xml b/Open-ILS/web/opac/skin/default/xml/page_rdetail.xml deleted file mode 100644 index f676a72bec..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/page_rdetail.xml +++ /dev/null @@ -1,93 +0,0 @@ -
- - - - - - - - - - - - - - - - - -
- - - &rdetail.result; - &common.of; - - - - - &rdetail.start; - &rdetail.page.previous.short; - - &rdetail.page.next.short; - &rdetail.end; - - -
- - - - - - - - - - -
- &rdetail.detailMain.headerLabel; - - - &opac.holds.exportRefWorks; - - - &opac.holds.placeHold; - - - - - -
- -
- &rdetail.record.deleted; -
- - -

- - -
&rdetail.none;
-
&rdetail.bookbag.add.success;
-
-
- - -
-
&rdetail.bookbag.create.success;
- -
diff --git a/Open-ILS/web/opac/skin/default/xml/page_rresult.xml b/Open-ILS/web/opac/skin/default/xml/page_rresult.xml deleted file mode 100644 index 2d0f2f6a86..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/page_rresult.xml +++ /dev/null @@ -1,9 +0,0 @@ -
- - - - - - -
- diff --git a/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_altcanvas.xml b/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_altcanvas.xml deleted file mode 100644 index ff17d172c3..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_altcanvas.xml +++ /dev/null @@ -1,28 +0,0 @@ - - -
- - - -
- diff --git a/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_cn_details.xml b/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_cn_details.xml deleted file mode 100644 index 294f4fe4fc..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_cn_details.xml +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - -
-
- - &rdetail.print; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
&rdetail.cn.barcode;&common.status;&rdetail.cn.location;&rdetail.cn.part;&rdetail.cn.hold.age;&rdetail.cn.genesis;&rdetail.cn.active;&rdetail.cn.holdable;&rdetail.cn.due;
- - &rdetail.cn.more; - &rdetail.cn.less; - &rdetail.cn.hold; - &rdetail.cn.reserve; - &rdetail.cn.multi_home; - &rdetail.cn.disabled; - - - -
- - - - - - - -
- &rdetail.cn.note; - &rdetail.cn.category; - - : -
-
-
-
- -&common.yes; -&common.no; - - -
-
-
- -
-
- - - - - - - - - - - - - - -
&common.library;
&common.title;
&common.author;
&common.edition;
&common.pubdate;
&common.publisher;
&common.physical;
&common.callnumber;
-
-
-
- diff --git a/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_copyinfo.xml b/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_copyinfo.xml deleted file mode 100644 index 01e463bf7d..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_copyinfo.xml +++ /dev/null @@ -1,89 +0,0 @@ - - -
- -
- - &rdetail.copyInfo.local; - - - &rdetail.copyInfo.all; - -
- - - - - - - - - - - - - - - - - - - - - - - - - -
&rdetail.copyInfo.library;&rdetail.copyInfo.callnumber;&rdetail.copyInfo.copylocation;&rdetail.copyInfo.actions; -
-
- - &rdetail.copyInfo.print; - - - - - -
&rdetail.loading;
- - - -

- -
&rdetail.noneAvailable;
- - - -
- - diff --git a/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_extras.xml b/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_extras.xml deleted file mode 100644 index 47382b624f..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_extras.xml +++ /dev/null @@ -1,184 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
&common.loading;
- - -
- -
-
- -
- - -
-
- -
- -
- -
- -
- -
-
-
- -
-
-
-
-
-
-
-
-
- -
- - - - - - -
&common.title; &common.authors;  
-
- -
- -
- &rdetail.extras.call.null; -
- -
- &rdetail.extras.call.local; - -
- - -
- - - -
- -
&rdetail.extras.preview.fulltext;
-
&rdetail.extras.preview.title;
-
&rdetail.extras.preview.badge;
- - - - - - - - - - - - - - - - - -
diff --git a/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_summary.xml b/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_summary.xml deleted file mode 100644 index d869f386c5..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/rdetail/rdetail_summary.xml +++ /dev/null @@ -1,231 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - -
-
&opac.image_provided;
- -
-
&common.title; - -
&common.author; - -
&common.isbn;
&common.edition;
&common.pubdate;
&common.publisher;
&common.physical;
&common.format; - - -
&rdetail.detailMain.abstract;
&rdetail.summary.subjects; - -
&rdetail.summary.online; - -
&rdetail.summary.issues_held; - ${holdingsStatement} - -
- - - - - - - - -
- diff --git a/Open-ILS/web/opac/skin/default/xml/result/filtersort.xml b/Open-ILS/web/opac/skin/default/xml/result/filtersort.xml deleted file mode 100644 index c8b3327df3..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/result/filtersort.xml +++ /dev/null @@ -1,20 +0,0 @@ - - &result.limit2avail; - - diff --git a/Open-ILS/web/opac/skin/default/xml/result/result_common.xml b/Open-ILS/web/opac/skin/default/xml/result/result_common.xml deleted file mode 100644 index 86848ab51f..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/result/result_common.xml +++ /dev/null @@ -1,36 +0,0 @@ - -
- - - - - - -
- - diff --git a/Open-ILS/web/opac/skin/default/xml/result/result_info.xml b/Open-ILS/web/opac/skin/default/xml/result/result_info.xml deleted file mode 100644 index 902035b808..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/result/result_info.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - -
- - &result.info.copies; - -
-
- - * - &result.info.no.items; -
&result.info.format.items;
-
-
- - - - - -
- diff --git a/Open-ILS/web/opac/skin/default/xml/result/result_lowhits.xml b/Open-ILS/web/opac/skin/default/xml/result/result_lowhits.xml deleted file mode 100644 index 0933ed1572..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/result/result_lowhits.xml +++ /dev/null @@ -1,49 +0,0 @@ - -
- -


- -
-
&result.lowhits.few;
-
&result.lowhits.zero;
-
- - -
- &result.lowhits.did.you.mean; - -
- -
- &result.lowhits.formats; - &result.lowhits.formats.search; -
- -
- &result.lowhits.related; -
- -
-
- -
- &result.lowhits.expand; - -
- - - -
- diff --git a/Open-ILS/web/opac/skin/default/xml/result/result_table.xml b/Open-ILS/web/opac/skin/default/xml/result/result_table.xml deleted file mode 100644 index d211867c15..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/result/result_table.xml +++ /dev/null @@ -1,323 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - -
- - - -
- - - | - | - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - &common.relevancy; - - - - &opac.holds.placeHold; - - - - - - - - - - &result.googleBooks.browse; - - -
- - = max_items) { - return output.innerHTML; - } - if (vol.getAttribute('deleted') == 't') { - return; - } - if (vol.getAttribute('opac_visible') == 'f') { - return; - } - dojo.query('copy', vol).forEach(function (cp) { - if (item_cnt >= max_items) { - return; - } - if (cp.getAttribute('deleted') == 't') { - return; - } - if (cp.getAttribute('opac_visible') == 'f') { - return; - } - - /* Ensure the status is visible */ - var visible_status; - dojo.query('status', cp).forEach(function (status) { - visible_status = status.getAttribute('opac_visible'); - }); - if (visible_status == 'f') { - return; - } - - /* Ensure the circulation library is visible */ - var lib_vis; - dojo.query('circlib', cp).forEach(function (status) { - lib_vis = status.getAttribute('opac_visible'); - }); - if (lib_vis != 't') { - return; - } - - var cp_entry = dojo.create('div'); - var loc_visible; - var vol_appended = false; - dojo.query('location', cp).forEach(function (location) { - loc_visible = location.getAttribute('opac_visible'); - if (loc_visible == 't') { - if (!vol_appended) { - var cn = dojo.create('span', { style: "font-weight: bold;" }, cp_entry); - var cn_txt = dojo.doc.createTextNode(vol.getAttribute('label')); - cn.appendChild(cn_txt); - vol_appended = true; - } - var loc = dojo.create('span', { "style": "font-weight: bold;"}, cp_entry); - var loc_txt = dojo.doc.createTextNode(' - ' + BT.textContent(location)); - loc.appendChild(loc_txt); - } - }); - if (loc_visible != 't') { - return; - } - dojo.query('circ_lib', cp).forEach(function (circ_lib) { - var cp_lib = dojo.create('span', { "style": "font-weight: bold;" }, cp_entry, "first"); - var cp_lib_txt = dojo.doc.createTextNode(circ_lib.getAttribute('name') + ' - '); - cp_lib.appendChild(cp_lib_txt); - }); - dojo.query('status', cp).forEach(function (status) { - var cp_status = dojo.create('span', { "style": "font-weight: bold;" }, cp_entry); - var cp_status_txt = dojo.doc.createTextNode(' (' + BT.textContent(status) + ')'); - cp_status.appendChild(cp_status_txt); - }); - - item_cnt++; - if (item_cnt >= max_items) { - dojo.create('br', null, cp_entry); - cp_entry.appendChild(dojo.doc.createTextNode(opac_strings.MORE_COPIES_FULL_RECORD)); - } - output.appendChild(cp_entry); - }); - }); - - return output.innerHTML; - ]]> - -
- -
-
-
- - - - - - - - - - - - - -
- - - &common.results; - - - - - &common.ofAtLeast; - - (page - - &common.of; - - - - - &rdetail.start;&rdetail.page.previous.short; - - - &rdetail.page.next.short; - - - - - -
- - - - - - - - - - - - - - -
- - diff --git a/Open-ILS/web/opac/skin/default/xml/setenv.xml b/Open-ILS/web/opac/skin/default/xml/setenv.xml deleted file mode 100644 index ac2975d084..0000000000 --- a/Open-ILS/web/opac/skin/default/xml/setenv.xml +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -