Line 0
Link Here
|
|
|
1 |
// Extends jQuery API |
2 |
// http://www.wskidmore.com/downloads/jquery-uniqueArray.min.js |
3 |
jQuery.extend({uniqueArray:function(e){if($.isArray(e)){var c={};var a,b;for(b=0,a=e.length;b<a;b++){var d=e[b].toString();if(c[d]){e.splice(b,1);a--;b--}else{c[d]=true}}}return(e)}}); |
4 |
|
5 |
function removeByValue(arr, val) { |
6 |
for(var i=0; i<arr.length; i++) { |
7 |
if(arr[i] == val) { |
8 |
arr.splice(i, 1); |
9 |
break; |
10 |
} |
11 |
} |
12 |
} |
13 |
|
14 |
function paramOfUrl( url, param ) { |
15 |
param = param.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); |
16 |
var regexS = "[\\?&]"+param+"=([^&#]*)"; |
17 |
var regex = new RegExp( regexS ); |
18 |
var results = regex.exec( url ); |
19 |
if( results == null ) { |
20 |
return ""; |
21 |
} else { |
22 |
return results[1]; |
23 |
} |
24 |
} |
25 |
|
26 |
function addBibToContext( bibnum ) { |
27 |
var bibnums = getContextBiblioNumbers(); |
28 |
bibnums.push(bibnum); |
29 |
setContextBiblioNumbers( bibnums ); |
30 |
//var store = sessionStorage.getItem( "bibs_selected" ); |
31 |
} |
32 |
|
33 |
function delBibToContext( bibnum ) { |
34 |
var bibnums = getContextBiblioNumbers(); |
35 |
removeByValue( bibnums, bibnum ); |
36 |
setContextBiblioNumbers( $.uniqueArray( bibnums ) ); |
37 |
} |
38 |
|
39 |
function setContextBiblioNumbers( bibnums ) { |
40 |
//sessionStorage.setItem("bibs_selected", JSON.stringify( bibnums ) ); |
41 |
$.cookie('bibs_selected', JSON.stringify( bibnums )); |
42 |
} |
43 |
|
44 |
function getContextBiblioNumbers() { |
45 |
//var r = sessionStorage.getItem("bibs_selected"); |
46 |
var r = $.cookie('bibs_selected'); |
47 |
if ( r ) { |
48 |
return JSON.parse(r); |
49 |
} |
50 |
r = new Array(); |
51 |
return r; |
52 |
} |
53 |
|
54 |
function resetSearchContext() { |
55 |
setContextBiblioNumbers( new Array() ); |
56 |
} |
57 |
|
58 |
$(document).ready(function(){ |
59 |
// forms with action leading to search |
60 |
$("form[action*='opac-search.pl']").submit(function(){ |
61 |
resetSearchContext(); |
62 |
}); |
63 |
// any link to launch a search except navigation links |
64 |
$("[href*='opac-search.pl?']").not(".nav").not('.searchwithcontext').click(function(){ |
65 |
resetSearchContext(); |
66 |
}); |
67 |
// any link to a detail page from the results page. |
68 |
$("#bookbag_form a[href*='opac-detail.pl?']").click(function(){ |
69 |
resetSearchContext(); |
70 |
}); |
71 |
}); |