views:

80

answers:

0

Im having problems getting the results sorted by date in my search...

In the API reference it says i have to use: videoSearch.setResultOrder(google.search.Search.ORDER_BY_DATE);

But when using this, my script stops working...

The code:

function OnLoad() {

    // Create a search control
    searchControl = new google.search.SearchControl();

    // Set the Search Control to get the most number of results       
    searchControl.setResultSetSize (google.search.Search.LARGE_RESULTSET); 
  //videoSearch.setResultOrder(google.search.Search.ORDER_BY_DATE);
    var options = new google.search.SearcherOptions(); 

    options.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN); 

    // Add in a full set of searchers
    //var localSearch = new google.search.LocalSearch();
    //searchControl.addSearcher(localSearch);
    //searchControl.addSearcher(new google.search.WebSearch());
    searchControl.addSearcher(new google.search.VideoSearch());
    //searchControl.addSearcher(new google.search.BlogSearch());

  // Set the result order of the search - check docs for other orders
    searchControl.setResultOrder(google.search.Search.ORDER_BY_DATE);

    // Set the Local Search center point
    //localSearch.setCenterPoint("New York, NY");

    // Tell the searcher to draw itself and tell it where to attach
    searchControl.draw(document.getElementById("searchcontrol"));

    // STH: Setup handler when result found
    searchControl.setSearchCompleteCallback(Bleau, Bleau.searchCompleteCallback)
    //var userid = "<xsl:value-of select="$youtubeID" />";
    // Execute an inital search
    //searchControl.execute("ytchannel:tvskive");
    doSearch(soegeord);
    //searchControl.execute("test");

    $('.gsc-result-selector .gsc-more-results:first').click();
  }
  google.setOnLoadCallback(OnLoad);