Changeset 33152 for main


Ignore:
Timestamp:
06/15/19 15:22:40 (18 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)

File:
1 edited

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
Note: See TracChangeset for help on using the changeset viewer.