Changeset 33322 for main/trunk


Ignore:
Timestamp:
2019-07-11T17:23:18+12:00 (5 years ago)
Author:
ak19
Message:

Getting faceted searching working with the map shapes.

Location:
main/trunk/greenstone3/web/interfaces/default/js
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/js/facet-scripts.js

    r33286 r33322  
    5050   
    5151    countsString += "&";
    52     console.log("STRING IS " + countsString);
     52    //console.log("STRING IS " + countsString);
    5353   
    5454    $.ajax(gs.xsltParams.library_name + "/collection/" + gs.cgiParams.c + "/search/" + gs.cgiParams.s + "?" + searchString + countsString + "excerptid=resultsArea")
    5555        .done(function(response)
    56         {
     56            {
    5757            $("#resultsArea").html("");
    5858            $("#resultsArea").html(response.substring(response.indexOf(">") + 1, response.lastIndexOf("<")));
     
    6363                    favouritesCheckout(); // called to add back in favourites icons (if favouritebasket active)
    6464            }
     65              if(typeof mapEnabled !== 'undefined') {                 
     66                 
     67                  facetedMapSearch(gs.xsltParams.library_name + "/collection/" + gs.cgiParams.c + "/search/" + gs.cgiParams.s + "?" + searchString + countsString);
     68                 
     69              }
    6570        });
    6671}
  • main/trunk/greenstone3/web/interfaces/default/js/map-scripts.js

    r33317 r33322  
    2121var _searchRunning = false;
    2222var _nearbyDocsByDistance = [];
    23 var _scrollThroughDefault = true;
     23var _scrollThroughDefault = true; // TODO: default is true
    2424
    2525var LOW_OPACITY = 0.1; // make surrounding docs' opacity 10%
     
    128128function performProximitySearch()
    129129{
     130    //console.log("@@@@ skipping proximity search for now");
     131    //return;
     132   
    130133    _gsDebug("*** START OF performProximitySearch()");
    131134   
     
    355358}
    356359
     360function facetedMapSearch(facet_request_url) {
     361    // ask for just the jsonNodes
     362    facet_request_url += "excerptid=jsonNodes";
     363   
     364    $.ajax(facet_request_url).done(function(responseText) {
     365    var doc;
     366    var nodeID;
     367   
     368    console.log("Sent off facetedMapSearch request to " + facet_request_url +  ", got response: ");
     369    console.log(responseText);
     370
     371    if(responseText.search("id=\"jsonNodes") != -1) {
     372        var startIndex = responseText.indexOf(">");
     373        var endIndex = responseText.indexOf("</");
     374        var jsonNodes = eval(responseText.substring(startIndex+1, endIndex));
     375        console.log(jsonNodes);
     376   
     377       
     378        if(jsonNodes && jsonNodes.length > 0) {
     379            console.log("Got some nodes. Removing all markers first...");
     380
     381       
     382        mapEnabled = true;
     383        showMap("initializeMapScripts");
     384
     385        // Remove all the markers/shapes from map
     386        // and empty _docList.ids and the _docList of items
     387        for(var j = 0; j < _docList.ids.length; j++) {
     388            nodeID = _docList.ids[j];
     389            doc = _docList.getDocByIndex(j);
     390            removeMarkersFromMap(doc);
     391            delete _docList[nodeID];
     392        }
     393        _docList.ids = [];
     394
     395        // repopulate _docList and _docList.ids and plot on map
     396        for(var i = 0; i < jsonNodes.length; i++)
     397        {
     398            _docList[jsonNodes[i].nodeID] = jsonNodes[i];
     399            _docList.ids.push(jsonNodes[i].nodeID);
     400            var options = {
     401            "mainDoc": true
     402            };
     403            console.log("#### " + jsonNodes[i].nodeID + " is a main doc: ");
     404            console.log(jsonNodes[i]);
     405            createOverlayItems(jsonNodes[i], options);
     406        }
     407
     408        // redo map bounds, which will also performProximitySearch
     409        updateMap();
     410        }
     411        else
     412        {
     413        //hiding the map
     414        mapEnabled = false;
     415        hideMap("initializeMapScripts");       
     416        }
     417    }   
     418    _docList.loopIndex = 0;
     419   
     420    });
     421   
     422}
     423
     424
    357425function toggleMapSection(options)
    358426{
Note: See TracChangeset for help on using the changeset viewer.