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

Last change on this file since 33259 was 33259, checked in by davidb, 5 years ago

Javascript code to implements favourites. Done in a way to be compatible with keeping the original berry-picking code functional also

File size: 22.6 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(document.createTextNode('Your berry basket is empty.'));
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 favouritesbasket is on
296 showFullViewFavourites();
297 }
298}
299
300function showFullViewBerries(){
301
302 var content = YAHOO.util.Dom.get('berryBasketContent');
303 var fullview = YAHOO.util.Dom.get('fullview');
304 berryCheckoutPageClear();
305
306 if (docList.length == 0){
307 content.appendChild(document.createTextNode(gs.text.berry.empty_basket));
308 return;
309 }
310
311 var trashbin = document.createElement('div');
312 trashbin.id ='trashbin';
313
314 var binhandle = document.createElement('div');
315 binhandle.id = 'binhandle';
316 binhandle.appendChild(document.createElement('span'));
317 trashbin.appendChild(binhandle);
318 content.appendChild(trashbin);
319
320 var dd = new ygDDOnTop('trashbin');
321 dd.setHandleElId('binhandle');
322 new YAHOO.util.DDTarget('trashbin','trash');
323
324 var dlist = document.createElement('div');
325 content.appendChild(dlist);
326 var ol = document.createElement('ol');
327 dlist.appendChild(ol);
328
329 ol.setAttribute("id", "berryDocsList");
330
331 for (var i in docList){
332 var doc = docList[i];
333 var li = document.createElement('li');
334 var img = document.createElement('img');
335 var text ="";
336
337 var doc_id = doc['collection']+":"+ doc['name'];
338
339 img.setAttribute("src", berry_icon);
340 img.setAttribute("id", doc_id);
341 img.setAttribute("height", "15px");
342 img.setAttribute("width", "15px");
343 li.appendChild(img);
344
345 generateDocDisplay(li, doc, doc_id)
346 li.className = 'berrydoc';
347 ol.appendChild(li);
348 new ygDDPlayer(img.id,'trash',docList);
349 }
350
351}
352
353function showFullViewFavourites(){
354
355 var content = YAHOO.util.Dom.get('berryBasketContent');
356 var fullview = YAHOO.util.Dom.get('fullview');
357 berryCheckoutPageClear();
358
359 var berryBasketDelOptions = YAHOO.util.Dom.get('delOptions');
360 if (docList.length == 0){
361 content.appendChild(document.createTextNode(gs.text.berry.empty_basket));
362 if (berryBasketDelOptions != null) {
363 berryBasketDelOptions.setAttribute("style","display:none;");
364 }
365
366 return;
367 }
368 if (berryBasketDelOptions != null) {
369 berryBasketDelOptions.setAttribute("style","display:block;");
370 }
371
372 var dlist = document.createElement('div');
373 content.appendChild(dlist);
374 var ul = document.createElement('ul');
375 dlist.appendChild(ul);
376
377 ul.setAttribute("id", "berryDocsList");
378 ul.setAttribute("style","list-style: none;");
379
380 for (var i in docList){
381 var doc = docList[i];
382 var li = document.createElement('li');
383 var img = document.createElement('img');
384 var text ="";
385
386 var doc_id = doc['collection']+":"+ doc['name'];
387
388 img.setAttribute("src", gs.variables.selected_favourite_icon_url);
389 img.setAttribute("id", doc_id);
390 img.setAttribute("height", "20px");
391 img.setAttribute("width", "20px");
392 img.setAttribute("style","padding-right: 5px;"); // **** better to do this with CSS
393 img.setAttribute("onClick", "deleteFavouriteFromCheckout(this)");
394 li.appendChild(img);
395
396 generateDocDisplay(li, doc, doc_id)
397 li.className = 'berrydoc';
398 ul.appendChild(li);
399 }
400
401}
402
403function generateDocDisplay(li, doc, doc_id) {
404 var a = document.createElement('a');
405 var text="";
406 a.href=generateURL(doc);
407 a.appendChild(document.createTextNode(doc['Title']));
408
409 if (doc['root_Title']){
410 li.appendChild(document.createTextNode(doc['root_Title']+": "));
411 }
412
413 li.appendChild(a);
414 li.appendChild(document.createTextNode(" ("+doc['collection']+")"));
415 var metadata = "";
416 for (var metaItem in doc) {
417 if ( !default_metas.includes(metaItem)){
418 metadata += " "+metaItem+": "+ doc[metaItem]+" ";
419 }
420 }
421 text +=metadata;
422 li.appendChild(document.createTextNode(text));
423
424}
425
426function showTextView(){
427
428 var content = YAHOO.util.Dom.get('berryBasketContent');
429 var textview = YAHOO.util.Dom.get('textview');
430
431 berryCheckoutPageClear();
432 if (docList.length == 0){
433 content.appendChild(document.createTextNode(gs.text.berry.empty_basket));
434 return;
435 }
436 buildPreview(content);
437
438}
439
440function getEmailContent(content){
441 var item ;
442 var tr;
443 var td;
444 var input;
445
446 table = document.createElement('table');
447 table.setAttribute("class","mailtable");
448
449 for (item in mailinfo){
450 tr = document.createElement('tr');
451 td = document.createElement('td');
452 td.setAttribute("class","mailitem");
453 td.appendChild(document.createTextNode(mailinfo[item]));
454 tr.appendChild(td);
455 td = document.createElement('td');
456 input = document.createElement('input');
457 input.setAttribute("id", item);
458 input.setAttribute("class", "mailinput");
459 if(item === "address") {
460 input.setAttribute("type", "email"); // https://html5-tutorial.net/form-validation/validating-email/
461 input.required = true; // https://stackoverflow.com/questions/18770369/how-to-set-html5-required-attribute-in-javascript
462 } else {
463 input.setAttribute("type", "text");
464 }
465 td.appendChild(input);
466 tr.appendChild(td);
467 table.appendChild(tr);
468 }
469
470 // an empty line
471 tr = document.createElement('tr');
472 td = document.createElement('td');
473 td.appendChild(document.createElement('br'));
474 tr.appendChild(td);
475 table.appendChild(tr);
476
477 content.appendChild(table);
478
479 buildPreview(content);
480
481 //send button
482 input = document.createElement('input');
483 input.setAttribute("id", 'sendmail');
484 input.setAttribute("class", "sendbutton");
485 input.setAttribute("type", "button");
486 input.setAttribute("value", gs.text.berry.send);
487 content.appendChild(input);
488}
489
490function showEmail(){
491 var content = YAHOO.util.Dom.get('berryBasketContent');
492 var email = YAHOO.util.Dom.get('email');
493
494 berryCheckoutPageClear();
495
496 if (docList.length == 0){
497 content.appendChild(document.createTextNode(gs.text.berry.empty_basket));
498 return;
499 }
500
501 var item;
502 var tr;
503 var td;
504 var input;
505
506 table = document.createElement('table');
507 table.setAttribute("class","mailtable");
508
509 for (item in mailinfo){
510 tr = document.createElement('tr');
511 td = document.createElement('td');
512 td.setAttribute("class","mailitem");
513 td.appendChild(document.createTextNode(mailinfo[item]));
514 tr.appendChild(td);
515
516 td = document.createElement('td');
517 input = document.createElement('input');
518 input.setAttribute("id", item);
519 input.setAttribute("class", "mailinput");
520 if(item === "address") {
521 input.setAttribute("type", "email"); // https://html5-tutorial.net/form-validation/validating-email/
522 input.required = true; // https://stackoverflow.com/questions/18770369/how-to-set-html5-required-attribute-in-javascript
523 } else {
524 input.setAttribute("type", "text");
525 }
526 td.appendChild(input);
527 tr.appendChild(td);
528 table.appendChild(tr);
529
530 }
531
532 // an empty line
533 tr = document.createElement('tr');
534 td = document.createElement('td');
535 td.appendChild(document.createElement('br'));
536 tr.appendChild(td);
537 table.appendChild(tr);
538
539 content.appendChild(table);
540
541 buildPreview(content);
542
543 //send button
544 input = document.createElement('input');
545 input.setAttribute("id", 'sendmail');
546 input.setAttribute("class", "sendbutton");
547 input.setAttribute("type", "button");
548 input.setAttribute("value", gs.text.berry.send);
549 content.appendChild(input);
550
551 YAHOO.util.Event.addListener(input, 'click', navigate);
552}
553
554function buildPreview(parent){
555
556 var div = document.createElement('div');
557 var cb = document.createElement('input');
558 cb.setAttribute('class', 'sendbutton');
559 cb.type = 'button';
560 cb.id = 'urlcheck';
561 if (urlonly)
562 {
563 cb.value=gs.text.berry.url_and_metadata;
564 }
565 else
566 {
567 cb.value=gs.text.berry.url_only;
568 }
569
570 YAHOO.util.Event.addListener(cb, 'click', navigate);
571
572 var img = document.createElement('img');
573 img.src = 'interfaces/default/images/check3.gif';
574 img.id = 'urlcheck';
575 div.appendChild(cb);
576 //div.appendChild(img);
577
578 var urls = document.createElement('span');
579 urls.id = 'urls';
580 urls.className = 'berrycheck';
581 //urls.appendChild(document.createTextNode('URL only'));
582 div.appendChild(urls);
583
584 // var urlsmetadata = document.createElement('span');
585 // urlsmetadata.id = 'urlsmetadata'
586 // urlsmetadata.className = 'berryradio';
587 // urlsmetadata.appendChild(document.createTextNode('URLs and Metadata'));
588 // div.appendChild(urlsmetadata);
589
590 parent.appendChild(div);
591
592 var parea = document.createElement('textarea');
593 parea.id = 'pretextarea';
594 parea.required = true; // https://www.w3schools.com/tags/att_textarea_required.asp
595 // and https://stackoverflow.com/questions/18770369/how-to-set-html5-required-attribute-in-javascript
596
597 parent.appendChild(parea);
598
599 if(urlonly)
600 {
601 populateUrls(parea);
602 }
603 else
604 {
605 populateUrlsAndMetadata(parea);
606 }
607}
608
609function getDefaultLinkType(collection) {
610 var link_type;
611 if (document_link_collections.includes(collection)) {
612 link_type = "document";
613 } else if (source_link_collections.includes(collection)) {
614 link_type = "source";
615 }
616 else {
617 link_type = default_link_type;
618 if (link_type != "source" && link_type != "document") {
619 link_type = "document"; //the default default
620 }
621 }
622 return link_type;
623}
624
625function generateURL(doc) {
626
627 var url;
628 var doc_url = document.URL;
629 var root_url = doc_url.substring(0,doc_url.indexOf('?'));
630
631 var link_type = getDefaultLinkType(doc["collection"]);
632 if (link_type == "document") {
633 url = root_url+"/collection/"+doc["collection"]+"/document/"+doc["name"];
634 } else if (link_type == "source") {
635 url = root_url+"/sites/"+gs.xsltParams.site_name+"/collect/"+doc['collection']+"/index/assoc/"+doc["root_assocfilepath"]+"/"+doc["root_srclinkFile"];
636 }
637 return url;
638}
639
640
641function populateUrls(parea){
642
643 var urls="";
644 for (var i in docList){
645 var doc = docList[i];
646 urls += generateURL(doc)+"\n\n";
647 }
648
649 parea.value = urls;
650
651}
652
653function populateUrlsAndMetadata(parea){
654
655 var fulltext="";
656 for (var i in docList){
657 var doc = docList[i];
658 var url = generateURL(doc)+"\n";
659
660 var metadata = "";
661 if (doc['Title']) {
662 metadata += gs.text.berry.doc_title+": "+doc['Title']+"\n";
663 }
664 if (doc['root_Title']) {
665 metadata += gs.text.berry.doc_root_title+": "+doc['root_Title']+"\n";
666
667 }
668 if (doc['name']) {
669 metadata += gs.text.berry.doc_name+": "+doc['name']+"\n";
670 }
671 if (doc['collection']) {
672 metadata += gs.text.berry.doc_collection+": "+doc['collection']+"\n";
673 }
674 if (doc['Date']) {
675 metadata += gs.text.berry.doc_date+": "+doc['Date']+"\n";
676 }
677 // allow for inclusion of custom metadata
678 for (var m in doc) {
679 if (!default_metas.includes(m)) {
680 metadata += m +":" + doc[m]+"\n";
681 }
682 }
683 fulltext +=url+metadata+"\n";
684 }
685
686 parea.value = fulltext;
687
688}
689
690function sendMail(){
691 var url = gs.xsltParams.library_name + "?a=pr&rt=r&ro=1&s=SendMail&c=";
692 var request_type = "POST";
693 var postdata = "";
694 var i;
695
696 var content = YAHOO.util.Dom.get('pretextarea').value;
697
698 // To send an email, the To address and message Body must contain data.
699 // HTML5 input checking (required attribute) would make empty fields red outlined,
700 // but did not prevent Send button submitting form. So some basic sanity checking in JS:
701 // Checking non-empty and to address field must further be a URL: checking it contains @
702 var to_address = YAHOO.util.Dom.get('address').value;
703
704 if(to_address.trim() === "") {
705 alert(gs.text.berry.invalid_to_address_empty);
706 return;
707 } else if(to_address.indexOf('@') === -1) {
708 alert(gs.text.berry.invalid_to_address);
709 return;
710 } else if(content.trim() === "") {
711 alert(gs.text.berry.invalid_msg_body_empty);
712 return;
713 }
714
715 //get checked items
716 for (i in mailinfo) {
717 var input = YAHOO.util.Dom.get(i);
718 var value = input.value;
719 postdata +="&s1."+i+"="+value;
720 }
721
722
723 content = content.replace(/&/g,'-------');
724 postdata +="&s1.content="+content;
725
726 var callback = {
727 success: function(o) {
728 var result = o.responseText;
729 alert(gs.text.berry.send_success);
730 } ,
731 failure: function(o) {
732 alert(gs.text.berry.send_fail);
733 }
734 }
735 YAHOO.util.Connect.asyncRequest(request_type , url , callback, postdata);
736}
737
738function berryCheckoutPageClear() {
739 var bbc = document.getElementById('berryBasketContent');
740 if ( bbc == null ) return;
741 bbc.innerHTML = '';
742}
743
744function berryCheckoutHighlight( id ) {
745
746 for ( var i=0; i<options.length; i++ ) {
747 var option = document.getElementById( options[i] );
748 if ( option != null ) {
749 if ( id == options[i] ) {
750 //YAHOO.util.Dom.addClass( option, 'current' );
751 option.className='current';
752 } else {
753 //YAHOO.util.Dom.removeClass( option, 'current' );
754 option.className='';
755 }
756 }
757 }
758
759 if ( option == null ) return;
760 option.style.className = 'current';
761
762 var del_options = document.getElementById("delOptions");
763 if (id == "fullview") {
764 del_options.style.display = "block";
765 } else {
766 del_options.style.display = "none";
767 }
768}
769
770YAHOO.util.Event.addListener(window,'load', pageLoad);
771
772
Note: See TracBrowser for help on using the repository browser.