source: main/trunk/greenstone3/web/interfaces/default/js/favouritebasket/favouritecheckout.js@ 36069

Last change on this file since 36069 was 36069, checked in by kjdon, 2 years ago

tidying up the berry basket javascript for having only favouritebasket. new files are a straight copy from berrybasket files.

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