+++ /dev/null
-
-<script>
-
- /* Checks to see if a given type of added content has data to show.
- * The first arg to callback() is boolean indicating the presence of data */
- function acIsAvailable(bre_id, type, callback) {
- var url = '/opac/extras/ac/' + type + '/html/r/' + bre_id;
- dojo.xhr('HEAD', {
- url : url,
- failOk : true, // http://bugs.dojotoolkit.org/ticket/11568
- error : function(err) { callback(false, bre_id, type); },
- load : function(result) { callback(true, bre_id, type); }
- });
- }
-
- [%-
- FOR type IN ctx.added_content.keys;
- IF ctx.added_content.$type.status == '3' # status unknown %]
-
- dojo.addOnLoad(function() {
- var bre_id = '[% ctx.bre_id %]';
- var type = '[% type %]';
-
- acIsAvailable(bre_id, type, function(avail, bre_id, type) {
- if (avail) {
-
- [% IF CGI.param('expand') == 'addedcontent' %]
-
- // if the content is available, un-hide the tab
- dojo.removeClass(dojo.byId('ac:' + type), 'hidden');
-
- [% ELSE %]
- // if no default type is selected on the main tab link
- // set one here, since we have available content
-
- var link = dojo.query('[name=addedcontent]')[0];
- var href = link.getAttribute('href');
- if (!href.match('[\&;]ac=')) {
- href = href.replace('#addedcontent', ';ac=' + type + '#addedcontent');
- dojo.attr(link, 'href', href);
- dojo.attr(dojo.query('[name=addedcontent_lbl]')[0], 'href', href);
- }
-
- [% END %]
- }
- });
- });
- [% END; # IF status unknown
- END; # FOR type
-
- ident = ctx.record_attrs.isbn_clean || ctx.record_attrs.upc;
- IF ident;
- -%]
-
-[%- IF ENV.OILS_NOVELIST_URL -%]
- /* Load novelist content */
- setTimeout( function() {
- novSelect.loadContentForQuery(
- {
- ClientIdentifier : '[% ident %]',
- ISBN : '[% ident %]',
- version : '2.1'
- },
- '[% ENV.OILS_NOVELIST_PROFILE %]',
- '[% ENV.OILS_NOVELIST_PASSWORD %]',
- function(d){
- // note if d.length == 0, there is no content to display
- // hide the Loading... text
- dojo.byId('novelist-loading').innerHTML = '';
- }
- )}, 100);
-[%- END; # Novelist -%]
-
- [% END; # IF ident
- %]
-</script>
-<script type="text/javascript">
+<script>
/* Checks to see if a given type of added content has data to show.
- * The first arg to callback() is boolean indicating the presence of data */
- function acIsAvailable(bre_id, type, callback) {
- var url = '/opac/extras/ac/' + type + '/html/r/' + bre_id;
- dojo.xhr('HEAD', {
- url : url,
- failOk : true, // http://bugs.dojotoolkit.org/ticket/11568
- error : function(err) { callback(false, bre_id, type); },
- load : function(result) { callback(true, bre_id, type); }
- });
+ * Returns a promise of a boolean value */
+ async function acIsAvailable(bre_id, type) {
+ const url = '/opac/extras/ac/' + type + '/html/r/' + bre_id;
+ const response = await fetch(url, {method: 'HEAD'});
+ return response.ok;
}
[%-
FOR type IN ctx.added_content.keys;
IF ctx.added_content.$type.status == '3' # status unknown %]
- dojo.addOnLoad(function() {
+ window.addEventListener('load', () => {
var bre_id = '[% ctx.bre_id %]';
var type = '[% type %]';
- acIsAvailable(bre_id, type, function(avail, bre_id, type) {
+ acIsAvailable(bre_id, type).then((avail) => {
if (avail) {
-
- [% IF CGI.param('expand') == 'addedcontent' %]
-
+ let params = (new URL(document.location)).searchParams;
+ if (params.get('expand') === 'addedcontent') {
// if the content is available, un-hide the tab
- dojo.removeClass(dojo.byId('ac:' + type), 'hidden');
-
- [% ELSE %]
+ document.getElementById('ac:' + type)).classList.remove('hidden');
+ } else {
// if no default type is selected on the main tab link
// set one here, since we have available content
- var link = dojo.query('[name=addedcontent]')[0];
+ var link = document.querySelector('[name="addedcontent"]');
var href = link.getAttribute('href');
if (!href.match('[\&;]ac=')) {
href = href.replace('#addedcontent', ';ac=' + type + '#addedcontent');
- dojo.attr(link, 'href', href);
- dojo.attr(dojo.query('[name=addedcontent_lbl]')[0], 'href', href);
+ link.setAttribute('href', href);
+ document.querySelector('[name="addedcontent_lbl"]').setAttribute('href', href);
}
-
- [% END %]
+ }
}
});
});
function(d){
// note if d.length == 0, there is no content to display
// hide the Loading... text
- dojo.byId('novelist-loading').innerHTML = '';
+ document.getElementById('novelist-loading').innerHTML = '';
}
)}, 100);
[%- END; # Novelist -%]