|
Lines 1-4
Link Here
|
| 1 |
/* global __ */ |
1 |
/* global __ getContextBiblioNumbers */ |
|
|
2 |
/* exported readCookie readCookieValue SelectAll addMultiple selRecord delSingleRecord delBasket quit sendBasket downloadBasket printBasket showMore showLess openBiblio addSelToShelf vShelfAdd */ |
| 2 |
|
3 |
|
| 3 |
////////////////////////////////////////////////////////////////////////////// |
4 |
////////////////////////////////////////////////////////////////////////////// |
| 4 |
// BASIC FUNCTIONS FOR COOKIE MANAGEMENT // |
5 |
// BASIC FUNCTIONS FOR COOKIE MANAGEMENT // |
|
Lines 9-24
var CGIBIN = "/cgi-bin/koha/";
Link Here
|
| 9 |
var nameCookie = "intranet_bib_list"; |
10 |
var nameCookie = "intranet_bib_list"; |
| 10 |
var nameParam = "bib_list"; |
11 |
var nameParam = "bib_list"; |
| 11 |
var valCookie = readCookie(nameCookie); |
12 |
var valCookie = readCookie(nameCookie); |
|
|
13 |
var basketcount; |
| 12 |
|
14 |
|
| 13 |
if(valCookie){ |
15 |
if(valCookie){ |
| 14 |
var arrayRecords = valCookie.split("/"); |
16 |
var arrayRecords = valCookie.split("/"); |
| 15 |
if(arrayRecords.length > 0){ |
17 |
if(arrayRecords.length > 0){ |
| 16 |
var basketcount = arrayRecords.length-1; |
18 |
basketcount = arrayRecords.length-1; |
| 17 |
} else { |
19 |
} else { |
| 18 |
var basketcount = ""; |
20 |
basketcount = ""; |
| 19 |
} |
21 |
} |
| 20 |
} else { |
22 |
} else { |
| 21 |
var basketcount = ""; |
23 |
basketcount = ""; |
| 22 |
} |
24 |
} |
| 23 |
|
25 |
|
| 24 |
function writeCookie(name, val, wd) { |
26 |
function writeCookie(name, val, wd) { |
|
Lines 39-45
function readCookieValue (str, val_beg) {
Link Here
|
| 39 |
|
41 |
|
| 40 |
function readCookie(name, wd) { |
42 |
function readCookie(name, wd) { |
| 41 |
var str_name = name + "="; |
43 |
var str_name = name + "="; |
| 42 |
var str_len = str_name.length; |
|
|
| 43 |
var str_cookie = ""; |
44 |
var str_cookie = ""; |
| 44 |
if (wd) { |
45 |
if (wd) { |
| 45 |
str_cookie = parent.opener.document.cookie; |
46 |
str_cookie = parent.opener.document.cookie; |
|
Lines 47-59
function readCookie(name, wd) {
Link Here
|
| 47 |
else { |
48 |
else { |
| 48 |
str_cookie = parent.document.cookie; |
49 |
str_cookie = parent.document.cookie; |
| 49 |
} |
50 |
} |
| 50 |
// fixed - getting the part of the basket that is bib_list |
51 |
// fixed - getting the part of the basket that is bib_list |
| 51 |
var cookie_parts = str_cookie.split(";"); |
52 |
var cookie_parts = str_cookie.split(";"); |
| 52 |
for(var i=0;i < cookie_parts.length;i++) { |
53 |
for(var i=0;i < cookie_parts.length;i++) { |
| 53 |
var c = cookie_parts[i]; |
54 |
var c = cookie_parts[i]; |
| 54 |
while (c.charAt(0)==' ') c = c.substring(1,c.length); |
55 |
while (c.charAt(0)==' ') c = c.substring(1,c.length); |
| 55 |
if(c.indexOf(str_name) === 0) return c.substring(str_name.length,c.length); |
56 |
if(c.indexOf(str_name) === 0) return c.substring(str_name.length,c.length); |
| 56 |
} |
57 |
} |
| 57 |
return null; |
58 |
return null; |
| 58 |
} |
59 |
} |
| 59 |
|
60 |
|
|
Lines 61-69
function delCookie(name) {
Link Here
|
| 61 |
var exp = new Date(); |
62 |
var exp = new Date(); |
| 62 |
exp.setTime(exp.getTime()-1); |
63 |
exp.setTime(exp.getTime()-1); |
| 63 |
if(parent.opener){ |
64 |
if(parent.opener){ |
| 64 |
parent.opener.document.cookie = name + "=null; path=/; expires=" + exp.toGMTString(); |
65 |
parent.opener.document.cookie = name + "=null; path=/; expires=" + exp.toGMTString(); |
| 65 |
} else { |
66 |
} else { |
| 66 |
document.cookie = name + "=null; path=/; expires=" + exp.toGMTString(); |
67 |
document.cookie = name + "=null; path=/; expires=" + exp.toGMTString(); |
| 67 |
} |
68 |
} |
| 68 |
} |
69 |
} |
| 69 |
|
70 |
|
|
Lines 139-156
function addRecord(val, selection,NoMsgAlert) {
Link Here
|
| 139 |
} |
140 |
} |
| 140 |
|
141 |
|
| 141 |
function AllAreChecked(s){ |
142 |
function AllAreChecked(s){ |
| 142 |
if (! s.length) { return false;} |
143 |
if (! s.length){ return false;} |
| 143 |
var l = s.length; |
144 |
var l = s.length; |
| 144 |
for (var i=0; i < l; i++) { |
145 |
for (var i=0; i < l; i++) { |
| 145 |
if(! s[i].checked) { return false; } |
146 |
if(! s[i].checked) { return false; } |
| 146 |
} |
147 |
} |
| 147 |
return true; |
148 |
return true; |
| 148 |
} |
149 |
} |
| 149 |
|
150 |
|
| 150 |
function SelectAll(){ |
151 |
function SelectAll(){ |
| 151 |
if(document.bookbag_form.biblionumber.length > 0) { |
152 |
if(document.bookbag_form.biblionumber.length > 0) { |
| 152 |
var checky = AllAreChecked(document.bookbag_form.biblionumber); |
153 |
var checky = AllAreChecked(document.bookbag_form.biblionumber); |
| 153 |
var l = document.bookbag_form.biblionumber.length; |
154 |
var l = document.bookbag_form.biblionumber.length; |
| 154 |
for (var i=0; i < l; i++) { |
155 |
for (var i=0; i < l; i++) { |
| 155 |
document.bookbag_form.biblionumber[i].checked = (checky) ? false : true; |
156 |
document.bookbag_form.biblionumber[i].checked = (checky) ? false : true; |
| 156 |
} |
157 |
} |
|
Lines 159-166
function SelectAll(){
Link Here
|
| 159 |
|
160 |
|
| 160 |
function addMultiple(biblist){ |
161 |
function addMultiple(biblist){ |
| 161 |
var c_value = ""; |
162 |
var c_value = ""; |
|
|
163 |
var i = 0; |
| 162 |
if( biblist && biblist.length > 0 ) { |
164 |
if( biblist && biblist.length > 0 ) { |
| 163 |
for (var i=0; i < biblist.length; i++) { |
165 |
for ( i=0; i < biblist.length; i++ ) { |
| 164 |
if (biblist[i].checked) { |
166 |
if (biblist[i].checked) { |
| 165 |
c_value = c_value + biblist[i].value + "/"; |
167 |
c_value = c_value + biblist[i].value + "/"; |
| 166 |
} |
168 |
} |
|
Lines 168-179
function addMultiple(biblist){
Link Here
|
| 168 |
} else { |
170 |
} else { |
| 169 |
var bibnums = getContextBiblioNumbers(); |
171 |
var bibnums = getContextBiblioNumbers(); |
| 170 |
if ( bibnums.length > 0 ) { |
172 |
if ( bibnums.length > 0 ) { |
| 171 |
for ( var i = 0 ; i < bibnums.length ; i++ ) { |
173 |
for ( i = 0 ; i < bibnums.length ; i++ ) { |
| 172 |
c_value = c_value + bibnums[i] + "/"; |
174 |
c_value = c_value + bibnums[i] + "/"; |
| 173 |
} |
175 |
} |
| 174 |
} else { |
176 |
} else { |
| 175 |
if(document.bookbag_form.biblionumber.length > 0) { |
177 |
if(document.bookbag_form.biblionumber.length > 0) { |
| 176 |
for (var i=0; i < document.bookbag_form.biblionumber.length; i++) { |
178 |
for ( i=0; i < document.bookbag_form.biblionumber.length; i++ ) { |
| 177 |
if (document.bookbag_form.biblionumber[i].checked) { |
179 |
if (document.bookbag_form.biblionumber[i].checked) { |
| 178 |
c_value = c_value + document.bookbag_form.biblionumber[i].value + "/"; |
180 |
c_value = c_value + document.bookbag_form.biblionumber[i].value + "/"; |
| 179 |
} |
181 |
} |
|
Lines 186-193
function addMultiple(biblist){
Link Here
|
| 186 |
addSelRecords(c_value); |
188 |
addSelRecords(c_value); |
| 187 |
} |
189 |
} |
| 188 |
|
190 |
|
| 189 |
function addSelRecords(valSel) { // function for adding a selection of biblios to the basket |
191 |
/* function for adding a selection of biblios to the basket |
| 190 |
// from the results list |
192 |
from the results list */ |
|
|
193 |
function addSelRecords(valSel) { |
| 191 |
var arrayRecords = valSel.split("/"); |
194 |
var arrayRecords = valSel.split("/"); |
| 192 |
var i = 0; |
195 |
var i = 0; |
| 193 |
var nbAdd = 0; |
196 |
var nbAdd = 0; |
|
Lines 218-236
function addSelRecords(valSel) { // function for adding a selection of biblios t
Link Here
|
| 218 |
msg = __("No item was added to your cart (already in your cart)!"); |
221 |
msg = __("No item was added to your cart (already in your cart)!"); |
| 219 |
} |
222 |
} |
| 220 |
} |
223 |
} |
| 221 |
showCartUpdate(msg); |
224 |
showCartUpdate(msg); |
| 222 |
} |
225 |
} |
| 223 |
|
226 |
|
| 224 |
function showCartUpdate(msg){ |
227 |
function showCartUpdate(msg){ |
| 225 |
// set body of popup window |
228 |
// set body of popup window |
| 226 |
$("#cartDetails").html(msg); |
229 |
$("#cartDetails").html(msg); |
| 227 |
showCart(); |
230 |
showCart(); |
| 228 |
setTimeout(hideCart,2000); |
231 |
setTimeout(hideCart,2000); |
| 229 |
} |
232 |
} |
| 230 |
|
233 |
|
| 231 |
function showListsUpdate(msg){ |
234 |
function showListsUpdate(msg){ |
| 232 |
// set body of popup window |
235 |
// set body of popup window |
| 233 |
alert(msg); |
236 |
alert(msg); |
| 234 |
} |
237 |
} |
| 235 |
|
238 |
|
| 236 |
function selRecord(num, status) { |
239 |
function selRecord(num, status) { |
|
Lines 261-267
function delSelRecords() {
Link Here
|
| 261 |
var recordsSel = 0; |
264 |
var recordsSel = 0; |
| 262 |
var end = 0; |
265 |
var end = 0; |
| 263 |
var valCookie = readCookie(nameCookie, 1); |
266 |
var valCookie = readCookie(nameCookie, 1); |
| 264 |
|
267 |
var s; |
| 265 |
if (valCookie) { |
268 |
if (valCookie) { |
| 266 |
var str = document.myform.records.value; |
269 |
var str = document.myform.records.value; |
| 267 |
if (str.length > 0){ |
270 |
if (str.length > 0){ |
|
Lines 270-276
function delSelRecords() {
Link Here
|
| 270 |
while (!end){ |
273 |
while (!end){ |
| 271 |
s = str.indexOf("/"); |
274 |
s = str.indexOf("/"); |
| 272 |
if (s>0){ |
275 |
if (s>0){ |
| 273 |
num = str.substring(0, s); |
276 |
var num = str.substring(0, s); |
| 274 |
str = delRecord(num,str); |
277 |
str = delRecord(num,str); |
| 275 |
str2 = delRecord(num,str2); |
278 |
str2 = delRecord(num,str2); |
| 276 |
updateLink(num,"del",top.opener); |
279 |
updateLink(num,"del",top.opener); |
|
Lines 331-337
function delRecord (n, s) {
Link Here
|
| 331 |
return s; |
334 |
return s; |
| 332 |
} |
335 |
} |
| 333 |
|
336 |
|
| 334 |
|
|
|
| 335 |
function delBasket(context,rep) { |
337 |
function delBasket(context,rep) { |
| 336 |
if (rep === undefined){ |
338 |
if (rep === undefined){ |
| 337 |
rep = confirm(__("Are you sure you want to empty your cart?")); |
339 |
rep = confirm(__("Are you sure you want to empty your cart?")); |
|
Lines 350-356
function delBasket(context,rep) {
Link Here
|
| 350 |
} |
352 |
} |
| 351 |
} |
353 |
} |
| 352 |
|
354 |
|
| 353 |
|
|
|
| 354 |
function quit() { |
355 |
function quit() { |
| 355 |
if (document.myform.records.value) { |
356 |
if (document.myform.records.value) { |
| 356 |
var rep = false; |
357 |
var rep = false; |
|
Lines 370-376
function sendBasket() {
Link Here
|
| 370 |
var loc = CGIBIN + "basket/sendbasket.pl?" + strCookie; |
371 |
var loc = CGIBIN + "basket/sendbasket.pl?" + strCookie; |
| 371 |
|
372 |
|
| 372 |
var optWin="scrollbars=no,resizable=no,height=400,width=650,top=50,left=100"; |
373 |
var optWin="scrollbars=no,resizable=no,height=400,width=650,top=50,left=100"; |
| 373 |
var win_form = open(loc,"win_form",optWin); |
374 |
open(loc,"win_form",optWin); |
| 374 |
} |
375 |
} |
| 375 |
|
376 |
|
| 376 |
function downloadBasket() { |
377 |
function downloadBasket() { |
|
Lines 409-422
function showLess() {
Link Here
|
| 409 |
} |
410 |
} |
| 410 |
|
411 |
|
| 411 |
function updateBasket(updated_value,target) { |
412 |
function updateBasket(updated_value,target) { |
| 412 |
if(target){ |
413 |
if(target){ |
| 413 |
target.$('#basketcount').html(" <span>("+updated_value+")</span>"); |
414 |
target.$('#basketcount').html(" <span>("+updated_value+")</span>"); |
| 414 |
target.$('#cartDetails').html(__("Items in your cart: %s").format(updated_value)); |
415 |
target.$('#cartDetails').html(__("Items in your cart: %s").format(updated_value)); |
| 415 |
} else { |
416 |
} else { |
| 416 |
$('#basketcount').html(" <span>("+updated_value+")</span>"); |
417 |
$('#basketcount').html(" <span>("+updated_value+")</span>"); |
| 417 |
$('#cartDetails').html(__("Items in your cart: %s").format(updated_value)); |
418 |
$('#cartDetails').html(__("Items in your cart: %s").format(updated_value)); |
| 418 |
} |
419 |
} |
| 419 |
var basketcount = updated_value; |
|
|
| 420 |
} |
420 |
} |
| 421 |
|
421 |
|
| 422 |
function openBiblio(openerURL) { |
422 |
function openBiblio(openerURL) { |
|
Lines 426-434
function openBiblio(openerURL) {
Link Here
|
| 426 |
|
426 |
|
| 427 |
function addSelToShelf() { |
427 |
function addSelToShelf() { |
| 428 |
var items = document.getElementById('records').value; |
428 |
var items = document.getElementById('records').value; |
| 429 |
if(items){ |
429 |
if(items){ |
| 430 |
document.location = "/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?biblionumber="+items; |
430 |
document.location = "/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?biblionumber="+items; |
| 431 |
} else { |
431 |
} else { |
| 432 |
alert(__("No item was selected")); |
432 |
alert(__("No item was selected")); |
| 433 |
} |
433 |
} |
| 434 |
} |
434 |
} |
|
Lines 437-444
function addSelToShelf() {
Link Here
|
| 437 |
|
437 |
|
| 438 |
function vShelfAdd(biblist) { |
438 |
function vShelfAdd(biblist) { |
| 439 |
var bibs = new Array; |
439 |
var bibs = new Array; |
|
|
440 |
var i; |
| 440 |
if( biblist && biblist.length > 0 ) { |
441 |
if( biblist && biblist.length > 0 ) { |
| 441 |
for (var i=0; i < biblist.length; i++) { |
442 |
for ( i=0; i < biblist.length; i++ ) { |
| 442 |
if (biblist[i].checked) { |
443 |
if (biblist[i].checked) { |
| 443 |
bibs.push("biblionumber=" + biblist[i].value); |
444 |
bibs.push("biblionumber=" + biblist[i].value); |
| 444 |
} |
445 |
} |
|
Lines 448-454
function vShelfAdd(biblist) {
Link Here
|
| 448 |
} else { |
449 |
} else { |
| 449 |
var bibnums = getContextBiblioNumbers(); |
450 |
var bibnums = getContextBiblioNumbers(); |
| 450 |
if ( bibnums.length > 0 ) { |
451 |
if ( bibnums.length > 0 ) { |
| 451 |
for ( var i = 0 ; i < bibnums.length ; i++ ) { |
452 |
for ( i = 0 ; i < bibnums.length ; i++ ) { |
| 452 |
bibs.push("biblionumber=" + bibnums[i]); |
453 |
bibs.push("biblionumber=" + bibnums[i]); |
| 453 |
} |
454 |
} |
| 454 |
return bibs.join("&"); |
455 |
return bibs.join("&"); |
|
Lines 521-525
$(document).ready(function(){
Link Here
|
| 521 |
e.preventDefault(); |
522 |
e.preventDefault(); |
| 522 |
openBasket(); |
523 |
openBasket(); |
| 523 |
}); |
524 |
}); |
| 524 |
if(basketcount){ updateBasket(basketcount); } |
525 |
if(basketcount){ updateBasket(basketcount); } |
| 525 |
}); |
526 |
}); |
| 526 |
- |
|
|