Ignore:
Timestamp:
2014-11-17T11:08:04+13:00 (9 years ago)
Author:
sjs49
Message:

Collection names now load dynamically instead of being hard-coded into dropdowns

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-sites-dev/von-sparql/js/von-sparql-comparison-setup.js

    r29423 r29434  
    5050
    5151function setupPage(){
     52    //load available collection names into dropdown lists
     53
    5254    sgvizler_setup();
     55
     56    populateCollectionDropdowns();
     57
    5358    //Load collection names from dropdown boxes
    5459    leftCollection = $('#sel_leftCollection').val();
    5560    rightCollection = $('#sel_rightCollection').val();
    56    
     61
     62
    5763    //Draw buttons, etc for each side of page
    5864    drawSide("left",leftCollection);
     
    6672    //populates predicate dropdown boxes
    6773    populatePredicateSelector("all", "sel_comparisonPredicate");
     74}
     75
     76//Loads collection names into seletors
     77function populateCollectionDropdowns(){
     78    var path = location.pathname;
     79    var libraryName = path.split("/")[2];
     80    var url = location.protocol + '//' + location.hostname + ":" +  location.port + "/greenstone3/" + libraryName + "?o=xml" ;
     81
     82    //Ajax to get page xml
     83    $.ajax({
     84        url: url,
     85        type:"GET",
     86        async: false,
     87    })
     88    .done(function( xmlDoc ) {
     89        //foreach collection returned
     90        $("#sel_leftCollection").empty();       
     91        $("#sel_rightCollection").empty();     
     92        $(xmlDoc).find("page pageResponse collectionList collection").each(function(){
     93            var name = $(this).attr("name");
     94            $("#sel_leftCollection").append("<option value=\"" + name + "\">" + name + " </option>");
     95            $("#sel_rightCollection").append("<option value=\"" + name + "\">" + name + " </option>");
     96        });
     97    });
     98   
    6899}
    69100
Note: See TracChangeset for help on using the changeset viewer.