PageSourceSearch

https://catalog.lacountylibrary.org/custom/web/COLA_javascript.js

js lacountylibrary.org collected 2026-09-24 09:03:03 UTC 17,682 bytes, 396 lines download raw bytes

1function customJavaScript () {
2
3
4/*****ADD FOR RETHEME: ASSIGN A HOME CLASS FOR THE HOME SCREEN, SO CSS CAN APPLY SPECIFICALLY TO THE HOME SCREEN***/
5var curLangProfile=window.location.pathname.split('/')[2] + '/' + window.location.pathname.split('/')[3];
6if (window.location.href.split(curLangProfile)[1].length<=2){
7$J('body,#content,#searchBoxWrapper, body.mobile').addClass('homepage');
8var advObjContainer=$J('.searchBoxSection:first');
9/***adding the Curiosity Welcome on hope page above search box***/
10var curiosityDiv='<div id="curiosity-div"><div id="curiosity-span">Curiosity Welcomed</div></div>'; 
11}
12if(!com_sirsi_ent_page.isMobile){
13$J('#searchBoxCentered').prepend(curiosityDiv);
14$J('#searchBoxAdvancedLink').appendTo(advObjContainer);
15$J('#searchBoxAdvancedLink a').addClass('button').css('color','#fff');
16
17if(window.location.href.indexOf('/search/mylists')>-1){
18   var myListCountText=$J('.myListItemCount').text();
19   myListCountText+=' (80 max)';
20   $J('.myListItemCount').text(myListCountText);
21}
22if($J('#myAccount').length>0){
23$J('#footer').css('position','absolute');
24}
25jQuery('.menuLink:contains("My Lists"),.menuActive:contains("My Lists")').next('.pipeSeparator-light').after('<div class="menuLink"><a id="classiccat-link" href="https://catalog.lacountylibrary.org/client/'+curLangProfile+'" >New Search</a></div><div class="pipeSeparator-light">|</div><div class="menuLink"><a id="classiccat-link" href="https://lacountylibrary.org/digital-library-card-application/" >Get a Library Card</a></div><div class="pipeSeparator-light">|</div>');
26//jQuery('.menuLink:contains("My Account")').next('.pipeSeparator-light').after('<div class="menuLink"><a id="classiccat-link" href="https://lacountylibrary.org/digital-library-card-application/" >Get a Library Card</a></div><div class="pipeSeparator-light">|</div>');
27
28}
29else{ //if mobile
30$J('.homepage .searchBoxWrapper').before(curiosityDiv);
31var registerHtml='<div class="mobileMenuLink text-h4"><a id="adaMenuLinkMobile" class="ajaxLink" href="https://lacountylibrary.org/digital-library-card-application/">Get a Library Card</a></div>';
32$J('#slideMenu--mainMenu').append(registerHtml);
33}
34
35/*****END HOME ADD***/
36/***RETHEME CHANGE IN LIBINFO, OTHER LINKS***/
37swapIcons();
38jQuery('.menuLink:contains("Send a Request")').hide();
39//jQuery('.menuLink:contains("My Lists")').next('.pipeSeparator-light').append('<a id="classiccat-link" href="https://cola.ent.sirsi.net/client/'+curLangProfile+'" >New Search</a>');
40jQuery('#libInfoLink').attr('onclick', '');
41
42jQuery('#libInfoLink a').attr('href', 'https://lacountylibrary.org/locations/');
43jQuery('#libInfoLink a').attr('target', '_blank');
44jQuery('#libInfoLink a').attr('onClick','');
45if(window.location.pathname.split('/')[2]!=='en_US'){
46  relabelQS(); //Quick Search relabel
47}
48/***END RETHEME***/
49
50
51jQuery('#changePinPanel').prepend('Your PIN must be 4 digits.');
52advancedSearch();
53/*waitToAddRequestButton();
54waitToAddFineButton();*/
55myListsText();
56}
57
58function advancedSearch(){
59	 if(window.location.href.indexOf("advanced?") > -1) {
60jQuery('#searchBoxHomeLink').append('<span style="font-size:26px; font-weight:800; opacity:1; color:#ffffff">&nbsp;&nbsp;Advanced Search</span>');
61/***RETHEME: CONTENT TOP MARGIN NEEDS REDUCTION HERE***/
62$J('#content').css('margin-top','1rem');
63
64	 }
65}
66
67/*function waitToAddRequestButton(){
68                var curAttempt = 0;
69                var maxAttempts = 40;
70                if (jQuery('.patronRequestsError').length == 0){
71                curAttempt++;
72                if(curAttempt<=maxAttempts){
73                setTimeout("waitToAddRequestButton()",500);
74                }// if 1
75                }// if 2
76                else{
77                addButton();
78                }// else
79                
80}// function
81
82
83function addButton(){
84	var requestButton = "<a style='color: #ffffff' href='https://catalog.lacountylibrary.org/client/en_US/default/requests?'><button class='button'>Change My Address/Email</button></a><br/><br/>"; 
85jQuery('#patronRequestsZone').prepend(requestButton);
86}
87
88function waitToAddFineButton(){
89                var curAttempt = 0;
90                var maxAttempts = 40;
91                if (jQuery('.payFinesPanel').length == 0){
92                curAttempt++;
93                if(curAttempt<=maxAttempts){
94                setTimeout("waitToAddFineButton()",500);
95                }// if 1
96                }// if 2
97                else{
98                addFineButton();
99                }// else
100                
101}// function
102
103
104function addFineButton(){
105	var fineButton = "<br/><a style='color: #13a89e' href='https://catalog.colapl.org/uhtbin/cgisirsi/0/0/0/1/1168/X'>Click here to pay fines by credit card (log in to your account on the Classic Catalog)</a><br/><br/>"; 
106//jQuery('.totalFinesOwed').append(fineButton);
107}*/
108
109function myListsText(){
110	var listsText = '<p><br/>When you find items in Searching that you want to keep and organize, you can save them in your My Lists. You can create and customize your lists, and you can print or email your lists. From My Lists, you can also place holds on items.</p>';
111	jQuery('#listLoginLink').parent().parent().append(listsText);
112}
113
114/*jQuery(document).ready(function() {
115  updatePaymentTermsLink();
116});*/
117
118/** CUSTOM - Joel Hahn - 29 January 2020 - Online Payment **/
119if (/search\/account/.test(window.location.pathname) || /mobile\/search\/fines/.test(window.location.pathname)) {
120jQuery(document).ready(function() {
121  waitToAddToFines();
122});
123}
124var curAttempt = 0;
125function waitToAddToFines(){
126  //console.log(curAttempt);
127  var maxAttempts = 40;
128  if (jQuery('.payFinesTable').length == 0){
129    curAttempt++;
130    //console.log('Current attempt number: '+curAttempt);
131    if(curAttempt<=maxAttempts){
132      setTimeout("waitToAddToFines()",500);
133    }// if 1
134  }// if 2
135  else{
136    if (jQuery('.myFines .payFinesTable').length > 0) {
137      //getBillInformation();
138      // SR-62569 PayFlow Terms and Conditions Link
139      updatePaymentTermsLink();
140    }
141    //if (jQuery('.groupFines .payFinesTable').length > 0) {
142    //  getGroupBillInformation();
143    //}
144   }// else
145  
146}// function
147
148// Must enable a mock PayPal account to get the bill info
149// After getting the info, the PayPal form is removed and a new payment link added
150
151/*function addPaymentButton (billInfo,totalBillAmt,tableSelector) {
152var myProfile = window.location.pathname.split("/")[3];
153
154var individualBills = billInfo.split('b').slice(1);
155var billKeys;
156var billAmts;
157var billKeyList = [];
158var billAmtList = [];
159jQuery.each(individualBills, function(index,individualBill) {
160   billKeyList.push(individualBill.split(',')[0]);
161   billAmtList.push(individualBill.split(',')[1]);
162});
163billKeys = billKeyList.join('|');
164billAmts = billAmtList.join('|');
165  billAmts = billAmts.replace(/\n$/, '');
166
167var userName = jQuery('#preferencesAccordion h3:first a').text();
168var LineItems=""; //="[";
169var lineCount=0;
170//4.5 selector
171//jQuery('table[id^="finesTable_personal"] tbody tr').each(function() {
172///5.0.1 selector
173/***JTN, 2020 Nov 10: Customer wants this on mobile.  The below would have to be reworked for mobile, as the LineItems variable
174is not building in the mobile page structure****/
175/*var lineItemSelector=!com_sirsi_ent_page.isMobile?jQuery('.payFinesPanel div[id^="finesTable_personal"] .tbody .tr'):jQuery('.payFinesPanel div[id^="finesTable_personal"] .tr');
176//was jQuery('.payFinesPanel div[id^="finesTable_personal"] .tbody .tr').each(function() {
177jQuery(lineItemSelector).each(function() {
178
179  lineCount++;
180  //if (LineItems != "[") { LineItems += ","; }
181  if (LineItems != "") { LineItems += ","; }
182  LineItems += '[';
183  LineItems += ''+ lineCount;
184  LineItems += "*";
185  if (jQuery(this).find('.indentCol').text().replace(/\n+/, '') == "") {
186    LineItems += "There are no library materials associated with the fine or fee";
187    LineItems += "*";
188    LineItems += jQuery(this).find('.medCol').text().replace(/[\[]/g, '(').replace(/[\]]/g, ')').replace(/[<]/g, '(').replace(/[>]/g, ')').replace(/&/g, 'and').replace(/[']/g, '').replace(/["]/g, '');
189    LineItems += "*";
190    LineItems += jQuery(this).find('.moneyCol').text().replace('$','');
191  } else {
192//var tt = jQuery(this).find('.indentCol').text();
193//if (/Personal finance in your 20/.test(tt)) { 
194/*var str= tt;
195var ascii= str.split('').map(function(itm){
196    return itm.charCodeAt(0);
197});
198var str2=ascii.map(function(itm, i){
199    return '#'+i+'=0x'+itm.toString(16)+' ('+String.fromCharCode(itm)+')';
200}).join('\n');
201console.log(str2)*/;
202//jQuery(this).find('.indentCol').text( jQuery(this).find('.indentCol').text().replace("30s", "three0s") );
203// }
204/*    LineItems += jQuery(this).find('.indentCol').text().replace(/[\[]/g, '(').replace(/[\]]/g, ')').replace(/[<]/g, '(').replace(/[>]/g, ')').replace(/&/g, 'and').replace(/[']/g, '').replace(/["]/g, '').replace("30s", "thirties");
205    LineItems += "*";
206    LineItems += jQuery(this).find('.medCol').text().replace(/[\[]/g, '(').replace(/[\]]/g, ')').replace(/[<]/g, '(').replace(/[>]/g, ')').replace(/&/g, 'and').replace(/[']/g, '').replace(/["]/g, '');
207    LineItems += "*";
208    LineItems += jQuery(this).find('.moneyCol').text().replace('$','');
209  }
210  LineItems += ']';
211});
212//LineItems += "]";
213
214//Temporary conditional to limit access to just one account
215//if (com_sirsi_ent_widgets.UserID == "1111722226648" || com_sirsi_ent_widgets.UserID == "1111701092680") {
216  var link2govForm = '';
217  //## Live payments link
218  link2govForm += '<form action="https://paydirect.link2gov.com/colapublib/" target="_self" method="post" name="LibPayOnline">';
219  //## Test payments link
220  //link2govForm += '<form action="https://paydirect.ca.link2gov.com/colapublib/" target="_self" method="post" name="LibPayOnline">';
221
222  link2govForm += '<input name="MerchantCode" value="06LAX-LAPUB-LIBPD-W" type="hidden">';
223  link2govForm += '<input name="MerchantPassword" value="PL5xY3" type="hidden">';
224  link2govForm += '<input name="SettleCode" value="06LAX-LAPUB-LIBPD-00" type="hidden">';
225  link2govForm += '<input name="PaymentMethod" value="CreditOrDebit" type="hidden">';
226  link2govForm += '<input name="ReturnUrl" value="https://catalog.lacountylibrary.org/client/en_US/'+myProfile+'/search/account/3" type="hidden">';
227  //link2govForm += '<input name="PostUrl" value="https://catalog.colapl.org/uhtbin/payBills.pl?entProfile='+myProfile+'&billInfo='+billInfo+'" type="hidden">';
228  //link2govForm += '<input name="PostUrl" value="https://el.isd.lacounty.gov/uhtbin/paydirect.pl?entProfile='+myProfile+'&billInfo='+billInfo+'" type="hidden">';
229  //link2govForm += '<input name="PostUrl" value="http://el.isd.lacounty.gov/uhtbin/paydirect.pl" type="hidden">';
230  link2govForm += '<input name="PostUrl" value="https://cola.sirsi.net/uhtbin/paydirect.pl" type="hidden">';
231  link2govForm += '<input name="CancelUrl" value="https://catalog.lacountylibrary.org/client/en_US/'+myProfile+'/search/account/3" type="hidden">';
232  link2govForm += '<input name="UserPart1" value="'+com_sirsi_ent_widgets.UserID+'" type="hidden">';
233  link2govForm += '<input name="UserPart2" value="'+userName+'" type="hidden">';
234  link2govForm += '<input name="UserPart3" value="'+billKeys+'" type="hidden">';
235  link2govForm += '<input name="UserPart4" value="'+billAmts+'" type="hidden">';
236  link2govForm += '<input name="LineItems" value="'+LineItems+'" type="hidden">';
237  link2govForm += '<button type="submit" id="submitButton">Pay Bills</button>';
238  link2govForm += '</form>';
239
240if (tableSelector == "myFines") {
241  /*** 4.5 selector ***/
242  //$J('table[id^="finesTable_personal"]').after('<div class="paymentForm">'+link2govForm+'</div>');
243  /*** 5.0.1 selector ***/
244/*if(!com_sirsi_ent_page.isMobile){
245  $J('.payFinesPanel div[id^="finesTable_personal"]').after('<div class="paymentForm">'+link2govForm+'</div>');
246}
247else{ 
248   /***JTN, 2020 Nov 10: customer asked for mobile appearance of Pay Bills button. With adjustments to the building of 
249    the lineItems, working so far.  Comment out below if problems with mobile use.***/
250/*    $J('.myFines').append('<div class="paymentForm">'+link2govForm+'</div>');
251
252}
253}
254/*else if (tableSelector == "groupFines") {
255  $J('.payFinesPanel div[id^="finesTable_group"]').after('<div class="paymentForm">'+link2govForm+'</div>');
256  //$J('.'+tableSelector+' .paymentButton').show();
257  $J('.groupFines table.bottomOfFinesTable::after').css("content", "");
258}*/
259
260/*$J('.checkboxCol').remove();
261$J('.myFines .selectAll').remove();
262$J('.finesSelectAll_div').remove();
263$J('.finesSelected').attr('colspan','2');
264
265//} // end temp conditional to limit access to one account
266
267} // end addPaymentButton function
268
269function getBillInformation () {
270
271	var identifier = com_sirsi_ent_widgets.UserID;
272	
273	//var scriptUrl = 'https://catalog.colapl.org/uhtbin/getBillInformation.pl';
274	//var scriptUrl = 'https://sym-epoch.sirsi.net/uhtbin/getBillInformation.pl';
275	var scriptUrl = 'https://datas-1.sirsi.net/CTS/COLA/getBillInformation.pl';
276	var data = 'identifier='+identifier;
277	var request = $J.ajax({
278	  url: scriptUrl,
279	  headers: {'Content-Type' : 'application/x-www-form-urlencoded'},
280	  method: "POST",
281	  data: data,
282	  crossDomain: true,
283	  processData: false,
284	  dataType: "text"
285	});
286	 
287	request.done(function( billinfo ) {
288	  var billInfo = billinfo;
289	  var totalBillAmt = billInfo.split('|')[1];
290          if (totalBillAmt > 0) {
291	    addPaymentButton (billInfo,totalBillAmt,"myFines");
292          }
293	  
294	});
295	 
296	request.fail(function( jqXHR, textStatus ) {
297	  //console.log( "Request failed message from AJAX: " + textStatus );
298	});
299	
300}
301/** END CUSTOM - Custom Online Payment **/
302
303/** custom user registration ***/
304jQuery(document).ready(function() {
305  setTimeout(function() {
306console.log(jQuery('#loginPageForm #registration_link').attr('rel'));
307    jQuery('#loginPageForm #registration_link').attr('rel', jQuery('#loginPageForm #registration_link').attr('rel').replace(' noreferrer',''));
308  }, 250);
309});
310
311function swapIcons(){
312  $J('img[src="/client/images/search-icons/list.png"]').attr('src','/custom/web/custom-icons/list.png');
313  $J('img[src="/client/images/search-icons/thumbnails.png"]').attr('src','/custom/web/custom-icons/thumbnails.png');
314  $J('img[src$="/client/images/account-icons/mylists.png"]').attr('src','/custom/web/custom-icons/mylists.png');
315  $J('.myListControls input[src$="/client/images/action-icons/addlist.png"]').attr('src','/custom/web/custom-icons/addlist.png');
316  $J('.myListControls input[src$="/client/images/action-icons/deletelist.png"]').attr('src','/custom/web/custom-icons/deletelist.png');
317}
318
319function customDetailJavaScript(detail){
320setTimeout(function(){
321$J('img[src="/client/images/arrow-right.png"]').attr('src','/custom/web/custom-icons/arrow-right.png');
322$J('img[src="/client/images/arrow-left.png"]').attr('src','/custom/web/custom-icons/arrow-left.png');
323
324},100);
325}
326
327function relabelQS(){
328  var curLang=window.location.pathname.split('/')[2];
329  if(curLang=='zh_CN'){
330     $J('.quicksearch_display_button a:contains("New Fiction")').text('最新小說');
331     $J('.quicksearch_display_button a:contains("New Nonfiction")').text('最新非小說');
332     $J('.quicksearch_display_button a:contains("New DVDs")').text('最新');
333     $J('.quicksearch_display_button a:contains("New Music")').text('最新音樂');
334     $J('.quicksearch_display_button a:contains("New Books on CD")').text('最新有聲書');
335
336  }
337  else if(curLang=='es_ES'){
338     $J('.quicksearch_display_button a:contains("New Fiction")').text(html_entities('Ficci&oacuten Nueva'));
339     $J('.quicksearch_display_button a:contains("New Nonfiction")').text('Nuevos De Consulta');
340     $J('.quicksearch_display_button a:contains("New DVDs")').text('DVD Nuevos');
341     $J('.quicksearch_display_button a:contains("New Music")').text(html_entities('M&uacutesica Nueva'));
342     $J('.quicksearch_display_button a:contains("New Books on CD")').text('Libros Nuevos en CD');
343
344  }
345 }
346
347function html_entities(str){
348    return $J('<textarea />').html(str).text();
349}
350
351/*** SD Custom Boolean/Browse functionality, PSC-8013 ***/
352jQuery.getScript('/custom/web/boolbrws.js');
353jQuery(document).ready(function() {
354    if (/boolean/.test(window.location.pathname) || /advanced/.test(window.location.pathname)) {
355      jQuery('#content').css('margin-top','1rem');
356      setTimeout(function() {
357        jQuery('#searchBoxWrapper').remove();
358      }, 200);
359    }
360  });
361
362/* SD Custom Laptop/Hotspot holds, SR-45335 */
363if (/josh/.test(window.location.pathname)) {
364  jQuery.getScript('/custom/web/sd_equipment_holds.js');
365}
366
367
368// SR-62569 PayFlow Terms and Conditions Link
369  function  updatePaymentTermsLink () {
370      $J('#showTermsAndConditionsLink').removeAttr('onclick');
371      $J('#showTermsAndConditionsLink').attr('href','https://lacountylibrary.org/terms-of-payment/');
372      $J('#showTermsAndConditionsLink').attr('target','_blank');
373  }
374
375
376/****GOOGLE ANALYTICS****/
377const script1 = document.createElement('script');
378script1.setAttribute('async', '');
379script1.setAttribute('src', 'https://www.googletagmanager.com/gtag/js?i
379d=G-V80GT0ELT0');
380document.head.appendChild(script1);
381
382const script2 = document.createElement('script');
383script2.innerHTML = `
vendor: 129 bytes, lines 383-387
383window.dataLayer = window.dataLayer || [];
384function gtag(){ dataLayer.push(arguments);}
385
386gtag('js', new Date());
387gtag('config', '
387G-V80GT0ELT0
vendor: 3 bytes, line 387
387');
387`;
388document.head.appendChild(script2);
389
390/*** SD Custom Sort Volume Hold Dropdown functionality, PSC-8113 ***/
391/*if (/^josh$/.test(window.location.pathname.split("/client/")[1].split("/")[1])) {*/
392    const customVolSortJS = document.createElement('script');
393    customVolSortJS.src = '/custom/web/volsort.js';
394    customVolSortJS.defer = true;
395    document.head.appendChild(customVolSortJS);
396/*}*/

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.