Changeset 36071 for main/trunk/greenstone3/web/interfaces/default/js/favouritebasket/favouritecheckout.js
- Timestamp:
- 2022-02-22T13:57:30+13:00 (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/interfaces/default/js/favouritebasket/favouritecheckout.js
r36069 r36071 4 4 var source_link_collections = new Array(); // or add list of collections like ["pdfberry", "mgppdemo"]; 5 5 var document_link_collections = new Array(); // or add list of collections as above. 6 //these are the default metadata items used by berrybaskets.6 //these are the default metadata items used by favourite baskets. 7 7 var default_metas = ["Title", "root_Title", "root_assocfilepath", "root_srclinkFile", "name", "collection", "Date"]; 8 8 … … 10 10 var urlonly = false; 11 11 var mailinfo = new Array(); 12 mailinfo['address'] = gs.text. berry.to;13 mailinfo['cc'] = gs.text. berry.cc;14 mailinfo['bcc'] = gs.text. berry.bcc;15 mailinfo['subject'] = gs.text. berry.subject;12 mailinfo['address'] = gs.text.favourites.to; 13 mailinfo['cc'] = gs.text.favourites.cc; 14 mailinfo['bcc'] = gs.text.favourites.bcc; 15 mailinfo['subject'] = gs.text.favourites.subject; 16 16 var textwin; 17 17 var mailwin; 18 18 19 19 var options = ['fullview', 'textview', 'email']; 20 21 function toggleSelectAll(selAllCheckbox) { 22 // https://stackoverflow.com/questions/386281/how-to-implement-select-all-check-box-in-html 23 var allBerriesCheckboxList = document.getElementsByName('select-berry-checkbox'); 24 for (var i = 0; i < allBerriesCheckboxList.length; i++) { 25 // if the selectAllCheckbox is checked, then all the berries' checkboxes will get checked 26 // And vice-versa. 27 allBerriesCheckboxList[i].checked = selAllCheckbox.checked; 28 } 29 } 30 31 function deleteSelected() { 32 33 if(docList.length == 0) return; // no berries on page, nothing to delete 34 35 // https://stackoverflow.com/questions/590018/getting-all-selected-checkboxes-in-an-array 36 // https://www.w3schools.com/jsref/met_document_queryselectorall.asp 37 // https://www.w3schools.com/cssref/css_selectors.asp 38 var selectedList = document.querySelectorAll('input[name=select-berry-checkbox]:checked'); 39 if(selectedList.length == 0) return; // nothing selected, so nothing to delete 40 41 // if all berries selected for deletion, can optimise 42 if(selectedList.length === docList.length) { 43 deleteAll(); 44 return; // done! 45 } 46 47 // otherwise selected list of berries is a proper subset of total berries (berries in docList) 48 var idsToDelete = []; 49 50 // construct the deletion url by concatenating the ids with | which is %7C in URL-encoded form 51 var delurl = delurlPath; // var delurlPath is declared in ygDDPlayer.js. 52 53 for(var i = 0; i < selectedList.length; i++) { 54 selected_id = selectedList[i].id; 55 // Format of checkbox id: "<docid>-checkbox" 56 var end = selected_id.indexOf("-checkbox"); 57 var doc_id = selected_id.substring(0, end); 58 59 idsToDelete[i] = doc_id; 60 61 // Now just need to append each doc_id to the deletion URL separated by |, 62 // but this character needs to be URL encoded, else the delete doesn't work. 63 if((i+1) == selectedList.length) { // if it's the last id to process, don't append separator 64 delurl += doc_id; 65 } else { // there's more ids to process, so append separator 66 delurl += doc_id + "%7C"; // url-encoded version of | 67 } 68 69 } 70 71 var delAll = false; 72 doDelete(delAll, delurl, selectedList, idsToDelete); 73 } 20 var delurlPath = gs.xsltParams.library_name + "?a=pr&rt=r&ro=1&s=DeleteItems&c=&o=XML&hhf="+makeURLComponentSafe("[{\"name\":\"Cache-Control\", \"value\":\"no-cache\"}]")+"&s1.items="; 21 var request_type = "GET"; // the default 22 74 23 75 24 function deleteAll() { … … 77 26 if(docList.length == 0) return; // nothing to delete 78 27 79 var delurl = delurlPath; // var delurlPath is declared in ygDDPlayer.js.28 var delurl = delurlPath; 80 29 // Just need to append each doc id separated by |, but this character needs to be URL encoded, 81 30 // else the delete doesn't work. … … 96 45 } 97 46 47 function deleteFavouriteFromCheckout(el) 48 { 49 var delurl = delurlPath; 50 51 var doc_id = el.getAttribute('id'); 52 delurl += doc_id; 53 54 var deleteAll = false; 55 var selectedList = [ el ]; 56 var idsToDelete = [ doc_id ]; 57 doDelete(deleteAll, delurl, selectedList, idsToDelete); 58 } 98 59 99 60 function doDelete(deleteAll, delurl, selectedList, idsToDelete) { // given list of selected checkboxes … … 180 141 } 181 142 182 function deleteFavouriteFromCheckout(el) 183 { 184 var delurl = delurlPath; // var delurlPath is declared in ygDDPlayer.js. 185 186 var doc_id = el.getAttribute('id'); 187 delurl += doc_id; 188 189 var deleteAll = false; 190 var selectedList = [ el ]; 191 var idsToDelete = [ doc_id ]; 192 doDelete(deleteAll, delurl, selectedList, idsToDelete); 193 } 194 195 143 144 // switch between Full, Text and Email views 196 145 function navigate(e){ 197 146 … … 227 176 urlonly = false; 228 177 229 this.value=gs.text. berry.url_only;178 this.value=gs.text.favourites.url_only; 230 179 231 180 populateUrlsAndMetadata(parea); … … 240 189 urlonly = true; 241 190 242 this.value=gs.text. berry.url_and_metadata;191 this.value=gs.text.favourites.url_and_metadata; 243 192 244 193 return; … … 288 237 289 238 function showFullView() { 290 if (gs.cgiParams.berrybasket == "on") {291 showFullViewBerries();292 }293 else {294 // assumption is that favouritebasket is on295 239 showFullViewFavourites(); 296 }297 240 } 298 241 299 242 function emptyBasketText() { 300 if (gs.cgiParams.berrybasket == "on") {301 return document.createTextNode(gs.text.berry.empty_basket);302 } else {303 // assume favourites304 243 return document.createTextNode(gs.text.favourites.empty_basket); 305 } 306 } 307 308 function showFullViewBerries(){ 309 310 var content = YAHOO.util.Dom.get('berryBasketContent'); 311 var fullview = YAHOO.util.Dom.get('fullview'); 312 berryCheckoutPageClear(); 313 314 if (docList.length == 0){ 315 content.appendChild(emptyBasketText()); 316 return; 317 } 318 319 var trashbin = document.createElement('div'); 320 trashbin.id ='trashbin'; 321 322 var binhandle = document.createElement('div'); 323 binhandle.id = 'binhandle'; 324 binhandle.appendChild(document.createElement('span')); 325 trashbin.appendChild(binhandle); 326 content.appendChild(trashbin); 327 328 var dd = new ygDDOnTop('trashbin'); 329 dd.setHandleElId('binhandle'); 330 new YAHOO.util.DDTarget('trashbin','trash'); 331 332 var dlist = document.createElement('div'); 333 content.appendChild(dlist); 334 var ol = document.createElement('ol'); 335 dlist.appendChild(ol); 336 337 ol.setAttribute("id", "berryDocsList"); 338 339 for (var i in docList){ 340 var doc = docList[i]; 341 var li = document.createElement('li'); 342 var img = document.createElement('img'); 343 var text =""; 344 345 var doc_id = doc['collection']+":"+ doc['name']; 346 347 img.setAttribute("src", berry_icon); 348 img.setAttribute("id", doc_id); 349 img.setAttribute("height", "15px"); 350 img.setAttribute("width", "15px"); 351 li.appendChild(img); 352 353 generateDocDisplay(li, doc, doc_id) 354 li.className = 'berrydoc'; 355 ol.appendChild(li); 356 new ygDDPlayer(img.id,'trash',docList); 357 } 358 359 } 244 } 245 360 246 361 247 function showFullViewFavourites(){ … … 492 378 input.setAttribute("class", "sendbutton"); 493 379 input.setAttribute("type", "button"); 494 input.setAttribute("value", gs.text. berry.send);380 input.setAttribute("value", gs.text.favourites.send); 495 381 content.appendChild(input); 496 382 } … … 554 440 input.setAttribute("class", "sendbutton"); 555 441 input.setAttribute("type", "button"); 556 input.setAttribute("value", gs.text. berry.send);442 input.setAttribute("value", gs.text.favourites.send); 557 443 content.appendChild(input); 558 444 … … 569 455 if (urlonly) 570 456 { 571 cb.value=gs.text. berry.url_and_metadata;457 cb.value=gs.text.favourites.url_and_metadata; 572 458 } 573 459 else 574 460 { 575 cb.value=gs.text. berry.url_only;461 cb.value=gs.text.favourites.url_only; 576 462 } 577 463 … … 668 554 var metadata = ""; 669 555 if (doc['Title']) { 670 metadata += gs.text. berry.doc_title+": "+doc['Title']+"\n";556 metadata += gs.text.favourites.doc_title+": "+doc['Title']+"\n"; 671 557 } 672 558 if (doc['root_Title']) { 673 metadata += gs.text. berry.doc_root_title+": "+doc['root_Title']+"\n";559 metadata += gs.text.favourites.doc_root_title+": "+doc['root_Title']+"\n"; 674 560 675 561 } 676 562 if (doc['name']) { 677 metadata += gs.text. berry.doc_name+": "+doc['name']+"\n";563 metadata += gs.text.favourites.doc_name+": "+doc['name']+"\n"; 678 564 } 679 565 if (doc['collection']) { 680 metadata += gs.text. berry.doc_collection+": "+doc['collection']+"\n";566 metadata += gs.text.favourites.doc_collection+": "+doc['collection']+"\n"; 681 567 } 682 568 if (doc['Date']) { 683 metadata += gs.text. berry.doc_date+": "+doc['Date']+"\n";569 metadata += gs.text.favourites.doc_date+": "+doc['Date']+"\n"; 684 570 } 685 571 // allow for inclusion of custom metadata … … 711 597 712 598 if(to_address.trim() === "") { 713 alert(gs.text. berry.invalid_to_address_empty);599 alert(gs.text.favourites.invalid_to_address_empty); 714 600 return; 715 601 } else if(to_address.indexOf('@') === -1) { 716 alert(gs.text. berry.invalid_to_address);602 alert(gs.text.favourites.invalid_to_address); 717 603 return; 718 604 } else if(content.trim() === "") { 719 alert(gs.text. berry.invalid_msg_body_empty);605 alert(gs.text.favourites.invalid_msg_body_empty); 720 606 return; 721 607 } … … 735 621 success: function(o) { 736 622 var result = o.responseText; 737 alert(gs.text. berry.send_success);623 alert(gs.text.favourites.send_success); 738 624 } , 739 625 failure: function(o) { 740 alert(gs.text. berry.send_fail);626 alert(gs.text.favourites.send_fail); 741 627 } 742 628 }
Note:
See TracChangeset
for help on using the changeset viewer.