Changeset 33104 for main

Show
Ignore:
Timestamp:
23.05.2019 20:44:31 (5 months ago)
Author:
ak19
Message:

Implemented the deleteAll for berrybaskets.

Location:
main/trunk/greenstone3/web/interfaces/default
Files:
3 modified

Legend:

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

    r33049 r33104  
    1515 
    1616 
     17// adds berries onto page 
    1718var checkout = function(){ 
    1819 
  • main/trunk/greenstone3/web/interfaces/default/js/berrybasket/berrycheckout.js

    r33048 r33104  
    1818 
    1919var options = ['fullview', 'textview', 'email']; 
     20 
     21 
     22function deleteAll() { 
     23 
     24    if(docList.length == 0) return; // nothing to delete 
     25     
     26    var  delurl = delurlPath; // var delurlPath is declared in ygDDPlayer.js. 
     27    // Just need to append each doc id separated by |, but this character needs to be URL encoded, 
     28    // else the delete doesn't work. 
     29 
     30    for(var i = 0; i < docList.length; i++) { 
     31    var doc = docList[i]; 
     32    var doc_id = doc['collection']+":"+ doc['name']; 
     33 
     34    if((i+1) == docList.length) { // if it's the last id to process, don't append separator 
     35        delurl += doc_id; 
     36    } else { // there's more ids to process, so append separator 
     37        delurl += doc_id + "%7C"; // url-encoded version of | 
     38    } 
     39    } 
     40 
     41    // The following is a modified version of methods internal to 
     42    // ygDDPlayer.js's ygDDPlayer.prototype.onDragDrop 
     43    var delSuccess = function(o){  
     44    var result = o.responseXML; 
     45     
     46    docList.length = 0; // https://www.jstips.co/en/javascript/two-ways-to-empty-an-array/   
     47     
     48    var content =  YAHOO.util.Dom.get('berryBasketContent'); 
     49    while (content.hasChildNodes()) { 
     50        content.removeChild(content.firstChild); 
     51    }   
     52    content.appendChild(document.createTextNode('Your berry basket is empty.')); 
     53     
     54    var trashbin =  YAHOO.util.Dom.get('trashbin'); 
     55    if ( trashbin !=null){ 
     56        trashbin.style.background = 'url("interfaces/default/images/trash-full.png") 0 0 no-repeat'; 
     57    } 
     58 
     59    var delall_checkbox = YAHOO.util.Dom.get('delall-checkbox'); 
     60    delall_checkbox.checked = false; // deselect the delete-all checkbox 
     61    } 
     62 
     63    var delFailure = function(o){ alert("Deletion failed" + o);} 
     64     
     65    var delcallback = { 
     66    success:delSuccess, 
     67    failure:delFailure,   
     68    argument:null // supposed to be the ygDDPlayer object, but don't have a ref to it here, so trying null 
     69    } 
     70    // request_type defaults to GET, which is what's used for add and del, see ygDDPlayer.js. 
     71    YAHOO.util.Connect.asyncRequest(request_type, delurl , delcallback); 
     72     
     73} 
    2074 
    2175function navigate(e){ 
  • main/trunk/greenstone3/web/interfaces/default/transform/pages/berry.xsl

    r33050 r33104  
    5151            <div class="clear"><xsl:text> </xsl:text></div> 
    5252        </table> 
     53        <input type="checkbox" name="delall-checkbox" id="delall-checkbox" value="delete-all" onclick="deleteAll()">Delete All</input> 
    5354        <div id="berryBasketContent"><span><xsl:text> </xsl:text></span></div> 
    5455