Changeset 33152 for main

Show
Ignore:
Timestamp:
15.06.2019 15:22:40 (4 months ago)
Author:
davidb
Message:

Additional method added, similar to the start checkout(), but counts the number of items in the berrybasket. Useful to decide if on a page (such as the About page) to show a link to the berry basket (because you have items in it)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/js/berrybasket/berrybasket.js

    r33104 r33152  
    1313var dd = new ygDDOnTop('berrybasket'); 
    1414dd.setHandleElId('baskethandle'); 
     15 
     16var countBerries = function(callback) { 
     17 
     18    var request_type = "GET"; 
     19    var url = gs.xsltParams.library_name + "?a=pr&rt=r&ro=1&s=ItemNum&o=XML&hhf="+makeURLComponentSafe("[{\"name\":\"Cache-Control\", \"value\":\"no-cache\"}]")+"&c="; 
     20 
     21    var responseSuccess = function(o) { 
     22         
     23    var response = o.responseXML; 
     24    var size = response.getElementsByTagName('size').item(0).getAttribute('value'); 
     25     
     26    var items = response.getElementsByTagName('item'); 
     27 
     28    callback(items.length); 
     29    } 
     30 
     31    YAHOO.util.Connect.asyncRequest(request_type , url , {success: responseSuccess }); 
     32} 
    1533 
    1634 
     
    89107 
    90108    var responseFailure = function(o){ 
    91         alert("CHECKOUT FAILED"); 
     109        console.error("Berry Basket GetItems AJAX call failed:" + url); 
    92110    } 
    93111