1// Promise polyfill https://github.com/taylorhakes/promise-polyfill 2!function(e){function n(){}function t(e,n){return function(){e.apply(n,arguments)}}function o(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],s(e,this)}function i(e,n){for(;3===e._state;)e=e._value;return 0===e._state?void e._deferreds.push(n):(e._handled=!0,void o._immediateFn(function(){var t=1===e._state?n.onFulfilled:n.onRejected;if(null===t)return void(1===e._state?r:u)(n.promise,e._value);var o;try{o=t(e._value)}catch(i){return void u(n.promise,i)}r(n.promise,o)}))}function r(e,n){try{if(n===e)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var i=n.then;if(n instanceof o)return e._state=3,e._value=n,void f(e);if("function"==typeof i)return void s(t(i,n),e)}e._state=1,e._value=n,f(e)}catch(r){u(e,r)}}function u(e,n){e._state=2,e._value=n,f(e)}function f(e){2===e._state&&0===e._deferreds.length&&o._immediateFn(function(){e._handled||o._unhandledRejectionFn(e._value)});for(var n=0,t=e._deferreds.length;n<t;n++)i(e,e._deferreds[n]);e._deferreds=null}function c(e,n,t){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.promise=t}function s(e,n){var t=!1;try{e(function(e){t||(t=!0,r(n,e))},function(e){t||(t=!0,u(n,e))})}catch(o){if(t)return;t=!0,u(n,o)}}var a=setTimeout;o.prototype["catch"]=function(e){return this.then(null,e)},o.prototype.then=function(e,t){var o=new this.constructor(n);return i(this,new c(e,t,o)),o},o.all=function(e){var n=Array.prototype.slice.call(e);return new o(function(e,t){function o(r,u){try{if(u&&("object"==typeof u||"function"==typeof u)){var f=u.then;if("function"==typeof f)return void f.call(u,function(e){o(r,e)},t)}n[r]=u,0===--i&&e(n)}catch(c){t(c)}}if(0===n.length)return e([]);for(var i=n.length,r=0;r<n.length;r++)o(r,n[r])})},o.resolve=function(e){return e&&"object"==typeof e&&e.constructor===o?e:new o(function(n){n(e)})},o.reject=function(e){return new o(function(n,t){t(e)})},o.race=function(e){return new o(function(n,t){for(var o=0,i=e.length;o<i;o++)e[o].then(n,t)})},o._immediateFn="function"==typeof setImmediate&&function(e){setImmediate(e)}||function(e){a(e,0)},o._unhandledRejectionFn=function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)},o._setImmediateFn=function(e){o._immediateFn=e},o._setUnhandledRejectionFn=function(e){o._unhandledRejectionFn=e},"undefined"!=typeof module&&module.exports?module.exports=o:e.Promise||(e.Promise=o)}(this); 3 4//Fetch polyfill https://github.com/developit/unfetch 5window.fetch||(window.fetch=function(e,t){return t=t||{},new Promise(function(n,s){function r(){var e,t=[],n=[],s={};return o.getAllResponseHeaders().replace(/^(.*?):\s*([\s\S]*?)$/gm,function(r,o,u){t.push(o=o.toLowerCase()),n.push([o,u]),e=s[o],s[o]=e?e+","+u:u}),{ok:1==(o.status/200|0),status:o.status,statusText:o.statusText,url:o.responseURL,clone:r,text:function(){return Promise.resolve(o.responseText)},json:function(){return Promise.resolve(o.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([o.response]))},headers:{keys:function(){return t},entries:function(){return n},get:function(e){s[e.toLowerCase()]},has:function(e){e.toLowerCase()}}}}var o=new XMLHttpRequest;o.open(t.method||"get",e);for(var u in t.headers)o.setRequestHeader(u,t.headers[u]);o.withCredentials="include"==t.credentials,o.onload=function(){n(r())},o.onerror=s,o.send(t.body)})}); 6 7/* More IE11 polyfills */ 8window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach); 9Number.isNaN = Number.isNaN || function(value) {return value !== value}; 10 11document.documentElement.classList.remove('js-no'); 12 13if (!window.HCPLC) window.HCPLC = {}; 14 15HCPLC.searchbar = { 16 doSearch: function (e) { 17 e = e || window.event; 18 e.preventDefault(); 19 var activeTab = document.querySelector('.search-tabs li.active'); 20 var searchtype = activeTab.getAttribute('data-searchtype'); 21 var catalogSearchType = document.getElementById('catalogSearchSelect').value; 22 var keyword = document.getElementById(searchtype + 'Input').value || ''; 23 if (keyword.trim() === '') { 24 document.getElementById(searchtype + 'Input').focus(); 25 return false; 26 } 27 var la = ''; 28 if (searchtype === 'catalog') { 29 la = '-' + catalogSearchType; 30 } 31 window.dataLayer = window.dataLayer || []; 32 window.dataLayer.push({ 33 'event': 'search_bar_submit', 34 'searchType': searchtype + la.toLowerCase(), 35 'searchTerm': keyword 36 });
37 if (searchtype === 'site') { 38 document.getElementById(searchtype + 'Search').submit(); 39 } else { 40 var catalogHref = 'https://hcplc.bibliocommons.com/v2/search?searchType=' 41 + catalogSearchType 42 + '&query=' + encodeURIComponent(keyword); 43 var gtMenu = document.querySelector('.goog-te-gadget-simple'); 44 if (gtMenu && gtMenu.textContent.includes('Spanish')) { 45 catalogHref += '&locale=es-ES'; 46 } 47 window.location = catalogHref; 48 } 49 return false; 50 }, 51 refocusTab: function (event) { 52 if (event.keyCode === 37 || event.keyCode === 39) { 53 var tabId = event.target.id; 54 var currentId = tabId.substr(-1); 55 var newId = (currentId === '1' ? '2' : '1') ; 56 document.querySelector('#search-tab' + newId).focus(); 57 }; 58 }, 59 switchTabPanel: function (activeTab) { 60 var tabs = document.querySelectorAll('.search-tabs li'); 61 var panels = document.querySelectorAll('.multisrch-form'); 62 tabs.forEach(function(tab){ 63 tab.classList.remove('active'); 64 tab.setAttribute('aria-selected', 'false'); 65 tab.setAttribute('tabindex', '-1'); 66 }); 67 panels.forEach(function(panel){ 68 panel.classList.remove('active'); 69 panel.setAttribute('aria-hidden', 'true'); 70 }); 71 var searchtype = activeTab.getAttribute('data-searchtype'); 72 var activePanel = document.getElementById(searchtype + 'SearchPanel'); 73 activeTab.classList.add('active'); 74 activeTab.setAttribute('aria-selected', 'true'); 75 activeTab.setAttribute('tabindex', '0'); 76 activePanel.classList.add('active'); 77 activePanel.setAttribute('aria-hidden', 'false'); 78 }, 79 init: function () { 80 var tabs = document.querySelectorAll('.search-tabs li'); 81 var forms = document.querySelectorAll('.multisrch-form form'); 82 document.getElementById('multisrch').classList.remove('hide-noscript'); 83 forms.forEach(function(form){ 84 form.addEventListener('submit', HCPLC.searchbar.doSearch); 85 }); 86 document.getElementById('multisrch-tablist').addEventListener('keydown', HCPLC.searchbar.refocusTab);
87 tabs.forEach(function(tab){ 88 tab.addEventListener('focus', function () { 89 HCPLC.searchbar.switchTabPanel(this); 90 }); 91 }); 92 document.getElementById('showSearch').addEventListener('click', function(){ 93 this.classList.toggle('active'); 94 }); 95 } 96} 97 98HCPLC.setBackToTop = function () { 99 var backToTop = document.createElement('a'); 100 backToTop.id = 'back-to-top'; 101 backToTop.href = '#'; 102 backToTop.innerHTML = '<span class="glyph-text">Back to top</span><svg version="1.1" id="btt" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 240 240"><circle id="btt_button" fill="#185370" cx="120" cy="120" r="100"/><polygon id="btt_chevron" fill="#ffffff" points="170,132 157.5,144 120,106 82.5,144 70,132 120,82"/></svg>'; 103 backToTop.addEventListener('click', function(event) { 104 event.preventDefault(); 105 var yPos = window.pageYOffset; 106 var factor = 100; 107 var scrollback = setInterval(function() { 108 yPos -= factor; 109 if (yPos < factor) { 110 window.scrollTo(0, 0); 111 clearInterval(scrollback); 112 } else { 113 window.scrollTo(0, yPos); 114 } 115 }, 20); 116 }); 117 document.body.appendChild(backToTop); 118 window.addEventListener('scroll', function () { 119 backToTop.style.display = (window.pageYOffset > window.innerWidth + 320) ? 'block' : 'none'; 120 }); 121}; 122 123HCPLC.overlay = { 124 elem: null, 125 closeBtn: null, 126 show: function () { 127 if (!this.elem) { 128 return; 129 } 130 document.body.classList.add('noscroll'); 131 this.elem.style.display = 'flex'; 132 if (this.closeBtn) { 133 this.closeBtn.focus(); 134 } 135 }, 136 hide: function () { 137 if (!this.elem) { 138 return; 139 } 140 document.body.classList.remove('noscroll'); 141 this.elem.style.display = 'none'; 142 }, 143 init: function () { 144 this.elem = document.querySelector('.overlay'); 145 if (!this.elem) { 146 return; 147 } 148 this.elem.addEventListener('click', function (event) { 149 if (event.target === this) { 150 HCPLC.overlay.hide(); 151 } 152 }); 153 this.elem.addEventListener('keydown', function (event) { 154 if (event.key && event.key === 'Escape') { 155 HCPLC.overlay.hide(); 156 } 157 }); 158 this.closeBtn = document.querySelector('.overlay-close'); 159 if (this.closeBtn) { 160 this.closeBtn.addEventListener('click', function () { 161 HCPLC.overlay.hide(); 162 }); 163 } 164 } 165}; 166 167HCPLC.nicheOverlay = { 168 openOverlay: function (courseNumber) { 169 var iframe = document.createElement('iframe'); 170 iframe.id = 'niche-iframe'; 171 iframe.className = 'niche-iframe'; 172 iframe.setAttribute('allow', 'fullscreen'); 173 iframe.src = 'https://my.nicheacademy.com/hcpl/course/' + courseNumber; 174 document.querySelector('.iframe-close').insertAdjacentElement('beforebegin', iframe); 175 HCPLC.overlay.show(); 176 document.querySelector('.overlay-close').focus(); 177 }, 178 init: function () { 179 var overlay = document.querySelector('#overlay'); 180 var overlayObserver = new MutationObserver(function() { 181 if (overlay.style.display === 'none') { 182 document.querySelector('#niche-iframe').remove(); 183 } 184 }); 185 var self = this; 186 overlayObserver.observe(overlay, {attributes: true}); 187 document.querySelectorAll('.niche-link').forEach(function(link){ 188 link.addEventListener('click', function (event) { 189 event.preventDefault(); 190 var course = this.getAttribute('data-course'); 191 self.openOverlay(course); 192 }); 193 }); 194 document.querySelector('.iframe-close').addEventListener('click', function () { 195 HCPLC.overlay.hide(); 196 }); 197 } 198} 199 200HCPLC.formCheck = { 201 form: null, 202 loadTime: null, 203 stamp: function () { 204 var completionTime = Date.now() - this.loadTime; 205 var existing = this.form.querySelector('input[name=completion_time]'); 206 if (existing) { 207 existing.setAttribute('value', completionTime); 208 } else { 209 var input = document.createElement('input'); 210 input.setAttribute('type', 'hidden'); 211 input.setAttribute('name', 'completion_time'); 212 input.setAttribute('value', completionTime); 213 this.form.appendChild(input); 214 } 215 }, 216 init: function (selector) { 217 this.loadTime = Date.now(); 218 this.form = document.querySelector(selector); 219 var self = this; 220 if (this.form) { 221 this.form.addEventListener('submit', self.stamp.bind(self), true); 222 } 223 } 224} 225 226window.addEventListener('load', function () { 227 HCPLC.setBackToTop(); 228 HCPLC.overlay.init(); 229});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.