source: main/trunk/greenstone3/web/interfaces/default/js/berrybasket/berrycheckout.js@ 33345

Last change on this file since 33345 was 33345, checked in by kjdon, 5 years ago

got rid of hard coded empty basket text

File size: 22.7 KB
Line 
1// The default link type in the basket - "document" = greenstone version of the document, "source" = link to source file eg pdf.
2//var default_link_type = "document"; // "source" or "document"
3var default_link_type = "source";
4// use the appropriate one of these to override the default for particular collections.
5var source_link_collections = new Array(); // or add list of collections like ["pdfberry", "mgppdemo"];
6var document_link_collections = new Array(); // or add list of collections as above.
7//these are the default metadata items used by berry baskets.
8var default_metas = ["Title", "root_Title", "root_assocfilepath", "root_srclinkFile", "name", "collection", "Date"];
9
10var docList = new Array();
11var urlonly = false;
12var mailinfo = new Array();
13mailinfo['address'] = gs.text.berry.to;
14mailinfo['cc'] = gs.text.berry.cc;
15mailinfo['bcc'] = gs.text.berry.bcc;
16mailinfo['subject'] = gs.text.berry.subject;
17var textwin;
18var mailwin;
19
20var options = ['fullview', 'textview', 'email'];
21
22function toggleSelectAll(selAllCheckbox) {
23 // https://stackoverflow.com/questions/386281/how-to-implement-select-all-check-box-in-html
24 var allBerriesCheckboxList = document.getElementsByName('select-berry-checkbox');
25 for (var i = 0; i < allBerriesCheckboxList.length; i++) {
26 // if the selectAllCheckbox is checked, then all the berries' checkboxes will get checked
27 // And vice-versa.
28 allBerriesCheckboxList[i].checked = selAllCheckbox.checked;
29 }
30}
31
32function deleteSelected() {
33
34 if(docList.length == 0) return; // no berries on page, nothing to delete
35
36 // https://stackoverflow.com/questions/590018/getting-all-selected-checkboxes-in-an-array
37 // https://www.w3schools.com/jsref/met_document_queryselectorall.asp
38 // https://www.w3schools.com/cssref/css_selectors.asp
39 var selectedList = document.querySelectorAll('input[name=select-berry-checkbox]:checked');
40 if(selectedList.length == 0) return; // nothing selected, so nothing to delete
41
42 // if all berries selected for deletion, can optimise
43 if(selectedList.length === docList.length) {
44 deleteAll();
45 return; // done!
46 }
47
48 // otherwise selected list of berries is a proper subset of total berries (berries in docList)
49 var idsToDelete = [];
50
51 // construct the deletion url by concatenating the ids with | which is %7C in URL-encoded form
52 var delurl = delurlPath; // var delurlPath is declared in ygDDPlayer.js.
53
54 for(var i = 0; i < selectedList.length; i++) {
55 selected_id = selectedList[i].id;
56 // Format of checkbox id: "<docid>-checkbox"
57 var end = selected_id.indexOf("-checkbox");
58 var doc_id = selected_id.substring(0, end);
59
60 idsToDelete[i] = doc_id;
61
62 // Now just need to append each doc_id to the deletion URL separated by |,
63 // but this character needs to be URL encoded, else the delete doesn't work.
64 if((i+1) == selectedList.length) { // if it's the last id to process, don't append separator
65 delurl += doc_id;
66 } else { // there's more ids to process, so append separator
67 delurl += doc_id + "%7C"; // url-encoded version of |
68 }
69
70 }
71
72 var delAll = false;
73 doDelete(delAll, delurl, selectedList, idsToDelete);
74}
75
76function deleteAll() {
77
78 if(docList.length == 0) return; // nothing to delete
79
80 var delurl = delurlPath; // var delurlPath is declared in ygDDPlayer.js.
81 // Just need to append each doc id separated by |, but this character needs to be URL encoded,
82 // else the delete doesn't work.
83
84 for(var i = 0; i < docList.length; i++) {
85 var doc = docList[i];
86 var doc_id = doc['collection']+":"+ doc['name'];
87
88 if((i+1) == docList.length) { // if it's the last id to process, don't append separator
89 delurl += doc_id;
90 } else { // there's more ids to process, so append separator (in URL encoded form!)
91 delurl += doc_id + "%7C"; // url-encoded version of |
92 }
93 }
94
95 var delAll = true;
96 doDelete(delAll, delurl, null, null);
97}
98
99
100function doDelete(deleteAll, delurl, selectedList, idsToDelete) { // given list of selected checkboxes
101
102 // The following is a modified version of methods internal to
103 // ygDDPlayer.js's ygDDPlayer.prototype.onDragDrop
104 var delSuccess = function(o) {
105 var result = o.responseXML;
106
107 if(!deleteAll) { // then we're given a selection to delete: Not deleting all berries, just a subset
108 // Remove id of selected doc to be deleted from docList.
109 // Minor optimisation to double for loop, dependent on ordering of selected berries being
110 // in order of checkboxes (i.e. order of docList ids), and order of docList ids having
111 // the same order as the checkboxes
112 var searchForNextSelectedIdFromIndex = idsToDelete.length-1;
113 for (var i = docList.length - 1; i >= 0; i--) {
114 var berry = docList[i];
115 var berry_id = berry['collection'] + ":" + berry['name'];
116
117 for(var j = searchForNextSelectedIdFromIndex; j >= 0; j--) {
118 if(idsToDelete[j] == berry_id) {
119 docList.splice(i, 1); // i indexes into docList, delete element i from docList
120 searchForNextSelectedIdFromIndex = j-1;
121 break;
122 }
123 }
124 }
125
126 // remove the selected documents' HTML display elements
127 var berryDocsList = YAHOO.util.Dom.get('berryDocsList'); // ordered list item containing the berries
128 for(var i = 0; i < selectedList.length; i++) {
129 var li = selectedList[i].parentNode; // list item parent of checkbox
130 // remove the list item from its containing orderedList
131 berryDocsList.removeChild(li);
132 }
133 }
134
135
136 // if all docs are deleted by this stage, then display "berry basket is empty" message
137 if (deleteAll || !berryDocsList.hasChildNodes()) { // 2nd clause no longer needed?, then this just becomes an else against the first if(!deleteAll) test
138
139 // if deleting all docs, just use the easy way to empty the docList array
140 docList.length = 0; // https://www.jstips.co/en/javascript/two-ways-to-empty-an-array/
141
142 // Removing all child nodes (done one at a time) is more optimal
143 // than setting innerHTML to empty string, see
144 // https://stackoverflow.com/questions/3955229/remove-all-child-elements-of-a-dom-node-in-javascript
145 var content = YAHOO.util.Dom.get('berryBasketContent');
146 while (content.hasChildNodes()) {
147 content.removeChild(content.firstChild);
148 }
149 content.appendChild(emptyBasketText());
150 var berryBasketDelOptions = YAHOO.util.Dom.get('delOptions');
151 if (berryBasketDelOptions != null) {
152 berryBasketDelOptions.setAttribute("style","display:none;");
153 }
154
155 var trashbin = YAHOO.util.Dom.get('trashbin');
156 if ( trashbin !=null){
157 trashbin.style.background = 'url("interfaces/default/images/trash-full.png") 0 0 no-repeat';
158 }
159 }
160
161 var have_checkboxes = YAHOO.util.Dom.get('select-all-checkbox'); // just pick one for the test
162 if (have_checkboxes) {
163 // Ensure the select-all, delete-all and delete-selected checkboxes are deselected
164 YAHOO.util.Dom.get('select-all-checkbox').checked = false;
165 YAHOO.util.Dom.get('delete-selected-checkbox').checked = false;
166 YAHOO.util.Dom.get('delete-all-checkbox').checked = false;
167 }
168 }
169
170 var delFailure = function(o){ alert("Deletion failed" + o);}
171
172 var delcallback = {
173 success:delSuccess,
174 failure:delFailure,
175 argument:null // supposed to be the ygDDPlayer object, but don't have a ref to it here, so trying null
176 }
177
178 // Finally send the actual delete request
179 // request_type defaults to GET, which is what's used for add and del, see ygDDPlayer.js.
180 YAHOO.util.Connect.asyncRequest(request_type, delurl , delcallback);
181}
182
183function deleteFavouriteFromCheckout(el)
184{
185 var delurl = delurlPath; // var delurlPath is declared in ygDDPlayer.js.
186
187 var doc_id = el.getAttribute('id');
188 delurl += doc_id;
189
190 var deleteAll = false;
191 var selectedList = [ el ];
192 var idsToDelete = [ doc_id ];
193 doDelete(deleteAll, delurl, selectedList, idsToDelete);
194}
195
196
197function navigate(e){
198
199 var target = this;
200
201 if ( target.id.toLowerCase() == '' ) {
202 target = target.parentNode;
203 }
204
205 if (target.id.toLowerCase() == 'fullview'){
206 berryCheckoutHighlight( 'fullview' );
207 showFullView();
208 }
209
210 if (target.id.toLowerCase() == 'textview'){
211 berryCheckoutHighlight( 'textview' );
212 showTextView();
213 }
214
215 if (target.id.toLowerCase() == 'email'){
216 berryCheckoutHighlight( 'email' );
217 showEmail();
218 }
219
220 if (target.id.toLowerCase() == 'sendmail'){
221 sendMail();
222 }
223
224 if (target.id.toLowerCase() == 'urlcheck' && urlonly){
225 var urlcheck = YAHOO.util.Dom.get('urlcheck');
226 urlcheck.src = 'interfaces/default/images/check3.gif';
227 var parea =YAHOO.util.Dom.get('pretextarea');
228 urlonly = false;
229
230 this.value=gs.text.berry.url_only;
231
232 populateUrlsAndMetadata(parea);
233 return;
234 }
235
236 if (target.id.toLowerCase() == 'urlcheck' && !urlonly ){
237 var urlcheck = YAHOO.util.Dom.get('urlcheck');
238 urlcheck.src = 'interfaces/default/images/check4.gif';
239 var parea =YAHOO.util.Dom.get('pretextarea');
240 populateUrls(parea);
241 urlonly = true;
242
243 this.value=gs.text.berry.url_and_metadata;
244
245 return;
246 }
247
248 if (target.id.toLowerCase() == 'extextview' ){
249 if (textwin != null){
250 textwin.close();
251 }
252
253 textwin = window.open("","Berry basket plain text view","status=1,width=450,height=300");
254 textwin.moveTo(0,0);
255 var content = document.createElement('div');
256 buildPreview(content);
257 var body = textwin.document.getElementsByTagName('body')[0];
258 body.appendChild(content);
259 var prearea = textwin.document.getElementsByTagName('textarea')[0];
260 prearea.cols = '55';
261 prearea.rows = '15';
262 }
263
264 if (target.id.toLowerCase() == 'exemail' ){
265 if (mailwin != null){
266 mailwin.close();
267 }
268 mailwin = window.open("","Berry basket mail to a friend","status=1,width=450,height=350");
269 mailwin.moveTo(0,0);
270 var content = document.createElement('div');
271 getEmailContent(content);
272 var body = mailwin.document.getElementsByTagName('body')[0];
273 body.appendChild(content);
274 var prearea = mailwin.document.getElementsByTagName('textarea')[0];
275 prearea.cols = '50';
276 prearea.rows = '11';
277 }
278}
279
280function pageLoad(){
281 for(var j = 0; j < options.length; j++)
282 {
283 var ele = document.getElementById(options[j]);
284 YAHOO.util.Event.addListener(ele, 'click', navigate);
285 }
286
287 showFullView();
288}
289
290function showFullView() {
291 if (gs.cgiParams.berrybasket == "on") {
292 showFullViewBerries();
293 }
294 else {
295 // assumption is that favouritebasket is on
296 showFullViewFavourites();
297 }
298}
299
300function emptyBasketText() {
301 if (gs.cgiParams.berrybasket == "on") {
302 return document.createTextNode(gs.text.berry.empty_basket);
303 } else {
304 // assume favourites
305 return document.createTextNode(gs.text.favourites.empty_basket);
306 }
307}
308
309function showFullViewBerries(){
310
311 var content = YAHOO.util.Dom.get('berryBasketContent');
312 var fullview = YAHOO.util.Dom.get('fullview');
313 berryCheckoutPageClear();
314
315 if (docList.length == 0){
316 content.appendChild(emptyBasketText());
317 return;
318 }
319
320 var trashbin = document.createElement('div');
321 trashbin.id ='trashbin';
322
323 var binhandle = document.createElement('div');
324 binhandle.id = 'binhandle';
325 binhandle.appendChild(document.createElement('span'));
326 trashbin.appendChild(binhandle);
327 content.appendChild(trashbin);
328
329 var dd = new ygDDOnTop('trashbin');
330 dd.setHandleElId('binhandle');
331 new YAHOO.util.DDTarget('trashbin','trash');
332
333 var dlist = document.createElement('div');
334 content.appendChild(dlist);
335 var ol = document.createElement('ol');
336 dlist.appendChild(ol);
337
338 ol.setAttribute("id", "berryDocsList");
339
340 for (var i in docList){
341 var doc = docList[i];
342 var li = document.createElement('li');
343 var img = document.createElement('img');
344 var text ="";
345
346 var doc_id = doc['collection']+":"+ doc['name'];
347
348 img.setAttribute("src", berry_icon);
349 img.setAttribute("id", doc_id);
350 img.setAttribute("height", "15px");
351 img.setAttribute("width", "15px");
352 li.appendChild(img);
353
354 generateDocDisplay(li, doc, doc_id)
355 li.className = 'berrydoc';
356 ol.appendChild(li);
357 new ygDDPlayer(img.id,'trash',docList);
358 }
359
360}
361
362function showFullViewFavourites(){
363
364 var content = YAHOO.util.Dom.get('berryBasketContent');
365 var fullview = YAHOO.util.Dom.get('fullview');
366 berryCheckoutPageClear();
367
368 var berryBasketDelOptions = YAHOO.util.Dom.get('delOptions');
369 if (docList.length == 0){
370 content.appendChild(emptyBasketText());
371 if (berryBasketDelOptions != null) {
372 berryBasketDelOptions.setAttribute("style","display:none;");
373 }
374
375 return;
376 }
377 if (berryBasketDelOptions != null) {
378 berryBasketDelOptions.setAttribute("style","display:block;");
379 }
380
381 var dlist = document.createElement('div');
382 content.appendChild(dlist);
383 var ul = document.createElement('ul');
384 dlist.appendChild(ul);
385
386 ul.setAttribute("id", "berryDocsList");
387 ul.setAttribute("style","list-style: none;");
388
389 for (var i in docList){
390 var doc = docList[i];
391 var li = document.createElement('li');
392 var img = document.createElement('img');
393 var text ="";
394
395 var doc_id = doc['collection']+":"+ doc['name'];
396
397 img.setAttribute("src", gs.variables.selected_favourite_icon_url);
398 img.setAttribute("id", doc_id);
399 img.setAttribute("height", "20px");
400 img.setAttribute("width", "20px");
401 img.setAttribute("style","padding-right: 5px;"); // **** better to do this with CSS
402 img.setAttribute("onClick", "deleteFavouriteFromCheckout(this)");
403 li.appendChild(img);
404
405 generateDocDisplay(li, doc, doc_id)
406 li.className = 'berrydoc';
407 ul.appendChild(li);
408 }
409
410}
411
412function generateDocDisplay(li, doc, doc_id) {
413 var a = document.createElement('a');
414 var text="";
415 a.href=generateURL(doc);
416 a.appendChild(document.createTextNode(doc['Title']));
417
418 if (doc['root_Title']){
419 li.appendChild(document.createTextNode(doc['root_Title']+": "));
420 }
421
422 li.appendChild(a);
423 li.appendChild(document.createTextNode(" ("+doc['collection']+")"));
424 var metadata = "";
425 for (var metaItem in doc) {
426 if ( !default_metas.includes(metaItem)){
427 metadata += " "+metaItem+": "+ doc[metaItem]+" ";
428 }
429 }
430 text +=metadata;
431 li.appendChild(document.createTextNode(text));
432
433}
434
435function showTextView(){
436
437 var content = YAHOO.util.Dom.get('berryBasketContent');
438 var textview = YAHOO.util.Dom.get('textview');
439
440 berryCheckoutPageClear();
441 if (docList.length == 0){
442 content.appendChild(emptyBasketText());
443 return;
444 }
445 buildPreview(content);
446
447}
448
449function getEmailContent(content){
450 var item ;
451 var tr;
452 var td;
453 var input;
454
455 table = document.createElement('table');
456 table.setAttribute("class","mailtable");
457
458 for (item in mailinfo){
459 tr = document.createElement('tr');
460 td = document.createElement('td');
461 td.setAttribute("class","mailitem");
462 td.appendChild(document.createTextNode(mailinfo[item]));
463 tr.appendChild(td);
464 td = document.createElement('td');
465 input = document.createElement('input');
466 input.setAttribute("id", item);
467 input.setAttribute("class", "mailinput");
468 if(item === "address") {
469 input.setAttribute("type", "email"); // https://html5-tutorial.net/form-validation/validating-email/
470 input.required = true; // https://stackoverflow.com/questions/18770369/how-to-set-html5-required-attribute-in-javascript
471 } else {
472 input.setAttribute("type", "text");
473 }
474 td.appendChild(input);
475 tr.appendChild(td);
476 table.appendChild(tr);
477 }
478
479 // an empty line
480 tr = document.createElement('tr');
481 td = document.createElement('td');
482 td.appendChild(document.createElement('br'));
483 tr.appendChild(td);
484 table.appendChild(tr);
485
486 content.appendChild(table);
487
488 buildPreview(content);
489
490 //send button
491 input = document.createElement('input');
492 input.setAttribute("id", 'sendmail');
493 input.setAttribute("class", "sendbutton");
494 input.setAttribute("type", "button");
495 input.setAttribute("value", gs.text.berry.send);
496 content.appendChild(input);
497}
498
499function showEmail(){
500 var content = YAHOO.util.Dom.get('berryBasketContent');
501 var email = YAHOO.util.Dom.get('email');
502
503 berryCheckoutPageClear();
504
505 if (docList.length == 0){
506 content.appendChild(emptyBasketText());
507 return;
508 }
509
510 var item;
511 var tr;
512 var td;
513 var input;
514
515 table = document.createElement('table');
516 table.setAttribute("class","mailtable");
517
518 for (item in mailinfo){
519 tr = document.createElement('tr');
520 td = document.createElement('td');
521 td.setAttribute("class","mailitem");
522 td.appendChild(document.createTextNode(mailinfo[item]));
523 tr.appendChild(td);
524
525 td = document.createElement('td');
526 input = document.createElement('input');
527 input.setAttribute("id", item);
528 input.setAttribute("class", "mailinput");
529 if(item === "address") {
530 input.setAttribute("type", "email"); // https://html5-tutorial.net/form-validation/validating-email/
531 input.required = true; // https://stackoverflow.com/questions/18770369/how-to-set-html5-required-attribute-in-javascript
532 } else {
533 input.setAttribute("type", "text");
534 }
535 td.appendChild(input);
536 tr.appendChild(td);
537 table.appendChild(tr);
538
539 }
540
541 // an empty line
542 tr = document.createElement('tr');
543 td = document.createElement('td');
544 td.appendChild(document.createElement('br'));
545 tr.appendChild(td);
546 table.appendChild(tr);
547
548 content.appendChild(table);
549
550 buildPreview(content);
551
552 //send button
553 input = document.createElement('input');
554 input.setAttribute("id", 'sendmail');
555 input.setAttribute("class", "sendbutton");
556 input.setAttribute("type", "button");
557 input.setAttribute("value", gs.text.berry.send);
558 content.appendChild(input);
559
560 YAHOO.util.Event.addListener(input, 'click', navigate);
561}
562
563function buildPreview(parent){
564
565 var div = document.createElement('div');
566 var cb = document.createElement('input');
567 cb.setAttribute('class', 'sendbutton');
568 cb.type = 'button';
569 cb.id = 'urlcheck';
570 if (urlonly)
571 {
572 cb.value=gs.text.berry.url_and_metadata;
573 }
574 else
575 {
576 cb.value=gs.text.berry.url_only;
577 }
578
579 YAHOO.util.Event.addListener(cb, 'click', navigate);
580
581 var img = document.createElement('img');
582 img.src = 'interfaces/default/images/check3.gif';
583 img.id = 'urlcheck';
584 div.appendChild(cb);
585 //div.appendChild(img);
586
587 var urls = document.createElement('span');
588 urls.id = 'urls';
589 urls.className = 'berrycheck';
590 //urls.appendChild(document.createTextNode('URL only'));
591 div.appendChild(urls);
592
593 // var urlsmetadata = document.createElement('span');
594 // urlsmetadata.id = 'urlsmetadata'
595 // urlsmetadata.className = 'berryradio';
596 // urlsmetadata.appendChild(document.createTextNode('URLs and Metadata'));
597 // div.appendChild(urlsmetadata);
598
599 parent.appendChild(div);
600
601 var parea = document.createElement('textarea');
602 parea.id = 'pretextarea';
603 parea.required = true; // https://www.w3schools.com/tags/att_textarea_required.asp
604 // and https://stackoverflow.com/questions/18770369/how-to-set-html5-required-attribute-in-javascript
605
606 parent.appendChild(parea);
607
608 if(urlonly)
609 {
610 populateUrls(parea);
611 }
612 else
613 {
614 populateUrlsAndMetadata(parea);
615 }
616}
617
618function getDefaultLinkType(collection) {
619 var link_type;
620 if (document_link_collections.includes(collection)) {
621 link_type = "document";
622 } else if (source_link_collections.includes(collection)) {
623 link_type = "source";
624 }
625 else {
626 link_type = default_link_type;
627 if (link_type != "source" && link_type != "document") {
628 link_type = "document"; //the default default
629 }
630 }
631 return link_type;
632}
633
634function generateURL(doc) {
635
636 var url;
637 var doc_url = document.URL;
638 var root_url = doc_url.substring(0,doc_url.indexOf('?'));
639
640 var link_type = getDefaultLinkType(doc["collection"]);
641 if (link_type == "document") {
642 url = root_url+"/collection/"+doc["collection"]+"/document/"+doc["name"];
643 } else if (link_type == "source") {
644 url = root_url+"/sites/"+gs.xsltParams.site_name+"/collect/"+doc['collection']+"/index/assoc/"+doc["root_assocfilepath"]+"/"+doc["root_srclinkFile"];
645 }
646 return url;
647}
648
649
650function populateUrls(parea){
651
652 var urls="";
653 for (var i in docList){
654 var doc = docList[i];
655 urls += generateURL(doc)+"\n\n";
656 }
657
658 parea.value = urls;
659
660}
661
662function populateUrlsAndMetadata(parea){
663
664 var fulltext="";
665 for (var i in docList){
666 var doc = docList[i];
667 var url = generateURL(doc)+"\n";
668
669 var metadata = "";
670 if (doc['Title']) {
671 metadata += gs.text.berry.doc_title+": "+doc['Title']+"\n";
672 }
673 if (doc['root_Title']) {
674 metadata += gs.text.berry.doc_root_title+": "+doc['root_Title']+"\n";
675
676 }
677 if (doc['name']) {
678 metadata += gs.text.berry.doc_name+": "+doc['name']+"\n";
679 }
680 if (doc['collection']) {
681 metadata += gs.text.berry.doc_collection+": "+doc['collection']+"\n";
682 }
683 if (doc['Date']) {
684 metadata += gs.text.berry.doc_date+": "+doc['Date']+"\n";
685 }
686 // allow for inclusion of custom metadata
687 for (var m in doc) {
688 if (!default_metas.includes(m)) {
689 metadata += m +":" + doc[m]+"\n";
690 }
691 }
692 fulltext +=url+metadata+"\n";
693 }
694
695 parea.value = fulltext;
696
697}
698
699function sendMail(){
700 var url = gs.xsltParams.library_name + "?a=pr&rt=r&ro=1&s=SendMail&c=";
701 var request_type = "POST";
702 var postdata = "";
703 var i;
704
705 var content = YAHOO.util.Dom.get('pretextarea').value;
706
707 // To send an email, the To address and message Body must contain data.
708 // HTML5 input checking (required attribute) would make empty fields red outlined,
709 // but did not prevent Send button submitting form. So some basic sanity checking in JS:
710 // Checking non-empty and to address field must further be a URL: checking it contains @
711 var to_address = YAHOO.util.Dom.get('address').value;
712
713 if(to_address.trim() === "") {
714 alert(gs.text.berry.invalid_to_address_empty);
715 return;
716 } else if(to_address.indexOf('@') === -1) {
717 alert(gs.text.berry.invalid_to_address);
718 return;
719 } else if(content.trim() === "") {
720 alert(gs.text.berry.invalid_msg_body_empty);
721 return;
722 }
723
724 //get checked items
725 for (i in mailinfo) {
726 var input = YAHOO.util.Dom.get(i);
727 var value = input.value;
728 postdata +="&s1."+i+"="+value;
729 }
730
731
732 content = content.replace(/&/g,'-------');
733 postdata +="&s1.content="+content;
734
735 var callback = {
736 success: function(o) {
737 var result = o.responseText;
738 alert(gs.text.berry.send_success);
739 } ,
740 failure: function(o) {
741 alert(gs.text.berry.send_fail);
742 }
743 }
744 YAHOO.util.Connect.asyncRequest(request_type , url , callback, postdata);
745}
746
747function berryCheckoutPageClear() {
748 var bbc = document.getElementById('berryBasketContent');
749 if ( bbc == null ) return;
750 bbc.innerHTML = '';
751}
752
753function berryCheckoutHighlight( id ) {
754
755 for ( var i=0; i<options.length; i++ ) {
756 var option = document.getElementById( options[i] );
757 if ( option != null ) {
758 if ( id == options[i] ) {
759 //YAHOO.util.Dom.addClass( option, 'current' );
760 option.className='current';
761 } else {
762 //YAHOO.util.Dom.removeClass( option, 'current' );
763 option.className='';
764 }
765 }
766 }
767
768 if ( option == null ) return;
769 option.style.className = 'current';
770
771 var del_options = document.getElementById("delOptions");
772 if (id == "fullview") {
773 del_options.style.display = "block";
774 } else {
775 del_options.style.display = "none";
776 }
777}
778
779YAHOO.util.Event.addListener(window,'load', pageLoad);
780
781
Note: See TracBrowser for help on using the repository browser.